Commit 1bf833c2 authored by jonnybradley's avatar jonnybradley

[FIX] plugin edit: Move dialogSelectElement function back into tiki-jquery.js...

[FIX] plugin edit: Move dialogSelectElement function back into tiki-jquery.js as it's called from the popupPluginForm fn and was failing if (for instance) you had a wikiplugin tool on a toolbar without a Picker or Dialog type tool there also (which would include tiki-toolbars.js)
parent d9cb316f
......@@ -785,6 +785,42 @@ function handlePluginFieldsHierarchy(type) {
});
}
function dialogSelectElement( area_id, elementStart, elementEnd ) {
if (typeof CKEDITOR !== 'undefined' && typeof CKEDITOR.instances[area_id] !== 'undefined') {return;} // TODO for ckeditor
var $textarea = $('#' + area_id);
var textareaEditor = syntaxHighlighter.get($textarea);
var val = ( textareaEditor ? textareaEditor.getValue() : $textarea.val() );
var pairs = [], pos = 0, s = 0, e = 0;
while (s > -1 && e > -1) { // positions of start/end markers
s = val.indexOf(elementStart, e);
if (s > -1) {
e = val.indexOf(elementEnd, s + elementStart.length);
if (e > -1) {
e += elementEnd.length;
pairs[pairs.length] = [ s, e ];
}
}
}
(textareaEditor ? textareaEditor : $textarea[0]).focus();
var selection = ( textareaEditor ? syntaxHighlighter.selection(textareaEditor, true) : $textarea.selection() );
s = selection.start;
e = selection.end;
var st = $textarea.attr('scrollTop');
for (var i = 0; i < pairs.length; i++) {
if (s >= pairs[i][0] && e <= pairs[i][1]) {
setSelectionRange($textarea[0], pairs[i][0], pairs[i][1]);
break;
}
}
}
/*
* JS only textarea fullscreen function (for Tiki 5+)
*/
......
......@@ -154,42 +154,6 @@ function displayPicker( closeTo, list, area_id, isSheet, styleType ) {
}
function dialogSelectElement( area_id, elementStart, elementEnd ) {
if (typeof CKEDITOR !== 'undefined' && typeof CKEDITOR.instances[area_id] !== 'undefined') {return;} // TODO for ckeditor
var $textarea = $('#' + area_id);
var textareaEditor = syntaxHighlighter.get($textarea);
var val = ( textareaEditor ? textareaEditor.getValue() : $textarea.val() );
var pairs = [], pos = 0, s = 0, e = 0;
while (s > -1 && e > -1) { // positions of start/end markers
s = val.indexOf(elementStart, e);
if (s > -1) {
e = val.indexOf(elementEnd, s + elementStart.length);
if (e > -1) {
e += elementEnd.length;
pairs[pairs.length] = [ s, e ];
}
}
}
(textareaEditor ? textareaEditor : $textarea[0]).focus();
var selection = ( textareaEditor ? syntaxHighlighter.selection(textareaEditor, true) : $textarea.selection() );
s = selection.start;
e = selection.end;
var st = $textarea.attr('scrollTop');
for (var i = 0; i < pairs.length; i++) {
if (s >= pairs[i][0] && e <= pairs[i][1]) {
setSelectionRange($textarea[0], pairs[i][0], pairs[i][1]);
break;
}
}
}
function dialogSharedClose( area_id, dialog ) {
$(dialog).dialog("close");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment