Skip to content

Commit

Permalink
babel building bindable properties correctly. changed interface and v…
Browse files Browse the repository at this point in the history
…alue properties to controller and selectedItem
  • Loading branch information
simonfox committed Apr 13, 2015
1 parent 6f5ec27 commit 49879cf
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 45 deletions.
23 changes: 15 additions & 8 deletions dist/amd/lookup-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
})();

Expand Down
23 changes: 15 additions & 8 deletions dist/commonjs/lookup-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
})();

Expand Down
20 changes: 10 additions & 10 deletions dist/es6/lookup-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
23 changes: 15 additions & 8 deletions dist/system/lookup-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
})();

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions src/lookup-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit 49879cf

Please sign in to comment.