1 | <div class="titrePage"> |
---|
2 | <h2>RV Autocomplete {$TABSHEET_TITLE}</h2> |
---|
3 | </div> |
---|
4 | |
---|
5 | <div id="acFormContainer" style="text-align:left"> |
---|
6 | <form> |
---|
7 | <table> |
---|
8 | <tr> |
---|
9 | <td> |
---|
10 | <label for=ac_name style="min-width:100px">Query:</label> |
---|
11 | </td> |
---|
12 | <td> |
---|
13 | <input id="ac_name" type="text" size="48"> |
---|
14 | </td> |
---|
15 | </tr> |
---|
16 | <tr> |
---|
17 | <td colspan=2> |
---|
18 | <small>Use <b>\</b> to break search (e.g. Central Park\, NY will not match NY but it will display it) |
---|
19 | </small> |
---|
20 | </td> |
---|
21 | </tr> |
---|
22 | |
---|
23 | |
---|
24 | <tr> |
---|
25 | <td> |
---|
26 | <label for=ac_counter>Weight:</label> |
---|
27 | </td> |
---|
28 | <td> |
---|
29 | <input id="ac_counter" type="text" size="3"> |
---|
30 | </td> |
---|
31 | </tr> |
---|
32 | |
---|
33 | <tr> |
---|
34 | <td> |
---|
35 | <label for=ac_url>Url:</label> |
---|
36 | </td> |
---|
37 | <td> |
---|
38 | <input id="ac_url" type="text" size="48"> |
---|
39 | </td> |
---|
40 | </tr> |
---|
41 | |
---|
42 | <tr> |
---|
43 | <td colspan=2> |
---|
44 | <small>Leave empty for automatic gallery search <br> |
---|
45 | OR enter an url ($r/ at the start of url means this gallery)<br> |
---|
46 | OR enter q=Term to search for a specific term |
---|
47 | </small> |
---|
48 | </td> |
---|
49 | </tr> |
---|
50 | </table> |
---|
51 | </form> |
---|
52 | </div> |
---|
53 | |
---|
54 | <p><a class="openAddNew">Create a new suggestion</a></p> |
---|
55 | <table id="csTable" class="table2"> |
---|
56 | <thead> |
---|
57 | <tr class="throw"> |
---|
58 | <th>Name</th> |
---|
59 | <th>Weight</th> |
---|
60 | <th>URL</th> |
---|
61 | <th>Actions</th> |
---|
62 | </tr> |
---|
63 | </thead> |
---|
64 | <tbody> |
---|
65 | </tbody> |
---|
66 | </table> |
---|
67 | |
---|
68 | <p><a class="openAddNew">Create a new suggestion</a></p> |
---|
69 | |
---|
70 | {include file='include/colorbox.inc.tpl'} |
---|
71 | |
---|
72 | {combine_css path="themes/default/js/ui/theme/jquery.ui.core.css"} |
---|
73 | {combine_css path="themes/default/js/ui/theme/jquery.ui.button.css"} |
---|
74 | {combine_css path="themes/default/js/ui/theme/jquery.ui.dialog.css"} |
---|
75 | {combine_css path="themes/default/js/ui/theme/jquery.ui.theme.css"} |
---|
76 | |
---|
77 | {combine_script id="jquery.ui.dialog" load="footer" require="jquery.ui.button"} |
---|
78 | {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} |
---|
79 | |
---|
80 | |
---|
81 | {combine_script id="jquery.dataTables" load="footer" path="plugins/`$RVAC_ID`/admin/res/jquery.dataTables.js"} |
---|
82 | |
---|
83 | |
---|
84 | {html_style}{literal} |
---|
85 | .ui-accordion-header-icon {display: none} |
---|
86 | |
---|
87 | .dtBar { |
---|
88 | text-align: right; |
---|
89 | } |
---|
90 | |
---|
91 | .dtBar DIV { |
---|
92 | display: inline; |
---|
93 | padding-right: 10px; |
---|
94 | } |
---|
95 | |
---|
96 | #csTable_filter { |
---|
97 | display: block; |
---|
98 | float: left; |
---|
99 | padding-left: 10px; |
---|
100 | } |
---|
101 | |
---|
102 | .dataTables_paginate A { |
---|
103 | padding-left: 3px; |
---|
104 | } |
---|
105 | |
---|
106 | #csTable TH { |
---|
107 | cursor: pointer; |
---|
108 | } |
---|
109 | |
---|
110 | .sorting_asc:after { content: " \2193" } |
---|
111 | .sorting_desc:after { content: " \2191" } |
---|
112 | {/literal}{/html_style} |
---|
113 | |
---|
114 | {footer_script} |
---|
115 | var iniDatas = [ |
---|
116 | {foreach from=$suggestions item=s name=sloop} |
---|
117 | {ldelim}id:{$s.id},name:"{$s.name|@escape:javascript}",counter:{$s.counter},url:"{$s.url|@escape:javascript}",U_LINK:"{$s.U_LINK|@escape:javascript}"{rdelim}{if !$smarty.foreach.sloop.last},{/if} |
---|
118 | {/foreach} |
---|
119 | ]; |
---|
120 | var SHelper = {ldelim} |
---|
121 | {literal} |
---|
122 | |
---|
123 | buildRowData: function(item) { |
---|
124 | var rowData = []; |
---|
125 | rowData.push(item.name); |
---|
126 | rowData.push(item.counter); |
---|
127 | rowData.push( "<a href=\""+item.U_LINK+"\" onclick=\"return SHelper.zoom(this.href)\">" |
---|
128 | + (item.url ? item.url : "show" ) |
---|
129 | + "</a>" |
---|
130 | ); |
---|
131 | rowData.push("<a href=\"\" onclick=\"return SHelper.del(this)\">Delete</a>" |
---|
132 | + " <a href=\"\" onclick=\"return SHelper.edit(this)\">Edit</a>" |
---|
133 | ); |
---|
134 | return rowData; |
---|
135 | }, |
---|
136 | |
---|
137 | buildRow: function(item) { |
---|
138 | var rd = SHelper.buildRowData(item) |
---|
139 | , row = "<tr>"; |
---|
140 | |
---|
141 | for (var i =0; i<rd.length; i++) |
---|
142 | row += "<td>"+rd[i]+"</td>"; |
---|
143 | |
---|
144 | row += "</tr>"; |
---|
145 | |
---|
146 | return $(row).data("ac", item) |
---|
147 | }, |
---|
148 | |
---|
149 | rowFromNode: function(node) { |
---|
150 | return $(node).parents("tr"); |
---|
151 | }, |
---|
152 | |
---|
153 | zoom: function(url){ |
---|
154 | jQuery.colorbox( { |
---|
155 | href: url, |
---|
156 | iframe: 1, |
---|
157 | width: "90%", height: "90%" |
---|
158 | }); |
---|
159 | return false; |
---|
160 | }, |
---|
161 | |
---|
162 | del: function(node){ |
---|
163 | if (!confirm("Are you sure?")) return false; |
---|
164 | var row = SHelper.rowFromNode(node) |
---|
165 | , item=row.data("ac"); |
---|
166 | |
---|
167 | row.fadeTo(500, 0.4); |
---|
168 | (new PwgWS("")).callService( |
---|
169 | "rvac.delCustom", {id: item.id} , |
---|
170 | { |
---|
171 | method: "POST", |
---|
172 | onFailure: function(num, text) { row.stop(); row.fadeTo(0,1); alert(num + " " + text); }, |
---|
173 | onSuccess: function(result) { |
---|
174 | // row.remove(); |
---|
175 | dataTable.fnDeleteRow( row[0] ); |
---|
176 | } |
---|
177 | } |
---|
178 | ); |
---|
179 | |
---|
180 | return false; |
---|
181 | }, |
---|
182 | |
---|
183 | add: function() { |
---|
184 | $("#ac_name,#ac_counter,#ac_url").val( "" ); |
---|
185 | $("#acFormContainer") |
---|
186 | .dialog("option", "buttons", [{text: "Create", click: function() { |
---|
187 | (new PwgWS("")).callService( |
---|
188 | "rvac.addCustom", { name:$("#ac_name").val(), counter:$("#ac_counter").val(), url:$("#ac_url").val() }, |
---|
189 | { |
---|
190 | method: "POST", |
---|
191 | onFailure: function(num, text) { |
---|
192 | alert(num + " " + text); |
---|
193 | }, |
---|
194 | onSuccess: function(result) { |
---|
195 | //$("#csTable").append( SHelper.buildRow(result) ); |
---|
196 | var rd = SHelper.buildRowData(result); |
---|
197 | var node = dataTable.fnGetNodes( dataTable.fnAddData(rd)[0] ); |
---|
198 | $(node).data("ac", result); |
---|
199 | |
---|
200 | $("#ac_name,#ac_counter,#ac_url").val( "" ); |
---|
201 | } |
---|
202 | } |
---|
203 | ); |
---|
204 | } |
---|
205 | }, { text: "Close", click: function(){ $(this).dialog("close") }} ]) |
---|
206 | .dialog("open"); |
---|
207 | }, |
---|
208 | |
---|
209 | edit: function(node) { |
---|
210 | var row = SHelper.rowFromNode(node) |
---|
211 | , item=row.data("ac"); |
---|
212 | |
---|
213 | $("#ac_name").val( item.name ); |
---|
214 | $("#ac_counter").val( item.counter ); |
---|
215 | $("#ac_url").val( item.url ); |
---|
216 | |
---|
217 | $("#acFormContainer") |
---|
218 | .dialog("option", "buttons", [{text: "Modify", click: function() { |
---|
219 | (new PwgWS("")).callService( |
---|
220 | "rvac.modCustom", {id: item.id, name:$("#ac_name").val(), counter:$("#ac_counter").val(), url:$("#ac_url").val() }, |
---|
221 | { |
---|
222 | method: "POST", |
---|
223 | onFailure: function(num, text) { |
---|
224 | alert(num + " " + text); |
---|
225 | }, |
---|
226 | onSuccess: function(result) { |
---|
227 | /*row.after( SHelper.buildRow(result) ) |
---|
228 | .remove();*/ |
---|
229 | |
---|
230 | dataTable.fnUpdate(SHelper.buildRowData(result), row[0]); |
---|
231 | row.data("ac", result); |
---|
232 | |
---|
233 | $("#acFormContainer").dialog("close"); |
---|
234 | } |
---|
235 | } |
---|
236 | ); |
---|
237 | } |
---|
238 | }, { text: "Close", click: function(){ $(this).dialog("close") }} ]) |
---|
239 | .dialog("open"); |
---|
240 | |
---|
241 | return false; |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | $().ready( function() { |
---|
246 | var table = $("#csTable"); |
---|
247 | $.each(iniDatas, function(i, item) { |
---|
248 | table.append( SHelper.buildRow(item) ); |
---|
249 | }); |
---|
250 | dataTable = table.dataTable( { |
---|
251 | sDom : '<"dtBar"filp>rt<"dtBar"ilp>', |
---|
252 | iDisplayLength: 100, |
---|
253 | aoColumnDefs: [ |
---|
254 | { bSearchable: false, aTargets: [1,3] }, |
---|
255 | { bSortable: false, aTargets: [3] } |
---|
256 | ], |
---|
257 | asStripeClasses: ["row1", "row2"], |
---|
258 | bAutoWidth: false, |
---|
259 | aaSorting: [] |
---|
260 | }); |
---|
261 | |
---|
262 | $("#acFormContainer").dialog({ |
---|
263 | autoOpen: false, |
---|
264 | modal: true, |
---|
265 | width: "auto" |
---|
266 | }); |
---|
267 | $(".openAddNew").click( SHelper.add ).button(); |
---|
268 | |
---|
269 | $("tr", table).hover( |
---|
270 | function() { |
---|
271 | $(this).addClass("ui-state-highlight"); |
---|
272 | }, |
---|
273 | function() { |
---|
274 | $(this).removeClass("ui-state-highlight"); |
---|
275 | } |
---|
276 | ); |
---|
277 | }); |
---|
278 | {/literal} |
---|
279 | {/footer_script} |
---|