atomic-routes
Advanced tools
Comparing version 0.2.0 to 0.3.0
(typeof module !== "undefined" && module !== null ? function(moduleBody) { | ||
return module.exports = moduleBody(require('jquery')); | ||
return module.exports = moduleBody(require('bluebird')); | ||
} : function(moduleBody) { | ||
return $.navigationRoot = moduleBody(jQuery); | ||
})(function($) { | ||
return window.RootRoute = moduleBody(Promise); | ||
})(function(Promise) { | ||
var NavigationState, getHashPath; | ||
@@ -14,13 +14,26 @@ NavigationState = (function() { | ||
this._isDestroyed = false; | ||
this.whenDestroyed = new $.Deferred(); | ||
this._listenerList = []; | ||
this.whenDestroyed = new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
return _this._resolveWhenDestroyed = resolve; | ||
}; | ||
})(this)); | ||
} | ||
NavigationState.prototype._update = function(subPath) { | ||
var changeListener, j, len, ref, results; | ||
if (this._isDestroyed) { | ||
throw new Error('already destroyed'); | ||
} | ||
return $(this).trigger('changed', [subPath]); | ||
ref = this._listenerList; | ||
results = []; | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
changeListener = ref[j]; | ||
results.push(changeListener(subPath)); | ||
} | ||
return results; | ||
}; | ||
NavigationState.prototype._destroy = function() { | ||
var changeListener, j, len, ref, results; | ||
if (this._isDestroyed) { | ||
@@ -30,4 +43,10 @@ throw new Error('already destroyed'); | ||
this._isDestroyed = true; | ||
this.whenDestroyed.resolve(); | ||
return $(this).trigger('destroyed'); | ||
this._resolveWhenDestroyed(); | ||
ref = this._listenerList; | ||
results = []; | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
changeListener = ref[j]; | ||
results.push(changeListener(null)); | ||
} | ||
return results; | ||
}; | ||
@@ -94,12 +113,3 @@ | ||
})(this); | ||
$(this).on('changed', (function(_this) { | ||
return function(e, subPath) { | ||
return processPath(subPath); | ||
}; | ||
})(this)); | ||
$(this).on('destroyed', (function(_this) { | ||
return function() { | ||
return processPath(null); | ||
}; | ||
})(this)); | ||
this._listenerList.push(processPath); | ||
processPath(this._currentPath); | ||
@@ -134,3 +144,3 @@ return this; | ||
var root; | ||
$(window).on('hashchange', function() { | ||
window.addEventListener('hashchange', function() { | ||
return root._update(getHashPath()); | ||
@@ -137,0 +147,0 @@ }); |
@@ -23,3 +23,7 @@ var gulp = require('gulp'); | ||
gulp.task('test', function() { | ||
return es.concat(gulp.src(coffeeSrc), gulp.src(testSrc)) | ||
return es.concat( | ||
gulp.src(__dirname + '/node_modules/bluebird/js/browser/bluebird.js'), | ||
gulp.src(coffeeSrc), | ||
gulp.src(testSrc) | ||
) | ||
.pipe(karma({ | ||
@@ -26,0 +30,0 @@ configFile: 'karma.conf.js', |
@@ -5,3 +5,3 @@ module.exports = function(config) { | ||
frameworks: ['jasmine', 'jquery-2.1.0'], | ||
frameworks: ['jasmine'], | ||
@@ -8,0 +8,0 @@ preprocessors: { |
{ | ||
"name": "atomic-routes", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"main": "dist/atomic-routes.js", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"dependencies": { | ||
"jquery": "~2.1.3" | ||
"bluebird": "^2.9.21" | ||
}, | ||
@@ -22,3 +22,2 @@ "devDependencies": { | ||
"karma-jasmine": "^0.3.4", | ||
"karma-jquery": "^0.1.0", | ||
"karma-phantomjs-launcher": "^0.1.4", | ||
@@ -25,0 +24,0 @@ "rimraf": "~2.2.8" |
@@ -6,3 +6,3 @@ # Atomic Routes | ||
```js | ||
var rootNav = $.navigationRoot(); | ||
var rootNav = new RootRoute(); | ||
@@ -51,3 +51,3 @@ rootNav.when('/foo', function (fooNav) { | ||
function RootView() { | ||
var rootNav = $.navigationRoot(); | ||
var rootNav = new RootRoute(); | ||
var $dom = $('body'); | ||
@@ -54,0 +54,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15759
10
184
+ Addedbluebird@^2.9.21
+ Addedbluebird@2.11.0(transitive)
- Removedjquery@~2.1.3
- Removedjquery@2.1.4(transitive)