Fix QTags.closeAllTags(), replace 'tb' with 'ed' in quicktags,js to make it clear it is the editor instance not the toolbar, small comments quick edit fixes, see #16695, fixes #15911
git-svn-id: http://svn.automattic.com/wordpress/trunk@18576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
35f5d1cefb
commit
6041cd0410
|
@ -356,6 +356,9 @@ commentReply = {
|
|||
if ( this.cid ) {
|
||||
c = $('#comment-' + this.cid);
|
||||
|
||||
if ( typeof QTags != 'undefined' )
|
||||
QTags.closeAllTags('replycontent');
|
||||
|
||||
if ( this.act == 'edit-comment' )
|
||||
c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
|
||||
|
||||
|
@ -365,18 +368,14 @@ commentReply = {
|
|||
$('input', '#edithead').val('');
|
||||
$('.error', '#replysubmit').html('').hide();
|
||||
$('.waiting', '#replysubmit').hide();
|
||||
|
||||
if ( $.browser.msie )
|
||||
$('#replycontainer, #replycontent').css('height', '120px');
|
||||
else
|
||||
$('#replycontainer').resizable('destroy').css('height', '120px');
|
||||
$('#replycontainer, #replycontent').height(120);
|
||||
|
||||
this.cid = '';
|
||||
}
|
||||
},
|
||||
|
||||
open : function(id, p, a) {
|
||||
var t = this, editRow, rowData, act, h, c = $('#comment-' + id), replyButton;
|
||||
var t = this, editRow, rowData, act, c = $('#comment-' + id), h = c.height(), replyButton;
|
||||
|
||||
t.close();
|
||||
t.cid = id;
|
||||
|
@ -389,6 +388,9 @@ commentReply = {
|
|||
$('#comment_post_ID', editRow).val(p);
|
||||
$('#comment_ID', editRow).val(id);
|
||||
|
||||
if ( h > 220 )
|
||||
$('#replycontainer, #replycontent', editRow).height(h-104);
|
||||
|
||||
if ( a == 'edit' ) {
|
||||
$('#author', editRow).val( $('div.author', rowData).text() );
|
||||
$('#author-email', editRow).val( $('div.author-email', rowData).text() );
|
||||
|
@ -398,13 +400,6 @@ commentReply = {
|
|||
$('#edithead, #savebtn', editRow).show();
|
||||
$('#replyhead, #replybtn', editRow).hide();
|
||||
|
||||
h = c.height();
|
||||
if ( h > 220 )
|
||||
if ( $.browser.msie )
|
||||
$('#replycontainer, #replycontent', editRow).height(h-105);
|
||||
else
|
||||
$('#replycontainer', editRow).height(h-105);
|
||||
|
||||
c.after( editRow ).fadeOut('fast', function(){
|
||||
$('#replyrow').fadeIn(300, function(){ $(this).show() });
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,9 @@ var switchEditors = {
|
|||
if ( ed && ! ed.isHidden() )
|
||||
return false;
|
||||
|
||||
if ( typeof(QTags) != 'undefined' )
|
||||
QTags.closeAllTags(id);
|
||||
|
||||
if ( tinyMCEPreInit.mceInit[id] && tinyMCEPreInit.mceInit[id].wpautop )
|
||||
txtarea_el.value = t.wpautop( txtarea_el.value );
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
var switchEditors={go:function(j){var k=this,d=j.id,e=d.length,b=d.substr(0,e-5),g=d.substr(e-4),h=tinyMCE.get(b),i="wp-"+b+"-wrap",f=tinymce.DOM,c=f.get(b);if("tmce"==g){if(h&&!h.isHidden()){return false}if(tinyMCEPreInit.mceInit[b]&&tinyMCEPreInit.mceInit[b].wpautop){c.value=k.wpautop(c.value)}if(h){h.show()}else{h=new tinymce.Editor(b,tinyMCEPreInit.mceInit[b]);h.render()}f.removeClass(i,"html-active");f.addClass(i,"tmce-active");setUserSetting("editor","tinymce")}else{if("html"==g){if(h&&h.isHidden()){return false}if(h){c.style.height=h.getContentAreaContainer().offsetHeight+20+"px";h.hide()}f.removeClass(i,"tmce-active");f.addClass(i,"html-active");setUserSetting("editor","html")}}return false},_wp_Nop:function(b){var c,a;if(b.indexOf("<pre")!=-1||b.indexOf("<script")!=-1){b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>(\r\n|\n)?/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"<wp_temp>")})}c="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","g"),"</$1>\n");b=b.replace(new RegExp("\\s*<((?:"+c+")(?: [^>]*)?)>","g"),"\n<$1>");b=b.replace(/(<p [^>]+>.*?)<\/p>/g,"$1</p#>");b=b.replace(/<div( [^>]*)?>\s*<p>/gi,"<div$1>\n\n");b=b.replace(/\s*<p>/gi,"");b=b.replace(/\s*<\/p>\s*/gi,"\n\n");b=b.replace(/\n[\s\u00a0]+\n/g,"\n\n");b=b.replace(/\s*<br ?\/?>\s*/gi,"\n");b=b.replace(/\s*<div/g,"\n<div");b=b.replace(/<\/div>\s*/g,"</div>\n");b=b.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");b=b.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";b=b.replace(new RegExp("\\s*<((?:"+a+")(?: [^>]*)?)\\s*>","g"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","g"),"</$1>\n");b=b.replace(/<li([^>]*)>/g,"\t<li$1>");if(b.indexOf("<hr")!=-1){b=b.replace(/\s*<hr( [^>]*)?>\s*/g,"\n\n<hr$1>\n\n")}if(b.indexOf("<object")!=-1){b=b.replace(/<object[\s\S]+?<\/object>/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(/<\/p#>/g,"</p>\n");b=b.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g,"\n$1");b=b.replace(/^\s+/,"");b=b.replace(/[\s\u00a0]+$/,"");b=b.replace(/<wp_temp>/g,"\n");return b},_wp_Autop:function(a){var b="table|thead|tfoot|tbody|tr|td|th|caption|col|colgroup|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr|noscript|menu|samp|header|footer|article|section|hgroup|nav|aside|details|summary";if(a.indexOf("<object")!=-1){a=a.replace(/<object[\s\S]+?<\/object>/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});if(a.indexOf("<pre")!=-1||a.indexOf("<script")!=-1){a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){return c.replace(/(\r\n|\n)/g,"<wp_temp_br>")})}a=a+"\n\n";a=a.replace(/<br \/>\s*<br \/>/gi,"\n\n");a=a.replace(new RegExp("(<(?:"+b+")(?: [^>]*)?>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n");a=a.replace(/\r\n|\r/g,"\n");a=a.replace(/\n\s*\n+/g,"\n\n");a=a.replace(/([\s\S]+?)\n\n/g,"<p>$1</p>\n");a=a.replace(/<p>\s*?<\/p>/gi,"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/<p>(<li.+?)<\/p>/gi,"$1");a=a.replace(/<p>\s*<blockquote([^>]*)>/gi,"<blockquote$1><p>");a=a.replace(/<\/blockquote>\s*<\/p>/gi,"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/\s*\n/gi,"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1");a=a.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi,"[caption$1[/caption]");a=a.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(e,d,f){if(f.match(/<p( [^>]*)?>/)){return e}return d+"<p>"+f+"</p>"});a=a.replace(/<wp_temp_br>/g,"\n");return a},pre_wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jQuery)!="undefined";if(c){jQuery("body").trigger("beforePreWpautop",[d])}d.data=a._wp_Nop(d.data);if(c){jQuery("body").trigger("afterPreWpautop",[d])}return d.data},wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jQuery)!="undefined";if(c){jQuery("body").trigger("beforeWpautop",[d])}d.data=a._wp_Autop(d.data);if(c){jQuery("body").trigger("afterWpautop",[d])}return d.data}};
|
||||
var switchEditors={go:function(j){var k=this,d=j.id,e=d.length,b=d.substr(0,e-5),g=d.substr(e-4),h=tinyMCE.get(b),i="wp-"+b+"-wrap",f=tinymce.DOM,c=f.get(b);if("tmce"==g){if(h&&!h.isHidden()){return false}if(typeof(QTags)!="undefined"){QTags.closeAllTags(b)}if(tinyMCEPreInit.mceInit[b]&&tinyMCEPreInit.mceInit[b].wpautop){c.value=k.wpautop(c.value)}if(h){h.show()}else{h=new tinymce.Editor(b,tinyMCEPreInit.mceInit[b]);h.render()}f.removeClass(i,"html-active");f.addClass(i,"tmce-active");setUserSetting("editor","tinymce")}else{if("html"==g){if(h&&h.isHidden()){return false}if(h){c.style.height=h.getContentAreaContainer().offsetHeight+20+"px";h.hide()}f.removeClass(i,"tmce-active");f.addClass(i,"html-active");setUserSetting("editor","html")}}return false},_wp_Nop:function(b){var c,a;if(b.indexOf("<pre")!=-1||b.indexOf("<script")!=-1){b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>(\r\n|\n)?/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"<wp_temp>")})}c="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","g"),"</$1>\n");b=b.replace(new RegExp("\\s*<((?:"+c+")(?: [^>]*)?)>","g"),"\n<$1>");b=b.replace(/(<p [^>]+>.*?)<\/p>/g,"$1</p#>");b=b.replace(/<div( [^>]*)?>\s*<p>/gi,"<div$1>\n\n");b=b.replace(/\s*<p>/gi,"");b=b.replace(/\s*<\/p>\s*/gi,"\n\n");b=b.replace(/\n[\s\u00a0]+\n/g,"\n\n");b=b.replace(/\s*<br ?\/?>\s*/gi,"\n");b=b.replace(/\s*<div/g,"\n<div");b=b.replace(/<\/div>\s*/g,"</div>\n");b=b.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");b=b.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";b=b.replace(new RegExp("\\s*<((?:"+a+")(?: [^>]*)?)\\s*>","g"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","g"),"</$1>\n");b=b.replace(/<li([^>]*)>/g,"\t<li$1>");if(b.indexOf("<hr")!=-1){b=b.replace(/\s*<hr( [^>]*)?>\s*/g,"\n\n<hr$1>\n\n")}if(b.indexOf("<object")!=-1){b=b.replace(/<object[\s\S]+?<\/object>/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(/<\/p#>/g,"</p>\n");b=b.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g,"\n$1");b=b.replace(/^\s+/,"");b=b.replace(/[\s\u00a0]+$/,"");b=b.replace(/<wp_temp>/g,"\n");return b},_wp_Autop:function(a){var b="table|thead|tfoot|tbody|tr|td|th|caption|col|colgroup|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr|noscript|menu|samp|header|footer|article|section|hgroup|nav|aside|details|summary";if(a.indexOf("<object")!=-1){a=a.replace(/<object[\s\S]+?<\/object>/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});if(a.indexOf("<pre")!=-1||a.indexOf("<script")!=-1){a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){return c.replace(/(\r\n|\n)/g,"<wp_temp_br>")})}a=a+"\n\n";a=a.replace(/<br \/>\s*<br \/>/gi,"\n\n");a=a.replace(new RegExp("(<(?:"+b+")(?: [^>]*)?>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n");a=a.replace(/\r\n|\r/g,"\n");a=a.replace(/\n\s*\n+/g,"\n\n");a=a.replace(/([\s\S]+?)\n\n/g,"<p>$1</p>\n");a=a.replace(/<p>\s*?<\/p>/gi,"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/<p>(<li.+?)<\/p>/gi,"$1");a=a.replace(/<p>\s*<blockquote([^>]*)>/gi,"<blockquote$1><p>");a=a.replace(/<\/blockquote>\s*<\/p>/gi,"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/\s*\n/gi,"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1");a=a.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi,"[caption$1[/caption]");a=a.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(e,d,f){if(f.match(/<p( [^>]*)?>/)){return e}return d+"<p>"+f+"</p>"});a=a.replace(/<wp_temp_br>/g,"\n");return a},pre_wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jQuery)!="undefined";if(c){jQuery("body").trigger("beforePreWpautop",[d])}d.data=a._wp_Nop(d.data);if(c){jQuery("body").trigger("afterPreWpautop",[d])}return d.data},wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jQuery)!="undefined";if(c){jQuery("body").trigger("beforeWpautop",[d])}d.data=a._wp_Autop(d.data);if(c){jQuery("body").trigger("afterWpautop",[d])}return d.data}};
|
|
@ -152,6 +152,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
|
||||
t.name = name;
|
||||
t.id = id;
|
||||
t.canvas = canvas;
|
||||
|
||||
// default buttons
|
||||
for ( i in edButtons ) {
|
||||
|
@ -161,8 +162,14 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
buttons[edButtons[i].id] = edButtons[i];
|
||||
}
|
||||
|
||||
if ( id == 'content' && adminpage && ( adminpage == 'post-new-php' || adminpage == 'post-php' ) )
|
||||
if ( id == 'content' && adminpage && ( adminpage == 'post-new-php' || adminpage == 'post-php' ) ) {
|
||||
buttons['fullscreen'] = new qt.FullscreenButton();
|
||||
// back compat hack :-(
|
||||
edCanvas = canvas;
|
||||
toolbar_id = 'ed_toolbar';
|
||||
} else {
|
||||
toolbar_id = name + '_toolbar';
|
||||
}
|
||||
|
||||
// add custom buttons
|
||||
for ( i in t._customButtons ) {
|
||||
|
@ -194,13 +201,6 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
for ( i in theButtons )
|
||||
html += theButtons[i].html(name + '_');
|
||||
|
||||
if ( id == 'content' && !qt.instances[0] ) { // back compat hack :-(
|
||||
edCanvas = canvas;
|
||||
toolbar_id = 'ed_toolbar';
|
||||
} else {
|
||||
toolbar_id = name + '_toolbar';
|
||||
}
|
||||
|
||||
tb = document.createElement('div');
|
||||
tb.id = toolbar_id;
|
||||
tb.className = 'quicktags-toolbar';
|
||||
|
@ -236,10 +236,10 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
return buttons[id];
|
||||
};
|
||||
|
||||
if ( !qt.instances[0] )
|
||||
qt.instances[0] = t;
|
||||
|
||||
qt.instances[id] = t;
|
||||
|
||||
if ( !qt.instances[0] )
|
||||
qt.instances[0] = qt.instances[id];
|
||||
};
|
||||
|
||||
qt.instances = {};
|
||||
|
@ -304,31 +304,31 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
};
|
||||
|
||||
qt.insertContent = function(content) {
|
||||
var sel, startPos, endPos, scrollTop, text, ed = document.getElementById(wpActiveEditor);
|
||||
var sel, startPos, endPos, scrollTop, text, canvas = document.getElementById(wpActiveEditor);
|
||||
|
||||
if ( !ed )
|
||||
if ( !canvas )
|
||||
return false;
|
||||
|
||||
if ( document.selection ) { //IE
|
||||
ed.focus();
|
||||
canvas.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = content;
|
||||
ed.focus();
|
||||
} else if ( ed.selectionStart || ed.selectionStart == '0' ) { // all other
|
||||
text = ed.value;
|
||||
startPos = ed.selectionStart;
|
||||
endPos = ed.selectionEnd;
|
||||
scrollTop = ed.scrollTop;
|
||||
canvas.focus();
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart == '0' ) { // FF, WebKit, Opera
|
||||
text = canvas.value;
|
||||
startPos = canvas.selectionStart;
|
||||
endPos = canvas.selectionEnd;
|
||||
scrollTop = canvas.scrollTop;
|
||||
|
||||
ed.value = text.substring(0, startPos) + content + text.substring(endPos, text.length);
|
||||
canvas.value = text.substring(0, startPos) + content + text.substring(endPos, text.length);
|
||||
|
||||
ed.focus();
|
||||
ed.selectionStart = startPos + content.length;
|
||||
ed.selectionEnd = startPos + content.length;
|
||||
ed.scrollTop = scrollTop;
|
||||
canvas.focus();
|
||||
canvas.selectionStart = startPos + content.length;
|
||||
canvas.selectionEnd = startPos + content.length;
|
||||
canvas.scrollTop = scrollTop;
|
||||
} else {
|
||||
ed.value += content;
|
||||
ed.focus();
|
||||
canvas.value += content;
|
||||
canvas.focus();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
@ -356,32 +356,32 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
t.open = open;
|
||||
};
|
||||
qt.TagButton.prototype = new qt.Button();
|
||||
qt.TagButton.prototype.openTag = function(e, tb) {
|
||||
qt.TagButton.prototype.openTag = function(e, ed) {
|
||||
var t = this;
|
||||
if ( ! tb.openTags ) {
|
||||
tb.openTags = [];
|
||||
|
||||
if ( ! ed.openTags ) {
|
||||
ed.openTags = [];
|
||||
}
|
||||
if ( t.tagEnd ) {
|
||||
tb.openTags.push(t.id);
|
||||
ed.openTags.push(t.id);
|
||||
e.value = '/' + e.value;
|
||||
}
|
||||
};
|
||||
qt.TagButton.prototype.closeTag = function(e, tb) {
|
||||
var t = this,
|
||||
i = t.isOpen(tb);
|
||||
qt.TagButton.prototype.closeTag = function(e, ed) {
|
||||
var t = this, i = t.isOpen(ed);
|
||||
|
||||
if ( i !== false ) {
|
||||
tb.openTags.splice(i, 1);
|
||||
ed.openTags.splice(i, 1);
|
||||
}
|
||||
|
||||
e.value = t.display;
|
||||
};
|
||||
// whether a tag is open or not. Returns false if not open, or current open depth of the tag
|
||||
qt.TagButton.prototype.isOpen = function (tb) {
|
||||
qt.TagButton.prototype.isOpen = function (ed) {
|
||||
var t = this, i = 0, ret = false;
|
||||
if ( tb.openTags ) {
|
||||
while ( ret === false && i < tb.openTags.length ) {
|
||||
ret = tb.openTags[i] == t.id ? i : false;
|
||||
if ( ed.openTags ) {
|
||||
while ( ret === false && i < ed.openTags.length ) {
|
||||
ret = ed.openTags[i] == t.id ? i : false;
|
||||
i ++;
|
||||
}
|
||||
} else {
|
||||
|
@ -389,30 +389,25 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
}
|
||||
return ret;
|
||||
};
|
||||
qt.TagButton.prototype.callback = function(element, canvas, toolbar) {
|
||||
var t = this, startPos, endPos, cursorPos, scrollTop, v, l, r, i, sel;
|
||||
qt.TagButton.prototype.callback = function(element, canvas, ed) {
|
||||
var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '';
|
||||
|
||||
v = canvas.value;
|
||||
|
||||
// IE support
|
||||
if ( document.selection ) {
|
||||
if ( document.selection ) { // IE
|
||||
canvas.focus();
|
||||
sel = document.selection.createRange();
|
||||
if ( sel.text.length > 0 ) {
|
||||
sel.text = t.tagStart + sel.text + t.tagEnd;
|
||||
sel.text = t.tagStart + sel.text + endTag;
|
||||
} else {
|
||||
if ( t.isOpen(toolbar) === false || t.tagEnd === '' ) {
|
||||
if ( t.isOpen(ed) === false || t.tagEnd === '' ) {
|
||||
sel.text = t.tagStart;
|
||||
t.openTag(element, toolbar);
|
||||
t.openTag(element, ed);
|
||||
} else {
|
||||
sel.text = t.tagEnd;
|
||||
t.closeTag(element, toolbar);
|
||||
sel.text = endTag;
|
||||
t.closeTag(element, ed);
|
||||
}
|
||||
}
|
||||
canvas.focus();
|
||||
}
|
||||
// moz, webkit, opera
|
||||
else if ( canvas.selectionStart || canvas.selectionStart == '0' ) {
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart == '0' ) { // FF, WebKit, Opera
|
||||
startPos = canvas.selectionStart;
|
||||
endPos = canvas.selectionEnd;
|
||||
cursorPos = endPos;
|
||||
|
@ -421,20 +416,20 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
r = v.substring(endPos, v.length); // right of the selection
|
||||
i = v.substring(startPos, endPos); // inside the selection
|
||||
if ( startPos != endPos ) {
|
||||
canvas.value = l + t.tagStart + i + t.tagEnd + r;
|
||||
if ( t.tagEnd === '' ) {
|
||||
canvas.value = l + t.tagStart + i + endTag + r;
|
||||
if ( endTag === '' ) {
|
||||
cursorPos = startPos;
|
||||
}
|
||||
cursorPos += t.tagStart.length + t.tagEnd.length;
|
||||
cursorPos += t.tagStart.length + endTag.length;
|
||||
} else {
|
||||
if ( t.isOpen(toolbar) === false || t.tagEnd === '' ) {
|
||||
if ( t.isOpen(ed) === false || t.tagEnd === '' ) {
|
||||
canvas.value = l + t.tagStart + r;
|
||||
t.openTag(element, toolbar);
|
||||
t.openTag(element, ed);
|
||||
cursorPos = startPos + t.tagStart.length;
|
||||
} else {
|
||||
canvas.value = l + t.tagEnd + r;
|
||||
cursorPos = startPos + t.tagEnd.length;
|
||||
t.closeTag(element, toolbar);
|
||||
canvas.value = l + endTag + r;
|
||||
cursorPos = startPos + endTag.length;
|
||||
t.closeTag(element, ed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,12 +440,12 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
}
|
||||
// other browsers
|
||||
else {
|
||||
if ( t.isOpen(toolbar) !== false || t.tagEnd === '' ) {
|
||||
if ( t.isOpen(ed) !== false || t.tagEnd === '' ) {
|
||||
canvas.value += t.tagStart;
|
||||
t.openTag(element, toolbar);
|
||||
t.openTag(element, ed);
|
||||
} else {
|
||||
canvas.value += t.tagEnd;
|
||||
t.closeTag(element, toolbar);
|
||||
canvas.value += endTag;
|
||||
t.closeTag(element, ed);
|
||||
}
|
||||
canvas.focus();
|
||||
}
|
||||
|
@ -461,7 +456,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
qt.Button.call(this, 'spell', quicktagsL10n.lookup, '', quicktagsL10n.dictionaryLookup);
|
||||
};
|
||||
qt.SpellButton.prototype = new qt.Button();
|
||||
qt.SpellButton.prototype.callback = function(element, canvas, toolbar) {
|
||||
qt.SpellButton.prototype.callback = function(element, canvas, ed) {
|
||||
var word = '', sel, startPos, endPos;
|
||||
|
||||
if ( document.selection ) {
|
||||
|
@ -470,8 +465,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
if ( sel.text.length > 0 ) {
|
||||
word = sel.text;
|
||||
}
|
||||
}
|
||||
else if ( canvas.selectionStart || canvas.selectionStart == '0' ) {
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart == '0' ) {
|
||||
startPos = canvas.selectionStart;
|
||||
endPos = canvas.selectionEnd;
|
||||
if ( startPos != endPos ) {
|
||||
|
@ -488,25 +482,26 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
}
|
||||
};
|
||||
|
||||
// the close button
|
||||
// the close tags button
|
||||
qt.CloseButton = function() {
|
||||
qt.Button.call(this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags);
|
||||
};
|
||||
qt.CloseButton.prototype = new qt.Button();
|
||||
qt.CloseButton.prototype.callback = function(e, c, tb) {
|
||||
var button, element, tbo = tb.openTags;
|
||||
qt.CloseButton.prototype.callback = function(e, c, ed) {
|
||||
var button, element, tbo = ed.openTags;
|
||||
|
||||
if ( tbo ) {
|
||||
while ( tbo.length > 0 ) {
|
||||
button = tb.getButton(tbo[tbo.length - 1]);
|
||||
element = document.getElementById(tb.name + '_' + button.id);
|
||||
button.callback.call(button, element, c, tb);
|
||||
button = ed.getButton(tbo[tbo.length - 1]);
|
||||
element = document.getElementById(ed.name + '_' + button.id);
|
||||
button.callback.call(button, element, c, ed);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
qt.prototype.closeAllTags = function() {
|
||||
var btn = this.getButton('close');
|
||||
btn.callback.call(btn, '', this.canvas, this.toolbar);
|
||||
qt.closeAllTags = function(editor_id) {
|
||||
var ed = this.getInstance(editor_id), btn = ed.getButton('close');
|
||||
btn.callback.call(btn, '', ed.canvas, ed);
|
||||
};
|
||||
|
||||
// the link button
|
||||
|
@ -514,7 +509,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
qt.TagButton.call(this, 'link', 'link', '', '</a>', 'a');
|
||||
};
|
||||
qt.LinkButton.prototype = new qt.TagButton();
|
||||
qt.LinkButton.prototype.callback = function(e, c, tb, defaultValue) {
|
||||
qt.LinkButton.prototype.callback = function(e, c, ed, defaultValue) {
|
||||
var URL, t = this;
|
||||
|
||||
if ( typeof(wpLink) != 'undefined' ) {
|
||||
|
@ -525,14 +520,14 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
if ( ! defaultValue )
|
||||
defaultValue = 'http://';
|
||||
|
||||
if ( t.isOpen(tb) === false ) {
|
||||
if ( t.isOpen(ed) === false ) {
|
||||
URL = prompt(quicktagsL10n.enterURL, defaultValue);
|
||||
if ( URL ) {
|
||||
t.tagStart = '<a href="' + URL + '">';
|
||||
qt.TagButton.prototype.callback.call(t, e, c, tb);
|
||||
qt.TagButton.prototype.callback.call(t, e, c, ed);
|
||||
}
|
||||
} else {
|
||||
qt.TagButton.prototype.callback.call(t, e, c, tb);
|
||||
qt.TagButton.prototype.callback.call(t, e, c, ed);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -541,7 +536,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
qt.TagButton.call(this, 'img', 'img', '', '', 'm', -1);
|
||||
};
|
||||
qt.ImgButton.prototype = new qt.TagButton();
|
||||
qt.ImgButton.prototype.callback = function(e, c, tb, defaultValue) {
|
||||
qt.ImgButton.prototype.callback = function(e, c, ed, defaultValue) {
|
||||
if ( ! defaultValue ) {
|
||||
defaultValue = 'http://';
|
||||
}
|
||||
|
@ -549,7 +544,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
|
|||
if ( src ) {
|
||||
alt = prompt(quicktagsL10n.enterImageDescription, '');
|
||||
this.tagStart = '<img src="' + src + '" alt="' + alt + '" />';
|
||||
qt.TagButton.prototype.callback.call(this, e, c, tb);
|
||||
qt.TagButton.prototype.callback.call(this, e, c, ed);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -68,7 +68,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1', 1 );
|
||||
|
||||
$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110819', 1 );
|
||||
$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110820', 1 );
|
||||
$scripts->add_script_data( 'quicktags', 'quicktagsL10n', array(
|
||||
'wordLookup' => __('Enter a word to look up:'),
|
||||
'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
|
||||
|
@ -84,7 +84,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
|
||||
|
||||
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110802', 1 );
|
||||
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110820', 1 );
|
||||
|
||||
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110802', 1 );
|
||||
|
||||
|
@ -269,7 +269,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20110429', 1 );
|
||||
|
||||
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110804', 1 );
|
||||
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), '20110820', 1 );
|
||||
$scripts->add_script_data( 'admin-comments', 'adminCommentsL10n', array(
|
||||
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
||||
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
|
||||
|
|
Loading…
Reference in New Issue