9 * @class Roo.bootstrap.Button
10 * @extends Roo.bootstrap.Component
11 * Bootstrap Button class
12 * @cfg {String} html The button content
13 * @cfg {String} weight default (or empty) | primary | success | info | warning | danger | link
14 * @cfg {String} size empty | lg | sm | xs
15 * @cfg {String} tag empty | a | input | submit
16 * @cfg {String} href empty or href
17 * @cfg {Boolean} disabled false | true
18 * @cfg {Boolean} isClose false | true
19 * @cfg {String} glyphicon empty | adjust | align-center | align-justify | align-left | align-right | arrow-down | arrow-left | arrow-right | arrow-up | asterisk | backward | ban-circle | barcode | bell | bold | book | bookmark | briefcase | bullhorn | calendar | camera | certificate | check | chevron-down | chevron-left | chevron-right | chevron-up | circle-arrow-down | circle-arrow-left | circle-arrow-right | circle-arrow-up | cloud | cloud-download | cloud-upload | cog | collapse-down | collapse-up | comment | compressed | copyright-mark | credit-card | cutlery | dashboard | download | download-alt | earphone | edit | eject | envelope | euro | exclamation-sign | expand | export | eye-close | eye-open | facetime-video | fast-backward | fast-forward | file | film | filter | fire | flag | flash | floppy-disk | floppy-open | floppy-remove | floppy-save | floppy-saved | folder-close | folder-open | font | forward | fullscreen | gbp | gift | glass | globe | hand-down | hand-left | hand-right | hand-up | hd-video | hdd | header | headphones | heart | heart-empty | home | import | inbox | indent-left | indent-right | info-sign | italic | leaf | link | list | list-alt | lock | log-in | log-out | magnet | map-marker | minus | minus-sign | move | music | new-window | off | ok | ok-circle | ok-sign | open | paperclip | pause | pencil | phone | phone-alt | picture | plane | play | play-circle | plus | plus-sign | print | pushpin | qrcode | question-sign | random | record | refresh | registration-mark | remove | remove-circle | remove-sign | repeat | resize-full | resize-horizontal | resize-small | resize-vertical | retweet | road | save | saved | screenshot | sd-video | search | send | share | share-alt | shopping-cart | signal | sort | sort-by-alphabet | sort-by-alphabet-alt | sort-by-attributes | sort-by-attributes-alt | sort-by-order | sort-by-order-alt | sound-5-1 | sound-6-1 | sound-7-1 | sound-dolby | sound-stereo | star | star-empty | stats | step-backward | step-forward | stop | subtitles | tag | tags | tasks | text-height | text-width | th | th-large | th-list | thumbs-down | thumbs-up | time | tint | tower | transfer | trash | tree-conifer | tree-deciduous | unchecked | upload | usd | user | volume-down | volume-off | volume-up | warning-sign | wrench | zoom-in | zoom-out
20 * @cfg {String} badge text for badge
21 * @cfg {String} theme default (or empty) | glow
22 * @cfg {Boolean} inverse false | true
23 * @cfg {Boolean} toggle false | true
24 * @cfg {String} ontext text for on toggle state
25 * @cfg {String} offtext text for off toggle state
26 * @cfg {Boolean} defaulton true | false
27 * @cfg {Boolean} preventDefault (true | false) default true
28 * @cfg {Boolean} removeClass true | false remove the standard class..
29 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
33 * @param {Object} config The config object
37 Roo.bootstrap.Button = function(config){
38 Roo.bootstrap.Button.superclass.constructor.call(this, config);
43 * The raw click event for the entire grid.
44 * @param {Roo.EventObject} e
50 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
73 getAutoCreate : function(){
81 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
82 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
87 cfg.html = this.html || cfg.html;
89 if (this.toggle===true) {
92 cls: 'slider-frame roo-button',
97 'data-off-text':'OFF',
104 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
105 cfg.cls += ' '+this.weight;
114 cfg["aria-hidden"] = true;
116 cfg.html = "×";
122 if (this.theme==='default') {
123 cfg.cls = 'btn roo-button';
125 if (this.parentType != 'Navbar') {
126 this.weight = this.weight.length ? this.weight : 'default';
128 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
130 cfg.cls += ' btn-' + this.weight;
132 } else if (this.theme==='glow') {
135 cfg.cls = 'btn-glow roo-button';
137 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
139 cfg.cls += ' ' + this.weight;
145 this.cls += ' inverse';
150 cfg.cls += ' active';
153 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
155 //gsRoo.log(this.parentType);
156 if (this.parentType === 'Navbar') {
164 href : this.href || '#'
167 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
168 cfg.cls += ' dropdown';
174 else if (this.menu) {
175 cfg.cls += ' dropdown';
176 cfg.html = this.html + ' <span class="caret"></span>';
179 if (cfg.tag !== 'a' && this.href !== '') {
180 throw "Tag must be a to set href.";
181 } else if (this.href.length > 0) {
182 cfg.href = this.href;
185 if(this.removeClass){
190 cfg.target = this.target;
195 initEvents: function() {
196 // Roo.log('init events?');
197 // Roo.log(this.el.dom);
198 if (this.el.hasClass('roo-button')) {
199 this.el.on('click', this.onClick, this);
201 this.el.select('.roo-button').on('click', this.onClick, this);
207 onClick : function(e)
209 Roo.log('button on click ');
210 if(this.preventDefault){
214 this.fireEvent('click', this, e);