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 ChButton = function(element, options) {
14 $.fn.ch_widget.Constructor(element, options);
15 this.$element = $(element);
16 this.options = $.extend(
18 $.fn.ch_widget.defaults,
22 disableWhenDriving: true
25 if (this.options.fixedWidth) {
26 this.$element.css({width: this.options.fixedWidth});
29 if (this.options.marquee) {
34 ChButton.prototype = $.extend(
36 $.fn.ch_widget.Constructor.prototype,
38 constructor: ChButton,
40 disableMarquee: function() {
41 var $marquee = this.$element.find('marquee');
42 if($marquee.length > 0) {
43 var text = $marquee.text();
45 this.$element.text(text);
49 enableMarquee: function() {
50 if (this.options.marquee && (
51 this.$element[0].tagName == 'A' ||
52 this.$element[0].tagName == 'BUTTON'))
54 var text = this.$element.text()
56 var $marquee = $('<marquee/>');
57 $marquee.attr('behavior', 'alternate')
58 $marquee.attr('scrollamount', 1)
59 $marquee.attr('width', this.$element.width());
62 this.$element.html($marquee);
66 onDrivingModeEnter: function() {
67 this.disableMarquee();
70 onDrivingModeExit: function() {
76 $.fn.ch_button = function(option) {
77 return this.each(function() {
79 data = $this.data('ch_button'),
80 options = typeof option == 'object' && option;
82 if ($this.data('marquee')) {
83 options = $.extend(options, {marquee: true});
85 if ($this.data('fixed-width')) {
86 options = $.extend(options, {fixedWidth: $this.data('fixed-width')})
89 $this.data('ch_button', (data = new ChButton(this, options)));
97 $.fn.ch_button.Constructor = ChButton;
100 * ================= */
102 $('.btn, button, input[type=button]').ch_button();