Editor: Add init
and remove
methods to Quicktags.
Props helgatheviking azaozz. Fixes #26183 #40708. git-svn-id: https://develop.svn.wordpress.org/trunk@40598 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cee49addad
commit
ef7b643a97
@ -243,14 +243,22 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||
return document.getElementById(name + '_' + id);
|
||||
};
|
||||
|
||||
qt.instances[id] = t;
|
||||
t.init = function() {
|
||||
_domReady( function(){ qt._buttonsInit( id ); } );
|
||||
};
|
||||
|
||||
if ( ! qt.instances['0'] ) {
|
||||
qt.instances['0'] = qt.instances[id];
|
||||
_domReady( function(){ qt._buttonsInit(); } );
|
||||
t.remove = function() {
|
||||
delete qt.instances[id];
|
||||
|
||||
if ( tb && tb.parentNode ) {
|
||||
tb.parentNode.removeChild( tb );
|
||||
}
|
||||
};
|
||||
|
||||
qt.instances[id] = t;
|
||||
t.init();
|
||||
};
|
||||
|
||||
function _escape( text ) {
|
||||
text = text || '';
|
||||
text = text.replace( /&([^#])(?![a-z1-4]{1,8};)/gi, '&$1' );
|
||||
@ -263,16 +271,14 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||
return qt.instances[id];
|
||||
};
|
||||
|
||||
qt._buttonsInit = function() {
|
||||
var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use,
|
||||
qt._buttonsInit = function( id ) {
|
||||
var t = this;
|
||||
|
||||
function _init( instanceId ) {
|
||||
var canvas, name, settings, theButtons, html, ed, id, i, use,
|
||||
defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
|
||||
|
||||
for ( inst in t.instances ) {
|
||||
if ( '0' === inst ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ed = t.instances[inst];
|
||||
ed = t.instances[instanceId];
|
||||
canvas = ed.canvas;
|
||||
name = ed.name;
|
||||
settings = ed.settings;
|
||||
@ -295,7 +301,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !edButtons[i].instance || edButtons[i].instance === inst ) {
|
||||
if ( ! edButtons[i].instance || edButtons[i].instance === instanceId ) {
|
||||
theButtons[id] = edButtons[i];
|
||||
|
||||
if ( edButtons[i].html ) {
|
||||
@ -321,6 +327,15 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||
jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( id ) {
|
||||
_init( id );
|
||||
} else {
|
||||
for ( id in t.instances ) {
|
||||
_init( id );
|
||||
}
|
||||
}
|
||||
|
||||
t.buttonsInitDone = true;
|
||||
};
|
||||
|
||||
@ -608,7 +623,10 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||
|
||||
qt.closeAllTags = function( editor_id ) {
|
||||
var ed = this.getInstance( editor_id );
|
||||
|
||||
if ( ed ) {
|
||||
qt._close( '', ed.canvas, ed );
|
||||
}
|
||||
};
|
||||
|
||||
// the link button
|
||||
|
Loading…
Reference in New Issue
Block a user