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 | |
---|
97 | |
---|
98 | /* ********** Actions*/ |
---|
99 | |
---|
100 | jQuery('[data-datepicker]').pwgDatepicker({ |
---|
101 | showTimepicker: true, |
---|
102 | cancelButton: lang.Cancel |
---|
103 | }); |
---|
104 | |
---|
105 | jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); |
---|
106 | |
---|
107 | $("input[name=remove_author]").click(function () { |
---|
108 | if ($(this).is(':checked')) { |
---|
109 | $("input[name=author]").hide(); |
---|
110 | } |
---|
111 | else { |
---|
112 | $("input[name=author]").show(); |
---|
113 | } |
---|
114 | }); |
---|
115 | |
---|
116 | $("input[name=remove_title]").click(function () { |
---|
117 | if ($(this).is(':checked')) { |
---|
118 | $("input[name=title]").hide(); |
---|
119 | } |
---|
120 | else { |
---|
121 | $("input[name=title]").show(); |
---|
122 | } |
---|
123 | }); |
---|
124 | |
---|
125 | $("input[name=remove_date_creation]").click(function () { |
---|
126 | if ($(this).is(':checked')) { |
---|
127 | $("#set_date_creation").hide(); |
---|
128 | } |
---|
129 | else { |
---|
130 | $("#set_date_creation").show(); |
---|
131 | } |
---|
132 | }); |
---|