X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/874d2a2f468a0d1e69aab49b1fe2d9d79d3e1142..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-includes/js/quicktags.js diff --git a/wp-includes/js/quicktags.js b/wp-includes/js/quicktags.js index 932fcc05..9b2f8c8d 100644 --- a/wp-includes/js/quicktags.js +++ b/wp-includes/js/quicktags.js @@ -230,8 +230,8 @@ function edButton(id, display, tagStart, tagEnd, access) { qt.instances[id] = t; - if ( !qt.instances[0] ) { - qt.instances[0] = qt.instances[id]; + if ( ! qt.instances['0'] ) { + qt.instances['0'] = qt.instances[id]; _domReady( function(){ qt._buttonsInit(); } ); } }; @@ -247,7 +247,7 @@ function edButton(id, display, tagStart, tagEnd, access) { defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,'; for ( inst in t.instances ) { - if ( inst === 0 ) { + if ( '0' === inst ) { continue; } @@ -288,6 +288,10 @@ function edButton(id, display, tagStart, tagEnd, access) { html += theButtons.fullscreen.html(name + '_'); } + if ( use && use.indexOf(',dfw,') !== -1 ) { + theButtons.dfw = new qt.DFWButton(); + html += theButtons.dfw.html( name + '_' ); + } if ( 'rtl' === document.getElementsByTagName('html')[0].dir ) { theButtons.textdirection = new qt.TextDirectionButton(); @@ -296,6 +300,10 @@ function edButton(id, display, tagStart, tagEnd, access) { ed.toolbar.innerHTML = html; ed.theButtons = theButtons; + + if ( typeof jQuery !== 'undefined' ) { + jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] ); + } } t.buttonsInitDone = true; }; @@ -320,10 +328,10 @@ function edButton(id, display, tagStart, tagEnd, access) { * @param string display Required. Button's value="..." * @param string|function arg1 Required. Either a starting tag to be inserted like "" or a callback that is executed when the button is clicked. * @param string arg2 Optional. Ending tag like "" - * @param string access_key Optional. Access key for the button. + * @param string access_key Deprecated Not used * @param string title Optional. Button's title="..." * @param int priority Optional. Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc. - * @param string instance Optional. Limit the button to a specifric instance of Quicktags, add to all instances if not present. + * @param string instance Optional. Limit the button to a specific instance of Quicktags, add to all instances if not present. * @return mixed null or the button object that is needed for back-compat. */ qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) { @@ -400,16 +408,25 @@ function edButton(id, display, tagStart, tagEnd, access) { var t = this; t.id = id; t.display = display; - t.access = access; + t.access = ''; t.title = title || ''; t.instance = instance || ''; }; qt.Button.prototype.html = function(idPrefix) { - var access = this.access ? ' accesskey="' + this.access + '"' : ''; + var title = this.title ? ' title="' + this.title + '"' : '', + active, on, wp, + dfw = ( wp = window.wp ) && wp.editor && wp.editor.dfw; + if ( this.id === 'fullscreen' ) { - return ''; + return ''; + } else if ( this.id === 'dfw' ) { + active = dfw && dfw.isActive() ? '' : ' disabled="disabled"'; + on = dfw && dfw.isOn() ? ' active' : ''; + + return ''; } - return ''; + + return ''; }; qt.Button.prototype.callback = function(){}; @@ -563,7 +580,7 @@ function edButton(id, display, tagStart, tagEnd, access) { // the link button qt.LinkButton = function() { - qt.TagButton.call(this, 'link', 'link', '', '', 'a'); + qt.TagButton.call(this, 'link', 'link', '', ''); }; qt.LinkButton.prototype = new qt.TagButton(); qt.LinkButton.prototype.callback = function(e, c, ed, defaultValue) { @@ -591,7 +608,7 @@ function edButton(id, display, tagStart, tagEnd, access) { // the img button qt.ImgButton = function() { - qt.TagButton.call(this, 'img', 'img', '', '', 'm'); + qt.TagButton.call(this, 'img', 'img', '', ''); }; qt.ImgButton.prototype = new qt.TagButton(); qt.ImgButton.prototype.callback = function(e, c, ed, defaultValue) { @@ -618,6 +635,20 @@ function edButton(id, display, tagStart, tagEnd, access) { wp.editor.fullscreen.on(); }; + qt.DFWButton = function() { + qt.Button.call( this, 'dfw', '', 'f', quicktagsL10n.dfw ); + }; + qt.DFWButton.prototype = new qt.Button(); + qt.DFWButton.prototype.callback = function() { + var wp; + + if ( ! ( wp = window.wp ) || ! wp.editor || ! wp.editor.dfw ) { + return; + } + + window.wp.editor.dfw.toggle(); + }; + qt.TextDirectionButton = function() { qt.Button.call(this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection); }; @@ -635,18 +666,18 @@ function edButton(id, display, tagStart, tagEnd, access) { }; // ensure backward compatibility - edButtons[10] = new qt.TagButton('strong','b','','','b'); - edButtons[20] = new qt.TagButton('em','i','','','i'), + edButtons[10] = new qt.TagButton('strong','b','',''); + edButtons[20] = new qt.TagButton('em','i','',''), edButtons[30] = new qt.LinkButton(), // special case - edButtons[40] = new qt.TagButton('block','b-quote','\n\n
','
\n\n','q'), - edButtons[50] = new qt.TagButton('del','del','','','d'), - edButtons[60] = new qt.TagButton('ins','ins','','','s'), + edButtons[40] = new qt.TagButton('block','b-quote','\n\n
','
\n\n'), + edButtons[50] = new qt.TagButton('del','del','',''), + edButtons[60] = new qt.TagButton('ins','ins','',''), edButtons[70] = new qt.ImgButton(), // special case - edButtons[80] = new qt.TagButton('ul','ul','\n\n','u'), - edButtons[90] = new qt.TagButton('ol','ol','
    \n','
\n\n','o'), - edButtons[100] = new qt.TagButton('li','li','\t
  • ','
  • \n','l'), - edButtons[110] = new qt.TagButton('code','code','','','c'), - edButtons[120] = new qt.TagButton('more','more','\n\n','','t'), + edButtons[80] = new qt.TagButton('ul','ul','\n\n'), + edButtons[90] = new qt.TagButton('ol','ol','
      \n','
    \n\n'), + edButtons[100] = new qt.TagButton('li','li','\t
  • ','
  • \n'), + edButtons[110] = new qt.TagButton('code','code','',''), + edButtons[120] = new qt.TagButton('more','more','\n\n',''), edButtons[140] = new qt.CloseButton(); })();