-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
781cdf4
commit ab9f9c9
Showing
75 changed files
with
3,490 additions
and
1,675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
define(['exports', './collection-strategy'], function (exports, _collectionStrategy) { | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var ArrayCollectionStrategy = (function (_CollectionStrategy) { | ||
_inherits(ArrayCollectionStrategy, _CollectionStrategy); | ||
|
||
function ArrayCollectionStrategy() { | ||
_classCallCheck(this, ArrayCollectionStrategy); | ||
|
||
_CollectionStrategy.apply(this, arguments); | ||
} | ||
|
||
ArrayCollectionStrategy.prototype.processItems = function processItems(items) { | ||
var i = undefined; | ||
var ii = undefined; | ||
var overrideContext = undefined; | ||
var view = undefined; | ||
this.items = items; | ||
for (i = 0, ii = items.length; i < ii; ++i) { | ||
overrideContext = _CollectionStrategy.prototype.createFullOverrideContext.call(this, items[i], i, ii); | ||
view = this.viewFactory.create(); | ||
view.bind(undefined, overrideContext); | ||
this.viewSlot.add(view); | ||
} | ||
}; | ||
|
||
ArrayCollectionStrategy.prototype.getCollectionObserver = function getCollectionObserver(items) { | ||
return this.observerLocator.getArrayObserver(items); | ||
}; | ||
|
||
ArrayCollectionStrategy.prototype.handleChanges = function handleChanges(array, splices) { | ||
var _this = this; | ||
|
||
var removeDelta = 0; | ||
var viewSlot = this.viewSlot; | ||
var rmPromises = []; | ||
|
||
for (var i = 0, ii = splices.length; i < ii; ++i) { | ||
var splice = splices[i]; | ||
var removed = splice.removed; | ||
|
||
for (var j = 0, jj = removed.length; j < jj; ++j) { | ||
var viewOrPromise = viewSlot.removeAt(splice.index + removeDelta + rmPromises.length, true); | ||
if (viewOrPromise instanceof Promise) { | ||
rmPromises.push(viewOrPromise); | ||
} | ||
} | ||
removeDelta -= splice.addedCount; | ||
} | ||
|
||
if (rmPromises.length > 0) { | ||
Promise.all(rmPromises).then(function () { | ||
var spliceIndexLow = _this._handleAddedSplices(array, splices); | ||
_this.updateOverrideContexts(spliceIndexLow); | ||
}); | ||
} else { | ||
var spliceIndexLow = this._handleAddedSplices(array, splices); | ||
_CollectionStrategy.prototype.updateOverrideContexts.call(this, spliceIndexLow); | ||
} | ||
}; | ||
|
||
ArrayCollectionStrategy.prototype._handleAddedSplices = function _handleAddedSplices(array, splices) { | ||
var spliceIndex = undefined; | ||
var spliceIndexLow = undefined; | ||
var arrayLength = array.length; | ||
for (var i = 0, ii = splices.length; i < ii; ++i) { | ||
var splice = splices[i]; | ||
var addIndex = spliceIndex = splice.index; | ||
var end = splice.index + splice.addedCount; | ||
|
||
if (typeof spliceIndexLow === 'undefined' || spliceIndexLow === null || spliceIndexLow > splice.index) { | ||
spliceIndexLow = spliceIndex; | ||
} | ||
|
||
for (; addIndex < end; ++addIndex) { | ||
var overrideContext = this.createFullOverrideContext(array[addIndex], addIndex, arrayLength); | ||
var view = this.viewFactory.create(); | ||
view.bind(undefined, overrideContext); | ||
this.viewSlot.insert(addIndex, view); | ||
} | ||
} | ||
|
||
return spliceIndexLow; | ||
}; | ||
|
||
return ArrayCollectionStrategy; | ||
})(_collectionStrategy.CollectionStrategy); | ||
|
||
exports.ArrayCollectionStrategy = ArrayCollectionStrategy; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
var ModeBindingBehavior = (function () { | ||
function ModeBindingBehavior(mode) { | ||
_classCallCheck(this, ModeBindingBehavior); | ||
|
||
this.mode = mode; | ||
} | ||
|
||
ModeBindingBehavior.prototype.bind = function bind(binding, source, lookupFunctions) { | ||
binding.originalMode = binding.mode; | ||
binding.mode = this.mode; | ||
}; | ||
|
||
ModeBindingBehavior.prototype.unbind = function unbind(binding, source) { | ||
binding.mode = binding.originalMode; | ||
binding.originalMode = null; | ||
}; | ||
|
||
return ModeBindingBehavior; | ||
})(); | ||
|
||
var OneTimeBindingBehavior = (function (_ModeBindingBehavior) { | ||
_inherits(OneTimeBindingBehavior, _ModeBindingBehavior); | ||
|
||
function OneTimeBindingBehavior() { | ||
_classCallCheck(this, OneTimeBindingBehavior); | ||
|
||
_ModeBindingBehavior.call(this, _aureliaBinding.bindingMode.oneTime); | ||
} | ||
|
||
return OneTimeBindingBehavior; | ||
})(ModeBindingBehavior); | ||
|
||
exports.OneTimeBindingBehavior = OneTimeBindingBehavior; | ||
|
||
var OneWayBindingBehavior = (function (_ModeBindingBehavior2) { | ||
_inherits(OneWayBindingBehavior, _ModeBindingBehavior2); | ||
|
||
function OneWayBindingBehavior() { | ||
_classCallCheck(this, OneWayBindingBehavior); | ||
|
||
_ModeBindingBehavior2.call(this, _aureliaBinding.bindingMode.oneWay); | ||
} | ||
|
||
return OneWayBindingBehavior; | ||
})(ModeBindingBehavior); | ||
|
||
exports.OneWayBindingBehavior = OneWayBindingBehavior; | ||
|
||
var TwoWayBindingBehavior = (function (_ModeBindingBehavior3) { | ||
_inherits(TwoWayBindingBehavior, _ModeBindingBehavior3); | ||
|
||
function TwoWayBindingBehavior() { | ||
_classCallCheck(this, TwoWayBindingBehavior); | ||
|
||
_ModeBindingBehavior3.call(this, _aureliaBinding.bindingMode.twoWay); | ||
} | ||
|
||
return TwoWayBindingBehavior; | ||
})(ModeBindingBehavior); | ||
|
||
exports.TwoWayBindingBehavior = TwoWayBindingBehavior; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
var BindingSignaler = (function () { | ||
function BindingSignaler() { | ||
_classCallCheck(this, BindingSignaler); | ||
|
||
this.signals = {}; | ||
} | ||
|
||
BindingSignaler.prototype.signal = function signal(name) { | ||
var bindings = this.signals[name]; | ||
if (!bindings) { | ||
return; | ||
} | ||
var i = bindings.length; | ||
while (i--) { | ||
bindings[i].call(_aureliaBinding.sourceContext); | ||
} | ||
}; | ||
|
||
return BindingSignaler; | ||
})(); | ||
|
||
exports.BindingSignaler = BindingSignaler; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
define(['exports', 'aurelia-dependency-injection', './array-collection-strategy', './map-collection-strategy', './number-strategy'], function (exports, _aureliaDependencyInjection, _arrayCollectionStrategy, _mapCollectionStrategy, _numberStrategy) { | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
var CollectionStrategyLocator = (function () { | ||
function CollectionStrategyLocator(container) { | ||
_classCallCheck(this, _CollectionStrategyLocator); | ||
|
||
this.container = container; | ||
this.strategies = []; | ||
this.matchers = []; | ||
|
||
this.addStrategy(_arrayCollectionStrategy.ArrayCollectionStrategy, function (items) { | ||
return items instanceof Array; | ||
}); | ||
this.addStrategy(_mapCollectionStrategy.MapCollectionStrategy, function (items) { | ||
return items instanceof Map; | ||
}); | ||
this.addStrategy(_numberStrategy.NumberStrategy, function (items) { | ||
return typeof items === 'number'; | ||
}); | ||
} | ||
|
||
CollectionStrategyLocator.prototype.addStrategy = function addStrategy(collectionStrategy, matcher) { | ||
this.strategies.push(collectionStrategy); | ||
this.matchers.push(matcher); | ||
}; | ||
|
||
CollectionStrategyLocator.prototype.getStrategy = function getStrategy(items) { | ||
var matchers = this.matchers; | ||
|
||
for (var i = 0, ii = matchers.length; i < ii; ++i) { | ||
if (matchers[i](items)) { | ||
return this.container.get(this.strategies[i]); | ||
} | ||
} | ||
|
||
throw new Error('Object in "repeat" must have a valid collection strategy.'); | ||
}; | ||
|
||
var _CollectionStrategyLocator = CollectionStrategyLocator; | ||
CollectionStrategyLocator = _aureliaDependencyInjection.inject(_aureliaDependencyInjection.Container)(CollectionStrategyLocator) || CollectionStrategyLocator; | ||
return CollectionStrategyLocator; | ||
})(); | ||
|
||
exports.CollectionStrategyLocator = CollectionStrategyLocator; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
define(['exports', 'aurelia-dependency-injection', 'aurelia-binding'], function (exports, _aureliaDependencyInjection, _aureliaBinding) { | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
var CollectionStrategy = (function () { | ||
function CollectionStrategy(observerLocator) { | ||
_classCallCheck(this, _CollectionStrategy); | ||
|
||
this.observerLocator = observerLocator; | ||
} | ||
|
||
CollectionStrategy.prototype.initialize = function initialize(repeat, bindingContext, overrideContext) { | ||
this.viewFactory = repeat.viewFactory; | ||
this.viewSlot = repeat.viewSlot; | ||
this.items = repeat.items; | ||
this.local = repeat.local; | ||
this.key = repeat.key; | ||
this.value = repeat.value; | ||
this.bindingContext = bindingContext; | ||
this.overrideContext = overrideContext; | ||
}; | ||
|
||
CollectionStrategy.prototype.dispose = function dispose() { | ||
this.viewFactory = null; | ||
this.viewSlot = null; | ||
this.items = null; | ||
this.local = null; | ||
this.key = null; | ||
this.value = null; | ||
this.bindingContext = null; | ||
this.overrideContext = null; | ||
}; | ||
|
||
CollectionStrategy.prototype.updateOverrideContexts = function updateOverrideContexts(startIndex) { | ||
var children = this.viewSlot.children; | ||
var length = children.length; | ||
|
||
if (startIndex > 0) { | ||
startIndex = startIndex - 1; | ||
} | ||
|
||
for (; startIndex < length; ++startIndex) { | ||
this.updateOverrideContext(children[startIndex].overrideContext, startIndex, length); | ||
} | ||
}; | ||
|
||
CollectionStrategy.prototype.createFullOverrideContext = function createFullOverrideContext(data, index, length, key) { | ||
var context = this.createBaseOverrideContext(data, key); | ||
return this.updateOverrideContext(context, index, length); | ||
}; | ||
|
||
CollectionStrategy.prototype.createBaseOverrideContext = function createBaseOverrideContext(data, key) { | ||
var context = _aureliaBinding.createOverrideContext(undefined, this.overrideContext); | ||
|
||
if (typeof key !== 'undefined') { | ||
context[this.key] = key; | ||
context[this.value] = data; | ||
} else { | ||
context[this.local] = data; | ||
} | ||
|
||
return context; | ||
}; | ||
|
||
CollectionStrategy.prototype.updateOverrideContext = function updateOverrideContext(context, index, length) { | ||
var first = index === 0; | ||
var last = index === length - 1; | ||
var even = index % 2 === 0; | ||
|
||
context.$index = index; | ||
context.$first = first; | ||
context.$last = last; | ||
context.$middle = !(first || last); | ||
context.$odd = !even; | ||
context.$even = even; | ||
|
||
return context; | ||
}; | ||
|
||
var _CollectionStrategy = CollectionStrategy; | ||
CollectionStrategy = _aureliaDependencyInjection.transient()(CollectionStrategy) || CollectionStrategy; | ||
CollectionStrategy = _aureliaDependencyInjection.inject(_aureliaBinding.ObserverLocator)(CollectionStrategy) || CollectionStrategy; | ||
return CollectionStrategy; | ||
})(); | ||
|
||
exports.CollectionStrategy = CollectionStrategy; | ||
}); |
Oops, something went wrong.