Make WordPress Core

Changeset 10916


Ignore:
Timestamp:
04/13/2009 01:17:59 AM (16 years ago)
Author:
azaozz
Message:

Resizing and animation for widgets, see #9511

Location:
trunk/wp-admin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/colors-classic.css

    r10912 r10916  
    15731573    border-color: #DDDDDD;
    15741574}
     1575
     1576.sidebar-name:hover {
     1577    color: #d54e21;
     1578}
     1579
  • trunk/wp-admin/css/colors-fresh.css

    r10912 r10916  
    15751575    border-color: #DDDDDD;
    15761576}
     1577
     1578.sidebar-name:hover {
     1579    color: #d54e21;
     1580}
     1581
  • trunk/wp-admin/css/widgets.css

    r10912 r10916  
    2020    width: 300px;
    2121    margin: 15px 0 18px;
     22    position: relative;
    2223}
    2324
     
    9192
    9293.widget .widget-inside {
    93     margin: 15px;
     94    padding: 15px;
    9495    font-size: 11px;
    9596    display: none;
  • trunk/wp-admin/includes/widgets.php

    r10913 r10916  
    178178    $widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
    179179    $id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
     180    $multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : '';
     181    $add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
    180182
    181183    // We aren't showing a widget control, we're outputing a template for a mult-widget control
     
    186188        if ( isset($control['id_base']) )
    187189            $id_format = $control['id_base'] . '-__i__';
    188 
    189         $multi_number = $sidebar_args['_multi_num'];
    190190    }
    191191
     
    216216            <input type="hidden" name="widget-id" class="widget-id" value="<?php echo $id_format; ?>" />
    217217            <input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
    218             <input type="hidden" name="widget-width" value="<?php echo $control['width']; ?>" />
    219             <input type="hidden" name="widget-height" value="<?php echo $control['height']; ?>" />
     218            <input type="hidden" name="widget-width" class="widget-width" value="<?php echo $control['width']; ?>" />
     219            <input type="hidden" name="widget-height" class="widget-height" value="<?php echo $control['height']; ?>" />
    220220            <input type="hidden" name="widget_number" class="widget_number" value="<?php echo $widget_number; ?>" />
    221 <?php
    222             if ( isset($multi_number) )
    223                 echo "\t\t\t<input type='hidden' name='multi_number' class='multi_number' value='$multi_number' />\n";
    224                
    225             if ( isset($sidebar_args['_add']) )
    226                 echo "\t\t\t<input type='hidden' name='add_new' class='add_new' value='" . $sidebar_args['_add'] . "' />\n"; ?>
     221            <input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
     222            <input type="hidden" name="add_new" class="add_new" value="<?php echo $add_new; ?>" />
    227223
    228224            <div class="widget-control-actions">
  • trunk/wp-admin/js/widgets.dev.js

    r10912 r10916  
    2121            handle: '.widget-title',
    2222            distance: 2,
    23             tolerance: 'pointer',
    24         //  forcePlaceholderSize: true,
    2523            helper: 'clone',
     24            zIndex: 5,
    2625            start: function() {
    2726                wpWidgets.fixWebkit(1);
     
    4241            cursor: 'move',
    4342            distance: 2,
    44             tolerance: 'pointer',
    45         //  forcePlaceholderSize: true,
    46         //  helper: 'clone',
    4743            opacity: 0.65,
    4844            start: function(e,ui) {
    4945                wpWidgets.fixWebkit(1);
     46                ui.item.find('.widget-inside').hide();
     47                ui.item.css({'marginLeft':'','width':''});
    5048            },
    5149            stop: function(e,ui) {
    5250                var add = ui.item.find('input.add_new').val(), n = ui.item.find('input.multi_number').val(), id = ui.item.attr('id'), sb = $(this).parent().attr('id');
     51                ui.item.css({'marginLeft':'','width':''});
    5352
    54                 if ( add ) {
     53                if ( add && n ) {
    5554                    if ( 'multi' == add ) {
    5655                        ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__/g, n); }) );
     
    9392    save : function(data, sb, del, t) {
    9493        var a;
    95         sb = sb || '';
     94
    9695        $('#' + sb + ' .ajax-feedback').css('visibility', 'visible');
    9796
     
    123122                }
    124123            } else {
    125                 $(t).parents('.widget-inside').hide();
     124                $(t).parents('.widget-inside').hide('fast');
    126125            }
    127126        });
     
    131130        n = n ? 'none' : '';
    132131        $('body').css({
    133           WebkitUserSelect: n,
    134           KhtmlUserSelect: n
     132            WebkitUserSelect: n,
     133            KhtmlUserSelect: n
    135134        });
    136135    },
     
    139138        sc = sc || document;
    140139        $('a.widget-action', sc).click(function(){
    141             $(this).parents('.widget-top').siblings('.widget-inside').toggle();
     140            var w = parseInt( $(this).parents('.widget').find('.widget-width').val(), 10 ), css = {}, inside = $(this).parents('.widget-top').siblings('.widget-inside');
     141            if ( inside.is(':hidden') ) {
     142                if ( w > 270 && inside.parents('.widgets-sortables').length ) {
     143                    css['width'] = w + 30 + 'px';
     144                    if ( inside.parents('.widget-liquid-right').length )
     145                        css['marginLeft'] = 270 - w + 'px';
     146                    inside.parents('.widget').css(css);
     147                }
     148                inside.show('fast');
     149            } else {
     150                inside.parents('.widget').css({'width':'','marginLeft':''});
     151                inside.hide('fast');
     152            }
    142153            return false;
    143154        });
  • trunk/wp-admin/js/widgets.js

    r10912 r10916  
    1 var wpWidgets;(function(a){wpWidgets={init:function(){var b;a("h3.sidebar-name").click(function(){var d=a(this).siblings(".widgets-sortables");if(d.is(":visible")){d.hide().sortable("disable")}else{d.show().sortable("enable").sortable("refresh")}a(this).siblings("#widget-list").toggle()});this.addEvents();a("#widget-list .widget").draggable({connectToSortable:".widgets-sortables",handle:".widget-title",distance:2,tolerance:"pointer",helper:"clone",start:function(){wpWidgets.fixWebkit(1)},stop:function(d,c){if(b){a(b).hide()}b="";wpWidgets.fixWebkit()}});a(".widgets-sortables").sortable({placeholder:"widget-placeholder",connectWith:".widgets-sortables",items:".widget",handle:".widget-title",cursor:"move",distance:2,tolerance:"pointer",opacity:0.65,start:function(d,c){wpWidgets.fixWebkit(1)},stop:function(f,c){var d=c.item.find("input.add_new").val(),i=c.item.find("input.multi_number").val(),h=c.item.attr("id"),g=a(this).parent().attr("id");if(d){if("multi"==d){c.item.html(c.item.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__/g,i)}));c.item.attr("id",h.replace(/__i__/g,i));i++;a("li#"+h).find("input.multi_number").val(i)}else{if("single"==d){c.item.attr("id","new-"+h);b="li#"+h}}wpWidgets.addEvents(c.item);wpWidgets.save(c.item.find("form").serializeArray(),g,0);c.item.find("input.add_new").val("")}wpWidgets.saveOrder(g);wpWidgets.fixWebkit()},receive:function(d,c){if(!a(this).is(":visible")){a(this).sortable("cancel")}}}).not(":visible").sortable("disable")},saveOrder:function(c){a("#"+c+" .ajax-feedback").css("visibility","visible");var b={action:"widgets-order",savewidgets:a("#_wpnonce_widgets").val()};a(".widgets-sortables").each(function(){b[a(this).parent().attr("id")]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b,function(){a(".ajax-feedback").css("visibility","hidden")})},save:function(e,f,c,d){var b;f=f||"";a("#"+f+" .ajax-feedback").css("visibility","visible");b={action:"save-widget",savewidgets:a("#_wpnonce_widgets").val(),sidebar:f};if(c){b.delete_widget=1}a.map(e,function(h,g){b[h.name]=h.value});a.post(ajaxurl,b,function(g){var h;a(".ajax-feedback").css("visibility","hidden");if(!d){return}if(c){a(d).parents("li.widget").remove();if(!b.widget_number){h=b["widget-id"];a("#available-widgets .widget-id").each(function(){if(a(this).val()==h){a(this).parents("li.widget").show()}})}}else{a(d).parents(".widget-inside").hide()}})},fixWebkit:function(b){b=b?"none":"";a("body").css({WebkitUserSelect:b,KhtmlUserSelect:b})},addEvents:function(b){b=b||document;a("a.widget-action",b).click(function(){a(this).parents(".widget-top").siblings(".widget-inside").toggle();return false});a(".widget-control-save",b).click(function(){wpWidgets.save(a(this).parents("form").serializeArray(),a(this).parents(".widgets-holder-wrap").attr("id"),0,this);return false});a(".widget-control-remove",b).click(function(){wpWidgets.save(a(this).parents("form").serializeArray(),a(this).parents(".widgets-holder-wrap").attr("id"),1,this);return false})}};a(document).ready(function(){wpWidgets.init()})})(jQuery);
     1var wpWidgets;(function(a){wpWidgets={init:function(){var b;a("h3.sidebar-name").click(function(){var d=a(this).siblings(".widgets-sortables");if(d.is(":visible")){d.hide().sortable("disable")}else{d.show().sortable("enable").sortable("refresh")}a(this).siblings("#widget-list").toggle()});this.addEvents();a("#widget-list .widget").draggable({connectToSortable:".widgets-sortables",handle:".widget-title",distance:2,helper:"clone",zIndex:5,start:function(){wpWidgets.fixWebkit(1)},stop:function(d,c){if(b){a(b).hide()}b="";wpWidgets.fixWebkit()}});a(".widgets-sortables").sortable({placeholder:"widget-placeholder",connectWith:".widgets-sortables",items:".widget",handle:".widget-title",cursor:"move",distance:2,opacity:0.65,start:function(d,c){wpWidgets.fixWebkit(1);c.item.find(".widget-inside").hide();c.item.css({marginLeft:"",width:""})},stop:function(f,c){var d=c.item.find("input.add_new").val(),i=c.item.find("input.multi_number").val(),h=c.item.attr("id"),g=a(this).parent().attr("id");c.item.css({marginLeft:"",width:""});if(d&&i){if("multi"==d){c.item.html(c.item.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__/g,i)}));c.item.attr("id",h.replace(/__i__/g,i));i++;a("li#"+h).find("input.multi_number").val(i)}else{if("single"==d){c.item.attr("id","new-"+h);b="li#"+h}}wpWidgets.addEvents(c.item);wpWidgets.save(c.item.find("form").serializeArray(),g,0);c.item.find("input.add_new").val("")}wpWidgets.saveOrder(g);wpWidgets.fixWebkit()},receive:function(d,c){if(!a(this).is(":visible")){a(this).sortable("cancel")}}}).not(":visible").sortable("disable")},saveOrder:function(c){a("#"+c+" .ajax-feedback").css("visibility","visible");var b={action:"widgets-order",savewidgets:a("#_wpnonce_widgets").val()};a(".widgets-sortables").each(function(){b[a(this).parent().attr("id")]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b,function(){a(".ajax-feedback").css("visibility","hidden")})},save:function(e,f,c,d){var b;a("#"+f+" .ajax-feedback").css("visibility","visible");b={action:"save-widget",savewidgets:a("#_wpnonce_widgets").val(),sidebar:f};if(c){b.delete_widget=1}a.map(e,function(h,g){b[h.name]=h.value});a.post(ajaxurl,b,function(g){var h;a(".ajax-feedback").css("visibility","hidden");if(!d){return}if(c){a(d).parents("li.widget").remove();if(!b.widget_number){h=b["widget-id"];a("#available-widgets .widget-id").each(function(){if(a(this).val()==h){a(this).parents("li.widget").show()}})}}else{a(d).parents(".widget-inside").hide("fast")}})},fixWebkit:function(b){b=b?"none":"";a("body").css({WebkitUserSelect:b,KhtmlUserSelect:b})},addEvents:function(b){b=b||document;a("a.widget-action",b).click(function(){var d=parseInt(a(this).parents(".widget").find(".widget-width").val(),10),e={},c=a(this).parents(".widget-top").siblings(".widget-inside");if(c.is(":hidden")){if(d>270&&c.parents(".widgets-sortables").length){e.width=d+30+"px";if(c.parents(".widget-liquid-right").length){e.marginLeft=270-d+"px"}c.parents(".widget").css(e)}c.show("fast")}else{c.parents(".widget").css({width:"",marginLeft:""});c.hide("fast")}return false});a(".widget-control-save",b).click(function(){wpWidgets.save(a(this).parents("form").serializeArray(),a(this).parents(".widgets-holder-wrap").attr("id"),0,this);return false});a(".widget-control-remove",b).click(function(){wpWidgets.save(a(this).parents("form").serializeArray(),a(this).parents(".widgets-holder-wrap").attr("id"),1,this);return false})}};a(document).ready(function(){wpWidgets.init()})})(jQuery);
  • trunk/wp-admin/widgets.php

    r10912 r10916  
    127127require_once( 'admin-header.php' ); ?>
    128128
     129<div class="wrap">
     130<?php screen_icon(); ?>
     131<h2><?php echo wp_specialchars( $title ); ?></h2>
     132
    129133<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?>
    130134<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    131135<?php endif; ?>
    132 
    133 
    134 <div id="message" class="updated"><p>This page is not 100% ready, please use only on test installations.</p></div>
    135 
    136 
    137 <div class="wrap">
    138 <?php screen_icon(); ?>
    139 <h2><?php echo wp_specialchars( $title ); ?></h2>
    140136
    141137
Note: See TracChangeset for help on using the changeset viewer.