While trying to generalize our practices from KendoUI related projects we've participated so far, we updated control.js - a small javascript additions to KendoUI.
At present we have defined:
1. An extended model. See KendoUI extended model.
2. A lightweight user control - a widget to bind a template and a model, and to facilitate declarative instantiation. See KendoUI User control.
3. A reworked version of nesterovskyBros.defineControl() function.
var widgetType = scope.defineControl( { name: widget-name-string, model: widget-model-type, template: optional-content-template, windowOptions: optional-window-options }, base);
When optional-content-template is not specified then template is calculated as following:
optional-content-template
var template = options.temlate || proto.template || model.temlate; if (template === undefined) { template = scope.template(options.name.toLowerCase() + "-template"); }
When windowOptions is specified then widgetType.dialog(options) function is defined. It's used to open dialog based on the specified user control. windowOptions is passed to kendo.ui.Window constructor. windowOptions.closeOnEscape indicates whether to close opened dialog on escape.
windowOptions
widgetType.dialog(options)
kendo.ui.Window
windowOptions.closeOnEscape
widgetType.dialog() returns a kendo.ui.Window instance with content based on the user control. Window instance contains functions:
widgetType.dialog()
result()
$.Deffered
model()
The model instance has functions:
dialog()
widget.dialog() allows all css units in windowOptions.width and windowOptions.height parameters.
widget.dialog()
windowOptions.width
windowOptions.height
base - is optional user control base. It defaults to nesterovskyBros.ui.UserControl.
base
nesterovskyBros.ui.UserControl
4. Adjusted splitter. See Adjust KendoUI Splitter.
5. Auto resize support.
Layout is often depends on available area. One example is Splitter widget that recalculates its panes when window or container Splitter is resized. There are other cases when you would like to adjust layout when a container's area is changed like: adjust grid, tab, editor or user's control contents.
Splitter
KendoUI does not provide a solution for this problem, so we have defined our own.
class="auto-resize"
widgetType.autoResize(element)
nesterovskyBros.resize(element)
To support existing controls we have defined autoResize() function for Grid, Splitter, TabStrip, and Editor widgets.
autoResize()
Grid
TabStrip
Editor
To see how auto resizing works, it's best to look into index.html, products.tmpl.html, and into the implementation controls.js.
Please note that we consider controls.js as an addition to KendoUI library. If in the future the library will integrate or implement similar features we will be happy to start using their API.
See also: Compile KendoUI templates.
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u