1 $.fn.realVal = function() { |
1 $.fn.realVal = function() { |
2 var obj = $(this[0]); |
2 var obj = $(this[0]); |
3 if(obj.val) { |
3 if(obj.val) { |
4 if(obj.val() == obj.attr('defaultText')) { |
4 if(obj.val() == obj.attr('defaultText')) { |
5 return ''; |
5 return ''; |
6 } |
6 } |
7 else { |
7 else { |
8 return obj.val(); |
8 return obj.val(); |
9 } |
9 } |
10 } |
10 } |
11 else { |
11 else { |
12 return null; |
12 return null; |
13 } |
13 } |
14 }; |
14 }; |
15 |
15 |
16 |
16 |
17 function init_events_base(base_node, embed_url) { |
17 function init_events_base(base_node, embed_url) { |
|
18 |
|
19 $('.ldt_link_embed',base_node).click(function(e) { |
|
20 e.preventDefault(); |
|
21 var link = $(e.target); |
|
22 var json_url = link.attr("href"); |
|
23 var player_id = link.attr("id"); |
|
24 var ldt_id = player_id.substring(15); |
|
25 $('<a />', { |
|
26 href: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id)+'&ldt_id='+escape(ldt_id), |
|
27 target: "_blank" |
|
28 }).nyroModal({ |
|
29 filters: ['iframe'], |
|
30 sizes: { |
|
31 minW: '750', |
|
32 minH: '662' |
|
33 }, |
|
34 callbacks: { |
|
35 afterShowCont: function(nm) { |
|
36 nm.store.iframe.height(662); |
|
37 nm.store.iframe.width(750); |
|
38 } |
|
39 } |
|
40 }).trigger('nyroModal'); |
|
41 return false; |
|
42 }); |
|
43 |
|
44 |
|
45 $('.imageline',base_node).each(function(i) { |
|
46 var tr = $(this); |
|
47 tr.mouseover(function() { |
|
48 $('.cellimgdiv',this).css('visibility', 'visible'); |
|
49 }); |
|
50 tr.mouseout(function() { |
|
51 $('.cellimgdiv',this).css('visibility', 'hidden'); |
|
52 }); |
|
53 }); |
|
54 |
|
55 $('.cellimgdiv img').qtip({ |
|
56 style: { |
|
57 'name': 'dark', |
|
58 'filter':'alpha(opacity=70)', |
|
59 '-moz-opacity':'0.7', |
|
60 '-khtml-opacity': '0.7', |
|
61 'opacity': '0.7', |
|
62 'border': { |
|
63 'width' : '0', |
|
64 'color': '#505050' |
|
65 }, |
|
66 'tip': true |
|
67 } |
|
68 }); |
|
69 |
|
70 |
|
71 }; |
|
72 |
|
73 function testAndClose(old_close) { |
18 |
74 |
19 $('.ldt_link_embed',base_node).click(function(e) { |
75 return function(force) { |
20 e.preventDefault(); |
76 // Here we ask LDT if the current work is modified and if the user want to save it. |
21 var link = $(e.target); |
77 var ldtSwf = $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0); |
22 var json_url = link.attr("href"); |
78 // In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test. |
23 var player_id = link.attr("id"); |
79 if (!force && ldtSwf && ldtSwf.name=="ldtInitSwf" && ldtSwf.isModified()=="true") { |
24 var ldt_id = player_id.substring(15); |
80 ldtSwf.askSave(); |
25 $('<a />', { |
81 } |
26 href: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id)+'&ldt_id='+escape(ldt_id), |
82 else { |
27 target: "_blank" |
83 old_close.apply(this); |
28 }).nyroModal({ |
84 } |
29 filters: ['iframe'], |
85 }; |
30 sizes: { |
86 } |
31 minW: '750', |
87 |
32 minH: '662' |
88 |
33 }, |
89 function searchCallback(target, container_selector, url, timeout) { |
34 callbacks: { |
90 |
35 afterShowCont: function(nm) { |
91 timeout = typeof(timeout) != 'undefined' ? timeout : 0; |
36 nm.store.iframe.height(662); |
92 var target = $(target); |
37 nm.store.iframe.width(750); |
93 |
38 } |
94 // remove all qtip |
39 } |
95 $(".qtip").remove(); |
40 }).trigger('nyroModal'); |
96 |
41 return false; |
97 if(target.realVal().length > 0) { |
42 }); |
98 target.nextAll(".searchclear").show(); |
43 |
99 } |
44 |
100 |
45 $('.imageline',base_node).each(function(i) { |
101 if(target.attr('timer')) { |
46 var tr = $(this); |
102 clearTimeout(target.attr('timer')); |
47 tr.mouseover(function() { |
103 } |
48 $('.cellimgdiv',this).css('visibility', 'visible'); |
104 |
49 }); |
105 target.attr( |
50 tr.mouseout(function() { |
106 'timer', |
51 $('.cellimgdiv',this).css('visibility', 'hidden'); |
107 setTimeout(function() { |
52 }); |
108 target.next(".searchajaxloader").show(); |
53 }); |
109 target.nextAll(".searchclear").hide(); |
54 |
110 var filterVal = "_" + escape(target.realVal()); |
55 $('.cellimgdiv img').qtip({ |
111 url = url.replace('__FILTER__',filterVal); |
56 style: { |
112 $.ajax({ |
57 'name': 'dark', |
113 url: url, |
58 'filter':'alpha(opacity=70)', |
114 cache: false, |
59 '-moz-opacity':'0.7', |
115 success: function(data, status, request) { |
60 '-khtml-opacity': '0.7', |
116 $(container_selector).html(data); |
61 'opacity': '0.7', |
117 target.next(".searchajaxloader").hide(); |
62 'border': { |
118 if(target.realVal().length > 0) { |
63 'width' : '0', |
119 target.nextAll(".searchclear").show(); |
64 'color': '#505050' |
120 } |
65 }, |
121 init_events($(container_selector)); |
66 'tip': true |
122 target.removeAttr('timer'); |
67 } |
123 } |
68 }); |
124 }); |
69 |
125 }, |
70 |
126 300) |
|
127 ); |
71 }; |
128 }; |
72 |
129 |
73 function testAndClose() { |
|
74 // Here we ask LDT if the current work is modified and if the user want to save it. |
|
75 var ldtSwf = $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0); |
|
76 // In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test. |
|
77 if (ldtSwf) { |
|
78 if (ldtSwf.name=="ldtInitSwf") { |
|
79 if(ldtSwf.isModified()=="true") { |
|
80 //ldtSwf.forceSave(); |
|
81 ldtSwf.askSave(); |
|
82 } |
|
83 else{ |
|
84 forceModalClose(); |
|
85 } |
|
86 } |
|
87 else{ |
|
88 forceModalClose(); |
|
89 } |
|
90 } |
|
91 else{ |
|
92 forceModalClose(); |
|
93 } |
|
94 } |
|
95 |
|
96 |
|
97 function searchCallback(target, container_selector, url, timeout) { |
|
98 |
|
99 timeout = typeof(timeout) != 'undefined' ? timeout : 0; |
|
100 var target = $(target); |
|
101 |
|
102 // remove all qtip |
|
103 $(".qtip").remove(); |
|
104 |
|
105 if(target.realVal().length > 0) { |
|
106 target.nextAll(".searchclear").show(); |
|
107 } |
|
108 |
|
109 if(target.attr('timer')) { |
|
110 clearTimeout(target.attr('timer')); |
|
111 } |
|
112 |
|
113 target.attr( |
|
114 'timer', |
|
115 setTimeout(function() { |
|
116 target.next(".searchajaxloader").show(); |
|
117 target.nextAll(".searchclear").hide(); |
|
118 var filterVal = "_" + escape(target.realVal()); |
|
119 url = url.replace('__FILTER__',filterVal); |
|
120 $.ajax({ |
|
121 url: url, |
|
122 cache: false, |
|
123 success: function(data, status, request) { |
|
124 $(container_selector).html(data); |
|
125 target.next(".searchajaxloader").hide(); |
|
126 if(target.realVal().length > 0) { |
|
127 target.nextAll(".searchclear").show(); |
|
128 } |
|
129 init_events($(container_selector)); |
|
130 target.removeAttr('timer'); |
|
131 } |
|
132 }); |
|
133 }, |
|
134 300) |
|
135 ); |
|
136 }; |
|
137 |
|
138 |
130 |
139 function init_events_contents(base_node, embed_url, content_filter_url) { |
131 function init_events_contents(base_node, embed_url, content_filter_url) { |
140 |
132 |
141 init_events_base(base_node, embed_url); |
133 init_events_base(base_node, embed_url); |
142 |
134 |
143 $('.content_link_create').each(function(i){ |
135 $('.content_link_create').each(function(i){ |
144 $(this).attr("target","_blank"); |
136 $(this).attr("target","_blank"); |
145 }); |
137 }); |
146 $('.content_link_create').nyroModal({ |
138 $('.content_link_create').nyroModal({ |
147 filters: ['iframe'], |
139 filters: ['iframe'], |
148 sizes: { |
140 sizes: { |
149 minW: 770, |
141 minW: 770, |
150 minH: 500 |
142 minH: 500 |
151 }, |
143 }, |
152 callbacks: { |
144 callbacks: { |
153 afterClose: function(nm) { |
145 afterClose: function(nm) { |
154 searchCallback($('#searchprojectsinput'), "#contentslistcontainer", content_filter_url); |
146 searchCallback($('#searchprojectsinput'), "#contentslistcontainer", content_filter_url); |
155 }, |
147 }, |
156 afterShowCont: function(nm) { |
148 afterShowCont: function(nm) { |
157 nm.store.iframe.width(770); |
149 nm.store.iframe.width(770); |
158 nm.store.iframe.height(500); |
150 nm.store.iframe.height(500); |
159 nm.store.iframe.load(function() { |
151 nm.store.iframe.load(function() { |
160 var form_status = $(this).contents().find("#content_form_status").val(); |
152 var form_status = $(this).contents().find("#content_form_status").val(); |
161 if(form_status == 'saved' || form_status == 'deleted' ) { |
153 if(form_status == 'saved' || form_status == 'deleted' ) { |
162 $.nmTop().close(); |
154 $.nmTop().close(); |
163 } |
155 } |
164 }); |
156 }); |
165 } |
157 } |
166 } |
158 } |
167 }); |
159 }); |
168 |
160 |
169 $('.contenttitlelink').each(function(i){ |
161 $('.contenttitlelink').each(function(i){ |
170 $(this).attr("target","_blank"); |
162 $(this).attr("target","_blank"); |
171 }); |
163 }); |
172 $('.contenttitlelink').nyroModal({ |
164 $('.contenttitlelink').nyroModal({ |
173 filters: ['iframe'], |
165 filters: ['iframe'], |
174 sizes: { |
166 sizes: { |
175 minW: 770, |
167 minW: 770, |
176 minH: 500 |
168 minH: 500 |
177 }, |
169 }, |
178 callbacks: { |
170 callbacks: { |
179 afterClose: function(nm) { |
171 afterClose: function(nm) { |
180 searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0); |
172 searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0); |
181 }, |
173 }, |
182 afterShowCont: function(nm) { |
174 afterShowCont: function(nm) { |
183 nm.store.iframe.width(770); |
175 nm.store.iframe.width(770); |
184 nm.store.iframe.height(500); |
176 nm.store.iframe.height(500); |
185 nm.store.iframe.load(function() { |
177 nm.store.iframe.load(function() { |
186 var form_status = $(this).contents().find("#content_form_status").val(); |
178 var form_status = $(this).contents().find("#content_form_status").val(); |
187 if(form_status == 'saved' || form_status == 'deleted') { |
179 if(form_status == 'saved' || form_status == 'deleted') { |
188 $.nmTop().close(); |
180 $.nmTop().close(); |
189 } |
181 } |
190 }); |
182 }); |
191 } |
183 } |
192 } |
184 } |
193 }); |
185 }); |
194 } |
186 } |
195 |
187 |
196 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
188 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
197 |
189 |
198 // These are the functions called when we display a project in an LDT modal window |
190 // These are the functions called when we display a project in an LDT modal window |
199 $('.ldt_link',base_node).each(function(i){ |
191 $('.ldt_link',base_node).each(function(i){ |
200 $(this).attr("target","_iri"); |
192 $(this).attr("target","_iri"); |
201 }); |
193 }); |
202 $('.ldt_link',base_node).nyroModal({ |
194 $('.ldt_link',base_node).nyroModal({ |
203 filters: ['iriIframe'], |
195 filters: ['iriIframe'], |
204 sizes: { |
196 sizes: { |
205 minW: '1022', |
197 minW: '1022', |
206 minH: '662' |
198 minH: '662' |
207 }, |
199 }, |
208 showCloseButton: true, |
200 showCloseButton: true, |
209 closeOnEscape:false, |
201 closeOnEscape:false, |
210 closeOnClick:false, |
202 closeOnClick:false, |
211 callbacks: { |
203 callbacks: { |
212 afterShowCont: function(nm) { |
204 afterShowCont: function(nm) { |
213 nm.store.iframe.height(662); |
205 nm.store.iframe.height(662); |
214 nm.store.iframe.width(1022); |
206 nm.store.iframe.width(1022); |
215 }, |
207 }, |
216 close: function(nm) { |
208 close: function(nm) { |
217 // We don't do anything here, we hack the callback directly from the close function. |
209 // We don't do anything here, we hack the callback directly from the close function. |
218 }, |
210 }, |
219 afterClose: function(nm) { |
211 afterClose: function(nm) { |
220 // Can't do that because searchprojectfilterurl is not defined in init_events_base params |
212 // Can't do that because searchprojectfilterurl is not defined in init_events_base params |
221 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
213 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
222 } |
214 } |
223 }, |
215 }, |
224 close:function(nm){ |
216 }); |
225 testAndClose(); |
217 |
226 } |
218 $('.ldt_link',base_node).each(function(i, e) { |
227 }); |
219 nm = $(e).data('nmObj'); |
228 |
220 $(e).data('nmObj', $.extend(true, nm, { |
229 |
221 close: testAndClose(nm.close) |
230 $('.ldt_link_create',base_node).each(function(i){ |
222 })); |
231 $(this).attr("target","_iri"); |
223 }); |
232 }); |
224 |
233 $('.ldt_link_create',base_node).nyroModal({ |
225 |
234 |
226 $('.ldt_link_create',base_node).each(function(i){ |
235 filters: ['iriIframe'], |
227 $(this).attr("target","_iri"); |
236 sizes: { |
228 }); |
237 minW: '600', |
229 $('.ldt_link_create',base_node).nyroModal({ |
238 minH: '500' |
230 |
239 }, |
231 filters: ['iriIframe'], |
240 showCloseButton:true, |
232 sizes: { |
241 closeOnEscape:false, |
233 minW: '600', |
242 closeOnClick:false, |
234 minH: '500' |
243 callbacks: { |
235 }, |
244 afterShowCont: function(nm) { |
236 showCloseButton:true, |
245 nm.store.iframe.width(600); |
237 closeOnEscape:false, |
246 nm.store.iframe.height(500); |
238 closeOnClick:false, |
247 var iframe = nm.store.iframe; |
239 callbacks: { |
248 iframe.load(function(){ |
240 afterShowCont: function(nm) { |
249 var form_status = $(this).contents().find("#project_form_status").val(); |
241 nm.store.iframe.width(600); |
250 if(form_status == 'saved' || form_status == 'deleted' ) { |
242 nm.store.iframe.height(500); |
251 $.nmTop().close(); |
243 var iframe = nm.store.iframe; |
252 } |
244 iframe.load(function(){ |
253 var swfobject = $(this).contents().find("#ldtInitSwf"); |
245 var form_status = $(this).contents().find("#project_form_status").val(); |
254 if (swfobject.length) { |
246 if(form_status == 'saved' || form_status == 'deleted' ) { |
255 nm['sizes']['initW'] = swfobject.width() + 21; |
247 $.nmTop().close(); |
256 nm['sizes']['initH'] = swfobject.height() + 31; |
248 } |
257 nm.resize(); |
249 var swfobject = $(this).contents().find("#ldtInitSwf"); |
258 nm.store.iframe.height(swfobject.height() + 31); |
250 if (swfobject.length) { |
259 nm.store.iframe.width(swfobject.width() + 21); |
251 nm['sizes']['initW'] = swfobject.width() + 21; |
260 } |
252 nm['sizes']['initH'] = swfobject.height() + 31; |
261 }); |
253 nm.resize(); |
262 }, |
254 nm.store.iframe.height(swfobject.height() + 31); |
263 afterClose: function(nm) { |
255 nm.store.iframe.width(swfobject.width() + 21); |
264 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
256 } |
265 } |
257 }); |
266 }, |
258 }, |
267 close:function(){ |
259 afterClose: function(nm) { |
268 testAndClose(); |
260 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
269 } |
261 } |
270 |
262 } |
271 }); |
263 }); |
272 |
264 $('.ldt_link_create',base_node).each(function(i, e) { |
273 |
265 nm = $(e).data('nmObj'); |
274 $('.publishedproject', base_node).click(function(e) { |
266 $(e).data('nmObj', $.extend(true, nm, { |
275 e.preventDefault(); |
267 close: testAndClose(nm.close) |
276 var target = $(e.target); |
268 })); |
277 var project_id = target.attr('id').replace('project_',''); |
269 }); |
278 var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id); |
270 |
279 $.ajax({ |
271 |
280 url: url, |
272 $('.publishedproject', base_node).click(function(e) { |
281 type: 'POST', |
273 e.preventDefault(); |
282 dataType: 'json', |
274 var target = $(e.target); |
283 success: function(json, textStatus, XMLHttpRequest){ |
275 var project_id = target.attr('id').replace('project_',''); |
284 if(json.res) { |
276 var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id); |
285 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
277 $.ajax({ |
286 } |
278 url: url, |
287 } |
279 type: 'POST', |
288 }); |
280 dataType: 'json', |
289 }); |
281 success: function(json, textStatus, XMLHttpRequest){ |
290 |
282 if(json.res) { |
291 $('.unpublishedproject', base_node).click(function(e) { |
283 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
292 e.preventDefault(); |
284 } |
293 var target = $(e.target); |
285 } |
294 var project_id = target.attr('id').replace('project_',''); |
286 }); |
295 var url = publishprojecturl.replace('__PROJECT_ID__', project_id); |
287 }); |
296 $.ajax({ |
288 |
297 url: url, |
289 $('.unpublishedproject', base_node).click(function(e) { |
298 type: 'POST', |
290 e.preventDefault(); |
299 dataType: 'json', |
291 var target = $(e.target); |
300 success: function(json, textStatus, XMLHttpRequest){ |
292 var project_id = target.attr('id').replace('project_',''); |
301 if(json.res) { |
293 var url = publishprojecturl.replace('__PROJECT_ID__', project_id); |
302 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
294 $.ajax({ |
303 } |
295 url: url, |
304 } |
296 type: 'POST', |
305 }); |
297 dataType: 'json', |
306 }); |
298 success: function(json, textStatus, XMLHttpRequest){ |
307 |
299 if(json.res) { |
308 $('.projecttitlelink').each(function(i){ |
300 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
309 $(this).attr("target","_blank"); |
301 } |
310 }); |
302 } |
311 $('.projecttitlelink').nyroModal({ |
303 }); |
312 filters: ['iframe'], |
304 }); |
313 sizes: { |
305 |
314 minH:680, |
306 $('.projecttitlelink').each(function(i){ |
315 minW:500 |
307 $(this).attr("target","_blank"); |
316 }, |
308 }); |
317 callbacks: { |
309 $('.projecttitlelink').nyroModal({ |
318 afterClose: function(nm) { |
310 filters: ['iframe'], |
319 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
311 sizes: { |
320 }, |
312 minH:680, |
321 afterShowCont: function(nm) { |
313 minW:500 |
322 nm.store.iframe.height(680); |
314 }, |
323 nm.store.iframe.width(600); |
315 callbacks: { |
324 var iframe = nm.store.iframe; |
316 afterClose: function(nm) { |
325 iframe.load(function(){ |
317 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
326 var form_status = $(this).contents().find("#project_form_status").val(); |
318 }, |
327 if(form_status == 'saved' || form_status == 'deleted') { |
319 afterShowCont: function(nm) { |
328 $.nmTop().close(); |
320 nm.store.iframe.height(680); |
329 } |
321 nm.store.iframe.width(600); |
330 }); |
322 var iframe = nm.store.iframe; |
331 } |
323 iframe.load(function(){ |
332 } |
324 var form_status = $(this).contents().find("#project_form_status").val(); |
333 }); |
325 if(form_status == 'saved' || form_status == 'deleted') { |
334 |
326 $.nmTop().close(); |
|
327 } |
|
328 }); |
|
329 } |
|
330 } |
|
331 }); |
|
332 |
335 } |
333 } |
336 |
334 |
337 function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
335 function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
338 |
336 |
339 init_events_base(base_node, embed_url); |
337 init_events_base(base_node, embed_url); |
340 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
338 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
341 } |
339 } |
342 |
340 |
343 function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
341 function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
344 |
342 |
345 init_events_contents(base_node, embed_url, searchcontentfilterurl); |
343 init_events_contents(base_node, embed_url, searchcontentfilterurl); |
346 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
344 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
347 } |
345 } |
348 |
346 |
349 |
347 |
350 |
348 |
351 function searchFieldInit(input_list_init) { |
349 function searchFieldInit(input_list_init) { |
352 |
350 |
353 $(".searchfieldinputbase").keydown(function (e) { |
351 $(".searchfieldinputbase").keydown(function (e) { |
354 if(e.which == 27) { |
352 if(e.which == 27) { |
355 $(e.target).blur(); |
353 $(e.target).blur(); |
356 $(e.target).next(".searchajaxloader").hide(); |
354 $(e.target).next(".searchajaxloader").hide(); |
357 } |
355 } |
358 }); |
356 }); |
359 |
357 |
360 $('.searchfieldinput').each(function(i) { |
358 $('.searchfieldinput').each(function(i) { |
361 var sbox = $(this); |
359 var sbox = $(this); |
362 if(sbox.val() != '') { |
360 if(sbox.val() != '') { |
363 sbox.attr('defaultText', sbox.val()); |
361 sbox.attr('defaultText', sbox.val()); |
364 } |
362 } |
365 |
363 |
366 sbox.focus(function() { |
364 sbox.focus(function() { |
367 box = $(this); |
365 box = $(this); |
368 if(box.val() == box.attr('defaultText')) { |
366 if(box.val() == box.attr('defaultText')) { |
369 box.val(''); |
367 box.val(''); |
370 box.toggleClass("searchfieldinput"); |
368 box.toggleClass("searchfieldinput"); |
371 } |
369 } |
372 }); |
370 }); |
373 |
371 |
374 sbox.blur(function() { |
372 sbox.blur(function() { |
375 var box = $(this); |
373 var box = $(this); |
376 if(box.val() == '' && box.attr('defaultText')) { |
374 if(box.val() == '' && box.attr('defaultText')) { |
377 box.val(box.attr('defaultText')); |
375 box.val(box.attr('defaultText')); |
378 box.toggleClass("searchfieldinput"); |
376 box.toggleClass("searchfieldinput"); |
379 } |
377 } |
380 }); |
378 }); |
381 |
379 |
382 }); |
380 }); |
383 |
381 |
384 $.each(input_list_init, function(index, value) { |
382 $.each(input_list_init, function(index, value) { |
385 $(value['input_selector']).keyup(function (e) { |
383 $(value['input_selector']).keyup(function (e) { |
386 searchCallback(e.target, value['container_selector'], value['url']); |
384 searchCallback(e.target, value['container_selector'], value['url']); |
387 }); |
385 }); |
388 }); |
386 }); |
389 |
387 |
390 $('.searchclear').click(function(e) { |
388 $('.searchclear').click(function(e) { |
391 var box = $(e.target).parent().find("input"); |
389 var box = $(e.target).parent().find("input"); |
392 box.val(box.attr('defaultText')); |
390 box.val(box.attr('defaultText')); |
393 box.addClass("searchfieldinput"); |
391 box.addClass("searchfieldinput"); |
394 box.blur(); |
392 box.blur(); |
395 box.keyup(); |
393 box.keyup(); |
396 }); |
394 }); |
397 |
395 |
398 $('.searchclear').each(function(i) { |
396 $('.searchclear').each(function(i) { |
399 $(this).hide(); |
397 $(this).hide(); |
400 }); |
398 }); |
401 |
399 |
402 } |
400 } |