Last active
August 25, 2016 15:09
-
-
Save len-ro/5082e487f6d86d7c4864e1f1abcdbc24 to your computer and use it in GitHub Desktop.
Menu: basic usage
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
| <template> | |
| <ul ak-menu k-on-select.delegate="onSelect($event.detail)"> | |
| <li> | |
| Modules | |
| <ul> | |
| <li><span class="d-menuitem" data-id="m1">First module</span></li> | |
| <li><span class="d-menuitem" data-id="m2">Second module</span></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| <div id="tabstrip" ref="tabStripElement" ak-tabstrip="k-animation.bind: { open: { effects: 'fadeIn' } }; k-widget.two-way: tabStrip"> | |
| <ul> | |
| <li class="k-state-active" t="title"> | |
| Initial | |
| </li> | |
| </ul> | |
| <div> | |
| <div> | |
| <p t="content"> | |
| Initial content here | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </template> |
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 {inject, TaskQueue} from 'aurelia-framework'; | |
| import {Container} from 'aurelia-dependency-injection'; | |
| import {CompositionEngine, ViewSlot, ViewResources, View } from 'aurelia-templating'; | |
| @inject(Container, CompositionEngine, ViewResources, Element, TaskQueue) | |
| export class BasicUse { | |
| constructor(container:Container, compositionEngine:CompositionEngine, viewResources:ViewResources, element:Element, taskQueue:TaskQueue){ | |
| this.compositionEngine = compositionEngine; | |
| this.instruction = { | |
| container: container, | |
| viewResources: viewResources, | |
| currentController: null | |
| }; | |
| this.element = element; | |
| this.taskQueue = taskQueue; | |
| } | |
| bind(bindingContext, overrideContext) { | |
| this.instruction = Object.assign(this.instruction, { | |
| bindingContext: bindingContext, | |
| overrideContext: overrideContext | |
| }); | |
| } | |
| created(owningView: View) { | |
| this.instruction = Object.assign(this.instruction, {owningView:owningView}); | |
| } | |
| attached(){ | |
| //this.openMenu("m1", "m1"); | |
| //setTimeout(() => { this.openMenu("m1", "m1");}, 100); | |
| //setTimeout(() => { this.openMenu("m2", "m2");}, 100); | |
| //setTimeout(() => { this.openMenu("m1", "m1");this.openMenu("m2", "m2");}, 100); | |
| this.taskQueue.queueTask(() => this.afterAttach()); | |
| } | |
| afterAttach(){ | |
| this.tabStrip.tabGroup.on("click", "[data-type='remove']", (e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| var item = $(e.target).closest(".k-item"); | |
| this.tabStrip.remove(item.index()); | |
| this.selectLastTab(); | |
| }); | |
| this.openMenu("m1", "m1"); | |
| } | |
| selectLastTab(){ | |
| let lastTab = this.tabStrip.tabGroup.children("li").last(); | |
| this.tabStrip.select(lastTab); | |
| } | |
| openMenu(menuName, menuId){ | |
| console.log('Selected: ' + menuId + ", " + menuName); | |
| this.tabStrip.append({ | |
| text: menuName + '<button data-type="remove" class="k-button k-button-icon"><span class="k-icon k-i-close"></span></button>', | |
| content: '<div id="module' + menuId + '"></div>', | |
| encoded: false | |
| }); | |
| let el = document.getElementById('module' + menuId); | |
| console.log("el: " + el); | |
| let vSlot = new ViewSlot(el, true); | |
| this.instruction = Object.assign(this.instruction, {viewModel: menuId, host: el, viewSlot: vSlot}); | |
| this.compositionEngine.compose(this.instruction).then(controller => { | |
| //console.log("end compose"); | |
| vSlot.bind(); | |
| vSlot.attached(); | |
| this.selectLastTab(); | |
| }); | |
| //.catch(error => {console.log("error: " + error)}); | |
| } | |
| onSelect(e){ | |
| let menuId = $(e.item).children(".k-link").children(".d-menuitem").attr("data-id"); | |
| let menuName = $(e.item).children(".k-link").text(); | |
| this.openMenu(menuName, menuId); | |
| } | |
| } |
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
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>Aurelia KendoUI bridge</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.common.min.css"> | |
| <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.rtl.min.css"> | |
| <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.default.min.css"> | |
| <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.mobile.all.min.css"> | |
| <script src="https://kendo.cdn.telerik.com/2016.1.226/js/jszip.min.js"></script> | |
| </head> | |
| <body aurelia-app="main"> | |
| <h1>Loading...</h1> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
| <script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/0.3.5/config2.js"></script> | |
| <script> | |
| System.import('aurelia-bootstrapper'); | |
| </script> | |
| </body> | |
| </html> |
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
| <template> | |
| <input ak-datepicker="k-widget.bind: datepicker" /> | |
| </template> |
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
| export class M1 { | |
| } |
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
| <template> | |
| <ak-combobox k-value.two-way="size"> | |
| <select style="width: 100%;"> | |
| <option>X-Small</option> | |
| <option>Small</option> | |
| <option>Medium</option> | |
| <option>Large</option> | |
| <option>X-Large</option> | |
| <option>2X-Large</option> | |
| </select> | |
| </ak-combobox> | |
| </template> |
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
| export class M2 { | |
| } |
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
| export function configure(aurelia) { | |
| aurelia.use | |
| .standardConfiguration() | |
| .developmentLogging() | |
| .plugin('aurelia-kendoui-bridge', kendo => kendo.pro()); | |
| aurelia.start().then(a => a.setRoot()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment