Ticket #28459: 28459.6.diff
| File 28459.6.diff, 12.6 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/js/media-views.js
94 94 /** 95 95 * Activate a mode. 96 96 * 97 * @since 3.5.0 98 * 97 99 * @param {string} mode 98 100 * 99 101 * @fires this.view#{this.id}:activate:{this._mode} … … 135 137 /** 136 138 * Render a mode. 137 139 * 140 * @since 3.5.0 141 * 138 142 * @param {string} mode 139 143 * 140 144 * @fires this.view#{this.id}:create:{this._mode} … … 182 186 /** 183 187 * Get the region's view. 184 188 * 189 * @since 3.5.0 190 * 185 191 * @returns {wp.media.View} 186 192 */ 187 193 get: function() { … … 191 197 /** 192 198 * Set the region's view as a subview of the frame. 193 199 * 200 * @since 3.5.0 201 * 194 202 * @param {Array|Object} views 195 203 * @param {Object} [options={}] 196 204 * @returns {wp.Backbone.Subviews} Subviews is returned to allow chaining … … 205 213 /** 206 214 * Trigger regional view events on the frame. 207 215 * 216 * @since 3.5.0 217 * 208 218 * @param {string} event 209 219 * @returns {undefined|wp.media.controller.Region} Returns itself to allow chaining. 210 220 */ … … 232 242 /** 233 243 * wp.media.controller.StateMachine 234 244 * 245 * @since 3.5.0 246 * 235 247 * @constructor 236 248 * @augments Backbone.Model 237 249 * @mixin … … 257 269 * Ensure that the `states` collection exists so the `StateMachine` 258 270 * can be used as a mixin. 259 271 * 272 * @since 3.5.0 273 * 260 274 * @param {string} id 261 275 * @returns {wp.media.controller.State} Returns a State model 262 276 * from the StateMachine collection … … 280 294 * created the `states` collection, or are trying to select a state 281 295 * that does not exist. 282 296 * 297 * @since 3.5.0 298 * 283 299 * @param {string} id 284 300 * 285 301 * @fires wp.media.controller.State#deactivate … … 311 327 * Call the `state()` method with no parameters to retrieve the current 312 328 * active state. 313 329 * 330 * @since 3.5.0 331 * 314 332 * @returns {wp.media.controller.State} Returns a State model 315 333 * from the StateMachine collection 316 334 */ … … 347 365 * @augments Backbone.Model 348 366 */ 349 367 media.controller.State = Backbone.Model.extend({ 368 /** 369 * Constructor. 370 * 371 * @since 3.5.0 372 */ 350 373 constructor: function() { 351 374 this.on( 'activate', this._preActivate, this ); 352 375 this.on( 'activate', this.activate, this ); … … 364 387 }, 365 388 /** 366 389 * @abstract 390 * @since 3.5.0 367 391 */ 368 392 ready: function() {}, 393 369 394 /** 370 395 * @abstract 396 * @since 3.5.0 371 397 */ 372 398 activate: function() {}, 399 373 400 /** 374 401 * @abstract 402 * @since 3.5.0 375 403 */ 376 404 deactivate: function() {}, 405 377 406 /** 378 407 * @abstract 408 * @since 3.5.0 379 409 */ 380 410 reset: function() {}, 411 381 412 /** 382 413 * @access private 414 * @since 4.0.0 383 415 */ 384 416 _ready: function() { 385 417 this._updateMenu(); 386 418 }, 419 387 420 /** 388 421 * @access private 422 * @since 3.5.0 389 423 */ 390 424 _preActivate: function() { 391 425 this.active = true; 392 426 }, 427 393 428 /** 394 429 * @access private 430 * @since 3.5.0 395 431 */ 396 432 _postActivate: function() { 397 433 this.on( 'change:menu', this._menu, this ); … … 407 443 this._content(); 408 444 this._router(); 409 445 }, 446 410 447 /** 411 448 * @access private 449 * @since 3.5.0 412 450 */ 413 451 _deactivate: function() { 414 452 this.active = false; … … 420 458 this.off( 'change:content', this._content, this ); 421 459 this.off( 'change:toolbar', this._toolbar, this ); 422 460 }, 461 423 462 /** 424 463 * @access private 464 * @since 3.5.0 425 465 */ 426 466 _title: function() { 427 467 this.frame.title.render( this.get('titleMode') || 'default' ); 428 468 }, 469 429 470 /** 430 471 * @access private 472 * @since 3.5.0 431 473 */ 432 474 _renderTitle: function( view ) { 433 475 view.$el.text( this.get('title') || '' ); 434 476 }, 477 435 478 /** 436 479 * @access private 480 * @since 3.5.0 437 481 */ 438 482 _router: function() { 439 483 var router = this.frame.router, … … 452 496 view.select( this.frame.content.mode() ); 453 497 } 454 498 }, 499 455 500 /** 456 501 * @access private 502 * @since 3.5.0 457 503 */ 458 504 _menu: function() { 459 505 var menu = this.frame.menu, … … 471 517 view.select( this.id ); 472 518 } 473 519 }, 520 474 521 /** 475 522 * @access private 523 * @since 3.5.0 476 524 */ 477 525 _updateMenu: function() { 478 526 var previous = this.previous('menu'), … … 486 534 this.frame.on( 'menu:render:' + menu, this._renderMenu, this ); 487 535 } 488 536 }, 537 489 538 /** 490 539 * @access private 540 * @since 3.5.0 491 541 */ 492 542 _renderMenu: function( view ) { 493 543 var menuItem = this.get('menuItem'), … … 523 573 }); 524 574 525 575 media.selectionSync = { 576 /** 577 * @since 3.5.0 578 */ 526 579 syncSelection: function() { 527 580 var selection = this.get('selection'), 528 581 manager = this.frame._selection; … … 550 603 * of the selection's attachments and the set of selected 551 604 * attachments that this specific selection considered invalid. 552 605 * Reset the difference and record the single attachment. 606 * 607 * @since 3.5.0 553 608 */ 554 609 recordSelection: function() { 555 610 var selection = this.get('selection'), … … 603 658 /** 604 659 * If a library isn't provided, query all media items. 605 660 * If a selection instance isn't provided, create one. 661 * 662 * @since 3.5.0 606 663 */ 607 664 initialize: function() { 608 665 var selection = this.get('selection'), … … 641 698 this.resetDisplays(); 642 699 }, 643 700 701 /** 702 * @since 3.5.0 703 */ 644 704 activate: function() { 645 705 this.syncSelection(); 646 706 … … 654 714 } 655 715 }, 656 716 717 /** 718 * @since 3.5.0 719 */ 657 720 deactivate: function() { 658 721 this.recordSelection(); 659 722 … … 666 729 wp.Uploader.queue.off( null, null, this ); 667 730 }, 668 731 732 /** 733 * @since 3.5.0 734 */ 669 735 reset: function() { 670 736 this.get('selection').reset(); 671 737 this.resetDisplays(); 672 738 this.refreshContent(); 673 739 }, 674 740 741 /** 742 * @since 3.5.0 743 */ 675 744 resetDisplays: function() { 676 745 var defaultProps = media.view.settings.defaultProps; 677 746 this._displays = []; … … 683 752 }, 684 753 685 754 /** 755 * @since 3.5.0 756 * 686 757 * @param {wp.media.model.Attachment} attachment 687 758 * @returns {Backbone.Model} 688 759 */ … … 696 767 }, 697 768 698 769 /** 770 * @since 3.6.0 771 * 699 772 * @param {wp.media.model.Attachment} attachment 700 773 * @returns {Object} 701 774 */ … … 708 781 }, 709 782 710 783 /** 784 * @since 3.6.0 785 * 711 786 * @param {wp.media.model.Attachment} attachment 712 787 * @returns {Boolean} 713 788 */ … … 728 803 * If the state is active, no items are selected, and the current 729 804 * content mode is not an option in the state's router (provided 730 805 * the state has a router), reset the content mode to the default. 806 * 807 * @since 3.5.0 731 808 */ 732 809 refreshContent: function() { 733 810 var selection = this.get('selection'), … … 749 826 * limit themselves to one attachment (in this case, the last 750 827 * attachment in the upload queue). 751 828 * 829 * @since 3.5.0 830 * 752 831 * @param {wp.media.model.Attachment} attachment 753 832 */ 754 833 uploading: function( attachment ) { … … 762 841 763 842 /** 764 843 * Only track the browse router on library states. 844 * 845 * @since 3.5.0 765 846 */ 766 847 saveContentMode: function() { 767 848 if ( 'browse' !== this.get('router') ) { … … 800 881 priority: 60 801 882 }, media.controller.Library.prototype.defaults ), 802 883 884 /** 885 * @since 3.9.0 886 * 887 * @param options Attributes 888 */ 803 889 initialize: function( options ) { 804 890 this.image = options.image; 805 891 media.controller.State.prototype.initialize.apply( this, arguments ); 806 892 }, 807 893 894 /** 895 * @since 3.9.0 896 */ 808 897 activate: function() { 809 898 this.frame.modal.$el.addClass('image-details'); 810 899 } … … 843 932 syncSelection: false 844 933 }, 845 934 935 /** 936 * @since 3.9.0 937 */ 846 938 initialize: function() { 847 939 // If we haven't been provided a `library`, create a `Selection`. 848 940 if ( ! this.get('library') ) … … 854 946 media.controller.Library.prototype.initialize.apply( this, arguments ); 855 947 }, 856 948 949 /** 950 * since 3.9.0 951 */ 857 952 activate: function() { 858 953 var library = this.get('library'); 859 954 … … 868 963 media.controller.Library.prototype.activate.apply( this, arguments ); 869 964 }, 870 965 966 /** 967 * @since 3.9.0 968 */ 871 969 deactivate: function() { 872 970 // Stop watching for uploaded attachments. 873 971 this.get('library').unobserve( wp.Uploader.queue ); … … 877 975 media.controller.Library.prototype.deactivate.apply( this, arguments ); 878 976 }, 879 977 978 /** 979 * @since 3.9.0 980 * 981 * @param browser 982 */ 880 983 gallerySettings: function( browser ) { 881 984 if ( ! this.get('displaySettings') ) { 882 985 return; … … 935 1038 syncSelection: false 936 1039 }, media.controller.Library.prototype.defaults ), 937 1040 1041 /** 1042 * @since 3.9.0 1043 */ 938 1044 initialize: function() { 939 1045 // If we haven't been provided a `library`, create a `Selection`. 940 1046 if ( ! this.get('library') ) … … 943 1049 media.controller.Library.prototype.initialize.apply( this, arguments ); 944 1050 }, 945 1051 1052 /** 1053 * @since 3.9.0 1054 */ 946 1055 activate: function() { 947 1056 var library = this.get('library'), 948 1057 edit = this.frame.state('gallery-edit').get('library'); … … 997 1106 syncSelection: false 998 1107 }, 999 1108 1109 /** 1110 * @since 3.9.0 1111 */ 1000 1112 initialize: function() { 1001 1113 var collectionType = this.get('collectionType'); 1002 1114 … … 1018 1130 media.controller.Library.prototype.initialize.apply( this, arguments ); 1019 1131 }, 1020 1132 1133 /** 1134 * @since 3.9.0 1135 */ 1021 1136 activate: function() { 1022 1137 var library = this.get('library'); 1023 1138 … … 1032 1147 media.controller.Library.prototype.activate.apply( this, arguments ); 1033 1148 }, 1034 1149 1150 /** 1151 * @since 3.9.0 1152 */ 1035 1153 deactivate: function() { 1036 1154 // Stop watching for uploaded attachments. 1037 1155 this.get('library').unobserve( wp.Uploader.queue ); … … 1041 1159 media.controller.Library.prototype.deactivate.apply( this, arguments ); 1042 1160 }, 1043 1161 1162 /** 1163 * @since 3.9.0 1164 * 1165 * @param browser 1166 */ 1044 1167 renderSettings: function( browser ) { 1045 1168 var library = this.get('library'), 1046 1169 collectionType = this.get('collectionType'), … … 1099 1222 syncSelection: false 1100 1223 }, media.controller.Library.prototype.defaults ), 1101 1224 1225 /** 1226 * @since 3.9.0 1227 */ 1102 1228 initialize: function() { 1103 1229 var collectionType = this.get('collectionType'); 1104 1230 … … 1117 1243 media.controller.Library.prototype.initialize.apply( this, arguments ); 1118 1244 }, 1119 1245 1246 /** 1247 * @since 3.9.0 1248 */ 1120 1249 activate: function() { 1121 1250 var library = this.get('library'), 1122 1251 editLibrary = this.get('editLibrary'), … … 1166 1295 syncSelection: true 1167 1296 }, media.controller.Library.prototype.defaults ), 1168 1297 1298 /** 1299 * @since 3.5.0 1300 */ 1169 1301 initialize: function() { 1170 1302 var library, comparator; 1171 1303 … … 1199 1331 library.observe( this.get('selection') ); 1200 1332 }, 1201 1333 1334 /** 1335 * @since 3.5.0 1336 */ 1202 1337 activate: function() { 1203 1338 this.updateSelection(); 1204 1339 this.frame.on( 'open', this.updateSelection, this ); … … 1206 1341 media.controller.Library.prototype.activate.apply( this, arguments ); 1207 1342 }, 1208 1343 1344 /** 1345 * @since 3.5.0 1346 */ 1209 1347 deactivate: function() { 1210 1348 this.frame.off( 'open', this.updateSelection, this ); 1211 1349 1212 1350 media.controller.Library.prototype.deactivate.apply( this, arguments ); 1213 1351 }, 1214 1352 1353 /** 1354 * @since 3.5.0 1355 */ 1215 1356 updateSelection: function() { 1216 1357 var selection = this.get('selection'), 1217 1358 id = media.view.settings.post.featuredImageId, … … 1249 1390 syncSelection: true 1250 1391 }, media.controller.Library.prototype.defaults ), 1251 1392 1393 /** 1394 * @since 3.9.0 1395 * 1396 * @param options 1397 */ 1252 1398 initialize: function( options ) { 1253 1399 var library, comparator; 1254 1400 … … 1283 1429 library.observe( this.get('selection') ); 1284 1430 }, 1285 1431 1432 /** 1433 * @since 3.9.0 1434 */ 1286 1435 activate: function() { 1287 1436 this.updateSelection(); 1288 1437 media.controller.Library.prototype.activate.apply( this, arguments ); 1289 1438 }, 1290 1439 1440 /** 1441 * @since 3.9.0 1442 */ 1291 1443 updateSelection: function() { 1292 1444 var selection = this.get('selection'), 1293 1445 attachment = this.image.attachment; … … 1315 1467 url: '' 1316 1468 }, 1317 1469 1470 /** 1471 * @since 3.9.0 1472 */ 1318 1473 activate: function() { 1319 1474 this.listenTo( this.frame, 'toolbar:render:edit-image', this.toolbar ); 1320 1475 }, 1321 1476 1477 /** 1478 * @since 3.9.0 1479 */ 1322 1480 deactivate: function() { 1323 1481 this.stopListening( this.frame ); 1324 1482 }, 1325 1483 1484 /** 1485 * @since 3.9.0 1486 */ 1326 1487 toolbar: function() { 1327 1488 var frame = this.frame, 1328 1489 lastState = frame.lastState(), … … 1366 1527 syncSelection: false 1367 1528 }, media.controller.Library.prototype.defaults ), 1368 1529 1530 /** 1531 * @since 3.9.0 1532 * 1533 * @param options 1534 */ 1369 1535 initialize: function( options ) { 1370 1536 this.media = options.media; 1371 1537 this.type = options.type; … … 1374 1540 media.controller.Library.prototype.initialize.apply( this, arguments ); 1375 1541 }, 1376 1542 1543 /** 1544 * @since 3.9.0 1545 */ 1377 1546 activate: function() { 1378 1547 if ( media.frame.lastMime ) { 1379 1548 this.set( 'library', media.query({ type: media.frame.lastMime }) );