From 8c9886db88b4226bedbdd5953880041fe77b1930 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Mon, 12 Jan 2015 09:55:50 -0500 Subject: [PATCH] chore(all): prepare release 0.7.0 --- bower.json | 2 +- dist/amd/compose.js | 105 ++++++---- dist/amd/if.js | 87 ++++++--- dist/amd/repeat.js | 339 +++++++++++++++++++-------------- dist/amd/selected-item.js | 124 ++++++++---- dist/amd/show.js | 63 ++++-- dist/commonjs/compose.js | 105 ++++++---- dist/commonjs/if.js | 87 ++++++--- dist/commonjs/repeat.js | 339 +++++++++++++++++++-------------- dist/commonjs/selected-item.js | 124 ++++++++---- dist/commonjs/show.js | 63 ++++-- dist/system/compose.js | 104 ++++++---- dist/system/if.js | 86 ++++++--- dist/system/repeat.js | 336 ++++++++++++++++++-------------- dist/system/selected-item.js | 123 ++++++++---- dist/system/show.js | 62 ++++-- doc/CHANGELOG.md | 8 + package.json | 2 +- 18 files changed, 1357 insertions(+), 802 deletions(-) diff --git a/bower.json b/bower.json index cdc91af..a021482 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-resources", - "version": "0.6.0", + "version": "0.7.0", "description": "A standard set of behaviors, converters and other resources for use with the Aurelia templating library.", "keywords": [ "aurelia", diff --git a/dist/amd/compose.js b/dist/amd/compose.js index d133520..00d921f 100644 --- a/dist/amd/compose.js +++ b/dist/amd/compose.js @@ -1,6 +1,11 @@ define(["exports", "aurelia-dependency-injection", "aurelia-templating"], function (exports, _aureliaDependencyInjection, _aureliaTemplating) { "use strict"; + var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); + }; + var Container = _aureliaDependencyInjection.Container; var CustomElement = _aureliaTemplating.CustomElement; var CompositionEngine = _aureliaTemplating.CompositionEngine; @@ -8,43 +13,75 @@ define(["exports", "aurelia-dependency-injection", "aurelia-templating"], functi var ViewSlot = _aureliaTemplating.ViewSlot; var NoView = _aureliaTemplating.NoView; var ViewResources = _aureliaTemplating.ViewResources; - var Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { - this.container = container; - this.compositionEngine = compositionEngine; - this.viewSlot = viewSlot; - this.viewResources = viewResources; - }; - - Compose.annotations = function () { - return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; - }; - - Compose.inject = function () { - return [Container, CompositionEngine, ViewSlot, ViewResources]; - }; + var Compose = (function () { + var Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { + this.container = container; + this.compositionEngine = compositionEngine; + this.viewSlot = viewSlot; + this.viewResources = viewResources; + }; - Compose.prototype.bind = function (executionContext) { - this.executionContext = executionContext; - processInstruction(this, { - view: this.view, - viewModel: this.viewModel, - model: this.model + _prototypeProperties(Compose, { + annotations: { + value: function () { + return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Container, CompositionEngine, ViewSlot, ViewResources]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function (executionContext) { + this.executionContext = executionContext; + processInstruction(this, { + view: this.view, + viewModel: this.viewModel, + model: this.model + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + modelChanged: { + value: function (newValue, oldValue) { + if (this.viewModel && typeof this.viewModel.activate === "function") { + this.viewModel.activate(newValue); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + viewChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { view: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + }, + viewModelChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { viewModel: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + } }); - }; - - Compose.prototype.modelChanged = function (newValue, oldValue) { - if (this.viewModel && typeof this.viewModel.activate === "function") { - this.viewModel.activate(newValue); - } - }; - Compose.prototype.viewChanged = function (newValue, oldValue) { - processInstruction(this, { view: newValue }); - }; - - Compose.prototype.viewModelChanged = function (newValue, oldValue) { - processInstruction(this, { viewModel: newValue }); - }; + return Compose; + })(); exports.Compose = Compose; diff --git a/dist/amd/if.js b/dist/amd/if.js index f31af62..643d8bc 100644 --- a/dist/amd/if.js +++ b/dist/amd/if.js @@ -1,49 +1,74 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating) { "use strict"; + var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); + }; + var TemplateController = _aureliaTemplating.TemplateController; var Property = _aureliaTemplating.Property; var BoundViewFactory = _aureliaTemplating.BoundViewFactory; var ViewSlot = _aureliaTemplating.ViewSlot; - var If = function If(viewFactory, viewSlot) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.showing = false; - }; - - If.annotations = function () { - return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; - }; - - If.inject = function () { - return [BoundViewFactory, ViewSlot]; - }; + var If = (function () { + var If = function If(viewFactory, viewSlot) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.showing = false; + }; - If.prototype.valueChanged = function (newValue) { - if (!newValue) { - if (this.view) { - this.viewSlot.remove(this.view); - this.view.unbind(); + _prototypeProperties(If, { + annotations: { + value: function () { + return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot]; + }, + writable: true, + enumerable: true, + configurable: true } + }, { + valueChanged: { + value: function (newValue) { + if (!newValue) { + if (this.view) { + this.viewSlot.remove(this.view); + this.view.unbind(); + } - this.showing = false; - return; - } + this.showing = false; + return; + } - if (!this.view) { - this.view = this.viewFactory.create(); - } + if (!this.view) { + this.view = this.viewFactory.create(); + } - if (!this.showing) { - this.showing = true; + if (!this.showing) { + this.showing = true; - if (!this.view.bound) { - this.view.bind(); + if (!this.view.bound) { + this.view.bind(); + } + + this.viewSlot.add(this.view); + } + }, + writable: true, + enumerable: true, + configurable: true } + }); - this.viewSlot.add(this.view); - } - }; + return If; + })(); exports.If = If; }); \ No newline at end of file diff --git a/dist/amd/repeat.js b/dist/amd/repeat.js index 35275af..256dba9 100644 --- a/dist/amd/repeat.js +++ b/dist/amd/repeat.js @@ -1,157 +1,212 @@ define(["exports", "aurelia-binding", "aurelia-templating"], function (exports, _aureliaBinding, _aureliaTemplating) { "use strict"; + var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); + }; + var ObserverLocator = _aureliaBinding.ObserverLocator; var calcSplices = _aureliaBinding.calcSplices; var TemplateController = _aureliaTemplating.TemplateController; var BoundViewFactory = _aureliaTemplating.BoundViewFactory; var ViewSlot = _aureliaTemplating.ViewSlot; var Property = _aureliaTemplating.Property; - var Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.observerLocator = observerLocator; - this.local = "item"; - }; - - Repeat.annotations = function () { - return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; - }; - - Repeat.inject = function () { - return [BoundViewFactory, ViewSlot, ObserverLocator]; - }; - - Repeat.prototype.bind = function (executionContext) { - var _this = this; - var items = this.items; - - this.executionContext = executionContext; - - if (this.oldItems === items) { - var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); - var observer = this.observerLocator.getArrayObserver(items); - - this.handleSplices(items, splices); - this.lastBoundItems = this.oldItems = null; - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this.handleSplices(items, splices); - }); - } else { - this.processItems(); - } - }; - - Repeat.prototype.unbind = function () { - this.oldItems = this.items; - this.lastBoundItems = this.items.slice(0); - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - this.disposeArraySubscription = null; - } - }; - - Repeat.prototype.itemsChanged = function () { - this.processItems(); - }; - - Repeat.prototype.processItems = function () { - var _this2 = this; - var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - viewSlot.removeAll(); - } - - for (i = 0, ii = items.length; i < ii; ++i) { - row = this.createFullExecutionContext(items[i], i, ii); - view = viewFactory.create(row); - viewSlot.add(view); - } - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this2.handleSplices(items, splices); - }); - }; - - Repeat.prototype.createBaseExecutionContext = function (data) { - var context = {}; - context[this.local] = data; - return context; - }; - - Repeat.prototype.createFullExecutionContext = function (data, index, length) { - var context = this.createBaseExecutionContext(data); - return this.updateExecutionContext(context, index, length); - }; - - Repeat.prototype.updateExecutionContext = function (context, index, length) { - var first = index === 0, last = index === length - 1, even = index % 2 === 0; - - context.$parent = this.executionContext; - context.$index = index; - context.$first = first; - context.$last = last; - context.$middle = !(first || last); - context.$odd = !even; - context.$even = even; - - return context; - }; - - Repeat.prototype.handleSplices = function (array, splices) { - var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - removed = splice.removed; - - for (j = 0, jj = removed.length; j < jj; ++j) { - model = removed[j]; - view = viewSlot.removeAt(splice.index + removeDelta); - - if (view) { - viewLookup.set(model, view); - } + var Repeat = (function () { + var Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.observerLocator = observerLocator; + this.local = "item"; + }; + + _prototypeProperties(Repeat, { + annotations: { + value: function () { + return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot, ObserverLocator]; + }, + writable: true, + enumerable: true, + configurable: true } - - removeDelta -= splice.addedCount; - } - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - addIndex = splice.index; - end = splice.index + splice.addedCount; - - for (; addIndex < end; ++addIndex) { - model = array[addIndex]; - view = viewLookup.get(model); - - if (view) { - viewLookup["delete"](model); - viewSlot.insert(addIndex, view); - } else { - row = this.createBaseExecutionContext(model); - view = this.viewFactory.create(row); - viewSlot.insert(addIndex, view); - } + }, { + bind: { + value: function (executionContext) { + var _this = this; + var items = this.items; + + this.executionContext = executionContext; + + if (this.oldItems === items) { + var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); + var observer = this.observerLocator.getArrayObserver(items); + + this.handleSplices(items, splices); + this.lastBoundItems = this.oldItems = null; + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this.handleSplices(items, splices); + }); + } else { + this.processItems(); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.oldItems = this.items; + this.lastBoundItems = this.items.slice(0); + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + this.disposeArraySubscription = null; + } + }, + writable: true, + enumerable: true, + configurable: true + }, + itemsChanged: { + value: function () { + this.processItems(); + }, + writable: true, + enumerable: true, + configurable: true + }, + processItems: { + value: function () { + var _this2 = this; + var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + viewSlot.removeAll(); + } + + for (i = 0, ii = items.length; i < ii; ++i) { + row = this.createFullExecutionContext(items[i], i, ii); + view = viewFactory.create(row); + viewSlot.add(view); + } + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this2.handleSplices(items, splices); + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + createBaseExecutionContext: { + value: function (data) { + var context = {}; + context[this.local] = data; + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + createFullExecutionContext: { + value: function (data, index, length) { + var context = this.createBaseExecutionContext(data); + return this.updateExecutionContext(context, index, length); + }, + writable: true, + enumerable: true, + configurable: true + }, + updateExecutionContext: { + value: function (context, index, length) { + var first = index === 0, + last = index === length - 1, + even = index % 2 === 0; + + context.$parent = this.executionContext; + context.$index = index; + context.$first = first; + context.$last = last; + context.$middle = !(first || last); + context.$odd = !even; + context.$even = even; + + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + handleSplices: { + value: function (array, splices) { + var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + removed = splice.removed; + + for (j = 0, jj = removed.length; j < jj; ++j) { + model = removed[j]; + view = viewSlot.removeAt(splice.index + removeDelta); + + if (view) { + viewLookup.set(model, view); + } + } + + removeDelta -= splice.addedCount; + } + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + addIndex = splice.index; + end = splice.index + splice.addedCount; + + for (; addIndex < end; ++addIndex) { + model = array[addIndex]; + view = viewLookup.get(model); + + if (view) { + viewLookup["delete"](model); + viewSlot.insert(addIndex, view); + } else { + row = this.createBaseExecutionContext(model); + view = this.viewFactory.create(row); + viewSlot.insert(addIndex, view); + } + } + } + + children = viewSlot.children; + length = children.length; + + for (i = 0; i < length; i++) { + this.updateExecutionContext(children[i].executionContext, i, length); + } + + viewLookup.forEach(function (x) { + return x.unbind(); + }); + }, + writable: true, + enumerable: true, + configurable: true } - } - - children = viewSlot.children; - length = children.length; - - for (i = 0; i < length; i++) { - this.updateExecutionContext(children[i].executionContext, i, length); - } - - viewLookup.forEach(function (x) { - return x.unbind(); }); - }; + + return Repeat; + })(); exports.Repeat = Repeat; }); \ No newline at end of file diff --git a/dist/amd/selected-item.js b/dist/amd/selected-item.js index b922b99..123f09f 100644 --- a/dist/amd/selected-item.js +++ b/dist/amd/selected-item.js @@ -1,58 +1,100 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating) { "use strict"; + var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); + }; + var AttachedBehavior = _aureliaTemplating.AttachedBehavior; var Property = _aureliaTemplating.Property; var Children = _aureliaTemplating.Children; - var SelectedItem = function SelectedItem(element) { - this.element = element; - this.options = []; - this.callback = this.selectedIndexChanged.bind(this); - }; - - SelectedItem.annotations = function () { - return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; - }; - - SelectedItem.inject = function () { - return [Element]; - }; - - SelectedItem.prototype.bind = function () { - this.element.addEventListener("change", this.callback, false); - }; - - SelectedItem.prototype.unbind = function () { - this.element.removeEventListener("change", this.callback); - }; - - SelectedItem.prototype.valueChanged = function (newValue) { - this.optionsChanged(); - }; + var SelectedItem = (function () { + var SelectedItem = function SelectedItem(element) { + this.element = element; + this.options = []; + this.callback = this.selectedIndexChanged.bind(this); + }; - SelectedItem.prototype.selectedIndexChanged = function () { - var index = this.element.selectedIndex, option = this.options[index]; + _prototypeProperties(SelectedItem, { + annotations: { + value: function () { + return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function () { + this.element.addEventListener("change", this.callback, false); + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.element.removeEventListener("change", this.callback); + }, + writable: true, + enumerable: true, + configurable: true + }, + valueChanged: { + value: function (newValue) { + this.optionsChanged(); + }, + writable: true, + enumerable: true, + configurable: true + }, + selectedIndexChanged: { + value: function () { + var index = this.element.selectedIndex, + option = this.options[index]; - this.value = option ? option.model : null; - }; + this.value = option ? option.model : null; + }, + writable: true, + enumerable: true, + configurable: true + }, + optionsChanged: { + value: function (mutations) { + var value = this.value, options = this.options, option, i, ii; - SelectedItem.prototype.optionsChanged = function (mutations) { - var value = this.value, options = this.options, option, i, ii; + for (i = 0, ii = options.length; i < ii; ++i) { + option = options[i]; - for (i = 0, ii = options.length; i < ii; ++i) { - option = options[i]; + if (option.model === value) { + if (this.element.selectedIndex !== i) { + this.element.selectedIndex = i; + } - if (option.model === value) { - if (this.element.selectedIndex !== i) { - this.element.selectedIndex = i; - } + return; + } + } - return; + this.element.selectedIndex = 0; + }, + writable: true, + enumerable: true, + configurable: true } - } + }); - this.element.selectedIndex = 0; - }; + return SelectedItem; + })(); exports.SelectedItem = SelectedItem; }); \ No newline at end of file diff --git a/dist/amd/show.js b/dist/amd/show.js index f84fab5..cf5503d 100644 --- a/dist/amd/show.js +++ b/dist/amd/show.js @@ -1,29 +1,54 @@ define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating) { "use strict"; - var AttachedBehavior = _aureliaTemplating.AttachedBehavior; - var Property = _aureliaTemplating.Property; - var Show = function Show(element) { - this.element = element; - this.displayStyle = element.style.display; + var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - Show.annotations = function () { - return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; - }; + var AttachedBehavior = _aureliaTemplating.AttachedBehavior; + var Property = _aureliaTemplating.Property; + var Show = (function () { + var Show = function Show(element) { + this.element = element; + this.displayStyle = element.style.display; + }; - Show.inject = function () { - return [Element]; - }; + _prototypeProperties(Show, { + annotations: { + value: function () { + return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + valueChanged: { + value: function (newValue) { + if (newValue) { + this.element.style.display = this.displayStyle || "block"; + } else { + this.displayStyle = this.element.style.display; + this.element.style.display = "none"; + } + }, + writable: true, + enumerable: true, + configurable: true + } + }); - Show.prototype.valueChanged = function (newValue) { - if (newValue) { - this.element.style.display = this.displayStyle || "block"; - } else { - this.displayStyle = this.element.style.display; - this.element.style.display = "none"; - } - }; + return Show; + })(); exports.Show = Show; }); \ No newline at end of file diff --git a/dist/commonjs/compose.js b/dist/commonjs/compose.js index ca42666..8f3df8e 100644 --- a/dist/commonjs/compose.js +++ b/dist/commonjs/compose.js @@ -1,5 +1,10 @@ "use strict"; +var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); +}; + var Container = require("aurelia-dependency-injection").Container; var CustomElement = require("aurelia-templating").CustomElement; var CompositionEngine = require("aurelia-templating").CompositionEngine; @@ -7,43 +12,75 @@ var Property = require("aurelia-templating").Property; var ViewSlot = require("aurelia-templating").ViewSlot; var NoView = require("aurelia-templating").NoView; var ViewResources = require("aurelia-templating").ViewResources; -var Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { - this.container = container; - this.compositionEngine = compositionEngine; - this.viewSlot = viewSlot; - this.viewResources = viewResources; -}; - -Compose.annotations = function () { - return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; -}; - -Compose.inject = function () { - return [Container, CompositionEngine, ViewSlot, ViewResources]; -}; +var Compose = (function () { + var Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { + this.container = container; + this.compositionEngine = compositionEngine; + this.viewSlot = viewSlot; + this.viewResources = viewResources; + }; -Compose.prototype.bind = function (executionContext) { - this.executionContext = executionContext; - processInstruction(this, { - view: this.view, - viewModel: this.viewModel, - model: this.model + _prototypeProperties(Compose, { + annotations: { + value: function () { + return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Container, CompositionEngine, ViewSlot, ViewResources]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function (executionContext) { + this.executionContext = executionContext; + processInstruction(this, { + view: this.view, + viewModel: this.viewModel, + model: this.model + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + modelChanged: { + value: function (newValue, oldValue) { + if (this.viewModel && typeof this.viewModel.activate === "function") { + this.viewModel.activate(newValue); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + viewChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { view: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + }, + viewModelChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { viewModel: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + } }); -}; - -Compose.prototype.modelChanged = function (newValue, oldValue) { - if (this.viewModel && typeof this.viewModel.activate === "function") { - this.viewModel.activate(newValue); - } -}; -Compose.prototype.viewChanged = function (newValue, oldValue) { - processInstruction(this, { view: newValue }); -}; - -Compose.prototype.viewModelChanged = function (newValue, oldValue) { - processInstruction(this, { viewModel: newValue }); -}; + return Compose; +})(); exports.Compose = Compose; diff --git a/dist/commonjs/if.js b/dist/commonjs/if.js index 547672b..12cfa85 100644 --- a/dist/commonjs/if.js +++ b/dist/commonjs/if.js @@ -1,47 +1,72 @@ "use strict"; +var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); +}; + var TemplateController = require("aurelia-templating").TemplateController; var Property = require("aurelia-templating").Property; var BoundViewFactory = require("aurelia-templating").BoundViewFactory; var ViewSlot = require("aurelia-templating").ViewSlot; -var If = function If(viewFactory, viewSlot) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.showing = false; -}; - -If.annotations = function () { - return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; -}; - -If.inject = function () { - return [BoundViewFactory, ViewSlot]; -}; +var If = (function () { + var If = function If(viewFactory, viewSlot) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.showing = false; + }; -If.prototype.valueChanged = function (newValue) { - if (!newValue) { - if (this.view) { - this.viewSlot.remove(this.view); - this.view.unbind(); + _prototypeProperties(If, { + annotations: { + value: function () { + return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot]; + }, + writable: true, + enumerable: true, + configurable: true } + }, { + valueChanged: { + value: function (newValue) { + if (!newValue) { + if (this.view) { + this.viewSlot.remove(this.view); + this.view.unbind(); + } - this.showing = false; - return; - } + this.showing = false; + return; + } - if (!this.view) { - this.view = this.viewFactory.create(); - } + if (!this.view) { + this.view = this.viewFactory.create(); + } - if (!this.showing) { - this.showing = true; + if (!this.showing) { + this.showing = true; - if (!this.view.bound) { - this.view.bind(); + if (!this.view.bound) { + this.view.bind(); + } + + this.viewSlot.add(this.view); + } + }, + writable: true, + enumerable: true, + configurable: true } + }); - this.viewSlot.add(this.view); - } -}; + return If; +})(); exports.If = If; \ No newline at end of file diff --git a/dist/commonjs/repeat.js b/dist/commonjs/repeat.js index 7aacf94..16a27d1 100644 --- a/dist/commonjs/repeat.js +++ b/dist/commonjs/repeat.js @@ -1,155 +1,210 @@ "use strict"; +var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); +}; + var ObserverLocator = require("aurelia-binding").ObserverLocator; var calcSplices = require("aurelia-binding").calcSplices; var TemplateController = require("aurelia-templating").TemplateController; var BoundViewFactory = require("aurelia-templating").BoundViewFactory; var ViewSlot = require("aurelia-templating").ViewSlot; var Property = require("aurelia-templating").Property; -var Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.observerLocator = observerLocator; - this.local = "item"; -}; - -Repeat.annotations = function () { - return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; -}; - -Repeat.inject = function () { - return [BoundViewFactory, ViewSlot, ObserverLocator]; -}; - -Repeat.prototype.bind = function (executionContext) { - var _this = this; - var items = this.items; - - this.executionContext = executionContext; - - if (this.oldItems === items) { - var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); - var observer = this.observerLocator.getArrayObserver(items); - - this.handleSplices(items, splices); - this.lastBoundItems = this.oldItems = null; - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this.handleSplices(items, splices); - }); - } else { - this.processItems(); - } -}; - -Repeat.prototype.unbind = function () { - this.oldItems = this.items; - this.lastBoundItems = this.items.slice(0); - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - this.disposeArraySubscription = null; - } -}; - -Repeat.prototype.itemsChanged = function () { - this.processItems(); -}; - -Repeat.prototype.processItems = function () { - var _this2 = this; - var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - viewSlot.removeAll(); - } - - for (i = 0, ii = items.length; i < ii; ++i) { - row = this.createFullExecutionContext(items[i], i, ii); - view = viewFactory.create(row); - viewSlot.add(view); - } - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this2.handleSplices(items, splices); - }); -}; - -Repeat.prototype.createBaseExecutionContext = function (data) { - var context = {}; - context[this.local] = data; - return context; -}; - -Repeat.prototype.createFullExecutionContext = function (data, index, length) { - var context = this.createBaseExecutionContext(data); - return this.updateExecutionContext(context, index, length); -}; - -Repeat.prototype.updateExecutionContext = function (context, index, length) { - var first = index === 0, last = index === length - 1, even = index % 2 === 0; - - context.$parent = this.executionContext; - context.$index = index; - context.$first = first; - context.$last = last; - context.$middle = !(first || last); - context.$odd = !even; - context.$even = even; - - return context; -}; - -Repeat.prototype.handleSplices = function (array, splices) { - var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - removed = splice.removed; - - for (j = 0, jj = removed.length; j < jj; ++j) { - model = removed[j]; - view = viewSlot.removeAt(splice.index + removeDelta); - - if (view) { - viewLookup.set(model, view); - } +var Repeat = (function () { + var Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.observerLocator = observerLocator; + this.local = "item"; + }; + + _prototypeProperties(Repeat, { + annotations: { + value: function () { + return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot, ObserverLocator]; + }, + writable: true, + enumerable: true, + configurable: true } - - removeDelta -= splice.addedCount; - } - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - addIndex = splice.index; - end = splice.index + splice.addedCount; - - for (; addIndex < end; ++addIndex) { - model = array[addIndex]; - view = viewLookup.get(model); - - if (view) { - viewLookup["delete"](model); - viewSlot.insert(addIndex, view); - } else { - row = this.createBaseExecutionContext(model); - view = this.viewFactory.create(row); - viewSlot.insert(addIndex, view); - } + }, { + bind: { + value: function (executionContext) { + var _this = this; + var items = this.items; + + this.executionContext = executionContext; + + if (this.oldItems === items) { + var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); + var observer = this.observerLocator.getArrayObserver(items); + + this.handleSplices(items, splices); + this.lastBoundItems = this.oldItems = null; + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this.handleSplices(items, splices); + }); + } else { + this.processItems(); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.oldItems = this.items; + this.lastBoundItems = this.items.slice(0); + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + this.disposeArraySubscription = null; + } + }, + writable: true, + enumerable: true, + configurable: true + }, + itemsChanged: { + value: function () { + this.processItems(); + }, + writable: true, + enumerable: true, + configurable: true + }, + processItems: { + value: function () { + var _this2 = this; + var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + viewSlot.removeAll(); + } + + for (i = 0, ii = items.length; i < ii; ++i) { + row = this.createFullExecutionContext(items[i], i, ii); + view = viewFactory.create(row); + viewSlot.add(view); + } + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this2.handleSplices(items, splices); + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + createBaseExecutionContext: { + value: function (data) { + var context = {}; + context[this.local] = data; + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + createFullExecutionContext: { + value: function (data, index, length) { + var context = this.createBaseExecutionContext(data); + return this.updateExecutionContext(context, index, length); + }, + writable: true, + enumerable: true, + configurable: true + }, + updateExecutionContext: { + value: function (context, index, length) { + var first = index === 0, + last = index === length - 1, + even = index % 2 === 0; + + context.$parent = this.executionContext; + context.$index = index; + context.$first = first; + context.$last = last; + context.$middle = !(first || last); + context.$odd = !even; + context.$even = even; + + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + handleSplices: { + value: function (array, splices) { + var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + removed = splice.removed; + + for (j = 0, jj = removed.length; j < jj; ++j) { + model = removed[j]; + view = viewSlot.removeAt(splice.index + removeDelta); + + if (view) { + viewLookup.set(model, view); + } + } + + removeDelta -= splice.addedCount; + } + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + addIndex = splice.index; + end = splice.index + splice.addedCount; + + for (; addIndex < end; ++addIndex) { + model = array[addIndex]; + view = viewLookup.get(model); + + if (view) { + viewLookup["delete"](model); + viewSlot.insert(addIndex, view); + } else { + row = this.createBaseExecutionContext(model); + view = this.viewFactory.create(row); + viewSlot.insert(addIndex, view); + } + } + } + + children = viewSlot.children; + length = children.length; + + for (i = 0; i < length; i++) { + this.updateExecutionContext(children[i].executionContext, i, length); + } + + viewLookup.forEach(function (x) { + return x.unbind(); + }); + }, + writable: true, + enumerable: true, + configurable: true } - } - - children = viewSlot.children; - length = children.length; - - for (i = 0; i < length; i++) { - this.updateExecutionContext(children[i].executionContext, i, length); - } - - viewLookup.forEach(function (x) { - return x.unbind(); }); -}; + + return Repeat; +})(); exports.Repeat = Repeat; \ No newline at end of file diff --git a/dist/commonjs/selected-item.js b/dist/commonjs/selected-item.js index cac8afa..a8f130e 100644 --- a/dist/commonjs/selected-item.js +++ b/dist/commonjs/selected-item.js @@ -1,56 +1,98 @@ "use strict"; +var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); +}; + var AttachedBehavior = require("aurelia-templating").AttachedBehavior; var Property = require("aurelia-templating").Property; var Children = require("aurelia-templating").Children; -var SelectedItem = function SelectedItem(element) { - this.element = element; - this.options = []; - this.callback = this.selectedIndexChanged.bind(this); -}; - -SelectedItem.annotations = function () { - return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; -}; - -SelectedItem.inject = function () { - return [Element]; -}; - -SelectedItem.prototype.bind = function () { - this.element.addEventListener("change", this.callback, false); -}; - -SelectedItem.prototype.unbind = function () { - this.element.removeEventListener("change", this.callback); -}; - -SelectedItem.prototype.valueChanged = function (newValue) { - this.optionsChanged(); -}; +var SelectedItem = (function () { + var SelectedItem = function SelectedItem(element) { + this.element = element; + this.options = []; + this.callback = this.selectedIndexChanged.bind(this); + }; -SelectedItem.prototype.selectedIndexChanged = function () { - var index = this.element.selectedIndex, option = this.options[index]; + _prototypeProperties(SelectedItem, { + annotations: { + value: function () { + return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function () { + this.element.addEventListener("change", this.callback, false); + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.element.removeEventListener("change", this.callback); + }, + writable: true, + enumerable: true, + configurable: true + }, + valueChanged: { + value: function (newValue) { + this.optionsChanged(); + }, + writable: true, + enumerable: true, + configurable: true + }, + selectedIndexChanged: { + value: function () { + var index = this.element.selectedIndex, + option = this.options[index]; - this.value = option ? option.model : null; -}; + this.value = option ? option.model : null; + }, + writable: true, + enumerable: true, + configurable: true + }, + optionsChanged: { + value: function (mutations) { + var value = this.value, options = this.options, option, i, ii; -SelectedItem.prototype.optionsChanged = function (mutations) { - var value = this.value, options = this.options, option, i, ii; + for (i = 0, ii = options.length; i < ii; ++i) { + option = options[i]; - for (i = 0, ii = options.length; i < ii; ++i) { - option = options[i]; + if (option.model === value) { + if (this.element.selectedIndex !== i) { + this.element.selectedIndex = i; + } - if (option.model === value) { - if (this.element.selectedIndex !== i) { - this.element.selectedIndex = i; - } + return; + } + } - return; + this.element.selectedIndex = 0; + }, + writable: true, + enumerable: true, + configurable: true } - } + }); - this.element.selectedIndex = 0; -}; + return SelectedItem; +})(); exports.SelectedItem = SelectedItem; \ No newline at end of file diff --git a/dist/commonjs/show.js b/dist/commonjs/show.js index 5816d04..cd3490a 100644 --- a/dist/commonjs/show.js +++ b/dist/commonjs/show.js @@ -1,27 +1,52 @@ "use strict"; -var AttachedBehavior = require("aurelia-templating").AttachedBehavior; -var Property = require("aurelia-templating").Property; -var Show = function Show(element) { - this.element = element; - this.displayStyle = element.style.display; +var _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; -Show.annotations = function () { - return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; -}; +var AttachedBehavior = require("aurelia-templating").AttachedBehavior; +var Property = require("aurelia-templating").Property; +var Show = (function () { + var Show = function Show(element) { + this.element = element; + this.displayStyle = element.style.display; + }; -Show.inject = function () { - return [Element]; -}; + _prototypeProperties(Show, { + annotations: { + value: function () { + return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + valueChanged: { + value: function (newValue) { + if (newValue) { + this.element.style.display = this.displayStyle || "block"; + } else { + this.displayStyle = this.element.style.display; + this.element.style.display = "none"; + } + }, + writable: true, + enumerable: true, + configurable: true + } + }); -Show.prototype.valueChanged = function (newValue) { - if (newValue) { - this.element.style.display = this.displayStyle || "block"; - } else { - this.displayStyle = this.element.style.display; - this.element.style.display = "none"; - } -}; + return Show; +})(); exports.Show = Show; \ No newline at end of file diff --git a/dist/system/compose.js b/dist/system/compose.js index 15db783..46758ea 100644 --- a/dist/system/compose.js +++ b/dist/system/compose.js @@ -1,7 +1,7 @@ System.register(["aurelia-dependency-injection", "aurelia-templating"], function (_export) { "use strict"; - var Container, CustomElement, CompositionEngine, Property, ViewSlot, NoView, ViewResources, Compose; + var Container, CustomElement, CompositionEngine, Property, ViewSlot, NoView, ViewResources, _prototypeProperties, Compose; function processInstruction(composer, instruction) { @@ -27,44 +27,80 @@ System.register(["aurelia-dependency-injection", "aurelia-templating"], function ViewResources = _aureliaTemplating.ViewResources; }], execute: function () { - Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { - this.container = container; - this.compositionEngine = compositionEngine; - this.viewSlot = viewSlot; - this.viewResources = viewResources; + _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - Compose.annotations = function () { - return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; - }; - - Compose.inject = function () { - return [Container, CompositionEngine, ViewSlot, ViewResources]; - }; + Compose = (function () { + var Compose = function Compose(container, compositionEngine, viewSlot, viewResources) { + this.container = container; + this.compositionEngine = compositionEngine; + this.viewSlot = viewSlot; + this.viewResources = viewResources; + }; - Compose.prototype.bind = function (executionContext) { - this.executionContext = executionContext; - processInstruction(this, { - view: this.view, - viewModel: this.viewModel, - model: this.model + _prototypeProperties(Compose, { + annotations: { + value: function () { + return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Container, CompositionEngine, ViewSlot, ViewResources]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function (executionContext) { + this.executionContext = executionContext; + processInstruction(this, { + view: this.view, + viewModel: this.viewModel, + model: this.model + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + modelChanged: { + value: function (newValue, oldValue) { + if (this.viewModel && typeof this.viewModel.activate === "function") { + this.viewModel.activate(newValue); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + viewChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { view: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + }, + viewModelChanged: { + value: function (newValue, oldValue) { + processInstruction(this, { viewModel: newValue }); + }, + writable: true, + enumerable: true, + configurable: true + } }); - }; - - Compose.prototype.modelChanged = function (newValue, oldValue) { - if (this.viewModel && typeof this.viewModel.activate === "function") { - this.viewModel.activate(newValue); - } - }; - - Compose.prototype.viewChanged = function (newValue, oldValue) { - processInstruction(this, { view: newValue }); - }; - - Compose.prototype.viewModelChanged = function (newValue, oldValue) { - processInstruction(this, { viewModel: newValue }); - }; + return Compose; + })(); _export("Compose", Compose); } }; diff --git a/dist/system/if.js b/dist/system/if.js index 7724912..c018e57 100644 --- a/dist/system/if.js +++ b/dist/system/if.js @@ -1,7 +1,7 @@ System.register(["aurelia-templating"], function (_export) { "use strict"; - var TemplateController, Property, BoundViewFactory, ViewSlot, If; + var TemplateController, Property, BoundViewFactory, ViewSlot, _prototypeProperties, If; return { setters: [function (_aureliaTemplating) { TemplateController = _aureliaTemplating.TemplateController; @@ -10,46 +10,70 @@ System.register(["aurelia-templating"], function (_export) { ViewSlot = _aureliaTemplating.ViewSlot; }], execute: function () { - If = function If(viewFactory, viewSlot) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.showing = false; + _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - If.annotations = function () { - return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; - }; - - If.inject = function () { - return [BoundViewFactory, ViewSlot]; - }; + If = (function () { + var If = function If(viewFactory, viewSlot) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.showing = false; + }; - If.prototype.valueChanged = function (newValue) { - if (!newValue) { - if (this.view) { - this.viewSlot.remove(this.view); - this.view.unbind(); + _prototypeProperties(If, { + annotations: { + value: function () { + return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot]; + }, + writable: true, + enumerable: true, + configurable: true } + }, { + valueChanged: { + value: function (newValue) { + if (!newValue) { + if (this.view) { + this.viewSlot.remove(this.view); + this.view.unbind(); + } - this.showing = false; - return; - } + this.showing = false; + return; + } - if (!this.view) { - this.view = this.viewFactory.create(); - } + if (!this.view) { + this.view = this.viewFactory.create(); + } - if (!this.showing) { - this.showing = true; + if (!this.showing) { + this.showing = true; - if (!this.view.bound) { - this.view.bind(); - } + if (!this.view.bound) { + this.view.bind(); + } - this.viewSlot.add(this.view); - } - }; + this.viewSlot.add(this.view); + } + }, + writable: true, + enumerable: true, + configurable: true + } + }); + return If; + })(); _export("If", If); } }; diff --git a/dist/system/repeat.js b/dist/system/repeat.js index 6dc3461..0357609 100644 --- a/dist/system/repeat.js +++ b/dist/system/repeat.js @@ -1,7 +1,7 @@ System.register(["aurelia-binding", "aurelia-templating"], function (_export) { "use strict"; - var ObserverLocator, calcSplices, TemplateController, BoundViewFactory, ViewSlot, Property, Repeat; + var ObserverLocator, calcSplices, TemplateController, BoundViewFactory, ViewSlot, Property, _prototypeProperties, Repeat; return { setters: [function (_aureliaBinding) { ObserverLocator = _aureliaBinding.ObserverLocator; @@ -13,152 +13,206 @@ System.register(["aurelia-binding", "aurelia-templating"], function (_export) { Property = _aureliaTemplating.Property; }], execute: function () { - Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { - this.viewFactory = viewFactory; - this.viewSlot = viewSlot; - this.observerLocator = observerLocator; - this.local = "item"; + _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - Repeat.annotations = function () { - return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; - }; - - Repeat.inject = function () { - return [BoundViewFactory, ViewSlot, ObserverLocator]; - }; - - Repeat.prototype.bind = function (executionContext) { - var _this = this; - var items = this.items; - - this.executionContext = executionContext; - - if (this.oldItems === items) { - var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); - var observer = this.observerLocator.getArrayObserver(items); - - this.handleSplices(items, splices); - this.lastBoundItems = this.oldItems = null; - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this.handleSplices(items, splices); - }); - } else { - this.processItems(); - } - }; - - Repeat.prototype.unbind = function () { - this.oldItems = this.items; - this.lastBoundItems = this.items.slice(0); - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - this.disposeArraySubscription = null; - } - }; - - Repeat.prototype.itemsChanged = function () { - this.processItems(); - }; - - Repeat.prototype.processItems = function () { - var _this2 = this; - var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; - - if (this.disposeArraySubscription) { - this.disposeArraySubscription(); - viewSlot.removeAll(); - } - - for (i = 0, ii = items.length; i < ii; ++i) { - row = this.createFullExecutionContext(items[i], i, ii); - view = viewFactory.create(row); - viewSlot.add(view); - } - - this.disposeArraySubscription = observer.subscribe(function (splices) { - _this2.handleSplices(items, splices); - }); - }; - - Repeat.prototype.createBaseExecutionContext = function (data) { - var context = {}; - context[this.local] = data; - return context; - }; - - Repeat.prototype.createFullExecutionContext = function (data, index, length) { - var context = this.createBaseExecutionContext(data); - return this.updateExecutionContext(context, index, length); - }; - - Repeat.prototype.updateExecutionContext = function (context, index, length) { - var first = index === 0, last = index === length - 1, even = index % 2 === 0; - - context.$parent = this.executionContext; - context.$index = index; - context.$first = first; - context.$last = last; - context.$middle = !(first || last); - context.$odd = !even; - context.$even = even; - - return context; - }; - - Repeat.prototype.handleSplices = function (array, splices) { - var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - removed = splice.removed; - - for (j = 0, jj = removed.length; j < jj; ++j) { - model = removed[j]; - view = viewSlot.removeAt(splice.index + removeDelta); - - if (view) { - viewLookup.set(model, view); - } + Repeat = (function () { + var Repeat = function Repeat(viewFactory, viewSlot, observerLocator) { + this.viewFactory = viewFactory; + this.viewSlot = viewSlot; + this.observerLocator = observerLocator; + this.local = "item"; + }; + + _prototypeProperties(Repeat, { + annotations: { + value: function () { + return [new TemplateController("repeat"), new Property("items", "itemsChanged", "repeat"), new Property("local")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [BoundViewFactory, ViewSlot, ObserverLocator]; + }, + writable: true, + enumerable: true, + configurable: true } - - removeDelta -= splice.addedCount; - } - - for (i = 0, ii = splices.length; i < ii; ++i) { - splice = splices[i]; - addIndex = splice.index; - end = splice.index + splice.addedCount; - - for (; addIndex < end; ++addIndex) { - model = array[addIndex]; - view = viewLookup.get(model); - - if (view) { - viewLookup["delete"](model); - viewSlot.insert(addIndex, view); - } else { - row = this.createBaseExecutionContext(model); - view = this.viewFactory.create(row); - viewSlot.insert(addIndex, view); - } + }, { + bind: { + value: function (executionContext) { + var _this = this; + var items = this.items; + + this.executionContext = executionContext; + + if (this.oldItems === items) { + var splices = calcSplices(items, 0, items.length, this.lastBoundItems, 0, this.lastBoundItems.length); + var observer = this.observerLocator.getArrayObserver(items); + + this.handleSplices(items, splices); + this.lastBoundItems = this.oldItems = null; + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this.handleSplices(items, splices); + }); + } else { + this.processItems(); + } + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.oldItems = this.items; + this.lastBoundItems = this.items.slice(0); + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + this.disposeArraySubscription = null; + } + }, + writable: true, + enumerable: true, + configurable: true + }, + itemsChanged: { + value: function () { + this.processItems(); + }, + writable: true, + enumerable: true, + configurable: true + }, + processItems: { + value: function () { + var _this2 = this; + var items = this.items, observer = this.observerLocator.getArrayObserver(items), viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, row, view; + + if (this.disposeArraySubscription) { + this.disposeArraySubscription(); + viewSlot.removeAll(); + } + + for (i = 0, ii = items.length; i < ii; ++i) { + row = this.createFullExecutionContext(items[i], i, ii); + view = viewFactory.create(row); + viewSlot.add(view); + } + + this.disposeArraySubscription = observer.subscribe(function (splices) { + _this2.handleSplices(items, splices); + }); + }, + writable: true, + enumerable: true, + configurable: true + }, + createBaseExecutionContext: { + value: function (data) { + var context = {}; + context[this.local] = data; + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + createFullExecutionContext: { + value: function (data, index, length) { + var context = this.createBaseExecutionContext(data); + return this.updateExecutionContext(context, index, length); + }, + writable: true, + enumerable: true, + configurable: true + }, + updateExecutionContext: { + value: function (context, index, length) { + var first = index === 0, + last = index === length - 1, + even = index % 2 === 0; + + context.$parent = this.executionContext; + context.$index = index; + context.$first = first; + context.$last = last; + context.$middle = !(first || last); + context.$odd = !even; + context.$even = even; + + return context; + }, + writable: true, + enumerable: true, + configurable: true + }, + handleSplices: { + value: function (array, splices) { + var viewLookup = new Map(), removeDelta = 0, arrayLength = array.length, viewSlot = this.viewSlot, viewFactory = this.viewFactory, i, ii, j, jj, splice, removed, addIndex, end, model, view, children, length, row; + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + removed = splice.removed; + + for (j = 0, jj = removed.length; j < jj; ++j) { + model = removed[j]; + view = viewSlot.removeAt(splice.index + removeDelta); + + if (view) { + viewLookup.set(model, view); + } + } + + removeDelta -= splice.addedCount; + } + + for (i = 0, ii = splices.length; i < ii; ++i) { + splice = splices[i]; + addIndex = splice.index; + end = splice.index + splice.addedCount; + + for (; addIndex < end; ++addIndex) { + model = array[addIndex]; + view = viewLookup.get(model); + + if (view) { + viewLookup["delete"](model); + viewSlot.insert(addIndex, view); + } else { + row = this.createBaseExecutionContext(model); + view = this.viewFactory.create(row); + viewSlot.insert(addIndex, view); + } + } + } + + children = viewSlot.children; + length = children.length; + + for (i = 0; i < length; i++) { + this.updateExecutionContext(children[i].executionContext, i, length); + } + + viewLookup.forEach(function (x) { + return x.unbind(); + }); + }, + writable: true, + enumerable: true, + configurable: true } - } - - children = viewSlot.children; - length = children.length; - - for (i = 0; i < length; i++) { - this.updateExecutionContext(children[i].executionContext, i, length); - } - - viewLookup.forEach(function (x) { - return x.unbind(); }); - }; + return Repeat; + })(); _export("Repeat", Repeat); } }; diff --git a/dist/system/selected-item.js b/dist/system/selected-item.js index a0780af..281dae8 100644 --- a/dist/system/selected-item.js +++ b/dist/system/selected-item.js @@ -1,7 +1,7 @@ System.register(["aurelia-templating"], function (_export) { "use strict"; - var AttachedBehavior, Property, Children, SelectedItem; + var AttachedBehavior, Property, Children, _prototypeProperties, SelectedItem; return { setters: [function (_aureliaTemplating) { AttachedBehavior = _aureliaTemplating.AttachedBehavior; @@ -9,56 +9,97 @@ System.register(["aurelia-templating"], function (_export) { Children = _aureliaTemplating.Children; }], execute: function () { - SelectedItem = function SelectedItem(element) { - this.element = element; - this.options = []; - this.callback = this.selectedIndexChanged.bind(this); + _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - SelectedItem.annotations = function () { - return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; - }; - - SelectedItem.inject = function () { - return [Element]; - }; - - SelectedItem.prototype.bind = function () { - this.element.addEventListener("change", this.callback, false); - }; - - SelectedItem.prototype.unbind = function () { - this.element.removeEventListener("change", this.callback); - }; + SelectedItem = (function () { + var SelectedItem = function SelectedItem(element) { + this.element = element; + this.options = []; + this.callback = this.selectedIndexChanged.bind(this); + }; - SelectedItem.prototype.valueChanged = function (newValue) { - this.optionsChanged(); - }; - - SelectedItem.prototype.selectedIndexChanged = function () { - var index = this.element.selectedIndex, option = this.options[index]; + _prototypeProperties(SelectedItem, { + annotations: { + value: function () { + return [new AttachedBehavior("selected-item"), new Property("value", "valueChanged", "selected-item"), new Children("options", "optionsChanged", "option")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + bind: { + value: function () { + this.element.addEventListener("change", this.callback, false); + }, + writable: true, + enumerable: true, + configurable: true + }, + unbind: { + value: function () { + this.element.removeEventListener("change", this.callback); + }, + writable: true, + enumerable: true, + configurable: true + }, + valueChanged: { + value: function (newValue) { + this.optionsChanged(); + }, + writable: true, + enumerable: true, + configurable: true + }, + selectedIndexChanged: { + value: function () { + var index = this.element.selectedIndex, + option = this.options[index]; - this.value = option ? option.model : null; - }; + this.value = option ? option.model : null; + }, + writable: true, + enumerable: true, + configurable: true + }, + optionsChanged: { + value: function (mutations) { + var value = this.value, options = this.options, option, i, ii; - SelectedItem.prototype.optionsChanged = function (mutations) { - var value = this.value, options = this.options, option, i, ii; + for (i = 0, ii = options.length; i < ii; ++i) { + option = options[i]; - for (i = 0, ii = options.length; i < ii; ++i) { - option = options[i]; + if (option.model === value) { + if (this.element.selectedIndex !== i) { + this.element.selectedIndex = i; + } - if (option.model === value) { - if (this.element.selectedIndex !== i) { - this.element.selectedIndex = i; - } + return; + } + } - return; + this.element.selectedIndex = 0; + }, + writable: true, + enumerable: true, + configurable: true } - } - - this.element.selectedIndex = 0; - }; + }); + return SelectedItem; + })(); _export("SelectedItem", SelectedItem); } }; diff --git a/dist/system/show.js b/dist/system/show.js index 3c3f51c..7c58957 100644 --- a/dist/system/show.js +++ b/dist/system/show.js @@ -1,35 +1,59 @@ System.register(["aurelia-templating"], function (_export) { "use strict"; - var AttachedBehavior, Property, Show; + var AttachedBehavior, Property, _prototypeProperties, Show; return { setters: [function (_aureliaTemplating) { AttachedBehavior = _aureliaTemplating.AttachedBehavior; Property = _aureliaTemplating.Property; }], execute: function () { - Show = function Show(element) { - this.element = element; - this.displayStyle = element.style.display; + _prototypeProperties = function (child, staticProps, instanceProps) { + if (staticProps) Object.defineProperties(child, staticProps); + if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; - Show.annotations = function () { - return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; - }; - - Show.inject = function () { - return [Element]; - }; + Show = (function () { + var Show = function Show(element) { + this.element = element; + this.displayStyle = element.style.display; + }; - Show.prototype.valueChanged = function (newValue) { - if (newValue) { - this.element.style.display = this.displayStyle || "block"; - } else { - this.displayStyle = this.element.style.display; - this.element.style.display = "none"; - } - }; + _prototypeProperties(Show, { + annotations: { + value: function () { + return [new AttachedBehavior("show"), new Property("value", "valueChanged", "show")]; + }, + writable: true, + enumerable: true, + configurable: true + }, + inject: { + value: function () { + return [Element]; + }, + writable: true, + enumerable: true, + configurable: true + } + }, { + valueChanged: { + value: function (newValue) { + if (newValue) { + this.element.style.display = this.displayStyle || "block"; + } else { + this.displayStyle = this.element.style.display; + this.element.style.display = "none"; + } + }, + writable: true, + enumerable: true, + configurable: true + } + }); + return Show; + })(); _export("Show", Show); } }; diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 7f4c272..8550f65 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.7.0 (2015-01-12) + + +#### Bug Fixes + +* **package:** update Aurelia dependencies ([f121fbb1](http://github.com/aurelia/templating-resources/commit/f121fbb1b4149bb84878396d3eb6ea804eec1e47)) + + ## 0.6.0 (2015-01-07) diff --git a/package.json b/package.json index 622ac91..18ec4ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-resources", - "version": "0.6.0", + "version": "0.7.0", "description": "A standard set of behaviors, converters and other resources for use with the Aurelia templating library.", "keywords": [ "aurelia",