mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Applied jsHint code checking standards.
This commit is contained in:
parent
1b65a3256d
commit
010a998431
@ -9,6 +9,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('AuthService', ['ngCookies', 'Utilities'])
|
angular.module('AuthService', ['ngCookies', 'Utilities'])
|
||||||
|
|
||||||
.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath',
|
.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath',
|
||||||
function($http, $rootScope, $location, $cookieStore, GetBasePath) {
|
function($http, $rootScope, $location, $cookieStore, GetBasePath) {
|
||||||
return {
|
return {
|
||||||
@ -28,7 +29,7 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
|
|||||||
},
|
},
|
||||||
|
|
||||||
isUserLoggedIn: function() {
|
isUserLoggedIn: function() {
|
||||||
if ($rootScope.userLoggedIn == undefined) {
|
if ($rootScope.userLoggedIn === undefined) {
|
||||||
// Browser refresh may have occurred
|
// Browser refresh may have occurred
|
||||||
$rootScope.userLoggedIn = $cookieStore.get('userLoggedIn');
|
$rootScope.userLoggedIn = $cookieStore.get('userLoggedIn');
|
||||||
$rootScope.sessionExpired = $cookieStore.get('sessionExpired');
|
$rootScope.sessionExpired = $cookieStore.get('sessionExpired');
|
||||||
@ -77,17 +78,17 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
|
|||||||
},
|
},
|
||||||
|
|
||||||
setLicense: function(license) {
|
setLicense: function(license) {
|
||||||
license['tested'] = false;
|
license.tested = false;
|
||||||
$cookieStore.put('license', license);
|
$cookieStore.put('license', license);
|
||||||
},
|
},
|
||||||
|
|
||||||
licenseTested: function() {
|
licenseTested: function() {
|
||||||
var result;
|
var license, result;
|
||||||
if ($rootScope.license_tested !== undefined) {
|
if ($rootScope.license_tested !== undefined) {
|
||||||
result = $rootScope.license_tested;
|
result = $rootScope.license_tested;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var license = $cookieStore.get('license');
|
license = $cookieStore.get('license');
|
||||||
if (license && license.tested !== undefined) {
|
if (license && license.tested !== undefined) {
|
||||||
result = license.tested;
|
result = license.tested;
|
||||||
}
|
}
|
||||||
@ -118,15 +119,14 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
|
|||||||
|
|
||||||
getUserInfo: function(key) {
|
getUserInfo: function(key) {
|
||||||
// Access values returned from the Me API call
|
// Access values returned from the Me API call
|
||||||
|
var cu;
|
||||||
if ($rootScope.current_user ) {
|
if ($rootScope.current_user ) {
|
||||||
return $rootScope.current_user[key]
|
return $rootScope.current_user[key];
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.restoreUserInfo();
|
this.restoreUserInfo();
|
||||||
var cu = $cookieStore.get('current_user');
|
cu = $cookieStore.get('current_user');
|
||||||
return cu[key];
|
return cu[key];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var INTEGER_REGEXP = /^\-?\d*$/;
|
/* global chkPass:false */
|
||||||
|
|
||||||
angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'JobsHelper'])
|
angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'JobsHelper'])
|
||||||
// awpassmatch: Add to password_confirm field. Will test if value
|
// awpassmatch: Add to password_confirm field. Will test if value
|
||||||
@ -17,9 +17,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift( function(viewValue) {
|
ctrl.$parsers.unshift( function(viewValue) {
|
||||||
var associated = attrs.awpassmatch;
|
var associated = attrs.awpassmatch,
|
||||||
var password = $('input[name="' + associated + '"]').val();
|
password = $('input[name="' + associated + '"]').val();
|
||||||
if (viewValue == password) {
|
if (viewValue === password) {
|
||||||
// it is valid
|
// it is valid
|
||||||
ctrl.$setValidity('awpassmatch', true);
|
ctrl.$setValidity('awpassmatch', true);
|
||||||
return viewValue;
|
return viewValue;
|
||||||
@ -42,13 +42,13 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift( function(viewValue) {
|
ctrl.$parsers.unshift( function(viewValue) {
|
||||||
var values = viewValue.split(" ");
|
var values = viewValue.split(" "),
|
||||||
var result = "", i;
|
result = "", i;
|
||||||
for (i = 0; i < values.length; i++){
|
for (i = 0; i < values.length; i++){
|
||||||
result += values[i].charAt(0).toUpperCase() + values[i].substr(1) + ' ';
|
result += values[i].charAt(0).toUpperCase() + values[i].substr(1) + ' ';
|
||||||
}
|
}
|
||||||
result = result.trim();
|
result = result.trim();
|
||||||
if (result != viewValue) {
|
if (result !== viewValue) {
|
||||||
ctrl.$setViewValue(result);
|
ctrl.$setViewValue(result);
|
||||||
ctrl.$render();
|
ctrl.$render();
|
||||||
}
|
}
|
||||||
@ -71,11 +71,11 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
ctrl.$parsers.unshift(function(viewValue) {
|
ctrl.$parsers.unshift(function(viewValue) {
|
||||||
ctrl.$setValidity('min', true);
|
ctrl.$setValidity('min', true);
|
||||||
ctrl.$setValidity('max', true);
|
ctrl.$setValidity('max', true);
|
||||||
if (INTEGER_REGEXP.test(viewValue)) {
|
if (/^\-?\d*$/.test(viewValue)) {
|
||||||
// it is valid
|
// it is valid
|
||||||
ctrl.$setValidity('integer', true);
|
ctrl.$setValidity('integer', true);
|
||||||
if ( elm.attr('min') &&
|
if ( elm.attr('min') &&
|
||||||
( viewValue == '' || viewValue == null || parseInt(viewValue,10) < parseInt(elm.attr('min'),10) ) ) {
|
( viewValue === '' || viewValue === null || parseInt(viewValue,10) < parseInt(elm.attr('min'),10) ) ) {
|
||||||
ctrl.$setValidity('min', false);
|
ctrl.$setValidity('min', false);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -105,10 +105,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
|
|
||||||
function checkIt () {
|
function checkIt () {
|
||||||
var viewValue = elm.val();
|
var viewValue = elm.val(), label, validity = true;
|
||||||
var label;
|
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') === null || elm.attr('required') === undefined) ) {
|
||||||
var validity = true;
|
|
||||||
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') == null || elm.attr('required') == undefined) ) {
|
|
||||||
$(elm).attr('required','required');
|
$(elm).attr('required','required');
|
||||||
if ($(elm).hasClass('lookup')) {
|
if ($(elm).hasClass('lookup')) {
|
||||||
$(elm).parent().parent().parent().find('label').first().addClass('prepend-asterisk');
|
$(elm).parent().parent().parent().find('label').first().addClass('prepend-asterisk');
|
||||||
@ -127,7 +125,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
$(elm).parent().parent().find('label').first().removeClass('prepend-asterisk');
|
$(elm).parent().parent().find('label').first().removeClass('prepend-asterisk');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scope[attrs.awRequiredWhen] && (viewValue == undefined || viewValue == null || viewValue == '')) {
|
if (scope[attrs.awRequiredWhen] && (viewValue === undefined || viewValue === null || viewValue === '')) {
|
||||||
validity = false;
|
validity = false;
|
||||||
}
|
}
|
||||||
ctrl.$setValidity('required', validity);
|
ctrl.$setValidity('required', validity);
|
||||||
@ -156,9 +154,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
.directive('awPlaceholder', [ function() {
|
.directive('awPlaceholder', [ function() {
|
||||||
return {
|
return {
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs) {
|
||||||
$(elm).attr('placeholder', scope[attrs.awPlaceholder]);
|
$(elm).attr('placeholder', scope[attrs.awPlaceholder]);
|
||||||
scope.$watch(attrs.awPlaceholder, function(newVal, oldVal) {
|
scope.$watch(attrs.awPlaceholder, function(newVal) {
|
||||||
$(elm).attr('placeholder',newVal);
|
$(elm).attr('placeholder',newVal);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -208,11 +206,11 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift( function(viewValue) {
|
ctrl.$parsers.unshift( function(viewValue) {
|
||||||
var validity = true;
|
var validity = true, rgx, rgx2;
|
||||||
if (viewValue !== '') {
|
if (viewValue !== '') {
|
||||||
ctrl.$setValidity('required', true);
|
ctrl.$setValidity('required', true);
|
||||||
var rgx = /^(https|http|ssh)\:\/\//;
|
rgx = /^(https|http|ssh)\:\/\//;
|
||||||
var rgx2 = /\@/g;
|
rgx2 = /\@/g;
|
||||||
if (!rgx.test(viewValue) || rgx2.test(viewValue)) {
|
if (!rgx.test(viewValue) || rgx2.test(viewValue)) {
|
||||||
validity = false;
|
validity = false;
|
||||||
}
|
}
|
||||||
@ -234,19 +232,19 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
*/
|
*/
|
||||||
.directive('awToolTip', function() {
|
.directive('awToolTip', function() {
|
||||||
return function(scope, element, attrs) {
|
return function(scope, element, attrs) {
|
||||||
var delay = (attrs.delay != undefined && attrs.delay != null) ? attrs.delay : $AnsibleConfig.tooltip_delay;
|
var delay = (attrs.delay !== undefined && attrs.delay !== null) ? attrs.delay : $AnsibleConfig.tooltip_delay,
|
||||||
var placement;
|
placement;
|
||||||
if (attrs.awTipPlacement) {
|
if (attrs.awTipPlacement) {
|
||||||
placement = attrs.awTipPlacement;
|
placement = attrs.awTipPlacement;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
placement = (attrs.placement != undefined && attrs.placement != null) ? attrs.placement : 'left';
|
placement = (attrs.placement !== undefined && attrs.placement !== null) ? attrs.placement : 'left';
|
||||||
}
|
}
|
||||||
$(element).on('hidden.bs.tooltip', function( ) {
|
$(element).on('hidden.bs.tooltip', function( ) {
|
||||||
// TB3RC1 is leaving behind tooltip <div> elements. This will remove them
|
// TB3RC1 is leaving behind tooltip <div> elements. This will remove them
|
||||||
// after a tooltip fades away. If not, they lay overtop of other elements and
|
// after a tooltip fades away. If not, they lay overtop of other elements and
|
||||||
// honk up the page.
|
// honk up the page.
|
||||||
$('.tooltip').each(function(index) {
|
$('.tooltip').each(function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -276,28 +274,27 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
*/
|
*/
|
||||||
.directive('awPopOver', ['$compile', function($compile) {
|
.directive('awPopOver', ['$compile', function($compile) {
|
||||||
return function(scope, element, attrs) {
|
return function(scope, element, attrs) {
|
||||||
var placement = (attrs.placement != undefined && attrs.placement != null) ? attrs.placement : 'left';
|
var placement = (attrs.placement !== undefined && attrs.placement !== null) ? attrs.placement : 'left',
|
||||||
var title = (attrs.title != undefined && attrs.title != null) ? attrs.title : 'Help';
|
title = (attrs.title !== undefined && attrs.title !== null) ? attrs.title : 'Help',
|
||||||
var container = (attrs.container !== undefined) ? attrs.container : false;
|
container = (attrs.container !== undefined) ? attrs.container : false;
|
||||||
$(element).popover({ placement: placement, delay: 0, title: title,
|
$(element).popover({ placement: placement, delay: 0, title: title,
|
||||||
content: attrs.awPopOver, trigger: 'manual', html: true, container: container });
|
content: attrs.awPopOver, trigger: 'manual', html: true, container: container });
|
||||||
$(element).click(function() {
|
$(element).click(function() {
|
||||||
var me = $(this).attr('id');
|
var me = $(this).attr('id');
|
||||||
var e = $(this);
|
$('.help-link, .help-link-white').each( function() {
|
||||||
$('.help-link, .help-link-white').each( function(index) {
|
if (me !== $(this).attr('id')) {
|
||||||
if (me != $(this).attr('id')) {
|
|
||||||
$(this).popover('hide');
|
$(this).popover('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.popover').each(function(index) {
|
$('.popover').each(function() {
|
||||||
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
$(this).tooltip('hide'); // hide a tooltip, if there is one associated with the element
|
$(this).tooltip('hide'); // hide a tooltip, if there is one associated with the element
|
||||||
$(this).popover('toggle');
|
$(this).popover('toggle');
|
||||||
|
|
||||||
$('.popover').each(function(index) {
|
$('.popover').each(function() {
|
||||||
$compile($(this))(scope); //make nested directives work!
|
$compile($(this))(scope); //make nested directives work!
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -306,7 +303,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
$(document).bind('keydown', function(e) {
|
$(document).bind('keydown', function(e) {
|
||||||
if (e.keyCode === 27) {
|
if (e.keyCode === 27) {
|
||||||
$(element).popover('hide');
|
$(element).popover('hide');
|
||||||
$('.popover').each(function(index) {
|
$('.popover').each(function() {
|
||||||
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
@ -337,7 +334,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
ctrl.$setValidity('max', true);
|
ctrl.$setValidity('max', true);
|
||||||
ctrl.$dirty = true;
|
ctrl.$dirty = true;
|
||||||
ctrl.$render();
|
ctrl.$render();
|
||||||
//scope['job_templates_form'].$dirty = true;
|
|
||||||
if (!scope.$$phase) {
|
if (!scope.$$phase) {
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
}
|
}
|
||||||
@ -348,7 +344,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
$('#' + name + '-slider').slider('value', parseInt($(this).val(),10));
|
$('#' + name + '-slider').slider('value', parseInt($(this).val(),10));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
@ -356,14 +351,14 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
.directive('awMultiSelect', [ function() {
|
.directive('awMultiSelect', [ function() {
|
||||||
return {
|
return {
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm) {
|
||||||
$(elm).multiselect ({
|
$(elm).multiselect ({
|
||||||
buttonClass: 'btn-default, btn-mini',
|
buttonClass: 'btn-default, btn-mini',
|
||||||
buttonWidth: 'auto',
|
buttonWidth: 'auto',
|
||||||
buttonContainer: '<div class="btn-group" />',
|
buttonContainer: '<div class="btn-group" />',
|
||||||
maxHeight: false,
|
maxHeight: false,
|
||||||
buttonText: function(options) {
|
buttonText: function(options) {
|
||||||
if (options.length == 0) {
|
if (options.length === 0) {
|
||||||
return 'None selected <b class="caret"></b>';
|
return 'None selected <b class="caret"></b>';
|
||||||
}
|
}
|
||||||
if (options.length > 3) {
|
if (options.length > 3) {
|
||||||
@ -389,9 +384,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
return {
|
return {
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
var name = elm.attr('name');
|
var disabled, opts;
|
||||||
var disabled = elm.attr('data-disabled');
|
disabled = elm.attr('data-disabled');
|
||||||
var opts = {
|
opts = {
|
||||||
value: 0,
|
value: 0,
|
||||||
step: 1,
|
step: 1,
|
||||||
min: elm.attr('min'),
|
min: elm.attr('min'),
|
||||||
@ -429,8 +424,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
$(elm).keyup(function() {
|
$(elm).keyup(function() {
|
||||||
var validity = true;
|
var validity = true,
|
||||||
var score = chkPass(elm.val());
|
score = chkPass(elm.val());
|
||||||
if (elm.val()) {
|
if (elm.val()) {
|
||||||
validity = (score > $AnsibleConfig.password_strength) ? true : false;
|
validity = (score > $AnsibleConfig.password_strength) ? true : false;
|
||||||
}
|
}
|
||||||
@ -451,7 +446,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
//
|
//
|
||||||
.directive('awRefresh', [ '$rootScope', function($rootScope) {
|
.directive('awRefresh', [ '$rootScope', function($rootScope) {
|
||||||
return {
|
return {
|
||||||
link: function(scope, elm, attrs, ctrl) {
|
link: function(scope) {
|
||||||
function msg() {
|
function msg() {
|
||||||
var num = '' + scope.refreshCnt;
|
var num = '' + scope.refreshCnt;
|
||||||
while (num.length < 2) {
|
while (num.length < 2) {
|
||||||
@ -493,8 +488,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
data: function() {
|
data: function() {
|
||||||
// dynamically load the possible values
|
// dynamically load the possible values
|
||||||
if (scope[attrs.awMultiselect]) {
|
if (scope[attrs.awMultiselect]) {
|
||||||
var set = scope[attrs.awMultiselect];
|
var set = scope[attrs.awMultiselect],
|
||||||
var opts = [], i;
|
opts = [], i;
|
||||||
for (i=0; i < set.length; i++) {
|
for (i=0; i < set.length; i++) {
|
||||||
opts.push({ id: set[i].value, text: set[i].label });
|
opts.push({ id: set[i].value, text: set[i].label });
|
||||||
}
|
}
|
||||||
@ -525,7 +520,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
.directive('awDraggable', [ function() {
|
.directive('awDraggable', [ function() {
|
||||||
return function(scope, element, attrs) {
|
return function(scope, element, attrs) {
|
||||||
|
|
||||||
if (attrs.awDraggable == "true") {
|
if (attrs.awDraggable === "true") {
|
||||||
var containment = attrs.containment; //provide dataContainment:"#id"
|
var containment = attrs.containment; //provide dataContainment:"#id"
|
||||||
$(element).draggable({
|
$(element).draggable({
|
||||||
containment: containment,
|
containment: containment,
|
||||||
@ -539,7 +534,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
cursorAt: { left: -1 }
|
cursorAt: { left: -1 }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
@ -552,14 +546,14 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
.directive('awDroppable', ['Find', function(Find) {
|
.directive('awDroppable', ['Find', function(Find) {
|
||||||
return function(scope, element, attrs) {
|
return function(scope, element, attrs) {
|
||||||
var node;
|
var node;
|
||||||
if (attrs.awDroppable == "true") {
|
if (attrs.awDroppable === "true") {
|
||||||
$(element).droppable({
|
$(element).droppable({
|
||||||
// the following is inventory specific accept checking and
|
// the following is inventory specific accept checking and
|
||||||
// drop processing.
|
// drop processing.
|
||||||
accept: function(draggable) {
|
accept: function(draggable) {
|
||||||
if (draggable.attr('data-type') == 'group') {
|
if (draggable.attr('data-type') === 'group') {
|
||||||
// Dropped a group
|
// Dropped a group
|
||||||
if ($(this).attr('data-group-id') == draggable.attr('data-group-id')) {
|
if ($(this).attr('data-group-id') === draggable.attr('data-group-id')) {
|
||||||
// No dropping a node onto itself (or a copy)
|
// No dropping a node onto itself (or a copy)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -570,7 +564,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
found = false, i;
|
found = false, i;
|
||||||
// For whatever reason indexOf() would not work...
|
// For whatever reason indexOf() would not work...
|
||||||
for (i=0; i < node.children.length; i++) {
|
for (i=0; i < node.children.length; i++) {
|
||||||
if (node.children[i] == group) {
|
if (node.children[i] === group) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -579,32 +573,31 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (draggable.attr('data-type') == 'host') {
|
if (draggable.attr('data-type') === 'host') {
|
||||||
// Dropped a host
|
// Dropped a host
|
||||||
node = Find({ list: scope.groups, key: 'id', val: parseInt($(this).attr('data-tree-id'),10) });
|
node = Find({ list: scope.groups, key: 'id', val: parseInt($(this).attr('data-tree-id'),10) });
|
||||||
return (node.id > 1) ? true : false;
|
return (node.id > 1) ? true : false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
over: function(e, ui) {
|
over: function() {
|
||||||
$(this).addClass('droppable-hover');
|
$(this).addClass('droppable-hover');
|
||||||
},
|
},
|
||||||
out: function(e, ui) {
|
out: function() {
|
||||||
$(this).removeClass('droppable-hover');
|
$(this).removeClass('droppable-hover');
|
||||||
},
|
},
|
||||||
drop: function(e, ui) {
|
drop: function(e, ui) {
|
||||||
// Drag-n-drop succeeded. Trigger a response from the inventory.edit controller
|
// Drag-n-drop succeeded. Trigger a response from the inventory.edit controller
|
||||||
$(this).removeClass('droppable-hover');
|
$(this).removeClass('droppable-hover');
|
||||||
if (ui.draggable.attr('data-type') == 'group') {
|
if (ui.draggable.attr('data-type') === 'group') {
|
||||||
scope.$emit('CopyMoveGroup', ui.draggable.attr('data-tree-id'), $(this).attr('data-tree-id'));
|
scope.$emit('CopyMoveGroup', ui.draggable.attr('data-tree-id'), $(this).attr('data-tree-id'));
|
||||||
}
|
}
|
||||||
else if (ui.draggable.attr('data-type') == 'host') {
|
else if (ui.draggable.attr('data-type') === 'host') {
|
||||||
scope.$emit('CopyMoveHost', $(this).attr('data-tree-id'), ui.draggable.attr('data-host-id'));
|
scope.$emit('CopyMoveHost', $(this).attr('data-tree-id'), ui.draggable.attr('data-host-id'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tolerance: 'pointer'
|
tolerance: 'pointer'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
Loading…
Reference in New Issue
Block a user