-
Notifications
You must be signed in to change notification settings - Fork 1
/
homebox.js
114 lines (91 loc) · 2.95 KB
/
homebox.js
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
114
(function ($) {
$(document).ready(function(){
$("#first-tab .column").sortable({
connectWith: '.column',
opacity: 0.7,
tolerance: 'pointer',
revert: true
});
$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
.find(".portlet-header")
.addClass("ui-widget-header ui-corner-all")
.prepend('<span class="ui-icon ui-icon-plusthick"></span>')
.end()
.find(".portlet-content");
$(".portlet-header .ui-icon").click(function() {
$(this).toggleClass("ui-icon-minusthick");
$(this).parents(".portlet:first").find(".portlet-content").toggle();
});
$(".column").disableSelection();
// Init the jQuery UI tabs
var tabs = $("#homebox-tabs").tabs({
show: function(event, ui) {
current_tab_is_loaded = 'homebox_tab_' + ui.tab.hash.replace('#', '') + '_loaded';
// Test if the Tab is already loaded
if (jQuery.data(document, current_tab_is_loaded) != true) {
// If not load boxes names
Drupal.Homebox.getBoxesIdentifiersForTab(ui);
// ... and store loaded state for this tab
jQuery.data(document, current_tab_is_loaded, true);
};
},
//cookie: { expires: 30 }
});
// Add tab button
$('#homebox-add-tab').click(function(e){
$(tabs).tabs('add' , '#foo' , 'Mon 3ème');
e.stopPropagation();
});
});
Drupal.Homebox = Drupal.Homebox || {};
Drupal.Homebox.getBoxesIdentifiersForTab = function (tab) {
var url = Drupal.settings.basePath + '?q=homebox/get/tab/';
try {
$.ajax({
type: "GET",
url: url + tab.tab.hash.replace('#', ''),
global: true,
success: Drupal.Homebox.getBoxesForTab,
error: function(xhr) {
Drupal.CTools.AJAX.handleErrors(xhr, url);
},
complete: function() {
},
dataType: 'json'
});
}
catch (err) {
// alert("An error occurred while attempting to process " + url);
return false;
}
},
Drupal.Homebox.getBoxesForTab = function (data) {
// TODO add correct CSS ID selector or XPath expr
//$('#homebox').empty();
$.each(data.boxes, function(index, value){
// if (index < 5) {
var url = Drupal.settings.basePath + '?q=homebox/get/box/' + value + '/' + data.tab;
var object = $(this);
try {
url = url.replace(/nojs/g, 'ajax');
$.ajax({
type: "GET",
url: url,
global: true,
success: Drupal.CTools.AJAX.respond,
error: function(xhr) {
Drupal.CTools.AJAX.handleErrors(xhr, url);
},
complete: function() {
},
dataType: 'json'
});
}
catch (err) {
// alert("An error occurred while attempting to process " + url);
return false;
}
// };
});
}
})(jQuery);