JSCS cleanup - horizon/static/framework conf and util
We need to do cleanup before we can enable JSCS globally (https://review.openstack.org/#/c/185725/). This patch excludes the 'util/tech-debt' folder which is covered in patch: https://review.openstack.org/#/c/188316/. Change-Id: I0b3e6435d48a24c0b24e38c96b1ce679c3268300 Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
parent
2f1c620424
commit
ffbfe81465
@ -1,8 +1,8 @@
|
|||||||
/*global angular*/
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('horizon.framework.conf', [])
|
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module('horizon.framework.conf', [])
|
||||||
.constant('horizon.framework.conf.spinner_options', {
|
.constant('horizon.framework.conf.spinner_options', {
|
||||||
inline: {
|
inline: {
|
||||||
lines: 10,
|
lines: 10,
|
||||||
@ -33,4 +33,4 @@
|
|||||||
trail: 50
|
trail: 50
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
})();
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('horizon.framework', [
|
angular
|
||||||
|
.module('horizon.framework', [
|
||||||
'horizon.framework.conf',
|
'horizon.framework.conf',
|
||||||
'horizon.framework.util',
|
'horizon.framework.util',
|
||||||
'horizon.framework.widgets'
|
'horizon.framework.widgets'
|
||||||
])
|
])
|
||||||
.constant('horizon.framework.basePath', '/static/framework/')
|
.constant('horizon.framework.basePath', '/static/framework/')
|
||||||
|
.config([
|
||||||
.config(['$interpolateProvider', '$httpProvider',
|
'$interpolateProvider',
|
||||||
|
'$httpProvider',
|
||||||
function ($interpolateProvider, $httpProvider) {
|
function ($interpolateProvider, $httpProvider) {
|
||||||
|
|
||||||
// Replacing the default angular symbol
|
// Replacing the default angular symbol
|
||||||
// allow us to mix angular with django templates
|
// allow us to mix angular with django templates
|
||||||
$interpolateProvider.startSymbol('{$');
|
$interpolateProvider.startSymbol('{$');
|
||||||
@ -35,5 +36,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}]);
|
}
|
||||||
|
]);
|
||||||
})();
|
})();
|
||||||
|
@ -56,5 +56,4 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
@ -8,7 +8,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('bind-scope directive', function () {
|
describe('bind-scope directive', function () {
|
||||||
|
|
||||||
var $scope, $element;
|
var $scope, $element;
|
||||||
|
|
||||||
beforeEach(module('horizon.framework'));
|
beforeEach(module('horizon.framework'));
|
||||||
@ -58,7 +57,5 @@
|
|||||||
expect(listItems[1].textContent.trim()).toBe('dog');
|
expect(listItems[1].textContent.trim()).toBe('dog');
|
||||||
expect(listItems[2].textContent.trim()).toBe('fish');
|
expect(listItems[2].textContent.trim()).toBe('fish');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
@ -177,5 +177,4 @@
|
|||||||
return gettextFunc(input);
|
return gettextFunc(input);
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
describe('horizon.framework.util.filters', function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
describe('horizon.framework.util.filters', function () {
|
||||||
beforeEach(module('horizon.framework.util.i18n'));
|
beforeEach(module('horizon.framework.util.i18n'));
|
||||||
beforeEach(module('horizon.framework.util.filters'));
|
beforeEach(module('horizon.framework.util.filters'));
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
expect(yesnoFilter(0)).toBe('No');
|
expect(yesnoFilter(0)).toBe('No');
|
||||||
expect(yesnoFilter('')).toBe('No');
|
expect(yesnoFilter('')).toBe('No');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('gb', function () {
|
describe('gb', function () {
|
||||||
@ -58,7 +58,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
it('returns empty string for null', function () {
|
it('returns empty string for null', function () {
|
||||||
expect(gbFilter(null)).toBe('');
|
expect(gbFilter(null)).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('mb', function () {
|
describe('mb', function () {
|
||||||
@ -80,7 +79,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
it('returns empty string for null', function () {
|
it('returns empty string for null', function () {
|
||||||
expect(mbFilter(null)).toBe('');
|
expect(mbFilter(null)).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('title', function () {
|
describe('title', function () {
|
||||||
@ -107,7 +105,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
it('handles strings beginning with numbers', function () {
|
it('handles strings beginning with numbers', function () {
|
||||||
expect(titleFilter('3abc')).toBe('3abc');
|
expect(titleFilter('3abc')).toBe('3abc');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('noUnderscore', function () {
|
describe('noUnderscore', function () {
|
||||||
@ -128,7 +125,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
expect(noUnderscoreFilter('')).toBe('');
|
expect(noUnderscoreFilter('')).toBe('');
|
||||||
expect(noUnderscoreFilter(21)).toBe(21);
|
expect(noUnderscoreFilter(21)).toBe(21);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("decode", function () {
|
describe("decode", function () {
|
||||||
@ -148,7 +144,6 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
it("Returns input when key is not present", function () {
|
it("Returns input when key is not present", function () {
|
||||||
expect(decodeFilter('NOT_PRESENT', {'PRESENT': 'Here'})).toBe('NOT_PRESENT');
|
expect(decodeFilter('NOT_PRESENT', {'PRESENT': 'Here'})).toBe('NOT_PRESENT');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('bytes', function () {
|
describe('bytes', function () {
|
||||||
@ -183,11 +178,9 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
expect(bytesFilter('Yo!')).toBe('');
|
expect(bytesFilter('Yo!')).toBe('');
|
||||||
expect(bytesFilter(null)).toBe('');
|
expect(bytesFilter(null)).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('itemCount', function () {
|
describe('itemCount', function () {
|
||||||
|
|
||||||
it('should return translated text with item count',
|
it('should return translated text with item count',
|
||||||
inject(function (itemCountFilter) {
|
inject(function (itemCountFilter) {
|
||||||
expect(itemCountFilter(null)).toBe('Displaying 0 items');
|
expect(itemCountFilter(null)).toBe('Displaying 0 items');
|
||||||
@ -207,14 +200,12 @@ describe('horizon.framework.util.filters', function () {
|
|||||||
expect(itemCountFilter(-1.2)).toBe('Displaying 0 items');
|
expect(itemCountFilter(-1.2)).toBe('Displaying 0 items');
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('trans', function () {
|
describe('trans', function () {
|
||||||
|
|
||||||
it('should return translated text', inject(function (transFilter) {
|
it('should return translated text', inject(function (transFilter) {
|
||||||
expect(transFilter("Howdy")).toBe("Howdy");
|
expect(transFilter("Howdy")).toBe("Howdy");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
})();
|
||||||
|
@ -13,11 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module("horizon.framework.util.i18n", [])
|
angular.module('horizon.framework.util.i18n', [])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @name horizon.framework.util.i18n.gettext
|
* @name horizon.framework.util.i18n.gettext
|
||||||
@ -37,19 +36,14 @@
|
|||||||
* (translation) from filters, which are arguably more
|
* (translation) from filters, which are arguably more
|
||||||
* presentation-oriented.
|
* presentation-oriented.
|
||||||
*/
|
*/
|
||||||
.factory("horizon.framework.util.i18n.gettext", ['$window', function($window) {
|
.factory('horizon.framework.util.i18n.gettext', ['$window', function ($window) {
|
||||||
|
|
||||||
// If no global function, revert to just returning given text.
|
// If no global function, revert to just returning given text.
|
||||||
var gettextFunc = $window.gettext || function (x) { return x; };
|
var gettextFunc = $window.gettext || function (x) { return x; };
|
||||||
|
|
||||||
// Eventually, could delete the window gettext references here,
|
// Eventually, could delete the window gettext references here,
|
||||||
// or provide an appropriate method.
|
// or provide an appropriate method.
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
return gettextFunc.apply(this, arguments);
|
return gettextFunc.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -13,19 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('horizon.framework.util.i18n', function () {
|
describe('horizon.framework.util.i18n', function () {
|
||||||
|
|
||||||
beforeEach(module('horizon.framework.util.i18n'));
|
beforeEach(module('horizon.framework.util.i18n'));
|
||||||
|
|
||||||
describe('gettext', function () {
|
describe('gettext', function () {
|
||||||
var factory;
|
var factory;
|
||||||
|
|
||||||
describe('Normal operation', function () {
|
describe('Normal operation', function () {
|
||||||
|
|
||||||
beforeEach(inject(function ($injector) {
|
beforeEach(inject(function ($injector) {
|
||||||
factory = $injector.get("horizon.framework.util.i18n.gettext");
|
factory = $injector.get("horizon.framework.util.i18n.gettext");
|
||||||
}));
|
}));
|
||||||
@ -40,7 +37,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("injected window.gettext", function () {
|
describe("injected window.gettext", function () {
|
||||||
|
|
||||||
beforeEach(module(function ($provide) {
|
beforeEach(module(function ($provide) {
|
||||||
var $window = { gettext: function (x) { return x.replace(/good/, 'bad'); } };
|
var $window = { gettext: function (x) { return x.replace(/good/, 'bad'); } };
|
||||||
$provide.value('$window', $window);
|
$provide.value('$window', $window);
|
||||||
@ -58,7 +54,5 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -10,5 +10,4 @@
|
|||||||
'horizon.framework.util.validators'
|
'horizon.framework.util.validators'
|
||||||
])
|
])
|
||||||
.constant('horizon.framework.util.basePath', '/static/framework/util/');
|
.constant('horizon.framework.util.basePath', '/static/framework/util/');
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* |---------------------------------------------------------------------------------|
|
* |---------------------------------------------------------------------------------|
|
||||||
* | {@link horizon.framework.util.validators.directive:validateNumberMax `validateNumberMax`} |
|
* | {@link horizon.framework.util.validators.directive:validateNumberMax `validateNumberMax`} |
|
||||||
* | {@link horizon.framework.util.validators.directive:validateNumberMin `validateNumberMin`} |
|
* | {@link horizon.framework.util.validators.directive:validateNumberMin `validateNumberMin`} |
|
||||||
|
* | {@link horizon.framework.util.validators.directive:notBlank `notBlank`} |
|
||||||
* | {@link horizon.framework.util.validators.directive:hzPasswordMatch `hzPasswordMatch`} |
|
* | {@link horizon.framework.util.validators.directive:hzPasswordMatch `hzPasswordMatch`} |
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -68,8 +69,10 @@
|
|||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Re-validate if value is changed through the UI
|
/**
|
||||||
// or model (programmatically)
|
* Re-validate if value is changed through the UI
|
||||||
|
* or model (programmatically)
|
||||||
|
*/
|
||||||
ctrl.$parsers.push(maxValidator);
|
ctrl.$parsers.push(maxValidator);
|
||||||
ctrl.$formatters.push(maxValidator);
|
ctrl.$formatters.push(maxValidator);
|
||||||
|
|
||||||
@ -128,8 +131,10 @@
|
|||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Re-validate if value is changed through the UI
|
/**
|
||||||
// or model (programmatically)
|
* Re-validate if value is changed through the UI
|
||||||
|
* or model (programmatically)
|
||||||
|
*/
|
||||||
ctrl.$parsers.push(minValidator);
|
ctrl.$parsers.push(minValidator);
|
||||||
ctrl.$formatters.push(minValidator);
|
ctrl.$formatters.push(minValidator);
|
||||||
|
|
||||||
@ -140,6 +145,12 @@
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc directive
|
||||||
|
* @name notBlank
|
||||||
|
* @element ng-model
|
||||||
|
* @description Ensure that the value is not blank
|
||||||
|
*/
|
||||||
.directive('notBlank', function () {
|
.directive('notBlank', function () {
|
||||||
return {
|
return {
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
@ -200,14 +211,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// this ensures that typing in either input
|
/**
|
||||||
// will trigger the password match
|
* this ensures that typing in either input
|
||||||
|
* will trigger the password match
|
||||||
|
*/
|
||||||
var pwElement = $('#' + scope.pw.$name);
|
var pwElement = $('#' + scope.pw.$name);
|
||||||
pwElement.on('keyup change', passwordCheck);
|
pwElement.on('keyup change', passwordCheck);
|
||||||
element.on('keyup change', passwordCheck);
|
element.on('keyup change', passwordCheck);
|
||||||
|
|
||||||
} // end of link
|
} // end of link
|
||||||
}; // end of return
|
}; // end of return
|
||||||
}); // end of directive
|
}); // end of directive
|
||||||
|
})();
|
||||||
}());
|
|
||||||
|
@ -8,12 +8,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('validators directive', function () {
|
describe('validators directive', function () {
|
||||||
|
|
||||||
beforeEach(module('horizon.framework.widgets'));
|
beforeEach(module('horizon.framework.widgets'));
|
||||||
beforeEach(module('horizon.framework.util.validators'));
|
beforeEach(module('horizon.framework.util.validators'));
|
||||||
|
|
||||||
describe('validateNumberMax directive', function () {
|
describe('validateNumberMax directive', function () {
|
||||||
|
|
||||||
var $scope, $form;
|
var $scope, $form;
|
||||||
|
|
||||||
beforeEach(inject(function ($injector) {
|
beforeEach(inject(function ($injector) {
|
||||||
@ -51,11 +49,9 @@
|
|||||||
expect($form.count.$valid).toBe(true);
|
expect($form.count.$valid).toBe(true);
|
||||||
expect($form.$valid).toBe(true);
|
expect($form.$valid).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validateNumberMin directive', function () {
|
describe('validateNumberMin directive', function () {
|
||||||
|
|
||||||
var $scope, $form;
|
var $scope, $form;
|
||||||
|
|
||||||
beforeEach(inject(function ($injector) {
|
beforeEach(inject(function ($injector) {
|
||||||
@ -94,7 +90,6 @@
|
|||||||
expect($form.count.$valid).toBe(true);
|
expect($form.count.$valid).toBe(true);
|
||||||
expect($form.$valid).toBe(true);
|
expect($form.$valid).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hzPasswordMatch directive', function () {
|
describe('hzPasswordMatch directive', function () {
|
||||||
@ -173,9 +168,6 @@
|
|||||||
done();
|
done();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
}); // end of hzPasswordMatch directive
|
}); // end of hzPasswordMatch directive
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
@ -97,5 +97,4 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -8,10 +8,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('workflow factory', function () {
|
describe('workflow factory', function () {
|
||||||
|
var workflow, spec;
|
||||||
var workflow,
|
var decorators = [
|
||||||
spec,
|
|
||||||
decorators = [
|
|
||||||
function (spec) {
|
function (spec) {
|
||||||
angular.forEach(spec.steps, function (step) {
|
angular.forEach(spec.steps, function (step) {
|
||||||
if (step.requireSomeServices) {
|
if (step.requireSomeServices) {
|
||||||
@ -55,5 +53,4 @@
|
|||||||
expect(angular.isFunction(steps[2].checkReadiness)).toBe(true);
|
expect(angular.isFunction(steps[2].checkReadiness)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user