Skip to content

Commit

Permalink
chore(all): prepare release 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 18, 2018
1 parent c275107 commit 3da40f1
Show file tree
Hide file tree
Showing 22 changed files with 402 additions and 290 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.5.4",
"version": "1.6.0",
"description": "A standard set of behaviors, converters and other resources for use with the Aurelia templating library.",
"keywords": [
"aurelia",
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/analyze-view-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(['exports'], function (exports) {
value: true
});
exports.viewsRequireLifecycle = viewsRequireLifecycle;
var lifecycleOptionalBehaviors = exports.lifecycleOptionalBehaviors = ['focus', 'if', 'repeat', 'show', 'with'];
var lifecycleOptionalBehaviors = exports.lifecycleOptionalBehaviors = ['focus', 'if', 'else', 'repeat', 'show', 'hide', 'with'];

function behaviorRequiresLifecycle(instruction) {
var t = instruction.type;
Expand Down
48 changes: 33 additions & 15 deletions dist/amd/debounce-binding-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {



function debounce(newValue) {
var unset = {};

function debounceCallSource(event) {
var _this = this;

var state = this.debounceState;
if (state.immediate) {
state.immediate = false;
this.debouncedMethod(newValue);
clearTimeout(state.timeoutId);
state.timeoutId = setTimeout(function () {
return _this.debouncedMethod(event);
}, state.delay);
}

function debounceCall(context, newValue, oldValue) {
var _this2 = this;

var state = this.debounceState;
clearTimeout(state.timeoutId);
if (context !== state.callContextToDebounce) {
state.oldValue = unset;
this.debouncedMethod(context, newValue, oldValue);
return;
}
clearTimeout(state.timeoutId);
if (state.oldValue === unset) {
state.oldValue = oldValue;
}
state.timeoutId = setTimeout(function () {
return _this.debouncedMethod(newValue);
var ov = state.oldValue;
state.oldValue = unset;
_this2.debouncedMethod(context, newValue, ov);
}, state.delay);
}

Expand All @@ -31,22 +48,23 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {
DebounceBindingBehavior.prototype.bind = function bind(binding, source) {
var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;

var methodToDebounce = 'updateTarget';
if (binding.callSource) {
methodToDebounce = 'callSource';
} else if (binding.updateSource && binding.mode === _aureliaBinding.bindingMode.twoWay) {
methodToDebounce = 'updateSource';
}
var isCallSource = binding.callSource !== undefined;
var methodToDebounce = isCallSource ? 'callSource' : 'call';
var debouncer = isCallSource ? debounceCallSource : debounceCall;
var mode = binding.mode;
var callContextToDebounce = mode === _aureliaBinding.bindingMode.twoWay || mode === _aureliaBinding.bindingMode.fromView ? _aureliaBinding.targetContext : _aureliaBinding.sourceContext;

binding.debouncedMethod = binding[methodToDebounce];
binding.debouncedMethod.originalName = methodToDebounce;

binding[methodToDebounce] = debounce;
binding[methodToDebounce] = debouncer;

binding.debounceState = {
callContextToDebounce: callContextToDebounce,
delay: delay,
timeoutId: null,
immediate: methodToDebounce === 'updateTarget' };
timeoutId: 0,
oldValue: unset
};
};

DebounceBindingBehavior.prototype.unbind = function unbind(binding, source) {
Expand Down
17 changes: 7 additions & 10 deletions dist/amd/update-trigger-binding-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {



var _class, _temp;

var eventNamesRequired = 'The updateTrigger binding behavior requires at least one event name argument: eg <input value.bind="firstName & updateTrigger:\'blur\'">';
var notApplicableMessage = 'The updateTrigger binding behavior can only be applied to two-way bindings on input/select elements.';
var notApplicableMessage = 'The updateTrigger binding behavior can only be applied to two-way/ from-view bindings on input/select elements.';

var UpdateTriggerBindingBehavior = exports.UpdateTriggerBindingBehavior = (_temp = _class = function () {
function UpdateTriggerBindingBehavior(eventManager) {
var UpdateTriggerBindingBehavior = exports.UpdateTriggerBindingBehavior = function () {
function UpdateTriggerBindingBehavior() {


this.eventManager = eventManager;
}

UpdateTriggerBindingBehavior.prototype.bind = function bind(binding, source) {
Expand All @@ -28,7 +24,7 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {
if (events.length === 0) {
throw new Error(eventNamesRequired);
}
if (binding.mode !== _aureliaBinding.bindingMode.twoWay) {
if (binding.mode !== _aureliaBinding.bindingMode.twoWay && binding.mode !== _aureliaBinding.bindingMode.fromView) {
throw new Error(notApplicableMessage);
}

Expand All @@ -40,15 +36,16 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) {

targetObserver.originalHandler = binding.targetObserver.handler;

var handler = this.eventManager.createElementHandler(events);
var handler = new _aureliaBinding.EventSubscriber(events);
targetObserver.handler = handler;
};

UpdateTriggerBindingBehavior.prototype.unbind = function unbind(binding, source) {
binding.targetObserver.handler.dispose();
binding.targetObserver.handler = binding.targetObserver.originalHandler;
binding.targetObserver.originalHandler = null;
};

return UpdateTriggerBindingBehavior;
}(), _class.inject = [_aureliaBinding.EventManager], _temp);
}();
});
5 changes: 2 additions & 3 deletions dist/aurelia-templating-resources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import {
import {
createOverrideContext,
bindingMode,
EventManager,
EventSubscriber,
BindingBehavior,
ValueConverter,
sourceContext,
targetContext,
DataAttributeObserver,
mergeSplice,
valueConverter,
Expand Down Expand Up @@ -92,8 +93,6 @@ export declare class With {
unbind(): any;
}
export declare class UpdateTriggerBindingBehavior {
static inject: any;
constructor(eventManager?: any);
bind(binding?: any, source?: any, ...events: any[]): any;
unbind(binding?: any, source?: any): any;
}
Expand Down
70 changes: 39 additions & 31 deletions dist/aurelia-templating-resources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as LogManager from 'aurelia-logging';
import {inject,Container,Optional} from 'aurelia-dependency-injection';
import {BoundViewFactory,ViewSlot,customAttribute,templateController,useView,customElement,bindable,ViewResources,resource,ViewCompileInstruction,CompositionEngine,CompositionContext,noView,View,ViewEngine,Animator,TargetInstruction} from 'aurelia-templating';
import {createOverrideContext,bindingMode,EventManager,BindingBehavior,ValueConverter,sourceContext,DataAttributeObserver,mergeSplice,valueConverter,ObserverLocator} from 'aurelia-binding';
import {createOverrideContext,bindingMode,EventSubscriber,BindingBehavior,ValueConverter,sourceContext,targetContext,DataAttributeObserver,mergeSplice,valueConverter,ObserverLocator} from 'aurelia-binding';
import {TaskQueue} from 'aurelia-task-queue';
import {DOM,FEATURE} from 'aurelia-pal';
import {Loader} from 'aurelia-loader';
Expand Down Expand Up @@ -65,20 +65,15 @@ export class With {
}

const eventNamesRequired = 'The updateTrigger binding behavior requires at least one event name argument: eg <input value.bind="firstName & updateTrigger:\'blur\'">';
const notApplicableMessage = 'The updateTrigger binding behavior can only be applied to two-way bindings on input/select elements.';
const notApplicableMessage = 'The updateTrigger binding behavior can only be applied to two-way/ from-view bindings on input/select elements.';

export class UpdateTriggerBindingBehavior {
static inject = [EventManager];

constructor(eventManager) {
this.eventManager = eventManager;
}

bind(binding, source, ...events) {
if (events.length === 0) {
throw new Error(eventNamesRequired);
}
if (binding.mode !== bindingMode.twoWay) {
if (binding.mode !== bindingMode.twoWay && binding.mode !== bindingMode.fromView) {
throw new Error(notApplicableMessage);
}

Expand All @@ -93,12 +88,13 @@ export class UpdateTriggerBindingBehavior {
targetObserver.originalHandler = binding.targetObserver.handler;

// replace the element subscribe function with one that uses the correct events.
let handler = this.eventManager.createElementHandler(events);
let handler = new EventSubscriber(events);
targetObserver.handler = handler;
}

unbind(binding, source) {
// restore the state of the binding.
binding.targetObserver.handler.dispose();
binding.targetObserver.handler = binding.targetObserver.originalHandler;
binding.targetObserver.originalHandler = null;
}
Expand Down Expand Up @@ -551,28 +547,39 @@ export function _createDynamicElement(name: string, viewUrl: string, bindableNam
return DynamicElement;
}

function debounce(newValue) {
let state = this.debounceState;
if (state.immediate) {
state.immediate = false;
this.debouncedMethod(newValue);
const unset = {};

function debounceCallSource(event) {
const state = this.debounceState;
clearTimeout(state.timeoutId);
state.timeoutId = setTimeout(() => this.debouncedMethod(event), state.delay);
}

function debounceCall(context, newValue, oldValue) {
const state = this.debounceState;
clearTimeout(state.timeoutId);
if (context !== state.callContextToDebounce) {
state.oldValue = unset;
this.debouncedMethod(context, newValue, oldValue);
return;
}
clearTimeout(state.timeoutId);
state.timeoutId = setTimeout(
() => this.debouncedMethod(newValue),
state.delay);
if (state.oldValue === unset) {
state.oldValue = oldValue;
}
state.timeoutId = setTimeout(() => {
const ov = state.oldValue;
state.oldValue = unset;
this.debouncedMethod(context, newValue, ov);
}, state.delay);
}

export class DebounceBindingBehavior {
bind(binding, source, delay = 200) {
// determine which method to debounce.
let methodToDebounce = 'updateTarget'; // one-way bindings or interpolation bindings
if (binding.callSource) {
methodToDebounce = 'callSource'; // listener and call bindings
} else if (binding.updateSource && binding.mode === bindingMode.twoWay) {
methodToDebounce = 'updateSource'; // two-way bindings
}
const isCallSource = binding.callSource !== undefined;
const methodToDebounce = isCallSource ? 'callSource' : 'call';
const debouncer = isCallSource ? debounceCallSource : debounceCall;
const mode = binding.mode;
const callContextToDebounce = mode === bindingMode.twoWay || mode === bindingMode.fromView ? targetContext : sourceContext;

// stash the original method and it's name.
// note: a generic name like "originalMethod" is not used to avoid collisions
Expand All @@ -581,19 +588,20 @@ export class DebounceBindingBehavior {
binding.debouncedMethod.originalName = methodToDebounce;

// replace the original method with the debouncing version.
binding[methodToDebounce] = debounce;
binding[methodToDebounce] = debouncer;

// create the debounce state.
binding.debounceState = {
delay: delay,
timeoutId: null,
immediate: methodToDebounce === 'updateTarget' // should not delay initial target update that occurs during bind.
callContextToDebounce,
delay,
timeoutId: 0,
oldValue: unset
};
}

unbind(binding, source) {
// restore the state of the binding.
let methodToRestore = binding.debouncedMethod.originalName;
const methodToRestore = binding.debouncedMethod.originalName;
binding[methodToRestore] = binding.debouncedMethod;
binding.debouncedMethod = null;
clearTimeout(binding.debounceState.timeoutId);
Expand Down Expand Up @@ -958,7 +966,7 @@ export class AttrBindingBehavior {
* Behaviors that do not require the composition lifecycle callbacks when replacing
* their binding context.
*/
export const lifecycleOptionalBehaviors = ['focus', 'if', 'repeat', 'show', 'with'];
export const lifecycleOptionalBehaviors = ['focus', 'if', 'else', 'repeat', 'show', 'hide', 'with'];

function behaviorRequiresLifecycle(instruction) {
let t = instruction.type;
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/analyze-view-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.viewsRequireLifecycle = viewsRequireLifecycle;
var lifecycleOptionalBehaviors = exports.lifecycleOptionalBehaviors = ['focus', 'if', 'repeat', 'show', 'with'];
var lifecycleOptionalBehaviors = exports.lifecycleOptionalBehaviors = ['focus', 'if', 'else', 'repeat', 'show', 'hide', 'with'];

function behaviorRequiresLifecycle(instruction) {
var t = instruction.type;
Expand Down
48 changes: 33 additions & 15 deletions dist/commonjs/debounce-binding-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@ var _aureliaBinding = require('aurelia-binding');



function debounce(newValue) {
var unset = {};

function debounceCallSource(event) {
var _this = this;

var state = this.debounceState;
if (state.immediate) {
state.immediate = false;
this.debouncedMethod(newValue);
clearTimeout(state.timeoutId);
state.timeoutId = setTimeout(function () {
return _this.debouncedMethod(event);
}, state.delay);
}

function debounceCall(context, newValue, oldValue) {
var _this2 = this;

var state = this.debounceState;
clearTimeout(state.timeoutId);
if (context !== state.callContextToDebounce) {
state.oldValue = unset;
this.debouncedMethod(context, newValue, oldValue);
return;
}
clearTimeout(state.timeoutId);
if (state.oldValue === unset) {
state.oldValue = oldValue;
}
state.timeoutId = setTimeout(function () {
return _this.debouncedMethod(newValue);
var ov = state.oldValue;
state.oldValue = unset;
_this2.debouncedMethod(context, newValue, ov);
}, state.delay);
}

Expand All @@ -32,22 +49,23 @@ var DebounceBindingBehavior = exports.DebounceBindingBehavior = function () {
DebounceBindingBehavior.prototype.bind = function bind(binding, source) {
var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;

var methodToDebounce = 'updateTarget';
if (binding.callSource) {
methodToDebounce = 'callSource';
} else if (binding.updateSource && binding.mode === _aureliaBinding.bindingMode.twoWay) {
methodToDebounce = 'updateSource';
}
var isCallSource = binding.callSource !== undefined;
var methodToDebounce = isCallSource ? 'callSource' : 'call';
var debouncer = isCallSource ? debounceCallSource : debounceCall;
var mode = binding.mode;
var callContextToDebounce = mode === _aureliaBinding.bindingMode.twoWay || mode === _aureliaBinding.bindingMode.fromView ? _aureliaBinding.targetContext : _aureliaBinding.sourceContext;

binding.debouncedMethod = binding[methodToDebounce];
binding.debouncedMethod.originalName = methodToDebounce;

binding[methodToDebounce] = debounce;
binding[methodToDebounce] = debouncer;

binding.debounceState = {
callContextToDebounce: callContextToDebounce,
delay: delay,
timeoutId: null,
immediate: methodToDebounce === 'updateTarget' };
timeoutId: 0,
oldValue: unset
};
};

DebounceBindingBehavior.prototype.unbind = function unbind(binding, source) {
Expand Down
Loading

0 comments on commit 3da40f1

Please sign in to comment.