comparison public/javascripts/application.js @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents 0c939c159af4
children 5e80956cc792 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
84 } 84 }
85 85
86 var fileFieldCount = 1; 86 var fileFieldCount = 1;
87 87
88 function addFileField() { 88 function addFileField() {
89 if (fileFieldCount >= 10) return false 89 var fields = $('attachments_fields');
90 fileFieldCount++; 90 if (fields.childElements().length >= 10) return false;
91 var f = document.createElement("input"); 91 fileFieldCount++;
92 f.type = "file"; 92 var s = new Element('span');
93 f.name = "attachments[" + fileFieldCount + "][file]"; 93 s.update(fields.down('span').innerHTML);
94 f.size = 30; 94 s.down('input.file').name = "attachments[" + fileFieldCount + "][file]";
95 var d = document.createElement("input"); 95 s.down('input.description').name = "attachments[" + fileFieldCount + "][description]";
96 d.type = "text"; 96 fields.appendChild(s);
97 d.name = "attachments[" + fileFieldCount + "][description]"; 97 }
98 d.size = 60; 98
99 var dLabel = new Element('label'); 99 function removeFileField(el) {
100 dLabel.addClassName('inline'); 100 var fields = $('attachments_fields');
101 // Pulls the languge value used for Optional Description 101 var s = Element.up(el, 'span');
102 dLabel.update($('attachment_description_label_content').innerHTML) 102 if (fields.childElements().length > 1) {
103 p = document.getElementById("attachments_fields"); 103 s.remove();
104 p.appendChild(document.createElement("br")); 104 } else {
105 p.appendChild(f); 105 s.update(s.innerHTML);
106 p.appendChild(dLabel); 106 }
107 dLabel.appendChild(d); 107 }
108 108
109 function checkFileSize(el, maxSize, message) {
110 var files = el.files;
111 if (files) {
112 for (var i=0; i<files.length; i++) {
113 if (files[i].size > maxSize) {
114 alert(message);
115 el.value = "";
116 }
117 }
118 }
109 } 119 }
110 120
111 function showTab(name) { 121 function showTab(name) {
112 var f = $$('div#content .tab-content'); 122 var f = $$('div#content .tab-content');
113 for(var i=0; i<f.length; i++){ 123 for(var i=0; i<f.length; i++){
186 new Ajax.Request(url + '?' + param + '=' + encodeURIComponent(value), {asynchronous:true, evalScripts:true}); 196 new Ajax.Request(url + '?' + param + '=' + encodeURIComponent(value), {asynchronous:true, evalScripts:true});
187 return false; 197 return false;
188 } 198 }
189 } 199 }
190 200
201 function showModal(id, width) {
202 el = $(id);
203 if (el == undefined || el.visible()) {return;}
204 var h = $$('body')[0].getHeight();
205 var d = document.createElement("div");
206 d.id = 'modalbg';
207 $('main').appendChild(d);
208 $('modalbg').setStyle({ width: '100%', height: h + 'px' });
209 $('modalbg').show();
210
211 var pageWidth = document.viewport.getWidth();
212 el.setStyle({'width': width});
213 el.setStyle({'left': (((pageWidth - el.getWidth())/2 *100) / pageWidth) + '%'});
214 el.addClassName('modal');
215 el.show();
216
217 var submit = el.down("input[type=submit]");
218 if (submit) {
219 submit.focus();
220 }
221 }
222
223 function hideModal(el) {
224 var modal = Element.up(el, 'div.modal');
225 if (modal) {
226 modal.hide();
227 }
228 var bg = $('modalbg');
229 if (bg) {
230 bg.remove();
231 }
232 }
233
191 function collapseScmEntry(id) { 234 function collapseScmEntry(id) {
192 var els = document.getElementsByClassName(id, 'browser'); 235 var els = document.getElementsByClassName(id, 'browser');
193 for (var i = 0; i < els.length; i++) { 236 for (var i = 0; i < els.length; i++) {
194 if (els[i].hasClassName('open')) { 237 if (els[i].hasClassName('open')) {
195 collapseScmEntry(els[i].id); 238 collapseScmEntry(els[i].id);
248 'parent_issue_candidates', 291 'parent_issue_candidates',
249 url, 292 url,
250 { minChars: 3, 293 { minChars: 3,
251 frequency: 0.5, 294 frequency: 0.5,
252 paramName: 'q', 295 paramName: 'q',
296 method: 'get',
253 updateElement: function(value) { 297 updateElement: function(value) {
254 document.getElementById('issue_parent_issue_id').value = value.id; 298 document.getElementById('issue_parent_issue_id').value = value.id;
255 }}); 299 }});
256 } 300 }
257 301
260 'related_issue_candidates', 304 'related_issue_candidates',
261 url, 305 url,
262 { minChars: 3, 306 { minChars: 3,
263 frequency: 0.5, 307 frequency: 0.5,
264 paramName: 'q', 308 paramName: 'q',
309 method: 'get',
265 updateElement: function(value) { 310 updateElement: function(value) {
266 document.getElementById('relation_issue_to_id').value = value.id; 311 document.getElementById('relation_issue_to_id').value = value.id;
267 }, 312 },
268 parameters: 'scope=all' 313 parameters: 'scope=all'
269 }); 314 });