Ticket #16631: 16631.diff
File 16631.diff, 15.8 KB (added by , 14 years ago) |
---|
-
wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
9 9 riverBottomThreshold: 5, 10 10 keySensitivity: 100, 11 11 lastSearch: '', 12 textarea: edCanvas, 13 12 14 init : function() { 13 15 inputs.dialog = $('#wp-link'); 14 16 inputs.submit = $('#wp-link-submit'); … … 31 33 wpLink.update(); 32 34 e.preventDefault(); 33 35 }); 34 $('#wp-link-cancel').click( wpLink.c ancel);36 $('#wp-link-cancel').click( wpLink.close ); 35 37 $('#internal-toggle').click( wpLink.toggleInternalLinking ); 36 38 37 39 rivers.elements.bind('river-select', wpLink.updateFields ); … … 39 41 inputs.search.keyup( wpLink.searchInternalLinks ); 40 42 41 43 inputs.dialog.bind('wpdialogrefresh', wpLink.refresh); 44 inputs.dialog.bind('wpdialogbeforeopen', wpLink.beforeOpen); 45 inputs.dialog.bind('wpdialogclose', wpLink.onClose); 42 46 }, 43 47 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 44 77 refresh : function() { 45 var e;46 ed = tinyMCEPopup.editor;47 48 78 // Refresh rivers (clear links, check visibility) 49 79 rivers.search.refresh(); 50 80 rivers.recent.refresh(); 51 81 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 52 100 tinyMCEPopup.restoreSelection(); 53 101 54 102 // If link exists, select proper values. … … 65 113 // If there's no link, set the default values. 66 114 } else { 67 115 wpLink.setDefaultValues(); 68 // Update save prompt.69 inputs.submit.val( wpLinkL10n.save );70 116 } 71 117 72 118 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();80 119 }, 81 120 82 cancel : function() { 83 tinyMCEPopup.close(); 121 close : function() { 122 if ( wpLink.isMCE() ) 123 tinyMCEPopup.close(); 124 else 125 inputs.dialog.wpdialog('close'); 84 126 }, 85 127 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 86 146 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() { 87 213 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; 93 216 94 217 tinyMCEPopup.restoreSelection(); 95 218 e = ed.dom.getParent(ed.selection.getNode(), 'A'); … … 102 225 ed.dom.remove(e, 1); 103 226 ed.selection.moveToBookmark(b); 104 227 tinyMCEPopup.execCommand("mceEndUndoLevel"); 105 tinyMCEPopup.close();228 wpLink.close(); 106 229 } 107 230 return; 108 231 } … … 140 263 } 141 264 142 265 tinyMCEPopup.execCommand("mceEndUndoLevel"); 143 tinyMCEPopup.close();266 wpLink.close(); 144 267 }, 145 268 146 269 updateFields : function( e, li, originalEvent ) { … … 154 277 // Leave the new tab setting as-is. 155 278 inputs.url.val('http://'); 156 279 inputs.title.val(''); 280 281 // Update save prompt. 282 inputs.submit.val( wpLinkL10n.save ); 157 283 }, 158 284 159 285 searchInternalLinks : function() { … … 210 336 211 337 switch( event.which ) { 212 338 case key.ESCAPE: 213 wpLink.c ancel();339 wpLink.close(); 214 340 break; 215 341 case key.UP: 216 342 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
8 8 * Contributing: http://tinymce.moxiecode.com/contributing 9 9 */ 10 10 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() { 21 12 tinymce.create('tinymce.plugins.WPDialogs', { 22 13 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 23 61 // Replace window manager 24 62 ed.onBeforeRenderUI.add(function() { 25 63 ed.windowManager = new tinymce.WPWindowManager(ed); … … 36 74 }; 37 75 } 38 76 }); 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 });54 77 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 selection78 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: 30000087 });88 },89 close : wpDialogFn(function() {90 this.element.wpdialog('close');91 })92 });93 94 78 // Register plugin 95 79 tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs); 96 })(jQuery); 97 80 })(); -
wp-includes/js/quicktags.dev.js
157 157 document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />'); 158 158 } 159 159 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 + '" />'); 161 161 } 162 162 else { 163 163 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
267 267 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' ); 268 268 $scripts->add_data( 'admin-bar', 'group', 1 ); 269 269 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' ); 271 271 $scripts->localize( 'wplink', 'wpLinkL10n', array( 272 'title' => __('Insert/edit link'), 272 273 'update' => __('Update'), 273 274 'save' => __('Add Link'), 274 275 'noTitle' => __('(no title)'), … … 276 277 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};', 277 278 ) ); 278 279 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' ); 280 282 281 283 if ( is_admin() ) { 282 284 $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );