1 | |
---|
2 | /* ********** Filters*/ |
---|
3 | function filter_enable(filter) { |
---|
4 | /* show the filter*/ |
---|
5 | $("#"+filter).show(); |
---|
6 | |
---|
7 | /* check the checkbox to declare we use this filter */ |
---|
8 | $("input[type=checkbox][name="+filter+"_use]").prop("checked", true); |
---|
9 | |
---|
10 | /* forbid to select this filter in the addFilter list */ |
---|
11 | $("#addFilter").children("option[value="+filter+"]").attr("disabled", "disabled"); |
---|
12 | } |
---|
13 | |
---|
14 | function filter_disable(filter) { |
---|
15 | /* hide the filter line */ |
---|
16 | $("#"+filter).hide(); |
---|
17 | |
---|
18 | /* uncheck the checkbox to declare we do not use this filter */ |
---|
19 | $("input[name="+filter+"_use]").prop("checked", false); |
---|
20 | |
---|
21 | /* give the possibility to show it again */ |
---|
22 | $("#addFilter").children("option[value="+filter+"]").removeAttr("disabled"); |
---|
23 | } |
---|
24 | |
---|
25 | $(".removeFilter").click(function () { |
---|
26 | var filter = $(this).parent('li').attr("id"); |
---|
27 | filter_disable(filter); |
---|
28 | |
---|
29 | return false; |
---|
30 | }); |
---|
31 | |
---|
32 | $("#addFilter").change(function () { |
---|
33 | var filter = $(this).prop("value"); |
---|
34 | filter_enable(filter); |
---|
35 | $(this).prop("value", -1); |
---|
36 | }); |
---|
37 | |
---|
38 | $("#removeFilters").click(function() { |
---|
39 | $("#filterList li").each(function() { |
---|
40 | var filter = $(this).attr("id"); |
---|
41 | filter_disable(filter); |
---|
42 | }); |
---|
43 | return false; |
---|
44 | }); |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | /* ********** Thumbs */ |
---|
49 | |
---|
50 | /* Shift-click: select all photos between the click and the shift+click */ |
---|
51 | jQuery(document).ready(function() { |
---|
52 | var last_clicked=0, |
---|
53 | last_clickedstatus=true; |
---|
54 | jQuery.fn.enableShiftClick = function() { |
---|
55 | var inputs = [], |
---|
56 | count=0; |
---|
57 | this.find('input[type=checkbox]').each(function() { |
---|
58 | var pos=count; |
---|
59 | inputs[count++]=this; |
---|
60 | $(this).bind("shclick", function (dummy,event) { |
---|
61 | if (event.shiftKey) { |
---|
62 | var first = last_clicked; |
---|
63 | var last = pos; |
---|
64 | if (first > last) { |
---|
65 | first=pos; |
---|
66 | last=last_clicked; |
---|
67 | } |
---|
68 | |
---|
69 | for (var i=first; i<=last;i++) { |
---|
70 | input = $(inputs[i]); |
---|
71 | $(input).prop('checked', last_clickedstatus); |
---|
72 | if (last_clickedstatus) |
---|
73 | { |
---|
74 | $(input).siblings("span.wrap2").addClass("thumbSelected"); |
---|
75 | } |
---|
76 | else |
---|
77 | { |
---|
78 | $(input).siblings("span.wrap2").removeClass("thumbSelected"); |
---|
79 | } |
---|
80 | } |
---|
81 | } |
---|
82 | else { |
---|
83 | last_clicked = pos; |
---|
84 | last_clickedstatus = this.checked; |
---|
85 | } |
---|
86 | return true; |
---|
87 | }); |
---|
88 | $(this).click(function(event) { $(this).triggerHandler("shclick",event)}); |
---|
89 | }); |
---|
90 | } |
---|
91 | $('ul.thumbnails').enableShiftClick(); |
---|
92 | }); |
---|
93 | |
---|
94 | jQuery("a.preview-box").colorbox(); |
---|
95 | |
---|
96 | jQuery('.thumbnails img').tipTip({ |
---|
97 | 'delay' : 0, |
---|
98 | 'fadeIn' : 200, |
---|
99 | 'fadeOut' : 200 |
---|
100 | }); |
---|
101 | |
---|
102 | |
---|
103 | /* ********** Actions*/ |
---|
104 | |
---|
105 | jQuery('[data-datepicker]').pwgDatepicker({ |
---|
106 | showTimepicker: true, |
---|
107 | cancelButton: lang.Cancel |
---|
108 | }); |
---|
109 | |
---|
110 | jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); |
---|
111 | |
---|
112 | $("input[name=remove_author]").click(function () { |
---|
113 | if ($(this).is(':checked')) { |
---|
114 | $("input[name=author]").hide(); |
---|
115 | } |
---|
116 | else { |
---|
117 | $("input[name=author]").show(); |
---|
118 | } |
---|
119 | }); |
---|
120 | |
---|
121 | $("input[name=remove_title]").click(function () { |
---|
122 | if ($(this).is(':checked')) { |
---|
123 | $("input[name=title]").hide(); |
---|
124 | } |
---|
125 | else { |
---|
126 | $("input[name=title]").show(); |
---|
127 | } |
---|
128 | }); |
---|
129 | |
---|
130 | $("input[name=remove_date_creation]").click(function () { |
---|
131 | if ($(this).is(':checked')) { |
---|
132 | $("#set_date_creation").hide(); |
---|
133 | } |
---|
134 | else { |
---|
135 | $("#set_date_creation").show(); |
---|
136 | } |
---|
137 | }); |
---|
138 | |
---|
139 | var derivatives = { |
---|
140 | elements: null, |
---|
141 | done: 0, |
---|
142 | total: 0, |
---|
143 | |
---|
144 | finished: function() { |
---|
145 | return derivatives.done == derivatives.total && derivatives.elements && derivatives.elements.length==0; |
---|
146 | } |
---|
147 | }; |
---|
148 | |
---|
149 | function progress(success) { |
---|
150 | jQuery('#progressBar').progressBar(derivatives.done, { |
---|
151 | max: derivatives.total, |
---|
152 | textFormat: 'fraction', |
---|
153 | boxImage: 'themes/default/images/progressbar.gif', |
---|
154 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
155 | }); |
---|
156 | if (success !== undefined) { |
---|
157 | var type = success ? 'regenerateSuccess': 'regenerateError', |
---|
158 | s = jQuery('[name="'+type+'"]').val(); |
---|
159 | jQuery('[name="'+type+'"]').val(++s); |
---|
160 | } |
---|
161 | |
---|
162 | if (derivatives.finished()) { |
---|
163 | jQuery('#applyAction').click(); |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | function getDerivativeUrls() { |
---|
168 | var ids = derivatives.elements.splice(0, 500); |
---|
169 | var params = {max_urls: 100000, ids: ids, types: []}; |
---|
170 | jQuery("#action_generate_derivatives input").each( function(i, t) { |
---|
171 | if ($(t).is(":checked")) |
---|
172 | params.types.push( t.value ); |
---|
173 | } ); |
---|
174 | |
---|
175 | jQuery.ajax( { |
---|
176 | type: "POST", |
---|
177 | url: 'ws.php?format=json&method=pwg.getMissingDerivatives', |
---|
178 | data: params, |
---|
179 | dataType: "json", |
---|
180 | success: function(data) { |
---|
181 | if (!data.stat || data.stat != "ok") { |
---|
182 | return; |
---|
183 | } |
---|
184 | derivatives.total += data.result.urls.length; |
---|
185 | progress(); |
---|
186 | for (var i=0; i < data.result.urls.length; i++) { |
---|
187 | jQuery.manageAjax.add("queued", { |
---|
188 | type: 'GET', |
---|
189 | url: data.result.urls[i] + "&ajaxload=true", |
---|
190 | dataType: 'json', |
---|
191 | success: ( function(data) { derivatives.done++; progress(true) }), |
---|
192 | error: ( function(data) { derivatives.done++; progress(false) }) |
---|
193 | }); |
---|
194 | } |
---|
195 | if (derivatives.elements.length) |
---|
196 | setTimeout( getDerivativeUrls, 25 * (derivatives.total-derivatives.done)); |
---|
197 | } |
---|
198 | } ); |
---|
199 | } |
---|
200 | |
---|
201 | function selectGenerateDerivAll() { |
---|
202 | $("#action_generate_derivatives input[type=checkbox]").prop("checked", true); |
---|
203 | } |
---|
204 | function selectGenerateDerivNone() { |
---|
205 | $("#action_generate_derivatives input[type=checkbox]").prop("checked", false); |
---|
206 | } |
---|
207 | |
---|
208 | function selectDelDerivAll() { |
---|
209 | $("#action_delete_derivatives input[type=checkbox]").prop("checked", true); |
---|
210 | } |
---|
211 | function selectDelDerivNone() { |
---|
212 | $("#action_delete_derivatives input[type=checkbox]").prop("checked", false); |
---|
213 | } |
---|