Last active
February 2, 2017 06:35
-
-
Save graham-sportsmgmt/7fdc2dd45d2732c44571222534854e60 to your computer and use it in GitHub Desktop.
Ember Kendo Components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoCalendar', | |
widgetElement: 'div', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoColorPalette', | |
widgetElement: 'div', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoColorPicker', | |
widgetElement: 'input type="color"', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoComboBox', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['k-content'], | |
style: null, | |
options: null, | |
widgetType: null, | |
widgetId: null, | |
init: function () { | |
this._super(...arguments); | |
this.set( 'widgetId', this.get('elementId') + '-' + this.get('widgetType') ); | |
}, | |
didInsertElement: function () { | |
this._super(...arguments); | |
// add widget to dom | |
// note - telerik recommends a fresh element on redraw | |
let element = '<' + this.get('widgetElement'); | |
element += ' id="' + this.get('widgetId') + '">'; | |
element += '</' + this.get('widgetElement') + '>'; | |
$('#' + this.get('elementId')).append( element ); | |
// initialize widget | |
//this is done by calling a function equal to the widget's type | |
// e.g. jQuery('#ember422-kendoDatePicker).kendoDatePicker(options); | |
$('#' + this.get('widgetId'))[this.get('widgetType')](this.get('options')); | |
// bind events | |
this.get('widgetEvents').forEach( ({ name, action, payload, debounce }) =>{ | |
if(debounce === undefined) { | |
$('#' + this.get('widgetId')).data(this.get('widgetType')).bind( name, (element) => { | |
Ember.run( () => { | |
this.get(action)(element.sender[payload]()); | |
}); | |
}); | |
} else { | |
$('#' + this.get('widgetId')).data(this.get('widgetType')).bind( name, (element) => { | |
Ember.run.debounce( () => { | |
console.log('debounce fired'); | |
this.get(action)(element.sender[payload]()); | |
}); | |
}, debounce); | |
} | |
}); | |
}, | |
// clean up to prevent memory leaks | |
willDestroyElement: function () { | |
this._super(...arguments); | |
// call kendo destroy method to clean up bindings, etc. | |
$('#' + this.get('widgetId'))['destroy']; | |
// remove dom element (as recommended by telerik) | |
$('#' + this.get('elementId')).children().remove(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoDatePicker', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoDateTimePicker', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoDropDownList', | |
widgetElement: 'select', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoEditor', | |
widgetElement: 'textarea', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoMaskedTextBox', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoMediaPlayer', | |
widgetElement: 'div', | |
widgetEvents: [ | |
{ | |
"name": "end", | |
"action": "onEnd", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoNumericTextBox', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "spin", | |
"action": "onChange", | |
"payload": "value", | |
"debounce": "1000" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import KendoComponent from './Kendo-Component' | |
export default KendoComponent.extend({ | |
widgetType: 'kendoTimePicker', | |
widgetElement: 'input', | |
widgetEvents: [ | |
{ | |
"name": "change", | |
"action": "onChange", | |
"payload": "value" | |
} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
options: { | |
dataSource: { | |
data: ["One", "Two", "Three"] | |
}, | |
index: 0 | |
}, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
options: { mask: '(000) 000-0000' }, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myValue: null, | |
options: { autoPlay: true, | |
media: { title: "David Bowie - Ashes To Ashes", | |
source: "https://www.youtube.com/watch?v=CMThz7eQ6K0" } | |
}, | |
actions: { | |
updateValue: function(value) { | |
this.set('myValue', value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('demos', function() { | |
this.route('editors', function() { | |
this.route('colorpicker'); | |
this.route('colorpalette'); | |
this.route('combobox'); | |
this.route('numerictextbox'); | |
this.route('maskedtextbox'); | |
this.route('editor'); | |
}); | |
this.route('datetime', function() { | |
this.route('datepicker'); | |
this.route('datetimepicker'); | |
this.route('timepicker'); | |
this.route('calendar'); | |
}); | |
this.route('other', function() { | |
this.route('mediaplayer'); | |
this.route('treeview'); | |
}); | |
}); | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js", | |
"ember": "2.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2", | |
"kendo": "https://kendo.cdn.telerik.com/2017.1.118/js/kendo.all.min.js", | |
"kendo-css": "https://kendo.cdn.telerik.com/2017.1.118/styles/kendo.common.min.css", | |
"kendo-theme": "https://kendo.cdn.telerik.com/2017.1.118/styles/kendo.default.min.css", | |
"bootstrap": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", | |
"bootstrap-js": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment