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) {
11 var ChPage = function(element, options) {
12 $.fn.ch_widget.Constructor(element, options);
13 this.$element = $(element);
14 this.options = $.extend(
16 $.fn.ch_widget.defaults,
21 var $parent_page = this.$element.parent().closest('div.page');
22 if ($parent_page.length !== 0) {
23 $.cowhide.fatal('#31: pages cannot be nested.');
27 ChPage.prototype = $.extend(
29 $.fn.ch_widget.Constructor.prototype,
34 registerWidget: function(widget) {
35 this.registeredWidgets++;
36 if (this.options.maxWidgets > 0 &&
37 this.registeredWidgets > this.options.maxWidgets)
39 $.cowhide.fatal("#32: a page cannot have more than " +
40 this.options.maxWidgets +
45 setMaxWidgets: function(value) {
46 this.options.maxWidgets = value;
52 /* CHPAGE PLUGIN DEFINITION
53 * ======================== */
55 $.fn.ch_page = function(option, value) {
56 return this.each(function() {
58 data = $this.data('ch_page'),
59 options = typeof option == 'object' && option;
62 $this.data('ch_page', (data = new ChPage(this, options)));
66 if(option == 'register') {
67 data.registerWidget(value);
70 if(option == 'setMaxWidgets') {
71 data.setMaxWidgets(value);
76 $.fn.ch_page.Constructor = ChPage;
80 * ================= */
83 $('div.page').ch_page();