Aurelia: Kendo TemplatesGrouping Exports https://gist.run/?id=53582770b5d72003fe3969c740b8fb6e
4 stars based on
Create stateful jQuery plugins using the same abstraction as all jQuery UI widgets. Widget object as a base to inherit from, or you can explicitly inherit from existing jQuery UI or third-party widgets. Defining a widget with the same name as you inherit from even allows you to extend widgets in place. All of jQuery UI's widgets use the same patterns, which is defined by the widget factory. So if you learn how to use one widget, then you'll know how to use all of them. Looking for tutorials about the widget factory?
Check out the articles on the jQuery Learning Center. This documentation shows examples using the progressbar widget but the syntax is the same for every widget. In order to track the state of the widget, we must introduce a full life cycle for the widget. The life cycle starts when the widget is initialized. To initialize a widget, we simply call the plugin on one or more elements. This will initialize each element in the jQuery object, in this case the element with an id of "elem".
Because progressbar was called with no parameters, the widget was initialized with its default options. We can pass a set of options during initialization to override the defaults:. We can pass as many or as few options as we want during initialization. Any options that we don't pass will just use their default values. You can kendo grid setoptions undefined multiple options arguments.
This is useful for sharing options between instances, while overriding some properties for each one:. All options passed on init are deep-copied to ensure the objects can be modified later without affecting the widget.
Arrays are the only exception, they are referenced as-is. This exception is in place to support data-binding, where the data source has to be kept as a kendo grid setoptions undefined. The default values are stored on the widget's prototype, therefore we have the ability to override the values that jQuery UI sets.
For example, after setting the following, kendo grid setoptions undefined future progressbar instances will default to a value of The options are part of the widget's state, so we can set options after initialization as well. We'll see this later with the option method. Now that the widget is initialized, we can query kendo grid setoptions undefined state or perform actions on the widget.
All actions kendo grid setoptions undefined initialization take the form of a method call. To call a method on a widget, we pass the name of the method to the jQuery plugin. For example, to call the value method on our progressbar widget, we would use:. If the method accepts parameters, we can pass them after the method name. For example, to pass the parameter 40 to the value method, we can use:. Each widget will have its own set of methods based on the functionality that the widget provides. However, there are a few methods that exist on all widgets, which are documented below.
All widgets have events associated with their various behaviors to notify you when the state is changing. For most widgets, when the events are triggered, the names are prefixed with the widget name and lowercased. For example, we can bind kendo grid setoptions undefined progressbar's change event which is triggered whenever the value changes. Each event has a corresponding callback, which is exposed as an option. We can hook into progressbar's change callback instead of binding to the progressbarchange event, if we want to.
The widget's instance can be retrieved from a given element using the instance method. If the instance method is called on an element that is not associated with the widget, undefined is returned. The instance is stored using jQuery.
You can also use: Additional thematic classes to add to the widget, in addition to the structural classes. The structural classes are used as keys of kendo grid setoptions undefined option and the thematic classes are the values.
Kendo grid setoptions undefined out the documentation of individual widgets to see which classes they support. The primary motivation of this option is to map structural classes to theme classes. In other words, any class prefixed with namespace and widget, like "ui-progressbar-"is considered a structural class.
These are always added to the widget. In contrast to that, any class not specific to the widget is considered a theme class. Setting the classes option after creation will kendo grid setoptions undefined all default properties. To only change specific values, use deep setters, e. Initialize a progressbar widget with the classes option specified, changing the theming for the ui-progressbar class:.
This provides a hook for the user to add additional classes or replace default styling classes, through the classes option. When you only need the extra argument, you can skip this argument by specifying null. Add the ui-progressbar class to the widget's element this. Will also add any additional classes specified through the classes option for the given class.
Add the demo-popup-header class to the specified element here referencing this. In addition, it will always add the ui-front class. Adds the ui-helper-hidden-accessible class to the specified element. Kendo grid setoptions undefined null for the keys argument to skip it. Initialization should only be handled if there is a logical action to perform on successive calls to the widget with no arguments.
Remove the ui-progressbar class from the widget's element this. Will also remove any additional classes specified through the classes option for the given class. Remove the demo-popup-header class from the specified element here referencing this. In addition, it will also remove the ui-front class. Remove the ui-helper-hidden-accessible class from the specified element. Update a widget's element when its height or width option changes. Overriding this is useful if you can defer processor-intensive changes for multiple option changes.
Call a resize method if the height or width options change. Indicates whether to add or kendo grid setoptions undefined the specified classes, where a boolean true indicates that classes should be added, a boolean false indicates kendo grid setoptions undefined classes should be removed.
Toggle the ui-state-disabled class on the widget's element this. When providing data, you must provide all three parameters. If there is no event kendo grid setoptions undefined pass along, just pass null. If the default action is prevented, false will be returned, otherwise true. Preventing the default action happens when the handler returns false or calls event. Retrieves the widget's instance object. If the element does not have an associated instance, undefined is returned.
Unlike other widget methods, instance is safe to call on any element after the widget plugin has loaded. For options that have objects as their value, you can get the value of a specific key by using dot notation. For options that have objects as their value, you can set the value of just one property by using dot notation for optionName. The ui object is empty but included for consistency with other events. The base widget to inherit from. Initialization In order to track the state of the widget, we must introduce a full life cycle for the widget.
The base widget used by the widget factory. Initialize a progressbar widget with the classes option specified, changing the theming for the ui-progressbar class: Get or set the classes option, after initialization: Boolean or Number or String or Object. The classes to add, as a space-delimited list. If a property of the classes option matches a key, the value will be added as well. Additional classes to add, required for layout or other reasons. Unlike the keys argument, these aren't associated with any properties of the classes option.
Just like keysthey will also be automatically removed when destroying the widget. There are no parameters, but this. Set the background color of the widget's element based on an option. Number Invokes the provided function after a specified delay. Keeps this context correct. Returns the timeout ID for use with clearTimeout. Remove a class from the widget's element when kendo grid setoptions undefined widget is destroyed.
The event handlers are automatically cleaned up on destroy.