2008-02-10 16:17:41 +03:00
|
|
|
/* redMine - project management software
|
|
|
|
Copyright (C) 2006-2008 Jean-Philippe Lang */
|
|
|
|
|
2007-04-04 22:20:45 +04:00
|
|
|
function checkAll (id, checked) {
|
2008-05-14 21:23:40 +04:00
|
|
|
var els = Element.descendants(id);
|
|
|
|
for (var i = 0; i < els.length; i++) {
|
|
|
|
if (els[i].disabled==false) {
|
|
|
|
els[i].checked = checked;
|
2007-04-04 22:20:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-29 22:46:58 +03:00
|
|
|
var fileFieldCount = 1;
|
|
|
|
|
2007-04-04 22:20:45 +04:00
|
|
|
function addFileField() {
|
2008-02-29 22:46:58 +03:00
|
|
|
if (fileFieldCount >= 10) return false
|
|
|
|
fileFieldCount++;
|
2007-04-04 22:20:45 +04:00
|
|
|
var f = document.createElement("input");
|
|
|
|
f.type = "file";
|
2008-02-29 22:46:58 +03:00
|
|
|
f.name = "attachments[" + fileFieldCount + "][file]";
|
2007-04-04 22:20:45 +04:00
|
|
|
f.size = 30;
|
2008-02-29 22:46:58 +03:00
|
|
|
var d = document.createElement("input");
|
|
|
|
d.type = "text";
|
|
|
|
d.name = "attachments[" + fileFieldCount + "][description]";
|
|
|
|
d.size = 60;
|
|
|
|
|
|
|
|
p = document.getElementById("attachments_fields");
|
2007-04-04 22:20:45 +04:00
|
|
|
p.appendChild(document.createElement("br"));
|
|
|
|
p.appendChild(f);
|
2008-02-29 22:46:58 +03:00
|
|
|
p.appendChild(d);
|
2007-04-04 22:20:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function showTab(name) {
|
|
|
|
var f = $$('div#content .tab-content');
|
|
|
|
for(var i=0; i<f.length; i++){
|
|
|
|
Element.hide(f[i]);
|
|
|
|
}
|
|
|
|
var f = $$('div.tabs a');
|
|
|
|
for(var i=0; i<f.length; i++){
|
|
|
|
Element.removeClassName(f[i], "selected");
|
|
|
|
}
|
|
|
|
Element.show('tab-content-' + name);
|
|
|
|
Element.addClassName('tab-' + name, "selected");
|
|
|
|
return false;
|
2007-04-27 23:32:57 +04:00
|
|
|
}
|
|
|
|
|
2007-05-05 17:22:27 +04:00
|
|
|
function setPredecessorFieldsVisibility() {
|
|
|
|
relationType = $('relation_relation_type');
|
|
|
|
if (relationType && relationType.value == "precedes") {
|
|
|
|
Element.show('predecessor_fields');
|
|
|
|
} else {
|
|
|
|
Element.hide('predecessor_fields');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-16 20:45:06 +04:00
|
|
|
function promptToRemote(text, param, url) {
|
|
|
|
value = prompt(text + ':');
|
|
|
|
if (value) {
|
2008-05-22 21:02:29 +04:00
|
|
|
new Ajax.Request(url + '?' + param + '=' + encodeURIComponent(value), {asynchronous:true, evalScripts:true});
|
2007-08-16 20:45:06 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-22 23:34:21 +04:00
|
|
|
function collapseScmEntry(id) {
|
|
|
|
var els = document.getElementsByClassName(id, 'browser');
|
|
|
|
for (var i = 0; i < els.length; i++) {
|
2007-10-23 23:07:59 +04:00
|
|
|
if (els[i].hasClassName('open')) {
|
|
|
|
collapseScmEntry(els[i].id);
|
|
|
|
}
|
2007-10-22 23:34:21 +04:00
|
|
|
Element.hide(els[i]);
|
|
|
|
}
|
|
|
|
$(id).removeClassName('open');
|
|
|
|
}
|
|
|
|
|
|
|
|
function expandScmEntry(id) {
|
|
|
|
var els = document.getElementsByClassName(id, 'browser');
|
|
|
|
for (var i = 0; i < els.length; i++) {
|
|
|
|
Element.show(els[i]);
|
2007-10-24 00:42:15 +04:00
|
|
|
if (els[i].hasClassName('loaded') && !els[i].hasClassName('collapsed')) {
|
|
|
|
expandScmEntry(els[i].id);
|
|
|
|
}
|
2007-10-22 23:34:21 +04:00
|
|
|
}
|
|
|
|
$(id).addClassName('open');
|
|
|
|
}
|
|
|
|
|
|
|
|
function scmEntryClick(id) {
|
|
|
|
el = $(id);
|
|
|
|
if (el.hasClassName('open')) {
|
|
|
|
collapseScmEntry(id);
|
2007-10-24 00:42:15 +04:00
|
|
|
el.addClassName('collapsed');
|
2007-10-22 23:34:21 +04:00
|
|
|
return false;
|
|
|
|
} else if (el.hasClassName('loaded')) {
|
|
|
|
expandScmEntry(id);
|
2007-10-24 00:42:15 +04:00
|
|
|
el.removeClassName('collapsed');
|
2007-10-22 23:34:21 +04:00
|
|
|
return false;
|
|
|
|
}
|
2007-10-24 00:42:15 +04:00
|
|
|
if (el.hasClassName('loading')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
el.addClassName('loading');
|
2007-10-22 23:34:21 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function scmEntryLoaded(id) {
|
|
|
|
Element.addClassName(id, 'open');
|
|
|
|
Element.addClassName(id, 'loaded');
|
2007-10-24 00:42:15 +04:00
|
|
|
Element.removeClassName(id, 'loading');
|
2007-10-22 23:34:21 +04:00
|
|
|
}
|
|
|
|
|
2008-06-25 23:25:28 +04:00
|
|
|
function randomKey(size) {
|
|
|
|
var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
|
|
|
|
var key = '';
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
key += chars[Math.floor(Math.random() * chars.length)];
|
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2007-04-27 23:32:57 +04:00
|
|
|
/* shows and hides ajax indicator */
|
|
|
|
Ajax.Responders.register({
|
|
|
|
onCreate: function(){
|
|
|
|
if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
|
|
|
|
Element.show('ajax-indicator');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onComplete: function(){
|
|
|
|
if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
|
|
|
|
Element.hide('ajax-indicator');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|