Ticket #4997: 4997.patch
File 4997.patch, 4.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/dialogui/plugin.js
1233 1233 * @returns {String} The value of the action. 1234 1234 * @example 1235 1235 */ 1236 getAction : function( action)1236 getAction : function() 1237 1237 { 1238 1238 return this.getInputElement().getParent().$.action; 1239 1239 }, 1240 1240 1241 1241 /** 1242 * The events must be applied on the inner input element, and 1243 * that must be done when the iframe & form has been loaded 1244 */ 1245 registerEvents : function( definition ) 1246 { 1247 var regex = /^on([A-Z]\w+)/, 1248 match; 1249 1250 var registerDomEvent = function( uiElement, dialog, eventName, func ) 1251 { 1252 uiElement.on( 'formLoaded', function() 1253 { 1254 uiElement.getInputElement().on( eventName, func, uiElement ); 1255 }); 1256 }; 1257 1258 for ( var i in definition ) 1259 { 1260 if ( !( match = i.match( regex ) ) ) 1261 continue; 1262 if ( this.eventProcessors[i] ) 1263 this.eventProcessors[i].call( this, this._.dialog, definition[i] ); 1264 else 1265 registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] ); 1266 } 1267 1268 return this; 1269 }, 1270 1271 /** 1242 1272 * Redraws the file input and resets the file path in the file input. 1243 1273 * The redraw logic is necessary because non-IE browsers tend to clear 1244 1274 * the <iframe> containing the file input after closing the dialog. … … 1249 1279 var frameElement = CKEDITOR.document.getById( this._.frameId ), 1250 1280 frameDocument = frameElement.getFrameDocument(), 1251 1281 elementDefinition = this._.definition, 1252 buttons = this._.buttons; 1282 buttons = this._.buttons, 1283 callNumber = this.formLoadedNumber; 1253 1284 1285 // The callback function for the iframe, but we must call tools.addFunction only once 1286 // so we store the function number in this.formLoadedNumber 1287 if (!callNumber) 1288 callNumber = this.formLoadedNumber = CKEDITOR.tools.addFunction( 1289 function() 1290 { 1291 // Now we can apply the events to the input type=file 1292 this.fire( 'formLoaded' ) ; 1293 }, this ) ; 1294 1295 1254 1296 function generateFormField() 1255 1297 { 1256 1298 frameDocument.$.open(); … … 1273 1315 CKEDITOR.tools.htmlEncode( size > 0 ? size : "" ), 1274 1316 '" />', 1275 1317 '</form>', 1276 '</body></html>' ].join( '' ) ); 1318 '</body></html>', 1319 '<script>window.parent.CKEDITOR.tools.callFunction(' + callNumber + ');</script>' ].join( '' ) ); 1277 1320 1278 1321 frameDocument.$.close(); 1279 1322 … … 1290 1333 1291 1334 getValue : function() 1292 1335 { 1293 // The file path returned from the input tag is incomplete anyway, so it's 1294 // safe to ignore it and prevent the confirmation dialog from appearing. 1295 // (Part of #3465) 1296 return ''; 1336 return this.getInputElement().$.value; 1297 1337 }, 1298 1338 1339 /*** 1340 * The default value of input type="file" is an empty string, but during initialization 1341 * of this UI element, the iframe still isn't ready so it can't be read from that object 1342 * Setting it manually prevents later issues about the current value ("") being different 1343 * of the initial value (undefined as it asked for .value of a div) 1344 */ 1345 setInitValue : function() 1346 { 1347 this._.initValue = ''; 1348 }, 1349 1299 1350 /** 1300 1351 * Defines the onChange event for UI element definitions. 1301 1352 * @field 1302 1353 * @type Object 1303 1354 * @example 1304 1355 */ 1305 eventProcessors : commonEventProcessors, 1356 eventProcessors : 1357 { 1358 onChange : function( dialog, func ) 1359 { 1360 // If this method is called several times (I'm not sure about how this can happen but the default 1361 // onChange processor includes this protection) 1362 // In order to reapply to the new element, the property is deleted at the beggining of the registerEvents method 1363 if ( !this._.domOnChangeRegistered ) 1364 { 1365 // By listening for the formLoaded event, this handler will get reapplied when a new 1366 // form is created 1367 this.on( 'formLoaded', function() 1368 { 1369 this.getInputElement().on( 'change', function(){ this.fire( 'change', { value : this.getValue() } ); }, this ); 1370 }, this ); 1371 this._.domOnChangeRegistered = true; 1372 } 1306 1373 1374 this.on( 'change', func ); 1375 } 1376 }, 1377 1307 1378 keyboardFocusable : true 1308 1379 }, true ); 1309 1380