Ticket #4594: 4594_2.patch
File 4594_2.patch, 4.7 KB (added by , 14 years ago) |
---|
-
_source/plugins/menu/plugin.js
97 97 // Get the element representing the current item. 98 98 var element = this._.panel.getBlock( this.id ).element.getDocument().getById( this.id + String( index ) ); 99 99 100 // Show the submenu. 101 menu.show( element, 2 ); 100 // Show the submenu, reverse the 'corner' when necessary. 101 menu.show( element, this._.reverse ? 1 : 2 ); 102 // Inheirit the reverse from parent menu. 103 menu._.reverse = this._.reverse; 102 104 } 103 105 }, 104 106 … … 147 149 148 150 panel.onHide = CKEDITOR.tools.bind( function() 149 151 { 152 delete this._.reverse; 150 153 this.onHide && this.onHide(); 151 154 }, 152 155 this ); … … 227 230 // Inject the HTML inside the panel. 228 231 element.setHtml( output.join( '' ) ); 229 232 233 // Off-screen menu support. (#4594) 234 panel.on( 'position', function ( evt ) 235 { 236 evt.removeListener(); 237 238 var left = evt.data.left, 239 top = evt.data.top, 240 panelElement = panel.element, 241 rtl = panel._.dir == 'rtl', 242 viewportSize = panelElement.getWindow().getViewPaneSize(); 243 244 var panelSize = 245 { 246 'height' : panelElement.$.offsetHeight, 247 'width' : panelElement.$.offsetWidth 248 }; 249 250 // Reverse the 'rtl' offsets. 251 if ( this._.reverse ) 252 { 253 left += ( panelSize.width * ( rtl ? 1 : -1 ) ); 254 } 255 // If the menu is horizontal off, shift it toward the opposite direction, 256 // meanwhile ask subsequent sub-menus to be opened in the reverse way. 257 else if ( rtl ? left < 0 : left + panelSize.width > viewportSize.width ) 258 { 259 left += ( panelSize.width * ( rtl ? 1 : -1 ) ); 260 this._.reverse = true; 261 } 262 263 // Vertical off screen is simpler. 264 if( top + panelSize.height > viewportSize.height ) 265 top -= panelSize.height; 266 267 evt.data = { left : left, top : top }; 268 269 }, this ); 270 271 230 272 // Show the panel. 231 273 if ( this.parent ) 232 274 this.parent._.panel.showAsChild( panel, this.id, offsetParent, corner, offsetX, offsetY ); 233 275 else 234 276 panel.showBlock( this.id, offsetParent, corner, offsetX, offsetY ); 235 277 236 278 editor.fire( 'menuShow', [ panel ] ); 237 279 }, 238 280 -
_source/plugins/floatpanel/plugin.js
195 195 if ( rtl ) 196 196 left -= element.$.offsetWidth; 197 197 198 element.setStyles( 199 { 200 left : left + 'px', 201 visibility : '', 202 opacity : '1' // FF3 is ignoring "visibility" 203 }); 198 var panelLoad = CKEDITOR.tools.bind( function () 199 { 200 if ( this.onShow ) 201 this.onShow.call( this ); 204 202 205 if ( block.autoSize ) 206 { 207 function setHeight() 208 { 203 if ( block.autoSize ) 204 { 209 205 var target = element.getFirst(); 210 206 var height = block.element.$.scrollHeight; 211 207 … … 220 216 // Fix IE < 8 visibility. 221 217 panel._.currentBlock.element.setStyle( 'display', 'none' ).removeStyle( 'display' ); 222 218 } 223 224 if ( panel.isLoaded )225 setHeight();226 219 else 227 panel.onLoad = setHeight; 228 } 229 else 230 element.getFirst().removeStyle( 'height' ); 220 element.getFirst().removeStyle( 'height' ); 231 221 222 // The panel size has been known for now, 223 // allow futher manipulating the position, 224 // e.g. off-screen adjustment for context menu. 225 var position = this.fire( 'position', { top : top, left : left } ); 226 227 element.setStyles( 228 { 229 top : ( position ? position.top : top ) + 'px', 230 left : ( position ? position.left : left ) + 'px', 231 visibility : '', 232 opacity : '1' // FF3 is ignoring "visibility" 233 } ); 234 235 isShowing = false; 236 } , this ); 237 238 panel.isLoaded ? panelLoad() : panel.onLoad = panelLoad; 232 239 // Set the IFrame focus, so the blur event gets fired. 233 240 CKEDITOR.tools.setTimeout( function() 234 241 { … … 255 262 }, 0, this); 256 263 this.visible = 1; 257 264 258 if ( this.onShow )259 this.onShow.call( this );260 261 isShowing = false;262 265 }, 263 266 264 267 hide : function() … … 329 332 } 330 333 } 331 334 }); 335 CKEDITOR.event.implementOn( CKEDITOR.ui.floatPanel.prototype, true ); 332 336 })();