64 'color': '#505050' |
65 'color': '#505050' |
65 }, |
66 }, |
66 'tip': true |
67 'tip': true |
67 } |
68 } |
68 }); |
69 }); |
69 |
70 } |
70 |
|
71 }; |
|
72 |
71 |
73 function testAndClose(close_fn) { |
72 function testAndClose(close_fn) { |
74 |
73 |
75 return function(force) { |
74 return function(force) { |
76 // Here we ask LDT if the current work is modified and if the user want to save it. |
75 // Here we ask LDT if the current work is modified and if the user want to save it. |
77 var ldtSwf = $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0); |
76 var ldtSwf = $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0); |
78 // In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test. |
77 // In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test. |
79 if (!force && ldtSwf && ldtSwf.name=="ldtInitSwf" && ldtSwf.isModified()=="true") { |
78 if (!force && ldtSwf && ldtSwf.name==="ldtInitSwf" && ldtSwf.isModified()==="true") { |
80 ldtSwf.askSave(); |
79 ldtSwf.askSave(); |
81 } |
80 } |
82 else { |
81 else { |
83 close_fn.apply(this); |
82 close_fn.apply(this); |
84 } |
83 } |
85 }; |
84 }; |
86 } |
85 } |
87 |
86 |
88 |
87 |
89 function searchCallback(target, container_selector, url, timeout) { |
88 function searchCallback(target, container_selector, url, timeout) { |
90 |
89 |
91 timeout = typeof(timeout) != 'undefined' ? timeout : 0; |
90 timeout = typeof(timeout) !== 'undefined' ? timeout : 0; |
92 var target = $(target); |
91 target = $(target); |
93 |
92 |
94 // remove all qtip |
93 // remove all qtip |
95 $(".qtip").remove(); |
94 $(".qtip").remove(); |
96 |
95 |
97 if(target.realVal().length > 0) { |
96 if(target.realVal().length > 0) { |
123 } |
122 } |
124 }); |
123 }); |
125 }, |
124 }, |
126 300) |
125 300) |
127 ); |
126 ); |
128 }; |
127 } |
129 |
128 |
130 |
129 |
131 function init_events_contents(base_node, embed_url, content_filter_url) { |
130 function init_events_contents(base_node, embed_url, content_filter_url) { |
132 |
131 |
133 init_events_base(base_node, embed_url); |
132 init_events_base(base_node, embed_url); |
134 |
133 |
135 $('.content_link_create').each(function(i){ |
134 $('.content_link_create').each(function(i){ |
136 $(this).attr("target","_blank"); |
135 $(this).attr("target","_blank"); |
137 }); |
136 }); |
147 }, |
146 }, |
148 afterShowCont: function(nm) { |
147 afterShowCont: function(nm) { |
149 nm.store.iframe.width(770); |
148 nm.store.iframe.width(770); |
150 nm.store.iframe.height(500); |
149 nm.store.iframe.height(500); |
151 nm.store.iframe.load(function() { |
150 nm.store.iframe.load(function() { |
152 var form_status = $(this).contents().find("#content_form_status").val(); |
151 var form_status = $(this).contents().find("#content_form_status").val(); |
153 if(form_status == 'saved' || form_status == 'deleted' ) { |
152 if(form_status === 'saved' || form_status === 'deleted' ) { |
154 $.nmTop().close(); |
153 $.nmTop().close(); |
155 } |
154 } |
156 }); |
155 }); |
157 } |
156 } |
158 } |
157 } |
159 }); |
158 }); |
160 |
159 |
161 $('.contenttitlelink').each(function(i){ |
160 $('.contenttitlelink').each(function(i){ |
162 $(this).attr("target","_blank"); |
161 $(this).attr("target","_blank"); |
163 }); |
162 }); |
164 $('.contenttitlelink').nyroModal({ |
163 $('.contenttitlelink').nyroModal({ |
165 filters: ['iframe'], |
164 filters: ['iframe'], |
174 afterShowCont: function(nm) { |
173 afterShowCont: function(nm) { |
175 nm.store.iframe.width(770); |
174 nm.store.iframe.width(770); |
176 nm.store.iframe.height(500); |
175 nm.store.iframe.height(500); |
177 nm.store.iframe.load(function() { |
176 nm.store.iframe.load(function() { |
178 var form_status = $(this).contents().find("#content_form_status").val(); |
177 var form_status = $(this).contents().find("#content_form_status").val(); |
179 if(form_status == 'saved' || form_status == 'deleted') { |
178 if(form_status === 'saved' || form_status === 'deleted') { |
180 $.nmTop().close(); |
179 $.nmTop().close(); |
181 } |
180 } |
182 }); |
181 }); |
183 } |
182 } |
184 } |
183 } |
185 }); |
184 }); |
|
185 |
186 } |
186 } |
187 |
187 |
188 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) { |
189 |
189 |
190 // 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 |
211 afterClose: function(nm) { |
211 afterClose: function(nm) { |
212 // 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 |
213 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
213 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
214 } |
214 } |
215 }, |
215 }, |
216 }); |
216 resize: function(recalc) { |
|
217 // We need to hack resize AND _unreposition to avoid reload in the modal when we resize the browser. |
|
218 // This code is from the resize function in nmObj.resize |
|
219 this.sizes.w = this.sizes.initW; |
|
220 this.sizes.h = this.sizes.initH; |
|
221 this.size(); |
|
222 // callAnim('resize') generates the nodal reload, and we don't want that. |
|
223 // this._callAnim('resize', $.proxy(function() { |
|
224 // this._reposition(); |
|
225 // }, this)); |
|
226 // This code is from the resize function in _animations.basic |
|
227 this.elts.cont.css({ |
|
228 width: this.sizes.w, |
|
229 height: this.sizes.h, |
|
230 top: (this.getInternal().fullSize.viewH - this.sizes.h - this.sizes.hMargin)/2, |
|
231 left: (this.getInternal().fullSize.viewW - this.sizes.w - this.sizes.wMargin)/2 |
|
232 }); |
|
233 }, |
|
234 _unreposition: function() { |
|
235 // We need to hack resize AND _unreposition to avoid reload in the modal when we resize the browser. |
|
236 } |
|
237 }); |
|
238 |
217 |
239 |
218 $('.ldt_link',base_node).each(function(i, e) { |
240 $('.ldt_link',base_node).each(function(i, e) { |
219 nm = $(e).data('nmObj'); |
241 nm = $(e).data('nmObj'); |
220 $(e).data('nmObj', $.extend(true, nm, { |
242 $(e).data('nmObj', $.extend(true, nm, { |
221 close: testAndClose(nm.close) |
243 close: testAndClose(nm.close) |
222 })); |
244 })); |
223 }); |
245 }); |
224 |
246 |
225 |
247 |
226 $('.ldt_link_create',base_node).each(function(i){ |
248 $('.ldt_link_create',base_node).each(function(i){ |
227 $(this).attr("target","_iri"); |
249 $(this).attr("target","_iri"); |
241 nm.store.iframe.width(600); |
263 nm.store.iframe.width(600); |
242 nm.store.iframe.height(500); |
264 nm.store.iframe.height(500); |
243 var iframe = nm.store.iframe; |
265 var iframe = nm.store.iframe; |
244 iframe.load(function(){ |
266 iframe.load(function(){ |
245 var form_status = $(this).contents().find("#project_form_status").val(); |
267 var form_status = $(this).contents().find("#project_form_status").val(); |
246 if(form_status == 'saved' || form_status == 'deleted' ) { |
268 if(form_status === 'saved' || form_status === 'deleted' ) { |
247 $.nmTop().close(); |
269 $.nmTop().close(); |
248 } |
270 } |
249 var swfobject = $(this).contents().find("#ldtInitSwf"); |
271 var swfobject = $(this).contents().find("#ldtInitSwf"); |
250 if (swfobject.length) { |
272 if (swfobject.length) { |
251 nm['sizes']['initW'] = swfobject.width() + 21; |
273 nm['sizes']['initW'] = swfobject.width() + 21; |
258 }, |
280 }, |
259 afterClose: function(nm) { |
281 afterClose: function(nm) { |
260 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
282 searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
261 } |
283 } |
262 } |
284 } |
263 }); |
285 }); |
264 $('.ldt_link_create',base_node).each(function(i, e) { |
286 $('.ldt_link_create',base_node).each(function(i, e) { |
265 nm = $(e).data('nmObj'); |
287 nm = $(e).data('nmObj'); |
266 $(e).data('nmObj', $.extend(true, nm, { |
288 $(e).data('nmObj', $.extend(true, nm, { |
267 close: testAndClose(nm.close) |
289 close: testAndClose(nm.close) |
268 })); |
290 })); |
269 }); |
291 }); |
270 |
292 |
271 |
293 |
272 $('.publishedproject', base_node).click(function(e) { |
294 $('.publishedproject', base_node).click(function(e) { |
273 e.preventDefault(); |
295 e.preventDefault(); |
274 var target = $(e.target); |
296 var target = $(e.target); |
320 nm.store.iframe.height(680); |
342 nm.store.iframe.height(680); |
321 nm.store.iframe.width(600); |
343 nm.store.iframe.width(600); |
322 var iframe = nm.store.iframe; |
344 var iframe = nm.store.iframe; |
323 iframe.load(function(){ |
345 iframe.load(function(){ |
324 var form_status = $(this).contents().find("#project_form_status").val(); |
346 var form_status = $(this).contents().find("#project_form_status").val(); |
325 if(form_status == 'saved' || form_status == 'deleted') { |
347 if(form_status === 'saved' || form_status === 'deleted') { |
326 $.nmTop().close(); |
348 $.nmTop().close(); |
327 } |
349 } |
328 }); |
350 }); |
329 } |
351 } |
330 } |
352 } |
337 init_events_base(base_node, embed_url); |
359 init_events_base(base_node, embed_url); |
338 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
360 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
339 } |
361 } |
340 |
362 |
341 function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
363 function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
342 |
|
343 init_events_contents(base_node, embed_url, searchcontentfilterurl); |
364 init_events_contents(base_node, embed_url, searchcontentfilterurl); |
344 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
365 init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
345 } |
366 } |
346 |
|
347 |
|
348 |
367 |
349 function searchFieldInit(input_list_init) { |
368 function searchFieldInit(input_list_init) { |
350 |
369 |
351 $(".searchfieldinputbase").keydown(function (e) { |
370 $(".searchfieldinputbase").keydown(function (e) { |
352 if(e.which == 27) { |
371 if(e.which === 27) { |
353 $(e.target).blur(); |
372 $(e.target).blur(); |
354 $(e.target).next(".searchajaxloader").hide(); |
373 $(e.target).next(".searchajaxloader").hide(); |
355 } |
374 } |
356 }); |
375 }); |
357 |
376 |
358 $('.searchfieldinput').each(function(i) { |
377 $('.searchfieldinput').each(function(i) { |
359 var sbox = $(this); |
378 var sbox = $(this); |
360 if(sbox.val() != '') { |
379 if(sbox.val() !== '') { |
361 sbox.attr('defaultText', sbox.val()); |
380 sbox.attr('defaultText', sbox.val()); |
362 } |
381 } |
363 |
382 |
364 sbox.focus(function() { |
383 sbox.focus(function() { |
365 box = $(this); |
384 box = $(this); |
366 if(box.val() == box.attr('defaultText')) { |
385 if(box.val() === box.attr('defaultText')) { |
367 box.val(''); |
386 box.val(''); |
368 box.toggleClass("searchfieldinput"); |
387 box.toggleClass("searchfieldinput"); |
369 } |
388 } |
370 }); |
389 }); |
371 |
390 |
372 sbox.blur(function() { |
391 sbox.blur(function() { |
373 var box = $(this); |
392 var box = $(this); |
374 if(box.val() == '' && box.attr('defaultText')) { |
393 if(box.val() === '' && box.attr('defaultText')) { |
375 box.val(box.attr('defaultText')); |
394 box.val(box.attr('defaultText')); |
376 box.toggleClass("searchfieldinput"); |
395 box.toggleClass("searchfieldinput"); |
377 } |
396 } |
378 }); |
397 }); |
379 |
398 |