Ticket #10021: widgets.diff
File widgets.diff, 28.6 KB (added by , 16 years ago) |
---|
-
wp-includes/default-widgets.php
873 873 874 874 if ( !empty($error) ) 875 875 echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>'; 876 876 877 global $wp_widget_control_number; 878 if ( !empty($wp_widget_control_number) ) { 879 $widget_title_id = 'widget-' . $wp_widget_control_number . '_rss-' . $number . '-title'; 880 } else { 881 $widget_title_id = 'rss-title-' . $number; 882 } 883 877 884 if ( $inputs['url'] ) : 878 885 ?> 879 886 <p><label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?></label> 880 887 <input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" /></p> 881 888 <?php endif; if ( $inputs['title'] ) : ?> 882 <p><label for=" rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?></label>883 <input class="widefat" id=" rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p>889 <p><label for="<?php echo $widget_title_id; ?>"><?php _e('Give the feed a title (optional):'); ?></label> 890 <input class="widefat" id="<?php echo $widget_title_id; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p> 884 891 <?php endif; if ( $inputs['items'] ) : ?> 885 892 <p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label> 886 893 <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]"> -
wp-includes/widgets.php
119 119 * @return string ID attribute for $field_name 120 120 */ 121 121 function get_field_id($field_name) { 122 return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name; 122 global $wp_widget_control_number; 123 if ( !empty($wp_widget_control_number) ) { 124 return 'widget-' . $wp_widget_control_number . '_' . $this->id_base . '-' . $this->number . '-' . $field_name; 125 } else { 126 return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name; 127 } 123 128 } 124 129 125 130 // Private Functions. Don't worry about these. -
wp-admin/includes/widgets.php
76 76 */ 77 77 function wp_list_widget_controls_dynamic_sidebar( $params ) { 78 78 global $wp_registered_widgets; 79 static $i = 0; 80 $i++; 79 global $wp_widget_control_number; 80 if ( empty($wp_widget_control_number) ) 81 $wp_widget_control_number = 0; 82 $wp_widget_control_number++; 81 83 82 84 $widget_id = $params[0]['widget_id']; 83 85 $id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id; 84 86 $hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : ''; 85 87 86 $params[0]['before_widget'] = "<div id='widget-${ i}_$id' class='widget'$hidden>";88 $params[0]['before_widget'] = "<div id='widget-${wp_widget_control_number}_$id' class='widget'$hidden>"; 87 89 $params[0]['after_widget'] = "</div>"; 88 90 $params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated 89 91 $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated -
wp-admin/js/common.dev.js
2 2 (function($){ 3 3 // sidebar admin menu 4 4 adminMenu = { 5 6 5 init : function() { 7 $('#adminmenu div.wp-menu-toggle').each( function() { 8 if ( $(this).siblings('.wp-submenu').length ) 9 $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); }); 6 $('.wp-menu-toggle', '#adminmenu') 7 .each( function() { 8 var t = $(this); 9 if ( t.siblings('.wp-submenu').length ) 10 t.click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); }); 10 11 else 11 $(this).hide();12 t.hide(); 12 13 }); 13 14 //$.log('wp-menu-toggle'); 15 14 16 this.favorites(); 15 16 $('a.separator').click(function(){ 17 //$.log('favorites'); 18 19 $('.separator', '#adminmenu') 20 .click(function(){ 17 21 if ( $('body').hasClass('folded') ) { 18 22 adminMenu.fold(1); 19 23 deleteUserSetting( 'mfold' ); … … 23 27 } 24 28 return false; 25 29 }); 26 30 //$.log('admin menu - separator'); 31 27 32 if ( $('body').hasClass('folded') ) { 28 33 this.fold(); 29 34 } 35 //$.log('admin menu - fold'); 36 30 37 this.restoreMenuState(); 38 //$.log('admin menu - restore state'); 31 39 }, 32 40 33 41 restoreMenuState : function() { 34 $('#adminmenu li.wp-has-submenu').each(function(i, e) { 42 $('.wp-has-submenu', '#adminmenu') 43 .each(function(i, e) { 35 44 var v = getUserSetting( 'm'+i ); 36 if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open 45 if ( $(e).hasClass('wp-has-current-submenu') ) 46 return true; // leave the current parent open 37 47 38 if ( 'o' == v ) $(e).addClass('wp-menu-open'); 39 else if ( 'c' == v ) $(e).removeClass('wp-menu-open'); 48 if ( 'o' == v ) 49 $(e).addClass('wp-menu-open'); 50 else if ( 'c' == v ) 51 $(e).removeClass('wp-menu-open'); 40 52 }); 41 53 }, 42 54 43 55 toggle : function(el) { 56 el['slideToggle'](150, function() { 57 el.css('display',''); 58 }).parent().toggleClass( 'wp-menu-open' ); 44 59 45 el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' ); 46 47 $('#adminmenu li.wp-has-submenu').each(function(i, e) { 60 $('.wp-has-submenu', '#adminmenu') 61 .each(function(i, e) { 48 62 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c'; 49 63 setUserSetting( 'm'+i, v ); 50 64 }); … … 55 69 fold : function(off) { 56 70 if (off) { 57 71 $('body').removeClass('folded'); 58 $(' #adminmenu li.wp-has-submenu').unbind();72 $('li.wp-has-submenu', '#adminmenu').unbind(); 59 73 } else { 60 74 $('body').addClass('folded'); 61 $('#adminmenu li.wp-has-submenu').hoverIntent({ 62 over: function(e){ 75 $('li.wp-has-submenu', '#adminmenu') 76 .hoverIntent({ 77 over: function(e) { 63 78 var m, b, h, o, f; 64 m = $( this).find('.wp-submenu');79 m = $('.wp-submenu', this); 65 80 b = m.parent().offset().top + m.height() + 1; // Bottom offset of the menu 66 81 h = $('#wpwrap').height(); // Height of the entire page 67 82 o = 60 + b - h; … … 76 91 } 77 92 m.addClass('sub-open'); 78 93 }, 79 out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); }, 94 out: function() { 95 $('.wp-submenu', this).removeClass('sub-open').css({'marginTop':''}); 96 }, 80 97 timeout: 220, 81 98 sensitivity: 8, 82 99 interval: 100 83 100 }); 84 85 101 } 86 102 }, 87 103 88 104 favorites : function() { 89 $('#favorite-inside').width($('#favorite-actions').width()-4); 90 $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } ); 91 92 $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } ); 105 $('#favorite-inside').width($('#favorite-actions').width() - 4); 106 107 $('#favorite-toggle, #favorite-inside') 108 .bind('mouseenter', function() { 109 $('#favorite-inside').removeClass('slideUp').addClass('slideDown'); 110 setTimeout(function() { 111 if ( $('#favorite-inside').hasClass('slideDown') ) { 112 $('#favorite-inside').slideDown(100); 113 $('#favorite-first').addClass('slide-down'); 114 } 115 }, 200); 116 }).bind('mouseleave', function() { 117 $('#favorite-inside').removeClass('slideDown').addClass('slideUp'); 118 setTimeout(function() { 119 if ( $('#favorite-inside').hasClass('slideUp') ) { 120 $('#favorite-inside').slideUp(100, function() { 121 $('#favorite-first').removeClass('slide-down'); 122 }); 123 } 124 }, 300); 125 }); 93 126 } 94 127 }; 95 128 96 $(document).ready(function(){adminMenu.init();}); 129 $(document).ready(function(){ 130 //$.log('common.js - start'); 131 adminMenu.init(); 132 }); 97 133 98 134 // show/hide/save table columns 99 135 columns = { 100 136 init : function() { 101 $('.hide-column-tog').click( function() { 137 $('.hide-column-tog', '#adv-settings') 138 .click( function() { 102 139 var column = $(this).val(), show = $(this).attr('checked'); 103 140 if ( show ) { 104 141 $('.column-' + column).show(); … … 106 143 $('.column-' + column).hide(); 107 144 } 108 145 columns.save_manage_columns_state(); 109 } ); 146 }); 147 //$.log('table columns init'); 110 148 }, 111 149 112 150 save_manage_columns_state : function() { 113 var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); 151 var hidden = $('.manage-column').filter(':hidden') 152 .map(function() { return this.id; }) 153 .get().join(','); 114 154 $.post(ajaxurl, { 115 155 action: 'hidden-columns', 116 156 hidden: hidden, … … 120 160 } 121 161 } 122 162 123 $(document).ready(function(){columns.init();}); 124 163 $(document).ready(function(){ 164 columns.init(); 165 }); 125 166 })(jQuery); 126 167 127 168 // stub for doing better warnings … … 144 185 var lastClicked = false, checks, first, last, checked; 145 186 146 187 // pulse 147 $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); 188 $('div.fade').animate( { backgroundColor: '#ffffe0' }, 300) 189 .animate( { backgroundColor: '#fffbcc' }, 300) 190 .animate( { backgroundColor: '#ffffe0' }, 300) 191 .animate( { backgroundColor: '#fffbcc' }, 300); 192 //$.log('fade'); 148 193 149 194 // Move .updated and .error alert boxes 150 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 151 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); 195 $('div.wrap').children('h2:first').nextAll('div.updated, div.error') 196 .addClass('below-h2'); 197 //$.log('lock div.updated, div.error') 152 198 199 $('div.updated, div.error').not('.below-h2') 200 .insertAfter($('div.wrap').children('h2:first')); 201 //$.log('move div.updated, div.error'); 202 153 203 // show warnings 154 $('#doaction, #doaction2').click(function (){204 $('#doaction, #doaction2').click(function () { 155 205 if ( $('select[name="action"]').val() == 'delete' || $('select[name="action2"]').val() == 'delete' ) { 156 206 return showNotice.warn(); 157 207 } 158 208 }); 209 //$.log('doaction') 159 210 160 211 // screen settings tab 161 $('#show-settings-link').click(function () { 212 $('#show-settings-link') 213 .click(function () { 162 214 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) { 163 215 $('#contextual-help-link-wrap').css('visibility', 'hidden'); 164 216 } 165 $('#screen-options-wrap').slideToggle('fast', function(){ 217 218 $('#screen-options-wrap') 219 .slideToggle('fast', function(){ 166 220 if ( $(this).hasClass('screen-options-open') ) { 167 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); 221 $('#show-settings-link') 222 .css({'backgroundImage':'url("images/screen-options-right.gif")'}); 223 168 224 $('#contextual-help-link-wrap').css('visibility', ''); 169 225 $(this).removeClass('screen-options-open'); 170 226 } else { 171 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 227 $('#show-settings-link') 228 .css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 229 172 230 $(this).addClass('screen-options-open'); 173 231 } 174 232 }); 175 233 return false; 176 234 }); 177 235 //$.log('show-settings-link') 236 178 237 // help tab 179 $('#contextual-help-link').click(function () { 238 $('#contextual-help-link') 239 .click(function () { 180 240 if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) { 181 241 $('#screen-options-link-wrap').css('visibility', 'hidden'); 182 242 } 183 $('#contextual-help-wrap').slideToggle('fast', function(){ 243 244 $('#contextual-help-wrap') 245 .slideToggle('fast', function() { 184 246 if ( $(this).hasClass('contextual-help-open') ) { 185 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); 247 $('#contextual-help-link') 248 .css({'backgroundImage':'url("images/screen-options-right.gif")'}); 249 186 250 $('#screen-options-link-wrap').css('visibility', ''); 187 251 $(this).removeClass('contextual-help-open'); 188 252 } else { 189 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 253 $('#contextual-help-link') 254 .css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 255 190 256 $(this).addClass('contextual-help-open'); 191 257 } 192 258 }); 193 259 return false; 194 260 }); 195 $('#contextual-help-link-wrap, #screen-options-link-wrap').show(); 261 //$.log('contextual-help-link'); 262 263 // this one is already taken care of by the hide-if-no-js class 264 // show() and :hidden are extremely slow on slow rendering engines 265 // e.g. Opera 9 with a 400kb widgets page gets: 266 // 6ms -- $('#contextual-help-link-wrap') 267 // 6071ms -- $('#contextual-help-link-wrap:hidden') 268 // $('#contextual-help-link-wrap, #screen-options-link-wrap').show(); 196 269 197 270 // check all checkboxes 198 $( 'table:visible tbody .check-column :checkbox' ).click( function(e) { 271 $('tbody').children().children('.check-column').find(':checkbox') 272 .click( function(e) { 199 273 if ( 'undefined' == e.shiftKey ) { return true; } 200 274 if ( e.shiftKey ) { 201 275 if ( !lastClicked ) { return true; } 202 checks = $( lastClicked ). parents( 'form:first' ).find( ':checkbox' );276 checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ); 203 277 first = checks.index( lastClicked ); 204 278 last = checks.index( this ); 205 279 checked = $(this).attr('checked'); 206 280 if ( 0 < first && 0 < last && first != last ) { 207 281 checks.slice( first, last ).attr( 'checked', function(){ 208 if ( $(this). parents('tr').is(':visible') )282 if ( $(this).closest('tr').is(':visible') ) 209 283 return checked ? 'checked' : ''; 210 284 211 285 return ''; … … 214 288 } 215 289 lastClicked = this; 216 290 return true; 217 } ); 218 $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) { 219 var c = $(this).attr('checked'), kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, toggle = e.shiftKey || kbtoggle; 220 221 222 $(this).parents( 'form:first' ).find( 'table tbody:visible' ).find( '.check-column :checkbox' ).attr( 'checked', function() { 223 if ( $(this).parents('tr').is(':hidden') ) 291 }); 292 //$.log('tbody checkboxes'); 293 294 $('thead, tfoot').find(':checkbox').click( function(e) { 295 var c = $(this).attr('checked'), 296 kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, 297 toggle = e.shiftKey || kbtoggle; 298 299 $(this).closest( 'table' ).children( 'tbody' ).filter(':visible') 300 .children().children('.check-column').find(':checkbox') 301 .attr('checked', function() { 302 if ( $(this).closest('tr').is(':hidden') ) 224 303 return ''; 225 304 if ( toggle ) 226 305 return $(this).attr( 'checked' ) ? '' : 'checked'; … … 228 307 return 'checked'; 229 308 return ''; 230 309 }); 231 $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() { 310 311 $(this).closest('table').children('thead, tfoot').filter(':visible') 312 .children().children('.check-column').find(':checkbox') 313 .attr('checked', function() { 232 314 if ( toggle ) 233 315 return ''; 234 316 else if (c) … … 236 318 return ''; 237 319 }); 238 320 }); 321 //$.log('thead, tfoot checkboxes'); 322 239 323 $('#default-password-nag-no').click( function() { 240 324 setUserSetting('default_password_nag', 'hide'); 241 325 $('div.default-password-nag').hide(); 242 326 return false; 243 327 }); 244 245 328 //$.log('password nag'); 246 329 }); 247 330 248 331 jQuery(document).ready( function($){ 249 var turboNag = $(' .turbo-nag');332 var turboNag = $('span.turbo-nag'); 250 333 251 334 if ( !turboNag.length || ('undefined' != typeof(google) && google.gears) ) 252 335 return; … … 263 346 } 264 347 265 348 turboNag.show(); 266 267 }); 349 //$.log('turbo'); 350 //$.log('common.js - stop'); 351 }); 352 No newline at end of file -
wp-admin/js/utils.dev.js
163 163 return {}; 164 164 165 165 return wpCookies.getHash('wp-settings-' + userSettings.uid) || {}; 166 } 166 } 167 No newline at end of file -
wp-admin/js/widgets.dev.js
1 2 1 var wpWidgets; 3 2 (function($) { 4 3 5 4 wpWidgets = { 5 sortables : null, 6 6 7 init : function() { 7 var rem; 8 8 var rem; 9 //wpWidgets.sortables = $('div.widgets-sortables'); 10 9 11 if ( $('body').hasClass('widgets_access') ) { 10 12 return; 11 13 } 12 13 $('#widgets-right div.sidebar-name').click(function(){ 14 var c = $(this).siblings('.widgets-sortables'); 15 if ( c.is(':visible') ) { 14 //$.log('check widgets_access'); 15 16 var availableWidgets = $('#widget-list').children('.widget'); 17 //$.log('availble widgets - find'); 18 19 var droppableSidebar = $('#available-widgets'); 20 //$.log('droppable sidebar - find'); 21 22 var sortableSidebars = $('div.widgets-sortables'); 23 //$.log('sortable sidebars - find'); 24 25 $('#widgets-right').children('.widgets-holder-wrap').children('.sidebar-name') 26 //.log('find widgets-right sidebar name') 27 .click(function(){ 28 var c = $(this).siblings('.widgets-sortables'), p = $(this).parent(); 29 if ( !p.hasClass('closed') ) { 16 30 c.sortable('disable'); 17 $(this).parent().addClass('closed');31 p.addClass('closed'); 18 32 } else { 19 $(this).parent().removeClass('closed');33 p.removeClass('closed'); 20 34 c.sortable('enable').sortable('refresh'); 21 35 } 22 }); 23 24 $('#widgets-left div.sidebar-name').click(function(){ 25 if ( $(this).siblings('.widget-holder').is(':visible') ) { 26 $(this).parent().addClass('closed'); 27 } else { 28 $(this).parent().removeClass('closed'); 29 } 30 }); 31 32 $('#widgets-right .widget, #wp_inactive_widgets .widget').each(function(){ 36 }); 37 //$.log('widgets-right sidebar name'); 38 39 $('#widgets-left').children('.widgets-holder-wrap').children('.sidebar-name') 40 //.log('find widgets-left sidebar name') 41 .click(function() { 42 $(this).siblings('.widget-holder').parent().toggleClass('closed'); 43 }); 44 //$.log('widgets-left sidebar name'); 45 46 sortableSidebars.not('#wp_inactive_widgets') 47 .each(function(){ 48 var h = 50, H = $(this).children('.widget').length; 49 h = h + parseInt(H * 48, 10); 50 $(this).css( 'minHeight', h + 'px' ); 51 }); 52 //$.log('sidebars - resize'); 53 54 sortableSidebars.children('.widget') 55 //.log('widgets - find active widgets') 56 .each(function() { 57 wpWidgets.addEvents(this); 58 }) 59 //.log('widgets - attach events') 60 .each(function() { 33 61 wpWidgets.appendTitle(this); 34 62 }); 35 36 this.addEvents(); 37 $('.widget-error').parents('.widget').find('a.widget-action').click(); 38 39 $('#available-widgets').droppable({ 40 tolerance: 'pointer', 41 accept: function(o){ 42 return $(o).parent().attr('id') != 'widget-list'; 43 }, 44 drop: function(e,ui) { 45 ui.draggable.addClass('deleting'); 46 $('#removing-widget').hide().children('span').html(''); 47 }, 48 over: function(e,ui) { 49 ui.draggable.addClass('deleting'); 50 $('.widget-placeholder').hide(); 51 52 if ( ui.draggable.hasClass('ui-sortable-helper') ) 53 $('#removing-widget').show().children('span').html( ui.draggable.find('.widget-title h4').html() ); 54 }, 55 out: function(e,ui) { 56 ui.draggable.removeClass('deleting'); 57 $('.widget-placeholder').show(); 58 $('#removing-widget').hide().children('span').html(''); 59 } 60 }); 61 62 $('#widget-list .widget').draggable({ 63 connectToSortable: '.widgets-sortables', 64 handle: '.widget-title', 63 //$.log('widgets - set title'); 64 65 availableWidgets.draggable({ 66 connectToSortable: 'div.widgets-sortables', 67 handle: '> .widget-top > .widget-title', 65 68 distance: 2, 66 69 helper: 'clone', 67 70 zIndex: 5, 68 71 containment: 'document', 69 72 start: function(e,ui) { 70 73 wpWidgets.fixWebkit(1); 71 ui.helper.find(' .widget-description').hide();74 ui.helper.find('div.widget-description').hide(); 72 75 }, 73 76 stop: function(e,ui) { 74 77 if ( rem ) … … 77 80 wpWidgets.fixWebkit(); 78 81 } 79 82 }); 80 81 $('.widgets-sortables').sortable({ 83 //$.log('available widgets - make draggable'); 84 85 sortableSidebars.sortable({ 82 86 placeholder: 'widget-placeholder', 83 connectWith: '.widgets-sortables', 84 items: '.widget', 85 handle: '.widget-title', 87 items: '> .widget', 88 handle: '> .widget-top > .widget-title', 86 89 cursor: 'move', 87 90 distance: 2, 88 91 containment: 'document', 89 92 start: function(e,ui) { 90 93 wpWidgets.fixWebkit(1); 91 ui.item. find('.widget-inside').hide();94 ui.item.children('.widget-inside').hide(); 92 95 ui.item.css({'marginLeft':'','width':''}); 93 96 }, 94 97 stop: function(e,ui) { … … 101 104 return; 102 105 } 103 106 104 var add = ui.item.find('input.add_new').val(), n = ui.item.find('input.multi_number').val(), id = ui.item.attr('id'), sb = $(this).attr('id'); 107 var add = ui.item.find('input.add_new').val(), 108 n = ui.item.find('input.multi_number').val(), 109 id = ui.item.attr('id'), 110 sb = $(this).attr('id'); 105 111 106 112 ui.item.css({'marginLeft':'','width':''}); 107 113 wpWidgets.fixWebkit(); … … 127 133 if ( !$(this).is(':visible') ) 128 134 $(this).sortable('cancel'); 129 135 } 130 }).not(':visible').sortable('disable'); 131 wpWidgets.resize(); 132 wpWidgets.fixLabels(); 136 }) 137 //.log('sortable sidebars - enable sortables') 138 .sortable('option', 'connectWith', 'div.widgets-sortables') 139 //.log('sortable sidebars - set connectWith') 140 .parent().filter('.closed').children('.widgets-sortables') 141 //.log('sortable sidebars - find hidden') 142 .sortable('disable'); 143 //$.log('sortable sidebars - disable sortables if hidden'); 144 145 droppableSidebar.droppable({ 146 tolerance: 'pointer', 147 accept: function(o){ 148 return $(o).parent().attr('id') != 'widget-list'; 149 }, 150 drop: function(e,ui) { 151 ui.draggable.addClass('deleting'); 152 $('#removing-widget').hide().children('span').html(''); 153 }, 154 over: function(e,ui) { 155 ui.draggable.addClass('deleting'); 156 $('div.widget-placeholder').hide(); 157 158 if ( ui.draggable.hasClass('ui-sortable-helper') ) 159 $('#removing-widget').show().children('span') 160 .html( ui.draggable.find('div.widget-title').children('h4').html() ); 161 }, 162 out: function(e,ui) { 163 ui.draggable.removeClass('deleting'); 164 $('div.widget-placeholder').show(); 165 $('#removing-widget').hide().children('span').html(''); 166 } 167 }); 168 //$.log('droppable sidebar - enable droppable'); 169 170 $('p.widget-error').closest('div.widget').find('a.widget-action').click(); 171 //$.log('widgets - open if errors'); 133 172 }, 134 173 135 174 saveOrder : function(sb) { 136 if ( sb ) 137 $('#' + sb).parents('.widgets-holder-wrap').find('.ajax-feedback').css('visibility', 'visible'); 175 if ( sb ) { 176 $('#' + sb).closest('div.widgets-holder-wrap').find('img.ajax-feedback') 177 .css('visibility', 'visible'); 178 } 138 179 139 180 var a = { 140 181 action: 'widgets-order', … … 142 183 sidebars: [] 143 184 }; 144 185 145 $(' .widgets-sortables').each( function() {186 $('div.widgets-sortables').each( function() { 146 187 a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(','); 147 188 }); 148 189 149 190 $.post( ajaxurl, a, function() { 150 $(' .ajax-feedback').css('visibility', 'hidden');191 $('img.ajax-feedback').css('visibility', 'hidden'); 151 192 }); 193 152 194 this.resize(); 153 195 }, 154 196 155 197 save : function(widget, del, animate, order) { 156 var sb = widget.parents('.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a; 198 var sb = widget.closest('div.widgets-sortables').attr('id'), 199 data = widget.find('form').serialize(), 200 a; 157 201 widget = $(widget); 158 202 widget.find('.ajax-feedback').css('visibility', 'visible'); 159 203 … … 172 216 var id; 173 217 174 218 if ( del ) { 175 if ( !$('.widget_number', widget).val() ) { 176 id = $('.widget-id', widget).val(); 177 $('#available-widgets .widget-id').each(function(){ 219 if ( !$('input.widget_number', widget).val() ) { 220 id = $('input.widget-id', widget).val(); 221 $('#available-widgets').find('input.widget-id') 222 .each(function(){ 178 223 if ( $(this).val() == id ) 179 $(this). parents('.widget').show();224 $(this).closest('div.widget').show(); 180 225 }); 181 226 } 182 227 … … 193 238 } else { 194 239 $('.ajax-feedback').css('visibility', 'hidden'); 195 240 if ( r && r.length > 2 ) { 196 $(' .widget-content', widget).html(r);241 $('div.widget-content', widget).html(r); 197 242 wpWidgets.appendTitle(widget); 198 243 wpWidgets.fixLabels(widget); 199 244 } … … 204 249 }, 205 250 206 251 appendTitle : function(widget) { 207 $(' input[type="text"]', widget).each(function(){208 var title ;209 if ( this.id.indexOf('title') != -1 ) {210 title = $(this).val().replace(/<[^<>]+>/g, '').replace(/</g, '<').replace(/>/g, '>');211 212 $('.widget-title .in-widget-title', widget).html(': ' + title);213 return false;214 }252 $('#' + widget.id + '-title').each(function() { 253 var title = $(this).val().replace(/<[^<>]+>/g, '') 254 .replace(/</g, '<').replace(/>/g, '>'); 255 256 if ( title ) 257 $(widget).children('.widget-top') 258 .children('.widget-title').children().children('.in-widget-title') 259 .html(': ' + title); 215 260 }); 216 261 }, 217 262 218 263 resize : function() { 219 $('.widgets-sortables').not('#wp_inactive_widgets').each(function(){ 220 var h = 50, H = $('.widget', this).length; 264 $('div.widgets-sortables').not('#wp_inactive_widgets') 265 //.log('find resizables') 266 .each(function(){ 267 var h = 50, H = $(this).children('.widget').length; 221 268 h = h + parseInt(H * 48, 10); 222 269 $(this).css( 'minHeight', h + 'px' ); 223 270 }); … … 231 278 }); 232 279 }, 233 280 234 fixLabels : function(sc) { 235 sc = sc || document; 236 237 $('.widget-inside label', sc).each(function(){ 281 fixLabels : function(widget) { 282 widget.children('.widget-inside').find('label').each(function(){ 238 283 var f = $(this).attr('for'); 239 284 240 285 if ( f && f == $('input', this).attr('id') ) … … 243 288 }, 244 289 245 290 close : function(widget) { 246 widget. find('.widget-inside').slideUp('fast', function(){291 widget.children('.widget-inside').slideUp('fast', function(){ 247 292 widget.css({'width':'','marginLeft':''}); 248 293 }); 249 294 }, 250 295 251 296 addEvents : function(sc) { 252 297 sc = sc || document; 298 253 299 $('a.widget-action', sc).click(function(){ 254 var w = parseInt( $(this).parents('.widget').find('.widget-width').val(), 10 ), css = {}, inside = $(this).parents('.widget-top').siblings('.widget-inside'); 300 var css = {}, 301 widget = $(this).closest('div.widget'), 302 inside = widget.children('.widget-inside'), 303 w = parseInt( widget.find('input.widget-width').val(), 10 ); 304 255 305 if ( inside.is(':hidden') ) { 256 if ( w > 250 && inside. parents('.widgets-sortables').length ) {306 if ( w > 250 && inside.closest('div.widgets-sortables').length ) { 257 307 css['width'] = w + 30 + 'px'; 258 if ( inside. parents('.widget-liquid-right').length )308 if ( inside.closest('div.widget-liquid-right').length ) 259 309 css['marginLeft'] = 235 - w + 'px'; 260 inside.parents('.widget').css(css);310 widget.css(css); 261 311 } 312 wpWidgets.fixLabels(widget); 262 313 inside.slideDown('fast'); 263 314 } else { 264 inside.slideUp('fast', function(){ inside.parents('.widget').css({'width':'','marginLeft':''}); }); 315 inside.slideUp('fast', function() { 316 widget.css({'width':'','marginLeft':''}); 317 }); 265 318 } 266 return false;267 });268 $('.widget-control-save', sc).click(function(){269 wpWidgets.save( $(this).parents('.widget'), 0, 1, 0 );270 319 return false; 271 320 }); 272 $('.widget-control-remove', sc).click(function(){ 273 wpWidgets.save( $(this).parents('.widget'), 1, 1, 0 ); 321 // todo: optimize this further by using a button tag instead 322 $('input.widget-control-save', sc).click(function(){ 323 wpWidgets.save( $(this).closest('div.widget'), 0, 1, 0 ); 274 324 return false; 275 325 }); 276 $(' .widget-control-close', sc).click(function(){277 wpWidgets. close( $(this).parents('.widget'));326 $('a.widget-control-remove', sc).click(function(){ 327 wpWidgets.save( $(this).closest('div.widget'), 1, 1, 0 ); 278 328 return false; 279 329 }); 330 $('a.widget-control-close', sc).click(function(){ 331 wpWidgets.close( $(this).closest('div.widget') ); 332 return false; 333 }); 280 334 } 281 335 }; 282 $(document).ready(function(){wpWidgets.init();}); 336 $(document).ready(function($){ 337 //$.log('widgets.js - start'); 338 wpWidgets.init(); 339 //$.log('widgets.js - done'); 340 }); 283 341 284 })(jQuery); 342 })(jQuery); 343 No newline at end of file