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
@ -223,7 +223,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
|
|
||||||
if ( tb.addEventListener ) {
|
if ( tb.addEventListener ) {
|
||||||
tb.addEventListener( 'click', onclick, false );
|
tb.addEventListener( 'click', onclick, false );
|
||||||
|
|
||||||
if ( wrap ) {
|
if ( wrap ) {
|
||||||
wrap.addEventListener( 'click', setActiveEditor, false );
|
wrap.addEventListener( 'click', setActiveEditor, false );
|
||||||
}
|
}
|
||||||
@ -243,12 +243,20 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
return document.getElementById(name + '_' + id);
|
return document.getElementById(name + '_' + id);
|
||||||
};
|
};
|
||||||
|
|
||||||
qt.instances[id] = t;
|
t.init = function() {
|
||||||
|
_domReady( function(){ qt._buttonsInit( id ); } );
|
||||||
|
};
|
||||||
|
|
||||||
if ( ! qt.instances['0'] ) {
|
t.remove = function() {
|
||||||
qt.instances['0'] = qt.instances[id];
|
delete qt.instances[id];
|
||||||
_domReady( function(){ qt._buttonsInit(); } );
|
|
||||||
}
|
if ( tb && tb.parentNode ) {
|
||||||
|
tb.parentNode.removeChild( tb );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
qt.instances[id] = t;
|
||||||
|
t.init();
|
||||||
};
|
};
|
||||||
|
|
||||||
function _escape( text ) {
|
function _escape( text ) {
|
||||||
@ -263,16 +271,14 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
return qt.instances[id];
|
return qt.instances[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
qt._buttonsInit = function() {
|
qt._buttonsInit = function( id ) {
|
||||||
var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use,
|
var t = this;
|
||||||
defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
|
|
||||||
|
|
||||||
for ( inst in t.instances ) {
|
function _init( instanceId ) {
|
||||||
if ( '0' === inst ) {
|
var canvas, name, settings, theButtons, html, ed, id, i, use,
|
||||||
continue;
|
defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
|
||||||
}
|
|
||||||
|
|
||||||
ed = t.instances[inst];
|
ed = t.instances[instanceId];
|
||||||
canvas = ed.canvas;
|
canvas = ed.canvas;
|
||||||
name = ed.name;
|
name = ed.name;
|
||||||
settings = ed.settings;
|
settings = ed.settings;
|
||||||
@ -286,7 +292,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ( i in edButtons ) {
|
for ( i in edButtons ) {
|
||||||
if ( !edButtons[i] ) {
|
if ( ! edButtons[i] ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,11 +301,11 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !edButtons[i].instance || edButtons[i].instance === inst ) {
|
if ( ! edButtons[i].instance || edButtons[i].instance === instanceId ) {
|
||||||
theButtons[id] = edButtons[i];
|
theButtons[id] = edButtons[i];
|
||||||
|
|
||||||
if ( edButtons[i].html ) {
|
if ( edButtons[i].html ) {
|
||||||
html += edButtons[i].html(name + '_');
|
html += edButtons[i].html( name + '_' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,9 +315,9 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
html += theButtons.dfw.html( name + '_' );
|
html += theButtons.dfw.html( name + '_' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'rtl' === document.getElementsByTagName('html')[0].dir ) {
|
if ( 'rtl' === document.getElementsByTagName( 'html' )[0].dir ) {
|
||||||
theButtons.textdirection = new qt.TextDirectionButton();
|
theButtons.textdirection = new qt.TextDirectionButton();
|
||||||
html += theButtons.textdirection.html(name + '_');
|
html += theButtons.textdirection.html( name + '_' );
|
||||||
}
|
}
|
||||||
|
|
||||||
ed.toolbar.innerHTML = html;
|
ed.toolbar.innerHTML = html;
|
||||||
@ -321,6 +327,15 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
|
jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( id ) {
|
||||||
|
_init( id );
|
||||||
|
} else {
|
||||||
|
for ( id in t.instances ) {
|
||||||
|
_init( id );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t.buttonsInitDone = true;
|
t.buttonsInitDone = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -606,9 +621,12 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
|||||||
|
|
||||||
qt.CloseButton.prototype.callback = qt._close;
|
qt.CloseButton.prototype.callback = qt._close;
|
||||||
|
|
||||||
qt.closeAllTags = function(editor_id) {
|
qt.closeAllTags = function( editor_id ) {
|
||||||
var ed = this.getInstance(editor_id);
|
var ed = this.getInstance( editor_id );
|
||||||
qt._close('', ed.canvas, ed);
|
|
||||||
|
if ( ed ) {
|
||||||
|
qt._close( '', ed.canvas, ed );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// the link button
|
// the link button
|
||||||
|
Loading…
Reference in New Issue
Block a user