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 | $('[data-slider=widths]').pwgDoubleSlider(sliders.widths); |
---|
47 | $('[data-slider=heights]').pwgDoubleSlider(sliders.heights); |
---|
48 | $('[data-slider=ratios]').pwgDoubleSlider(sliders.ratios); |
---|
49 | $('[data-slider=filesizes]').pwgDoubleSlider(sliders.filesizes); |
---|
50 | |
---|
51 | |
---|
52 | /* ********** Thumbs */ |
---|
53 | |
---|
54 | /* Shift-click: select all photos between the click and the shift+click */ |
---|
55 | jQuery(document).ready(function() { |
---|
56 | var last_clicked=0, |
---|
57 | last_clickedstatus=true; |
---|
58 | jQuery.fn.enableShiftClick = function() { |
---|
59 | var inputs = [], |
---|
60 | count=0; |
---|
61 | this.find('input[type=checkbox]').each(function() { |
---|
62 | var pos=count; |
---|
63 | inputs[count++]=this; |
---|
64 | $(this).bind("shclick", function (dummy,event) { |
---|
65 | if (event.shiftKey) { |
---|
66 | var first = last_clicked; |
---|
67 | var last = pos; |
---|
68 | if (first > last) { |
---|
69 | first=pos; |
---|
70 | last=last_clicked; |
---|
71 | } |
---|
72 | |
---|
73 | for (var i=first; i<=last;i++) { |
---|
74 | input = $(inputs[i]); |
---|
75 | $(input).prop('checked', last_clickedstatus); |
---|
76 | if (last_clickedstatus) |
---|
77 | { |
---|
78 | $(input).siblings("span.wrap2").addClass("thumbSelected"); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | $(input).siblings("span.wrap2").removeClass("thumbSelected"); |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | else { |
---|
87 | last_clicked = pos; |
---|
88 | last_clickedstatus = this.checked; |
---|
89 | } |
---|
90 | return true; |
---|
91 | }); |
---|
92 | $(this).click(function(event) { $(this).triggerHandler("shclick",event)}); |
---|
93 | }); |
---|
94 | } |
---|
95 | $('ul.thumbnails').enableShiftClick(); |
---|
96 | }); |
---|
97 | |
---|
98 | jQuery("a.preview-box").colorbox(); |
---|
99 | |
---|
100 | jQuery('.thumbnails img').tipTip({ |
---|
101 | 'delay' : 0, |
---|
102 | 'fadeIn' : 200, |
---|
103 | 'fadeOut' : 200 |
---|
104 | }); |
---|
105 | |
---|
106 | |
---|
107 | /* ********** Actions*/ |
---|
108 | |
---|
109 | jQuery('[data-datepicker]').pwgDatepicker({ |
---|
110 | showTimepicker: true, |
---|
111 | cancelButton: lang.Cancel |
---|
112 | }); |
---|
113 | |
---|
114 | jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); |
---|
115 | |
---|
116 | $("input[name=remove_author]").click(function () { |
---|
117 | if ($(this).is(':checked')) { |
---|
118 | $("input[name=author]").hide(); |
---|
119 | } |
---|
120 | else { |
---|
121 | $("input[name=author]").show(); |
---|
122 | } |
---|
123 | }); |
---|
124 | |
---|
125 | $("input[name=remove_title]").click(function () { |
---|
126 | if ($(this).is(':checked')) { |
---|
127 | $("input[name=title]").hide(); |
---|
128 | } |
---|
129 | else { |
---|
130 | $("input[name=title]").show(); |
---|
131 | } |
---|
132 | }); |
---|
133 | |
---|
134 | $("input[name=remove_date_creation]").click(function () { |
---|
135 | if ($(this).is(':checked')) { |
---|
136 | $("#set_date_creation").hide(); |
---|
137 | } |
---|
138 | else { |
---|
139 | $("#set_date_creation").show(); |
---|
140 | } |
---|
141 | }); |
---|
142 | |
---|
143 | var derivatives = { |
---|
144 | elements: null, |
---|
145 | done: 0, |
---|
146 | total: 0, |
---|
147 | |
---|
148 | finished: function() { |
---|
149 | return derivatives.done == derivatives.total && derivatives.elements && derivatives.elements.length==0; |
---|
150 | } |
---|
151 | }; |
---|
152 | |
---|
153 | function progress(success) { |
---|
154 | jQuery('#progressBar').progressBar(derivatives.done, { |
---|
155 | max: derivatives.total, |
---|
156 | textFormat: 'fraction', |
---|
157 | boxImage: 'themes/default/images/progressbar.gif', |
---|
158 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
159 | }); |
---|
160 | if (success !== undefined) { |
---|
161 | var type = success ? 'regenerateSuccess': 'regenerateError', |
---|
162 | s = jQuery('[name="'+type+'"]').val(); |
---|
163 | jQuery('[name="'+type+'"]').val(++s); |
---|
164 | } |
---|
165 | |
---|
166 | if (derivatives.finished()) { |
---|
167 | jQuery('#applyAction').click(); |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | function getDerivativeUrls() { |
---|
172 | var ids = derivatives.elements.splice(0, 500); |
---|
173 | var params = {max_urls: 100000, ids: ids, types: []}; |
---|
174 | jQuery("#action_generate_derivatives input").each( function(i, t) { |
---|
175 | if ($(t).is(":checked")) |
---|
176 | params.types.push( t.value ); |
---|
177 | } ); |
---|
178 | |
---|
179 | jQuery.ajax( { |
---|
180 | type: "POST", |
---|
181 | url: 'ws.php?format=json&method=pwg.getMissingDerivatives', |
---|
182 | data: params, |
---|
183 | dataType: "json", |
---|
184 | success: function(data) { |
---|
185 | if (!data.stat || data.stat != "ok") { |
---|
186 | return; |
---|
187 | } |
---|
188 | derivatives.total += data.result.urls.length; |
---|
189 | progress(); |
---|
190 | for (var i=0; i < data.result.urls.length; i++) { |
---|
191 | jQuery.manageAjax.add("queued", { |
---|
192 | type: 'GET', |
---|
193 | url: data.result.urls[i] + "&ajaxload=true", |
---|
194 | dataType: 'json', |
---|
195 | success: ( function(data) { derivatives.done++; progress(true) }), |
---|
196 | error: ( function(data) { derivatives.done++; progress(false) }) |
---|
197 | }); |
---|
198 | } |
---|
199 | if (derivatives.elements.length) |
---|
200 | setTimeout( getDerivativeUrls, 25 * (derivatives.total-derivatives.done)); |
---|
201 | } |
---|
202 | } ); |
---|
203 | } |
---|
204 | |
---|
205 | function selectGenerateDerivAll() { |
---|
206 | $("#action_generate_derivatives input[type=checkbox]").prop("checked", true); |
---|
207 | } |
---|
208 | function selectGenerateDerivNone() { |
---|
209 | $("#action_generate_derivatives input[type=checkbox]").prop("checked", false); |
---|
210 | } |
---|
211 | |
---|
212 | function selectDelDerivAll() { |
---|
213 | $("#action_delete_derivatives input[type=checkbox]").prop("checked", true); |
---|
214 | } |
---|
215 | function selectDelDerivNone() { |
---|
216 | $("#action_delete_derivatives input[type=checkbox]").prop("checked", false); |
---|
217 | } |
---|