Loading...
 
Features / Usability

Features / Usability


Pseudo qysiwyg for wikis

posts: 80 Austria

To get pseudo wysiwyg for all edits where you have smiley inserts you have to edit 2 files: lib/tiki-js.js andtemplates/tiki-smileys.tpl

First replace the function insertAt (around line 270) in lib/tiki-js.js

Copy to clipboard
// Edit lib/tiki-js.js // replace the function insertAt(elementId, replaceString) with the folowing function to get pseudo wysiwyg: function insertAt(elementId, replaceString, enclose) { // enclose for wysiwyg //inserts given text at selection or cursor position textarea = getElementById(elementId); var toBeReplaced = /text|page|area_name/;//substrings in replaceString to be replaced by the selection if a selection was done if (textarea.setSelectionRange) { //Mozilla UserAgent Gecko-1.4 var selectionStart = textarea.selectionStart; var selectionEnd = textarea.selectionEnd; var scrollTop=textarea.scrollTop; if (selectionStart != selectionEnd) { // has there been a selection // wysiwyg if (enclose) { var newString = replaceString + textarea.value.substring(selectionStart, selectionEnd) + enclose; } else { var newString = replaceString.replace(toBeReplaced, textarea.value.substring(selectionStart, selectionEnd)); } textarea.value = textarea.value.substring(0, selectionStart) + newString + textarea.value.substring(selectionEnd); setSelectionRange(textarea, selectionStart, selectionStart + newString.length); } else {// set caret if (enclose) { textarea.value = textarea.value.substring(0, selectionStart) + replaceString + enclose + textarea.value.substring(selectionEnd); } else { textarea.value = textarea.value.substring(0, selectionStart) + replaceString + textarea.value.substring(selectionEnd); } setCaretToPos(textarea, selectionStart + replaceString.length); } textarea.scrollTop=scrollTop; } else if (document.selection) { //UserAgent IE-6.0 textarea.focus(); var range = document.selection.createRange(); if (range.parentElement() == textarea) { var isCollapsed = range.text == ''; if (! isCollapsed) { if (enclose) { range.text = replaceString + range.text + enclose } else { range.text = replaceString.replace(toBeReplaced, range.text); } range.moveStart('character', -range.text.length); range.select(); } else { range.text = replaceString; } } } else { //UserAgent Gecko-1.0.1 (NN7.0) setSomeElement(elementId, replaceString) //alert("don't know yet how to handle insert" + document); } }

You can insert in templates/tiki-smileys.tpl
after the normal smileys the content of the attached file.
Unfortunaltely i cannot post this into CODE plugin du to literal tags inside:

There are no comments at this time.

Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting