Ticket #7280: 7280_3.patch
File 7280_3.patch, 14.9 KB (added by , 13 years ago) |
---|
-
_source/plugins/panelbutton/plugin.js
46 46 47 47 $ : function( definition ) 48 48 { 49 // Store/Restore a copy of the panel definition to allow switch toolbars 50 if ( definition.panel ) 51 definition.storedPanel = definition.panel; 52 else 53 definition.panel = definition.storedPanel ; 54 49 55 // We don't want the panel definition in this object. 50 56 var panelDefinition = definition.panel; 51 57 delete definition.panel; -
_source/plugins/richcombo/plugin.js
128 128 clickFn : clickFn 129 129 }; 130 130 131 editor.on( 'mode',function()131 instance.onmode = function() 132 132 { 133 133 this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); 134 134 this.setValue( '' ); 135 }, 136 this ); 135 }; 137 136 137 editor.on( 'mode', instance.onmode, this ); 138 138 139 var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ) 139 140 { 140 141 ev = new CKEDITOR.dom.event( ev ); -
_source/plugins/toolbar/plugin.js
153 153 }; 154 154 155 155 editor.on( 'themeSpace', function( event ) 156 { 157 if ( event.data.space == editor.config.toolbarLocation ) 156 158 { 157 if ( event.data.space == editor.config.toolbarLocation )158 {159 editor.toolbox = new toolbox();159 event.data.html += generateToolbarHtml( editor ); 160 } 161 }); 160 162 161 var labelId = CKEDITOR.tools.getNextId(); 163 var generateToolbarHtml = function ( editor ) 164 { 165 editor.toolbox = new toolbox(); 162 166 163 var output = [ '<div class="cke_toolbox" role="toolbar" aria-labelledby="', labelId, '" onmousedown="return false;"' ], 164 expanded = editor.config.toolbarStartupExpanded !== false, 165 groupStarted; 167 var labelId = CKEDITOR.tools.getNextId(); 166 168 167 output.push( expanded ? '>' : ' style="display:none">' ); 169 var output = [ '<div class="cke_toolbox" role="toolbar" aria-labelledby="', labelId, '" onmousedown="return false;"' ], 170 expanded = editor.config.toolbarStartupExpanded !== false, 171 groupStarted; 168 172 169 // Sends the ARIA label. 170 output.push( '<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbar, '</span>' ); 173 output.push( expanded ? '>' : ' style="display:none">' ); 171 174 172 var toolbars = editor.toolbox.toolbars, 173 toolbar = 174 ( editor.config.toolbar instanceof Array ) ? 175 editor.config.toolbar 176 : 177 editor.config[ 'toolbar_' + editor.config.toolbar ]; 175 // Sends the ARIA label. 176 output.push( '<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbar, '</span>' ); 178 177 179 for ( var r = 0 ; r < toolbar.length ; r++ ) 180 { 181 var row = toolbar[ r ]; 178 var toolbars = editor.toolbox.toolbars, 179 toolbar = 180 ( editor.config.toolbar instanceof Array ) ? 181 editor.config.toolbar 182 : 183 editor.config[ 'toolbar_' + editor.config.toolbar ]; 182 184 183 // It's better to check if the row object is really 184 // available because it's a common mistake to leave 185 // an extra comma in the toolbar definition 186 // settings, which leads on the editor not loading 187 // at all in IE. (#3983) 188 if ( !row ) 189 continue; 185 for ( var r = 0 ; r < toolbar.length ; r++ ) 186 { 187 var row = toolbar[ r ]; 190 188 191 var toolbarId = CKEDITOR.tools.getNextId(), 192 toolbarObj = { id : toolbarId, items : [] }; 189 // It's better to check if the row object is really 190 // available because it's a common mistake to leave 191 // an extra comma in the toolbar definition 192 // settings, which leads on the editor not loading 193 // at all in IE. (#3983) 194 if ( !row ) 195 continue; 193 196 194 if ( groupStarted ) 195 { 196 output.push( '</div>' ); 197 groupStarted = 0; 198 } 197 var toolbarId = CKEDITOR.tools.getNextId(), 198 toolbarObj = { id : toolbarId, items : [] }; 199 199 200 if ( row === '/')201 202 output.push( '<div class="cke_break"></div>' );203 continue;204 200 if ( groupStarted ) 201 { 202 output.push( '</div>' ); 203 groupStarted = 0; 204 } 205 205 206 output.push( '<span id="', toolbarId, '" class="cke_toolbar" role="presentation"><span class="cke_toolbar_start"></span>' ); 206 if ( row === '/' ) 207 { 208 output.push( '<div class="cke_break"></div>' ); 209 continue; 210 } 207 211 208 // Add the toolbar to the "editor.toolbox.toolbars" 209 // array. 210 var index = toolbars.push( toolbarObj ) - 1; 212 output.push( '<span id="', toolbarId, '" class="cke_toolbar" role="presentation"><span class="cke_toolbar_start"></span>' ); 211 213 212 // Create the next/previous reference. 213 if ( index > 0 ) 214 { 215 toolbarObj.previous = toolbars[ index - 1 ]; 216 toolbarObj.previous.next = toolbarObj; 217 } 214 // Add the toolbar to the "editor.toolbox.toolbars" 215 // array. 216 var index = toolbars.push( toolbarObj ) - 1; 218 217 219 // Create all items defined for this toolbar. 220 for ( var i = 0 ; i < row.length ; i++ ) 221 { 222 var item, 223 itemName = row[ i ]; 218 // Create the next/previous reference. 219 if ( index > 0 ) 220 { 221 toolbarObj.previous = toolbars[ index - 1 ]; 222 toolbarObj.previous.next = toolbarObj; 223 } 224 224 225 if ( itemName == '-' ) 226 item = CKEDITOR.ui.separator; 227 else 228 item = editor.ui.create( itemName ); 225 // Create all items defined for this toolbar. 226 for ( var i = 0 ; i < row.length ; i++ ) 227 { 228 var item, 229 itemName = row[ i ]; 229 230 230 if ( item ) 231 if ( itemName == '-' ) 232 item = CKEDITOR.ui.separator; 233 else 234 item = editor.ui.create( itemName ); 235 236 if ( item ) 237 { 238 if ( item.canGroup ) 239 { 240 if ( !groupStarted ) 231 241 { 232 if ( item.canGroup ) 233 { 234 if ( !groupStarted ) 235 { 236 output.push( '<span class="cke_toolgroup" role="presentation">' ); 237 groupStarted = 1; 238 } 239 } 240 else if ( groupStarted ) 241 { 242 output.push( '</span>' ); 243 groupStarted = 0; 244 } 245 246 var itemObj = item.render( editor, output ); 247 index = toolbarObj.items.push( itemObj ) - 1; 248 249 if ( index > 0 ) 250 { 251 itemObj.previous = toolbarObj.items[ index - 1 ]; 252 itemObj.previous.next = itemObj; 253 } 254 255 itemObj.toolbar = toolbarObj; 256 itemObj.onkey = itemKeystroke; 257 258 /* 259 * Fix for #3052: 260 * Prevent JAWS from focusing the toolbar after document load. 261 */ 262 itemObj.onfocus = function() 263 { 264 if ( !editor.toolbox.focusCommandExecuted ) 265 editor.focus(); 266 }; 242 output.push( '<span class="cke_toolgroup" role="presentation">' ); 243 groupStarted = 1; 267 244 } 268 245 } 269 270 if ( groupStarted ) 246 else if ( groupStarted ) 271 247 { 272 248 output.push( '</span>' ); 273 249 groupStarted = 0; 274 250 } 275 251 276 output.push( '<span class="cke_toolbar_end"></span></span>' ); 252 var itemObj = item.render( editor, output ); 253 index = toolbarObj.items.push( itemObj ) - 1; 254 255 if ( index > 0 ) 256 { 257 itemObj.previous = toolbarObj.items[ index - 1 ]; 258 itemObj.previous.next = itemObj; 259 } 260 261 itemObj.toolbar = toolbarObj; 262 itemObj.onkey = itemKeystroke; 263 264 /* 265 * Fix for #3052: 266 * Prevent JAWS from focusing the toolbar after document load. 267 */ 268 itemObj.onfocus = function() 269 { 270 if ( !editor.toolbox.focusCommandExecuted ) 271 editor.focus(); 272 }; 277 273 } 274 } 278 275 279 output.push( '</div>' ); 276 if ( groupStarted ) 277 { 278 output.push( '</span>' ); 279 groupStarted = 0; 280 } 280 281 281 if ( editor.config.toolbarCanCollapse ) 282 output.push( '<span class="cke_toolbar_end"></span></span>' ); 283 } 284 285 output.push( '</div>' ); 286 287 if ( editor.config.toolbarCanCollapse ) 288 { 289 var collapserFn = CKEDITOR.tools.addFunction( 290 function() 282 291 { 283 var collapserFn = CKEDITOR.tools.addFunction( 284 function() 285 { 286 editor.execCommand( 'toolbarCollapse' ); 287 }); 292 editor.execCommand( 'toolbarCollapse' ); 293 }); 288 294 289 290 291 295 editor.on( 'destroy', function () { 296 CKEDITOR.tools.removeFunction( collapserFn ); 297 }); 292 298 293 299 var collapserId = CKEDITOR.tools.getNextId(); 294 300 295 editor.addCommand( 'toolbarCollapse', 301 editor.addCommand( 'toolbarCollapse', 302 { 303 exec : function( editor ) 304 { 305 var collapser = CKEDITOR.document.getById( collapserId ), 306 toolbox = collapser.getPrevious(), 307 contents = editor.getThemeSpace( 'contents' ), 308 toolboxContainer = toolbox.getParent(), 309 contentHeight = parseInt( contents.$.style.height, 10 ), 310 previousHeight = toolboxContainer.$.offsetHeight, 311 collapsed = !toolbox.isVisible(); 312 313 if ( !collapsed ) 296 314 { 297 exec : function( editor ) 298 { 299 var collapser = CKEDITOR.document.getById( collapserId ), 300 toolbox = collapser.getPrevious(), 301 contents = editor.getThemeSpace( 'contents' ), 302 toolboxContainer = toolbox.getParent(), 303 contentHeight = parseInt( contents.$.style.height, 10 ), 304 previousHeight = toolboxContainer.$.offsetHeight, 305 collapsed = !toolbox.isVisible(); 315 toolbox.hide(); 316 collapser.addClass( 'cke_toolbox_collapser_min' ); 317 collapser.setAttribute( 'title', editor.lang.toolbarExpand ); 318 } 319 else 320 { 321 toolbox.show(); 322 collapser.removeClass( 'cke_toolbox_collapser_min' ); 323 collapser.setAttribute( 'title', editor.lang.toolbarCollapse ); 324 } 306 325 307 if ( !collapsed ) 308 { 309 toolbox.hide(); 310 collapser.addClass( 'cke_toolbox_collapser_min' ); 311 collapser.setAttribute( 'title', editor.lang.toolbarExpand ); 312 } 313 else 314 { 315 toolbox.show(); 316 collapser.removeClass( 'cke_toolbox_collapser_min' ); 317 collapser.setAttribute( 'title', editor.lang.toolbarCollapse ); 318 } 326 // Update collapser symbol. 327 collapser.getFirst().setText( collapsed ? 328 '\u25B2' : // BLACK UP-POINTING TRIANGLE 329 '\u25C0' ); // BLACK LEFT-POINTING TRIANGLE 319 330 320 // Update collapser symbol. 321 collapser.getFirst().setText( collapsed ? 322 '\u25B2' : // BLACK UP-POINTING TRIANGLE 323 '\u25C0' ); // BLACK LEFT-POINTING TRIANGLE 331 var dy = toolboxContainer.$.offsetHeight - previousHeight; 332 contents.setStyle( 'height', ( contentHeight - dy ) + 'px' ); 324 333 325 var dy = toolboxContainer.$.offsetHeight - previousHeight;326 contents.setStyle( 'height', ( contentHeight - dy ) + 'px' );334 editor.fire( 'resize' ); 335 }, 327 336 328 editor.fire( 'resize' );329 },337 modes : { wysiwyg : 1, source : 1 } 338 } ); 330 339 331 modes : { wysiwyg : 1, source : 1 }332 });340 output.push( '<a title="' + ( expanded ? editor.lang.toolbarCollapse : editor.lang.toolbarExpand ) 341 + '" id="' + collapserId + '" tabIndex="-1" class="cke_toolbox_collapser' ); 333 342 334 output.push( '<a title="' + ( expanded ? editor.lang.toolbarCollapse : editor.lang.toolbarExpand )335 + '" id="' + collapserId + '" tabIndex="-1" class="cke_toolbox_collapser' );343 if ( !expanded ) 344 output.push( ' cke_toolbox_collapser_min' ); 336 345 337 if ( !expanded ) 338 output.push( ' cke_toolbox_collapser_min' ); 346 output.push( '" onclick="CKEDITOR.tools.callFunction(' + collapserFn + ')">', 347 '<span>▲</span>', // BLACK UP-POINTING TRIANGLE 348 '</a>' ); 349 } 339 350 340 output.push( '" onclick="CKEDITOR.tools.callFunction(' + collapserFn + ')">', 341 '<span>▲</span>', // BLACK UP-POINTING TRIANGLE 342 '</a>' ); 343 } 351 return output.join( '' ); 352 }; 344 353 345 event.data.html += output.join( '' ); 346 } 347 }); 354 var destroyToolbar = function() 355 { 356 var index = 0, 357 i, 358 items, 359 instance, 360 toolbars = this.toolbox.toolbars; 348 361 349 editor.on( 'destroy', function()350 {351 var toolbars, index = 0, i,352 items, instance;353 toolbars = this.toolbox.toolbars;354 362 for ( ; index < toolbars.length; index++ ) 355 363 { 356 364 items = toolbars[ index ].items; 357 365 for ( i = 0; i < items.length; i++ ) 358 366 { 359 367 instance = items[ i ]; 368 360 369 if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn ); 361 370 if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn ); 362 371 363 372 if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null; 373 374 if ( instance.button && instance.button.command ) 375 { 376 var command = editor.getCommand( instance.button.command ); 377 command.uiItems = []; 378 } 379 380 if ( instance.onmode ) 381 this.removeListener( 'mode', instance.onmode ); 364 382 } 365 383 } 366 } );384 }; 367 385 386 editor.on( 'destroy', destroyToolbar ); 387 388 // Method to switch the currently used toolbar 389 editor.setToolbar = function( toolbar ) 390 { 391 // Remove existing toolbar 392 destroyToolbar.call( this ); 393 394 // Set new one 395 this.config.toolbar = toolbar; 396 397 // Create it 398 var toolbarLocation = this.config.toolbarLocation, 399 space = document.getElementById('cke_' + toolbarLocation + '_' + this.name); 400 401 space.innerHTML = generateToolbarHtml( this ); 402 403 // IE... 404 if ( CKEDITOR.env.ie ) 405 { 406 var table = space.parentNode.parentNode.parentNode; 407 table.style.display = 'none'; 408 // Force refresh 409 var h = table.scrollHeight; 410 table.style.display = ''; 411 } 412 }; 413 368 414 editor.addCommand( 'toolbarFocus', commands.toolbarFocus ); 369 415 } 370 416 });