1 | {combine_script id='jquery.timepicker' require='jquery.ui.datepicker,jquery.ui.slider' load='footer' path=$BIRTHDATE_PATH|@cat:"admin/template/jquery-ui-timepicker-addon.js"} |
---|
2 | |
---|
3 | {assign var="datepicker_language" value="themes/default/js/ui/i18n/jquery.ui.datepicker-`$lang_info.code`.js"} |
---|
4 | |
---|
5 | {if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists} |
---|
6 | {combine_script id="jquery.ui.datepicker-$lang_info.code" load='footer' path=$datepicker_language} |
---|
7 | {/if} |
---|
8 | |
---|
9 | {combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} |
---|
10 | {combine_css path="themes/default/js/plugins/chosen.css"} |
---|
11 | |
---|
12 | {combine_css path="themes/default/js/ui/theme/jquery.ui.datepicker.css"} |
---|
13 | {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} |
---|
14 | |
---|
15 | {footer_script require='jquery.timepicker'} |
---|
16 | jQuery(document).ready(function() { |
---|
17 | jQuery("#who").chosen({ "width":"300px" }); |
---|
18 | |
---|
19 | jQuery('#birthdateSelect').datetimepicker({ |
---|
20 | numberOfMonths: 1, |
---|
21 | changeMonth: true, |
---|
22 | changeYear: true, |
---|
23 | yearRange: "1900:+1", |
---|
24 | dateFormat: "yy-mm-dd", |
---|
25 | timeText: '{'selection'|@translate|escape:javascript}', |
---|
26 | hourText: '{'Hour'|@translate|escape:javascript}', |
---|
27 | minuteText: '{'Minute'|@translate|escape:javascript}', |
---|
28 | currentText: '{'Now'|@translate|escape:javascript}', |
---|
29 | closeText: '{'Validate'|@translate|escape:javascript}' |
---|
30 | }); |
---|
31 | |
---|
32 | jQuery("#displayForm").click(function() { |
---|
33 | jQuery("#editLegend").hide(); |
---|
34 | jQuery("#addLegend").show(); |
---|
35 | |
---|
36 | jQuery("[name=add_birthdate]").show(); |
---|
37 | jQuery(this).hide(); |
---|
38 | return false; |
---|
39 | }); |
---|
40 | |
---|
41 | jQuery("#cancelBirthdate").click(function() { |
---|
42 | jQuery("[name=add_birthdate]").hide(); |
---|
43 | jQuery("#displayForm").show(); |
---|
44 | return false; |
---|
45 | }); |
---|
46 | |
---|
47 | jQuery(".editBirthdate").click(function() { |
---|
48 | var tag_id = jQuery(this).data("tag_id"); |
---|
49 | var birthdate = jQuery(this).data("birthdate"); |
---|
50 | |
---|
51 | console.log("tag_id = "+tag_id+"; birthdate = "+birthdate); |
---|
52 | |
---|
53 | jQuery("#displayForm").hide(); |
---|
54 | |
---|
55 | jQuery("#editLegend").show(); |
---|
56 | jQuery("#addLegend").hide(); |
---|
57 | |
---|
58 | jQuery("[name=add_birthdate]").show(); |
---|
59 | jQuery("#who").val("~~"+tag_id+"~~").trigger("chosen:updated"); |
---|
60 | jQuery("#birthdateSelect").val(birthdate); |
---|
61 | |
---|
62 | jQuery("#birthdateList tr").removeClass("rowSelected"); |
---|
63 | jQuery(this).parentsUntil("tr").parent().addClass("rowSelected"); |
---|
64 | window.scroll(0,140); // horizontal and vertical scroll targets |
---|
65 | |
---|
66 | return false; |
---|
67 | }); |
---|
68 | |
---|
69 | jQuery("form[name=add_birthdate]").submit(function(){ |
---|
70 | jQuery("form[name=add_birthdate] .error").hide(); |
---|
71 | var nb_errors = 0; |
---|
72 | |
---|
73 | if ("" == jQuery("#who").val()) { |
---|
74 | jQuery("#whoError").show(); |
---|
75 | nb_errors++; |
---|
76 | } |
---|
77 | |
---|
78 | if ("" == jQuery("#birthdateSelect").val()) { |
---|
79 | jQuery("#birthdateError").show(); |
---|
80 | nb_errors++; |
---|
81 | } |
---|
82 | |
---|
83 | if (nb_errors > 0) { |
---|
84 | return false; |
---|
85 | } |
---|
86 | }); |
---|
87 | |
---|
88 | }); |
---|
89 | {/footer_script} |
---|
90 | |
---|
91 | {html_style}{literal} |
---|
92 | form fieldset p {text-align:left;margin:0 0 1.5em 0;line-height:20px;} |
---|
93 | .rowSelected {background-color:#C2F5C2 !important} |
---|
94 | form .error {display:none; color:red;} |
---|
95 | .birthdateActions {text-align:center;} |
---|
96 | .birthdateActions a:hover {border:none} |
---|
97 | .ui-datepicker-current {display:none} |
---|
98 | |
---|
99 | #editLegend {display:none} |
---|
100 | .birthdateActions a {display:inline-block;} |
---|
101 | .birthdateActions a:hover {text-decoration:none;} |
---|
102 | {/literal}{/html_style} |
---|
103 | |
---|
104 | <div class="titrePage"> |
---|
105 | <h2>{'Manage birthdates'|@translate}</h2> |
---|
106 | </div> |
---|
107 | |
---|
108 | <p style="text-align:left;margin:0 1em;"> |
---|
109 | <a id="displayForm" href="#">{'Add a birthdate'|@translate}</a> |
---|
110 | </p> |
---|
111 | |
---|
112 | <form method="post" name="add_birthdate" action="{$F_ADD_ACTION}" style="display:none"> |
---|
113 | <fieldset> |
---|
114 | <legend> |
---|
115 | <span id="editLegend">{'Edit a birthdate'|@translate}</span> |
---|
116 | <span id="addLegend">{'Add a birthdate'|@translate}</span> |
---|
117 | </legend> |
---|
118 | |
---|
119 | <p> |
---|
120 | <strong>{'Who?'|@translate}</strong> |
---|
121 | <br> |
---|
122 | <select id="who" name="who" data-placeholder="{'Select a tag'|@translate}"> |
---|
123 | <option value=""></option> |
---|
124 | {foreach from=$tags item=tag} |
---|
125 | <option value="{$tag.id}">{$tag.name}</option> |
---|
126 | {/foreach} |
---|
127 | </select> |
---|
128 | <span class="error" id="whoError">✘ {'Select a tag'|@translate}</span> |
---|
129 | </p> |
---|
130 | |
---|
131 | <p> |
---|
132 | <strong>{'Birthdate'|@translate}</strong> |
---|
133 | <br> |
---|
134 | <input type="text" id="birthdateSelect" name="birthdate" style="width:120px;" value="{$BIRTHDATE}"> |
---|
135 | <span class="error" id="birthdateError">✘ {'Select a birthdate'|@translate}</span> |
---|
136 | </p> |
---|
137 | |
---|
138 | <p style="margin:0;"> |
---|
139 | <input class="submit" type="submit" name="submit_add" value="{'Submit'|@translate}"/> |
---|
140 | <a href="#" id="cancelBirthdate">{'Cancel'|@translate}</a> |
---|
141 | </p> |
---|
142 | </fieldset> |
---|
143 | </form> |
---|
144 | |
---|
145 | <table id="birthdateList" class="table2" style="margin:1em;"> |
---|
146 | <tr class="throw"> |
---|
147 | <th>{'Who?'|@translate} ({'Tag'|@translate})</th> |
---|
148 | <th>{'Birthdate'|@translate}</th> |
---|
149 | <th>{'Photos'|@translate}</th> |
---|
150 | <th>{'Actions'|@translate}</th> |
---|
151 | </tr> |
---|
152 | {if not empty($birthdates)} |
---|
153 | {foreach from=$birthdates item=birthdate name=birthdate_loop} |
---|
154 | <tr class="{if $smarty.foreach.birthdate_loop.index is odd}row1{else}row2{/if}{if $birthdate.HIGHLIGHT} rowSelected{/if}"> |
---|
155 | <td>{$birthdate.NAME}</td> |
---|
156 | <td>{$birthdate.BIRTHDATE}</td> |
---|
157 | <td>{$birthdate.PHOTOS}</td> |
---|
158 | <td class="birthdateActions"> |
---|
159 | <a href="#" class="editBirthdate icon-pencil" data-tag_id="{$birthdate.TAG_ID}" data-birthdate="{$birthdate.BIRTHDATE_RAW}" title="{'edit'|@translate}"></a> |
---|
160 | <a href="{$birthdate.U_DELETE}" onclick="return confirm( document.getElementById('btn_delete{$birthdate.TAG_ID}').title + '\n\n' + '{'Are you sure?'|@translate|@escape:'javascript'}');" class="icon-trash" title="{'Delete birthdate for %s'|@translate|@sprintf:$birthdate.NAME}"></a> |
---|
161 | </td> |
---|
162 | </tr> |
---|
163 | {/foreach} |
---|
164 | {/if} |
---|
165 | </table> |
---|