Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0-beta.1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed May 3, 2016
1 parent d5856be commit 707fab9
Show file tree
Hide file tree
Showing 38 changed files with 1,916 additions and 439 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating-resources",
"version": "1.0.0-beta.1.2.2",
"version": "1.0.0-beta.1.2.3",
"description": "A standard set of behaviors, converters and other resources for use with the Aurelia templating library.",
"keywords": [
"aurelia",
Expand Down
12 changes: 12 additions & 0 deletions dist/amd/abstract-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ define(['exports'], function (exports) {
throw new Error('subclass must implement `view`');
};

AbstractRepeater.prototype.matcher = function matcher() {
throw new Error('subclass must implement `matcher`');
};

AbstractRepeater.prototype.addView = function addView(bindingContext, overrideContext) {
throw new Error('subclass must implement `addView`');
};
Expand All @@ -41,10 +45,18 @@ define(['exports'], function (exports) {
throw new Error('subclass must implement `insertView`');
};

AbstractRepeater.prototype.moveView = function moveView(sourceIndex, targetIndex) {
throw new Error('subclass must implement `moveView`');
};

AbstractRepeater.prototype.removeAllViews = function removeAllViews(returnToCache, skipAnimation) {
throw new Error('subclass must implement `removeAllViews`');
};

AbstractRepeater.prototype.removeViews = function removeViews(viewsToRemove, returnToCache, skipAnimation) {
throw new Error('subclass must implement `removeView`');
};

AbstractRepeater.prototype.removeView = function removeView(index, returnToCache, skipAnimation) {
throw new Error('subclass must implement `removeView`');
};
Expand Down
5 changes: 1 addition & 4 deletions dist/amd/analyze-view-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ define(['exports'], function (exports) {
function behaviorRequiresLifecycle(instruction) {
var t = instruction.type;
var name = t.elementName !== null ? t.elementName : t.attributeName;
if (lifecycleOptionalBehaviors.indexOf(name) === -1) {
return t.handlesAttached || t.handlesBind || t.handlesCreated || t.handlesDetached || t.handlesUnbind;
}
return instruction.viewFactory && viewsRequireLifecycle(instruction.viewFactory);
return lifecycleOptionalBehaviors.indexOf(name) === -1 && (t.handlesAttached || t.handlesBind || t.handlesCreated || t.handlesDetached || t.handlesUnbind) || t.viewFactory && viewsRequireLifecycle(t.viewFactory) || instruction.viewFactory && viewsRequireLifecycle(instruction.viewFactory);
}

function targetRequiresLifecycle(instruction) {
Expand Down
90 changes: 81 additions & 9 deletions dist/amd/array-repeat-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,90 @@ define(['exports', './repeat-utilities', 'aurelia-binding'], function (exports,
ArrayRepeatStrategy.prototype.instanceChanged = function instanceChanged(repeat, items) {
var _this = this;

if (repeat.viewsRequireLifecycle) {
var removePromise = repeat.removeAllViews(true);
if (removePromise instanceof Promise) {
removePromise.then(function () {
return _this._standardProcessInstanceChanged(repeat, items);
});
return;
}
var itemsLength = items.length;

if (!items || itemsLength === 0) {
repeat.removeAllViews(true);
return;
}

var children = repeat.views();
var viewsLength = children.length;

if (viewsLength === 0) {
this._standardProcessInstanceChanged(repeat, items);
return;
}
this._inPlaceProcessItems(repeat, items);

if (repeat.viewsRequireLifecycle) {
(function () {
var childrenSnapshot = children.slice(0);
var itemNameInBindingContext = repeat.local;
var matcher = repeat.matcher();

var itemsPreviouslyInViews = [];
var viewsToRemove = [];

for (var index = 0; index < viewsLength; index++) {
var view = childrenSnapshot[index];
var oldItem = view.bindingContext[itemNameInBindingContext];

if ((0, _repeatUtilities.indexOf)(items, oldItem, matcher) === -1) {
viewsToRemove.push(view);
} else {
itemsPreviouslyInViews.push(oldItem);
}
}

var updateViews = void 0;
var removePromise = void 0;

if (itemsPreviouslyInViews.length > 0) {
removePromise = repeat.removeViews(viewsToRemove, true);
updateViews = function updateViews() {
for (var _index = 0; _index < itemsLength; _index++) {
var item = items[_index];
var indexOfView = (0, _repeatUtilities.indexOf)(itemsPreviouslyInViews, item, matcher, _index);
var _view = void 0;

if (indexOfView === -1) {
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, items[_index], _index, itemsLength);
repeat.insertView(_index, overrideContext.bindingContext, overrideContext);

itemsPreviouslyInViews.splice(_index, 0, undefined);
} else if (indexOfView === _index) {
_view = children[indexOfView];
itemsPreviouslyInViews[indexOfView] = undefined;
} else {
_view = children[indexOfView];
repeat.moveView(indexOfView, _index);
itemsPreviouslyInViews.splice(indexOfView, 1);
itemsPreviouslyInViews.splice(_index, 0, undefined);
}

if (_view) {
(0, _repeatUtilities.updateOverrideContext)(_view.overrideContext, _index, itemsLength);
}
}

_this._inPlaceProcessItems(repeat, items);
};
} else {
removePromise = repeat.removeAllViews(true);
updateViews = function updateViews() {
return _this._standardProcessInstanceChanged(repeat, items);
};
}

if (removePromise instanceof Promise) {
removePromise.then(updateViews);
} else {
updateViews();
}
})();
} else {
this._inPlaceProcessItems(repeat, items);
}
};

ArrayRepeatStrategy.prototype._standardProcessInstanceChanged = function _standardProcessInstanceChanged(repeat, items) {
Expand Down
33 changes: 33 additions & 0 deletions dist/amd/aurelia-templating-resources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ declare module 'aurelia-templating-resources' {
*/
export function updateOneTimeBinding(binding: any): any;

/**
* Returns the index of the element in an array, optionally using a matcher function.
*/
export function indexOf(array: any, item: any, matcher: any, startIndex: any): any;

/**
* A strategy for repeating a template over null or undefined (does nothing)
*/
Expand Down Expand Up @@ -469,6 +474,13 @@ declare module 'aurelia-templating-resources' {
*/
view(index: any): any;

/**
* Returns the matcher function to be used by the repeater, or null if strict matching is to be performed.
*
* @return {Function|null} The requested matcher function.
*/
matcher(): any;

/**
* Adds a view to the repeater, binding the view to the
* provided contexts.
Expand All @@ -488,6 +500,14 @@ declare module 'aurelia-templating-resources' {
*/
insertView(index: any, bindingContext: any, overrideContext: any): any;

/**
* Moves a view across the repeater.
*
* @param {Number} sourceIndex The index of the view to be moved.
* @param {Number} sourceIndex The index where the view should be placed at.
*/
moveView(sourceIndex: any, targetIndex: any): any;

/**
* Removes all views from the repeater.
* @param {Boolean} returnToCache Should the view be returned to the view cache?
Expand All @@ -496,6 +516,16 @@ declare module 'aurelia-templating-resources' {
*/
removeAllViews(returnToCache?: boolean, skipAnimation?: boolean): any;

/**
* Removes an array of Views from the repeater.
*
* @param {Array} viewsToRemove The array of views to be removed.
* @param {Boolean} returnToCache Should the view be returned to the view cache?
* @param {Boolean} skipAnimation Should the removal animation be skipped?
* @return {Promise|null}
*/
removeViews(viewsToRemove: Array<View>, returnToCache?: boolean, skipAnimation?: boolean): any;

/**
* Removes a view from the repeater at a specific index.
*
Expand Down Expand Up @@ -717,9 +747,12 @@ declare module 'aurelia-templating-resources' {
viewCount(): any;
views(): any;
view(index: any): any;
matcher(): any;
addView(bindingContext: any, overrideContext: any): any;
insertView(index: any, bindingContext: any, overrideContext: any): any;
moveView(sourceIndex: any, targetIndex: any): any;
removeAllViews(returnToCache: any, skipAnimation: any): any;
removeViews(viewsToRemove: any, returnToCache: any, skipAnimation: any): any;
removeView(index: any, returnToCache: any, skipAnimation: any): any;
updateBindings(view: View): any;
}
Expand Down
30 changes: 21 additions & 9 deletions dist/amd/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', 'aurelia-dependency-

this.element = element;
this.taskQueue = taskQueue;
this.isAttached = false;
this.needsApply = false;

this.focusListener = function (e) {
_this.value = true;
Expand All @@ -34,29 +36,39 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', 'aurelia-dependency-
}

Focus.prototype.valueChanged = function valueChanged(newValue) {
if (newValue) {
this._giveFocus();
if (this.isAttached) {
this._apply();
} else {
this.element.blur();
this.needsApply = true;
}
};

Focus.prototype._giveFocus = function _giveFocus() {
Focus.prototype._apply = function _apply() {
var _this2 = this;

this.taskQueue.queueMicroTask(function () {
if (_this2.value) {
_this2.element.focus();
}
});
if (this.value) {
this.taskQueue.queueMicroTask(function () {
if (_this2.value) {
_this2.element.focus();
}
});
} else {
this.element.blur();
}
};

Focus.prototype.attached = function attached() {
this.isAttached = true;
if (this.needsApply) {
this.needsApply = false;
this._apply();
}
this.element.addEventListener('focus', this.focusListener);
this.element.addEventListener('blur', this.blurListener);
};

Focus.prototype.detached = function detached() {
this.isAttached = false;
this.element.removeEventListener('focus', this.focusListener);
this.element.removeEventListener('blur', this.blurListener);
};
Expand Down
14 changes: 14 additions & 0 deletions dist/amd/repeat-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {
exports.unwrapExpression = unwrapExpression;
exports.isOneTime = isOneTime;
exports.updateOneTimeBinding = updateOneTimeBinding;
exports.indexOf = indexOf;


var oneTime = _aureliaBinding.bindingMode.oneTime;
Expand Down Expand Up @@ -89,4 +90,17 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {
binding.updateOneTimeBindings();
}
}

function indexOf(array, item, matcher, startIndex) {
if (!matcher) {
return array.indexOf(item);
}
var length = array.length;
for (var index = startIndex || 0; index < length; index++) {
if (matcher(array[index], item)) {
return index;
}
}
return -1;
}
});
40 changes: 40 additions & 0 deletions dist/amd/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t

Repeat.prototype.bind = function bind(bindingContext, overrideContext) {
this.scope = { bindingContext: bindingContext, overrideContext: overrideContext };
this.matcherBinding = this._captureAndRemoveMatcherBinding();
this.itemsChanged();
};

Repeat.prototype.unbind = function unbind() {
this.scope = null;
this.items = null;
this.matcherBinding = null;
this.viewSlot.removeAll(true);
this._unsubscribeCollection();
};
Expand Down Expand Up @@ -167,12 +169,19 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
};

Repeat.prototype.handleCollectionMutated = function handleCollectionMutated(collection, changes) {
if (!this.collectionObserver) {
return;
}
this.strategy.instanceMutated(this, collection, changes);
};

Repeat.prototype.handleInnerCollectionMutated = function handleInnerCollectionMutated(collection, changes) {
var _this2 = this;

if (!this.collectionObserver) {
return;
}

if (this.ignoreMutation) {
return;
}
Expand Down Expand Up @@ -213,6 +222,25 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
}
};

Repeat.prototype._captureAndRemoveMatcherBinding = function _captureAndRemoveMatcherBinding() {
if (this.viewFactory.viewFactory) {
var instructions = this.viewFactory.viewFactory.instructions;
var instructionIds = Object.keys(instructions);
for (var i = 0; i < instructionIds.length; i++) {
var expressions = instructions[instructionIds[i]].expressions;
if (expressions) {
for (var ii = 0; i < expressions.length; i++) {
if (expressions[ii].targetProperty === 'matcher') {
var matcherBinding = expressions[ii];
expressions.splice(ii, 1);
return matcherBinding;
}
}
}
}
}
};

Repeat.prototype.viewCount = function viewCount() {
return this.viewSlot.children.length;
};
Expand All @@ -225,6 +253,10 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
return this.viewSlot.children[index];
};

Repeat.prototype.matcher = function matcher() {
return this.matcherBinding ? this.matcherBinding.sourceExpression.evaluate(this.scope, this.matcherBinding.lookupFunctions) : null;
};

Repeat.prototype.addView = function addView(bindingContext, overrideContext) {
var view = this.viewFactory.create();
view.bind(bindingContext, overrideContext);
Expand All @@ -237,10 +269,18 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-t
this.viewSlot.insert(index, view);
};

Repeat.prototype.moveView = function moveView(sourceIndex, targetIndex) {
this.viewSlot.move(sourceIndex, targetIndex);
};

Repeat.prototype.removeAllViews = function removeAllViews(returnToCache, skipAnimation) {
return this.viewSlot.removeAll(returnToCache, skipAnimation);
};

Repeat.prototype.removeViews = function removeViews(viewsToRemove, returnToCache, skipAnimation) {
return this.viewSlot.removeMany(viewsToRemove, returnToCache, skipAnimation);
};

Repeat.prototype.removeView = function removeView(index, returnToCache, skipAnimation) {
return this.viewSlot.removeAt(index, returnToCache, skipAnimation);
};
Expand Down
Loading

0 comments on commit 707fab9

Please sign in to comment.