Skip to content

Commit

Permalink
convert autocomplete custom attribute to custom element
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfox committed Jul 16, 2015
1 parent 3eaae63 commit 4039954
Show file tree
Hide file tree
Showing 27 changed files with 212 additions and 307 deletions.
30 changes: 0 additions & 30 deletions dist/amd/autocomplete-abstract.js

This file was deleted.

10 changes: 10 additions & 0 deletions dist/amd/autocomplete-widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<div class="form-group">
<label class="control-label">${title}</label>
<input class="form-control" type="text"/>
</div>
</template>




34 changes: 17 additions & 17 deletions dist/amd/autocomplete-widget.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
define(['exports', 'aurelia-framework', 'jquery', 'devbridge/jQuery-Autocomplete'], function (exports, _aureliaFramework, _jquery, _devbridgeJQueryAutocomplete) {
'use strict';

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, '__esModule', {
value: true
});

var _$ = _interopRequire(_jquery);
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _autocomplete = _interopRequire(_devbridgeJQueryAutocomplete);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _$ = _interopRequireDefault(_jquery);

var _autocomplete = _interopRequireDefault(_devbridgeJQueryAutocomplete);

var AutoCompleteWidget = (function () {
function AutoCompleteWidget(element) {
Expand All @@ -22,22 +22,20 @@ define(['exports', 'aurelia-framework', 'jquery', 'devbridge/jQuery-Autocomplete
this.element = element;
}

var _AutoCompleteWidget = AutoCompleteWidget;

_createClass(_AutoCompleteWidget, [{
_createClass(AutoCompleteWidget, [{
key: 'bind',
value: function bind() {
this.apply();
}
}, {
key: 'unbind',
value: function unbind() {
_$(this.element).autocomplete('dispose');
(0, _$['default'])(this.element).autocomplete('dispose');
}
}, {
key: 'apply',
value: function apply() {
_$(this.element).autocomplete({
(0, _$['default'])(this.element).autocomplete({
lookup: this.lookup.bind(this),
onSelect: this.onSelect.bind(this)
});
Expand All @@ -56,18 +54,20 @@ define(['exports', 'aurelia-framework', 'jquery', 'devbridge/jQuery-Autocomplete
}
}]);

AutoCompleteWidget = _aureliaFramework.bindable({
var _AutoCompleteWidget = AutoCompleteWidget;
AutoCompleteWidget = (0, _aureliaFramework.bindable)('title')(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = (0, _aureliaFramework.bindable)({
name: 'selectedItem',
attribute: 'selected-item',
defaultBindingMode: _aureliaFramework.bindingMode.twoWay
})(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = _aureliaFramework.bindable({
AutoCompleteWidget = (0, _aureliaFramework.bindable)({
name: 'controller',
attribute: 'controller',
defaultBindingMode: _aureliaFramework.bindingMode.twoWay
})(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = _aureliaFramework.customAttribute('autocomplete-widget')(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = _aureliaFramework.inject(Element)(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = (0, _aureliaFramework.customElement)('autocomplete-widget')(AutoCompleteWidget) || AutoCompleteWidget;
AutoCompleteWidget = (0, _aureliaFramework.inject)(Element)(AutoCompleteWidget) || AutoCompleteWidget;
return AutoCompleteWidget;
})();

Expand Down
8 changes: 4 additions & 4 deletions dist/amd/lookup-abstract.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
define(['exports'], function (exports) {
'use strict';

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, '__esModule', {
value: true
});

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var LookupAbstract = (function () {
function LookupAbstract() {
_classCallCheck(this, LookupAbstract);
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/lookup-widget.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>

<label for="lookupField" class="control-label" show.bind="isShowing">${title}</label>
<label for="lookupField" class="control-label">${title}</label>
<input type="text" id="lookupField">

</template>
71 changes: 30 additions & 41 deletions dist/amd/lookup-widget.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
define(['exports', 'aurelia-framework', 'jquery', 'select2'], function (exports, _aureliaFramework, _jquery, _select2) {
'use strict';

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, '__esModule', {
value: true
});

var _$ = _interopRequire(_jquery);
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _select22 = _interopRequire(_select2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _$ = _interopRequireDefault(_jquery);

var _select22 = _interopRequireDefault(_select2);

var LookupWidget = (function () {
function LookupWidget(element) {
Expand All @@ -22,76 +22,65 @@ define(['exports', 'aurelia-framework', 'jquery', 'select2'], function (exports,
this.element = element;
}

var _LookupWidget = LookupWidget;

_createClass(_LookupWidget, [{
_createClass(LookupWidget, [{
key: 'bind',
value: function bind() {
this.apply();
}
}, {
key: 'unbind',
value: function unbind() {
_$(this.element).find('input').select2('destroy');
}
}, {
key: 'isShowing',
get: function () {
return this.title.length > 0;
(0, _$['default'])(this.element).find('input').select2('destroy');
}
}, {
key: 'apply',
value: function apply() {
var _this = this;

var self = this;
_$(this.element).find('input').select2({
(0, _$['default'])(this.element).find('input').select2({
initSelection: function initSelection(element, callback) {
callback(self.controller.setDefaultSelection());
},
id: self.controller.id,
placeholder: this.placeholder,
formatSelection: self.controller.formatSelection,
formatResult: self.controller.formatItem,
query: (function (_query) {
function query(_x) {
return _query.apply(this, arguments);
}

query.toString = function () {
return _query.toString();
};

return query;
})(function (query) {
self.controller.search(query.term).then(function (result) {
query.callback({ results: result });
query: function query(_query) {
self.controller.search(_query.term).then(function (result) {
_query.callback({ results: result });
});
}),
},
width: '100%'
});

_$(this.element).find('input').select2('val', this.selectedItem);
_$(this.element).find('input').on('change', function () {
_this.selectedItem = _$(_this.element).find('input').select2('val');
(0, _$['default'])(this.element).find('input').select2('val', this.selectedItem);
(0, _$['default'])(this.element).find('input').on('change', function () {
_this.selectedItem = (0, _$['default'])(_this.element).find('input').select2('val');
});
}
}, {
key: 'isShowing',
get: function get() {
return this.title.length > 0;
}
}]);

LookupWidget = _aureliaFramework.bindable('placeholder')(LookupWidget) || LookupWidget;
LookupWidget = _aureliaFramework.bindable('title')(LookupWidget) || LookupWidget;
LookupWidget = _aureliaFramework.bindable({
var _LookupWidget = LookupWidget;
LookupWidget = (0, _aureliaFramework.bindable)('placeholder')(LookupWidget) || LookupWidget;
LookupWidget = (0, _aureliaFramework.bindable)('title')(LookupWidget) || LookupWidget;
LookupWidget = (0, _aureliaFramework.bindable)({
name: 'selectedItem',
attribute: 'selected-item',
defaultBindingMode: _aureliaFramework.bindingMode.twoWay
})(LookupWidget) || LookupWidget;
LookupWidget = _aureliaFramework.bindable({
LookupWidget = (0, _aureliaFramework.bindable)({
name: 'controller',
attribute: 'controller',
defaultBindingMode: _aureliaFramework.bindingMode.twoWay
})(LookupWidget) || LookupWidget;
LookupWidget = _aureliaFramework.customElement('lookup-widget')(LookupWidget) || LookupWidget;
LookupWidget = _aureliaFramework.inject(Element)(LookupWidget) || LookupWidget;
LookupWidget = (0, _aureliaFramework.customElement)('lookup-widget')(LookupWidget) || LookupWidget;
LookupWidget = (0, _aureliaFramework.inject)(Element)(LookupWidget) || LookupWidget;
return LookupWidget;
})();

Expand Down
28 changes: 0 additions & 28 deletions dist/commonjs/autocomplete-abstract.js

This file was deleted.

10 changes: 10 additions & 0 deletions dist/commonjs/autocomplete-widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<div class="form-group">
<label class="control-label">${title}</label>
<input class="form-control" type="text"/>
</div>
</template>




Loading

0 comments on commit 4039954

Please sign in to comment.