diff --git a/module/bug/js/batchcreate.js b/module/bug/js/batchcreate.js index 5f208fb928..355e079f91 100644 --- a/module/bug/js/batchcreate.js +++ b/module/bug/js/batchcreate.js @@ -25,7 +25,7 @@ function loadProjectBuilds(productID, projectID, index) $.get(link, function(builds) { - var row = $('#buildBox' + index).parents('tbody').find('tr').size() + var row = $('#buildBox' + index).closest('tbody').find('tr').size() do { var selected = $('#buildBox' + index).find('select').val(); @@ -49,9 +49,9 @@ $(document).on('click', '.chosen-with-drop', function() var select = $(this).prev('select'); if($(select).val() == 'ditto') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { @@ -66,9 +66,9 @@ $(document).on('mousedown', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).parents('td').index(); - var row = $(this).parents('tr').index(); - var table = $(this).parents('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var table = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { diff --git a/module/bug/js/browse.js b/module/bug/js/browse.js index b2d4546ab7..30d3d4c5c1 100644 --- a/module/bug/js/browse.js +++ b/module/bug/js/browse.js @@ -11,7 +11,7 @@ $(document).ready(function() }).on('keyup change paste', 'input', function() { var val = $(this).val().toLowerCase(); - var $options = $(this).parents('ul.dropdown-menu.with-search').find('.option'); + var $options = $(this).closest('ul.dropdown-menu.with-search').find('.option'); if(val == '') return $options.removeClass('hide'); $options.each(function() { diff --git a/module/bug/js/common.js b/module/bug/js/common.js index c12b8db577..9af319cb25 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -426,15 +426,15 @@ function notice() } else { - if($('#buildBox').parents('tr').find('td').size() > 1) + if($('#buildBox').closest('tr').find('td').size() > 1) { - $('#buildBox').parents('td').next().attr('id', 'buildBoxActions'); - $('#buildBox').parents('td').next().html(html); + $('#buildBox').closest('td').next().attr('id', 'buildBoxActions'); + $('#buildBox').closest('td').next().html(html); } else { html = "" + html + ''; - $('#buildBox').parents('td').after(html); + $('#buildBox').closest('td').after(html); } } } diff --git a/module/common/view/noticeimport.html.php b/module/common/view/noticeimport.html.php index 96cc883144..5ab3e2a711 100644 --- a/module/common/view/noticeimport.html.php +++ b/module/common/view/noticeimport.html.php @@ -23,6 +23,6 @@ function submitForm(type) { $('#insert').val('0'); } - $("button[data-toggle='myModal']").parents('form').submit(); + $("button[data-toggle='myModal']").closest('form').submit(); } diff --git a/module/doc/js/edit.js b/module/doc/js/edit.js index 76fd00eb7d..70afdd7caf 100644 --- a/module/doc/js/edit.js +++ b/module/doc/js/edit.js @@ -18,7 +18,7 @@ function loadModule(lib) $.get(createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + root + '&viewType=' + type), function(data) { - $('#module').parents('td').html(data); + $('#module').closest('td').html(data); $("#module").removeAttr('onchange'); $("#module").chosen(defaultChosenOptions); }); @@ -28,18 +28,18 @@ function changeByLib(lib) { if(lib == 'product') { - $('#product').parents('tr').show(); - $('#project').parents('tr').hide(); + $('#product').closest('tr').show(); + $('#project').closest('tr').hide(); } else if(lib == 'project') { - $('#product').parents('tr').show(); - $('#project').parents('tr').show(); + $('#product').closest('tr').show(); + $('#project').closest('tr').show(); } else { - $('#product').parents('tr').hide(); - $('#project').parents('tr').hide(); + $('#product').closest('tr').hide(); + $('#project').closest('tr').hide(); } } diff --git a/module/file/view/buildform.html.php b/module/file/view/buildform.html.php index 0bff28681d..cb6831f4ab 100644 --- a/module/file/view/buildform.html.php +++ b/module/file/view/buildform.html.php @@ -53,7 +53,7 @@ function checkSize(obj) var unit = maxUploadInfo.replace(/\d+/, ''); var maxUploadSize = maxUploadInfo.replace(unit,'') * sizeType[unit]; var fileSize = 0; - $(obj).parents('#fileform').find(':file').each(function() + $(obj).closest('#fileform').find(':file').each(function() { if($(this).val()) fileSize += $(this)[0].files[0].size; }) diff --git a/module/product/js/browse.js b/module/product/js/browse.js index aec0bdbdf5..060728a787 100644 --- a/module/product/js/browse.js +++ b/module/product/js/browse.js @@ -9,7 +9,7 @@ $(function() }).on('keyup change paste', 'input', function() { var val = $(this).val().toLowerCase(); - var $options = $(this).parents('ul.dropdown-menu.with-search').find('.option'); + var $options = $(this).closest('ul.dropdown-menu.with-search').find('.option'); if(val == '') return $options.removeClass('hide'); $options.each(function() { diff --git a/module/productplan/js/view.js b/module/productplan/js/view.js index 5db8a30083..ade756b067 100644 --- a/module/productplan/js/view.js +++ b/module/productplan/js/view.js @@ -32,7 +32,7 @@ $(function() }).on('keyup change paste', 'input', function() { var val = $(this).val().toLowerCase(); - var $options = $(this).parents('ul.dropdown-menu.with-search').find('.option'); + var $options = $(this).closest('ul.dropdown-menu.with-search').find('.option'); if(val == '') return $options.removeClass('hide'); $options.each(function() { diff --git a/module/search/view/buildform.html.php b/module/search/view/buildform.html.php index 12402b40d0..959f4e5a2a 100644 --- a/module/search/view/buildform.html.php +++ b/module/search/view/buildform.html.php @@ -104,11 +104,11 @@ function setDateField(query, fieldNO) $period = $("").appendTo('body'); $period.find('li > a').click(function(event) { - var target = $(query).parents('form').find('#' + $period.data('target')); + var target = $(query).closest('form').find('#' + $period.data('target')); if(target.length) { target.val($(this).attr('href').replace('#', '$')); - $(query).parents('form').find('#operator' + $period.data('fieldNO')).val('between'); + $(query).closest('form').find('#operator' + $period.data('fieldNO')).val('between'); $period.hide(); } event.stopPropagation(); @@ -123,7 +123,7 @@ function setDateField(query, fieldNO) $period.find("li > a[href='" + $e.val().replace('$', '#') + "']").closest('li').addClass('active'); }).on('changeDate', function() { - var opt = $(query).parents('form').find('#operator' + $period.data('fieldNO')); + var opt = $(query).closest('form').find('#operator' + $period.data('fieldNO')); if(opt.val() == 'between') opt.val('<='); $period.hide(); }).on('hide', function(){setTimeout(function(){$period.hide();}, 200);}); @@ -141,31 +141,32 @@ function setField(obj, fieldNO, moduleparams) { var params = moduleparams; var fieldName = $(obj).val(); - $(obj).parents('form').find('#operator' + fieldNO).val(params[fieldName]['operator']); // Set the operator according the param setting. - $(obj).parents('form').find('#valueBox' + fieldNO).html($(obj).parents('form').find('#box' + fieldName).children().clone()); - $(obj).parents('form').find('#valueBox' + fieldNO).children().attr({name : 'value' + fieldNO, id : 'value' + fieldNO}); + console.log(fieldName); + $(obj).closest('form').find('#operator' + fieldNO).val(params[fieldName]['operator']); // Set the operator according the param setting. + $(obj).closest('form').find('#valueBox' + fieldNO).html($(obj).closest('form').find('#box' + fieldName).children().clone()); + $(obj).closest('form').find('#valueBox' + fieldNO).children().attr({name : 'value' + fieldNO, id : 'value' + fieldNO}); if(typeof(params[fieldName]['class']) != undefined && params[fieldName]['class'] == 'date') { - setDateField($(obj).parents('form').find("#value" + fieldNO), fieldNO); - $(obj).parents('form').find("#value" + fieldNO).addClass('date'); // Shortcut the width of the datepicker to make sure align with others. + setDateField($(obj).closest('form').find("#value" + fieldNO), fieldNO); + $(obj).closest('form').find("#value" + fieldNO).addClass('date'); // Shortcut the width of the datepicker to make sure align with others. var groupItems = search->groupItems?>; var maxNO = 2 * groupItems; var nextNO = fieldNO > groupItems ? fieldNO - groupItems + 1 : fieldNO + groupItems; - var nextValue = $(obj).parents('form').find('#value' + nextNO).val(); + var nextValue = $(obj).closest('form').find('#value' + nextNO).val(); if(nextNO <= maxNO && fieldNO < maxNO && (nextValue == '' || nextValue == 0)) { - $(obj).parents('form').find('#field' + nextNO).val($(obj).parents('form').find('#field' + fieldNO).val()); - $(obj).parents('form').find('#operator' + nextNO).val('<='); - $(obj).parents('form').find('#valueBox' + nextNO).html($(obj).parents('form').find('#box' + fieldName).children().clone()); - $(obj).parents('form').find('#valueBox' + nextNO).children().attr({name : 'value' + nextNO, id : 'value' + nextNO}); - setDateField($(obj).parents('form').find("#value" + nextNO), nextNO); - $(obj).parents('form').find("#value" + nextNO).addClass('date'); + $(obj).closest('form').find('#field' + nextNO).val($(obj).closest('form').find('#field' + fieldNO).val()); + $(obj).closest('form').find('#operator' + nextNO).val('<='); + $(obj).closest('form').find('#valueBox' + nextNO).html($(obj).closest('form').find('#box' + fieldName).children().clone()); + $(obj).closest('form').find('#valueBox' + nextNO).children().attr({name : 'value' + nextNO, id : 'value' + nextNO}); + setDateField($(obj).closest('form').find("#value" + nextNO), nextNO); + $(obj).closest('form').find("#value" + nextNO).addClass('date'); } } else if(params[fieldName]['control'] == 'select') { - $(obj).parents('form').find("#value" + fieldNO).chosen(defaultChosenOptions).on('chosen:showing_dropdown', function() + $(obj).closest('form').find("#value" + fieldNO).chosen(defaultChosenOptions).on('chosen:showing_dropdown', function() { var $this = $(this); var $chosen = $this.next('.chosen-container').removeClass('chosen-up'); @@ -185,7 +186,7 @@ function resetForm(obj) { for(i = 1; i <= groupItems * 2; i ++) { - $(obj).parents('form').find('#value' + i).val('').trigger('chosen:updated'); + $(obj).closest('form').find('#value' + i).val('').trigger('chosen:updated'); } } @@ -201,12 +202,12 @@ function showmore(obj) { if(i != 1 && i != groupItems + 1 ) { - $(obj).parents('form').find('#searchbox' + i).removeClass('hidden'); + $(obj).closest('form').find('#searchbox' + i).removeClass('hidden'); } } - $(obj).parents('form').find('#formType').val('more'); - $(obj).parents('form').addClass('showmore'); + $(obj).closest('form').find('#formType').val('more'); + $(obj).closest('form').addClass('showmore'); } /** @@ -221,12 +222,12 @@ function showlite(obj) { if(i != 1 && i != groupItems + 1) { - $(obj).parents('form').find('#value' + i).val(''); - $(obj).parents('form').find('#searchbox' + i).addClass('hidden'); + $(obj).closest('form').find('#value' + i).val(''); + $(obj).closest('form').find('#searchbox' + i).addClass('hidden'); } } - $(obj).parents('form').removeClass('showmore'); - $(obj).parents('form').find('#formType').val('lite'); + $(obj).closest('form').removeClass('showmore'); + $(obj).closest('form').find('#formType').val('lite'); } /** @@ -282,8 +283,8 @@ function deleteQuery() foreach($fieldParams as $fieldName => $param) { echo ""; - if($param['control'] == 'select') echo html::select($fieldName, $param['values'], '', "class='form-control searchSelect'"); - if($param['control'] == 'input') echo html::input($fieldName, '', "class='form-control searchInput'"); + if($param['control'] == 'select') echo html::select('field' . $fieldName, $param['values'], '', "class='form-control searchSelect'"); + if($param['control'] == 'input') echo html::input('field' . $fieldName, '', "class='form-control searchInput'"); echo ''; } ?> diff --git a/module/story/js/batchcreate.js b/module/story/js/batchcreate.js index bc2370a3ea..ed0b319f4d 100644 --- a/module/story/js/batchcreate.js +++ b/module/story/js/batchcreate.js @@ -3,9 +3,9 @@ $(document).on('click', '.chosen-with-drop', function() var select = $(this).prev('select'); if($(select).val() == 'same') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { @@ -20,9 +20,9 @@ $(document).on('mousedown', 'select', function() { if($(this).val() == 'same') { - var index = $(this).parents('td').index(); - var row = $(this).parents('tr').index(); - var table = $(this).parents('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var table = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index a3ffedbdc1..7aad224bf3 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -47,9 +47,9 @@ $(document).on('click', '.chosen-with-drop', function() var select = $(this).prev('select'); if($(select).val() == 'ditto') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { @@ -65,9 +65,9 @@ $(document).on('mousedown', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).parents('td').index(); - var row = $(this).parents('tr').index(); - var table = $(this).parents('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var table = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index b0d766b252..e0cb2f011e 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -24,9 +24,9 @@ $(document).ready(function() } if($(select).val() == 'same') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { @@ -42,9 +42,9 @@ $(document).ready(function() { if($(this).val() == 'same') { - var index = $(this).parents('td').index(); - var row = $(this).parents('tr').index(); - var table = $(this).parents('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var table = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { diff --git a/module/user/js/batchcreate.js b/module/user/js/batchcreate.js index cef8e9f54d..d2858d1c9b 100644 --- a/module/user/js/batchcreate.js +++ b/module/user/js/batchcreate.js @@ -26,9 +26,9 @@ $(document).on('click', '.chosen-with-drop', function() var select = $(this).prev('select'); if($(select).val() == 'ditto') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { diff --git a/module/user/js/batchedit.js b/module/user/js/batchedit.js index b362fedffe..252897a815 100644 --- a/module/user/js/batchedit.js +++ b/module/user/js/batchedit.js @@ -3,9 +3,9 @@ $(document).on('click', '.chosen-with-drop', function() var select = $(this).prev('select'); if($(select).val() == 'ditto') { - var index = $(select).parents('td').index(); - var row = $(select).parents('tr').index(); - var table = $(select).parents('tr').parent(); + var index = $(select).closest('td').index(); + var row = $(select).closest('tr').index(); + var table = $(select).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { @@ -20,9 +20,9 @@ $(document).on('mousedown', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).parents('td').index(); - var row = $(this).parents('tr').index(); - var table = $(this).parents('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var table = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) {