Changeset 30560
- Timestamp:
- 11/25/2014 04:30:31 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
r30558 r30560 1 1 /* global tinymce */ 2 2 tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 3 var tb, serializer,3 var floatingToolbar, serializer, 4 4 DOM = tinymce.DOM, 5 5 settings = editor.settings, … … 156 156 } 157 157 158 tb= Factory.create( toolbarConfig() ).renderTo( document.body ).hide();159 160 tb.reposition = function() {158 floatingToolbar = Factory.create( toolbarConfig() ).renderTo( document.body ).hide(); 159 160 floatingToolbar.reposition = function() { 161 161 var top, left, minTop, className, 162 windowPos, adminbar, mceToolbar, boundary, 163 boundaryMiddle, boundaryVerticalMiddle, spaceTop, 164 spaceBottom, windowWidth, toolbarWidth, toolbarHalf, 165 iframe, iframePos, iframeWidth, iframeHeigth, 166 toolbarNodeHeight, verticalSpaceNeeded, 162 167 toolbarNode = this.getEl(), 163 168 buffer = 5, 164 169 margin = 8, 165 windowPos = window.pageYOffset || document.documentElement.scrollTop,166 adminbar = tinymce.$( '#wpadminbar' )[0],167 mceToolbar = tinymce.$( '.mce-tinymce .mce-toolbar-grp' )[0],168 170 adminbarHeight = 0, 169 boundary = editor.selection.getNode().getBoundingClientRect(), 170 boundaryMiddle = ( boundary.left + boundary.right ) / 2, 171 boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2, 172 spaceTop = boundary.top, 173 spaceBottom = iframeHeigth - boundary.bottom, 174 windowWidth = window.innerWidth, 175 toolbarWidth = toolbarNode.offsetWidth, 176 toolbarHalf = toolbarWidth / 2, 177 iframe = editor.getContentAreaContainer().firstChild, 178 iframePos = DOM.getPos( iframe ), 179 iframeWidth = iframe.offsetWidth, 180 iframeHeigth = iframe.offsetHeight, 181 toolbarNodeHeight = toolbarNode.offsetHeight, 182 verticalSpaceNeeded = toolbarNodeHeight + margin + buffer; 171 imageNode = editor.selection.getNode(); 172 173 if ( ! imageNode || imageNode.nodeName !== 'IMG' ) { 174 return this; 175 } 176 177 windowPos = window.pageYOffset || document.documentElement.scrollTop; 178 adminbar = tinymce.$( '#wpadminbar' )[0]; 179 mceToolbar = tinymce.$( '.mce-tinymce .mce-toolbar-grp' )[0]; 180 boundary = imageNode.getBoundingClientRect(); 181 boundaryMiddle = ( boundary.left + boundary.right ) / 2; 182 boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2; 183 spaceTop = boundary.top; 184 spaceBottom = iframeHeigth - boundary.bottom; 185 windowWidth = window.innerWidth; 186 toolbarWidth = toolbarNode.offsetWidth; 187 toolbarHalf = toolbarWidth / 2; 188 iframe = editor.getContentAreaContainer().firstChild; 189 iframePos = DOM.getPos( iframe ); 190 iframeWidth = iframe.offsetWidth; 191 iframeHeigth = iframe.offsetHeight; 192 toolbarNodeHeight = toolbarNode.offsetHeight; 193 verticalSpaceNeeded = toolbarNodeHeight + margin + buffer; 183 194 184 195 if ( iOS ) { … … 264 275 }, 200 ); 265 276 } else { 266 tb.hide();277 floatingToolbar.hide(); 267 278 } 268 279 }); … … 273 284 274 285 if ( event.element.nodeName !== 'IMG' || isPlaceholder( event.element ) ) { 275 tb.hide();286 floatingToolbar.hide(); 276 287 return; 277 288 } … … 281 292 282 293 if ( element.nodeName === 'IMG' && ! isPlaceholder( element ) ) { 283 if ( tb._visible ) {284 tb.reposition();294 if ( floatingToolbar._visible ) { 295 floatingToolbar.reposition(); 285 296 } else { 286 tb.show();297 floatingToolbar.show(); 287 298 } 288 299 } else { 289 tb.hide();300 floatingToolbar.hide(); 290 301 } 291 302 }, delay ); 292 303 } ); 293 304 294 tb.on( 'show', function() {305 floatingToolbar.on( 'show', function() { 295 306 var self = this; 296 307 … … 305 316 } ); 306 317 307 tb.on( 'hide', function() {318 floatingToolbar.on( 'hide', function() { 308 319 toolbarIsHidden = true; 309 320 DOM.removeClass( this.getEl(), 'mce-inline-toolbar-grp-active' ); … … 312 323 function hide() { 313 324 if ( ! toolbarIsHidden ) { 314 tb.hide();325 floatingToolbar.hide(); 315 326 } 316 327 } … … 323 334 324 335 editor.on( 'init', function() { 325 DOM.bind( editor.getWin(), 'resizescroll', hide );326 } 327 336 editor.dom.bind( editor.getWin(), 'scroll', hide ); 337 }); 338 328 339 editor.on( 'blur hide', hide ); 329 340 330 341 // 119 = F8 331 342 editor.shortcuts.add( 'Alt+119', '', function() { 332 var node = tb.find( 'toolbar' )[0];343 var node = floatingToolbar.find( 'toolbar' )[0]; 333 344 334 345 if ( node ) { 335 346 node.focus( true ); 336 347 } 337 } 348 }); 338 349 339 350 function parseShortcode( content ) { … … 1111 1122 event.preventDefault(); 1112 1123 1113 if ( tb) {1114 tb.reposition();1124 if ( floatingToolbar ) { 1125 floatingToolbar.reposition(); 1115 1126 } 1116 1127 }
Note: See TracChangeset
for help on using the changeset viewer.