Make WordPress Core

Ticket #16631: 16631.diff

File 16631.diff, 15.8 KB (added by koopersmith, 14 years ago)
  • wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js

     
    99                riverBottomThreshold: 5,
    1010                keySensitivity: 100,
    1111                lastSearch: '',
     12                textarea: edCanvas,
     13
    1214                init : function() {
    1315                        inputs.dialog = $('#wp-link');
    1416                        inputs.submit = $('#wp-link-submit');
     
    3133                                wpLink.update();
    3234                                e.preventDefault();
    3335                        });
    34                         $('#wp-link-cancel').click( wpLink.cancel );
     36                        $('#wp-link-cancel').click( wpLink.close );
    3537                        $('#internal-toggle').click( wpLink.toggleInternalLinking );
    3638
    3739                        rivers.elements.bind('river-select', wpLink.updateFields );
     
    3941                        inputs.search.keyup( wpLink.searchInternalLinks );
    4042
    4143                        inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);
     44                        inputs.dialog.bind('wpdialogbeforeopen', wpLink.beforeOpen);
     45                        inputs.dialog.bind('wpdialogclose', wpLink.onClose);
    4246                },
    4347
     48                beforeOpen : function() {
     49                        wpLink.range = null;
     50
     51                        if ( ! wpLink.isMCE() && document.selection ) {
     52                                wpLink.textarea.focus();
     53                                wpLink.range = document.selection.createRange();
     54                        }
     55                },
     56
     57                open : function() {
     58                        // Initialize the dialog if necessary (html mode).
     59                        if ( ! inputs.dialog.data('wpdialog') ) {
     60                                inputs.dialog.wpdialog({
     61                                        title: wpLinkL10n.title,
     62                                        width: 480,
     63                                        height: 'auto',
     64                                        modal: true,
     65                                        dialogClass: 'wp-dialog',
     66                                        zIndex: 300000
     67                                });
     68                        }
     69
     70                        inputs.dialog.wpdialog('open');
     71                },
     72
     73                isMCE : function() {
     74                        return tinyMCEPopup && ( ed = tinyMCEPopup.editor ) && ! ed.isHidden();
     75                },
     76
    4477                refresh : function() {
    45                         var e;
    46                         ed = tinyMCEPopup.editor;
    47 
    4878                        // Refresh rivers (clear links, check visibility)
    4979                        rivers.search.refresh();
    5080                        rivers.recent.refresh();
    5181
     82                        if ( wpLink.isMCE() )
     83                                wpLink.mceRefresh();
     84                        else
     85                                wpLink.setDefaultValues();
     86
     87                        // Focus the URL field and highlight its contents.
     88                        //     If this is moved above the selection changes,
     89                        //     IE will show a flashing cursor over the dialog.
     90                        inputs.url.focus()[0].select();
     91                        // Load the most recent results if this is the first time opening the panel.
     92                        if ( ! rivers.recent.ul.children().length )
     93                                rivers.recent.ajax();
     94                },
     95
     96                mceRefresh : function() {
     97                        var e;
     98                        ed = tinyMCEPopup.editor;
     99
    52100                        tinyMCEPopup.restoreSelection();
    53101
    54102                        // If link exists, select proper values.
     
    65113                        // If there's no link, set the default values.
    66114                        } else {
    67115                                wpLink.setDefaultValues();
    68                                 // Update save prompt.
    69                                 inputs.submit.val( wpLinkL10n.save );
    70116                        }
    71117
    72118                        tinyMCEPopup.storeSelection();
    73                         // Focus the URL field and highlight its contents.
    74                         //     If this is moved above the selection changes,
    75                         //     IE will show a flashing cursor over the dialog.
    76                         inputs.url.focus()[0].select();
    77                         // Load the most recent results if this is the first time opening the panel.
    78                         if ( ! rivers.recent.ul.children().length )
    79                                 rivers.recent.ajax();
    80119                },
    81120
    82                 cancel : function() {
    83                         tinyMCEPopup.close();
     121                close : function() {
     122                        if ( wpLink.isMCE() )
     123                                tinyMCEPopup.close();
     124                        else
     125                                inputs.dialog.wpdialog('close');
    84126                },
    85127
     128                onClose: function() {
     129                        if ( ! wpLink.isMCE() ) {
     130                                wpLink.textarea.focus();
     131                                if ( wpLink.range ) {
     132                                        wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
     133                                        wpLink.range.select();
     134                                }
     135                        }
     136                },
     137
     138                getAttrs : function() {
     139                        return {
     140                                href : inputs.url.val(),
     141                                title : inputs.title.val(),
     142                                target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
     143                        };
     144                },
     145
    86146                update : function() {
     147                        if ( wpLink.isMCE() )
     148                                wpLink.mceUpdate();
     149                        else
     150                                wpLink.htmlUpdate();
     151                },
     152
     153                htmlUpdate : function() {
     154                        var attrs, html, start, end, cursor,
     155                                textarea = wpLink.textarea;
     156
     157                        if ( ! textarea )
     158                                return;
     159
     160                        attrs = wpLink.getAttrs();
     161
     162                        // If there's no href, return.
     163                        if ( ! attrs.href || attrs.href == 'http://' )
     164                                return;
     165
     166                        // Build HTML
     167                        html = '<a href="' + attrs.href + '"';
     168
     169                        if ( attrs.title )
     170                                html += ' title="' + attrs.title + '"';
     171                        if ( attrs.target )
     172                                html += ' target="' + attrs.target + '"';
     173
     174                        html += '>';
     175
     176                        // Insert HTML
     177                        // W3C
     178                        if ( typeof textarea.selectionStart !== 'undefined' ) {
     179                                start       = textarea.selectionStart;
     180                                end         = textarea.selectionEnd;
     181                                selection   = textarea.value.substring( start, end );
     182                                html        = html + selection + '</a>';
     183                                cursor      = start + html.length;
     184
     185                                // If no next is selected, place the cursor inside the closing tag.
     186                                if ( start == end )
     187                                        cursor -= '</a>'.length;
     188
     189                                textarea.value = textarea.value.substring( 0, start )
     190                                               + html
     191                                               + textarea.value.substring( end, textarea.value.length );
     192
     193                                // Update cursor position
     194                                textarea.selectionStart = textarea.selectionEnd = cursor;
     195
     196                        // IE
     197                        // Note: If no text is selected, IE will not place the cursor
     198                        //       inside the closing tag.
     199                        } else if ( document.selection && wpLink.range ) {
     200                                textarea.focus();
     201                                wpLink.range.text = html + wpLink.range.text + '</a>';
     202                                wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
     203                                wpLink.range.select();
     204
     205                                wpLink.range = null;
     206                        }
     207
     208                        wpLink.close();
     209                        textarea.focus();
     210                },
     211
     212                mceUpdate : function() {
    87213                        var ed = tinyMCEPopup.editor,
    88                                 attrs = {
    89                                         href : inputs.url.val(),
    90                                         title : inputs.title.val(),
    91                                         target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
    92                                 }, e, b;
     214                                attrs = wpLink.getAttrs(),
     215                                e, b;
    93216
    94217                        tinyMCEPopup.restoreSelection();
    95218                        e = ed.dom.getParent(ed.selection.getNode(), 'A');
     
    102225                                        ed.dom.remove(e, 1);
    103226                                        ed.selection.moveToBookmark(b);
    104227                                        tinyMCEPopup.execCommand("mceEndUndoLevel");
    105                                         tinyMCEPopup.close();
     228                                        wpLink.close();
    106229                                }
    107230                                return;
    108231                        }
     
    140263                        }
    141264
    142265                        tinyMCEPopup.execCommand("mceEndUndoLevel");
    143                         tinyMCEPopup.close();
     266                        wpLink.close();
    144267                },
    145268
    146269                updateFields : function( e, li, originalEvent ) {
     
    154277                        // Leave the new tab setting as-is.
    155278                        inputs.url.val('http://');
    156279                        inputs.title.val('');
     280
     281                        // Update save prompt.
     282                        inputs.submit.val( wpLinkL10n.save );
    157283                },
    158284
    159285                searchInternalLinks : function() {
     
    210336
    211337                        switch( event.which ) {
    212338                                case key.ESCAPE:
    213                                         wpLink.cancel();
     339                                        wpLink.close();
    214340                                        break;
    215341                                case key.UP:
    216342                                case key.DOWN:
  • wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js

     
    1 (function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});b(document).ready(function(){b.widget("wp.wpdialog",b.ui.dialog,{open:function(){if(tinyMCEPopup){tinyMCEPopup.init()}b.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.wpdialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery);
    2  No newline at end of file
     1(function(){tinymce.create("tinymce.plugins.WPDialogs",{init:function(a,b){tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=jQuery("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);if(!c.data("wpdialog")){c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})}c.wpdialog("open")},close:function(){if(!this.features.wpDialog){return this.parent.apply(this,arguments)}this.element.wpdialog("close")}});a.onBeforeRenderUI.add(function(){a.windowManager=new tinymce.WPWindowManager(a)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})();
     2 No newline at end of file
  • wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog.dev.js

     
     1(function($){
     2        $.widget("wp.wpdialog", $.ui.dialog, {
     3                open: function() {
     4                        // Initialize tinyMCEPopup if it exists and is the editor is active.
     5                        if ( tinyMCEPopup && typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
     6                                tinyMCEPopup.init();
     7                        }
     8
     9                        // Add beforeOpen event.
     10                        if ( this._isOpen || false === this._trigger('beforeOpen') ) {
     11                                return;
     12                        }
     13
     14                        // Open the dialog.
     15                        $.ui.dialog.prototype.open.apply( this, arguments );
     16                        // WebKit leaves focus in the TinyMCE editor unless we shift focus.
     17                        this.element.focus();
     18                        this._trigger('refresh');
     19                }
     20        });
     21})(jQuery);
     22 No newline at end of file
  • wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js

     
    88 * Contributing: http://tinymce.moxiecode.com/contributing
    99 */
    1010
    11 (function($) {
    12         var wpDialogFn = function( fn ) {
    13                 return function() {
    14                         if ( this.features.wpDialog )
    15                                 return fn.apply( this, arguments );
    16                         else
    17                                 return this.parent.apply( this, arguments );
    18                 };
    19         };
    20 
     11(function() {
    2112        tinymce.create('tinymce.plugins.WPDialogs', {
    2213                init : function(ed, url) {
     14                        tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
     15                                WPWindowManager : function(ed) {
     16                                        this.parent(ed);
     17                                },
     18
     19                                open : function(f, p) {
     20                                        var t = this, element;
     21
     22                                        if ( ! f.wpDialog )
     23                                                return this.parent( f, p );
     24                                        else if ( ! f.id )
     25                                                return;
     26
     27                                        element = jQuery('#' + f.id);
     28                                        if ( ! element.length )
     29                                                return;
     30
     31                                        t.features = f;
     32                                        t.params = p;
     33                                        t.onOpen.dispatch(t, f, p);
     34                                        t.element = t.windows[ f.id ] = element;
     35
     36                                        // Store selection
     37                                        t.bookmark = t.editor.selection.getBookmark(1);
     38
     39                                        // Create the dialog if necessary
     40                                        if ( ! element.data('wpdialog') ) {
     41                                                element.wpdialog({
     42                                                        title: f.title,
     43                                                        width: f.width,
     44                                                        height: f.height,
     45                                                        modal: true,
     46                                                        dialogClass: 'wp-dialog',
     47                                                        zIndex: 300000
     48                                                });
     49                                        }
     50
     51                                        element.wpdialog('open');
     52                                },
     53                                close : function() {
     54                                        if ( ! this.features.wpDialog )
     55                                                return this.parent.apply( this, arguments );
     56
     57                                        this.element.wpdialog('close');
     58                                }
     59                        });
     60
    2361                        // Replace window manager
    2462                        ed.onBeforeRenderUI.add(function() {
    2563                                ed.windowManager = new tinymce.WPWindowManager(ed);
     
    3674                        };
    3775                }
    3876        });
    39        
    40         $(document).ready(function() {
    41                 $.widget("wp.wpdialog", $.ui.dialog, {
    42                         open: function() {
    43                                 // Initialize tinyMCEPopup if it exists.
    44                                 if ( tinyMCEPopup )
    45                                         tinyMCEPopup.init();
    46                                 // Open the dialog.
    47                                 $.ui.dialog.prototype.open.apply( this, arguments );
    48                                 // WebKit leaves focus in the TinyMCE editor unless we shift focus.
    49                                 this.element.focus();
    50                                 this._trigger('refresh');
    51                         }
    52                 });
    53         });
    5477
    55         tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
    56                 WPWindowManager : function(ed) {
    57                         this.parent(ed);
    58                 },
    59 
    60                 open : function(f, p) {
    61                         var t = this, element;
    62                         // Can't use wpDialogFn here; this.features isn't set yet.
    63                         if ( ! f.wpDialog )
    64                                 return this.parent( f, p );
    65                         else if ( ! f.id )
    66                                 return;
    67                        
    68                         element = $('#' + f.id);
    69                         if ( ! element.length )
    70                                 return;
    71                        
    72                         t.features = f;
    73                         t.params = p;
    74                         t.onOpen.dispatch(t, f, p);
    75                         t.element = t.windows[ f.id ] = element;
    76                        
    77                         // Store selection
    78                         t.bookmark = t.editor.selection.getBookmark(1);
    79                        
    80                         element.wpdialog({
    81                                 title: f.title,
    82                                 width: f.width,
    83                                 height: f.height,
    84                                 modal: true,
    85                                 dialogClass: 'wp-dialog',
    86                                 zIndex: 300000
    87                         });
    88                 },
    89                 close : wpDialogFn(function() {
    90                         this.element.wpdialog('close');
    91                 })
    92         });
    93 
    9478        // Register plugin
    9579        tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs);
    96 })(jQuery);
    97 
     80})();
  • wp-includes/js/quicktags.dev.js

     
    157157                document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');
    158158        }
    159159        else if (button.id == 'ed_link') {
    160                 document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
     160                document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="wpLink.open();" value="' + button.display + '" />');
    161161        }
    162162        else {
    163163                document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '"  />');
  • wp-includes/script-loader.php

     
    267267        $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
    268268        $scripts->add_data( 'admin-bar', 'group', 1 );
    269269
    270         $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20110111' );
     270        $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110421' );
    271271        $scripts->localize( 'wplink', 'wpLinkL10n', array(
     272                'title' => __('Insert/edit link'),
    272273                'update' => __('Update'),
    273274                'save' => __('Add Link'),
    274275                'noTitle' => __('(no title)'),
     
    276277                'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
    277278        ) );
    278279
    279         $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'jquery-ui-dialog' ), '20101119' );
     280        $scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), '20110421' );
     281        $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'wpdialogs' ), '20110421' );
    280282
    281283        if ( is_admin() ) {
    282284                $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );