Changeset 27540
- Timestamp:
- 03/14/2014 07:15:04 PM (10 years ago)
- Location:
- trunk/src/wp-admin/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-controls.js
r27498 r27540 953 953 action: 'customize_save', 954 954 nonce: this.nonce.save 955 }), 956 request = $.post( api.settings.url.ajax, query ); 957 958 api.trigger( 'save', request ); 959 960 body.addClass('saving'); 961 962 request.always( function() { 963 body.removeClass('saving'); 964 }); 965 966 request.done( function( response ) { 967 // Check if the user is logged out. 968 if ( '0' === response ) { 969 self.preview.iframe.hide(); 970 self.login().done( function() { 971 self.save(); 972 self.preview.iframe.show(); 973 }); 974 return; 975 } 976 977 // Check for cheaters. 978 if ( '-1' === response ) { 979 self.cheatin(); 980 return; 981 } 982 983 api.trigger( 'saved' ); 984 }); 955 } ), 956 processing = api.state( 'processing' ), 957 submitWhenDoneProcessing, 958 submit; 959 960 body.addClass( 'saving' ); 961 962 submit = function () { 963 var request = $.post( api.settings.url.ajax, query ); 964 965 api.trigger( 'save', request ); 966 967 request.always( function () { 968 body.removeClass( 'saving' ); 969 } ); 970 971 request.done( function( response ) { 972 // Check if the user is logged out. 973 if ( '0' === response ) { 974 self.preview.iframe.hide(); 975 self.login().done( function() { 976 self.save(); 977 self.preview.iframe.show(); 978 } ); 979 return; 980 } 981 982 // Check for cheaters. 983 if ( '-1' === response ) { 984 self.cheatin(); 985 return; 986 } 987 988 api.trigger( 'saved' ); 989 } ); 990 }; 991 992 if ( 0 === processing() ) { 993 submit(); 994 } else { 995 submitWhenDoneProcessing = function () { 996 if ( 0 === processing() ) { 997 api.state.unbind( 'change', submitWhenDoneProcessing ); 998 submit(); 999 } 1000 }; 1001 api.state.bind( 'change', submitWhenDoneProcessing ); 1002 } 1003 985 1004 } 986 1005 }); … … 1017 1036 (function() { 1018 1037 var state = new api.Values(), 1019 saved = state.create('saved'), 1020 activated = state.create('activated'); 1038 saved = state.create( 'saved' ), 1039 activated = state.create( 'activated' ), 1040 processing = state.create( 'processing' ); 1021 1041 1022 1042 state.bind( 'change', function() { … … 1041 1061 saved( true ); 1042 1062 activated( api.settings.theme.active ); 1063 processing( 0 ); 1043 1064 1044 1065 api.bind( 'change', function() { -
trunk/src/wp-admin/js/customize-widgets.js
r27524 r27540 915 915 widget_content, 916 916 save_btn, 917 trigger_save;917 update_widget_debounced; 918 918 919 919 widget_content = control.container.find( '.widget-content' ); … … 929 929 } ); 930 930 931 trigger_save= _.debounce( function () {931 update_widget_debounced = _.debounce( function () { 932 932 // @todo For compatibility with other plugins, should we trigger a click event? What about form submit event? 933 933 control.updateWidget(); … … 944 944 // Handle widgets that support live previews 945 945 widget_content.on( 'change input propertychange', ':input', function ( e ) { 946 if ( e.type === 'change' || ( this.checkValidity && this.checkValidity() ) ) { 947 trigger_save(); 946 if ( e.type === 'change' ) { 947 control.updateWidget(); 948 } else if ( this.checkValidity && this.checkValidity() ) { 949 update_widget_debounced(); 948 950 } 949 951 } ); … … 1098 1100 active_input_selection_start = null, 1099 1101 active_input_selection_end = null, 1100 params = {},1102 params, 1101 1103 data, 1102 1104 inputs, 1105 processing, 1103 1106 jqxhr; 1104 1107 … … 1130 1133 control.container.addClass( 'widget-form-loading' ); 1131 1134 control.container.addClass( 'previewer-loading' ); 1135 processing = wp.customize.state( 'processing' ); 1136 processing( processing() + 1 ); 1132 1137 1133 1138 params = {}; … … 1253 1258 $( this ).removeData( 'state' + update_number ); 1254 1259 } ); 1260 1261 processing( processing() - 1 ); 1255 1262 } ); 1256 1263 },
Note: See TracChangeset
for help on using the changeset viewer.