Changeset 22480
- Timestamp:
- 11/09/2012 01:44:02 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/media-upload.js
r22466 r22480 108 108 } ) ); 109 109 110 workflow.on( 'insert', function( ) {110 workflow.on( 'insert', function( selection ) { 111 111 var state = workflow.state(), 112 selection = state.get('selection'),113 112 details = state.get('details'); 113 114 selection = selection || state.get('selection'); 114 115 115 116 if ( ! selection || ! details ) -
trunk/wp-includes/js/media-views.js
r22478 r22480 701 701 createStates: function() { 702 702 var options = this.options, 703 main, gallery ;703 main, gallery, batch; 704 704 705 705 main = { … … 714 714 715 715 gallery = { 716 multiple: true, 717 menu: 'gallery', 718 toolbar: 'gallery-add' 716 multiple: true, 717 menu: 'gallery', 718 toolbar: 'gallery-add', 719 excludeState: 'gallery-edit' 720 }; 721 722 batch = { 723 multiple: true, 724 menu: 'batch', 725 toolbar: 'batch-add', 726 excludeState: 'batch-edit' 719 727 }; 720 728 721 729 // Add the default states. 722 730 this.states.add([ 731 // Main states. 723 732 new media.controller.Library( _.defaults({ 724 733 selection: options.selection, … … 728 737 new media.controller.Upload( main ), 729 738 739 // Gallery states. 730 740 new media.controller.Gallery({ 731 741 editing: options.editing, … … 735 745 new media.controller.Library( _.defaults({ 736 746 id: 'gallery-library', 737 library: media.query({ type: 'image' }), 738 excludeState: 'gallery-edit' 747 library: media.query({ type: 'image' }) 739 748 }, gallery ) ), 740 749 741 750 new media.controller.Upload( _.defaults({ 742 id: 'gallery-upload', 743 excludeState: 'gallery-edit' 744 }, gallery ) ) 751 id: 'gallery-upload' 752 }, gallery ) ), 753 754 // Batch states. 755 new media.controller.Library({ 756 id: 'batch-edit', 757 multiple: false, 758 describe: true, 759 edge: 199, 760 sortable: true, 761 menu: 'batch', 762 toolbar: 'batch-edit', 763 sidebar: 'attachment-settings' 764 }), 765 766 new media.controller.Library( _.defaults({ 767 id: 'batch-library', 768 library: media.query({ type: 'image' }) 769 }, batch ) ), 770 771 new media.controller.Upload( _.defaults({ 772 id: 'batch-upload' 773 }, batch ) ) 745 774 ]); 746 775 … … 774 803 }, 775 804 776 batchMenu: function() {}, 805 batchMenu: function() { 806 var previous = this.previous(), 807 frame = this; 808 809 this.menu.view( new media.view.Menu({ 810 controller: this, 811 views: { 812 cancel: { 813 text: l10n.cancelBatchTitle, 814 priority: 20, 815 click: function() { 816 if ( previous ) 817 frame.state( previous ); 818 else 819 frame.close(); 820 } 821 }, 822 separateCancel: new Backbone.View({ 823 className: 'separator', 824 priority: 40 825 }), 826 'batch-edit': { 827 text: l10n.editBatchTitle, 828 priority: 60 829 }, 830 'batch-upload': { 831 text: l10n.uploadFilesTitle, 832 priority: 80 833 }, 834 'batch-library': { 835 text: l10n.mediaLibraryTitle, 836 priority: 100 837 } 838 } 839 }) ); 840 }, 777 841 778 842 galleryMenu: function() { … … 811 875 } 812 876 }) ); 813 814 877 }, 815 878 … … 901 964 902 965 mainEmbedToolbar: function() {}, 903 batchEditToolbar: function() {}, 904 batchAddToolbar: function() {}, 966 967 batchEditToolbar: function() { 968 this.toolbar.view( new media.view.Toolbar({ 969 controller: this, 970 items: { 971 insert: { 972 style: 'primary', 973 text: l10n.insertIntoPost, 974 priority: 80, 975 976 click: function() { 977 var controller = this.controller, 978 state = controller.state(); 979 980 controller.close(); 981 state.trigger( 'insert', state.get('library') ); 982 983 controller.reset(); 984 // @todo: Make the state activated dynamic (instead of hardcoded). 985 controller.state('upload'); 986 } 987 } 988 } 989 }) ); 990 }, 991 992 batchAddToolbar: function() { 993 this.toolbar.view( new media.view.Toolbar({ 994 controller: this, 995 items: { 996 insert: { 997 style: 'primary', 998 text: l10n.addToBatch, 999 priority: 80, 1000 1001 click: function() { 1002 var controller = this.controller, 1003 state = controller.state(), 1004 edit = controller.get('batch-edit'); 1005 1006 edit.get('library').add( state.get('selection').models ); 1007 state.trigger('reset'); 1008 controller.state('batch-edit'); 1009 } 1010 } 1011 } 1012 }) ); 1013 }, 905 1014 906 1015 galleryEditToolbar: function() { … … 1293 1402 media.view.Toolbar.Insert.Post = media.view.Toolbar.Insert.extend({ 1294 1403 initialize: function() { 1404 var selectionToLibrary = function( state ) { 1405 return function() { 1406 var controller = this.controller, 1407 selection = controller.state().get('selection'), 1408 edit = controller.get( state ); 1409 1410 edit.set( 'library', new media.model.Selection( selection.models, { 1411 props: selection.props.toJSON(), 1412 multiple: true 1413 }) ); 1414 1415 this.controller.state( state ); 1416 }; 1417 }; 1418 1295 1419 this.options.items = _.defaults( this.options.items || {}, { 1296 1420 gallery: { 1297 1421 text: l10n.createNewGallery, 1298 1422 priority: 40, 1299 1300 click: function() { 1301 var controller = this.controller, 1302 selection = controller.state().get('selection'), 1303 edit = controller.get('gallery-edit'); 1304 1305 edit.set( 'library', new media.model.Selection( selection.models, { 1306 props: selection.props.toJSON(), 1307 multiple: true 1308 }) ); 1309 1310 this.controller.state('gallery-edit'); 1311 } 1423 click: selectionToLibrary('gallery-edit') 1312 1424 }, 1313 1425 … … 1315 1427 text: l10n.batchInsert, 1316 1428 priority: 60, 1317 1318 click: function() { 1319 this.controller.state('batch-edit'); 1320 } 1429 click: selectionToLibrary('batch-edit') 1321 1430 } 1322 1431 }); … … 1338 1447 1339 1448 // Batch insert shows for multiple selected attachments. 1340 // Temporarily disabled with `false &&`. 1341 this.get('batch').$el.toggle( false && count > 1 ); 1449 this.get('batch').$el.toggle( count > 1 ); 1342 1450 1343 1451 // Insert only shows for single attachments. 1344 // Temporarily disabled. 1345 // this.get('insert').$el.toggle( count <= 1 ); 1452 this.get('insert').$el.toggle( count <= 1 ); 1346 1453 } 1347 1454 }); -
trunk/wp-includes/script-loader.php
r22437 r22480 339 339 'createNewGallery' => __( 'Create a new gallery' ), 340 340 'insertIntoPost' => __( 'Insert into post' ), 341 'addToGallery' => __( 'Add to gallery' ),342 341 343 342 // Embed … … 347 346 'batchInsert' => __( 'Batch insert' ), 348 347 'cancelBatchTitle' => __( '← Cancel Batch' ), 348 'editBatchTitle' => __( 'Edit Batch' ), 349 'addToBatch' => __( 'Add to batch' ), 349 350 350 351 // Gallery … … 355 356 'updateGallery' => __( 'Update gallery' ), 356 357 'continueEditing' => __( 'Continue editing' ), 358 'addToGallery' => __( 'Add to gallery' ), 357 359 ) ); 358 360
Note: See TracChangeset
for help on using the changeset viewer.