Ticket #25917: customize-controls.diff
| File customize-controls.diff, 8.9 KB (added by , 13 years ago) |
|---|
-
src/wp-admin/js/customize-controls.js
8 8 */ 9 9 api.Setting = api.Value.extend({ 10 10 initialize: function( id, value, options ) { 11 var element;12 13 11 api.Value.prototype.initialize.call( this, value, options ); 14 12 15 13 this.id = id; … … 85 83 ready: function() {}, 86 84 87 85 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 ) { 92 91 if ( typeof to === 'string' && params.statuses && params.statuses[ to ] ) 93 92 statuses.html( params.statuses[ to ] ).show(); 94 93 else 95 94 statuses.hide(); 96 95 }; 97 96 98 var toggleFreeze = false;99 97 100 98 // Support the .dropdown class to open/close complex elements 101 99 this.container.on( 'click keydown', '.dropdown', function( event ) { … … 128 126 picker = this.container.find('.color-picker-hex'); 129 127 130 128 picker.val( control.setting() ).wpColorPicker({ 131 change: function( event, options) {129 change: function( ) { 132 130 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 } 137 135 }); 138 136 } 139 137 }); … … 157 155 158 156 if ( control.params.extensions ) { 159 157 control.uploader.plupload.filters = [{ 160 title: api.l10n.allowedFiles,158 title: api.l10n.allowedFiles, 161 159 extensions: control.params.extensions 162 160 }]; 163 161 } … … 197 195 panels; 198 196 199 197 this.uploader = { 200 init: function( up) {198 init: function( ) { 201 199 var fallback, button; 202 200 203 201 if ( this.supports.dragdrop ) … … 205 203 206 204 // Maintain references while wrapping the fallback button. 207 205 fallback = control.container.find( '.upload-fallback' ); 208 button = fallback.children().detach();206 button = fallback.children().detach(); 209 207 210 208 this.browser.detach().empty().append( button ); 211 209 fallback.append( this.browser ).show(); … … 214 212 215 213 api.UploadControl.prototype.ready.call( this ); 216 214 217 this.thumbnail = this.container.find('.preview-thumbnail img');215 this.thumbnail = this.container.find('.preview-thumbnail img'); 218 216 this.thumbnailSrc = $.proxy( this.thumbnailSrc, this ); 219 217 this.setting.bind( this.thumbnailSrc ); 220 218 … … 222 220 223 221 // Generate tab objects 224 222 this.tabs = {}; 225 panels = this.library.find('.library-content');223 panels = this.library.find('.library-content'); 226 224 227 225 this.library.children('ul').children('li').each( function() { 228 226 var link = $(this), 229 id = link.data('customizeTab'),227 id = link.data('customizeTab'), 230 228 panel = panels.filter('[data-customize-tab="' + id + '"]'); 231 229 232 230 control.tabs[ id ] = { … … 241 239 if ( event.type === 'keydown' && 13 !== event.which ) // enter 242 240 return; 243 241 244 var id = $(this).data('customizeTab'),242 var id = $(this).data('customizeTab'), 245 243 tab = control.tabs[ id ]; 246 244 247 245 event.preventDefault(); … … 319 317 sensitivity: 2000, 320 318 321 319 initialize: function( params, options ) { 322 var deferred = $.Deferred(), 323 self = this; 320 var deferred = $.Deferred(); 324 321 325 322 // This is the promise object. 326 323 deferred.promise( this ); … … 483 480 484 481 /** 485 482 * Requires params: 486 * - container - a selector or jQuery element487 * - previewUrl - the URL of preview frame483 * - container - a selector or jQuery element 484 * - previewUrl - the URL of preview frame 488 485 */ 489 486 initialize: function( params, options ) { 490 487 var self = this, 491 rscheme = /^https?/, 492 url; 488 rscheme = /^https?/; 493 489 494 490 $.extend( this, options || {} ); 495 491 … … 503 499 * debounce the refresh requests: 504 500 * 1. Stop the loading request (as it is instantly outdated). 505 501 * 2. Trigger the new request once refresh hasn't been called for 506 * self.refreshBuffer milliseconds.502 * self.refreshBuffer milliseconds. 507 503 */ 508 504 this.refresh = (function( self ) { 509 505 var refresh = self.refresh, … … 527 523 }; 528 524 })( this ); 529 525 530 this.container = api.ensure( params.container );526 this.container = api.ensure( params.container ); 531 527 this.allowedUrls = params.allowedUrls; 532 this.signature = params.signature;528 this.signature = params.signature; 533 529 534 530 params.url = window.location.href; 535 531 … … 605 601 this.abort(); 606 602 607 603 this.loading = new api.PreviewFrame({ 608 url: this.url(),604 url: this.url(), 609 605 previewUrl: this.previewUrl(), 610 query: this.query() || {},611 container: this.container,612 signature: this.signature606 query: this.query() || {}, 607 container: this.container, 608 signature: this.signature 613 609 }); 614 610 615 611 this.loading.done( function() { … … 662 658 663 659 messenger = new api.Messenger({ 664 660 channel: 'login', 665 url: api.settings.url.login661 url: api.settings.url.login 666 662 }); 667 663 668 664 iframe = $('<iframe src="' + api.settings.url.login + '" />').appendTo( this.container ); … … 689 685 * ===================================================================== */ 690 686 691 687 api.controlConstructor = { 692 color: api.ColorControl,688 color: api.ColorControl, 693 689 upload: api.UploadControl, 694 image: api.ImageControl690 image: api.ImageControl 695 691 }; 696 692 697 693 $( function() { … … 708 704 709 705 var body = $( document.body ), 710 706 overlay = body.children('.wp-full-overlay'), 711 query, previewer, parent;707 previewer, parent, topFocus; 712 708 713 709 // Prevent the form from saving when enter is pressed. 714 710 $('#customize-controls').on( 'keydown', function( e ) { … … 721 717 722 718 // Initialize Previewer 723 719 previewer = new api.Previewer({ 724 container: '#customize-preview',725 form: '#customize-controls',720 container: '#customize-preview', 721 form: '#customize-controls', 726 722 previewUrl: api.settings.url.preview, 727 723 allowedUrls: api.settings.url.allowed, 728 signature: 'WP_CUSTOMIZER_SIGNATURE'724 signature: 'WP_CUSTOMIZER_SIGNATURE' 729 725 }, { 730 726 731 727 nonce: api.settings.nonce, … … 733 729 query: function() { 734 730 return { 735 731 wp_customize: 'on', 736 theme: api.settings.theme.stylesheet,732 theme: api.settings.theme.stylesheet, 737 733 customized: JSON.stringify( api.get() ), 738 nonce: this.nonce.preview734 nonce: this.nonce.preview 739 735 }; 740 736 }, 741 737 … … 743 739 var self = this, 744 740 query = $.extend( this.query(), { 745 741 action: 'customize_save', 746 nonce: this.nonce.save742 nonce: this.nonce.save 747 743 }), 748 744 request = $.post( api.settings.url.ajax, query ); 749 745 … … 778 774 }); 779 775 780 776 // 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 }); 784 780 785 781 $.each( api.settings.settings, function( id, data ) { 786 782 api.create( id, id, data.value, { … … 920 916 $.each({ 921 917 'background_image': { 922 918 controls: [ 'background_repeat', 'background_position_x', 'background_attachment' ], 923 callback: function( to ) { return !! to }919 callback: function( to ) { return !! to; } 924 920 }, 925 921 'show_on_front': { 926 922 controls: [ 'page_on_front', 'page_for_posts' ], 927 callback: function( to ) { return 'page' === to }923 callback: function( to ) { return 'page' === to; } 928 924 }, 929 925 'header_textcolor': { 930 926 controls: [ 'header_textcolor' ], 931 callback: function( to ) { return 'blank' !== to }927 callback: function( to ) { return 'blank' !== to; } 932 928 } 933 929 }, function( settingId, o ) { 934 930 api( settingId, function( setting ) { … … 973 969 control.settings.data.set( false ); 974 970 }); 975 971 976 control.library.on( 'click', 'a', function( event) {972 control.library.on( 'click', 'a', function( ) { 977 973 control.settings.data.set( $(this).data('customizeHeaderImageData') ); 978 974 }); 979 975 … … 984 980 985 981 data = { 986 982 attachment_id: attachment.get('id'), 987 url: attachment.get('url'),983 url: attachment.get('url'), 988 984 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') 991 987 }; 992 988 993 989 attachment.element.data( 'customizeHeaderImageData', data ); … … 998 994 api.trigger( 'ready' ); 999 995 1000 996 // Make sure left column gets focus 1001 vartopFocus = $('.back');997 topFocus = $('.back'); 1002 998 topFocus.focus(); 1003 999 setTimeout(function () { 1004 1000 topFocus.focus();
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)