4 var medium = new Object();
5 medium.type = 'inline';
11 medium.addMedia = function()
14 'Nucleus CMS Medium Plugin',
15 'status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=450,top=0,left=0');
19 medium.isCaretEmpty = function()
21 /* lastSelected object is on main window */
22 if ( lastSelected && lastSelected.createTextRange && lastSelected.caretPos )
24 return ( lastSelected.caretPos.text == '' );
26 else if ( !document.all && document.getElementById )
28 return ( mozSelectedText() == '' );
33 medium.getCaretText = function()
35 if ( !document.all && document.getElementById )
37 return mozSelectedText();
39 return lastSelected.caretPos.text;
42 // inserts text at caret (overwriting selection)
43 medium.insertAtCaret = function(text)
45 /* lastSelected is on main window */
46 var textEl = lastSelected;
47 if ( textEl && textEl.createTextRange && textEl.caretPos )
49 var caretPos = textEl.caretPos;
51 if ( caretPos.text.charAt(caretPos.text.length - 1) != ' ' )
57 caretPos.text = text + ' ';
60 else if ( !document.all && document.getElementById )
62 mozReplace(document.getElementById('input' + nonie_FormType), text);
65 document.getElementById('input' + nonie_FormType).scrollTop = scrollTop;
74 document.getElementById('input' + nonie_FormType).value += text;
77 document.getElementById('input' + nonie_FormType).scrollTop = scrollTop;
80 /* updAllPreviews() is on main window */
85 medium.includeImage = function(collection, filename, type, width, height)
90 if ( this.isCaretEmpty() )
92 text = prompt("Text to display ?", filename);
96 text = this.getCaretText();
100 * add collection name when not private collection
101 * (or editing a message that's not your)
103 if ( isNaN(collection) || (nucleusAuthorId != collection) )
105 fullName = collection + '/' + filename;
115 replaceBy = '<%popup(' + fullName + '|'+width+'|'+height+'|' + text +')%>';
119 replaceBy = '<%image(' + fullName + '|'+width+'|'+height+'|' + text +')%>';
123 this.insertAtCaret(replaceBy);
127 medium.includeOtherMedia = function(collection, filename)
132 if ( this.isCaretEmpty() )
134 text = prompt("Text to display ?",filename);
138 text = getCaretText();
141 // add collection name when not private collection (or editing a message that's not your)
142 if ( isNaN(collection) || (nucleusAuthorId != collection) )
144 fullName = collection + '/' + filename;
151 replaceBy = '<%media(' + fullName + '|' + text +')%>';
153 this.insertAtCaret(replaceBy);
158 medium.setType = function(value)
163 medium.chooseImage = function(collection, filename, width, height)
165 if ( this.type != 'inline' )
171 window.opener.focus();
172 window.opener.medium.includeImage(collection, filename, this.type, width, height);
176 medium.chooseOther = function(collection, filename)
180 window.opener.focus();
181 window.opener.medium.type = this.type;
182 window.opener.medium.includeOtherMedia(collection, filename);