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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/*
* @todo Trap resize of dialog and resize the child areas (tree, grid and edit form)
*/
var url;
var height;
function get_album_content() {
var grid_width = $("#gMicroThumbContainer").width();
url = $("#gMicroThumbContainer").attr("ref");
url = url.replace("__WIDTH__", grid_width);
url = url.replace("__HEIGHT__", height);
retrieve_micro_thumbs(url);
}
function retrieve_micro_thumbs() {
var offset = $("#gMicroThumbGrid li").length;
if (url == null) {
var grid_width = $("#gMicroThumbContainer").width();
url = $("#gMicroThumbContainer").attr("ref");
url = url.replace("__WIDTH__", grid_width);
url = url.replace("__HEIGHT__", height);
}
var url_data = url.replace("__OFFSET__", offset);
url_data = url.replace("__ITEM_ID__", item_id);
$.get(url_data, function(data) {
$("#gMicroThumbGrid").append(data);
get_more_data();
});
}
function get_more_data() {
var element = $("#gMicroThumbContainer").get(0);
var scrollHeight = element.scrollHeight;
var scrollTop = element.scrollTop;
var height = $("#gMicroThumbContainer").height();
var scrollPosition = scrollHeight - (scrollTop + height);
if (scrollPosition > 0 && scrollPosition <= 100) {
retrieve_micro_thumbs();
}
}
function toggle_select(event) {
var clone = null;
var id = $(this).attr("id").replace(/[^0-9]/g, "");
if ($(this).hasClass("gThumbSelected")) {
$(this).removeClass("gThumbSelected");
var newSelect = $(".gThumbSelected");
if (newSelect.size() == 1) {
clone = $(".gThumbSelected").children("img").clone(true);
id = $(".gThumbSelected").attr("id").replace(/[^0-9]/g, "");
} else {
clone = null;
}
} else {
clone = $(this).children("img").clone(true);
$(this).addClass("gThumbSelected");
}
switch ($(".gThumbSelected").size()) {
case 0:
reset_edit_select();
break;
case 1:
$("#gOrganizeFormThumb").empty();
$("#gOrganizeFormThumb").append(clone);
$("#gOrganizeFormNoImage").hide();
$("#gOrganizeFormMultipleImages").hide();
$("#gOrganizeFormThumb").show();
$("#gOrganizeButtonPane").show();
$.getJSON($("#gOrganizeFormInfo").attr("ref").replace("__ITEM_ID__", id), function(data) {
$("#gOrganizeFormTitle").text(data.title);
$("#gOrganizeFormOwner").text(data.owner);
$("#gOrganizeFormDate").text(data.date);
$("#gOrganizeFormDescription").text(data.description);
$("#gOrganizeFormInfo").show();
});
break;
default:
$("#gOrganizeFormThumb").hide();
$("#gOrganizeFormInfo").hide();
$("#gOrganizeFormMultipleImages").show();
}
event.preventDefault();
}
function reset_edit_select() {
$("#gOrganizeFormNoImage").show();
$("#gOrganizeFormThumb").hide();
$("#gOrganizeFormMultipleImages").hide();
$("#gOrganizeButtonPane").hide();
$("#gOrganizeFormInfo").hide();
}
function organize_toggle_children(event) {
var id = $(this).attr("ref");
var span_children = $("#gOrganizeChildren-" + id);
if ($(this).hasClass("ui-icon-plus")) {
$(this).removeClass("ui-icon-plus");
$(this).addClass("ui-icon-minus");
$("#gOrganizeChildren-" + id).removeClass("gBranchCollapsed");
} else {
$(this).removeClass("ui-icon-minus");
$(this).addClass("ui-icon-plus");
$("#gOrganizeChildren-" + id).addClass("gBranchCollapsed");
}
event.preventDefault();
}
function organize_open_folder(event) {
var selected = $(".gBranchSelected");
if ($(selected).attr("id") != $(this).attr("id")) {
$(selected).removeClass("gBranchSelected");
$(this).addClass("gBranchSelected");
item_id = $(this).attr("ref");
$("#gMicroThumbGrid").empty();
var url_header = $("#gDialog #hd").attr("ref").replace("__ITEM_ID__", item_id);
$.getJSON(url_header, function(data) {
$("#gOrganizeAlbumTitle").text(data.title);
$("#gOrganizeAlbumDescription").text(data.description);
});
reset_edit_select();
retrieve_micro_thumbs();
}
event.preventDefault();
}
function organize_dialog_init() {
var size = viewport_size();
height = size.height() - 100;
var width = size.width() - 100;
$("#gDialog").dialog("option", "width", width);
$("#gDialog").dialog("option", "height", height);
$("#gDialog").dialog("open");
if ($("#gDialog h1").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html());
} else if ($("#gDialog fieldset legend").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html());
}
height -= 2 * parseFloat($("#gDialog").css("padding-top"));
height -= 2 * parseFloat($("#gDialog").css("padding-bottom"));
height -= $("#gMicroThumbContainer").position().top;
height -= $("#gDialog #ft").height();
height = Math.round(height);
$("#gMicroThumbContainer").height(height);
$("#gOrganizeTreeContainer").height(height);
$("#gOrganizeEditContainer").height(height);
$(".gOrganizeBranch .ui-icon").click(organize_toggle_children);
$(".gBranchText").click(organize_open_folder);
retrieve_micro_thumbs(item_id);
//showLoading("#gDialog");
}
function viewport_size() {
return {
width : function() {
return window.innerWidth
|| document.documentElement && document.documentElement.clientWidth
|| document.body.clientWidth;
},
height : function() {
return window.innerHeight
|| document.documentElement && document.documentElement.clientHeight
|| document.body.clientHeight;
}
};
}
|