WordPress.org

Make WordPress Core

Changeset 19172


Ignore:
Timestamp:
11/05/11 16:00:38 (2 years ago)
Author:
azaozz
Message:

Improve handling of init and adding buttons to Quicktags, fixes #19098

Location:
trunk/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-editor.php

    r19126 r19172  
    140140 
    141141        if ( $this->this_quicktags ) { 
    142             $qt_buttons = array(); 
    143142 
    144143            $qtInit = array( 
    145144                'id' => $editor_id, 
    146                 'buttons' => '', 
    147                 'disabled_buttons' => '' 
     145                'buttons' => '' 
    148146            ); 
    149147 
     
    151149                $qtInit = array_merge($qtInit, $set['quicktags']); 
    152150 
    153             $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); 
    154  
     151            if ( empty($qtInit['buttons']) ) 
     152                $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close'; 
     153 
     154            if ( $set['dfw'] ) 
     155                $qtInit['buttons'] .= ',fullscreen'; 
     156 
     157            $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id); 
    155158            $this->qt_settings[$editor_id] = $qtInit; 
    156159 
    157             if ( !empty($qtInit['buttons']) || !empty($qtInit['disabled_buttons']) ) { 
    158                 if ( strpos( ',' . $qtInit['buttons'] . ',', ',link,' ) !== false ) 
    159                     $qt_buttons[] = 'link'; 
    160  
    161                 if ( strpos( ',' . $qtInit['disabled_buttons'] . ',', ',link,' ) !== false ) 
    162                     $qt_buttons = array(); 
    163             } else { 
    164                 $qt_buttons[] = 'link'; 
    165             } 
    166  
    167             if ( $set['dfw'] ) 
    168                 $qt_buttons[] = 'fullscreen'; 
    169  
    170             $this->qt_buttons = array_merge( $this->qt_buttons, $qt_buttons ); 
     160            $this->qt_buttons = array_merge( $this->qt_buttons, explode(',', $qtInit['buttons']) ); 
    171161        } 
    172162 
  • trunk/wp-includes/js/quicktags.dev.js

    r19084 r19172  
    88 * settings = { 
    99 *   id : 'my_id',          // the HTML ID of the textarea, required 
    10  *   buttons: '',           // Comma separated list of the names of the default buttons to show. Optional. 
     10 *   buttons: ''            // Comma separated list of the names of the default buttons to show. Optional. 
    1111 *                          // This overwrites buttons order and any buttons added by plugins. 
    1212 *                          // Current list of default button names: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close' 
    13  *   disabled_buttons : ''  // Comma separated list of the names of the buttons to disable. 
    1413 * } 
    1514 * 
     
    1716 * 
    1817 * quicktags_id The ID of the textarea that will be the editor canvas 
    19  * buttons Comma separated list of the buttons IDs that will be shown. Buttons added by plugins 
    20  * will not show. Default: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close' 
    21  * disabled_buttons Comma separated list of the buttons IDs that should be excluded. Buttons 
    22  * added by plugins will show unless specifically disabled. 
     18 * buttons Comma separated list of the buttons IDs that will be shown. Buttons added from JavaScript by plugins will not show. 
    2319 */ 
    2420 
     
    148144            '+00:00'; 
    149145    })(), 
    150  
    151     _customButtons = {}, 
    152146    qt; 
    153147 
     
    193187 
    194188            // as long as it has the class ed_button, execute the callback 
    195             if ( /\s+ed_button\s+/.test(' ' + target.className + ' ' ) ) { 
     189            if ( / ed_button /.test(' ' + target.className + ' ') ) { 
    196190                // we have to reassign canvas here 
    197191                t.canvas = canvas = document.getElementById(id); 
     
    227221    qt.instances = {}; 
    228222 
    229     qt.registerButton = function(id, btnClass) { 
    230         _customButtons[id] = btnClass; 
    231     }; 
    232  
    233223    qt.getInstance = function(id) { 
    234224        return qt.instances[id]; 
     
    236226 
    237227    qt._buttonsInit = function() { 
    238         var t = this, instance, canvas, name, settings, buttons, theButtons, html, id, i, qb, btn; 
    239  
    240         for ( id in t.instances ) { 
    241             if ( id == 0 ) 
     228        var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use = '', 
     229            defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,'; 
     230 
     231        for ( inst in t.instances ) { 
     232            if ( inst == 0 ) 
    242233                continue; 
    243234 
    244             instance = t.instances[id]; 
    245             canvas = instance.canvas; 
    246             name = instance.name; 
    247             settings = instance.settings; 
     235            ed = t.instances[inst]; 
     236            canvas = ed.canvas; 
     237            name = ed.name; 
     238            settings = ed.settings; 
    248239            html = ''; 
    249             buttons = {}; 
    250240            theButtons = {}; 
    251241 
    252242            // set buttons 
     243            if ( settings.buttons ) 
     244                use = ','+settings.buttons+','; 
     245 
    253246            for ( i in edButtons ) { 
    254247                if ( !edButtons[i] ) 
    255248                    continue; 
    256249 
    257                 buttons[edButtons[i].id] = edButtons[i]; 
    258             } 
    259  
    260             if ( id == 'content' && typeof(adminpage) == 'string' && ( adminpage == 'post-new-php' || adminpage == 'post-php' ) ) 
    261                 buttons['fullscreen'] = new qt.FullscreenButton(); 
    262  
    263             // add custom buttons 
    264             for ( i in t._customButtons ) { 
    265                 if ( !buttons[i] ) 
    266                     buttons[i] = new t._customButtons[i](); 
    267             } 
    268  
    269             if ( settings.buttons ) { 
    270                 qb = settings.buttons.split(','); 
    271  
    272                 for ( i in qb ) { 
    273                     btn = qb[i]; 
    274                     if ( buttons[btn] ) 
    275                         theButtons[btn] = buttons[btn]; 
    276                 } 
    277             } else { 
    278                 theButtons = buttons; 
    279             } 
    280  
    281             if ( settings.disabled_buttons ) { 
    282                 qb = settings.disabled_buttons.split(','); 
    283  
    284                 for ( i in qb ) { 
    285                     btn = qb[i]; 
    286                     if ( theButtons[btn] ) 
    287                         delete(theButtons[btn]); 
    288                 } 
     250                id = edButtons[i].id; 
     251                if ( use && defaults.indexOf(','+id+',') != -1 && use.indexOf(','+id+',') == -1 ) 
     252                    continue; 
     253 
     254                if ( !edButtons[i].instance || edButtons[i].instance == inst ) 
     255                    theButtons[id] = edButtons[i]; 
    289256            } 
    290257 
     
    296263            } 
    297264 
    298             instance.toolbar.innerHTML = html; 
    299             instance.theButtons = theButtons; 
     265            ed.toolbar.innerHTML = html; 
     266            ed.theButtons = theButtons; 
    300267        } 
    301268        t.buttonsInitDone = true; 
     
    316283     * Minimum required to add a button that inserts a tag: 
    317284     *     QTags.addButton( 'my_id', 'my button', '<span>', '</span>' ); 
    318      *     QTags.addButton( 'my_id', 'my button', '<br />' ); 
     285     *     QTags.addButton( 'my_id2', 'my button', '<br />' ); 
    319286     * 
    320287     * @param id string required Button HTML ID 
    321288     * @param display string required Button's value="..." 
    322289     * @param arg1 string || function required Either a starting tag to be inserted like "<span>" or a callback that is executed when the button is clicked. 
    323      * @param arg2 string Ending tag like "</span>" 
    324      * @param access_key string Access key for the button 
    325      * @param title string Button's title="..."  
    326      * @param priority int Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc. 
    327      * @return mixed null or the button object that is needed for back-compat. The common method of adding a button was to manually add it to the buttons array. 
     290     * @param arg2 string optional Ending tag like "</span>" 
     291     * @param access_key string optional Access key for the button. 
     292     * @param title string optional Button's title="..."  
     293     * @param priority int optional Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc. 
     294     * @param instance string optional Limit the button to a specifric instance of Quicktags, add to all instances if not present. 
     295     * @return mixed null or the button object that is needed for back-compat. 
    328296     */              
    329     qt.addButton = function( id, display, arg1, arg2, access_key, title, priority ) { 
     297    qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) { 
    330298        var btn; 
    331299         
     
    337305 
    338306        if ( typeof(arg1) === 'function' ) { 
    339             btn = new qt.Button(id, display, access_key, title); 
     307            btn = new qt.Button(id, display, access_key, title, instance); 
    340308            btn.callback = arg1; 
    341309        } else if ( typeof(arg1) === 'string' ) { 
    342             btn = new qt.TagButton(id, display, arg1, arg2, access_key, title); 
     310            btn = new qt.TagButton(id, display, arg1, arg2, access_key, title, instance); 
    343311        } else { 
    344312            return; 
     
    393361 
    394362    // a plain, dumb button 
    395     qt.Button = function(id, display, access, title) { 
     363    qt.Button = function(id, display, access, title, instance) { 
    396364        var t = this; 
    397365        t.id = id; 
     
    399367        t.access = access; 
    400368        t.title = title || ''; 
     369        t.instance = instance || ''; 
    401370    }; 
    402371    qt.Button.prototype.html = function(idPrefix) { 
     
    407376 
    408377    // a button that inserts HTML tag 
    409     qt.TagButton = function(id, display, tagStart, tagEnd, access, title) { 
     378    qt.TagButton = function(id, display, tagStart, tagEnd, access, title, instance) { 
    410379        var t = this; 
    411         qt.Button.call(t, id, display, access, title); 
     380        qt.Button.call(t, id, display, access, title, instance); 
    412381        t.tagStart = tagStart; 
    413382        t.tagEnd = tagEnd; 
  • trunk/wp-includes/js/quicktags.js

    r18766 r19172  
    1 var QTags,edButtons=[],edCanvas,edAddTag=function(){},edCheckOpenTags=function(){},edCloseAllTags=function(){},edInsertImage=function(){},edInsertLink=function(){},edInsertTag=function(){},edLink=function(){},edQuickLink=function(){},edRemoveTag=function(){},edShowButton=function(){},edShowLinks=function(){},edSpell=function(){},edToolbar=function(){};function quicktags(a){return new QTags(a)}function edInsertContent(b,a){return QTags.insertContent(a)}function edButton(f,e,c,b,a,d){return QTags.addButton(f,e,c,b,a,"",-1)}(function(){var c=function(h){var g,f,e;if(typeof jQuery!="undefined"){jQuery(document).ready(h)}else{g=c;g.funcs=[];g.ready=function(){if(!g.isReady){g.isReady=true;for(f=0;f<g.funcs.length;f++){g.funcs[f]()}}};if(g.isReady){h()}else{g.funcs.push(h)}if(!g.eventAttached){if(document.addEventListener){e=function(){document.removeEventListener("DOMContentLoaded",e,false);g.ready()};document.addEventListener("DOMContentLoaded",e,false);window.addEventListener("load",g.ready,false)}else{if(document.attachEvent){e=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",e);g.ready()}};document.attachEvent("onreadystatechange",e);window.attachEvent("onload",g.ready);(function(){try{document.documentElement.doScroll("left")}catch(i){setTimeout(arguments.callee,50);return}g.ready()})()}}g.eventAttached=true}}},a=(function(){var e=new Date(),f;f=function(g){var h=g.toString();if(h.length<2){h="0"+h}return h};return e.getUTCFullYear()+"-"+f(e.getUTCMonth()+1)+"-"+f(e.getUTCDate())+"T"+f(e.getUTCHours())+":"+f(e.getUTCMinutes())+":"+f(e.getUTCSeconds())+"+00:00"})(),b={},d;d=QTags=function(k){if(typeof(k)=="string"){k={id:k}}else{if(typeof(k)!="object"){return false}}var j=this,l=k.id,i=document.getElementById(l),h="qt_"+l,e,g,f;if(!l||!i){return false}j.name=h;j.id=l;j.canvas=i;j.settings=k;if(l=="content"&&typeof(adminpage)=="string"&&(adminpage=="post-new-php"||adminpage=="post-php")){edCanvas=i;f="ed_toolbar"}else{f=h+"_toolbar"}e=document.createElement("div");e.id=f;e.className="quicktags-toolbar";i.parentNode.insertBefore(e,i);j.toolbar=e;g=function(o){o=o||window.event;var n=o.target||o.srcElement,m;if(/\s+ed_button\s+/.test(" "+n.className+" ")){j.canvas=i=document.getElementById(l);m=n.id.replace(h+"_","");if(j.theButtons[m]){j.theButtons[m].callback.call(j.theButtons[m],n,i,j)}}};if(e.addEventListener){e.addEventListener("click",g,false)}else{if(e.attachEvent){e.attachEvent("onclick",g)}}j.getButton=function(m){return j.theButtons[m]};j.getButtonElement=function(m){return document.getElementById(h+"_"+m)};d.instances[l]=j;if(!d.instances[0]){d.instances[0]=d.instances[l];c(function(){d._buttonsInit()})}};d.instances={};d.registerButton=function(f,e){b[f]=e};d.getInstance=function(e){return d.instances[e]};d._buttonsInit=function(){var q=this,p,h,e,j,o,n,m,f,l,k,g;for(f in q.instances){if(f==0){continue}p=q.instances[f];h=p.canvas;e=p.name;j=p.settings;m="";o={};n={};for(l in edButtons){if(!edButtons[l]){continue}o[edButtons[l].id]=edButtons[l]}if(f=="content"&&typeof(adminpage)=="string"&&(adminpage=="post-new-php"||adminpage=="post-php")){o.fullscreen=new d.FullscreenButton()}for(l in q._customButtons){if(!o[l]){o[l]=new q._customButtons[l]()}}if(j.buttons){k=j.buttons.split(",");for(l in k){g=k[l];if(o[g]){n[g]=o[g]}}}else{n=o}if(j.disabled_buttons){k=j.disabled_buttons.split(",");for(l in k){g=k[l];if(n[g]){delete (n[g])}}}for(l in n){if(!n[l]||!n[l].html){continue}m+=n[l].html(e+"_")}p.toolbar.innerHTML=m;p.theButtons=n}q.buttonsInitDone=true};d.addButton=function(l,j,f,e,i,k,h){var g;if(!l||!j){return}h=h||0;e=e||"";if(typeof(f)==="function"){g=new d.Button(l,j,i,k);g.callback=f}else{if(typeof(f)==="string"){g=new d.TagButton(l,j,f,e,i,k)}else{return}}if(h==-1){return g}if(h>0){while(typeof(edButtons[h])!="undefined"){h++}edButtons[h]=g}else{edButtons[edButtons.length]=g}if(this.buttonsInitDone){this._buttonsInit()}};d.insertContent=function(h){var i,g,f,j,k,e=document.getElementById(wpActiveEditor);if(!e){return false}if(document.selection){e.focus();i=document.selection.createRange();i.text=h;e.focus()}else{if(e.selectionStart||e.selectionStart=="0"){k=e.value;g=e.selectionStart;f=e.selectionEnd;j=e.scrollTop;e.value=k.substring(0,g)+h+k.substring(f,k.length);e.focus();e.selectionStart=g+h.length;e.selectionEnd=g+h.length;e.scrollTop=j}else{e.value+=h;e.focus()}}return true};d.Button=function(i,g,e,h){var f=this;f.id=i;f.display=g;f.access=e;f.title=h||""};d.Button.prototype.html=function(f){var e=this.access?' accesskey="'+this.access+'"':"";return'<input type="button" id="'+f+this.id+'"'+e+' class="ed_button" title="'+this.title+'" value="'+this.display+'" />'};d.Button.prototype.callback=function(){};d.TagButton=function(k,i,g,f,e,j){var h=this;d.Button.call(h,k,i,e,j);h.tagStart=g;h.tagEnd=f};d.TagButton.prototype=new d.Button();d.TagButton.prototype.openTag=function(h,f){var g=this;if(!f.openTags){f.openTags=[]}if(g.tagEnd){f.openTags.push(g.id);h.value="/"+h.value}};d.TagButton.prototype.closeTag=function(j,f){var h=this,g=h.isOpen(f);if(g!==false){f.openTags.splice(g,1)}j.value=h.display};d.TagButton.prototype.isOpen=function(e){var h=this,g=0,f=false;if(e.openTags){while(f===false&&g<e.openTags.length){f=e.openTags[g]==h.id?g:false;g++}}else{f=false}return f};d.TagButton.prototype.callback=function(p,j,q){var w=this,s,f,n,h,u=j.value,k,e,o,g,m=u?w.tagEnd:"";if(document.selection){j.focus();g=document.selection.createRange();if(g.text.length>0){if(!w.tagEnd){g.text=g.text+w.tagStart}else{g.text=w.tagStart+g.text+m}}else{if(!w.tagEnd){g.text=w.tagStart}else{if(w.isOpen(q)===false){g.text=w.tagStart;w.openTag(p,q)}else{g.text=m;w.closeTag(p,q)}}}j.focus()}else{if(j.selectionStart||j.selectionStart=="0"){s=j.selectionStart;f=j.selectionEnd;n=f;h=j.scrollTop;k=u.substring(0,s);e=u.substring(f,u.length);o=u.substring(s,f);if(s!=f){if(!w.tagEnd){j.value=k+o+w.tagStart+e;n+=w.tagStart.length}else{j.value=k+w.tagStart+o+m+e;n+=w.tagStart.length+m.length}}else{if(!w.tagEnd){j.value=k+w.tagStart+e;n=s+w.tagStart.length}else{if(w.isOpen(q)===false){j.value=k+w.tagStart+e;w.openTag(p,q);n=s+w.tagStart.length}else{j.value=k+m+e;n=s+m.length;w.closeTag(p,q)}}}j.focus();j.selectionStart=n;j.selectionEnd=n;j.scrollTop=h}else{if(!m){j.value+=w.tagStart}else{if(w.isOpen(q)!==false){j.value+=w.tagStart;w.openTag(p,q)}else{j.value+=m;w.closeTag(p,q)}}j.focus()}}};d.SpellButton=function(){d.Button.call(this,"spell",quicktagsL10n.lookup,"",quicktagsL10n.dictionaryLookup)};d.SpellButton.prototype=new d.Button();d.SpellButton.prototype.callback=function(i,h,e){var k="",j,g,f;if(document.selection){h.focus();j=document.selection.createRange();if(j.text.length>0){k=j.text}}else{if(h.selectionStart||h.selectionStart=="0"){g=h.selectionStart;f=h.selectionEnd;if(g!=f){k=h.value.substring(g,f)}}}if(k===""){k=prompt(quicktagsL10n.wordLookup,"")}if(k!==null&&/^\w[\w ]*$/.test(k)){window.open("http://www.answers.com/"+encodeURIComponent(k))}};d.CloseButton=function(){d.Button.call(this,"close",quicktagsL10n.closeTags,"",quicktagsL10n.closeAllOpenTags)};d.CloseButton.prototype=new d.Button();d._close=function(j,k,f){var h,g,i=f.openTags;if(i){while(i.length>0){h=f.getButton(i[i.length-1]);g=document.getElementById(f.name+"_"+h.id);h.callback.call(h,g,k,f)}}};d.CloseButton.prototype.callback=d._close;d.closeAllTags=function(f){var e=this.getInstance(f);d._close("",e.canvas,e)};d.LinkButton=function(){d.TagButton.call(this,"link","link","","</a>","a")};d.LinkButton.prototype=new d.TagButton();d.LinkButton.prototype.callback=function(j,k,h,g){var f,i=this;if(typeof(wpLink)!="undefined"){wpLink.open();return}if(!g){g="http://"}if(i.isOpen(h)===false){f=prompt(quicktagsL10n.enterURL,g);if(f){i.tagStart='<a href="'+f+'">';d.TagButton.prototype.callback.call(i,j,k,h)}}else{d.TagButton.prototype.callback.call(i,j,k,h)}};d.ImgButton=function(){d.TagButton.call(this,"img","img","","","m")};d.ImgButton.prototype=new d.TagButton();d.ImgButton.prototype.callback=function(i,k,g,f){if(!f){f="http://"}var j=prompt(quicktagsL10n.enterImageURL,f),h;if(j){h=prompt(quicktagsL10n.enterImageDescription,"");this.tagStart='<img src="'+j+'" alt="'+h+'" />';d.TagButton.prototype.callback.call(this,i,k,g)}};d.FullscreenButton=function(){d.Button.call(this,"fullscreen",quicktagsL10n.fullscreen,"f",quicktagsL10n.toggleFullscreen)};d.FullscreenButton.prototype=new d.Button();d.FullscreenButton.prototype.callback=function(f,g){if(g.id!="content"||typeof(fullscreen)=="undefined"){return}fullscreen.on()};edButtons[10]=new d.TagButton("strong","b","<strong>","</strong>","b");edButtons[20]=new d.TagButton("em","i","<em>","</em>","i"),edButtons[30]=new d.LinkButton(),edButtons[40]=new d.TagButton("block","b-quote","\n\n<blockquote>","</blockquote>\n\n","q"),edButtons[50]=new d.TagButton("del","del",'<del datetime="'+a+'">',"</del>","d"),edButtons[60]=new d.TagButton("ins","ins",'<ins datetime="'+a+'">',"</ins>","s"),edButtons[70]=new d.ImgButton(),edButtons[80]=new d.TagButton("ul","ul","<ul>\n","</ul>\n\n","u"),edButtons[90]=new d.TagButton("ol","ol","<ol>\n","</ol>\n\n","o"),edButtons[100]=new d.TagButton("li","li","\t<li>","</li>\n","l"),edButtons[110]=new d.TagButton("code","code","<code>","</code>","c"),edButtons[120]=new d.TagButton("more","more","<!--more-->","","t"),edButtons[130]=new d.SpellButton(),edButtons[140]=new d.CloseButton()})(); 
     1var QTags,edButtons=[],edCanvas,edAddTag=function(){},edCheckOpenTags=function(){},edCloseAllTags=function(){},edInsertImage=function(){},edInsertLink=function(){},edInsertTag=function(){},edLink=function(){},edQuickLink=function(){},edRemoveTag=function(){},edShowButton=function(){},edShowLinks=function(){},edSpell=function(){},edToolbar=function(){};function quicktags(a){return new QTags(a)}function edInsertContent(b,a){return QTags.insertContent(a)}function edButton(f,e,c,b,a,d){return QTags.addButton(f,e,c,b,a,"",-1)}(function(){var b=function(g){var f,e,d;if(typeof jQuery!="undefined"){jQuery(document).ready(g)}else{f=b;f.funcs=[];f.ready=function(){if(!f.isReady){f.isReady=true;for(e=0;e<f.funcs.length;e++){f.funcs[e]()}}};if(f.isReady){g()}else{f.funcs.push(g)}if(!f.eventAttached){if(document.addEventListener){d=function(){document.removeEventListener("DOMContentLoaded",d,false);f.ready()};document.addEventListener("DOMContentLoaded",d,false);window.addEventListener("load",f.ready,false)}else{if(document.attachEvent){d=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",d);f.ready()}};document.attachEvent("onreadystatechange",d);window.attachEvent("onload",f.ready);(function(){try{document.documentElement.doScroll("left")}catch(h){setTimeout(arguments.callee,50);return}f.ready()})()}}f.eventAttached=true}}},a=(function(){var d=new Date(),e;e=function(f){var g=f.toString();if(g.length<2){g="0"+g}return g};return d.getUTCFullYear()+"-"+e(d.getUTCMonth()+1)+"-"+e(d.getUTCDate())+"T"+e(d.getUTCHours())+":"+e(d.getUTCMinutes())+":"+e(d.getUTCSeconds())+"+00:00"})(),c;c=QTags=function(j){if(typeof(j)=="string"){j={id:j}}else{if(typeof(j)!="object"){return false}}var i=this,k=j.id,h=document.getElementById(k),g="qt_"+k,d,f,e;if(!k||!h){return false}i.name=g;i.id=k;i.canvas=h;i.settings=j;if(k=="content"&&typeof(adminpage)=="string"&&(adminpage=="post-new-php"||adminpage=="post-php")){edCanvas=h;e="ed_toolbar"}else{e=g+"_toolbar"}d=document.createElement("div");d.id=e;d.className="quicktags-toolbar";h.parentNode.insertBefore(d,h);i.toolbar=d;f=function(n){n=n||window.event;var m=n.target||n.srcElement,l;if(/ ed_button /.test(" "+m.className+" ")){i.canvas=h=document.getElementById(k);l=m.id.replace(g+"_","");if(i.theButtons[l]){i.theButtons[l].callback.call(i.theButtons[l],m,h,i)}}};if(d.addEventListener){d.addEventListener("click",f,false)}else{if(d.attachEvent){d.attachEvent("onclick",f)}}i.getButton=function(l){return i.theButtons[l]};i.getButtonElement=function(l){return document.getElementById(g+"_"+l)};c.instances[k]=i;if(!c.instances[0]){c.instances[0]=c.instances[k];b(function(){c._buttonsInit()})}};c.instances={};c.getInstance=function(d){return c.instances[d]};c._buttonsInit=function(){var p=this,g,e,h,o,m,l,n,f,k,d="",j=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,";for(l in p.instances){if(l==0){continue}n=p.instances[l];g=n.canvas;e=n.name;h=n.settings;m="";o={};if(h.buttons){d=","+h.buttons+","}for(k in edButtons){if(!edButtons[k]){continue}f=edButtons[k].id;if(d&&j.indexOf(","+f+",")!=-1&&d.indexOf(","+f+",")==-1){continue}if(!edButtons[k].instance||edButtons[k].instance==l){o[f]=edButtons[k]}}for(k in o){if(!o[k]||!o[k].html){continue}m+=o[k].html(e+"_")}n.toolbar.innerHTML=m;n.theButtons=o}p.buttonsInitDone=true};c.addButton=function(e,i,h,g,d,j,k,l){var f;if(!e||!i){return}k=k||0;g=g||"";if(typeof(h)==="function"){f=new c.Button(e,i,d,j,l);f.callback=h}else{if(typeof(h)==="string"){f=new c.TagButton(e,i,h,g,d,j,l)}else{return}}if(k==-1){return f}if(k>0){while(typeof(edButtons[k])!="undefined"){k++}edButtons[k]=f}else{edButtons[edButtons.length]=f}if(this.buttonsInitDone){this._buttonsInit()}};c.insertContent=function(g){var h,f,e,i,j,d=document.getElementById(wpActiveEditor);if(!d){return false}if(document.selection){d.focus();h=document.selection.createRange();h.text=g;d.focus()}else{if(d.selectionStart||d.selectionStart=="0"){j=d.value;f=d.selectionStart;e=d.selectionEnd;i=d.scrollTop;d.value=j.substring(0,f)+g+j.substring(e,j.length);d.focus();d.selectionStart=f+g.length;d.selectionEnd=f+g.length;d.scrollTop=i}else{d.value+=g;d.focus()}}return true};c.Button=function(i,g,e,h,d){var f=this;f.id=i;f.display=g;f.access=e;f.title=h||"";f.instance=d||""};c.Button.prototype.html=function(e){var d=this.access?' accesskey="'+this.access+'"':"";return'<input type="button" id="'+e+this.id+'"'+d+' class="ed_button" title="'+this.title+'" value="'+this.display+'" />'};c.Button.prototype.callback=function(){};c.TagButton=function(k,i,g,f,e,j,d){var h=this;c.Button.call(h,k,i,e,j,d);h.tagStart=g;h.tagEnd=f};c.TagButton.prototype=new c.Button();c.TagButton.prototype.openTag=function(g,d){var f=this;if(!d.openTags){d.openTags=[]}if(f.tagEnd){d.openTags.push(f.id);g.value="/"+g.value}};c.TagButton.prototype.closeTag=function(h,d){var g=this,f=g.isOpen(d);if(f!==false){d.openTags.splice(f,1)}h.value=g.display};c.TagButton.prototype.isOpen=function(d){var g=this,f=0,e=false;if(d.openTags){while(e===false&&f<d.openTags.length){e=d.openTags[f]==g.id?f:false;f++}}else{e=false}return e};c.TagButton.prototype.callback=function(o,h,p){var u=this,q,e,m,g,s=h.value,j,d,n,f,k=s?u.tagEnd:"";if(document.selection){h.focus();f=document.selection.createRange();if(f.text.length>0){if(!u.tagEnd){f.text=f.text+u.tagStart}else{f.text=u.tagStart+f.text+k}}else{if(!u.tagEnd){f.text=u.tagStart}else{if(u.isOpen(p)===false){f.text=u.tagStart;u.openTag(o,p)}else{f.text=k;u.closeTag(o,p)}}}h.focus()}else{if(h.selectionStart||h.selectionStart=="0"){q=h.selectionStart;e=h.selectionEnd;m=e;g=h.scrollTop;j=s.substring(0,q);d=s.substring(e,s.length);n=s.substring(q,e);if(q!=e){if(!u.tagEnd){h.value=j+n+u.tagStart+d;m+=u.tagStart.length}else{h.value=j+u.tagStart+n+k+d;m+=u.tagStart.length+k.length}}else{if(!u.tagEnd){h.value=j+u.tagStart+d;m=q+u.tagStart.length}else{if(u.isOpen(p)===false){h.value=j+u.tagStart+d;u.openTag(o,p);m=q+u.tagStart.length}else{h.value=j+k+d;m=q+k.length;u.closeTag(o,p)}}}h.focus();h.selectionStart=m;h.selectionEnd=m;h.scrollTop=g}else{if(!k){h.value+=u.tagStart}else{if(u.isOpen(p)!==false){h.value+=u.tagStart;u.openTag(o,p)}else{h.value+=k;u.closeTag(o,p)}}h.focus()}}};c.SpellButton=function(){c.Button.call(this,"spell",quicktagsL10n.lookup,"",quicktagsL10n.dictionaryLookup)};c.SpellButton.prototype=new c.Button();c.SpellButton.prototype.callback=function(h,g,d){var j="",i,f,e;if(document.selection){g.focus();i=document.selection.createRange();if(i.text.length>0){j=i.text}}else{if(g.selectionStart||g.selectionStart=="0"){f=g.selectionStart;e=g.selectionEnd;if(f!=e){j=g.value.substring(f,e)}}}if(j===""){j=prompt(quicktagsL10n.wordLookup,"")}if(j!==null&&/^\w[\w ]*$/.test(j)){window.open("http://www.answers.com/"+encodeURIComponent(j))}};c.CloseButton=function(){c.Button.call(this,"close",quicktagsL10n.closeTags,"",quicktagsL10n.closeAllOpenTags)};c.CloseButton.prototype=new c.Button();c._close=function(i,j,d){var g,f,h=d.openTags;if(h){while(h.length>0){g=d.getButton(h[h.length-1]);f=document.getElementById(d.name+"_"+g.id);g.callback.call(g,f,j,d)}}};c.CloseButton.prototype.callback=c._close;c.closeAllTags=function(e){var d=this.getInstance(e);c._close("",d.canvas,d)};c.LinkButton=function(){c.TagButton.call(this,"link","link","","</a>","a")};c.LinkButton.prototype=new c.TagButton();c.LinkButton.prototype.callback=function(i,j,g,f){var d,h=this;if(typeof(wpLink)!="undefined"){wpLink.open();return}if(!f){f="http://"}if(h.isOpen(g)===false){d=prompt(quicktagsL10n.enterURL,f);if(d){h.tagStart='<a href="'+d+'">';c.TagButton.prototype.callback.call(h,i,j,g)}}else{c.TagButton.prototype.callback.call(h,i,j,g)}};c.ImgButton=function(){c.TagButton.call(this,"img","img","","","m")};c.ImgButton.prototype=new c.TagButton();c.ImgButton.prototype.callback=function(h,j,f,d){if(!d){d="http://"}var i=prompt(quicktagsL10n.enterImageURL,d),g;if(i){g=prompt(quicktagsL10n.enterImageDescription,"");this.tagStart='<img src="'+i+'" alt="'+g+'" />';c.TagButton.prototype.callback.call(this,h,j,f)}};c.FullscreenButton=function(){c.Button.call(this,"fullscreen",quicktagsL10n.fullscreen,"f",quicktagsL10n.toggleFullscreen)};c.FullscreenButton.prototype=new c.Button();c.FullscreenButton.prototype.callback=function(d,f){if(f.id!="content"||typeof(fullscreen)=="undefined"){return}fullscreen.on()};edButtons[10]=new c.TagButton("strong","b","<strong>","</strong>","b");edButtons[20]=new c.TagButton("em","i","<em>","</em>","i"),edButtons[30]=new c.LinkButton(),edButtons[40]=new c.TagButton("block","b-quote","\n\n<blockquote>","</blockquote>\n\n","q"),edButtons[50]=new c.TagButton("del","del",'<del datetime="'+a+'">',"</del>","d"),edButtons[60]=new c.TagButton("ins","ins",'<ins datetime="'+a+'">',"</ins>","s"),edButtons[70]=new c.ImgButton(),edButtons[80]=new c.TagButton("ul","ul","<ul>\n","</ul>\n\n","u"),edButtons[90]=new c.TagButton("ol","ol","<ol>\n","</ol>\n\n","o"),edButtons[100]=new c.TagButton("li","li","\t<li>","</li>\n","l"),edButtons[110]=new c.TagButton("code","code","<code>","</code>","c"),edButtons[120]=new c.TagButton("more","more","<!--more-->","","t"),edButtons[130]=new c.SpellButton(),edButtons[140]=new c.CloseButton()})(); 
  • trunk/wp-includes/script-loader.php

    r19168 r19172  
    6969    $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1', 1 ); 
    7070 
    71     $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110919', 1 ); 
     71    $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20111105', 1 ); 
    7272    $scripts->add_script_data( 'quicktags', 'quicktagsL10n', array( 
    7373        'wordLookup' => __('Enter a word to look up:'), 
Note: See TracChangeset for help on using the changeset viewer.