1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/* Dependencies: MochiKit Base Async, BitAjax.j */
LibertyAttachment = {
"fileInputClone":null,
"uploader_under_way":0,
"uploaderSetup":function(fileid){
LibertyAttachment.fileInputClone = $(fileid).cloneNode(true);
},
"uploader": function(file, action, waitmsg, frmid, cform) {
if (LibertyAttachment.uploader_under_way) {
alert(waitmsg);
}else{
if ( LibertyAttachment.preflightCheck( cform ) ){
LibertyAttachment.uploader_under_way = 1;
BitBase.showSpinner();
var old_target = file.form.target;
file.form.target = frmid;
var old_action = file.form.action;
file.form.action=action;
file.form.submit();
file.form.target = old_target;
file.form.action = old_action;
}
}
},
"preflightCheck": function( cform ){
var t = $(cform).title.value;
if ( MochiKit.Base.isEmpty(t) ){
alert( "Please enter a title for your new content before attempting to upload a file." );
return false;
}else{
$('la_title').value = t;
return true;
}
},
"uploaderComplete": function(frmid, divid, fileid, cform) {
if (LibertyAttachment.uploader_under_way){
BitBase.hideSpinner();
var ifrm = document.getElementById(frmid);
if (ifrm.contentDocument) {
var d = ifrm.contentDocument;
} else if (ifrm.contentWindow) {
var d = ifrm.contentWindow.document;
} else {
var d = window.frames[frmid].document;
}
if (d.location.href == "about:blank") {
return;
}
LibertyAttachment.postflightCheck( cform, d );
var errMsg = "<div>Sorry, there was a problem retrieving results.</div>";
var divO = document.getElementById(divid);
divR = d.getElementById('result_tab');
if (divO != null) {
divO.innerHTML = (divR != null)?divR.innerHTML:errMsg+"a";
}
divid = divid + '_tab';
divO = document.getElementById(divid);
var divR = d.getElementById('result_list');
if (divO != null) {
divO.innerHTML = (divR != null)?divR.innerHTML:errMsg+"b";
}
LibertyAttachment.uploader_under_way = 0;
var file = document.getElementById(fileid);
LibertyAttachment.fileInputClone.id = fileid;
MochiKit.DOM.swapDOM(file, LibertyAttachment.fileInputClone);
LibertyAttachment.uploaderSetup( fileid );
// file.value = '';
}
},
"postflightCheck": function( cform, d ){
var form = $(cform);
var cid = d.getElementById("upload_content_id").value;
if ( typeof( form.content_id ) == "undefined" ){
var i = INPUT( {'name':'content_id', 'type':'hidden', 'value':cid}, null );
form.insertBefore( i, form.firstChild );
}else{
form.content_id.value = cid;
}
$('la_content_id').value = cid;
}
}
|