Ticket #2924: 2924.patch
File 2924.patch, 4.7 KB (added by , 15 years ago) |
---|
-
_samples/api_dialog.html
75 75 { 76 76 id : 'myField1', 77 77 type : 'text', 78 label : 'My Text Field' 78 label : 'My Text Field', 79 onEnterKey : function(evt) 80 { 81 this.getDialog().getContentElement( 'customTab', 'myField2' ).focus(); 82 evt.cancel(); 83 }, 79 84 }, 80 85 { 81 86 id : 'myField2', -
_source/plugins/dialogui/plugin.js
60 60 { 61 61 return this._.initValue; 62 62 } 63 }; 64 65 //SpecialKeyMap 66 var keystrokeEnum = { 67 ENTER : 13, 68 CTRLENTER : 1013 63 69 }, 64 commonEventProcessors = CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors, 70 //special-keystroke handlers in elementDefinition 71 keystrokeHandlers = {}; 72 73 var commonEventProcessors = CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors, 65 74 { 66 75 onChange : function( dialog, func ) 67 76 { … … 75 84 } 76 85 77 86 this.on( 'change', func ); 87 }, 88 89 /** 90 * Dispatch special-keystroke to their corresponding named handler function in element definition. 91 * @param {Object} dialog 92 * @param {Object} func 93 * @param {Object} keystrokeName The shortcut name for keystroke combination 94 */ 95 onSpecialKey : function( dialog, func, keystrokeName ) 96 { 97 keystrokeHandlers[ keystrokeName.toUpperCase() ] = func; 98 if ( !this._.specialKeyRegistered ) 99 { 100 dialog.on( 'load', function() 101 { 102 this.getInputElement().on( 'keyup', function( evt ){ 103 104 var keyStrikeCode = evt.data.getKeystroke(); 105 var i ; 106 for( i in keystrokeEnum) 107 { 108 //Is special-keystroke? 109 if( keystrokeEnum[ i ] == keyStrikeCode 110 //Is handler defined? 111 && keystrokeHandlers[ i ]) 112 keystrokeHandlers[ i ].call( this, evt ); 113 } 114 115 }, this ); 116 }, this ); 117 this._.specialKeyRegistered = true; 118 } 78 119 } 79 120 }, true ), 80 121 eventRegex = /^on([A-Z]\w+)/, … … 207 248 if ( elementDefinition.size ) 208 249 attributes.size = elementDefinition.size; 209 250 210 // If user presses Enter in a text box, it implies clicking OK for the dialog.211 var me = this;212 dialog.on( 'load', function()213 {214 me.getInputElement().on( 'keyup', function( evt )215 {216 if ( evt.data.$.keyCode == 13 )217 dialog.getButton( 'ok' ) && dialog.getButton( 'ok' ).click();218 } );219 } );220 221 251 /** @ignore */ 222 252 var innerHTML = function() 223 253 { … … 230 260 return html.join( '' ); 231 261 }; 232 262 CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML ); 263 264 // If user presses Enter in a text box, it implies clicking OK for the dialog. 265 var me = this; 266 dialog.on( 'load', function() 267 { 268 me.getInputElement().on( 'keyup', function( evt ) 269 { 270 if ( evt.data.$.keyCode == 13 ) 271 dialog.getButton( 'ok' ) && dialog.getButton( 'ok' ).click(); 272 } ); 273 } ); 274 233 275 }, 234 276 235 277 /** -
_source/plugins/dialog/plugin.js
2036 2036 registerEvents : function( definition ) 2037 2037 { 2038 2038 var regex = /^on([A-Z]\w+)/, 2039 match; 2039 match, 2040 specialKeyRegex = /^(Enter|Esc)Key$/, 2041 specialKeyMatch; 2040 2042 2041 2043 var registerDomEvent = function( uiElement, dialog, eventName, func ) 2042 2044 { … … 2052 2054 continue; 2053 2055 if ( this.eventProcessors[i] ) 2054 2056 this.eventProcessors[i].call( this, this._.dialog, definition[i] ); 2057 //seak for specialkey handler names 2058 else if ( specialKeyMatch = match[1].match( specialKeyRegex ) ) 2059 { 2060 this.eventProcessors.onSpecialKey.call( this, this._.dialog, definition[i], specialKeyMatch[1] ) 2061 } 2055 2062 else 2056 2063 registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] ); 2057 2064 } … … 2094 2101 onHide : function( dialog, func ) 2095 2102 { 2096 2103 dialog.on( 'hide', func ); 2104 }, 2105 /** 2106 * @see CKEDITOR.ui.dialog::eventProcessors.onSpecialKey 2107 */ 2108 onSpecialKey : function( dialog, func, keystrokeName ) 2109 { 2097 2110 } 2098 2111 }, 2099 2112