Changeset 22340
- Timestamp:
- 10/31/2012 07:22:25 PM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/mce-view.js
r22320 r22340 591 591 var shortcodeString = shortcode.string(), 592 592 result = galleries[ shortcodeString ], 593 attrs, args ;593 attrs, args, query; 594 594 595 595 delete galleries[ shortcodeString ]; … … 618 618 args.parent = attrs.id || parent; 619 619 620 return media.query( args ); 620 query = media.query( args ); 621 query.props.set( _.pick( attrs, 'columns', 'link' ) ); 622 return query; 621 623 }, 622 624 623 625 shortcode: function( attachments ) { 624 626 var props = attachments.props.toJSON(), 625 attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order' ),627 attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order', 'link', 'columns' ), 626 628 shortcode; 627 629 -
trunk/wp-includes/js/media-views.js
r22339 r22340 283 283 284 284 this.details(); 285 frame.sidebar().add({ 286 settings: new media.view.Settings.Gallery({ 287 controller: frame, 288 model: this.get('library').props, 289 priority: 40 290 }).render() 291 }); 285 292 }, 286 293 … … 753 760 { 754 761 classes: ['down-arrow'], 755 dropdown: new media.view. AttachmentDisplaySettings().render().$el,762 dropdown: new media.view.Settings.AttachmentDisplay().render().$el, 756 763 757 764 click: function( event ) { … … 1445 1452 1446 1453 /** 1447 * wp.media.view. AttachmentDisplaySettings1448 */ 1449 media.view. AttachmentDisplaySettings = Backbone.View.extend({1454 * wp.media.view.Settings 1455 */ 1456 media.view.Settings = Backbone.View.extend({ 1450 1457 tagName: 'div', 1451 1458 className: 'attachment-display-settings', … … 1453 1460 1454 1461 events: { 1455 'click button': 'updateHandler' 1456 }, 1457 1458 settings: { 1462 'click button': 'updateHandler', 1463 'change input': 'updateHandler', 1464 'change select': 'updateHandler', 1465 'change textarea': 'updateHandler' 1466 }, 1467 1468 settings: {}, 1469 1470 initialize: function() { 1471 var settings = this.settings; 1472 1473 this.model = this.model || new Backbone.Model(); 1474 1475 _.each( settings, function( setting, key ) { 1476 if ( setting.name ) 1477 this.model.set( key, getUserSetting( setting.name, setting.fallback ) ); 1478 else 1479 this.model.set( key, this.model.get( key ) || setting.fallback ); 1480 }, this ); 1481 1482 this.model.validate = function( attrs ) { 1483 return _.any( attrs, function( value, key ) { 1484 return ! settings[ key ] || ! _.contains( settings[ key ].accepts, value ); 1485 }); 1486 }; 1487 1488 this.model.on( 'change', function( model, options ) { 1489 if ( ! options.changes ) 1490 return; 1491 1492 _.each( _.keys( options.changes ), function( key ) { 1493 if ( settings[ key ] && settings[ key ].name ) 1494 setUserSetting( settings[ key ].name, model.get( key ) ); 1495 }); 1496 }, this ); 1497 1498 this.model.on( 'change', this.updateChanges, this ); 1499 }, 1500 1501 render: function() { 1502 this.$el.html( this.template( this.model.toJSON() ) ); 1503 1504 // Select the correct values. 1505 _( this.model.attributes ).chain().keys().each( this.update, this ); 1506 return this; 1507 }, 1508 1509 update: function( key ) { 1510 var setting = this.settings[ key ], 1511 $setting = this.$('[data-setting="' + key + '"]'), 1512 $buttons; 1513 1514 if ( ! setting ) 1515 return; 1516 1517 if ( 'select' === setting.type ) { 1518 $setting.find('[value="' + this.model.get( key ) + '"]').attr( 'selected', true ); 1519 } else { 1520 $buttons = $setting.find('button').removeClass('active'); 1521 $buttons.filter( '[value="' + this.model.get( key ) + '"]' ).addClass('active'); 1522 } 1523 }, 1524 1525 updateHandler: function( event ) { 1526 var $setting = $( event.target ).closest('[data-setting]'); 1527 1528 event.preventDefault(); 1529 1530 if ( $setting.length ) 1531 this.model.set( $setting.data('setting'), event.target.value ); 1532 }, 1533 1534 updateChanges: function( model, options ) { 1535 if ( options.changes ) 1536 _( options.changes ).chain().keys().each( this.update, this ); 1537 } 1538 }); 1539 1540 /** 1541 * wp.media.view.Settings.AttachmentDisplay 1542 */ 1543 media.view.Settings.AttachmentDisplay = media.view.Settings.extend({ 1544 className: 'attachment-display-settings', 1545 template: media.template('attachment-display-settings'), 1546 1547 settings: { 1459 1548 align: { 1460 1549 accepts: ['left','center','right','none'], … … 1473 1562 fallback: 'medium' 1474 1563 } 1475 }, 1476 1477 initialize: function() { 1478 var settings = this.settings; 1479 1480 this.model = new Backbone.Model(); 1481 1482 _.each( settings, function( setting, key ) { 1483 this.model.set( key, getUserSetting( setting.name, setting.fallback ) ); 1484 }, this ); 1485 1486 this.model.validate = function( attrs ) { 1487 return _.any( attrs, function( value, key ) { 1488 return ! settings[ key ] || ! _.contains( settings[ key ].accepts, value ); 1489 }); 1490 }; 1491 1492 this.model.on( 'change', function( model, options ) { 1493 if ( ! options.changes ) 1494 return; 1495 1496 _.each( _.keys( options.changes ), function( key ) { 1497 if ( settings[ key ] ) 1498 setUserSetting( settings[ key ].name, model.get( key ) ); 1499 }); 1500 }, this ); 1501 1502 this.model.on( 'change', this.updateChanges, this ); 1503 }, 1504 1505 render: function() { 1506 this.$el.html( this.template( this.model.toJSON() ) ); 1507 1508 // Select the correct values. 1509 _( this.model.attributes ).chain().keys().each( this.update, this ); 1510 return this; 1511 }, 1512 1513 update: function( key ) { 1514 var buttons = this.$('[data-setting="' + key + '"] button').removeClass('active'); 1515 buttons.filter( '[value="' + this.model.get( key ) + '"]' ).addClass('active'); 1516 }, 1517 1518 updateHandler: function( event ) { 1519 var group = $( event.target ).closest('.button-group'); 1520 1521 event.preventDefault(); 1522 1523 if ( group.length ) 1524 this.model.set( group.data('setting'), event.target.value ); 1525 }, 1526 1527 updateChanges: function( model, options ) { 1528 if ( options.changes ) 1529 _( options.changes ).chain().keys().each( this.update, this ); 1530 } 1564 } 1565 }); 1566 1567 /** 1568 * wp.media.view.Settings.Gallery 1569 */ 1570 media.view.Settings.Gallery = media.view.Settings.extend({ 1571 className: 'gallery-settings', 1572 template: media.template('gallery-settings'), 1573 1574 settings: { 1575 columns: { 1576 accepts: _.invoke( _.range( 1, 10 ), 'toString' ), 1577 fallback: 3, 1578 type: 'select' 1579 }, 1580 link: { 1581 accepts: ['post','file'], 1582 fallback: 'post' 1583 } 1584 } 1585 1586 // render: function() { 1587 // this.$el.html( this.template({ 1588 // count: this.options.maxColumns 1589 // }) ); 1590 1591 // this.$('option[value="' + this.options.columns + '"]').attr( 'selected', true ); 1592 // this.$('option[value="' + this.options.linkTo + '"]').addClass('active'); 1593 // } 1531 1594 }); 1532 1595 -
trunk/wp-includes/media.php
r22324 r22340 1435 1435 </script> 1436 1436 1437 <script type="text/html" id="tmpl-gallery-settings"> 1438 <h4><?php _e('Link To'); ?></h4> 1439 <div class="link-to button-group button-large" data-setting="link"> 1440 <button class="button" value="post"> 1441 <?php esc_attr_e('Attachment Page'); ?> 1442 </button> 1443 <button class="button" value="file"> 1444 <?php esc_attr_e('Media File'); ?> 1445 </button> 1446 </div> 1447 1448 <h4><?php _e('Gallery Columns'); ?></h4> 1449 1450 <select class="columns" name="columns" data-setting="columns"> 1451 <% _.times( 9, function( i ) { %> 1452 <option value="<%- i %>"><%- i %></option> 1453 <% }); %> 1454 </select> 1455 </script> 1456 1437 1457 <script type="text/html" id="tmpl-editor-attachment"> 1438 1458 <div class="editor-attachment-preview">
Note: See TracChangeset
for help on using the changeset viewer.