* Adapted serendipity_editor.js to provide more global (though
deprecated) API access methods for plugins like amazonchooser and linktrimmer, to perform insertion. Also fixed the insertion of text when the ID of the element is not prefixed (You may need to reload your browsercache to get the new JS)
This commit is contained in:
@ -4,6 +4,11 @@
|
|||||||
Version 2.0-beta3 ()
|
Version 2.0-beta3 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Adapted serendipity_editor.js to provide more global (though
|
||||||
|
deprecated) API access methods for plugins like amazonchooser
|
||||||
|
and linktrimmer, to perform insertion. Also fixed the
|
||||||
|
insertion of text when the ID of the element is not prefixed
|
||||||
|
|
||||||
* Move sort by name to simple filter in ML, replace file extension
|
* Move sort by name to simple filter in ML, replace file extension
|
||||||
|
|
||||||
* Remember selected media library folder
|
* Remember selected media library folder
|
||||||
|
@ -66,6 +66,11 @@
|
|||||||
|
|
||||||
// http://stackoverflow.com/questions/1712417/jquery-wrap-selected-text-in-a-textarea
|
// http://stackoverflow.com/questions/1712417/jquery-wrap-selected-text-in-a-textarea
|
||||||
var $txtarea = $(txtarea);
|
var $txtarea = $(txtarea);
|
||||||
|
|
||||||
|
if (!$txtarea.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var len = $txtarea.val().length;
|
var len = $txtarea.val().length;
|
||||||
var start = $txtarea[0].selectionStart;
|
var start = $txtarea[0].selectionStart;
|
||||||
var end = $txtarea[0].selectionEnd;
|
var end = $txtarea[0].selectionEnd;
|
||||||
@ -73,8 +78,8 @@
|
|||||||
var replacement = openTag + selectedText + closeTag;
|
var replacement = openTag + selectedText + closeTag;
|
||||||
$txtarea.val($txtarea.val().substring(0, start) + replacement + $txtarea.val().substring(end, len));
|
$txtarea.val($txtarea.val().substring(0, start) + replacement + $txtarea.val().substring(end, len));
|
||||||
|
|
||||||
$txtarea[0].selectionStart = start + replacement.length
|
$txtarea[0].selectionStart = start + replacement.length;
|
||||||
$txtarea[0].selectionEnd = start + replacement.length
|
$txtarea[0].selectionEnd = start + replacement.length;
|
||||||
|
|
||||||
if (scrollPos) {
|
if (scrollPos) {
|
||||||
txtarea.focus();
|
txtarea.focus();
|
||||||
@ -243,7 +248,19 @@
|
|||||||
// which works fine in NO WYSIWYG mode
|
// which works fine in NO WYSIWYG mode
|
||||||
// NOTE: the serendipity_imageSelector_addToBody could add any valid HTML string to the textarea
|
// NOTE: the serendipity_imageSelector_addToBody could add any valid HTML string to the textarea
|
||||||
serendipity.noWysiwygAdd = function(str, textarea) {
|
serendipity.noWysiwygAdd = function(str, textarea) {
|
||||||
serendipity.wrapSelection($('#'+serendipity.escapeBrackets(textarea)), str, '');
|
escapedElement = serendipity.escapeBrackets(textarea);
|
||||||
|
if ($('#' + escapedElement).length) {
|
||||||
|
// Proper ID was specified (hopefully by plugins)
|
||||||
|
} else {
|
||||||
|
// Let's try the serendipity[] prefix
|
||||||
|
escapedElement = serendipity.escapeBrackets('serendipity[' + textarea + ']');
|
||||||
|
|
||||||
|
if (!$('#' + escapedElement).length) {
|
||||||
|
console.log("Serendipity plugin error: " + escapedElement + " not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serendipity.wrapSelection($('#'+escapedElement), str, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserting media db img markup including s9y-specific container markup
|
// Inserting media db img markup including s9y-specific container markup
|
||||||
@ -1463,7 +1480,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// This is kept for older plugins. Use of $(document).ready() is encouraged.
|
// This is kept for older plugins. Use of $(document).ready() is encouraged.
|
||||||
// At some point, this will be removed.
|
// At some point, these will be removed.
|
||||||
addLoadEvent = function(func) {
|
addLoadEvent = function(func) {
|
||||||
var oldonload = window.onload;
|
var oldonload = window.onload;
|
||||||
if (typeof window.onload != 'function') {
|
if (typeof window.onload != 'function') {
|
||||||
@ -1475,3 +1492,18 @@ $(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Several plugins use this in the global scope. Those API functions are
|
||||||
|
// vital, so they reference to our new serendipity scope. This global
|
||||||
|
// scope is deprecated and subject to removal in the future.
|
||||||
|
serendipity_imageSelector_addToBody = function(block, textarea) {
|
||||||
|
return serendipity.serendipity_imageSelector_addToBody(block, textarea);
|
||||||
|
}
|
||||||
|
|
||||||
|
serendipity_imageSelector_done = function(textarea) {
|
||||||
|
return serendipity.serendipity_imageSelector_done(textarea);
|
||||||
|
}
|
||||||
|
|
||||||
|
serendipity_imageSelector_addToElement = function(str, id) {
|
||||||
|
return serendipity.serendipity_imageSelector_addToElement(str, id);
|
||||||
|
}
|
Reference in New Issue
Block a user