Adds the CowhideSelect widget.
[profile/ivi/cowhide.git] / src / javascripts / cowhide-select.js
1 (function($, undefined) {
2     'use strict';
3
4     var ChSelect = function(element, options) {
5         $.fn.ch_widget.Constructor(element, options);
6         this.$element = $(element);
7         this.options = $.extend(
8             {},
9             $.fn.ch_widget.defaults,
10             {
11                 disableWhenDriving: true
12             });
13     };
14
15     ChSelect.prototype = $.extend(
16         {},
17         $.fn.ch_widget.Constructor.prototype,
18         {
19             constructor: ChSelect
20         }
21     );
22
23     $.fn.ch_select = function(option) {
24         return this.each(function() {
25             var $this = $(this),
26                 data = $this.data('ch_select'),
27                 options = typeof option == 'object' && option;
28
29             if (!data) {
30                 $this.data('ch_select', (data = new ChSelect(this, options)));
31                 data.register();
32             }
33         });
34     };
35
36     $.fn.ch_select.Constructor = ChSelect;
37
38     /* CHBUTTON DATA-API
39      * ================= */
40     $(function() {
41         $('select').ch_select();
42     })
43 })(window.jQuery);