| author | cavaliet |
| Mon, 09 May 2011 18:57:23 +0200 | |
| changeset 103 | 5578dcb54f4d |
| parent 71 | 8a881c9593d0 |
| permissions | -rw-r--r-- |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
1 |
|
| 0 | 2 |
$.fn.realVal = function() { |
| 32 | 3 |
var obj = $(this[0]); |
4 |
if(obj.val) { |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
5 |
if(obj.val() === obj.attr('defaultText')) { |
| 32 | 6 |
return ''; |
7 |
} |
|
8 |
else { |
|
9 |
return obj.val(); |
|
10 |
} |
|
11 |
} |
|
12 |
else { |
|
13 |
return null; |
|
14 |
} |
|
| 0 | 15 |
}; |
16 |
||
| 24 | 17 |
|
| 0 | 18 |
function init_events_base(base_node, embed_url) { |
| 32 | 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 |
}); |
|
| 0 | 44 |
|
45 |
||
| 32 | 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 |
}); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
70 |
} |
| 0 | 71 |
|
| 33 | 72 |
function testAndClose(close_fn) { |
| 32 | 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. |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
78 |
if (!force && ldtSwf && ldtSwf.name==="ldtInitSwf" && ldtSwf.isModified()==="true") { |
| 32 | 79 |
ldtSwf.askSave(); |
80 |
} |
|
81 |
else { |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
82 |
close_fn.apply(this); |
| 32 | 83 |
} |
84 |
}; |
|
|
31
0d829ac13c4b
Update modal behavior, to test if LDT swf has a still not saved work. Update language files too.
Cavalie Thibaut <thibaut.cavalie@centrepompidou.fr>
parents:
24
diff
changeset
|
85 |
} |
|
0d829ac13c4b
Update modal behavior, to test if LDT swf has a still not saved work. Update language files too.
Cavalie Thibaut <thibaut.cavalie@centrepompidou.fr>
parents:
24
diff
changeset
|
86 |
|
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
87 |
function testCreateAndClose(nm, close_fn) { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
88 |
|
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
89 |
return function(force) { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
90 |
// We get the frames vars |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
91 |
f = window.frames[0]; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
92 |
form_status = $('#content_form_status',$.nmTop().store.iframe.contents()).val(); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
93 |
// If form_status is "saved", we don't have to test anything, the form was was normally submitted. |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
94 |
// If was status is "empty" AND an upload from local was done |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
95 |
if(form_status!="saved" && f.upload_from_local_done==true && f.remove_temp_file_url){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
96 |
// ERASE FILE |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
97 |
//alert("testCreateAndClose : " + "f = " + f + ", status = " + form_status + ", u = " + f.upload_from_local_done + ", s = " + f.submit_asked + ", url = " + f.remove_temp_file_url); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
98 |
$.ajax({ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
99 |
type: "GET", |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
100 |
url: f.remove_temp_file_url, |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
101 |
data: "filename="+ $('#id_media-local_file_name',$.nmTop().store.iframe.contents()).val(), |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
102 |
cache: false, |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
103 |
success: function(data, status, request){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
104 |
//alert("remove success"); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
105 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
106 |
}); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
107 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
108 |
close_fn.apply(this); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
109 |
}; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
110 |
} |
| 0 | 111 |
|
112 |
function searchCallback(target, container_selector, url, timeout) { |
|
113 |
||
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
114 |
timeout = typeof(timeout) !== 'undefined' ? timeout : 0; |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
115 |
target = $(target); |
| 32 | 116 |
|
117 |
// remove all qtip |
|
118 |
$(".qtip").remove(); |
|
119 |
|
|
120 |
if(target.realVal().length > 0) { |
|
121 |
target.nextAll(".searchclear").show(); |
|
122 |
} |
|
| 0 | 123 |
|
| 32 | 124 |
if(target.attr('timer')) { |
125 |
clearTimeout(target.attr('timer')); |
|
126 |
} |
|
| 0 | 127 |
|
| 32 | 128 |
target.attr( |
129 |
'timer', |
|
130 |
setTimeout(function() { |
|
131 |
target.next(".searchajaxloader").show(); |
|
132 |
target.nextAll(".searchclear").hide(); |
|
133 |
var filterVal = "_" + escape(target.realVal()); |
|
134 |
url = url.replace('__FILTER__',filterVal); |
|
135 |
$.ajax({ |
|
136 |
url: url, |
|
137 |
cache: false, |
|
138 |
success: function(data, status, request) { |
|
139 |
$(container_selector).html(data); |
|
140 |
target.next(".searchajaxloader").hide(); |
|
141 |
if(target.realVal().length > 0) { |
|
142 |
target.nextAll(".searchclear").show(); |
|
143 |
} |
|
144 |
init_events($(container_selector)); |
|
145 |
target.removeAttr('timer'); |
|
146 |
} |
|
147 |
}); |
|
148 |
}, |
|
149 |
300) |
|
150 |
); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
151 |
} |
| 0 | 152 |
|
153 |
||
154 |
function init_events_contents(base_node, embed_url, content_filter_url) { |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
155 |
|
| 32 | 156 |
init_events_base(base_node, embed_url); |
157 |
|
|
158 |
$('.content_link_create').each(function(i){ |
|
159 |
$(this).attr("target","_blank"); |
|
160 |
}); |
|
161 |
$('.content_link_create').nyroModal({ |
|
162 |
filters: ['iframe'], |
|
163 |
sizes: { |
|
164 |
minW: 770, |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
165 |
minH: 550 |
| 32 | 166 |
}, |
167 |
callbacks: { |
|
168 |
afterClose: function(nm) { |
|
169 |
searchCallback($('#searchprojectsinput'), "#contentslistcontainer", content_filter_url); |
|
170 |
}, |
|
171 |
afterShowCont: function(nm) { |
|
172 |
nm.store.iframe.width(770); |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
173 |
nm.store.iframe.height(550); |
| 32 | 174 |
nm.store.iframe.load(function() { |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
175 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
176 |
if(form_status === 'saved' || form_status === 'deleted' ) { |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
177 |
$.nmTop().close(); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
178 |
} |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
179 |
}); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
180 |
} |
| 32 | 181 |
} |
182 |
}); |
|
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
183 |
$('.content_link_create',base_node).each(function(i, e) { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
184 |
nm = $(e).data('nmObj'); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
185 |
$(e).data('nmObj', $.extend(true, nm, { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
186 |
close: testCreateAndClose(nm, nm.close) |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
187 |
})); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
188 |
}); |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
189 |
|
| 32 | 190 |
$('.contenttitlelink').each(function(i){ |
191 |
$(this).attr("target","_blank"); |
|
192 |
}); |
|
193 |
$('.contenttitlelink').nyroModal({ |
|
194 |
filters: ['iframe'], |
|
195 |
sizes: { |
|
196 |
minW: 770, |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
197 |
minH: 550 |
| 32 | 198 |
}, |
199 |
callbacks: { |
|
200 |
afterClose: function(nm) { |
|
201 |
searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0); |
|
202 |
}, |
|
203 |
afterShowCont: function(nm) { |
|
204 |
nm.store.iframe.width(770); |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
205 |
nm.store.iframe.height(550); |
| 32 | 206 |
nm.store.iframe.load(function() { |
207 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
208 |
if(form_status === 'saved' || form_status === 'deleted') { |
| 32 | 209 |
$.nmTop().close(); |
210 |
} |
|
211 |
}); |
|
212 |
} |
|
213 |
} |
|
214 |
}); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
215 |
|
| 0 | 216 |
} |
217 |
||
218 |
function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
219 |
||
| 32 | 220 |
// These are the functions called when we display a project in an LDT modal window |
221 |
$('.ldt_link',base_node).each(function(i){ |
|
222 |
$(this).attr("target","_iri"); |
|
|
31
0d829ac13c4b
Update modal behavior, to test if LDT swf has a still not saved work. Update language files too.
Cavalie Thibaut <thibaut.cavalie@centrepompidou.fr>
parents:
24
diff
changeset
|
223 |
}); |
| 32 | 224 |
$('.ldt_link',base_node).nyroModal({ |
225 |
filters: ['iriIframe'], |
|
226 |
sizes: { |
|
|
38
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
227 |
minW: '1025', |
|
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
228 |
minH: '665' |
| 32 | 229 |
}, |
230 |
showCloseButton: true, |
|
231 |
closeOnEscape:false, |
|
232 |
closeOnClick:false, |
|
233 |
callbacks: { |
|
234 |
afterShowCont: function(nm) { |
|
|
38
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
235 |
nm.store.iframe.width(1025); |
|
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
236 |
nm.store.iframe.height(665); |
| 32 | 237 |
}, |
238 |
close: function(nm) { |
|
239 |
// We don't do anything here, we hack the callback directly from the close function. |
|
240 |
}, |
|
241 |
afterClose: function(nm) { |
|
242 |
// Can't do that because searchprojectfilterurl is not defined in init_events_base params |
|
243 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
244 |
} |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
245 |
} |
| 32 | 246 |
}); |
247 |
||
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
248 |
|
| 32 | 249 |
$('.ldt_link',base_node).each(function(i, e) { |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
250 |
nm = $(e).data('nmObj'); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
251 |
$(e).data('nmObj', $.extend(true, nm, { |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
252 |
close: testAndClose(nm.close) |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
253 |
})); |
| 32 | 254 |
}); |
|
31
0d829ac13c4b
Update modal behavior, to test if LDT swf has a still not saved work. Update language files too.
Cavalie Thibaut <thibaut.cavalie@centrepompidou.fr>
parents:
24
diff
changeset
|
255 |
|
|
0d829ac13c4b
Update modal behavior, to test if LDT swf has a still not saved work. Update language files too.
Cavalie Thibaut <thibaut.cavalie@centrepompidou.fr>
parents:
24
diff
changeset
|
256 |
|
| 32 | 257 |
$('.ldt_link_create',base_node).each(function(i){ |
258 |
$(this).attr("target","_iri"); |
|
259 |
}); |
|
|
66
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
260 |
$('.ldt_link_create',base_node).nyroModal({ |
| 32 | 261 |
|
262 |
filters: ['iriIframe'], |
|
263 |
sizes: { |
|
264 |
minW: '600', |
|
265 |
minH: '500' |
|
266 |
}, |
|
267 |
showCloseButton:true, |
|
268 |
closeOnEscape:false, |
|
269 |
closeOnClick:false, |
|
270 |
callbacks: { |
|
271 |
afterShowCont: function(nm) { |
|
272 |
nm.store.iframe.width(600); |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
273 |
nm.store.iframe.height(600); |
| 32 | 274 |
var iframe = nm.store.iframe; |
275 |
iframe.load(function(){ |
|
276 |
var form_status = $(this).contents().find("#project_form_status").val(); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
277 |
if(form_status === 'saved' || form_status === 'deleted' ) { |
| 32 | 278 |
$.nmTop().close(); |
279 |
} |
|
280 |
var swfobject = $(this).contents().find("#ldtInitSwf"); |
|
281 |
if (swfobject.length) { |
|
|
38
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
282 |
nm['sizes']['initW'] = 1025; |
|
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
283 |
nm['sizes']['initH'] = 665; |
| 32 | 284 |
nm.resize(); |
|
38
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
285 |
nm.store.iframe.width(1025); |
|
457d4ab675df
debug modal for chrome, ie7. For firefox, links are not modal anymore.
cavaliet
parents:
37
diff
changeset
|
286 |
nm.store.iframe.height(665); |
| 32 | 287 |
} |
288 |
}); |
|
289 |
}, |
|
290 |
afterClose: function(nm) { |
|
291 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
292 |
} |
| 32 | 293 |
} |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
294 |
}); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
295 |
$('.ldt_link_create',base_node).each(function(i, e) { |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
296 |
nm = $(e).data('nmObj'); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
297 |
$(e).data('nmObj', $.extend(true, nm, { |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
298 |
close: testAndClose(nm.close) |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
299 |
})); |
|
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
300 |
}); |
| 32 | 301 |
|
302 |
|
|
|
66
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
303 |
$('.publishedproject', base_node).click(function(e) { |
| 32 | 304 |
e.preventDefault(); |
305 |
var target = $(e.target); |
|
306 |
var project_id = target.attr('id').replace('project_',''); |
|
307 |
var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id); |
|
308 |
$.ajax({ |
|
309 |
url: url, |
|
310 |
type: 'POST', |
|
|
66
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
311 |
data: {csrfmiddlewaretoken:global_csrf_token}, |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
312 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
313 |
//dataType: 'json', |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
314 |
success: function(json, textStatus, XMLHttpRequest) { |
| 32 | 315 |
if(json.res) { |
316 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
317 |
} |
|
318 |
} |
|
319 |
}); |
|
| 24 | 320 |
}); |
|
66
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
321 |
|
| 32 | 322 |
$('.unpublishedproject', base_node).click(function(e) { |
323 |
e.preventDefault(); |
|
324 |
var target = $(e.target); |
|
325 |
var project_id = target.attr('id').replace('project_',''); |
|
326 |
var url = publishprojecturl.replace('__PROJECT_ID__', project_id); |
|
327 |
$.ajax({ |
|
328 |
url: url, |
|
329 |
type: 'POST', |
|
|
66
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
330 |
data: {csrfmiddlewaretoken:global_csrf_token}, |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
331 |
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
332 |
//dataType: 'json', |
|
8a7530e28185
Add token authentification to un/publish request. Update jquery.min.js and twitter auth keys.
cavaliet
parents:
46
diff
changeset
|
333 |
success: function(json, textStatus, XMLHttpRequest) { |
| 32 | 334 |
if(json.res) { |
335 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
336 |
} |
|
337 |
} |
|
338 |
}); |
|
339 |
}); |
|
| 0 | 340 |
|
| 32 | 341 |
$('.projecttitlelink').each(function(i){ |
342 |
$(this).attr("target","_blank"); |
|
343 |
}); |
|
344 |
$('.projecttitlelink').nyroModal({ |
|
345 |
filters: ['iframe'], |
|
346 |
sizes: { |
|
347 |
minH:680, |
|
|
46
ba02faf089df
Update media adding, to allow youtube import, and display the thumbnail when we paste the youtube url.
cavaliet
parents:
38
diff
changeset
|
348 |
minW:600 |
| 32 | 349 |
}, |
350 |
callbacks: { |
|
351 |
afterClose: function(nm) { |
|
352 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
353 |
}, |
|
354 |
afterShowCont: function(nm) { |
|
355 |
nm.store.iframe.height(680); |
|
356 |
nm.store.iframe.width(600); |
|
357 |
var iframe = nm.store.iframe; |
|
358 |
iframe.load(function(){ |
|
359 |
var form_status = $(this).contents().find("#project_form_status").val(); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
360 |
if(form_status === 'saved' || form_status === 'deleted') { |
| 32 | 361 |
$.nmTop().close(); |
362 |
} |
|
363 |
}); |
|
364 |
} |
|
365 |
} |
|
366 |
}); |
|
367 |
|
|
| 0 | 368 |
} |
369 |
||
370 |
function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
| 32 | 371 |
init_events_base(base_node, embed_url); |
372 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
|
| 0 | 373 |
} |
374 |
||
375 |
function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
| 32 | 376 |
init_events_contents(base_node, embed_url, searchcontentfilterurl); |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
377 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
| 0 | 378 |
} |
379 |
||
380 |
function searchFieldInit(input_list_init) { |
|
381 |
||
| 32 | 382 |
$(".searchfieldinputbase").keydown(function (e) { |
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
383 |
if(e.which === 27) { |
| 32 | 384 |
$(e.target).blur(); |
385 |
$(e.target).next(".searchajaxloader").hide(); |
|
386 |
} |
|
387 |
}); |
|
388 |
|
|
389 |
$('.searchfieldinput').each(function(i) { |
|
390 |
var sbox = $(this); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
391 |
if(sbox.val() !== '') { |
| 32 | 392 |
sbox.attr('defaultText', sbox.val()); |
393 |
} |
|
394 |
|
|
395 |
sbox.focus(function() { |
|
396 |
box = $(this); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
397 |
if(box.val() === box.attr('defaultText')) { |
| 32 | 398 |
box.val(''); |
399 |
box.toggleClass("searchfieldinput"); |
|
400 |
} |
|
401 |
}); |
|
402 |
|
|
403 |
sbox.blur(function() { |
|
404 |
var box = $(this); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
405 |
if(box.val() === '' && box.attr('defaultText')) { |
| 32 | 406 |
box.val(box.attr('defaultText')); |
407 |
box.toggleClass("searchfieldinput"); |
|
408 |
} |
|
409 |
}); |
|
410 |
|
|
411 |
}); |
|
| 0 | 412 |
|
| 32 | 413 |
$.each(input_list_init, function(index, value) { |
414 |
$(value['input_selector']).keyup(function (e) { |
|
415 |
searchCallback(e.target, value['container_selector'], value['url']); |
|
416 |
}); |
|
417 |
}); |
|
418 |
|
|
419 |
$('.searchclear').click(function(e) { |
|
420 |
var box = $(e.target).parent().find("input"); |
|
421 |
box.val(box.attr('defaultText')); |
|
422 |
box.addClass("searchfieldinput"); |
|
423 |
box.blur(); |
|
424 |
box.keyup(); |
|
425 |
}); |
|
426 |
|
|
427 |
$('.searchclear').each(function(i) { |
|
428 |
$(this).hide(); |
|
429 |
}); |
|
|
37
3586af4092f3
update projectscontents.js to avoid reload on modal resize.
cavaliet
parents:
33
diff
changeset
|
430 |
|
| 0 | 431 |
} |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
432 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
433 |
// |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
434 |
// Functions used in the create content view. |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
435 |
// |
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
436 |
function onCreateContentReady(url_upload, media_prefix, post_added_params, btn_label, success_label, wait_label, cancel_label, remove_url) { |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
437 |
|
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
438 |
window.upload_from_local_done = false; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
439 |
window.submit_asked = false; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
440 |
window.remove_temp_file_url = remove_url; |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
441 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
442 |
$("#close_button").click(function (e) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
443 |
e.preventDefault(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
444 |
parent.$.nmTop().close(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
445 |
}); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
446 |
$("#submit_button_write").click(function(e) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
447 |
$(".submitcontent-loader-content").show(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
448 |
}); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
449 |
$(".media_fields").hide(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
450 |
$("#media_field_"+$("#id_content-media_input_type").val()).show(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
451 |
$("#id_content-media_input_type").change(function(e) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
452 |
$(".media_fields").hide(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
453 |
$("#media_field_"+$(e.target).val()).show(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
454 |
}); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
455 |
// The textinput's id for external url is id_media-src |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
456 |
$('#id_media-src').bind('textchange', function(e) { testUrlValue(e); }); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
457 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
458 |
// We disable the default submit |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
459 |
$('#my_form').submit(function() { |
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
460 |
window.submit_asked = true; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
461 |
if($('#id_content-media_input_type').val()=="upload"){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
462 |
if(window.upload_from_local_done==false){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
463 |
// The form has sent but the uploading has not ended. |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
464 |
if($('#upload_progress_info').children().size()>0){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
465 |
$('#progress_info').remove(); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
466 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
467 |
$('#upload_progress_info').append('<p id="progress_info"><font color="red"><strong>' + wait_label + '.</strong></font></p>'); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
468 |
return false; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
469 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
470 |
else{ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
471 |
return true; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
472 |
} |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
473 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
474 |
else{ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
475 |
//alert("2. " + $('#id_content-media_input_type').val()); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
476 |
return true; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
477 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
478 |
}); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
479 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
480 |
$("#upload_progress_bar").css({ width:"90%", height:"10" }); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
481 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
482 |
$('#media_fields_div').height(80); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
483 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
484 |
// We init the swfupload object |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
485 |
swfupload = new SWFUpload({ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
486 |
debug: false, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
487 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
488 |
upload_url: url_upload, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
489 |
flash_url: media_prefix+"swf/swfupload.swf", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
490 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
491 |
post_params: post_added_params, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
492 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
493 |
button_placeholder_id: "upload_btn", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
494 |
button_width: "60", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
495 |
button_height: "16", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
496 |
button_cursor: SWFUpload.CURSOR.HAND, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
497 |
button_text : '<span class="btnText">' + btn_label + '</span>', |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
498 |
button_text_style : ".btnText { font-size: 12; font-family: Arial; }", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
499 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
500 |
file_types : "*.flv;*.f4v;*.mp4;*.mov;*.mp3", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
501 |
file_types_description : "Media Files (flv, f4v, mov H264, mp4, mp3)", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
502 |
file_upload_limit : "1", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
503 |
file_queue_limit : "1", |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
504 |
|
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
505 |
upload_error_handler : uploadError, |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
506 |
upload_start_handler : function(file) { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
507 |
try { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
508 |
if($('#upload_progress_info').children().size()>0){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
509 |
$('#progress_info').remove(); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
510 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
511 |
$('#upload_progress_info').append('<p id="progress_info"><a href="javascript:cancelSwfUpload()">' + cancel_label + '.</a></p>'); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
512 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
513 |
catch (ex) { |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
514 |
//this.debug(ex); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
515 |
} |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
516 |
}, |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
517 |
upload_progress_handler : uploadProgress, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
518 |
upload_success_handler : function() { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
519 |
try { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
520 |
if($('#upload_progress_info').children().size()>0){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
521 |
$('#progress_info').remove(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
522 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
523 |
$('#upload_progress_info').append('<p id="progress_info">' + success_label + '.</p>'); |
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
524 |
$("#upload_progress_bar > div").css({ 'background': '#90ffa8' }); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
525 |
window.upload_from_local_done = true; |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
526 |
// Now that the file is uploaded, we submit the form if asked |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
527 |
if(window.submit_asked==true){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
528 |
$('#my_form').submit(); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
529 |
} |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
530 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
531 |
catch (ex) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
532 |
//this.debug(ex); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
533 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
534 |
}, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
535 |
file_queued_handler : displayUploadPath, |
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
536 |
file_dialog_complete_handler: function() { this.startUpload(); }, |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
537 |
//upload_complete_handler: function() { this.startUpload(); }, |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
538 |
}); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
539 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
540 |
function displayUploadPath(file) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
541 |
try { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
542 |
$('#id_media-local_file_name').val(file.name); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
543 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
544 |
catch (ex) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
545 |
//this.debug(ex); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
546 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
547 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
548 |
function startLocalUpload(){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
549 |
swfupload.startUpload(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
550 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
551 |
function uploadProgress(file, bytesLoaded, bytesTotal) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
552 |
try { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
553 |
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
554 |
$("#upload_progress_bar").progressbar({ value: percent }); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
555 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
556 |
catch (ex) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
557 |
//this.debug(ex); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
558 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
559 |
} |
|
103
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
560 |
function cancelSwfUpload(){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
561 |
swfupload.cancelUpload(); |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
562 |
if($('#media_field_upload').has($('#cancelupload')).length==0){ |
|
5578dcb54f4d
merge context_processors.py and enable upload cancel and remove temp file. Creation of a session temp folder for upload.
cavaliet
parents:
71
diff
changeset
|
563 |
$('#cancelupload').remove(); |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
564 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
565 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
566 |
function uploadError(file, errorCode, message) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
567 |
try { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
568 |
if($('#upload_progress_info').children().size()>0){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
569 |
$('#progress_info').remove(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
570 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
571 |
switch (errorCode) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
572 |
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
573 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: HTTP Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
574 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
575 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
576 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
577 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
578 |
case SWFUpload.UPLOAD_ERROR.IO_ERROR: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
579 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: IO Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
580 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
581 |
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
582 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Security Error, File name: " + file.name + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
583 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
584 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
585 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
586 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
587 |
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
588 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
589 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
590 |
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
591 |
$('#upload_progress_info').append('<p id="progress_info">' + "Error Code: FILE_CANCELLED" + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
592 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
593 |
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
594 |
$('#upload_progress_info').append('<p id="progress_info">' + "STOPPED" + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
595 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
596 |
default: |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
597 |
$('#upload_progress_info').append('<p id="progress_info">' + "unhandled error: File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '</p>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
598 |
break; |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
599 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
600 |
} catch (ex) { |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
601 |
//this.debug(ex); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
602 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
603 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
604 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
605 |
// Test the value of the URL from the form to load a picture in case it is a youtube video |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
606 |
function testUrlValue(e){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
607 |
// First, we remove the current thumbnail if there is one. |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
608 |
if($('#media_field_create').children().size()>2){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
609 |
$('#external_thumbnail').remove(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
610 |
$('#media_fields_div').height(80); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
611 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
612 |
// If the pasted text is a youtube url, we get the default thumbnail of the video and display it. |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
613 |
url = $('#id_media-src').val(); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
614 |
if(url.match("youtube") && url.match("[\\?&]v=([^&#]*)")){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
615 |
results = url.match("[\\?&]v=([^&#]*)"); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
616 |
vid = ( results === null ) ? url : results[1].substring(0,11); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
617 |
if(vid.length===11){ |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
618 |
//$('#id_content-description').val($('#media_field_create') + '<img src="http://img.youtube.com/vi/'+vid+'/default.jpg" alt="Youtube Thumbnail"/>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
619 |
$('#media_field_create').append('<img id="external_thumbnail" src="http://img.youtube.com/vi/'+vid+'/default.jpg" alt="Youtube Thumbnail"/>'); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
620 |
$('#media_fields_div').height(150); |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
621 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
622 |
} |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
66
diff
changeset
|
623 |
} |