From 49879cfbd02145bff4ae0e6a964ff84607fa0782 Mon Sep 17 00:00:00 2001 From: Simon Fox Date: Tue, 14 Apr 2015 10:05:32 +1200 Subject: [PATCH] babel building bindable properties correctly. changed interface and value properties to controller and selectedItem --- dist/amd/lookup-widget.js | 23 +++++++++++++++-------- dist/commonjs/lookup-widget.js | 23 +++++++++++++++-------- dist/es6/lookup-widget.js | 20 ++++++++++---------- dist/system/lookup-widget.js | 23 +++++++++++++++-------- package.json | 3 ++- src/lookup-widget.js | 20 ++++++++++---------- 6 files changed, 67 insertions(+), 45 deletions(-) diff --git a/dist/amd/lookup-widget.js b/dist/amd/lookup-widget.js index 5a984e4..07480ed 100644 --- a/dist/amd/lookup-widget.js +++ b/dist/amd/lookup-widget.js @@ -53,11 +53,11 @@ define(['exports', 'aurelia-framework', 'jquery', 'select2'], function (exports, var self = _this; _$(_this.element).find('input').select2({ initSelection: function initSelection(element, callback) { - callback(self['interface'].setDefaultSelection()); + callback(self.controller.setDefaultSelection()); }, placeholder: _this.placeholder, - formatSelection: self['interface'].formatSelection, - formatResult: self['interface'].formatItem, + formatSelection: self.controller.formatSelection, + formatResult: self.controller.formatItem, query: (function (_query) { function query(_x) { return _query.apply(this, arguments); @@ -69,26 +69,33 @@ define(['exports', 'aurelia-framework', 'jquery', 'select2'], function (exports, return query; })(function (query) { - self['interface'].search(query.term).then(function (result) { + self.controller.search(query.term).then(function (result) { query.callback({ results: result }); }); }), width: '100%' }); - _$(_this.element).find('input').select2('val', _this.value); + _$(_this.element).find('input').select2('val', _this.selectedItem); _$(_this.element).find('input').on('change', function () { - _this.value = _$(_this.element).find('input').select2('val'); + _this.selectedItem = _$(_this.element).find('input').select2('val'); }); }, 100); } }], null, _instanceInitializers); LookupWidget = _aureliaFramework.bindable({ - name: 'value', - attribute: 'value', + name: 'selectedItem', + attribute: 'selected-item', defaultBindingMode: _aureliaFramework.TWO_WAY })(LookupWidget) || LookupWidget; + LookupWidget = _aureliaFramework.bindable({ + name: 'controller', + attribute: 'controller', + defaultBindingMode: _aureliaFramework.TWO_WAY + })(LookupWidget) || LookupWidget; + LookupWidget = _aureliaFramework.customElement('lookup-widget')(LookupWidget) || LookupWidget; + LookupWidget = _aureliaFramework.inject(Element)(LookupWidget) || LookupWidget; return LookupWidget; })(); diff --git a/dist/commonjs/lookup-widget.js b/dist/commonjs/lookup-widget.js index 2e02808..4f612b2 100644 --- a/dist/commonjs/lookup-widget.js +++ b/dist/commonjs/lookup-widget.js @@ -58,11 +58,11 @@ var LookupWidget = (function () { var self = _this; _$2['default'](_this.element).find('input').select2({ initSelection: function initSelection(element, callback) { - callback(self['interface'].setDefaultSelection()); + callback(self.controller.setDefaultSelection()); }, placeholder: _this.placeholder, - formatSelection: self['interface'].formatSelection, - formatResult: self['interface'].formatItem, + formatSelection: self.controller.formatSelection, + formatResult: self.controller.formatItem, query: (function (_query) { function query(_x) { return _query.apply(this, arguments); @@ -74,26 +74,33 @@ var LookupWidget = (function () { return query; })(function (query) { - self['interface'].search(query.term).then(function (result) { + self.controller.search(query.term).then(function (result) { query.callback({ results: result }); }); }), width: '100%' }); - _$2['default'](_this.element).find('input').select2('val', _this.value); + _$2['default'](_this.element).find('input').select2('val', _this.selectedItem); _$2['default'](_this.element).find('input').on('change', function () { - _this.value = _$2['default'](_this.element).find('input').select2('val'); + _this.selectedItem = _$2['default'](_this.element).find('input').select2('val'); }); }, 100); } }], null, _instanceInitializers); LookupWidget = _inject$bindable$customElement$TWO_WAY.bindable({ - name: 'value', - attribute: 'value', + name: 'selectedItem', + attribute: 'selected-item', defaultBindingMode: _inject$bindable$customElement$TWO_WAY.TWO_WAY })(LookupWidget) || LookupWidget; + LookupWidget = _inject$bindable$customElement$TWO_WAY.bindable({ + name: 'controller', + attribute: 'controller', + defaultBindingMode: _inject$bindable$customElement$TWO_WAY.TWO_WAY + })(LookupWidget) || LookupWidget; + LookupWidget = _inject$bindable$customElement$TWO_WAY.customElement('lookup-widget')(LookupWidget) || LookupWidget; + LookupWidget = _inject$bindable$customElement$TWO_WAY.inject(Element)(LookupWidget) || LookupWidget; return LookupWidget; })(); diff --git a/dist/es6/lookup-widget.js b/dist/es6/lookup-widget.js index 9945ea6..8dff9b1 100644 --- a/dist/es6/lookup-widget.js +++ b/dist/es6/lookup-widget.js @@ -5,13 +5,13 @@ import select2 from 'select2'; @inject(Element) @customElement('lookup-widget') @bindable({ - name:'interface', - attribute:'interface', + name:'controller', + attribute:'controller', defaultBindingMode: TWO_WAY }) @bindable({ - name:'value', - attribute:'value', + name:'selectedItem', + attribute:'selected-item', defaultBindingMode: TWO_WAY }) export class LookupWidget { @@ -32,22 +32,22 @@ export class LookupWidget { var self = this; $(this.element).find('input').select2({ initSelection: function(element, callback) { - callback(self.interface.setDefaultSelection()); + callback(self.controller.setDefaultSelection()); }, placeholder: this.placeholder, - formatSelection: self.interface.formatSelection, - formatResult: self.interface.formatItem, + formatSelection: self.controller.formatSelection, + formatResult: self.controller.formatItem, query: function(query) { - self.interface.search(query.term).then((result) => { + self.controller.search(query.term).then((result) => { query.callback({ results: result }); }); }, width:'100%' }); - $(this.element).find('input').select2('val', this.value); + $(this.element).find('input').select2('val', this.selectedItem); $(this.element).find('input').on('change', () => { - this.value = $(this.element).find('input').select2('val'); + this.selectedItem = $(this.element).find('input').select2('val'); }); }, 100); } diff --git a/dist/system/lookup-widget.js b/dist/system/lookup-widget.js index 572b1b2..ec0ebbd 100644 --- a/dist/system/lookup-widget.js +++ b/dist/system/lookup-widget.js @@ -57,11 +57,11 @@ System.register(['aurelia-framework', 'jquery', 'select2'], function (_export) { var self = _this; $(_this.element).find('input').select2({ initSelection: function initSelection(element, callback) { - callback(self['interface'].setDefaultSelection()); + callback(self.controller.setDefaultSelection()); }, placeholder: _this.placeholder, - formatSelection: self['interface'].formatSelection, - formatResult: self['interface'].formatItem, + formatSelection: self.controller.formatSelection, + formatResult: self.controller.formatItem, query: (function (_query) { function query(_x) { return _query.apply(this, arguments); @@ -73,26 +73,33 @@ System.register(['aurelia-framework', 'jquery', 'select2'], function (_export) { return query; })(function (query) { - self['interface'].search(query.term).then(function (result) { + self.controller.search(query.term).then(function (result) { query.callback({ results: result }); }); }), width: '100%' }); - $(_this.element).find('input').select2('val', _this.value); + $(_this.element).find('input').select2('val', _this.selectedItem); $(_this.element).find('input').on('change', function () { - _this.value = $(_this.element).find('input').select2('val'); + _this.selectedItem = $(_this.element).find('input').select2('val'); }); }, 100); } }], null, _instanceInitializers); LookupWidget = bindable({ - name: 'value', - attribute: 'value', + name: 'selectedItem', + attribute: 'selected-item', defaultBindingMode: TWO_WAY })(LookupWidget) || LookupWidget; + LookupWidget = bindable({ + name: 'controller', + attribute: 'controller', + defaultBindingMode: TWO_WAY + })(LookupWidget) || LookupWidget; + LookupWidget = customElement('lookup-widget')(LookupWidget) || LookupWidget; + LookupWidget = inject(Element)(LookupWidget) || LookupWidget; return LookupWidget; })(); diff --git a/package.json b/package.json index 78c465d..2be2e87 100755 --- a/package.json +++ b/package.json @@ -20,13 +20,14 @@ "author": "Drive Software", "license": "MIT", "devDependencies": { - "aurelia-tools": "^0.1.0", + "aurelia-tools": "^0.1.3", "conventional-changelog": "0.0.11", "del": "^1.1.0", "gulp": "^3.8.10", "gulp-babel": "^5.1.0", "gulp-bump": "^0.1.11", "gulp-jshint": "^1.9.0", + "gulp-plumber": "^1.0.0", "gulp-yuidoc": "^0.1.2", "jasmine-core": "^2.1.3", "jshint-stylish": "^1.0.0", diff --git a/src/lookup-widget.js b/src/lookup-widget.js index 9945ea6..8dff9b1 100644 --- a/src/lookup-widget.js +++ b/src/lookup-widget.js @@ -5,13 +5,13 @@ import select2 from 'select2'; @inject(Element) @customElement('lookup-widget') @bindable({ - name:'interface', - attribute:'interface', + name:'controller', + attribute:'controller', defaultBindingMode: TWO_WAY }) @bindable({ - name:'value', - attribute:'value', + name:'selectedItem', + attribute:'selected-item', defaultBindingMode: TWO_WAY }) export class LookupWidget { @@ -32,22 +32,22 @@ export class LookupWidget { var self = this; $(this.element).find('input').select2({ initSelection: function(element, callback) { - callback(self.interface.setDefaultSelection()); + callback(self.controller.setDefaultSelection()); }, placeholder: this.placeholder, - formatSelection: self.interface.formatSelection, - formatResult: self.interface.formatItem, + formatSelection: self.controller.formatSelection, + formatResult: self.controller.formatItem, query: function(query) { - self.interface.search(query.term).then((result) => { + self.controller.search(query.term).then((result) => { query.callback({ results: result }); }); }, width:'100%' }); - $(this.element).find('input').select2('val', this.value); + $(this.element).find('input').select2('val', this.selectedItem); $(this.element).find('input').on('change', () => { - this.value = $(this.element).find('input').select2('val'); + this.selectedItem = $(this.element).find('input').select2('val'); }); }, 100); }