Make WordPress Core

Ticket #25917: customize-controls.diff

File customize-controls.diff, 8.9 KB (added by jorbin, 13 years ago)
  • src/wp-admin/js/customize-controls.js

     
    88         */
    99        api.Setting = api.Value.extend({
    1010                initialize: function( id, value, options ) {
    11                         var element;
    12 
    1311                        api.Value.prototype.initialize.call( this, value, options );
    1412
    1513                        this.id = id;
    … …  
    8583                ready: function() {},
    8684
    8785                dropdownInit: function() {
    88                         var control  = this,
    89                                 statuses = this.container.find('.dropdown-status'),
    90                                 params   = this.params,
    91                                 update   = function( to ) {
     86                        var control      = this,
     87                                statuses     = this.container.find('.dropdown-status'),
     88                                params       = this.params,
     89                                toggleFreeze = false,
     90                                update       = function( to ) {
    9291                                        if ( typeof     to === 'string' && params.statuses && params.statuses[ to ] )
    9392                                                statuses.html( params.statuses[ to ] ).show();
    9493                                        else
    9594                                                statuses.hide();
    9695                                };
    9796
    98                         var toggleFreeze = false;
    9997
    10098                        // Support the .dropdown class to open/close complex elements
    10199                        this.container.on( 'click keydown', '.dropdown', function( event ) {
    … …  
    128126                                picker = this.container.find('.color-picker-hex');
    129127
    130128                        picker.val( control.setting() ).wpColorPicker({
    131                                 change: function( event, options ) {
     129                                change: function( ) {
    132130                                        control.setting.set( picker.wpColorPicker('color') );
    133                                 },
    134                                 clear: function() {
    135                                         control.setting.set( false );
    136                                 }
     131                                },
     132                                clear: function() {
     133                                        control.setting.set( false );
     134                                }
    137135                        });
    138136                }
    139137        });
    … …  
    157155
    158156                        if ( control.params.extensions ) {
    159157                                control.uploader.plupload.filters = [{
    160                                         title:      api.l10n.allowedFiles,
     158                                        title:          api.l10n.allowedFiles,
    161159                                        extensions: control.params.extensions
    162160                                }];
    163161                        }
    … …  
    197195                                panels;
    198196
    199197                        this.uploader = {
    200                                 init: function( up ) {
     198                                init: function( ) {
    201199                                        var fallback, button;
    202200
    203201                                        if ( this.supports.dragdrop )
    … …  
    205203
    206204                                        // Maintain references while wrapping the fallback button.
    207205                                        fallback = control.container.find( '.upload-fallback' );
    208                                         button  = fallback.children().detach();
     206                                        button  = fallback.children().detach();
    209207
    210208                                        this.browser.detach().empty().append( button );
    211209                                        fallback.append( this.browser ).show();
    … …  
    214212
    215213                        api.UploadControl.prototype.ready.call( this );
    216214
    217                         this.thumbnail    = this.container.find('.preview-thumbnail img');
     215                        this.thumbnail    = this.container.find('.preview-thumbnail img');
    218216                        this.thumbnailSrc = $.proxy( this.thumbnailSrc, this );
    219217                        this.setting.bind( this.thumbnailSrc );
    220218
    … …  
    222220
    223221                        // Generate tab objects
    224222                        this.tabs = {};
    225                         panels    = this.library.find('.library-content');
     223                        panels    = this.library.find('.library-content');
    226224
    227225                        this.library.children('ul').children('li').each( function() {
    228226                                var link  = $(this),
    229                                         id    = link.data('customizeTab'),
     227                                        id        = link.data('customizeTab'),
    230228                                        panel = panels.filter('[data-customize-tab="' + id + '"]');
    231229
    232230                                control.tabs[ id ] = {
    … …  
    241239                                if ( event.type === 'keydown' &&  13 !== event.which ) // enter
    242240                                        return;
    243241
    244                                 var id  = $(this).data('customizeTab'),
     242                                var id  = $(this).data('customizeTab'),
    245243                                        tab = control.tabs[ id ];
    246244
    247245                                event.preventDefault();
    … …  
    319317                sensitivity: 2000,
    320318
    321319                initialize: function( params, options ) {
    322                         var deferred = $.Deferred(),
    323                                 self     = this;
     320                        var deferred = $.Deferred();
    324321
    325322                        // This is the promise object.
    326323                        deferred.promise( this );
    … …  
    483480
    484481                /**
    485482                 * Requires params:
    486                  *  - container  - a selector or jQuery element
    487                  *  - previewUrl - the URL of preview frame
     483                 *      - container  - a selector or jQuery element
     484                 *      - previewUrl - the URL of preview frame
    488485                 */
    489486                initialize: function( params, options ) {
    490487                        var self = this,
    491                                 rscheme = /^https?/,
    492                                 url;
     488                                rscheme = /^https?/;
    493489
    494490                        $.extend( this, options || {} );
    495491
    … …  
    503499                         * debounce the refresh requests:
    504500                         * 1. Stop the loading request (as it is instantly outdated).
    505501                         * 2. Trigger the new request once refresh hasn't been called for
    506                          *    self.refreshBuffer milliseconds.
     502                         *        self.refreshBuffer milliseconds.
    507503                         */
    508504                        this.refresh = (function( self ) {
    509505                                var refresh  = self.refresh,
    … …  
    527523                                };
    528524                        })( this );
    529525
    530                         this.container  = api.ensure( params.container );
     526                        this.container  = api.ensure( params.container );
    531527                        this.allowedUrls = params.allowedUrls;
    532                         this.signature  = params.signature;
     528                        this.signature  = params.signature;
    533529
    534530                        params.url = window.location.href;
    535531
    … …  
    605601                        this.abort();
    606602
    607603                        this.loading = new api.PreviewFrame({
    608                                 url:        this.url(),
     604                                url:            this.url(),
    609605                                previewUrl: this.previewUrl(),
    610                                 query:      this.query() || {},
    611                                 container:  this.container,
    612                                 signature:  this.signature
     606                                query:          this.query() || {},
     607                                container:      this.container,
     608                                signature:      this.signature
    613609                        });
    614610
    615611                        this.loading.done( function() {
    … …  
    662658
    663659                        messenger = new api.Messenger({
    664660                                channel: 'login',
    665                                 url:    api.settings.url.login
     661                                url:    api.settings.url.login
    666662                        });
    667663
    668664                        iframe = $('<iframe src="' + api.settings.url.login + '" />').appendTo( this.container );
    … …  
    689685         * ===================================================================== */
    690686
    691687        api.controlConstructor = {
    692                 color:  api.ColorControl,
     688                color:  api.ColorControl,
    693689                upload: api.UploadControl,
    694                 image:  api.ImageControl
     690                image:  api.ImageControl
    695691        };
    696692
    697693        $( function() {
    … …  
    708704
    709705                var body = $( document.body ),
    710706                        overlay = body.children('.wp-full-overlay'),
    711                         query, previewer, parent;
     707                        previewer, parent, topFocus;
    712708
    713709                // Prevent the form from saving when enter is pressed.
    714710                $('#customize-controls').on( 'keydown', function( e ) {
    … …  
    721717
    722718                // Initialize Previewer
    723719                previewer = new api.Previewer({
    724                         container:  '#customize-preview',
    725                         form:        '#customize-controls',
     720                        container:      '#customize-preview',
     721                        form:            '#customize-controls',
    726722                        previewUrl:  api.settings.url.preview,
    727723                        allowedUrls: api.settings.url.allowed,
    728                         signature:  'WP_CUSTOMIZER_SIGNATURE'
     724                        signature:      'WP_CUSTOMIZER_SIGNATURE'
    729725                }, {
    730726
    731727                        nonce: api.settings.nonce,
    … …  
    733729                        query: function() {
    734730                                return {
    735731                                        wp_customize: 'on',
    736                                         theme:        api.settings.theme.stylesheet,
     732                                        theme:            api.settings.theme.stylesheet,
    737733                                        customized:   JSON.stringify( api.get() ),
    738                                         nonce:        this.nonce.preview
     734                                        nonce:            this.nonce.preview
    739735                                };
    740736                        },
    741737
    … …  
    743739                                var self  = this,
    744740                                        query = $.extend( this.query(), {
    745741                                                action: 'customize_save',
    746                                                 nonce:  this.nonce.save
     742                                                nonce:  this.nonce.save
    747743                                        }),
    748744                                        request = $.post( api.settings.url.ajax, query );
    749745
    … …  
    778774                });
    779775
    780776                // Refresh the nonces if the preview sends updated nonces over.
    781                 previewer.bind( 'nonce', function( nonce ) {
    782                         $.extend( this.nonce, nonce );
    783                 });
     777                previewer.bind( 'nonce', function( nonce ) {
     778                        $.extend( this.nonce, nonce );
     779                });
    784780
    785781                $.each( api.settings.settings, function( id, data ) {
    786782                        api.create( id, id, data.value, {
    … …  
    920916                $.each({
    921917                        'background_image': {
    922918                                controls: [ 'background_repeat', 'background_position_x', 'background_attachment' ],
    923                                 callback: function( to ) { return !! to }
     919                                callback: function( to ) { return !! to; }
    924920                        },
    925921                        'show_on_front': {
    926922                                controls: [ 'page_on_front', 'page_for_posts' ],
    927                                 callback: function( to ) { return 'page' === to }
     923                                callback: function( to ) { return 'page' === to; }
    928924                        },
    929925                        'header_textcolor': {
    930926                                controls: [ 'header_textcolor' ],
    931                                 callback: function( to ) { return 'blank' !== to }
     927                                callback: function( to ) { return 'blank' !== to; }
    932928                        }
    933929                }, function( settingId, o ) {
    934930                        api( settingId, function( setting ) {
    … …  
    973969                                        control.settings.data.set( false );
    974970                        });
    975971
    976                         control.library.on( 'click', 'a', function( event ) {
     972                        control.library.on( 'click', 'a', function( ) {
    977973                                control.settings.data.set( $(this).data('customizeHeaderImageData') );
    978974                        });
    979975
    … …  
    984980
    985981                                data = {
    986982                                        attachment_id: attachment.get('id'),
    987                                         url:           attachment.get('url'),
     983                                        url:               attachment.get('url'),
    988984                                        thumbnail_url: attachment.get('url'),
    989                                         height:        attachment.get('height'),
    990                                         width:         attachment.get('width')
     985                                        height:            attachment.get('height'),
     986                                        width:             attachment.get('width')
    991987                                };
    992988
    993989                                attachment.element.data( 'customizeHeaderImageData', data );
    … …  
    998994                api.trigger( 'ready' );
    999995
    1000996                // Make sure left column gets focus
    1001                 var topFocus = $('.back');
     997                topFocus = $('.back');
    1002998                topFocus.focus();
    1003999                setTimeout(function () {
    10041000                        topFocus.focus();