1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
var Portal = Class.create();
Portal.prototype = {
initialize: function (options) {
this.setOptions(options);
if (!this.options.editorEnabled) return;
Droppables.add(this.options.blocklist, {
containment : $A($$("."+this.options.column)),
hoverclass : this.options.hoverclass,
overlap : 'horizontal',
onDrop: function(dragged, dropped) {
$(dragged).remove();
}
});
this.createAllSortables();
this.lastSaveString = "";
this.saveDashboardsState();
},
/****************************************************/
createAllSortables: function () {
var sortables = $$("."+this.options.column);
$A(sortables).each(function (sortable) {
Sortable.create(sortable, {
containment: $A(sortables),
constraint: false,
tag: 'div',
only: this.options.block,
dropOnEmpty: true,
hoverclass: this.options.hoverclass,
starteffect: function(widget) {
$(widget).addClassName("shadow-block");
}.bind(this),
endeffect: function(widget) {
$(widget).removeClassName("shadow-block");
}.bind(this),
onUpdate: function () {
this.saveDashboardsState();
}.bind(this)
});
}.bind(this));
},
highlightWidget: function(widgetId) {
new Effect.Highlight($('block_' + widgetId), {duration: this.options.highlight_duration,
startcolor: this.options.highlight_startcolor,
endcolor: this.options.highlight_endcolor});
},
/****************************************************/
saveDashboardsState: function () {
var result = "";
var index = 1;
$$("."+this.options.column).each(function (sortable) {
if ($(sortable).select("."+this.options.block).length == 0) {
$(sortable).select("."+this.options.columnhandle)[0].show();
} else {
$(sortable).select("."+this.options.columnhandle)[0].hide();
}
if (index > 1) result += ";";
result += Sortable.sequence($(sortable).identify());
index++;
});
if (result==this.lastSaveString) {
return;
}
var firstTime=this.lastSaveString=="";
this.lastSaveString=result;
if (firstTime) return;
try {
if ($(this.options.dashboardstate)) {
$(this.options.dashboardstate).value = result;
}
if (this.options.saveurl) {
var url = this.options.saveurl;
var postBody = this.options.dashboardstate + '=' +escape(result);
new Ajax.Request(url,
{
evalscripts:false,
method: 'post',
postBody: postBody
});
}
} catch(e) {
}
},
setOptions: function (options) {
this.options = {};
Object.extend(this.options, options || {});
},
editWidget: function(id) {
$('widget_' + id).hide();
$('widget_props_' + id).show();
},
cancelEditWidget: function(id) {
$('widget_' + id).show();
$('widget_props_' + id).hide();
},
deleteWidget: function(elt) {
$(elt).up('.block').remove();
this.saveDashboardsState();
}
};
|