| 1507 | | nodes = control.container.find('[data-customize-setting-link]'); |
| 1508 | | radios = {}; |
| 1509 | | |
| 1510 | | nodes.each( function() { |
| 1511 | | var node = $( this ), |
| 1512 | | name; |
| 1513 | | |
| 1514 | | if ( node.is( ':radio' ) ) { |
| 1515 | | name = node.prop( 'name' ); |
| 1516 | | if ( radios[ name ] ) { |
| 1517 | | return; |
| 1518 | | } |
| 1519 | | |
| 1520 | | radios[ name ] = true; |
| 1521 | | node = nodes.filter( '[name="' + name + '"]' ); |
| 1522 | | } |
| 1523 | | |
| 1524 | | api( node.data( 'customizeSettingLink' ), function( setting ) { |
| 1525 | | var element = new api.Element( node ); |
| 1526 | | control.elements.push( element ); |
| 1527 | | element.sync( setting ); |
| 1528 | | element.set( setting() ); |
| 1529 | | }); |
| 1530 | | }); |
| 1531 | | |
| 1567 | | // Add setting notifications to the control notification. |
| 1568 | | _.each( control.settings, function( setting ) { |
| 1569 | | setting.notifications.bind( 'add', function( settingNotification ) { |
| 1570 | | var controlNotification, code, params; |
| 1571 | | code = setting.id + ':' + settingNotification.code; |
| 1572 | | params = _.extend( |
| 1573 | | {}, |
| 1574 | | settingNotification, |
| 1575 | | { |
| 1576 | | setting: setting.id |
| 1577 | | } |
| 1578 | | ); |
| 1579 | | controlNotification = new api.Notification( code, params ); |
| 1580 | | control.notifications.add( controlNotification.code, controlNotification ); |
| 1581 | | } ); |
| 1582 | | setting.notifications.bind( 'remove', function( settingNotification ) { |
| 1583 | | control.notifications.remove( setting.id + ':' + settingNotification.code ); |
| 1584 | | } ); |
| 1585 | | } ); |
| 1586 | | |
| | 1553 | control._linkElements(); |
| | 1554 | control._linkNotifications(); |
| | 1581 | * Link elements. |
| | 1582 | * |
| | 1583 | * @private |
| | 1584 | */ |
| | 1585 | _linkElements: function() { |
| | 1586 | var control = this, nodes, radios; |
| | 1587 | |
| | 1588 | nodes = control.container.find('[data-customize-setting-link]'); |
| | 1589 | radios = {}; |
| | 1590 | |
| | 1591 | nodes.each( function() { |
| | 1592 | var node = $( this ), |
| | 1593 | name; |
| | 1594 | |
| | 1595 | if ( node.is( ':radio' ) ) { |
| | 1596 | name = node.prop( 'name' ); |
| | 1597 | if ( radios[ name ] ) { |
| | 1598 | return; |
| | 1599 | } |
| | 1600 | |
| | 1601 | radios[ name ] = true; |
| | 1602 | node = nodes.filter( '[name="' + name + '"]' ); |
| | 1603 | } |
| | 1604 | |
| | 1605 | api( node.data( 'customizeSettingLink' ), function( setting ) { |
| | 1606 | var element = new api.Element( node ); |
| | 1607 | control.elements.push( element ); |
| | 1608 | element.sync( setting ); |
| | 1609 | element.set( setting() ); |
| | 1610 | }); |
| | 1611 | }); |
| | 1612 | }, |
| | 1613 | |
| | 1614 | /** |
| | 1615 | * Add setting notifications to the control notification. |
| | 1616 | * |
| | 1617 | * @private |
| | 1618 | */ |
| | 1619 | _linkNotifications: function() { |
| | 1620 | var control = this; |
| | 1621 | |
| | 1622 | _.each( control.settings, function( setting ) { |
| | 1623 | setting.notifications.bind( 'add', function( settingNotification ) { |
| | 1624 | var controlNotification, code, params; |
| | 1625 | code = setting.id + ':' + settingNotification.code; |
| | 1626 | params = _.extend( |
| | 1627 | {}, |
| | 1628 | settingNotification, |
| | 1629 | { |
| | 1630 | setting: setting.id |
| | 1631 | } |
| | 1632 | ); |
| | 1633 | controlNotification = new api.Notification( code, params ); |
| | 1634 | control.notifications.add( controlNotification.code, controlNotification ); |
| | 1635 | } ); |
| | 1636 | setting.notifications.bind( 'remove', function( settingNotification ) { |
| | 1637 | control.notifications.remove( setting.id + ':' + settingNotification.code ); |
| | 1638 | } ); |
| | 1639 | } ); |
| | 1640 | }, |
| | 1641 | |
| | 1642 | /** |