Skip to content

Commit 32fdefd

Browse files
committed
Release v0.1.0
1 parent eceb257 commit 32fdefd

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-router-css-plugin",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"author": "Harm van der Werf",
55
"keywords": [
66
"angular",

Diff for: dist/angular-ui-router-css.js

+35-30
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
* angular-ui-router-css
33
* https://github.com/harm-less/angular-ui-router-css
44
5-
* Version: 0.1.0 - 2017-05-27
5+
* Version: 0.1.0 - 2017-05-30
66
* License: MIT
77
*/
88
(function (angular, window) {
99

1010
'use strict';
1111

1212
// used for the Uglify Grunt task when compiling the build. It sets a global variable 'DEBUG' and sets it to false.
13+
/* istanbul ignore next */
1314
if (angular.isUndefined(window.DEBUG)) {
1415
window.DEBUG = true;
1516
}
@@ -28,8 +29,8 @@
2829
var addedDefinitions = [];
2930
var firstAddedStateDefinition;
3031

31-
function log(message) {
32-
console.log('Log "angular-ui-router-css": ' + message);
32+
function error(message) {
33+
throw Error('Error "angular-ui-router-css": ' + message);
3334
}
3435

3536
function isInt (value) {
@@ -60,18 +61,14 @@
6061
url: definition
6162
};
6263
}
63-
else if (angular.isObject(definition)) {
64-
if (!definition.url) {
65-
if (DEBUG) {
66-
log('The definition needs to contain a URL: ' + JSON.stringify(definition));
67-
}
68-
return;
69-
}
7064

71-
// Using specified ID as new object key.
72-
if (definition.id) {
73-
key = definition.id;
74-
}
65+
if (angular.isUndefined(definition.url)) {
66+
error('The definition needs to contain a URL: ' + JSON.stringify(definition));
67+
}
68+
69+
// Using specified ID as new object key.
70+
if (definition.id) {
71+
key = definition.id;
7572
}
7673

7774
// Using custom unique resource ID instead of simple array index.
@@ -117,18 +114,15 @@
117114
*/
118115
function loadStyleDefinition(definition, options) {
119116
var deferred = _$q.defer();
120-
if (definition.url) {
121-
if (DEBUG && !window.loadStylesheet) {
122-
log('Package "betsol-load-stylesheet" must be loaded before you can use "angular-ui-router-css"');
123-
}
124117

125-
definition.element = window.loadStylesheet(definition.url, function () {
126-
deferred.resolve();
127-
}, options);
118+
if (DEBUG && !window.loadStylesheet) {
119+
error('Package "betsol-load-stylesheet" must be loaded before you can use "angular-ui-router-css"');
128120
}
129-
else {
121+
122+
definition.element = window.loadStylesheet(definition.url, function () {
130123
deferred.resolve();
131-
}
124+
}, options);
125+
132126
return deferred.promise;
133127
}
134128

@@ -180,13 +174,11 @@
180174
angular.forEach(definitions, function (definition) {
181175
if (isInjectable(definition)) {
182176
definition = normalizeStyleDefinition(inject(definition));
183-
console.log('gg', definition);
184177
}
185178
if (!definition.url) {
186179
return;
187180
}
188181

189-
console.log(definition.url);
190182
var definitionPromise = loadStyleDefinition(definition, {
191183
insertBefore: linkElementPlaceholder
192184
});
@@ -228,7 +220,7 @@
228220
}
229221
}
230222

231-
angular.module('hl.ui.router.css', ['ui.router'])
223+
angular.module('hl.css.ui.router', ['ui.router'])
232224

233225
.config(["$stateProvider", function ($stateProvider) {
234226

@@ -249,7 +241,7 @@
249241
_$q = $q;
250242
_$injector = $injector;
251243

252-
$transitions.onBefore(null, function(transition) {
244+
$transitions.onBefore({}, function(transition) {
253245
transition.addResolvable({
254246
token: '@css',
255247
resolveFn: function() {
@@ -258,7 +250,7 @@
258250
});
259251
});
260252

261-
$transitions.onSuccess(null, function() {
253+
$transitions.onSuccess({}, function() {
262254
loadStylesForStateComplete();
263255
});
264256
}])
@@ -269,10 +261,10 @@
269261
link: function(scope, element, attrs) {
270262
if (DEBUG) {
271263
if (linkElementPlaceholder) {
272-
log('The directive "uiCss" can only be set once');
264+
error('The directive "uiCss" can only be set once');
273265
}
274266
else if (document.getElementsByTagName('head')[0] !== element[0].parentNode) {
275-
log('The directive "uiCss" must be placed in the "head" of your HTML');
267+
error('The directive "uiCss" must be placed in the "head" of your HTML');
276268
}
277269
}
278270

@@ -300,6 +292,19 @@
300292
});
301293
}
302294
};
295+
296+
/* istanbul ignore next */
297+
if (DEBUG) {
298+
299+
// necessary for resetting unit tests as those variables are not reset automatically
300+
this.reset = function() {
301+
linkElementPlaceholder = null;
302+
nextResourceId = 1;
303+
removeDefinitionQueue = [];
304+
addedDefinitions = [];
305+
firstAddedStateDefinition = null;
306+
};
307+
}
303308
}]);
304309

305310
})(angular, window);

Diff for: dist/angular-ui-router-css.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Harm van der Werf <[email protected]> {https://github.com/harm-less}",
33
"name": "angular-ui-router-css",
4-
"version": "0.0.0",
4+
"version": "0.1.0",
55
"description": "UI Router (1.*) extension to load route-specific, promised based CSS files",
66
"homepage": "https://github.com/harm-less/angular-ui-router-css",
77
"main": "dist/angular-ui-router-css.js",

0 commit comments

Comments
 (0)