Changeset 22781
- Timestamp:
- 11/21/2012 06:29:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22779 r22781 445 445 // wp.media.controller.Upload 446 446 // --------------------------- 447 media.controller.Upload = media.controller. Library.extend({447 media.controller.Upload = media.controller.State.extend({ 448 448 defaults: _.defaults({ 449 id: 'upload', 450 upload: { text: l10n.uploadMoreFiles }, 451 searchable: false, 452 sortable: true 453 }, media.controller.Library.prototype.defaults ), 449 id: 'upload', 450 content: 'upload', 451 sidebar: 'empty', 452 toolbar: 'empty', 453 454 // The state to navigate to when files are uploading. 455 libraryState: 'library' 456 }, media.controller.State.prototype.defaults ), 454 457 455 458 initialize: function() { 456 var library = this.get('library'); 457 458 // If a `library` attribute isn't provided, create a new 459 // `Attachments` collection that observes (and thereby receives 460 // all uploading) attachments. 461 if ( ! library ) { 462 library = new Attachments(); 463 library.observe( wp.Uploader.queue ); 464 this.set( 'library', library ); 465 } 466 467 media.controller.Library.prototype.initialize.apply( this, arguments ); 468 } 469 459 media.controller.State.prototype.initialize.apply( this, arguments ); 460 }, 461 462 activate: function() { 463 wp.Uploader.queue.on( 'add', this.uploading, this ); 464 media.controller.State.prototype.activate.apply( this, arguments ); 465 }, 466 467 deactivate: function() { 468 wp.Uploader.queue.off( null, null, this ); 469 media.controller.State.prototype.deactivate.apply( this, arguments ); 470 }, 471 472 uploading: function( attachment ) { 473 var library = this.get('libraryState'); 474 475 this.frame.get( library ).get('selection').add( attachment ); 476 this.frame.state( library ); 477 } 470 478 }); 471 479 … … 1176 1184 1177 1185 createStates: function() { 1178 var options = this.options, 1179 attributes; 1180 1181 attributes = { 1182 multiple: this.options.multiple, 1183 menu: 'main', 1184 toolbar: 'select' 1185 }; 1186 var options = this.options; 1186 1187 1187 1188 // Add the default states. … … 1190 1191 new media.controller.Library( _.defaults({ 1191 1192 selection: options.selection, 1192 library: media.query( options.library ) 1193 library: media.query( options.library ), 1194 multiple: this.options.multiple, 1195 menu: 'main', 1196 toolbar: 'select' 1193 1197 }, attributes ) ), 1194 1198 1195 new media.controller.Upload( attributes ) 1199 new media.controller.Upload({ 1200 menu: 'main' 1201 }) 1196 1202 ]); 1197 1203 }, … … 1246 1252 1247 1253 uploadContent: function() { 1248 // In the meantime, render an inline uploader. 1254 this.$el.addClass('hide-sidebar hide-toolbar'); 1255 1249 1256 this.content.view( new media.view.UploaderInline({ 1250 1257 controller: this … … 1343 1350 1344 1351 createStates: function() { 1345 var options = this.options, 1346 main, gallery; 1347 1348 main = { 1349 multiple: this.options.multiple, 1350 menu: 'main', 1351 sidebar: 'attachment-settings', 1352 1353 // Update user settings when users adjust the 1354 // attachment display settings. 1355 displayUserSettings: true 1356 }; 1357 1358 gallery = { 1359 multiple: true, 1360 menu: 'gallery', 1361 toolbar: 'gallery-add', 1362 excludeState: 'gallery-edit' 1363 }; 1352 var options = this.options; 1364 1353 1365 1354 // Add the default states. 1366 1355 this.states.add([ 1367 1356 // Main states. 1368 new media.controller.Library( _.defaults({1357 new media.controller.Library({ 1369 1358 selection: options.selection, 1370 1359 library: media.query( options.library ), 1371 1360 editable: true, 1372 filterable: 'all' 1373 }, main ) ), 1374 1375 new media.controller.Upload( main ), 1361 filterable: 'all', 1362 multiple: this.options.multiple, 1363 menu: 'main', 1364 sidebar: 'attachment-settings', 1365 1366 // Update user settings when users adjust the 1367 // attachment display settings. 1368 displayUserSettings: true 1369 }), 1370 1371 new media.controller.Upload({ 1372 menu: 'main' 1373 }), 1376 1374 1377 1375 // Embed states. … … 1385 1383 }), 1386 1384 1387 new media.controller.Library( _.defaults({ 1388 id: 'gallery-library', 1389 library: media.query({ type: 'image' }), 1390 filterable: 'uploaded' 1391 }, gallery ) ), 1392 1393 new media.controller.Upload( _.defaults({ 1394 id: 'gallery-upload' 1395 }, gallery ) ) 1385 new media.controller.Library({ 1386 id: 'gallery-library', 1387 library: media.query({ type: 'image' }), 1388 filterable: 'uploaded', 1389 multiple: true, 1390 menu: 'gallery', 1391 toolbar: 'gallery-add', 1392 excludeState: 'gallery-edit' 1393 }), 1394 1395 new media.controller.Upload({ 1396 id: 'gallery-upload', 1397 menu: 'gallery', 1398 libraryState: 'gallery-edit' 1399 }) 1396 1400 ]); 1397 1401 },
Note: See TracChangeset
for help on using the changeset viewer.