2 * Copyright (c) 2012, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 (function($, undefined) {
13 var ChPage = function(element, options) {
14 $.fn.ch_widget.Constructor(element, options);
15 this.$element = $(element);
16 this.options = $.extend(
18 $.fn.ch_widget.defaults,
23 var $parent_page = this.$element.parent().closest('div.page');
24 if ($parent_page.length !== 0) {
25 $.cowhide.fatal('#31: pages cannot be nested.');
29 ChPage.prototype = $.extend(
31 $.fn.ch_widget.Constructor.prototype,
36 registerWidget: function(widget) {
37 this.registeredWidgets++;
38 if (this.options.maxWidgets > 0 &&
39 this.registeredWidgets > this.options.maxWidgets)
41 $.cowhide.fatal("#32: a page cannot have more than " +
42 this.options.maxWidgets +
47 setMaxWidgets: function(value) {
48 this.options.maxWidgets = value;
53 $.fn.ch_page = function(option, value) {
54 return this.each(function() {
56 data = $this.data('ch_page'),
57 options = typeof option == 'object' && option;
60 $this.data('ch_page', (data = new ChPage(this, options)));
64 if(option == 'register') {
65 data.registerWidget(value);
68 if(option == 'setMaxWidgets') {
69 data.setMaxWidgets(value);
74 $.fn.ch_page.Constructor = ChPage;
77 * ================= */
79 $('div.page').ch_page();