Changeset 30120
- Timestamp:
- 10/31/2014 03:19:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-views.js
r29917 r30120 73 73 74 74 /** 75 * ========================================================================76 * CONTROLLERS77 * ========================================================================78 */79 80 /**81 75 * wp.media.controller.Region 82 76 * 83 * @constructor 84 * @augments Backbone.Model 85 * 86 * @param {Object} [options={}] 77 * A region is a persistent application layout area. 78 * 79 * A region assumes one mode at any time, and can be switched to another. 80 * 81 * When mode changes, events are triggered on the region's parent view. 82 * The parent view will listen to specific events and fill the region with an 83 * appropriate view depending on mode. For example, a frame listens for the 84 * 'browse' mode t be activated on the 'content' view and then fills the region 85 * with an AttachmentsBrowser view. 86 * 87 * @class 88 * 89 * @param {object} options Options hash for the region. 90 * @param {string} options.id Unique identifier for the region. 91 * @param {Backbone.View} options.view A parent view the region exists within. 92 * @param {string} options.selector jQuery selector for the region within the parent view. 87 93 */ 88 94 media.controller.Region = function( options ) { … … 245 251 * wp.media.controller.StateMachine 246 252 * 253 * A state machine keeps track of state. It is in one state at a time, 254 * and can change from one state to another. 255 * 256 * States are stored as models in a Backbone collection. 257 * 247 258 * @since 3.5.0 248 259 * 249 * @c onstructor260 * @class 250 261 * @augments Backbone.Model 251 262 * @mixin … … 255 266 */ 256 267 media.controller.StateMachine = function( states ) { 268 // @todo This is dead code. The states collection gets created in media.view.Frame._createStates. 257 269 this.states = new Backbone.Collection( states ); 258 270 }; … … 361 373 * 362 374 * A state is a step in a workflow that when set will trigger the controllers 363 * for the regions to be updated as specified in the frame. This is the base 364 * class that the various states used in wp.media extend. 365 * 366 * @constructor 375 * for the regions to be updated as specified in the frame. 376 * 377 * A state has an event-driven lifecycle: 378 * 379 * 'ready' triggers when a state is added to a state machine's collection. 380 * 'activate' triggers when a state is activated by a state machine. 381 * 'deactivate' triggers when a state is deactivated by a state machine. 382 * 'reset' is not triggered automatically. It should be invoked by the 383 * proper controller to reset the state to its default. 384 * 385 * @class 367 386 * @augments Backbone.Model 368 387 */ … … 389 408 }, 390 409 /** 410 * Ready event callback. 411 * 391 412 * @abstract 392 413 * @since 3.5.0 … … 395 416 396 417 /** 418 * Activate event callback. 419 * 397 420 * @abstract 398 421 * @since 3.5.0 … … 401 424 402 425 /** 426 * Deactivate event callback. 427 * 403 428 * @abstract 404 429 * @since 3.5.0 … … 407 432 408 433 /** 434 * Reset event callback. 435 * 409 436 * @abstract 410 437 * @since 3.5.0 … … 540 567 541 568 /** 569 * Create a view in the media menu for the state. 570 * 542 571 * @access private 543 572 * @since 3.5.0 573 * 574 * @param {media.view.Menu} view The menu view. 544 575 */ 545 576 _renderMenu: function( view ) { … … 576 607 }); 577 608 609 /** 610 * wp.media.selectionSync 611 * 612 * Sync an attachments selection in a state with another state. 613 * 614 * Allows for selecting multiple images in the Insert Media workflow, and then 615 * switching to the Insert Gallery workflow while preserving the attachments selection. 616 * 617 * @mixin 618 */ 578 619 media.selectionSync = { 579 620 /** … … 630 671 631 672 /** 632 * A state for choosing an attachment from the media library. 633 * 634 * @constructor 673 * wp.media.controller.Library 674 * 675 * A state for choosing an attachment or group of attachments from the media library. 676 * 677 * @class 635 678 * @augments wp.media.controller.State 636 679 * @augments Backbone.Model 680 * @mixes media.selectionSync 681 * 682 * @param {object} [attributes] The attributes hash passed to the state. 683 * @param {string} [attributes.id=library] Unique identifier. 684 * @param {string} [attributes.title=Media library] Title for the state. Displays in the media menu and the frame's title region. 685 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. 686 * If one is not supplied, a collection of all attachments will be created. 687 * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. 688 * @param {string} [attributes.content=upload] Initial mode for the content region. 689 * Overridden by persistent user setting if 'contentUserSetting' is true. 690 * @param {string} [attributes.menu=default] Initial mode for the menu region. 691 * @param {string} [attributes.router=browse] Initial mode for the router region. 692 * @param {string} [attributes.toolbar=select] Initial mode for the toolbar region. 693 * @param {boolean} [attributes.searchable=true] Whether the library is searchable. 694 * @param {boolean|string} [attributes.filterable=false] Whether the library is filterable, and if so what filters should be shown. 695 * Accepts 'all', 'uploaded', or 'unattached'. 696 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 697 * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. 698 * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. 699 * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. 700 * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. 637 701 */ 638 702 media.controller.Library = media.controller.State.extend({ … … 640 704 id: 'library', 641 705 title: l10n.mediaLibraryTitle, 642 // Selection defaults. @see media.model.Selection643 706 multiple: false, 644 // Initial region modes.645 707 content: 'upload', 646 708 menu: 'default', 647 709 router: 'browse', 648 710 toolbar: 'select', 649 // Attachments browser defaults. @see media.view.AttachmentsBrowser650 711 searchable: true, 651 712 filterable: false, 652 713 sortable: true, 653 654 714 autoSelect: true, 655 715 describe: false, 656 // Uses a user setting to override the content mode.657 716 contentUserSetting: true, 658 // Sync the selection from the last state when 'multiple' matches.659 717 syncSelection: true 660 718 }, … … 727 785 728 786 /** 787 * Reset the library to its initial state. 788 * 729 789 * @since 3.5.0 730 790 */ … … 736 796 737 797 /** 798 * Reset the attachment display settings defaults to the site options. 799 * 800 * If site options don't define them, fall back to a persistent user setting. 801 * 738 802 * @since 3.5.0 739 803 */ … … 749 813 750 814 /** 815 * Create a model to represent display settings (alignment, etc.) for an attachment. 816 * 751 817 * @since 3.5.0 752 818 * … … 764 830 765 831 /** 832 * Given an attachment, create attachment display settings properties. 833 * 766 834 * @since 3.6.0 767 835 * … … 778 846 779 847 /** 848 * Whether an attachment can be embedded (audio or video). 849 * 780 850 * @since 3.6.0 781 851 * … … 815 885 816 886 /** 817 * If the uploader was selected, navigate to the browser. 818 * 819 * Automatically select any uploading attachments. 820 * 821 * Selections that don't support multiple attachments automatically 822 * limit themselves to one attachment (in this case, the last 823 * attachment in the upload queue). 887 * Callback handler when an attachment is uploaded. 888 * 889 * Switch to the Media Library if uploaded from the 'Upload Files' tab. 890 * 891 * Adds any uploading attachments to the selection. 892 * 893 * If the state only supports one attachment to be selected and multiple 894 * attachments are uploaded, the last attachment in the upload queue will 895 * be selected. 824 896 * 825 897 * @since 3.5.0 … … 841 913 842 914 /** 843 * Only track the browse router on library states.915 * Persist the mode of the content region as a user setting. 844 916 * 845 917 * @since 3.5.0 … … 859 931 }); 860 932 933 // Make selectionSync available on any Media Library state. 861 934 _.extend( media.controller.Library.prototype, media.selectionSync ); 862 935 863 936 /** 864 * A state for editing the settings of an image within a content editor. 865 * 866 * @constructor 937 * wp.media.controller.ImageDetails 938 * 939 * A state for editing the attachment display settings of an image that's been 940 * inserted into the editor. 941 * 942 * @class 867 943 * @augments wp.media.controller.State 868 944 * @augments Backbone.Model 945 * 946 * @param {object} [attributes] The attributes hash passed to the state. 947 * @param {string} [attributes.id=image-details] Unique identifier. 948 * @param {string} [attributes.title=Image Details] Title for the state. Displays in the frame's title region. 949 * @param {wp.media.model.Attachment} attributes.image The image's model. 950 * @param {string|false} [attributes.content=image-details] Initial mode for the content region. 951 * @param {string|false} [attributes.menu=false] Initial mode for the menu region. 952 * @param {string|false} [attributes.router=false] Initial mode for the router region. 953 * @param {string|false} [attributes.toolbar=image-details] Initial mode for the toolbar region. 954 * @param {boolean} [attributes.editing=false] Unused. 955 * @param {int} [attributes.priority=60] Unused. 956 * 957 * @todo This state inherits some defaults from media.controller.Library.prototype.defaults, 958 * however this may not do anything. 869 959 */ 870 960 media.controller.ImageDetails = media.controller.State.extend({ … … 872 962 id: 'image-details', 873 963 title: l10n.imageDetailsTitle, 874 // Initial region modes.875 964 content: 'image-details', 876 965 menu: false, 877 966 router: false, 878 967 toolbar: 'image-details', 879 880 968 editing: false, 881 969 priority: 60 … … 901 989 902 990 /** 991 * wp.media.controller.GalleryEdit 992 * 903 993 * A state for editing a gallery's images and settings. 904 994 * 905 * @c onstructor995 * @class 906 996 * @augments wp.media.controller.Library 907 997 * @augments wp.media.controller.State 908 998 * @augments Backbone.Model 999 * 1000 * @param {object} [attributes] The attributes hash passed to the state. 1001 * @param {string} [attributes.id=gallery-edit] Unique identifier. 1002 * @param {string} [attributes.title=Edit Gallery] Title for the state. Displays in the frame's title region. 1003 * @param {wp.media.model.Attachments} [attributes.library] The collection of attachments in the gallery. 1004 * If one is not supplied, an empty media.model.Selection collection is created. 1005 * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. 1006 * @param {boolean} [attributes.searchable=false] Whether the library is searchable. 1007 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1008 * @param {string|false} [attributes.content=browse] Initial mode for the content region. 1009 * @param {string|false} [attributes.toolbar=image-details] Initial mode for the toolbar region. 1010 * @param {boolean} [attributes.describe=true] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. 1011 * @param {boolean} [attributes.displaySettings=true] Whether to show the attachment display settings interface. 1012 * @param {boolean} [attributes.dragInfo=true] Whether to show instructional text about the attachments being sortable. 1013 * @param {int} [attributes.idealColumnWidth=170] The ideal column width in pixels for attachments. 1014 * @param {boolean} [attributes.editing=false] Whether the gallery is being created, or editing an existing instance. 1015 * @param {int} [attributes.priority=60] The priority for the state link in the media menu. 1016 * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. 1017 * Defaults to false for this state, because the library passed in *is* the selection. 1018 * @param {view} [attributes.AttachmentView] The single `Attachment` view to be used in the `Attachments`. 1019 * If none supplied, defaults to wp.media.view.Attachment.EditLibrary. 909 1020 */ 910 1021 media.controller.GalleryEdit = media.controller.Library.extend({ 911 1022 defaults: { 912 id: 'gallery-edit', 913 title: l10n.editGalleryTitle, 914 // Selection defaults. @see media.model.Selection 915 multiple: false, 916 // Attachments browser defaults. @see media.view.AttachmentsBrowser 917 searchable: false, 918 sortable: true, 919 display: false, 920 // Initial region modes. 921 content: 'browse', 922 toolbar: 'gallery-edit', 923 1023 id: 'gallery-edit', 1024 title: l10n.editGalleryTitle, 1025 multiple: false, 1026 searchable: false, 1027 sortable: true, 1028 display: false, 1029 content: 'browse', 1030 toolbar: 'gallery-edit', 924 1031 describe: true, 925 1032 displaySettings: true, … … 928 1035 editing: false, 929 1036 priority: 60, 930 931 // Don't sync the selection, as the Edit Gallery library 932 // *is* the selection. 933 syncSelection: false 1037 syncSelection: false 934 1038 }, 935 1039 … … 1015 1119 1016 1120 /** 1017 * A state for adding an imageto a gallery.1018 * 1019 * @c onstructor1121 * A state for selecting more images to add to a gallery. 1122 * 1123 * @class 1020 1124 * @augments wp.media.controller.Library 1021 1125 * @augments wp.media.controller.State 1022 1126 * @augments Backbone.Model 1127 * 1128 * @param {object} [attributes] The attributes hash passed to the state. 1129 * @param {string} [attributes.id=gallery-library] Unique identifier. 1130 * @param {string} [attributes.title=Add to Gallery] Title for the state. Displays in the frame's title region. 1131 * @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean. 1132 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. 1133 * If one is not supplied, a collection of all images will be created. 1134 * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. 1135 * Accepts 'all', 'uploaded', or 'unattached'. 1136 * @param {string} [attributes.menu=gallery] Initial mode for the menu region. 1137 * @param {string} [attributes.content=upload] Initial mode for the content region. 1138 * Overridden by persistent user setting if 'contentUserSetting' is true. 1139 * @param {string} [attributes.router=browse] Initial mode for the router region. 1140 * @param {string} [attributes.toolbar=gallery-add] Initial mode for the toolbar region. 1141 * @param {boolean} [attributes.searchable=true] Whether the library is searchable. 1142 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1143 * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. 1144 * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. 1145 * @param {int} [attributes.priority=100] The priority for the state link in the media menu. 1146 * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. 1147 * Defaults to false because for this state, because the library of the Edit Gallery state is the selection. 1023 1148 */ 1024 1149 media.controller.GalleryAdd = media.controller.Library.extend({ … … 1026 1151 id: 'gallery-library', 1027 1152 title: l10n.addToGalleryTitle, 1028 // Selection defaults. @see media.model.Selection1029 1153 multiple: 'add', 1030 // Attachments browser defaults. @see media.view.AttachmentsBrowser1031 1154 filterable: 'uploaded', 1032 // Initial region modes.1033 1155 menu: 'gallery', 1034 1156 toolbar: 'gallery-add', 1035 1036 1157 priority: 100, 1037 // Don't sync the selection, as the Edit Gallery library1038 // *is* the selection.1039 1158 syncSelection: false 1040 1159 }, media.controller.Library.prototype.defaults ), … … 1044 1163 */ 1045 1164 initialize: function() { 1046 // If we haven't been provided a `library`, create a `Selection`.1165 // If a library wasn't supplied, create a library of images. 1047 1166 if ( ! this.get('library') ) 1048 1167 this.set( 'library', media.query({ type: 'image' }) ); … … 1081 1200 * wp.media.controller.CollectionEdit 1082 1201 * 1083 * @constructor 1202 * A state for editing a collection, which is used by audio and video playlists, 1203 * and can be used for other collections. 1204 * 1205 * @class 1084 1206 * @augments wp.media.controller.Library 1085 1207 * @augments wp.media.controller.State 1086 1208 * @augments Backbone.Model 1209 * 1210 * @param {object} [attributes] The attributes hash passed to the state. 1211 * @param {string} attributes.title Title for the state. Displays in the media menu and the frame's title region. 1212 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to edit. 1213 * If one is not supplied, an empty media.model.Selection collection is created. 1214 * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. 1215 * @param {string} [attributes.content=browse] Initial mode for the content region. 1216 * @param {string} attributes.menu Initial mode for the menu region. @todo this needs a better explanation. 1217 * @param {boolean} [attributes.searchable=false] Whether the library is searchable. 1218 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1219 * @param {boolean} [attributes.describe=true] Whether to offer UI to describe the attachments - e.g. captioning images in a gallery. 1220 * @param {boolean} [attributes.dragInfo=true] Whether to show instructional text about the attachments being sortable. 1221 * @param {boolean} [attributes.dragInfoText] Instructional text about the attachments being sortable. 1222 * @param {int} [attributes.idealColumnWidth=170] The ideal column width in pixels for attachments. 1223 * @param {boolean} [attributes.editing=false] Whether the gallery is being created, or editing an existing instance. 1224 * @param {int} [attributes.priority=60] The priority for the state link in the media menu. 1225 * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. 1226 * Defaults to false for this state, because the library passed in *is* the selection. 1227 * @param {view} [attributes.SettingsView] The view to edit the collection instance settings (e.g. Playlist settings with "Show tracklist" checkbox). 1228 * @param {view} [attributes.AttachmentView] The single `Attachment` view to be used in the `Attachments`. 1229 * If none supplied, defaults to wp.media.view.Attachment.EditLibrary. 1230 * @param {string} attributes.type The collection's media type. (e.g. 'video'). 1231 * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). 1087 1232 */ 1088 1233 media.controller.CollectionEdit = media.controller.Library.extend({ 1089 1234 defaults: { 1090 // Selection defaults. @see media.model.Selection 1091 multiple: false, 1092 // Attachments browser defaults. @see media.view.AttachmentsBrowser 1093 sortable: true, 1094 searchable: false, 1095 // Region mode defaults. 1096 content: 'browse', 1097 1235 multiple: false, 1236 sortable: true, 1237 searchable: false, 1238 content: 'browse', 1098 1239 describe: true, 1099 1240 dragInfo: true, … … 1102 1243 priority: 60, 1103 1244 SettingsView: false, 1104 1105 // Don't sync the selection, as the Edit {Collection} library 1106 // *is* the selection. 1107 syncSelection: false 1245 syncSelection: false 1108 1246 }, 1109 1247 … … 1162 1300 1163 1301 /** 1302 * Render the collection embed settings view in the browser sidebar. 1303 * 1304 * @todo This is against the pattern elsewhere in media. Typically the frame 1305 * is responsible for adding region mode callbacks. Explain. 1306 * 1164 1307 * @since 3.9.0 1165 1308 * 1166 * @param browser1167 */ 1168 renderSettings: function( browser) {1309 * @param {wp.media.view.attachmentsBrowser} The attachments browser view. 1310 */ 1311 renderSettings: function( attachmentsBrowserView ) { 1169 1312 var library = this.get('library'), 1170 1313 collectionType = this.get('collectionType'), … … 1194 1337 } 1195 1338 1339 // Add the 'Reverse order' button to the toolbar. 1196 1340 browser.toolbar.set( 'reverse', { 1197 1341 text: l10n.reverseOrder, … … 1208 1352 * wp.media.controller.CollectionAdd 1209 1353 * 1210 * @constructor 1354 * A state for adding attachments to a collection (e.g. video playlist). 1355 * 1356 * @class 1211 1357 * @augments wp.media.controller.Library 1212 1358 * @augments wp.media.controller.State 1213 1359 * @augments Backbone.Model 1360 * 1361 * @param {object} [attributes] The attributes hash passed to the state. 1362 * @param {string} [attributes.id=library] Unique identifier. 1363 * @param {string} attributes.title Title for the state. Displays in the frame's title region. 1364 * @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean. 1365 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. 1366 * If one is not supplied, a collection of attachments of the specified type will be created. 1367 * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. 1368 * Accepts 'all', 'uploaded', or 'unattached'. 1369 * @param {string} [attributes.menu=gallery] Initial mode for the menu region. 1370 * @param {string} [attributes.content=upload] Initial mode for the content region. 1371 * Overridden by persistent user setting if 'contentUserSetting' is true. 1372 * @param {string} [attributes.router=browse] Initial mode for the router region. 1373 * @param {string} [attributes.toolbar=gallery-add] Initial mode for the toolbar region. 1374 * @param {boolean} [attributes.searchable=true] Whether the library is searchable. 1375 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1376 * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. 1377 * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. 1378 * @param {int} [attributes.priority=100] The priority for the state link in the media menu. 1379 * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. 1380 * Defaults to false because for this state, because the library of the Edit Gallery state is the selection. 1381 * @param {string} attributes.type The collection's media type. (e.g. 'video'). 1382 * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). 1214 1383 */ 1215 1384 media.controller.CollectionAdd = media.controller.Library.extend({ … … 1275 1444 1276 1445 /** 1446 * wp.media.controller.FeaturedImage 1447 * 1277 1448 * A state for selecting a featured image for a post. 1278 1449 * 1279 * @c onstructor1450 * @class 1280 1451 * @augments wp.media.controller.Library 1281 1452 * @augments wp.media.controller.State 1282 1453 * @augments Backbone.Model 1454 * 1455 * @param {object} [attributes] The attributes hash passed to the state. 1456 * @param {string} [attributes.id=featured-image] Unique identifier. 1457 * @param {string} [attributes.title=Set Featured Image] Title for the state. Displays in the media menu and the frame's title region. 1458 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. 1459 * If one is not supplied, a collection of all images will be created. 1460 * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. 1461 * @param {string} [attributes.content=upload] Initial mode for the content region. 1462 * Overridden by persistent user setting if 'contentUserSetting' is true. 1463 * @param {string} [attributes.menu=default] Initial mode for the menu region. 1464 * @param {string} [attributes.router=browse] Initial mode for the router region. 1465 * @param {string} [attributes.toolbar=featured-image] Initial mode for the toolbar region. 1466 * @param {int} [attributes.priority=60] The priority for the state link in the media menu. 1467 * @param {boolean} [attributes.searchable=true] Whether the library is searchable. 1468 * @param {boolean|string} [attributes.filterable=false] Whether the library is filterable, and if so what filters should be shown. 1469 * Accepts 'all', 'uploaded', or 'unattached'. 1470 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1471 * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. 1472 * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. 1473 * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. 1474 * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. 1283 1475 */ 1284 1476 media.controller.FeaturedImage = media.controller.Library.extend({ … … 1286 1478 id: 'featured-image', 1287 1479 title: l10n.setFeaturedImageTitle, 1288 // Selection defaults. @see media.model.Selection1289 1480 multiple: false, 1290 // Attachments browser defaults. @see media.view.AttachmentsBrowser1291 1481 filterable: 'uploaded', 1292 // Region mode defaults.1293 1482 toolbar: 'featured-image', 1294 1295 1483 priority: 60, 1296 1484 syncSelection: true … … 1370 1558 1371 1559 /** 1560 * wp.media.controller.ReplaceImage 1561 * 1372 1562 * A state for replacing an image. 1373 1563 * 1374 * @c onstructor1564 * @class 1375 1565 * @augments wp.media.controller.Library 1376 1566 * @augments wp.media.controller.State 1377 1567 * @augments Backbone.Model 1568 * 1569 * @param {object} [attributes] The attributes hash passed to the state. 1570 * @param {string} [attributes.id=replace-image] Unique identifier. 1571 * @param {string} [attributes.title=Replace Image] Title for the state. Displays in the media menu and the frame's title region. 1572 * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. 1573 * If one is not supplied, a collection of all images will be created. 1574 * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. 1575 * @param {string} [attributes.content=upload] Initial mode for the content region. 1576 * Overridden by persistent user setting if 'contentUserSetting' is true. 1577 * @param {string} [attributes.menu=default] Initial mode for the menu region. 1578 * @param {string} [attributes.router=browse] Initial mode for the router region. 1579 * @param {string} [attributes.toolbar=replace] Initial mode for the toolbar region. 1580 * @param {int} [attributes.priority=60] The priority for the state link in the media menu. 1581 * @param {boolean} [attributes.searchable=true] Whether the library is searchable. 1582 * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. 1583 * Accepts 'all', 'uploaded', or 'unattached'. 1584 * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. 1585 * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. 1586 * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. 1587 * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. 1588 * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. 1378 1589 */ 1379 1590 media.controller.ReplaceImage = media.controller.Library.extend({ … … 1381 1592 id: 'replace-image', 1382 1593 title: l10n.replaceImageTitle, 1383 // Selection defaults. @see media.model.Selection1384 1594 multiple: false, 1385 // Attachments browser defaults. @see media.view.AttachmentsBrowser1386 1595 filterable: 'uploaded', 1387 // Region mode defaults.1388 1596 toolbar: 'replace', 1389 1597 menu: false, 1390 1391 1598 priority: 60, 1392 1599 syncSelection: true … … 1452 1659 1453 1660 /** 1661 * wp.media.controller.EditImage 1662 * 1454 1663 * A state for editing (cropping, etc.) an image. 1455 1664 * 1456 * @c onstructor1665 * @class 1457 1666 * @augments wp.media.controller.State 1458 1667 * @augments Backbone.Model 1668 * 1669 * @param {object} attributes The attributes hash passed to the state. 1670 * @param {wp.media.model.Attachment} attributes.model The attachment. 1671 * @param {string} [attributes.id=edit-image] Unique identifier. 1672 * @param {string} [attributes.title=Edit Image] Title for the state. Displays in the media menu and the frame's title region. 1673 * @param {string} [attributes.content=edit-image] Initial mode for the content region. 1674 * @param {string} [attributes.toolbar=edit-image] Initial mode for the toolbar region. 1675 * @param {string} [attributes.menu=false] Initial mode for the menu region. 1676 * @param {string} [attributes.url] Unused. @todo Consider removal. 1459 1677 */ 1460 1678 media.controller.EditImage = media.controller.State.extend({ … … 1462 1680 id: 'edit-image', 1463 1681 title: l10n.editImage, 1464 // Region mode defaults.1465 1682 menu: false, 1466 1683 toolbar: 'edit-image', 1467 1684 content: 'edit-image', 1468 1469 1685 url: '' 1470 1686 }, … … 1515 1731 * wp.media.controller.MediaLibrary 1516 1732 * 1517 * @c onstructor1733 * @class 1518 1734 * @augments wp.media.controller.Library 1519 1735 * @augments wp.media.controller.State … … 1547 1763 */ 1548 1764 activate: function() { 1765 // @todo this should use this.frame. 1549 1766 if ( media.frame.lastMime ) { 1550 1767 this.set( 'library', media.query({ type: media.frame.lastMime }) ); … … 1558 1775 * wp.media.controller.Embed 1559 1776 * 1560 * @constructor 1777 * A state for embedding media from a URL. 1778 * 1779 * @class 1561 1780 * @augments wp.media.controller.State 1562 1781 * @augments Backbone.Model 1782 * 1783 * @param {object} attributes The attributes hash passed to the state. 1784 * @param {string} [attributes.id=embed] Unique identifier. 1785 * @param {string} [attributes.title=Insert From URL] Title for the state. Displays in the media menu and the frame's title region. 1786 * @param {string} [attributes.content=embed] Initial mode for the content region. 1787 * @param {string} [attributes.menu=default] Initial mode for the menu region. 1788 * @param {string} [attributes.toolbar=main-embed] Initial mode for the toolbar region. 1789 * @param {string} [attributes.menu=false] Initial mode for the menu region. 1790 * @param {int} [attributes.priority=120] The priority for the state link in the media menu. 1791 * @param {string} [attributes.type=link] The type of embed. Currently only link is supported. 1792 * @param {string} [attributes.url] The embed URL. 1793 * @param {object} [attributes.metadata={}] Properties of the embed, which will override attributes.url if set. 1563 1794 */ 1564 1795 media.controller.Embed = media.controller.State.extend({ … … 1566 1797 id: 'embed', 1567 1798 title: l10n.insertFromUrlTitle, 1568 // Region mode defaults.1569 1799 content: 'embed', 1570 1800 menu: 'default', 1571 1801 toolbar: 'main-embed', 1572 1573 1802 priority: 120, 1574 1803 type: 'link', … … 1590 1819 1591 1820 /** 1821 * Trigger a scan of the embedded URL's content for metadata required to embed. 1822 * 1592 1823 * @fires wp.media.controller.Embed#scan 1593 1824 */ … … 1622 1853 }, 1623 1854 /** 1855 * Try scanning the embed as an image to discover its dimensions. 1856 * 1624 1857 * @param {Object} attributes 1625 1858 */ … … 1671 1904 * wp.media.controller.Cropper 1672 1905 * 1673 * A llows for a cropping step.1674 * 1675 * @c onstructor1906 * A state for cropping an image. 1907 * 1908 * @class 1676 1909 * @augments wp.media.controller.State 1677 1910 * @augments Backbone.Model … … 1775 2008 1776 2009 /** 1777 * ========================================================================1778 * VIEWS1779 * ========================================================================1780 */1781 1782 /**1783 2010 * wp.media.View 1784 * ------------- 1785 * 1786 * The base view class. 2011 * 2012 * The base view class for media. 1787 2013 * 1788 2014 * Undelegating events, removing events from the model, and … … 1793 2019 * outside of the media manager. 1794 2020 * 1795 * @c onstructor2021 * @class 1796 2022 * @augments wp.Backbone.View 1797 2023 * @augments Backbone.View … … 1805 2031 }, 1806 2032 /** 2033 * @todo The internal comment mentions this might have been a stop-gap 2034 * before Backbone 0.9.8 came out. Figure out if Backbone core takes 2035 * care of this in Backbone.View now. 2036 * 1807 2037 * @returns {wp.media.View} Returns itself to allow chaining 1808 2038 */ … … 1844 2074 * 1845 2075 * A frame is a composite view consisting of one or more regions and one or more 1846 * states. Only one state can be active at any given moment. 1847 * 1848 * @constructor 2076 * states. 2077 * 2078 * @see wp.media.controller.State 2079 * @see wp.media.controller.Region 2080 * 2081 * @class 1849 2082 * @augments wp.media.View 1850 2083 * @augments wp.Backbone.View … … 1876 2109 }, 1877 2110 /** 2111 * Create the frame's states. 2112 * 2113 * @see wp.media.controller.State 2114 * @see wp.media.controller.StateMachine 2115 * 1878 2116 * @fires wp.media.controller.State#ready 1879 2117 */ … … 1894 2132 } 1895 2133 }, 2134 2135 /** 2136 * A frame can be in a mode or multiple modes at one time. 2137 * 2138 * For example, the manage media frame can be in the `Bulk Select` or `Edit` mode. 2139 */ 1896 2140 _createModes: function() { 1897 2141 // Store active "modes" that the frame is in. Unrelated to region modes. … … 1904 2148 }, 1905 2149 /** 2150 * Reset all states on the frame to their defaults. 2151 * 1906 2152 * @returns {wp.media.view.Frame} Returns itself to allow chaining 1907 2153 */ … … 1990 2236 * wp.media.view.MediaFrame 1991 2237 * 1992 * T ype offrame used to create the media modal.1993 * 1994 * @c onstructor2238 * The frame used to create the media modal. 2239 * 2240 * @class 1995 2241 * @augments wp.media.view.Frame 1996 2242 * @augments wp.media.View … … 2225 2471 * wp.media.view.MediaFrame.Select 2226 2472 * 2227 * Type of media frame that is used to select an item or items from the media library2228 * 2229 * @c onstructor2473 * A frame for selecting an item or items from the media library. 2474 * 2475 * @class 2230 2476 * @augments wp.media.view.MediaFrame 2231 2477 * @augments wp.media.view.Frame … … 2389 2635 * wp.media.view.MediaFrame.Post 2390 2636 * 2391 * @constructor 2637 * The frame for manipulating media on the Edit Post page. 2638 * 2639 * @class 2392 2640 * @augments wp.media.view.MediaFrame.Select 2393 2641 * @augments wp.media.view.MediaFrame … … 2425 2673 }, 2426 2674 2675 /** 2676 * Create the default states. 2677 */ 2427 2678 createStates: function() { 2428 2679 var options = this.options; 2429 2680 2430 // Add the default states.2431 2681 this.states.add([ 2432 2682 // Main states. … … 3109 3359 * wp.media.view.MediaFrame.ImageDetails 3110 3360 * 3111 * @constructor 3361 * A media frame for manipulating an image that's already been inserted 3362 * into a post. 3363 * 3364 * @class 3112 3365 * @augments wp.media.view.MediaFrame.Select 3113 3366 * @augments wp.media.view.MediaFrame … … 3131 3384 3132 3385 initialize: function( options ) { 3386 debugger; 3133 3387 this.image = new media.model.PostImage( options.metadata ); 3134 3388 this.options.selection = new media.model.Selection( this.image.attachment, { multiple: false } ); … … 3276 3530 * wp.media.view.Modal 3277 3531 * 3278 * @constructor 3532 * A modal view, which the media modal uses as its default container. 3533 * 3534 * @class 3279 3535 * @augments wp.media.View 3280 3536 * @augments wp.Backbone.View … … 3481 3737 * wp.media.view.FocusManager 3482 3738 * 3483 * @c onstructor3739 * @class 3484 3740 * @augments wp.media.View 3485 3741 * @augments wp.Backbone.View … … 3523 3779 * wp.media.view.UploaderWindow 3524 3780 * 3525 * @constructor 3781 * An uploader window that allows for dragging and dropping media. 3782 * 3783 * @class 3526 3784 * @augments wp.media.View 3527 3785 * @augments wp.Backbone.View 3528 3786 * @augments Backbone.View 3787 * 3788 * @param {object} [options] Options hash passed to the view. 3789 * @param {object} [options.uploader] Uploader properties. 3790 * @param {jQuery} [options.uploader.browser] 3791 * @param {jQuery} [options.uploader.dropzone] jQuery collection of the dropzone. 3792 * @param {object} [options.uploader.params] 3529 3793 */ 3530 3794 media.view.UploaderWindow = media.View.extend({ … … 3620 3884 * wp.media.view.EditorUploader 3621 3885 * 3622 * @c onstructor3886 * @class 3623 3887 * @augments wp.media.View 3624 3888 * @augments wp.Backbone.View … … 3724 3988 }, 3725 3989 3990 /** 3991 * When a file is dropped on the editor uploader, open up an editor media workflow 3992 * and upload the file immediately. 3993 * 3994 * @param {jQuery.Event} event The 'drop' event. 3995 */ 3726 3996 drop: function( event ) { 3727 3997 var $wrap = null, uploadView; … … 3763 4033 }, 3764 4034 4035 /** 4036 * Add the files to the uploader. 4037 */ 3765 4038 addFiles: function() { 3766 4039 if ( this.files.length ) { … … 3813 4086 * wp.media.view.UploaderInline 3814 4087 * 3815 * @constructor 4088 * The inline uploader that shows up in the 'Upload Files' tab. 4089 * 4090 * @class 3816 4091 * @augments wp.media.View 3817 4092 * @augments wp.Backbone.View … … 3936 4211 * wp.media.view.UploaderStatus 3937 4212 * 3938 * @constructor 4213 * An uploader status for on-going uploads. 4214 * 4215 * @class 3939 4216 * @augments wp.media.View 3940 4217 * @augments wp.Backbone.View … … 4066 4343 * wp.media.view.UploaderStatusError 4067 4344 * 4068 * @c onstructor4345 * @class 4069 4346 * @augments wp.media.View 4070 4347 * @augments wp.Backbone.View … … 4079 4356 * wp.media.view.Toolbar 4080 4357 * 4081 * @constructor 4358 * A toolbar which consists of a primary and a secondary section. Each sections 4359 * can be filled with views. 4360 * 4361 * @class 4082 4362 * @augments wp.media.View 4083 4363 * @augments wp.Backbone.View … … 4230 4510 * wp.media.view.Toolbar.Select 4231 4511 * 4232 * @c onstructor4512 * @class 4233 4513 * @augments wp.media.view.Toolbar 4234 4514 * @augments wp.media.View … … 4295 4575 * wp.media.view.Toolbar.Embed 4296 4576 * 4297 * @c onstructor4577 * @class 4298 4578 * @augments wp.media.view.Toolbar.Select 4299 4579 * @augments wp.media.view.Toolbar … … 4327 4607 * wp.media.view.Button 4328 4608 * 4329 * @c onstructor4609 * @class 4330 4610 * @augments wp.media.View 4331 4611 * @augments wp.Backbone.View … … 4410 4690 * wp.media.view.ButtonGroup 4411 4691 * 4412 * @c onstructor4692 * @class 4413 4693 * @augments wp.media.View 4414 4694 * @augments wp.Backbone.View … … 4450 4730 * wp.media.view.PriorityList 4451 4731 * 4452 * @c onstructor4732 * @class 4453 4733 * @augments wp.media.View 4454 4734 * @augments wp.Backbone.View … … 4544 4824 * wp.media.view.MenuItem 4545 4825 * 4546 * @c onstructor4826 * @class 4547 4827 * @augments wp.media.View 4548 4828 * @augments wp.Backbone.View … … 4610 4890 * wp.media.view.Menu 4611 4891 * 4612 * @c onstructor4892 * @class 4613 4893 * @augments wp.media.view.PriorityList 4614 4894 * @augments wp.media.View … … 4720 5000 * wp.media.view.RouterItem 4721 5001 * 4722 * @c onstructor5002 * @class 4723 5003 * @augments wp.media.view.MenuItem 4724 5004 * @augments wp.media.View … … 4741 5021 * wp.media.view.Router 4742 5022 * 4743 * @c onstructor5023 * @class 4744 5024 * @augments wp.media.view.Menu 4745 5025 * @augments wp.media.view.PriorityList … … 4774 5054 * wp.media.view.Sidebar 4775 5055 * 4776 * @c onstructor5056 * @class 4777 5057 * @augments wp.media.view.PriorityList 4778 5058 * @augments wp.media.View … … 4787 5067 * wp.media.view.Attachment 4788 5068 * 4789 * @c onstructor5069 * @class 4790 5070 * @augments wp.media.View 4791 5071 * @augments wp.Backbone.View … … 5320 5600 * wp.media.view.Attachment.Library 5321 5601 * 5322 * @c onstructor5602 * @class 5323 5603 * @augments wp.media.view.Attachment 5324 5604 * @augments wp.media.View … … 5335 5615 * wp.media.view.Attachment.EditLibrary 5336 5616 * 5337 * @c onstructor5617 * @class 5338 5618 * @augments wp.media.view.Attachment 5339 5619 * @augments wp.media.View … … 5350 5630 * wp.media.view.Attachments 5351 5631 * 5352 * @c onstructor5632 * @class 5353 5633 * @augments wp.media.View 5354 5634 * @augments wp.Backbone.View … … 5642 5922 * wp.media.view.Search 5643 5923 * 5644 * @c onstructor5924 * @class 5645 5925 * @augments wp.media.View 5646 5926 * @augments wp.Backbone.View … … 5684 5964 * wp.media.view.AttachmentFilters 5685 5965 * 5686 * @c onstructor5966 * @class 5687 5967 * @augments wp.media.View 5688 5968 * @augments wp.Backbone.View … … 5756 6036 * A filter dropdown for month/dates. 5757 6037 * 5758 * @c onstructor6038 * @class 5759 6039 * @augments wp.media.view.AttachmentFilters 5760 6040 * @augments wp.media.View … … 5791 6071 * wp.media.view.AttachmentFilters.Uploaded 5792 6072 * 5793 * @c onstructor6073 * @class 5794 6074 * @augments wp.media.view.AttachmentFilters 5795 6075 * @augments wp.media.View … … 5844 6124 * wp.media.view.AttachmentFilters.All 5845 6125 * 5846 * @c onstructor6126 * @class 5847 6127 * @augments wp.media.view.AttachmentFilters 5848 6128 * @augments wp.media.View … … 5928 6208 * wp.media.view.AttachmentsBrowser 5929 6209 * 5930 * @c onstructor6210 * @class 5931 6211 * @augments wp.media.View 5932 6212 * @augments wp.Backbone.View … … 6345 6625 * wp.media.view.Selection 6346 6626 * 6347 * @c onstructor6627 * @class 6348 6628 * @augments wp.media.View 6349 6629 * @augments wp.Backbone.View … … 6423 6703 * wp.media.view.Attachment.Selection 6424 6704 * 6425 * @c onstructor6705 * @class 6426 6706 * @augments wp.media.view.Attachment 6427 6707 * @augments wp.media.View … … 6442 6722 * wp.media.view.Attachments.Selection 6443 6723 * 6444 * @c onstructor6724 * @class 6445 6725 * @augments wp.media.view.Attachments 6446 6726 * @augments wp.media.View … … 6468 6748 * wp.media.view.Attachments.EditSelection 6469 6749 * 6470 * @c onstructor6750 * @class 6471 6751 * @augments wp.media.view.Attachment.Selection 6472 6752 * @augments wp.media.view.Attachment … … 6485 6765 * wp.media.view.Settings 6486 6766 * 6487 * @c onstructor6767 * @class 6488 6768 * @augments wp.media.View 6489 6769 * @augments wp.Backbone.View … … 6599 6879 * wp.media.view.Settings.AttachmentDisplay 6600 6880 * 6601 * @c onstructor6881 * @class 6602 6882 * @augments wp.media.view.Settings 6603 6883 * @augments wp.media.View … … 6689 6969 * wp.media.view.Settings.Gallery 6690 6970 * 6691 * @c onstructor6971 * @class 6692 6972 * @augments wp.media.view.Settings 6693 6973 * @augments wp.media.View … … 6703 6983 * wp.media.view.Settings.Playlist 6704 6984 * 6705 * @c onstructor6985 * @class 6706 6986 * @augments wp.media.view.Settings 6707 6987 * @augments wp.media.View … … 6717 6997 * wp.media.view.Attachment.Details 6718 6998 * 6719 * @c onstructor6999 * @class 6720 7000 * @augments wp.media.view.Attachment 6721 7001 * @augments wp.media.View … … 6847 7127 * A view to display fields added via the `attachment_fields_to_edit` filter. 6848 7128 * 6849 * @c onstructor7129 * @class 6850 7130 * @augments wp.media.View 6851 7131 * @augments wp.Backbone.View … … 6924 7204 * wp.media.view.Iframe 6925 7205 * 6926 * @c onstructor7206 * @class 6927 7207 * @augments wp.media.View 6928 7208 * @augments wp.Backbone.View … … 6945 7225 * wp.media.view.Embed 6946 7226 * 6947 * @c onstructor7227 * @class 6948 7228 * @augments wp.media.View 6949 7229 * @augments wp.Backbone.View … … 7004 7284 7005 7285 /** 7006 * @c onstructor7286 * @class 7007 7287 * @augments wp.media.View 7008 7288 * @augments wp.Backbone.View … … 7027 7307 * wp.media.view.EmbedUrl 7028 7308 * 7029 * @c onstructor7309 * @class 7030 7310 * @augments wp.media.View 7031 7311 * @augments wp.Backbone.View … … 7101 7381 * wp.media.view.EmbedLink 7102 7382 * 7103 * @c onstructor7383 * @class 7104 7384 * @augments wp.media.view.Settings 7105 7385 * @augments wp.media.View … … 7161 7441 * wp.media.view.EmbedImage 7162 7442 * 7163 * @c onstructor7443 * @class 7164 7444 * @augments wp.media.view.Settings.AttachmentDisplay 7165 7445 * @augments wp.media.view.Settings … … 7188 7468 * wp.media.view.ImageDetails 7189 7469 * 7190 * @c onstructor7470 * @class 7191 7471 * @augments wp.media.view.Settings.AttachmentDisplay 7192 7472 * @augments wp.media.view.Settings … … 7354 7634 * wp.customize.HeaderControl.openMM. 7355 7635 * 7356 * @c onstructor7636 * @class 7357 7637 * @augments wp.media.View 7358 7638 * @augments wp.Backbone.View … … 7455 7735 * wp.media.view.Spinner 7456 7736 * 7457 * @c onstructor7737 * @class 7458 7738 * @augments wp.media.View 7459 7739 * @augments wp.Backbone.View
Note: See TracChangeset
for help on using the changeset viewer.