|
72
|
1 |
|
|
|
2 |
$.fn.realVal = function() { |
|
|
3 |
var obj = $(this[0]); |
|
|
4 |
if(obj.val) { |
|
|
5 |
if(obj.val() === obj.attr('defaultText')) { |
|
|
6 |
return ''; |
|
|
7 |
} |
|
|
8 |
else { |
|
|
9 |
return obj.val(); |
|
|
10 |
} |
|
|
11 |
} |
|
|
12 |
else { |
|
|
13 |
return null; |
|
|
14 |
} |
|
|
15 |
}; |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
function init_events_base(base_node, embed_url) { |
|
|
19 |
|
|
|
20 |
$('.ldt_link_embed',base_node).click(function(e) { |
|
|
21 |
e.preventDefault(); |
|
|
22 |
var link = $(e.target); |
|
|
23 |
var json_url = link.attr("href"); |
|
|
24 |
var player_id = link.attr("id"); |
|
|
25 |
var ldt_id = player_id.substring(15); |
|
|
26 |
$('<a />', { |
|
|
27 |
href: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id)+'&ldt_id='+escape(ldt_id), |
|
|
28 |
target: "_blank" |
|
|
29 |
}).nyroModal({ |
|
|
30 |
filters: ['iframe'], |
|
|
31 |
sizes: { |
|
|
32 |
minW: '750', |
|
|
33 |
minH: '662' |
|
|
34 |
}, |
|
|
35 |
callbacks: { |
|
|
36 |
afterShowCont: function(nm) { |
|
|
37 |
nm.store.iframe.height(662); |
|
|
38 |
nm.store.iframe.width(750); |
|
|
39 |
} |
|
|
40 |
} |
|
|
41 |
}).trigger('nyroModal'); |
|
|
42 |
return false; |
|
|
43 |
}); |
|
|
44 |
|
|
|
45 |
|
|
|
46 |
$('.imageline',base_node).each(function(i) { |
|
|
47 |
var tr = $(this); |
|
|
48 |
tr.mouseover(function() { |
|
|
49 |
$('.cellimgdiv',this).css('visibility', 'visible'); |
|
|
50 |
}); |
|
|
51 |
tr.mouseout(function() { |
|
|
52 |
$('.cellimgdiv',this).css('visibility', 'hidden'); |
|
|
53 |
}); |
|
|
54 |
}); |
|
|
55 |
|
|
|
56 |
$('.cellimgdiv img').qtip({ |
|
|
57 |
style: { |
|
|
58 |
'name': 'dark', |
|
|
59 |
'filter':'alpha(opacity=70)', |
|
|
60 |
'-moz-opacity':'0.7', |
|
|
61 |
'-khtml-opacity': '0.7', |
|
|
62 |
'opacity': '0.7', |
|
|
63 |
'border': { |
|
|
64 |
'width' : '0', |
|
|
65 |
'color': '#505050' |
|
|
66 |
}, |
|
|
67 |
'tip': true |
|
|
68 |
} |
|
|
69 |
}); |
|
|
70 |
} |
|
|
71 |
|
|
|
72 |
function testAndClose(close_fn) { |
|
|
73 |
|
|
|
74 |
return function(force) { |
|
|
75 |
// Here we ask LDT if the current work is modified and if the user want to save it. |
|
|
76 |
var ldtSwf = $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0); |
|
|
77 |
// In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test. |
|
|
78 |
if (!force && ldtSwf && ldtSwf.name==="ldtInitSwf" && ldtSwf.isModified()==="true") { |
|
|
79 |
ldtSwf.askSave(); |
|
|
80 |
} |
|
|
81 |
else { |
|
|
82 |
close_fn.apply(this); |
|
|
83 |
} |
|
|
84 |
}; |
|
|
85 |
} |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
function searchCallback(target, container_selector, url, timeout) { |
|
|
89 |
|
|
|
90 |
timeout = typeof(timeout) !== 'undefined' ? timeout : 0; |
|
|
91 |
target = $(target); |
|
|
92 |
|
|
|
93 |
// remove all qtip |
|
|
94 |
$(".qtip").remove(); |
|
|
95 |
|
|
|
96 |
if(target.realVal().length > 0) { |
|
|
97 |
target.nextAll(".searchclear").show(); |
|
|
98 |
} |
|
|
99 |
|
|
|
100 |
if(target.attr('timer')) { |
|
|
101 |
clearTimeout(target.attr('timer')); |
|
|
102 |
} |
|
|
103 |
|
|
|
104 |
target.attr( |
|
|
105 |
'timer', |
|
|
106 |
setTimeout(function() { |
|
|
107 |
target.next(".searchajaxloader").show(); |
|
|
108 |
target.nextAll(".searchclear").hide(); |
|
|
109 |
var filterVal = "_" + escape(target.realVal()); |
|
|
110 |
url = url.replace('__FILTER__',filterVal); |
|
|
111 |
$.ajax({ |
|
|
112 |
url: url, |
|
|
113 |
cache: false, |
|
|
114 |
success: function(data, status, request) { |
|
|
115 |
$(container_selector).html(data); |
|
|
116 |
target.next(".searchajaxloader").hide(); |
|
|
117 |
if(target.realVal().length > 0) { |
|
|
118 |
target.nextAll(".searchclear").show(); |
|
|
119 |
} |
|
|
120 |
init_events($(container_selector)); |
|
|
121 |
target.removeAttr('timer'); |
|
|
122 |
} |
|
|
123 |
}); |
|
|
124 |
}, |
|
|
125 |
300) |
|
|
126 |
); |
|
|
127 |
} |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
function init_events_contents(base_node, embed_url, content_filter_url) { |
|
|
131 |
|
|
|
132 |
init_events_base(base_node, embed_url); |
|
|
133 |
|
|
|
134 |
$('.content_link_create').each(function(i){ |
|
|
135 |
$(this).attr("target","_blank"); |
|
|
136 |
}); |
|
|
137 |
$('.content_link_create').nyroModal({ |
|
|
138 |
filters: ['iframe'], |
|
|
139 |
sizes: { |
|
|
140 |
minW: 770, |
|
|
141 |
minH: 550 |
|
|
142 |
}, |
|
|
143 |
callbacks: { |
|
|
144 |
afterClose: function(nm) { |
|
|
145 |
searchCallback($('#searchprojectsinput'), "#contentslistcontainer", content_filter_url); |
|
|
146 |
}, |
|
|
147 |
afterShowCont: function(nm) { |
|
|
148 |
nm.store.iframe.width(770); |
|
|
149 |
nm.store.iframe.height(550); |
|
|
150 |
nm.store.iframe.load(function() { |
|
|
151 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
|
152 |
if(form_status === 'saved' || form_status === 'deleted' ) { |
|
|
153 |
$.nmTop().close(); |
|
|
154 |
} |
|
|
155 |
}); |
|
|
156 |
} |
|
|
157 |
} |
|
|
158 |
}); |
|
|
159 |
|
|
|
160 |
$('.contenttitlelink').each(function(i){ |
|
|
161 |
$(this).attr("target","_blank"); |
|
|
162 |
}); |
|
|
163 |
$('.contenttitlelink').nyroModal({ |
|
|
164 |
filters: ['iframe'], |
|
|
165 |
sizes: { |
|
|
166 |
minW: 770, |
|
|
167 |
minH: 550 |
|
|
168 |
}, |
|
|
169 |
callbacks: { |
|
|
170 |
afterClose: function(nm) { |
|
|
171 |
searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0); |
|
|
172 |
}, |
|
|
173 |
afterShowCont: function(nm) { |
|
|
174 |
nm.store.iframe.width(770); |
|
|
175 |
nm.store.iframe.height(550); |
|
|
176 |
nm.store.iframe.load(function() { |
|
|
177 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
|
178 |
if(form_status === 'saved' || form_status === 'deleted') { |
|
|
179 |
$.nmTop().close(); |
|
|
180 |
} |
|
|
181 |
}); |
|
|
182 |
} |
|
|
183 |
} |
|
|
184 |
}); |
|
|
185 |
|
|
|
186 |
} |
|
|
187 |
|
|
|
188 |
function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
|
189 |
|
|
|
190 |
// These are the functions called when we display a project in an LDT modal window |
|
|
191 |
$('.ldt_link',base_node).each(function(i){ |
|
|
192 |
$(this).attr("target","_iri"); |
|
|
193 |
}); |
|
|
194 |
$('.ldt_link',base_node).nyroModal({ |
|
|
195 |
filters: ['iriIframe'], |
|
|
196 |
sizes: { |
|
|
197 |
minW: '1025', |
|
|
198 |
minH: '665' |
|
|
199 |
}, |
|
|
200 |
showCloseButton: true, |
|
|
201 |
closeOnEscape:false, |
|
|
202 |
closeOnClick:false, |
|
|
203 |
callbacks: { |
|
|
204 |
afterShowCont: function(nm) { |
|
|
205 |
nm.store.iframe.width(1025); |
|
|
206 |
nm.store.iframe.height(665); |
|
|
207 |
}, |
|
|
208 |
close: function(nm) { |
|
|
209 |
// We don't do anything here, we hack the callback directly from the close function. |
|
|
210 |
}, |
|
|
211 |
afterClose: function(nm) { |
|
|
212 |
// Can't do that because searchprojectfilterurl is not defined in init_events_base params |
|
|
213 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
214 |
} |
|
|
215 |
} |
|
|
216 |
}); |
|
|
217 |
|
|
|
218 |
|
|
|
219 |
$('.ldt_link',base_node).each(function(i, e) { |
|
|
220 |
nm = $(e).data('nmObj'); |
|
|
221 |
$(e).data('nmObj', $.extend(true, nm, { |
|
|
222 |
close: testAndClose(nm.close) |
|
|
223 |
})); |
|
|
224 |
}); |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
$('.ldt_link_create',base_node).each(function(i){ |
|
|
228 |
$(this).attr("target","_iri"); |
|
|
229 |
}); |
|
|
230 |
$('.ldt_link_create',base_node).nyroModal({ |
|
|
231 |
|
|
|
232 |
filters: ['iriIframe'], |
|
|
233 |
sizes: { |
|
|
234 |
minW: '600', |
|
|
235 |
minH: '500' |
|
|
236 |
}, |
|
|
237 |
showCloseButton:true, |
|
|
238 |
closeOnEscape:false, |
|
|
239 |
closeOnClick:false, |
|
|
240 |
callbacks: { |
|
|
241 |
afterShowCont: function(nm) { |
|
|
242 |
nm.store.iframe.width(600); |
|
|
243 |
nm.store.iframe.height(600); |
|
|
244 |
var iframe = nm.store.iframe; |
|
|
245 |
iframe.load(function(){ |
|
|
246 |
var form_status = $(this).contents().find("#project_form_status").val(); |
|
|
247 |
if(form_status === 'saved' || form_status === 'deleted' ) { |
|
|
248 |
$.nmTop().close(); |
|
|
249 |
} |
|
|
250 |
var swfobject = $(this).contents().find("#ldtInitSwf"); |
|
|
251 |
if (swfobject.length) { |
|
|
252 |
nm['sizes']['initW'] = 1025; |
|
|
253 |
nm['sizes']['initH'] = 665; |
|
|
254 |
nm.resize(); |
|
|
255 |
nm.store.iframe.width(1025); |
|
|
256 |
nm.store.iframe.height(665); |
|
|
257 |
} |
|
|
258 |
}); |
|
|
259 |
}, |
|
|
260 |
afterClose: function(nm) { |
|
|
261 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
262 |
} |
|
|
263 |
} |
|
|
264 |
}); |
|
|
265 |
$('.ldt_link_create',base_node).each(function(i, e) { |
|
|
266 |
nm = $(e).data('nmObj'); |
|
|
267 |
$(e).data('nmObj', $.extend(true, nm, { |
|
|
268 |
close: testAndClose(nm.close) |
|
|
269 |
})); |
|
|
270 |
}); |
|
|
271 |
|
|
|
272 |
|
|
|
273 |
$('.publishedproject', base_node).click(function(e) { |
|
|
274 |
e.preventDefault(); |
|
|
275 |
var target = $(e.target); |
|
|
276 |
var project_id = target.attr('id').replace('project_',''); |
|
|
277 |
var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id); |
|
|
278 |
$.ajax({ |
|
|
279 |
url: url, |
|
|
280 |
type: 'POST', |
|
|
281 |
data: {csrfmiddlewaretoken:global_csrf_token}, |
|
|
282 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
|
283 |
//dataType: 'json', |
|
|
284 |
success: function(json, textStatus, XMLHttpRequest) { |
|
|
285 |
if(json.res) { |
|
|
286 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
287 |
} |
|
|
288 |
} |
|
|
289 |
}); |
|
|
290 |
}); |
|
|
291 |
|
|
|
292 |
$('.unpublishedproject', base_node).click(function(e) { |
|
|
293 |
e.preventDefault(); |
|
|
294 |
var target = $(e.target); |
|
|
295 |
var project_id = target.attr('id').replace('project_',''); |
|
|
296 |
var url = publishprojecturl.replace('__PROJECT_ID__', project_id); |
|
|
297 |
$.ajax({ |
|
|
298 |
url: url, |
|
|
299 |
type: 'POST', |
|
|
300 |
data: {csrfmiddlewaretoken:global_csrf_token}, |
|
|
301 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
|
302 |
//dataType: 'json', |
|
|
303 |
success: function(json, textStatus, XMLHttpRequest) { |
|
|
304 |
if(json.res) { |
|
|
305 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
306 |
} |
|
|
307 |
} |
|
|
308 |
}); |
|
|
309 |
}); |
|
|
310 |
|
|
|
311 |
$('.projecttitlelink').each(function(i){ |
|
|
312 |
$(this).attr("target","_blank"); |
|
|
313 |
}); |
|
|
314 |
$('.projecttitlelink').nyroModal({ |
|
|
315 |
filters: ['iframe'], |
|
|
316 |
sizes: { |
|
|
317 |
minH:680, |
|
|
318 |
minW:600 |
|
|
319 |
}, |
|
|
320 |
callbacks: { |
|
|
321 |
afterClose: function(nm) { |
|
|
322 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
323 |
}, |
|
|
324 |
afterShowCont: function(nm) { |
|
|
325 |
nm.store.iframe.height(680); |
|
|
326 |
nm.store.iframe.width(600); |
|
|
327 |
var iframe = nm.store.iframe; |
|
|
328 |
iframe.load(function(){ |
|
|
329 |
var form_status = $(this).contents().find("#project_form_status").val(); |
|
|
330 |
if(form_status === 'saved' || form_status === 'deleted') { |
|
|
331 |
$.nmTop().close(); |
|
|
332 |
} |
|
|
333 |
}); |
|
|
334 |
} |
|
|
335 |
} |
|
|
336 |
}); |
|
|
337 |
|
|
|
338 |
} |
|
|
339 |
|
|
|
340 |
function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
|
341 |
init_events_base(base_node, embed_url); |
|
|
342 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
|
|
343 |
} |
|
|
344 |
|
|
|
345 |
function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
|
346 |
init_events_contents(base_node, embed_url, searchcontentfilterurl); |
|
|
347 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
|
|
348 |
} |
|
|
349 |
|
|
|
350 |
function searchFieldInit(input_list_init) { |
|
|
351 |
|
|
|
352 |
$(".searchfieldinputbase").keydown(function (e) { |
|
|
353 |
if(e.which === 27) { |
|
|
354 |
$(e.target).blur(); |
|
|
355 |
$(e.target).next(".searchajaxloader").hide(); |
|
|
356 |
} |
|
|
357 |
}); |
|
|
358 |
|
|
|
359 |
$('.searchfieldinput').each(function(i) { |
|
|
360 |
var sbox = $(this); |
|
|
361 |
if(sbox.val() !== '') { |
|
|
362 |
sbox.attr('defaultText', sbox.val()); |
|
|
363 |
} |
|
|
364 |
|
|
|
365 |
sbox.focus(function() { |
|
|
366 |
box = $(this); |
|
|
367 |
if(box.val() === box.attr('defaultText')) { |
|
|
368 |
box.val(''); |
|
|
369 |
box.toggleClass("searchfieldinput"); |
|
|
370 |
} |
|
|
371 |
}); |
|
|
372 |
|
|
|
373 |
sbox.blur(function() { |
|
|
374 |
var box = $(this); |
|
|
375 |
if(box.val() === '' && box.attr('defaultText')) { |
|
|
376 |
box.val(box.attr('defaultText')); |
|
|
377 |
box.toggleClass("searchfieldinput"); |
|
|
378 |
} |
|
|
379 |
}); |
|
|
380 |
|
|
|
381 |
}); |
|
|
382 |
|
|
|
383 |
$.each(input_list_init, function(index, value) { |
|
|
384 |
$(value['input_selector']).keyup(function (e) { |
|
|
385 |
searchCallback(e.target, value['container_selector'], value['url']); |
|
|
386 |
}); |
|
|
387 |
}); |
|
|
388 |
|
|
|
389 |
$('.searchclear').click(function(e) { |
|
|
390 |
var box = $(e.target).parent().find("input"); |
|
|
391 |
box.val(box.attr('defaultText')); |
|
|
392 |
box.addClass("searchfieldinput"); |
|
|
393 |
box.blur(); |
|
|
394 |
box.keyup(); |
|
|
395 |
}); |
|
|
396 |
|
|
|
397 |
$('.searchclear').each(function(i) { |
|
|
398 |
$(this).hide(); |
|
|
399 |
}); |
|
|
400 |
|
|
|
401 |
} |
|
|
402 |
|
|
|
403 |
// |
|
|
404 |
// Functions used in the create content view. |
|
|
405 |
// |
|
|
406 |
function onCreateContentReady(url_upload, media_prefix, post_added_params, btn_label, success_label) { |
|
|
407 |
|
|
|
408 |
var upload_from_local_done = false; |
|
|
409 |
|
|
|
410 |
$("#close_button").click(function (e) { |
|
|
411 |
e.preventDefault(); |
|
|
412 |
parent.$.nmTop().close(); |
|
|
413 |
}); |
|
|
414 |
$("#submit_button_write").click(function(e) { |
|
|
415 |
$(".submitcontent-loader-content").show(); |
|
|
416 |
}); |
|
|
417 |
$(".media_fields").hide(); |
|
|
418 |
$("#media_field_"+$("#id_content-media_input_type").val()).show(); |
|
|
419 |
$("#id_content-media_input_type").change(function(e) { |
|
|
420 |
$(".media_fields").hide(); |
|
|
421 |
$("#media_field_"+$(e.target).val()).show(); |
|
|
422 |
}); |
|
|
423 |
// The textinput's id for external url is id_media-src |
|
|
424 |
$('#id_media-src').bind('textchange', function(e) { testUrlValue(e); }); |
|
|
425 |
|
|
|
426 |
// We disable the default submit |
|
|
427 |
$('#my_form').submit(function() { |
|
|
428 |
if($('#id_content-media_input_type').val()=="upload" && upload_from_local_done==false){ |
|
|
429 |
//alert("1. " + $('#id_content-media_input_type').val() + ", upload_done = " + upload_from_local_done); |
|
|
430 |
startLocalUpload(); |
|
|
431 |
return false; |
|
|
432 |
} |
|
|
433 |
else{ |
|
|
434 |
//alert("2. " + $('#id_content-media_input_type').val()); |
|
|
435 |
return true; |
|
|
436 |
} |
|
|
437 |
}); |
|
|
438 |
|
|
|
439 |
$("#upload_progress_bar").css({ width:"90%", height:"10" }); |
|
|
440 |
|
|
|
441 |
$('#media_fields_div').height(80); |
|
|
442 |
|
|
|
443 |
// We init the swfupload object |
|
|
444 |
swfupload = new SWFUpload({ |
|
|
445 |
debug: false, |
|
|
446 |
|
|
|
447 |
upload_url: url_upload, |
|
|
448 |
flash_url: media_prefix+"swf/swfupload.swf", |
|
|
449 |
|
|
|
450 |
post_params: post_added_params, |
|
|
451 |
|
|
|
452 |
button_placeholder_id: "upload_btn", |
|
|
453 |
button_width: "60", |
|
|
454 |
button_height: "16", |
|
|
455 |
button_cursor: SWFUpload.CURSOR.HAND, |
|
|
456 |
button_text : '<span class="btnText">' + btn_label + '</span>', |
|
|
457 |
button_text_style : ".btnText { font-size: 12; font-family: Arial; }", |
|
|
458 |
|
|
|
459 |
file_types : "*.flv;*.f4v;*.mp4;*.mov;*.mp3", |
|
|
460 |
file_types_description : "Media Files (flv, f4v, mov H264, mp4, mp3)", |
|
|
461 |
file_upload_limit : "1", |
|
|
462 |
file_queue_limit : "1", |
|
|
463 |
|
|
|
464 |
upload_progress_handler : uploadProgress, |
|
|
465 |
upload_error_handler : uploadError, |
|
|
466 |
//upload_success_handler : uploadSuccess, |
|
|
467 |
upload_success_handler : function() { |
|
|
468 |
try { |
|
|
469 |
if($('#upload_progress_info').children().size()>0){ |
|
|
470 |
$('#progress_info').remove(); |
|
|
471 |
} |
|
|
472 |
$('#upload_progress_info').append('<p id="progress_info">' + success_label + '.</p>'); |
|
|
473 |
upload_from_local_done = true; |
|
|
474 |
// Now that the file is uploaded, we submit the form |
|
|
475 |
$('#my_form').submit(); |
|
|
476 |
} |
|
|
477 |
catch (ex) { |
|
|
478 |
//this.debug(ex); |
|
|
479 |
} |
|
|
480 |
}, |
|
|
481 |
|
|
|
482 |
file_queued_handler : displayUploadPath, |
|
|
483 |
//file_dialog_complete_handler: function() { this.startUpload(); }, |
|
|
484 |
//upload_complete_handler: function() { this.startUpload(); }, |
|
|
485 |
}); |
|
|
486 |
} |
|
|
487 |
function displayUploadPath(file) { |
|
|
488 |
try { |
|
|
489 |
$('#id_media-local_file_name').val(file.name); |
|
|
490 |
} |
|
|
491 |
catch (ex) { |
|
|
492 |
//this.debug(ex); |
|
|
493 |
} |
|
|
494 |
} |
|
|
495 |
function startLocalUpload(){ |
|
|
496 |
swfupload.startUpload(); |
|
|
497 |
} |
|
|
498 |
function uploadProgress(file, bytesLoaded, bytesTotal) { |
|
|
499 |
try { |
|
|
500 |
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); |
|
|
501 |
$("#upload_progress_bar").progressbar({ value: percent }); |
|
|
502 |
} |
|
|
503 |
catch (ex) { |
|
|
504 |
//this.debug(ex); |
|
|
505 |
} |
|
|
506 |
} |
|
|
507 |
function uploadSuccess(success_label) { |
|
|
508 |
try { |
|
|
509 |
if($('#upload_progress_info').children().size()>0){ |
|
|
510 |
$('#progress_info').remove(); |
|
|
511 |
} |
|
|
512 |
$('#upload_progress_info').append('<p id="progress_info">' + success_label + '.</p>'); |
|
|
513 |
upload_from_local_done = true; |
|
|
514 |
// Now that the file is uploaded, we submit the form |
|
|
515 |
$('#my_form').submit(); |
|
|
516 |
} |
|
|
517 |
catch (ex) { |
|
|
518 |
//this.debug(ex); |
|
|
519 |
} |
|
|
520 |
} |
|
|
521 |
function uploadError(file, errorCode, message) { |
|
|
522 |
try { |
|
|
523 |
if($('#upload_progress_info').children().size()>0){ |
|
|
524 |
$('#progress_info').remove(); |
|
|
525 |
} |
|
|
526 |
switch (errorCode) { |
|
|
527 |
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: |
|
|
528 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: HTTP Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
|
529 |
break; |
|
|
530 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: |
|
|
531 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
|
532 |
break; |
|
|
533 |
case SWFUpload.UPLOAD_ERROR.IO_ERROR: |
|
|
534 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: IO Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
|
535 |
break; |
|
|
536 |
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: |
|
|
537 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Security Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
|
538 |
break; |
|
|
539 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: |
|
|
540 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
|
541 |
break; |
|
|
542 |
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: |
|
|
543 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
|
544 |
break; |
|
|
545 |
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: |
|
|
546 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: FILE_CANCELLED" + '</p>'); |
|
|
547 |
break; |
|
|
548 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: |
|
|
549 |
$('#upload_progress_info').append('<p id="progress_info">' + "STOPPED" + '</p>'); |
|
|
550 |
break; |
|
|
551 |
default: |
|
|
552 |
$('#upload_progress_info').append('<p id="progress_info">' + "unhandled error: File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
|
553 |
break; |
|
|
554 |
} |
|
|
555 |
} catch (ex) { |
|
|
556 |
//this.debug(ex); |
|
|
557 |
} |
|
|
558 |
} |
|
|
559 |
|
|
|
560 |
// Test the value of the URL from the form to load a picture in case it is a youtube video |
|
|
561 |
function testUrlValue(e){ |
|
|
562 |
// First, we remove the current thumbnail if there is one. |
|
|
563 |
if($('#media_field_create').children().size()>2){ |
|
|
564 |
$('#external_thumbnail').remove(); |
|
|
565 |
$('#media_fields_div').height(80); |
|
|
566 |
} |
|
|
567 |
// If the pasted text is a youtube url, we get the default thumbnail of the video and display it. |
|
|
568 |
url = $('#id_media-src').val(); |
|
|
569 |
if(url.match("youtube") && url.match("[\\?&]v=([^&#]*)")){ |
|
|
570 |
results = url.match("[\\?&]v=([^&#]*)"); |
|
|
571 |
vid = ( results === null ) ? url : results[1].substring(0,11); |
|
|
572 |
if(vid.length===11){ |
|
|
573 |
//$('#id_content-description').val($('#media_field_create') + '<img src="http://img.youtube.com/vi/'+vid+'/default.jpg" alt="Youtube Thumbnail"/>'); |
|
|
574 |
$('#media_field_create').append('<img id="external_thumbnail" src="http://img.youtube.com/vi/'+vid+'/default.jpg" alt="Youtube Thumbnail"/>'); |
|
|
575 |
$('#media_fields_div').height(150); |
|
|
576 |
} |
|
|
577 |
} |
|
|
578 |
} |