diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 296dbd531..4a34a2f97 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -2404,7 +2404,7 @@ EOF $sJSToken = json_encode($sOwnershipToken); $oPage->add_ready_script( <<SetTransactionId($sTransactionId); $this->add("\n"); - $this->add_ready_script("$(window).unload(function() { OnUnload('$sTransactionId') } );\n"); + $this->add_ready_script("$(window).on('unload', function() { OnUnload('$sTransactionId') } );\n"); } public function WizardFormButtons($iButtonFlags) diff --git a/js/datatable.js b/js/datatable.js index 8c8bc054a..08a09a19e 100644 --- a/js/datatable.js +++ b/js/datatable.js @@ -187,7 +187,7 @@ $(function() // Check if we need to save the settings or not... var oSaveCheck = $('#datatable_dlg_'+sListId).find('input[name=save_settings]'); var oSaveScope = $('#datatable_dlg_'+sListId).find('input[name=scope]:checked'); - if (oSaveCheck.attr('checked')) + if (oSaveCheck.prop('checked')) { if (oSettings.val() == 'defaults') { @@ -209,14 +209,14 @@ $(function() { var sId = new String(this.element.attr('id')); var sListId = sId.replace('datatable_', ''); - $('#datatable_dlg_'+sListId).find('input.specific_settings').attr('checked', 'checked'); + $('#datatable_dlg_'+sListId).find('input.specific_settings').prop('checked', true); }, _updateSaveScope: function() { var sId = new String(this.element.attr('id')); var sListId = sId.replace('datatable_', ''); var oSaveCheck = $('#datatable_dlg_'+sListId).find('input[name=save_settings]'); - if (oSaveCheck.attr('checked')) + if (oSaveCheck.prop('checked')) { $('#datatable_dlg_'+sListId).find('input[name=scope]').each(function() { if ($(this).attr('stay-disabled') != 'true') diff --git a/js/extkeywidget.js b/js/extkeywidget.js index c0c9bf9ac..9afe4e88a 100644 --- a/js/extkeywidget.js +++ b/js/extkeywidget.js @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2017 Combodo SARL +// Copyright (C) 2010-2018 Combodo SARL // // This file is part of iTop. // @@ -34,7 +34,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper this.Init = function() { // make sure that the form is clean - $('#'+this.id+'_btnRemove').attr('disabled','disabled'); + $('#'+this.id+'_btnRemove').prop('disabled','disabled'); $('#'+this.id+'_linksToRemove').val(''); }; @@ -49,7 +49,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper this.Search = function() { - if($('#'+me.id).attr('disabled')) return; // Disabled, do nothing + if($('#'+me.id).prop('disabled')) return; // Disabled, do nothing var value = $('#'+me.id).val(); // Current value // Query the server to get the form to search for target objects @@ -140,7 +140,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper } else { - okBtn.attr('disabled', 'disabled'); + okBtn.prop('disabled', 'disabled'); } }; @@ -303,7 +303,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper this.CreateObject = function(oWizHelper) { - if($('#'+me.id).attr('disabled')) return; // Disabled, do nothing + if($('#'+me.id).prop('disabled')) return; // Disabled, do nothing // Query the server to get the form to create a target object if (me.bSelectMode) { @@ -351,7 +351,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper this.CloseCreateObject = function() { - $('#ac_create_'+me.id).dialog( "close" );console.log('closecreateobj') + $('#ac_create_'+me.id).dialog( "close" ); }; this.OnCloseCreateObject = function() @@ -367,7 +367,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper $('#label_'+me.id).focus(); $('#ac_create_'+me.id).dialog("destroy"); $('#ac_create_'+me.id).remove(); - $('#ajax_'+me.id).html('');console.log('onclosecreateobj') + $('#ajax_'+me.id).html(''); }; this.DoCreateObject = function() @@ -453,10 +453,10 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper this.Update = function() { - if ($('#'+me.id).attr('disabled')) + if ($('#'+me.id).prop('disabled')) { $('#v_'+me.id).html(''); - $('#label_'+me.id).attr('disabled', 'disabled'); + $('#label_'+me.id).prop('disabled', 'disabled'); $('#label_'+me.id).css({'background': 'transparent'}); $('#mini_add_'+me.id).hide(); $('#mini_tree_'+me.id).hide(); diff --git a/js/field_sorter.js b/js/field_sorter.js index 9bae1d56d..a71d0f5a3 100644 --- a/js/field_sorter.js +++ b/js/field_sorter.js @@ -249,12 +249,12 @@ $(function() var oCheckbox = oItem.find('input[type=checkbox]'); var bChecked = false; - if (oCheckbox.attr('checked')) + if (oCheckbox.prop('checked')) { bChecked = true; } var bDisabled = false; - if (oCheckbox.attr('disabled')) + if (oCheckbox.prop('disabled')) { bDisabled = true; } diff --git a/js/jquery.dragtable.js b/js/jquery.dragtable.js index 9595eb731..ff7051540 100644 --- a/js/jquery.dragtable.js +++ b/js/jquery.dragtable.js @@ -1,7 +1,7 @@ /*! * dragtable * - * @Version 2.0.14 + * @Version 2.0.15 * * Copyright (c) 2010-2013, Andres akottr@gmail.com * Dual licensed under the MIT (MIT-LICENSE.txt) @@ -12,6 +12,9 @@ * * Any comment, bug report, feature-request is welcome * Feel free to contact me. + * + * sabello : Updated to remove .attr('checked') in order to comply with jQuery deprecation of this use of .attr + * */ /* TOKNOW: @@ -53,349 +56,351 @@ */ (function($) { - $.widget("akottr.dragtable", { - options: { - revert: false, // smooth revert - dragHandle: '.table-handle', // handle for moving cols, if not exists the whole 'th' is the handle - maxMovingRows: 40, // 1 -> only header. 40 row should be enough, the rest is usually not in the viewport - excludeFooter: false, // excludes the footer row(s) while moving other columns. Make sense if there is a footer with a colspan. */ - onlyHeaderThreshold: 100, // TODO: not implemented yet, switch automatically between entire col moving / only header moving - dragaccept: null, // draggable cols -> default all - persistState: null, // url or function -> plug in your custom persistState function right here. function call is persistState(originalTable) - restoreState: null, // JSON-Object or function: some kind of experimental aka Quick-Hack TODO: do it better - exact: true, // removes pixels, so that the overlay table width fits exactly the original table width - clickDelay: 10, // ms to wait before rendering sortable list and delegating click event - containment: null, // @see http://api.jqueryui.com/sortable/#option-containment, use it if you want to move in 2 dimesnions (together with axis: null) - cursor: 'move', // @see http://api.jqueryui.com/sortable/#option-cursor - cursorAt: false, // @see http://api.jqueryui.com/sortable/#option-cursorAt - distance: 0, // @see http://api.jqueryui.com/sortable/#option-distance, for immediate feedback use "0" - tolerance: 'pointer', // @see http://api.jqueryui.com/sortable/#option-tolerance - axis: 'x', // @see http://api.jqueryui.com/sortable/#option-axis, Only vertical moving is allowed. Use 'x' or null. Use this in conjunction with the 'containment' setting - beforeStart: $.noop, // returning FALSE will stop the execution chain. - beforeMoving: $.noop, - beforeReorganize: $.noop, - beforeStop: $.noop - }, - originalTable: { - el: null, - selectedHandle: null, - sortOrder: null, - startIndex: 0, - endIndex: 0 - }, - sortableTable: { - el: $(), - selectedHandle: $(), - movingRow: $() - }, - persistState: function() { - var _this = this; - this.originalTable.el.find('th').each(function(i) { - if (this.id !== '') { - _this.originalTable.sortOrder[this.id] = i; - } - }); - $.ajax({ - url: this.options.persistState, - data: this.originalTable.sortOrder - }); - }, - /* - * persistObj looks like - * {'id1':'2','id3':'3','id2':'1'} - * table looks like - * | id2 | id1 | id3 | - */ - _restoreState: function(persistObj) { - for (var n in persistObj) { - this.originalTable.startIndex = $('#' + n).closest('th').prevAll().size() + 1; - this.originalTable.endIndex = parseInt(persistObj[n], 10) + 1; - this._bubbleCols(); - } - }, - // bubble the moved col left or right - _bubbleCols: function() { - var i, j, col1, col2; - var from = this.originalTable.startIndex; - var to = this.originalTable.endIndex; - /* Find children thead and tbody. - * Only to process the immediate tr-children. Bugfix for inner tables - */ - var thtb = this.originalTable.el.children(); - if (this.options.excludeFooter) { - thtb = thtb.not('tfoot'); - } - if (from < to) { - for (i = from; i < to; i++) { - col1 = thtb.find('> tr > td:nth-child(' + i + ')') - .add(thtb.find('> tr > th:nth-child(' + i + ')')); - col2 = thtb.find('> tr > td:nth-child(' + (i + 1) + ')') - .add(thtb.find('> tr > th:nth-child(' + (i + 1) + ')')); - for (j = 0; j < col1.length; j++) { - swapNodes(col1[j], col2[j]); - } - } - } else { - for (i = from; i > to; i--) { - col1 = thtb.find('> tr > td:nth-child(' + i + ')') - .add(thtb.find('> tr > th:nth-child(' + i + ')')); - col2 = thtb.find('> tr > td:nth-child(' + (i - 1) + ')') - .add(thtb.find('> tr > th:nth-child(' + (i - 1) + ')')); - for (j = 0; j < col1.length; j++) { - swapNodes(col1[j], col2[j]); - } - } - } - }, - _rearrangeTableBackroundProcessing: function() { - var _this = this; - return function() { - _this._bubbleCols(); - _this.options.beforeStop(_this.originalTable); - _this.sortableTable.el.remove(); - restoreTextSelection(); - // persist state if necessary - if (_this.options.persistState !== null) { - $.isFunction(_this.options.persistState) ? _this.options.persistState(_this.originalTable) : _this.persistState(); - } - }; - }, - _rearrangeTable: function() { - var _this = this; - return function() { - // remove handler-class -> handler is now finished - _this.originalTable.selectedHandle.removeClass('dragtable-handle-selected'); - // add disabled class -> reorgorganisation starts soon - _this.sortableTable.el.sortable("disable"); - _this.sortableTable.el.addClass('dragtable-disabled'); - _this.options.beforeReorganize(_this.originalTable, _this.sortableTable); - // do reorganisation asynchronous - // for chrome a little bit more than 1 ms because we want to force a rerender - _this.originalTable.endIndex = _this.sortableTable.movingRow.prevAll().size() + 1; - setTimeout(_this._rearrangeTableBackroundProcessing(), 50); - }; - }, - /* - * Disrupts the table. The original table stays the same. - * But on a layer above the original table we are constructing a list (ul > li) - * each li with a separate table representig a single col of the original table. - */ - _generateSortable: function(e) { - !e.cancelBubble && (e.cancelBubble = true); - var _this = this; - // table attributes - var attrs = this.originalTable.el[0].attributes; - var attrsString = ''; - for (var i = 0; i < attrs.length; i++) { - if (attrs[i].nodeValue && attrs[i].nodeName != 'id' && attrs[i].nodeName != 'width') { - attrsString += attrs[i].nodeName + '="' + attrs[i].nodeValue + '" '; - } - } + $.widget("akottr.dragtable", { + options: { + revert: false, // smooth revert + dragHandle: '.table-handle', // handle for moving cols, if not exists the whole 'th' is the handle + maxMovingRows: 40, // 1 -> only header. 40 row should be enough, the rest is usually not in the viewport + excludeFooter: false, // excludes the footer row(s) while moving other columns. Make sense if there is a footer with a colspan. */ + onlyHeaderThreshold: 100, // TODO: not implemented yet, switch automatically between entire col moving / only header moving + dragaccept: null, // draggable cols -> default all + persistState: null, // url or function -> plug in your custom persistState function right here. function call is persistState(originalTable) + restoreState: null, // JSON-Object or function: some kind of experimental aka Quick-Hack TODO: do it better + exact: true, // removes pixels, so that the overlay table width fits exactly the original table width + clickDelay: 10, // ms to wait before rendering sortable list and delegating click event + containment: null, // @see http://api.jqueryui.com/sortable/#option-containment, use it if you want to move in 2 dimesnions (together with axis: null) + cursor: 'move', // @see http://api.jqueryui.com/sortable/#option-cursor + cursorAt: false, // @see http://api.jqueryui.com/sortable/#option-cursorAt + distance: 0, // @see http://api.jqueryui.com/sortable/#option-distance, for immediate feedback use "0" + tolerance: 'pointer', // @see http://api.jqueryui.com/sortable/#option-tolerance + axis: 'x', // @see http://api.jqueryui.com/sortable/#option-axis, Only vertical moving is allowed. Use 'x' or null. Use this in conjunction with the 'containment' setting + beforeStart: $.noop, // returning FALSE will stop the execution chain. + beforeMoving: $.noop, + beforeReorganize: $.noop, + beforeStop: $.noop + }, + originalTable: { + el: null, + selectedHandle: null, + sortOrder: null, + startIndex: 0, + endIndex: 0 + }, + sortableTable: { + el: $(), + selectedHandle: $(), + movingRow: $() + }, + persistState: function() { + var _this = this; + this.originalTable.el.find('th').each(function(i) { + if (this.id !== '') { + _this.originalTable.sortOrder[this.id] = i; + } + }); + $.ajax({ + url: this.options.persistState, + data: this.originalTable.sortOrder + }); + }, + /* + * persistObj looks like + * {'id1':'2','id3':'3','id2':'1'} + * table looks like + * | id2 | id1 | id3 | + */ + _restoreState: function(persistObj) { + for (var n in persistObj) { + this.originalTable.startIndex = $('#' + n).closest('th').prevAll().length + 1; + this.originalTable.endIndex = parseInt(persistObj[n], 10) + 1; + this._bubbleCols(); + } + }, + // bubble the moved col left or right + _bubbleCols: function() { + var i, j, col1, col2; + var from = this.originalTable.startIndex; + var to = this.originalTable.endIndex; + /* Find children thead and tbody. + * Only to process the immediate tr-children. Bugfix for inner tables + */ + var thtb = this.originalTable.el.children(); + if (this.options.excludeFooter) { + thtb = thtb.not('tfoot'); + } + if (from < to) { + for (i = from; i < to; i++) { + col1 = thtb.find('> tr > td:nth-child(' + i + ')') + .add(thtb.find('> tr > th:nth-child(' + i + ')')); + col2 = thtb.find('> tr > td:nth-child(' + (i + 1) + ')') + .add(thtb.find('> tr > th:nth-child(' + (i + 1) + ')')); + for (j = 0; j < col1.length; j++) { + swapNodes(col1[j], col2[j]); + } + } + } else { + for (i = from; i > to; i--) { + col1 = thtb.find('> tr > td:nth-child(' + i + ')') + .add(thtb.find('> tr > th:nth-child(' + i + ')')); + col2 = thtb.find('> tr > td:nth-child(' + (i - 1) + ')') + .add(thtb.find('> tr > th:nth-child(' + (i - 1) + ')')); + for (j = 0; j < col1.length; j++) { + swapNodes(col1[j], col2[j]); + } + } + } + }, + _rearrangeTableBackroundProcessing: function() { + var _this = this; + return function() { + _this._bubbleCols(); + _this.options.beforeStop(_this.originalTable); + _this.sortableTable.el.remove(); + restoreTextSelection(); + // persist state if necessary + if (_this.options.persistState !== null) { + $.isFunction(_this.options.persistState) ? _this.options.persistState(_this.originalTable) : _this.persistState(); + } + }; + }, + _rearrangeTable: function() { + var _this = this; + return function() { + // remove handler-class -> handler is now finished + _this.originalTable.selectedHandle.removeClass('dragtable-handle-selected'); + // add disabled class -> reorgorganisation starts soon + _this.sortableTable.el.sortable("disable"); + _this.sortableTable.el.addClass('dragtable-disabled'); + _this.options.beforeReorganize(_this.originalTable, _this.sortableTable); + // do reorganisation asynchronous + // for chrome a little bit more than 1 ms because we want to force a rerender + _this.originalTable.endIndex = _this.sortableTable.movingRow.prevAll().length + 1; + setTimeout(_this._rearrangeTableBackroundProcessing(), 50); + }; + }, + /* + * Disrupts the table. The original table stays the same. + * But on a layer above the original table we are constructing a list (ul > li) + * each li with a separate table representig a single col of the original table. + */ + _generateSortable: function(e) { + !e.cancelBubble && (e.cancelBubble = true); + var _this = this; + // table attributes + var attrs = this.originalTable.el[0].attributes; + var attrsString = ''; + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].nodeValue && attrs[i].nodeName != 'id' && attrs[i].nodeName != 'width') { + attrsString += attrs[i].nodeName + '="' + attrs[i].nodeValue + '" '; + } + } - // row attributes - var rowAttrsArr = []; - //compute height, special handling for ie needed :-( - var heightArr = []; - this.originalTable.el.find('tr').slice(0, this.options.maxMovingRows).each(function(i, v) { - // row attributes - var attrs = this.attributes; - var attrsString = ""; - for (var j = 0; j < attrs.length; j++) { - if (attrs[j].nodeValue && attrs[j].nodeName != 'id') { - attrsString += " " + attrs[j].nodeName + '="' + attrs[j].nodeValue + '"'; - } - } - rowAttrsArr.push(attrsString); - heightArr.push($(this).height()); - }); + // row attributes + var rowAttrsArr = []; + //compute height, special handling for ie needed :-( + var heightArr = []; + this.originalTable.el.find('tr').slice(0, this.options.maxMovingRows).each(function(i, v) { + // row attributes + var attrs = this.attributes; + var attrsString = ""; + for (var j = 0; j < attrs.length; j++) { + if (attrs[j].nodeValue && attrs[j].nodeName != 'id') { + attrsString += " " + attrs[j].nodeName + '="' + attrs[j].nodeValue + '"'; + } + } + rowAttrsArr.push(attrsString); + heightArr.push($(this).height()); + }); - // compute width, no special handling for ie needed :-) - var widthArr = []; - // compute total width, needed for not wrapping around after the screen ends (floating) - var totalWidth = 0; - /* Find children thead and tbody. - * Only to process the immediate tr-children. Bugfix for inner tables - */ - var thtb = _this.originalTable.el.children(); - if (this.options.excludeFooter) { - thtb = thtb.not('tfoot'); - } - thtb.find('> tr > th').each(function(i, v) { - var w = $(this).outerWidth(); - widthArr.push(w); - totalWidth += w; - }); - if(_this.options.exact) { - var difference = totalWidth - _this.originalTable.el.outerWidth(); - widthArr[0] -= difference; - } - // one extra px on right and left side - totalWidth += 2 + // compute width, no special handling for ie needed :-) + var widthArr = []; + // compute total width, needed for not wrapping around after the screen ends (floating) + var totalWidth = 0; + /* Find children thead and tbody. + * Only to process the immediate tr-children. Bugfix for inner tables + */ + var thtb = _this.originalTable.el.children(); + if (this.options.excludeFooter) { + thtb = thtb.not('tfoot'); + } + thtb.find('> tr > th').each(function(i, v) { + var w = $(this).is(':visible') ? $(this).outerWidth() : 0; + widthArr.push(w); + totalWidth += w; + }); + if(_this.options.exact) { + var difference = totalWidth - _this.originalTable.el.outerWidth(); + widthArr[0] -= difference; + } + // one extra px on right and left side + totalWidth += 2 - var sortableHtml = '