mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-07 09:49:04 +00:00
Append the widget's title to the header, adjust sidebar height after changing widgets, see #9511
git-svn-id: https://develop.svn.wordpress.org/trunk@11246 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+41
-14
@@ -4,16 +4,15 @@ var wpWidgets;
|
||||
|
||||
wpWidgets = {
|
||||
init : function() {
|
||||
var rem, hr = $('#available-widgets .widget-holder').height() - 7, firstsb = $('#widgets-right .widgets-holder-wrap .widgets-sortables:first'), hl = firstsb.height();
|
||||
var rem;
|
||||
|
||||
$('#widgets-right div.sidebar-name').click(function(){
|
||||
var c = $(this).siblings('.widgets-sortables');
|
||||
if ( c.is(':visible') ) {
|
||||
c.hide().sortable('disable');
|
||||
$(this).parent().addClass('closed');
|
||||
} else {
|
||||
c.show().sortable('enable').sortable('refresh');
|
||||
$(this).parent().removeClass('closed');
|
||||
c.sortable('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,8 +24,9 @@ wpWidgets = {
|
||||
}
|
||||
});
|
||||
|
||||
if ( hr > hl )
|
||||
firstsb.css('minHeight', hr + 'px');
|
||||
$('#widgets-right .widget, #wp_inactive_widgets .widget').each(function(){
|
||||
wpWidgets.appendTitle(this);
|
||||
});
|
||||
|
||||
this.addEvents();
|
||||
$('.widget-error').parents('.widget').find('a.widget-action').click();
|
||||
@@ -37,6 +37,7 @@ wpWidgets = {
|
||||
distance: 2,
|
||||
helper: 'clone',
|
||||
zIndex: 5,
|
||||
containment: 'document',
|
||||
start: function(e,ui) {
|
||||
wpWidgets.fixWebkit(1);
|
||||
ui.helper.find('.widget-description').hide();
|
||||
@@ -57,6 +58,7 @@ wpWidgets = {
|
||||
cursor: 'move',
|
||||
distance: 2,
|
||||
opacity: 0.65,
|
||||
containment: 'document',
|
||||
start: function(e,ui) {
|
||||
wpWidgets.fixWebkit(1);
|
||||
ui.item.find('.widget-inside').hide();
|
||||
@@ -65,7 +67,6 @@ wpWidgets = {
|
||||
stop: function(e,ui) {
|
||||
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');
|
||||
ui.item.css({'marginLeft':'','width':''});
|
||||
|
||||
if ( add ) {
|
||||
if ( 'multi' == add ) {
|
||||
ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
|
||||
@@ -82,14 +83,15 @@ wpWidgets = {
|
||||
ui.item.find('a.widget-action').click();
|
||||
}
|
||||
wpWidgets.saveOrder(sb);
|
||||
wpWidgets.resize();
|
||||
wpWidgets.fixWebkit();
|
||||
},
|
||||
receive: function(e,ui) {
|
||||
if ( !$(this).is(':visible') )
|
||||
$(this).sortable('cancel');
|
||||
}
|
||||
|
||||
}).not(':visible').sortable('disable');
|
||||
});
|
||||
wpWidgets.resize();
|
||||
},
|
||||
|
||||
saveOrder : function(sb) {
|
||||
@@ -125,26 +127,51 @@ wpWidgets = {
|
||||
data += '&' + $.param(a);
|
||||
|
||||
$.post( ajaxurl, data, function(r){
|
||||
var id;
|
||||
var id, widget;
|
||||
$('.ajax-feedback').css('visibility', 'hidden');
|
||||
if ( !t )
|
||||
return;
|
||||
|
||||
widget = $(t).parents('.widget');
|
||||
|
||||
if ( del ) {
|
||||
$(t).parents('.widget').slideUp('normal', function(){ $(this).remove(); });
|
||||
if ( !a.widget_number ) {
|
||||
id = a['widget-id'];
|
||||
widget.slideUp('normal', function(){
|
||||
$(this).remove();
|
||||
wpWidgets.resize();
|
||||
});
|
||||
if ( !$('.widget_number', widget).val() ) {
|
||||
id = $('.widget-id', widget).val();
|
||||
$('#available-widgets .widget-id').each(function(){
|
||||
if ( $(this).val() == id )
|
||||
$(this).parents('.widget').show();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$(t).parents('.widget-inside').slideUp('normal', function(){ $(this).parents('.widget').css({'width':'','marginLeft':''}); });
|
||||
$(t).parents('.widget-inside').slideUp('normal', function(){
|
||||
widget.css({'width':'','marginLeft':''});
|
||||
wpWidgets.appendTitle(widget);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
appendTitle : function(widget) {
|
||||
$('input[type="text"]', widget).each(function(){
|
||||
if ( this.id.indexOf('title') != -1 && $(this).val() ) {
|
||||
$('.widget-title .in-widget-title', widget).html(': ' + $(this).val());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
resize : function() {
|
||||
$('.widgets-sortables').not('#wp_inactive_widgets').each(function(){
|
||||
var h = 50, H = $('.widget', this).length;
|
||||
h = h + parseInt(H * 48, 10);
|
||||
$(this).css( 'minHeight', h + 'px' );
|
||||
});
|
||||
},
|
||||
|
||||
fixWebkit : function(n) {
|
||||
n = n ? 'none' : '';
|
||||
$('body').css({
|
||||
@@ -161,7 +188,7 @@ wpWidgets = {
|
||||
if ( w > 250 && inside.parents('.widgets-sortables').length ) {
|
||||
css['width'] = w + 30 + 'px';
|
||||
if ( inside.parents('.widget-liquid-right').length )
|
||||
css['marginLeft'] = 234 - w + 'px';
|
||||
css['marginLeft'] = 235 - w + 'px';
|
||||
inside.parents('.widget').css(css);
|
||||
}
|
||||
inside.slideDown('normal');
|
||||
|
||||
Reference in New Issue
Block a user