2012-02-10 04:36:21 +04:00
|
|
|
/* Redmine - project management software
|
|
|
|
Copyright (C) 2006-2012 Jean-Philippe Lang */
|
2008-02-10 16:17:41 +03:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function checkAll(id, checked) {
|
|
|
|
if (checked) {
|
|
|
|
$('#'+id).find('input[type=checkbox]').attr('checked', true);
|
|
|
|
} else {
|
|
|
|
$('#'+id).find('input[type=checkbox]').removeAttr('checked');
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2007-04-04 22:20:45 +04:00
|
|
|
}
|
|
|
|
|
2008-08-26 20:05:02 +04:00
|
|
|
function toggleCheckboxesBySelector(selector) {
|
2012-02-10 04:35:58 +04:00
|
|
|
var all_checked = true;
|
2012-07-22 17:29:26 +04:00
|
|
|
$(selector).each(function(index) {
|
|
|
|
if (!$(this).is(':checked')) { all_checked = false; }
|
2010-09-29 01:09:06 +04:00
|
|
|
});
|
2012-07-22 17:29:26 +04:00
|
|
|
$(selector).attr('checked', !all_checked)
|
2010-09-29 01:09:06 +04:00
|
|
|
}
|
|
|
|
|
2008-06-29 23:50:07 +04:00
|
|
|
function showAndScrollTo(id, focus) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('#'+id).show();
|
|
|
|
if (focus!=null) {
|
|
|
|
$('#'+focus).focus();
|
|
|
|
}
|
|
|
|
$('html, body').animate({scrollTop: $('#'+id).offset().top}, 100);
|
2008-06-29 23:50:07 +04:00
|
|
|
}
|
|
|
|
|
2009-05-04 22:04:09 +04:00
|
|
|
function toggleRowGroup(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var tr = $(el).parents('tr').first();
|
|
|
|
var n = tr.next();
|
|
|
|
tr.toggleClass('open');
|
|
|
|
while (n.length && !n.hasClass('group')) {
|
|
|
|
n.toggle();
|
|
|
|
n = n.next('tr');
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2009-05-04 22:04:09 +04:00
|
|
|
}
|
|
|
|
|
2011-03-20 19:01:25 +03:00
|
|
|
function collapseAllRowGroups(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var tbody = $(el).parents('tbody').first();
|
|
|
|
tbody.children('tr').each(function(index) {
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
$(this).removeClass('open');
|
2011-03-20 19:01:25 +03:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$(this).hide();
|
2011-03-20 19:01:25 +03:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
2011-03-20 19:01:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function expandAllRowGroups(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var tbody = $(el).parents('tbody').first();
|
|
|
|
tbody.children('tr').each(function(index) {
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
$(this).addClass('open');
|
2011-03-20 19:01:25 +03:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$(this).show();
|
2011-03-20 19:01:25 +03:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
2011-03-20 19:01:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleAllRowGroups(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var tr = $(el).parents('tr').first();
|
|
|
|
if (tr.hasClass('open')) {
|
2011-03-20 19:01:25 +03:00
|
|
|
collapseAllRowGroups(el);
|
|
|
|
} else {
|
|
|
|
expandAllRowGroups(el);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-20 11:24:16 +04:00
|
|
|
function toggleFieldset(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var fieldset = $(el).parents('fieldset').first();
|
|
|
|
fieldset.toggleClass('collapsed');
|
|
|
|
fieldset.children('div').toggle();
|
2009-09-20 11:24:16 +04:00
|
|
|
}
|
|
|
|
|
2011-02-20 18:38:07 +03:00
|
|
|
function hideFieldset(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var fieldset = $(el).parents('fieldset').first();
|
|
|
|
fieldset.toggleClass('collapsed');
|
|
|
|
fieldset.children('div').hide();
|
2011-02-20 18:38:07 +03:00
|
|
|
}
|
|
|
|
|
2012-01-24 22:02:22 +04:00
|
|
|
function add_filter() {
|
2012-07-22 17:29:26 +04:00
|
|
|
var select = $('#add_filter_select');
|
|
|
|
var field = select.val();
|
|
|
|
$('#tr_'+field).show();
|
|
|
|
var check_box = $('#cb_' + field);
|
|
|
|
check_box.attr('checked', true);
|
2012-01-24 22:02:22 +04:00
|
|
|
toggle_filter(field);
|
2012-07-22 17:29:26 +04:00
|
|
|
select.val('');
|
2012-01-24 22:02:22 +04:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
select.children('option').each(function(index) {
|
|
|
|
if ($(this).attr('value') == field) {
|
|
|
|
$(this).attr('disabled', true);
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_filter(field) {
|
2012-07-22 17:29:26 +04:00
|
|
|
check_box = $('#cb_' + field);
|
|
|
|
if (check_box.is(':checked')) {
|
|
|
|
$("#operators_" + field).show().removeAttr('disabled');
|
2012-01-24 22:02:22 +04:00
|
|
|
toggle_operator(field);
|
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$("#operators_" + field).hide().attr('disabled', true);
|
2012-01-24 22:02:22 +04:00
|
|
|
enableValues(field, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableValues(field, indexes) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$(".values_" + field).each(function(index) {
|
|
|
|
if (indexes.indexOf(index) >= 0) {
|
|
|
|
$(this).removeAttr('disabled');
|
|
|
|
$(this).parents('span').first().show();
|
2012-01-24 22:02:22 +04:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$(this).val('');
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
$(this).parents('span').first().hide();
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
$(this).addClass('open');
|
|
|
|
} else {
|
|
|
|
$(this).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-01-24 22:02:22 +04:00
|
|
|
if (indexes.length > 0) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$("#div_values_" + field).show();
|
2012-01-24 22:02:22 +04:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$("#div_values_" + field).hide();
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_operator(field) {
|
2012-07-22 17:29:26 +04:00
|
|
|
operator = $("#operators_" + field);
|
|
|
|
switch (operator.val()) {
|
2012-01-24 22:02:22 +04:00
|
|
|
case "!*":
|
|
|
|
case "*":
|
|
|
|
case "t":
|
|
|
|
case "w":
|
|
|
|
case "o":
|
|
|
|
case "c":
|
|
|
|
enableValues(field, []);
|
|
|
|
break;
|
|
|
|
case "><":
|
|
|
|
enableValues(field, [0,1]);
|
|
|
|
break;
|
|
|
|
case "<t+":
|
|
|
|
case ">t+":
|
|
|
|
case "t+":
|
|
|
|
case ">t-":
|
|
|
|
case "<t-":
|
|
|
|
case "t-":
|
|
|
|
enableValues(field, [2]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
enableValues(field, [0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function toggle_multi_select(id) {
|
|
|
|
var select = $('#'+id);
|
|
|
|
if (select.attr('multiple')) {
|
|
|
|
select.removeAttr('multiple');
|
2012-01-24 22:02:22 +04:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
select.attr('multiple', true);
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function submit_query_form(id) {
|
|
|
|
selectAllOptions("selected_columns");
|
2012-07-22 17:29:26 +04:00
|
|
|
$('#'+id).submit();
|
2012-01-24 22:02:22 +04:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function observeIssueFilters() {
|
|
|
|
$('#query_form input[type=text]').keypress(function(e){
|
|
|
|
if (e.keyCode == 13) submit_query_form("query_form");
|
2012-01-24 22:02:22 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2008-02-29 22:46:58 +03:00
|
|
|
var fileFieldCount = 1;
|
2007-04-04 22:20:45 +04:00
|
|
|
function addFileField() {
|
2012-07-22 17:29:26 +04:00
|
|
|
var fields = $('#attachments_fields');
|
|
|
|
if (fields.children().length >= 10) return false;
|
2011-07-10 00:11:18 +04:00
|
|
|
fileFieldCount++;
|
2012-07-22 17:29:26 +04:00
|
|
|
var s = fields.children('span').first().clone();
|
|
|
|
s.children('input.file').attr('name', "attachments[" + fileFieldCount + "][file]").val('');
|
|
|
|
s.children('input.description').attr('name', "attachments[" + fileFieldCount + "][description]").val('');
|
|
|
|
fields.append(s);
|
2007-04-04 22:20:45 +04:00
|
|
|
}
|
|
|
|
|
2011-07-10 00:11:18 +04:00
|
|
|
function removeFileField(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var fields = $('#attachments_fields');
|
|
|
|
var s = $(el).parents('span').first();
|
|
|
|
if (fields.children().length > 1) {
|
2012-02-10 04:35:58 +04:00
|
|
|
s.remove();
|
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
s.children('input.file').val('');
|
|
|
|
s.children('input.description').val('');
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2011-07-10 00:11:18 +04:00
|
|
|
}
|
|
|
|
|
2011-11-26 02:32:07 +04:00
|
|
|
function checkFileSize(el, maxSize, message) {
|
|
|
|
var files = el.files;
|
|
|
|
if (files) {
|
|
|
|
for (var i=0; i<files.length; i++) {
|
|
|
|
if (files[i].size > maxSize) {
|
|
|
|
alert(message);
|
|
|
|
el.value = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-04 22:20:45 +04:00
|
|
|
function showTab(name) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('div#content .tab-content').hide();
|
|
|
|
$('div.tabs a').removeClass('selected');
|
|
|
|
$('#tab-content-' + name).show();
|
|
|
|
$('#tab-' + name).addClass('selected');
|
2012-02-10 04:35:58 +04:00
|
|
|
return false;
|
2007-04-27 23:32:57 +04:00
|
|
|
}
|
|
|
|
|
2009-12-14 23:13:29 +03:00
|
|
|
function moveTabRight(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var lis = $(el).parents('div.tabs').first().find('ul').children();
|
2012-02-10 04:35:58 +04:00
|
|
|
var tabsWidth = 0;
|
2012-07-22 17:29:26 +04:00
|
|
|
var i = 0;
|
|
|
|
lis.each(function(){
|
|
|
|
if ($(this).is(':visible')) {
|
|
|
|
tabsWidth += $(this).width() + 6;
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
|
|
|
if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; }
|
|
|
|
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
|
|
|
|
lis.eq(i).hide();
|
2009-12-14 23:13:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function moveTabLeft(el) {
|
2012-07-22 17:29:26 +04:00
|
|
|
var lis = $(el).parents('div.tabs').first().find('ul').children();
|
2012-02-10 04:35:58 +04:00
|
|
|
var i = 0;
|
2012-07-22 17:29:26 +04:00
|
|
|
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
|
2012-02-10 04:35:58 +04:00
|
|
|
if (i>0) {
|
2012-07-22 17:29:26 +04:00
|
|
|
lis.eq(i-1).show();
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2009-12-14 23:13:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function displayTabsButtons() {
|
2012-02-10 04:35:58 +04:00
|
|
|
var lis;
|
|
|
|
var tabsWidth = 0;
|
2012-07-22 17:29:26 +04:00
|
|
|
var el;
|
|
|
|
$('div.tabs').each(function() {
|
|
|
|
el = $(this);
|
|
|
|
lis = el.find('ul').children();
|
|
|
|
lis.each(function(){
|
|
|
|
if ($(this).is(':visible')) {
|
|
|
|
tabsWidth += $(this).width() + 6;
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
|
|
|
if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) {
|
|
|
|
el.find('div.tabs-buttons').hide();
|
2012-02-10 04:35:58 +04:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
el.find('div.tabs-buttons').show();
|
2012-02-10 04:35:58 +04:00
|
|
|
}
|
|
|
|
});
|
2009-12-14 23:13:29 +03:00
|
|
|
}
|
|
|
|
|
2007-05-05 17:22:27 +04:00
|
|
|
function setPredecessorFieldsVisibility() {
|
2012-07-22 17:29:26 +04:00
|
|
|
var relationType = $('#relation_relation_type');
|
|
|
|
if (relationType.val() == "precedes" || relationType.val() == "follows") {
|
|
|
|
$('#predecessor_fields').show();
|
|
|
|
} else {
|
|
|
|
$('#predecessor_fields').hide();
|
|
|
|
}
|
2007-08-16 20:45:06 +04:00
|
|
|
}
|
|
|
|
|
2011-11-20 17:23:20 +04:00
|
|
|
function showModal(id, width) {
|
2012-07-22 19:42:29 +04:00
|
|
|
var el = $('#'+id).first();
|
2012-07-22 17:29:26 +04:00
|
|
|
if (el.length == 0 || el.is(':visible')) {return;}
|
2012-07-22 19:42:29 +04:00
|
|
|
var title = el.find('h3.title').text();
|
|
|
|
el.dialog({
|
|
|
|
width: width,
|
|
|
|
modal: true,
|
|
|
|
resizable: false,
|
|
|
|
dialogClass: 'modal',
|
|
|
|
title: title
|
|
|
|
});
|
2012-07-22 17:29:26 +04:00
|
|
|
el.find("input[type=text], input[type=submit]").first().focus();
|
2011-11-20 17:23:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideModal(el) {
|
2012-02-11 17:05:41 +04:00
|
|
|
var modal;
|
2012-07-22 17:29:26 +04:00
|
|
|
if (el) {
|
2012-07-22 19:42:29 +04:00
|
|
|
modal = $(el).parents('.ui-dialog-content');
|
2012-07-22 17:29:26 +04:00
|
|
|
} else {
|
|
|
|
modal = $('#ajax-modal');
|
2011-11-20 17:23:20 +04:00
|
|
|
}
|
2012-07-22 19:42:29 +04:00
|
|
|
modal.dialog("close");
|
2011-11-20 17:23:20 +04:00
|
|
|
}
|
|
|
|
|
2012-07-18 21:47:19 +04:00
|
|
|
function submitPreview(url, form, target) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'post',
|
|
|
|
data: $('#'+form).serialize(),
|
|
|
|
success: function(data){
|
|
|
|
$('#'+target).html(data);
|
|
|
|
}
|
2012-07-18 21:47:19 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2007-10-22 23:34:21 +04:00
|
|
|
function collapseScmEntry(id) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('.'+id).each(function() {
|
|
|
|
if ($(this).hasClass('open')) {
|
|
|
|
collapseScmEntry($(this).attr('id'));
|
|
|
|
}
|
|
|
|
$(this).hide();
|
|
|
|
});
|
|
|
|
$('#'+id).removeClass('open');
|
2007-10-22 23:34:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function expandScmEntry(id) {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('.'+id).each(function() {
|
|
|
|
$(this).show();
|
|
|
|
if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
|
|
|
|
expandScmEntry($(this).attr('id'));
|
2007-10-22 23:34:21 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
|
|
|
$('#'+id).addClass('open');
|
2007-10-22 23:34:21 +04:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function scmEntryClick(id, url) {
|
|
|
|
el = $('#'+id);
|
|
|
|
if (el.hasClass('open')) {
|
2007-10-22 23:34:21 +04:00
|
|
|
collapseScmEntry(id);
|
2012-07-22 17:29:26 +04:00
|
|
|
el.addClass('collapsed');
|
2007-10-22 23:34:21 +04:00
|
|
|
return false;
|
2012-07-22 17:29:26 +04:00
|
|
|
} else if (el.hasClass('loaded')) {
|
2007-10-22 23:34:21 +04:00
|
|
|
expandScmEntry(id);
|
2012-07-22 17:29:26 +04:00
|
|
|
el.removeClass('collapsed');
|
2007-10-22 23:34:21 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
if (el.hasClass('loading')) {
|
2007-10-24 00:42:15 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
el.addClass('loading');
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
success: function(data){
|
|
|
|
el.after(data);
|
|
|
|
el.addClass('open').addClass('loaded').removeClass('loading');
|
|
|
|
}
|
|
|
|
});
|
2007-10-22 23:34:21 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-25 23:25:28 +04:00
|
|
|
function randomKey(size) {
|
2012-02-10 04:35:58 +04:00
|
|
|
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;
|
2008-06-25 23:25:28 +04:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
// Can't use Rails' remote select because we need the form data
|
|
|
|
function updateIssueFrom(url) {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'post',
|
|
|
|
data: $('#issue-form').serialize()
|
|
|
|
});
|
2010-03-13 17:56:49 +03:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function updateBulkEditFrom(url) {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'post',
|
|
|
|
data: $('#bulk_edit_form').serialize()
|
|
|
|
});
|
2010-12-12 19:04:28 +03:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function observeAutocompleteField(fieldId, url) {
|
|
|
|
$('#'+fieldId).autocomplete({
|
|
|
|
source: url,
|
|
|
|
minLength: 2,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function observeSearchfield(fieldId, targetId, url) {
|
|
|
|
$('#'+fieldId).each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.attr('data-value-was', $this.val());
|
|
|
|
var check = function() {
|
|
|
|
var val = $this.val();
|
|
|
|
if ($this.attr('data-value-was') != val){
|
|
|
|
$this.attr('data-value-was', val);
|
|
|
|
if (val != '') {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'get',
|
|
|
|
data: {q: $this.val()},
|
|
|
|
success: function(data){ $('#'+targetId).html(data); },
|
|
|
|
beforeSend: function(){ $this.addClass('ajax-loading'); },
|
|
|
|
complete: function(){ $this.removeClass('ajax-loading'); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var reset = function() {
|
|
|
|
if (timer) {
|
|
|
|
clearInterval(timer);
|
|
|
|
timer = setInterval(check, 300);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var timer = setInterval(check, 300);
|
|
|
|
$this.bind('keyup click mousemove', reset);
|
|
|
|
});
|
2011-01-07 00:02:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function observeProjectModules() {
|
|
|
|
var f = function() {
|
|
|
|
/* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */
|
2012-07-22 17:29:26 +04:00
|
|
|
if ($('#project_enabled_module_names_issue_tracking').attr('checked')) {
|
|
|
|
$('#project_trackers').show();
|
|
|
|
}else{
|
|
|
|
$('#project_trackers').hide();
|
|
|
|
}
|
2011-01-07 00:02:19 +03:00
|
|
|
};
|
2012-02-10 04:36:21 +04:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
$(window).load(f);
|
|
|
|
$('#project_enabled_module_names_issue_tracking').change(f);
|
2011-01-07 00:02:19 +03:00
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
function initMyPageSortable(list, url) {
|
|
|
|
$('#list-'+list).sortable({
|
|
|
|
connectWith: '.block-receiver',
|
|
|
|
tolerance: 'pointer',
|
|
|
|
update: function(){
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'post',
|
|
|
|
data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#list-top, #list-left, #list-right").disableSelection();
|
|
|
|
}
|
2012-02-10 04:36:21 +04:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
var warnLeavingUnsavedMessage;
|
|
|
|
function warnLeavingUnsaved(message) {
|
|
|
|
warnLeavingUnsavedMessage = message;
|
2012-02-10 04:36:21 +04:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
$('form').submit(function(){
|
|
|
|
$('textarea').removeData('changed');
|
|
|
|
});
|
|
|
|
$('textarea').change(function(){
|
|
|
|
$(this).data('changed', 'changed');
|
|
|
|
});
|
|
|
|
window.onbeforeunload = function(){
|
|
|
|
var warn = false;
|
|
|
|
$('textarea').blur().each(function(){
|
|
|
|
if ($(this).data('changed')) {
|
|
|
|
warn = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (warn) {return warnLeavingUnsavedMessage;}
|
|
|
|
};
|
|
|
|
};
|
2011-01-07 00:02:19 +03:00
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
$(document).ready(function(){
|
|
|
|
$('#ajax-indicator').bind('ajaxSend', function(){
|
|
|
|
if ($('.ajax-loading').length == 0) {
|
|
|
|
$('#ajax-indicator').show();
|
2007-04-27 23:32:57 +04:00
|
|
|
}
|
2012-07-22 17:29:26 +04:00
|
|
|
});
|
|
|
|
$('#ajax-indicator').bind('ajaxStop', function(){
|
|
|
|
$('#ajax-indicator').hide();
|
|
|
|
});
|
2007-04-27 23:32:57 +04:00
|
|
|
});
|
2010-02-25 00:23:20 +03:00
|
|
|
|
2010-06-19 23:51:43 +04:00
|
|
|
function hideOnLoad() {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('.hol').hide();
|
2010-06-19 23:51:43 +04:00
|
|
|
}
|
|
|
|
|
2012-04-13 21:01:46 +04:00
|
|
|
function addFormObserversForDoubleSubmit() {
|
2012-07-22 17:29:26 +04:00
|
|
|
$('form[method=post]').each(function() {
|
|
|
|
if (!$(this).hasClass('multiple-submit')) {
|
|
|
|
$(this).submit(function(form_submission) {
|
|
|
|
if ($(form_submission.target).attr('data-submitted')) {
|
|
|
|
form_submission.preventDefault();
|
2012-04-19 11:17:48 +04:00
|
|
|
} else {
|
2012-07-22 17:29:26 +04:00
|
|
|
$(form_submission.target).attr('data-submitted', true);
|
2012-04-19 11:17:48 +04:00
|
|
|
}
|
2012-04-13 21:01:46 +04:00
|
|
|
});
|
2012-04-19 11:17:48 +04:00
|
|
|
}
|
2012-04-13 21:01:46 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-07-22 17:29:26 +04:00
|
|
|
$(document).ready(hideOnLoad);
|
|
|
|
$(document).ready(addFormObserversForDoubleSubmit);
|