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:
Kelly Domico 2015-06-05 18:26:53 -07:00
parent 2f1c620424
commit ffbfe81465
14 changed files with 582 additions and 608 deletions

View File

@ -1,8 +1,8 @@
/*global angular*/
(function () {
'use strict';
angular.module('horizon.framework.conf', [])
angular
.module('horizon.framework.conf', [])
.constant('horizon.framework.conf.spinner_options', {
inline: {
lines: 10,
@ -33,4 +33,4 @@
trail: 50
}
});
}());
})();

View File

@ -1,16 +1,17 @@
(function () {
'use strict';
angular.module('horizon.framework', [
angular
.module('horizon.framework', [
'horizon.framework.conf',
'horizon.framework.util',
'horizon.framework.widgets'
])
.constant('horizon.framework.basePath', '/static/framework/')
.config(['$interpolateProvider', '$httpProvider',
.config([
'$interpolateProvider',
'$httpProvider',
function ($interpolateProvider, $httpProvider) {
// Replacing the default angular symbol
// allow us to mix angular with django templates
$interpolateProvider.startSymbol('{$');
@ -35,5 +36,6 @@
}
};
});
}]);
}
]);
})();

View File

@ -56,5 +56,4 @@
}
};
});
})();

View File

@ -8,7 +8,6 @@
});
describe('bind-scope directive', function () {
var $scope, $element;
beforeEach(module('horizon.framework'));
@ -58,7 +57,5 @@
expect(listItems[1].textContent.trim()).toBe('dog');
expect(listItems[2].textContent.trim()).toBe('fish');
});
});
})();

View File

@ -177,5 +177,4 @@
return gettextFunc(input);
};
}]);
}());

View File

@ -1,6 +1,7 @@
describe('horizon.framework.util.filters', function () {
(function () {
'use strict';
describe('horizon.framework.util.filters', function () {
beforeEach(module('horizon.framework.util.i18n'));
beforeEach(module('horizon.framework.util.filters'));
@ -36,7 +37,6 @@ describe('horizon.framework.util.filters', function () {
expect(yesnoFilter(0)).toBe('No');
expect(yesnoFilter('')).toBe('No');
});
});
describe('gb', function () {
@ -58,7 +58,6 @@ describe('horizon.framework.util.filters', function () {
it('returns empty string for null', function () {
expect(gbFilter(null)).toBe('');
});
});
describe('mb', function () {
@ -80,7 +79,6 @@ describe('horizon.framework.util.filters', function () {
it('returns empty string for null', function () {
expect(mbFilter(null)).toBe('');
});
});
describe('title', function () {
@ -107,7 +105,6 @@ describe('horizon.framework.util.filters', function () {
it('handles strings beginning with numbers', function () {
expect(titleFilter('3abc')).toBe('3abc');
});
});
describe('noUnderscore', function () {
@ -128,7 +125,6 @@ describe('horizon.framework.util.filters', function () {
expect(noUnderscoreFilter('')).toBe('');
expect(noUnderscoreFilter(21)).toBe(21);
});
});
describe("decode", function () {
@ -148,7 +144,6 @@ describe('horizon.framework.util.filters', function () {
it("Returns input when key is not present", function () {
expect(decodeFilter('NOT_PRESENT', {'PRESENT': 'Here'})).toBe('NOT_PRESENT');
});
});
describe('bytes', function () {
@ -183,11 +178,9 @@ describe('horizon.framework.util.filters', function () {
expect(bytesFilter('Yo!')).toBe('');
expect(bytesFilter(null)).toBe('');
});
});
describe('itemCount', function () {
it('should return translated text with item count',
inject(function (itemCountFilter) {
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');
})
);
});
describe('trans', function () {
it('should return translated text', inject(function (transFilter) {
expect(transFilter("Howdy")).toBe("Howdy");
}));
});
});
})();

View File

@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular.module("horizon.framework.util.i18n", [])
angular.module('horizon.framework.util.i18n', [])
/*
* @name horizon.framework.util.i18n.gettext
@ -37,19 +36,14 @@
* (translation) from filters, which are arguably more
* 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.
var gettextFunc = $window.gettext || function (x) { return x; };
// Eventually, could delete the window gettext references here,
// or provide an appropriate method.
return function () {
return gettextFunc.apply(this, arguments);
};
}]);
})();

View File

@ -13,19 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
describe('horizon.framework.util.i18n', function () {
beforeEach(module('horizon.framework.util.i18n'));
describe('gettext', function () {
var factory;
describe('Normal operation', function () {
beforeEach(inject(function ($injector) {
factory = $injector.get("horizon.framework.util.i18n.gettext");
}));
@ -40,7 +37,6 @@
});
describe("injected window.gettext", function () {
beforeEach(module(function ($provide) {
var $window = { gettext: function (x) { return x.replace(/good/, 'bad'); } };
$provide.value('$window', $window);
@ -58,7 +54,5 @@
});
});
});
});
})();

View File

@ -10,5 +10,4 @@
'horizon.framework.util.validators'
])
.constant('horizon.framework.util.basePath', '/static/framework/util/');
})();

View File

@ -15,6 +15,7 @@
* |---------------------------------------------------------------------------------|
* | {@link horizon.framework.util.validators.directive:validateNumberMax `validateNumberMax`} |
* | {@link horizon.framework.util.validators.directive:validateNumberMin `validateNumberMin`} |
* | {@link horizon.framework.util.validators.directive:notBlank `notBlank`} |
* | {@link horizon.framework.util.validators.directive:hzPasswordMatch `hzPasswordMatch`} |
*
*/
@ -68,8 +69,10 @@
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.$formatters.push(maxValidator);
@ -128,8 +131,10 @@
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.$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 () {
return {
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);
pwElement.on('keyup change', passwordCheck);
element.on('keyup change', passwordCheck);
} // end of link
}; // end of return
}); // end of directive
}());
})();

View File

@ -8,12 +8,10 @@
});
describe('validators directive', function () {
beforeEach(module('horizon.framework.widgets'));
beforeEach(module('horizon.framework.util.validators'));
describe('validateNumberMax directive', function () {
var $scope, $form;
beforeEach(inject(function ($injector) {
@ -51,11 +49,9 @@
expect($form.count.$valid).toBe(true);
expect($form.$valid).toBe(true);
});
});
describe('validateNumberMin directive', function () {
var $scope, $form;
beforeEach(inject(function ($injector) {
@ -94,7 +90,6 @@
expect($form.count.$valid).toBe(true);
expect($form.$valid).toBe(true);
});
});
describe('hzPasswordMatch directive', function () {
@ -173,9 +168,6 @@
done();
}, 1000);
});
}); // end of hzPasswordMatch directive
});
})();

View File

@ -97,5 +97,4 @@
};
}
]);
})();

View File

@ -8,10 +8,8 @@
});
describe('workflow factory', function () {
var workflow,
spec,
decorators = [
var workflow, spec;
var decorators = [
function (spec) {
angular.forEach(spec.steps, function (step) {
if (step.requireSomeServices) {
@ -55,5 +53,4 @@
expect(angular.isFunction(steps[2].checkReadiness)).toBe(true);
});
});
})();