2014-04-18 10:46:29 +08:00
|
|
|
|
//= require_directory ./rateable
|
2013-08-01 10:33:49 +08:00
|
|
|
|
/* Redmine - project management software
|
2014-11-05 15:01:36 +08:00
|
|
|
|
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
2013-08-01 10:33:49 +08:00
|
|
|
|
|
2014-03-31 15:36:51 +08:00
|
|
|
|
function cleanArray (actual){
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var newArray = new Array();
|
2014-03-31 15:36:51 +08:00
|
|
|
|
for (var i = 0; i< actual.length; i++){
|
2014-11-05 15:01:36 +08:00
|
|
|
|
if (actual[i]){
|
|
|
|
|
newArray.push(actual[i]);
|
|
|
|
|
}
|
2014-03-31 15:36:51 +08:00
|
|
|
|
}
|
2014-11-05 15:01:36 +08:00
|
|
|
|
return newArray;
|
2014-03-31 15:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
|
function checkAll(id, checked) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
if (checked) {
|
|
|
|
|
$('#'+id).find('input[type=checkbox]').attr('checked', true);
|
|
|
|
|
} else {
|
|
|
|
|
$('#'+id).find('input[type=checkbox]').removeAttr('checked');
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleCheckboxesBySelector(selector) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var all_checked = true;
|
|
|
|
|
$(selector).each(function(index) {
|
|
|
|
|
if (!$(this).is(':checked')) { all_checked = false; }
|
|
|
|
|
});
|
|
|
|
|
$(selector).attr('checked', !all_checked);
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showAndScrollTo(id, focus) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#'+id).show();
|
|
|
|
|
if (focus !== null) {
|
|
|
|
|
$('#'+focus).focus();
|
|
|
|
|
}
|
|
|
|
|
$('html, body').animate({scrollTop: $('#'+id).offset().top}, 400);
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleRowGroup(el) {
|
2014-11-05 15:01:36 +08: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');
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function collapseAllRowGroups(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var tbody = $(el).parents('tbody').first();
|
|
|
|
|
tbody.children('tr').each(function(index) {
|
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
|
$(this).removeClass('open');
|
|
|
|
|
} else {
|
|
|
|
|
$(this).hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expandAllRowGroups(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var tbody = $(el).parents('tbody').first();
|
|
|
|
|
tbody.children('tr').each(function(index) {
|
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
|
$(this).addClass('open');
|
|
|
|
|
} else {
|
|
|
|
|
$(this).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleAllRowGroups(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var tr = $(el).parents('tr').first();
|
|
|
|
|
if (tr.hasClass('open')) {
|
|
|
|
|
collapseAllRowGroups(el);
|
|
|
|
|
} else {
|
|
|
|
|
expandAllRowGroups(el);
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleFieldset(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldset = $(el).parents('fieldset').first();
|
|
|
|
|
fieldset.toggleClass('collapsed');
|
|
|
|
|
fieldset.children('div').toggle();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideFieldset(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldset = $(el).parents('fieldset').first();
|
|
|
|
|
fieldset.toggleClass('collapsed');
|
|
|
|
|
fieldset.children('div').hide();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initFilters(){
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#add_filter_select').change(function(){
|
|
|
|
|
addFilter($(this).val(), '', []);
|
|
|
|
|
});
|
|
|
|
|
$('#filters-table td.field input[type=checkbox]').each(function(){
|
|
|
|
|
toggleFilter($(this).val());
|
|
|
|
|
});
|
|
|
|
|
$('#filters-table td.field input[type=checkbox]').live('click',function(){
|
|
|
|
|
toggleFilter($(this).val());
|
|
|
|
|
});
|
|
|
|
|
$('#filters-table .toggle-multiselect').live('click',function(){
|
|
|
|
|
toggleMultiSelect($(this).siblings('select'));
|
|
|
|
|
});
|
|
|
|
|
$('#filters-table input[type=text]').live('keypress', function(e){
|
|
|
|
|
if (e.keyCode == 13) submit_query_form("query_form");
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addFilter(field, operator, values) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldId = field.replace('.', '_');
|
|
|
|
|
var tr = $('#tr_'+fieldId);
|
|
|
|
|
if (tr.length > 0) {
|
|
|
|
|
tr.show();
|
|
|
|
|
} else {
|
|
|
|
|
buildFilterRow(field, operator, values);
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#cb_'+fieldId).attr('checked', true);
|
|
|
|
|
toggleFilter(field);
|
|
|
|
|
$('#add_filter_select').val('').children('option').each(function(){
|
|
|
|
|
if ($(this).attr('value') == field) {
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildFilterRow(field, operator, values) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldId = field.replace('.', '_');
|
|
|
|
|
var filterTable = $("#filters-table");
|
|
|
|
|
var filterOptions = availableFilters[field];
|
|
|
|
|
var operators = operatorByType[filterOptions['type']];
|
|
|
|
|
var filterValues = filterOptions['values'];
|
|
|
|
|
var i, select;
|
|
|
|
|
|
|
|
|
|
var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
|
|
|
|
|
'<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
|
|
|
|
|
'<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
|
|
|
|
|
'<td class="values"></td>'
|
2013-08-01 10:33:49 +08:00
|
|
|
|
);
|
2014-11-05 15:01:36 +08:00
|
|
|
|
filterTable.append(tr);
|
|
|
|
|
|
|
|
|
|
select = tr.find('td.operator select');
|
|
|
|
|
for (i=0;i<operators.length;i++){
|
|
|
|
|
var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
|
|
|
|
|
if (operators[i] == operator) { option.attr('selected', true); }
|
|
|
|
|
select.append(option);
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
2014-11-05 15:01:36 +08:00
|
|
|
|
select.change(function(){ toggleOperator(field); });
|
|
|
|
|
|
|
|
|
|
switch (filterOptions['type']){
|
|
|
|
|
case "list":
|
|
|
|
|
case "list_optional":
|
|
|
|
|
case "list_status":
|
|
|
|
|
case "list_subprojects":
|
|
|
|
|
tr.find('td.values').append(
|
|
|
|
|
'<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
|
|
|
|
|
' <span class="toggle-multiselect"><a>复选/multi-select</a></span></span>'
|
|
|
|
|
);
|
|
|
|
|
select = tr.find('td.values select');
|
|
|
|
|
if (values.length > 1) { select.attr('multiple', true); }
|
|
|
|
|
for (i=0;i<filterValues.length;i++){
|
|
|
|
|
var filterValue = filterValues[i];
|
|
|
|
|
var option = $('<option>');
|
|
|
|
|
if ($.isArray(filterValue)) {
|
|
|
|
|
option.val(filterValue[1]).text(filterValue[0]);
|
|
|
|
|
if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
|
|
|
|
|
} else {
|
|
|
|
|
option.val(filterValue).text(filterValue);
|
|
|
|
|
if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
|
|
|
|
|
}
|
|
|
|
|
select.append(option);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "date":
|
|
|
|
|
case "date_past":
|
|
|
|
|
tr.find('td.values').append(
|
|
|
|
|
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
|
|
|
|
|
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
|
|
|
|
|
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
|
|
|
|
|
);
|
|
|
|
|
$('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions);
|
|
|
|
|
$('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions);
|
|
|
|
|
$('#values_'+fieldId).val(values[0]);
|
|
|
|
|
break;
|
|
|
|
|
case "string":
|
|
|
|
|
case "text":
|
|
|
|
|
tr.find('td.values').append(
|
|
|
|
|
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
|
|
|
|
|
);
|
|
|
|
|
$('#values_'+fieldId).val(values[0]);
|
|
|
|
|
break;
|
|
|
|
|
case "relation":
|
|
|
|
|
tr.find('td.values').append(
|
|
|
|
|
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
|
|
|
|
|
'<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
|
|
|
|
|
);
|
|
|
|
|
$('#values_'+fieldId).val(values[0]);
|
|
|
|
|
select = tr.find('td.values select');
|
|
|
|
|
for (i=0;i<allProjects.length;i++){
|
|
|
|
|
var filterValue = allProjects[i];
|
|
|
|
|
var option = $('<option>');
|
|
|
|
|
option.val(filterValue[1]).text(filterValue[0]);
|
|
|
|
|
if (values[0] == filterValue[1]) { option.attr('selected', true); }
|
|
|
|
|
select.append(option);
|
|
|
|
|
}
|
|
|
|
|
case "integer":
|
|
|
|
|
case "float":
|
|
|
|
|
tr.find('td.values').append(
|
|
|
|
|
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' +
|
|
|
|
|
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>'
|
|
|
|
|
);
|
|
|
|
|
$('#values_'+fieldId+'_1').val(values[0]);
|
|
|
|
|
$('#values_'+fieldId+'_2').val(values[1]);
|
|
|
|
|
break;
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleFilter(field) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldId = field.replace('.', '_');
|
|
|
|
|
if ($('#cb_' + fieldId).is(':checked')) {
|
|
|
|
|
$("#operators_" + fieldId).show().removeAttr('disabled');
|
|
|
|
|
toggleOperator(field);
|
|
|
|
|
} else {
|
|
|
|
|
$("#operators_" + fieldId).hide().attr('disabled', true);
|
|
|
|
|
enableValues(field, []);
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enableValues(field, indexes) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldId = field.replace('.', '_');
|
|
|
|
|
$('#tr_'+fieldId+' td.values .value').each(function(index) {
|
|
|
|
|
if ($.inArray(index, indexes) >= 0) {
|
|
|
|
|
$(this).removeAttr('disabled');
|
|
|
|
|
$(this).parents('span').first().show();
|
|
|
|
|
} else {
|
|
|
|
|
$(this).val('');
|
|
|
|
|
$(this).attr('disabled', true);
|
|
|
|
|
$(this).parents('span').first().hide();
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
|
2014-11-05 15:01:36 +08:00
|
|
|
|
if ($(this).hasClass('group')) {
|
|
|
|
|
$(this).addClass('open');
|
|
|
|
|
} else {
|
|
|
|
|
$(this).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleOperator(field) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var fieldId = field.replace('.', '_');
|
|
|
|
|
var operator = $("#operators_" + fieldId);
|
|
|
|
|
switch (operator.val()) {
|
|
|
|
|
case "!*":
|
|
|
|
|
case "*":
|
|
|
|
|
case "t":
|
|
|
|
|
case "ld":
|
|
|
|
|
case "w":
|
|
|
|
|
case "lw":
|
|
|
|
|
case "l2w":
|
|
|
|
|
case "m":
|
|
|
|
|
case "lm":
|
|
|
|
|
case "y":
|
|
|
|
|
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-":
|
|
|
|
|
case "><t-":
|
|
|
|
|
case "t-":
|
|
|
|
|
enableValues(field, [2]);
|
|
|
|
|
break;
|
|
|
|
|
case "=p":
|
|
|
|
|
case "=!p":
|
|
|
|
|
case "!p":
|
|
|
|
|
enableValues(field, [1]);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
enableValues(field, [0]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleMultiSelect(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
if (el.attr('multiple')) {
|
|
|
|
|
el.removeAttr('multiple');
|
|
|
|
|
} else {
|
|
|
|
|
el.attr('multiple', true);
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submit_query_form(id) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
selectAllOptions("selected_columns");
|
|
|
|
|
$('#'+id).submit();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showTab(name) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('div#content .tab-content').hide();
|
|
|
|
|
$('div.tabs a').removeClass('selected');
|
|
|
|
|
$('#tab-content-' + name).show();
|
|
|
|
|
$('#tab-' + name).addClass('selected');
|
|
|
|
|
return false;
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveTabRight(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var lis = $(el).parents('div.tabs').first().find('ul').children();
|
|
|
|
|
var tabsWidth = 0;
|
|
|
|
|
var i = 0;
|
|
|
|
|
lis.each(function(){
|
|
|
|
|
if ($(this).is(':visible')) {
|
|
|
|
|
tabsWidth += $(this).width() + 6;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; }
|
|
|
|
|
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
|
|
|
|
|
lis.eq(i).hide();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveTabLeft(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var lis = $(el).parents('div.tabs').first().find('ul').children();
|
|
|
|
|
var i = 0;
|
|
|
|
|
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
|
|
|
|
|
if (i>0) {
|
|
|
|
|
lis.eq(i-1).show();
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function displayTabsButtons() {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var lis;
|
|
|
|
|
var tabsWidth = 0;
|
|
|
|
|
var el;
|
|
|
|
|
$('div.tabs').each(function() {
|
|
|
|
|
el = $(this);
|
|
|
|
|
lis = el.find('ul').children();
|
|
|
|
|
lis.each(function(){
|
|
|
|
|
if ($(this).is(':visible')) {
|
|
|
|
|
tabsWidth += $(this).width() + 6;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) {
|
|
|
|
|
el.find('div.tabs-buttons').hide();
|
|
|
|
|
} else {
|
|
|
|
|
el.find('div.tabs-buttons').show();
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setPredecessorFieldsVisibility() {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var relationType = $('#relation_relation_type');
|
|
|
|
|
if (relationType.val() == "precedes" || relationType.val() == "follows") {
|
|
|
|
|
$('#predecessor_fields').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#predecessor_fields').hide();
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showModal(id, width) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var el = $('#'+id).first();
|
|
|
|
|
if (el.length === 0 || el.is(':visible')) {return;}
|
|
|
|
|
var title = el.find('h3.title').text();
|
|
|
|
|
el.dialog({
|
|
|
|
|
width: width,
|
|
|
|
|
modal: true,
|
|
|
|
|
resizable: false,
|
|
|
|
|
dialogClass: 'modal',
|
|
|
|
|
title: title
|
|
|
|
|
});
|
|
|
|
|
el.find("input[type=text], input[type=submit]").first().focus();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideModal(el) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var modal;
|
|
|
|
|
if (el) {
|
|
|
|
|
modal = $(el).parents('.ui-dialog-content');
|
|
|
|
|
} else {
|
|
|
|
|
modal = $('#ajax-modal');
|
|
|
|
|
}
|
|
|
|
|
modal.dialog("close");
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submitPreview(url, form, target) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'post',
|
|
|
|
|
data: $('#'+form).serialize(),
|
|
|
|
|
success: function(data){
|
|
|
|
|
$('#'+target).html(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function collapseScmEntry(id) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('.'+id).each(function() {
|
|
|
|
|
if ($(this).hasClass('open')) {
|
|
|
|
|
collapseScmEntry($(this).attr('id'));
|
|
|
|
|
}
|
|
|
|
|
$(this).hide();
|
|
|
|
|
});
|
|
|
|
|
$('#'+id).removeClass('open');
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expandScmEntry(id) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('.'+id).each(function() {
|
|
|
|
|
$(this).show();
|
|
|
|
|
if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
|
|
|
|
|
expandScmEntry($(this).attr('id'));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$('#'+id).addClass('open');
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function scmEntryClick(id, url) {
|
|
|
|
|
el = $('#'+id);
|
|
|
|
|
if (el.hasClass('open')) {
|
|
|
|
|
collapseScmEntry(id);
|
|
|
|
|
el.addClass('collapsed');
|
|
|
|
|
return false;
|
|
|
|
|
} else if (el.hasClass('loaded')) {
|
|
|
|
|
expandScmEntry(id);
|
|
|
|
|
el.removeClass('collapsed');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (el.hasClass('loading')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
el.addClass('loading');
|
|
|
|
|
$.ajax({
|
2014-11-05 15:01:36 +08:00
|
|
|
|
url: url,
|
|
|
|
|
success: function(data){
|
|
|
|
|
el.after(data);
|
|
|
|
|
el.addClass('open').addClass('loaded').removeClass('loading');
|
|
|
|
|
}
|
2013-08-01 10:33:49 +08:00
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function randomKey(size) {
|
2014-11-05 15:01:36 +08: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;
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Can't use Rails' remote select because we need the form data
|
|
|
|
|
function updateIssueFrom(url) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'post',
|
|
|
|
|
data: $('#issue-form').serialize()
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBulkEditFrom(url) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'post',
|
|
|
|
|
data: $('#bulk_edit_form').serialize()
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearMessage(id) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#'+id).val("");
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function observeAutocompleteField(fieldId, url, options) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
$('#'+fieldId).autocomplete($.extend({
|
|
|
|
|
source: url,
|
|
|
|
|
select: function(e,ui){self.location="/issues/"+ui.item.value;},
|
|
|
|
|
minLength: 2,
|
|
|
|
|
search: function(){$('#'+fieldId).addClass('ajax-loading');},
|
|
|
|
|
response: function(){$('#'+fieldId).removeClass('ajax-loading');
|
|
|
|
|
}
|
|
|
|
|
}, options));
|
|
|
|
|
$('#'+fieldId).addClass('autocomplete');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function observeSearchfield(fieldId, targetId, url) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#'+fieldId).each(function() {
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
$this.addClass('autocomplete');
|
|
|
|
|
$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);
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'get',
|
|
|
|
|
data: {q: $this.val()},
|
|
|
|
|
success: function(data){ if(targetId) $('#'+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);
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function observeProjectModules() {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
var f = function() {
|
|
|
|
|
/* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */
|
|
|
|
|
if ($('#project_enabled_module_names_issue_tracking').attr('checked')) {
|
|
|
|
|
$('#project_trackers').show();
|
|
|
|
|
}else{
|
|
|
|
|
$('#project_trackers').hide();
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-08-01 10:33:49 +08:00
|
|
|
|
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$(window).load(f);
|
|
|
|
|
$('#project_enabled_module_names_issue_tracking').change(f);
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initMyPageSortable(list, url) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#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();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var warnLeavingUnsavedMessage;
|
|
|
|
|
function warnLeavingUnsaved(message) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
warnLeavingUnsavedMessage = message;
|
|
|
|
|
|
|
|
|
|
$('form').submit(function(){
|
|
|
|
|
$('textarea').removeData('changed');
|
|
|
|
|
});
|
|
|
|
|
$('textarea').change(function(){
|
|
|
|
|
$(this).data('changed', 'changed');
|
2013-08-01 10:33:49 +08:00
|
|
|
|
});
|
2014-11-05 15:01:36 +08:00
|
|
|
|
window.onbeforeunload = function(){
|
|
|
|
|
var warn = false;
|
|
|
|
|
$('textarea').blur().each(function(){
|
|
|
|
|
if ($(this).data('changed')) {
|
|
|
|
|
warn = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (warn) {return warnLeavingUnsavedMessage;}
|
|
|
|
|
};
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupAjaxIndicator() {
|
|
|
|
|
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
|
2014-07-15 16:13:50 +08:00
|
|
|
|
|
2014-11-05 15:01:36 +08:00
|
|
|
|
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
|
|
|
|
|
$('#ajax-indicator').show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#ajax-indicator').bind('ajaxStop', function() {
|
|
|
|
|
$('#ajax-indicator').hide();
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideOnLoad() {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('.hol').hide();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addFormObserversForDoubleSubmit() {
|
2014-11-05 15:01:36 +08: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();
|
|
|
|
|
} else {
|
|
|
|
|
$(form_submission.target).attr('data-submitted', true);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
2014-11-05 15:01:36 +08:00
|
|
|
|
});
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function blockEventPropagation(event) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
2013-08-01 10:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-26 10:52:16 +08:00
|
|
|
|
function toggleAndSettingWordsVal(parent_widget, text_widget, value){
|
2014-11-05 15:01:36 +08:00
|
|
|
|
text_widget.val(value)
|
|
|
|
|
parent_widget.slideToggle(400)
|
2013-12-26 10:52:16 +08:00
|
|
|
|
}
|
2014-05-20 09:50:28 +08:00
|
|
|
|
function transpotUrl (scope) {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$(scope).each(function(){
|
|
|
|
|
var tmpContent = $(this).html();
|
|
|
|
|
tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,,]+)/gi,"$1<a href='$2$3' target='_blank'>$2$3<\/a>");
|
|
|
|
|
// tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,,]+)/gi,"$1<a href='http:\/\/$2' style='color:blue' target='_blank'>$2</a>");
|
|
|
|
|
$(this).html(tmpContent);
|
|
|
|
|
});
|
2014-05-20 09:50:28 +08:00
|
|
|
|
}
|
2013-12-26 10:52:16 +08:00
|
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
|
$(document).ready(setupAjaxIndicator);
|
|
|
|
|
$(document).ready(hideOnLoad);
|
|
|
|
|
$(document).ready(addFormObserversForDoubleSubmit);
|
2013-09-27 14:58:51 +08:00
|
|
|
|
|
2014-07-10 10:05:45 +08:00
|
|
|
|
function img_thumbnails() {
|
2014-11-05 15:01:36 +08:00
|
|
|
|
$('.thumbnails a').colorbox({rel:'nofollow'});
|
|
|
|
|
$('.attachments').find('a').each(function(index, element) {
|
|
|
|
|
var href_value = $(element).attr('href');
|
|
|
|
|
if (/\.(jpg|png|gif|bmp)$/.test(href_value)) {
|
|
|
|
|
$(element).colorbox({rel:'nofollow'});
|
|
|
|
|
}
|
2014-07-10 10:12:16 +08:00
|
|
|
|
|
2014-11-05 15:01:36 +08:00
|
|
|
|
});
|
2014-07-10 10:05:45 +08:00
|
|
|
|
}
|
|
|
|
|
$(document).ready(img_thumbnails);
|
2014-08-23 10:58:07 +08:00
|
|
|
|
|
|
|
|
|
function TimeClose(dateText, inst) {
|
|
|
|
|
if(inst.id=="issue_start_date"){
|
|
|
|
|
time=dateText;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var time=new Date();
|
|
|
|
|
function TimeBeforeShow(input){
|
|
|
|
|
if(input.id=="issue_due_date"){
|
|
|
|
|
//var minDate = $(input).datepicker('option', 'minDate');
|
|
|
|
|
var tempdata=$("#issue_start_date").attr("value");
|
|
|
|
|
|
|
|
|
|
$(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/")));
|
|
|
|
|
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SetMinValue(){
|
|
|
|
|
/// var tempdata=$("#issue_start_date").attr("value");
|
|
|
|
|
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
|
|
|
|
|
//alert(tempdata);
|
|
|
|
|
//$("#issue_due_date").datepicker({
|
|
|
|
|
// minDate: new Date(2014,08,23)
|
|
|
|
|
//var datepickerOptions=
|
|
|
|
|
//{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
|
|
|
|
|
//alert( $('.issue_due_date').length);
|
|
|
|
|
//$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23));
|
|
|
|
|
//$("#issue_due_date").datepicker(datepickerOptions);
|
|
|
|
|
//$("##{issue_due_date}").datepicker(datepickerOptions);
|
|
|
|
|
//$("#issue_due_date").datepicker(
|
|
|
|
|
// {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}
|
|
|
|
|
//)
|
|
|
|
|
//});
|
|
|
|
|
}
|
|
|
|
|
function PrecentChange(obj){
|
|
|
|
|
var _v= obj;
|
|
|
|
|
if(_v==100)
|
|
|
|
|
{
|
|
|
|
|
//var select=$("select[id='issue_status_id']");
|
|
|
|
|
$("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected");
|
|
|
|
|
}
|
|
|
|
|
else if(_v==0)
|
|
|
|
|
{
|
|
|
|
|
//alert(1);
|
|
|
|
|
$("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected");
|
|
|
|
|
}
|
|
|
|
|
else if(_v!=100&&_v!=0)
|
|
|
|
|
{
|
|
|
|
|
// alert(2);
|
|
|
|
|
$("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected");
|
|
|
|
|
}
|
|
|
|
|
}
|