Changeset 11645 for branches

Show
Ignore:
Timestamp:
11/12/08 18:16:59 (8 weeks ago)
Author:
iclerencia@…
Message:

Fix several problems with dragging stuff around.
Calculate urls to reload automatically instead of on load time (what didn't
work anymore for obvious reasons :P)

Location:
branches/iclerencia/dashboard/client/ebox/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/iclerencia/dashboard/client/ebox/src/EBox/Module.pm

    r11594 r11645  
    709709    if(defined($winfo)) { 
    710710        my $widget = $winfo->{'widget'}->($self, $name, $winfo->{'title'}); 
     711        $widget->{'module'} = $self->{'name'}; 
    711712        unless(UNIVERSAL::can($widget,'isa') and 
    712713               $widget->isa('EBox::Dashboard::Widget')) { 
  • branches/iclerencia/dashboard/client/ebox/src/templates/dashboard/configurewidgets.mas

    r11626 r11645  
    4343                var wid = "widget_" + module + ":" + widname; 
    4444                var drag = new Draggable(wid, { 
    45                     onStart: function(d) { 
    46                         if(!this.loaded) {  
    47                             new Ajax.Updater(d.element.id, 
    48                                     '/ebox/Dashboard/Widget?module=' + 
    49                                     d.module + '&widget=' + d.widget, { 
    50                                 method: 'get', 
    51                                 onComplete: function() { 
    52                                     var elements = $(d.element.id).getElementsByClassName('closeBox'); 
    53                                     Effect.toggle(elements[0],'appear'); 
    54                                 } 
    55                             }); 
    56                             this.loaded = true; 
     45                    onDrag: function(d,e) { 
     46                        if(e.clientY > 100) { 
     47                            if(!this.loaded) {  
     48                                new Ajax.Updater(d.element.id, 
     49                                        '/ebox/Dashboard/Widget?module=' + 
     50                                        d.module + '&widget=' + d.widget, { 
     51                                    method: 'get', 
     52                                    onComplete: function() { 
     53                                        var elements = $(d.element.id).getElementsByClassName('closeBox'); 
     54                                        Effect.toggle(elements[0],'appear'); 
     55                                    } 
     56                                }); 
     57                                this.loaded = true; 
     58                            } 
    5759                        } 
    5860                    }, 
     
    7173            var func = null; 
    7274            if(widget_name_list[j].indexOf("dashboard") == 0) { 
    73                 func = function(dashboard) { 
    74                     var id = dashboard.id; 
    75                     new Ajax.Request("/ebox/Dashboard/Update", { 
    76                         method: "post", 
    77                         parameters: { dashboard: id, widgets: Sortable.sequence(id).join(',') } 
    78                     }); 
    79                 }; 
     75                Sortable.create(widget_name_list[j], { 
     76                    tag: "div", 
     77                    handle: "widgetHandle", 
     78                    dropOnEmpty: true, 
     79                    constraint: false, 
     80                    scroll: window, 
     81                    containment: widget_name_list, 
     82                    onUpdate: function(dashboard) { 
     83                        var id = dashboard.id; 
     84                        new Ajax.Request("/ebox/Dashboard/Update", { 
     85                            method: "post", 
     86                            parameters: { dashboard: id, widgets: Sortable.sequence(id).join(',') } 
     87                        }); 
     88                    } 
     89                }); 
    8090            } else { 
    81                 func = function() {}; 
     91                var d = new Draggable(widget_name_list[j], { 
     92                    handle: "widgetHandle", 
     93                    constraint: false, 
     94                    scroll: window 
     95                }); 
     96                d.element.onChange = function() {} 
     97                Sortable.sortables[d.element.id] = d.element; 
    8298            } 
    83             Sortable.create(widget_name_list[j], { 
    84                 tag: "div", 
    85                 handle: "widgetHandle", 
    86                 dropOnEmpty: true, 
    87                 constraint: false, 
    88                 scroll: window, 
    89                 containment: widget_name_list, 
    90                 onUpdate: func 
    91             }); 
    9299        } 
    93100    } 
  • branches/iclerencia/dashboard/client/ebox/src/templates/dashboard/index.mas

    r11638 r11645  
    66<%init> 
    77use EBox::Gettext; 
    8 my @urls; 
    98</%init> 
    109<link href="/data/css/modalbox.css" rel="stylesheet" type="text/css" /> 
     
    5756<br/> 
    5857% foreach my $widget (@dashboard1) { 
    59 %   push(@urls, '/ebox/Dashboard/WidgetJSON?module=' . $widget->{module} . '&widget=' . $widget->{name}); 
    6058    <& dashboard/widget.mas, widget => $widget, toggled => \%toggled &> 
    6159% } 
     
    6462<br/> 
    6563% foreach my $widget (@dashboard2) { 
    66 %   push(@urls, '/ebox/Dashboard/WidgetJSON?module=' . $widget->{module} . '&widget=' . $widget->{name}); 
    6764    <& dashboard/widget.mas, widget => $widget, toggled => \%toggled &> 
    6865% } 
     
    127124% } 
    128125 
    129 % my $urlstr = join(",", map {qq/"$_"/} @urls); 
    130 var urls = new Array(<% $urlstr %>); 
    131  
    132126function updateWidget(widget) { 
    133127    if(widget == null) { 
     
    135129    } 
    136130    widget.sections.each(function(s) { 
    137         var sectname = widget.name + '_' + s.name; 
     131        var sectname = widget.module + ":" + widget.name + '_' + s.name; 
    138132        s.items.each(function(item,i) { 
    139133            var itemname = sectname + '_' + i; 
     
    183177 
    184178function updateWidgets() { 
    185     urls.each(function(u) { 
    186         new Ajax.Request(u, { 
     179    var widgets = Sortable.sequence("dashboard1").concat(Sortable.sequence("dashboard2")); 
     180    widgets.each(function(w) { 
     181        var parts = w.split(':'); 
     182        var url = '/ebox/Dashboard/WidgetJSON?module=' + parts[0] + '&widget=' + parts[1]; 
     183        new Ajax.Request(url, { 
    187184            method: "get", 
    188185            asynchronous: false,