4 * base class for bootstrap elements.
8 Roo.bootstrap = Roo.bootstrap || {};
10 * @class Roo.bootstrap.Component
11 * @extends Roo.Component
12 * Bootstrap Component base class
13 * @cfg {String} cls css class
14 * @cfg {String} style any extra css
15 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
19 * Do not use directly - it does not do anything..
20 * @param {Object} config The config object
25 Roo.bootstrap.Component = function(config){
26 Roo.bootstrap.Component.superclass.constructor.call(this, config);
29 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
37 initEvents : function() { },
44 // returns the parent component..
45 return Roo.ComponentMgr.get(this.parentId)
51 onRender : function(ct, position)
53 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
56 if (this.el.attr('xtype')) {
57 this.el.dom.removeAttribute('xtype');
66 var cfg = Roo.apply({}, this.getAutoCreate());
69 // fill in the extra attributes
70 if (this.xattr && typeof(this.xattr) =='object') {
71 for (var i in this.xattr) {
72 cfg[i] = this.xattr[i];
77 cfg.cls += ' ' + this.cls;
79 if (this.style) { // fixme needs to support more complex style data.
80 cfg.style = this.style;
82 this.el = ct.createChild(cfg, position);
83 if(this.tabIndex !== undefined){
84 this.el.dom.setAttribute('tabIndex', this.tabIndex);
91 getChildContainer : function()
96 addxtype : function (tree, cntr) {
98 cntr = typeof(cntr == 'undefined' ) ? 'getChildContainer' : cntr;
100 // render the element if it's not BODY.
101 if (tree.xtype != 'Body') {
103 cn = Roo.factory(tree);
105 cn.parentType = this.xtype; //??
106 cn.parentId = this.id;
108 // does the container contain child eleemnts with 'xtype' attributes.
109 // that match this xtype..
110 // note - when we render we create these as well..
111 // so we should check to see if body has xtype set.
112 if (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
114 var echild = Roo.get(this[cntr]()).child('*[xtype]');
117 //echild.dom.removeAttribute('xtype');
120 cn.render(this[cntr]());
121 // then add the element..
128 if (typeof (tree.menu) != 'undefined') {
129 tree.menu.parentType = cn.xtype;
130 tree.menu.triggerEl = cn.el;
131 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
134 if (typeof (tree.buttons) != 'undefined' && typeof(cn.getButtonContainer) == 'function') {
136 for(var i =0;i < tree.buttons.length;i++) {
137 nitems.push(cn.addxtype(Roo.apply({}, tree.buttons[i]), 'getButtonContainer'));
142 if (!tree.items || !tree.items.length) {
146 var items = tree.items;
149 //Roo.log(items.length);
151 for(var i =0;i < items.length;i++) {
152 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
172 Roo.bootstrap.Body = function(config){
173 Roo.bootstrap.Body.superclass.constructor.call(this, config);
174 this.el = Roo.get(document.body);
177 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
182 onRender : function(ct, position){
185 //this.el.addClass([this.fieldClass, this.cls]);
203 * @class Roo.bootstrap.ButtonGroup
204 * @extends Roo.bootstrap.Component
205 * Bootstrap ButtonGroup class
206 * @cfg {String} size lg | sm | xs (default empty normal)
207 * @cfg {String} align vertical | justified (default none)
208 * @cfg {String} direction up | down (default down)
209 * @cfg {Boolean} toolbar false | true
210 * @cfg {Boolean} btn true | false
215 * @param {Object} config The config object
218 Roo.bootstrap.ButtonGroup = function(config){
219 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
222 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
230 getAutoCreate : function(){
236 cfg.html = this.html || cfg.html;
247 if (['vertical','justified'].indexOf(this.align)!==-1) {
248 cfg.cls = 'btn-group-' + this.align;
250 if (this.align == 'justified') {
251 console.log(this.items);
255 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
256 cfg.cls += ' btn-group-' + this.size;
259 if (this.direction == 'up') {
260 cfg.cls += ' dropup' ;
276 * @class Roo.bootstrap.Button
277 * @extends Roo.bootstrap.Component
278 * Bootstrap Button class
279 * @cfg {String} html The button content
280 * @cfg {String} weight default (or empty) | primary | success | info | warning | danger
281 * @cfg {String} size empty | lg | sm | xs
282 * @cfg {String} tag empty | a | input | submit
283 * @cfg {String} href empty or href
284 * @cfg {Boolean} disabled false | true
285 * @cfg {Boolean} isClose false | true
286 * @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
287 * @cfg {String} badge text for badge
288 * @cfg {String} theme default (or empty) | glow
289 * @cfg {Boolean} inverse false | true
290 * @cfg {Boolean} toggle false | true
291 * @cfg {String} ontext text for on toggle state
292 * @cfg {String} offtext text for off toggle state
293 * @cfg {Boolean} defaulton true | false
296 * Create a new button
297 * @param {Object} config The config object
301 Roo.bootstrap.Button = function(config){
302 Roo.bootstrap.Button.superclass.constructor.call(this, config);
307 * The raw click event for the entire grid.
308 * @param {Roo.EventObject} e
314 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
333 getAutoCreate : function(){
340 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
341 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
346 cfg.html = this.html || cfg.html;
348 if (this.toggle===true) {
356 'data-off-text':'OFF',
357 cls: 'slider-button',
363 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
364 cfg.cls += ' '+this.weight;
373 cfg["aria-hidden"] = true;
375 cfg.html = "×";
381 if (this.theme==='default') {
384 if (this.parentType != 'Navbar') {
385 this.weight = this.weight.length ? this.weight : 'default';
387 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
389 cfg.cls += ' btn-' + this.weight;
391 } else if (this.theme==='glow') {
396 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
398 cfg.cls += ' ' + this.weight;
404 this.cls += ' inverse';
409 cfg.cls += ' active';
412 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
414 //gsRoo.log(this.parentType);
415 if (this.parentType === 'Navbar') {
422 href : this.href || '#'
425 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
426 cfg.cls += ' dropdown';
431 } else if (this.menu) {
433 cfg.cls += ' dropdown test';
439 cfg.disabled = 'disabled';
443 Roo.log('changing to ul' );
445 this.glyphicon = 'caret';
448 if (this.glyphicon) {
449 cfg.html = ' ' + cfg.html;
454 cls: 'glyphicon glyphicon-' + this.glyphicon
480 if (cfg.tag !== 'a' && this.href !== '') {
481 throw "Tag must be a to set href.";
482 } else if (this.href.length > 0) {
483 cfg.href = this.href;
488 initEvents: function() {
489 // Roo.log('init events?');
490 // Roo.log(this.el.dom);
491 this.el.select('a',true).relayEvent('click', this);
492 this.el.select('button',true).relayEvent('click', this);
495 onClick : function(e)
498 this.fireEvent('click', this, e);
512 * @class Roo.bootstrap.Column
513 * @extends Roo.bootstrap.Component
514 * Bootstrap Column class
515 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
516 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
517 * @cfg {Number} md colspan out of 12 for computer-sized screens
518 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
519 * @cfg {String} html content of column.
522 * Create a new Column
523 * @param {Object} config The config object
526 Roo.bootstrap.Column = function(config){
527 Roo.bootstrap.Column.superclass.constructor.call(this, config);
530 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
539 getAutoCreate : function(){
540 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
548 ['xs','sm','md','lg'].map(function(size){
549 if (settings[size]) {
550 cfg.cls += ' col-' + size + '-' + settings[size];
553 if (this.html.length) {
554 cfg.html = this.html;
573 * @class Roo.bootstrap.Container
574 * @extends Roo.bootstrap.Component
575 * Bootstrap Container class
576 * @cfg {Boolean} jumbotron is it a jumbotron element
577 * @cfg {String} html content of element
578 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
579 * @cfg {String} panel (primary|success|info|warning|danger) render as a panel.
580 * @cfg {String} header content of header (for panel)
581 * @cfg {String} footer content of footer (for panel)
582 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
585 * Create a new Container
586 * @param {Object} config The config object
589 Roo.bootstrap.Container = function(config){
590 Roo.bootstrap.Container.superclass.constructor.call(this, config);
593 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
603 getChildContainer : function() {
604 if (this.panel.length) {
605 return this.el.select('.panel-body',true).first();
612 getAutoCreate : function(){
618 if (this.jumbotron) {
619 cfg.cls = 'jumbotron';
622 cfg.cls = this.cls + '';
625 if (this.sticky.length) {
626 var bd = Roo.get(document.body);
627 if (!bd.hasClass('bootstrap-sticky')) {
628 bd.addClass('bootstrap-sticky');
629 Roo.select('html',true).setStyle('height', '100%');
632 cfg.cls += 'bootstrap-sticky-' + this.sticky;
636 if (this.well.length) {
640 cfg.cls +=' well well-' +this.well;
650 if (this.panel.length) {
651 cfg.cls += 'panel panel-' + this.panel;
653 if (this.header.length) {
656 cls : 'panel-heading',
672 if (this.footer.length) {
674 cls : 'panel-footer',
682 body.html = this.html || cfg.html;
684 if (!cfg.cls.length) {
685 cfg.cls = 'container';
702 * @class Roo.bootstrap.Img
703 * @extends Roo.bootstrap.Component
704 * Bootstrap Img class
705 * @cfg {Boolean} imgResponsive false | true
706 * @cfg {String} border rounded | circle | thumbnail
707 * @cfg {String} src image source
708 * @cfg {String} alt image alternative text
712 * @param {Object} config The config object
715 Roo.bootstrap.Img = function(config){
716 Roo.bootstrap.Img.superclass.constructor.call(this, config);
719 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
725 getAutoCreate : function(){
729 cls: 'img-responsive',
733 cfg.html = this.html || cfg.html;
735 cfg.src = this.src || cfg.src;
737 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
738 cfg.cls += ' img-' + this.border;
758 * @class Roo.bootstrap.Header
759 * @extends Roo.bootstrap.Component
760 * Bootstrap Header class
761 * @cfg {String} html content of header
762 * @cfg {Number} level (1|2|3|4|5|6) default 1
765 * Create a new Header
766 * @param {Object} config The config object
770 Roo.bootstrap.Header = function(config){
771 Roo.bootstrap.Header.superclass.constructor.call(this, config);
774 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
782 getAutoCreate : function(){
785 tag: 'h' + (1 *this.level),
786 html: this.html || 'fill in html'
804 * @class Roo.bootstrap.Menu
805 * @extends Roo.bootstrap.Component
806 * Bootstrap Menu class - container for MenuItems
807 * @cfg {String} type type of menu
811 * @param {Object} config The config object
815 Roo.bootstrap.Menu = function(config){
816 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
819 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
827 getChildContainer : function() {
831 getAutoCreate : function(){
833 //if (['right'].indexOf(this.align)!==-1) {
834 // cfg.cn[1].cls += ' pull-right'
838 cls : 'dropdown-menu'
842 if (this.type==='submenu') {
843 cfg.cls='submenu active'
848 initEvents : function() {
849 // Roo.log("ADD event");
850 // Roo.log(this.triggerEl.dom);
851 this.triggerEl.on('click', this.toggle, this);
852 this.triggerEl.addClass('dropdown-toggle');
857 //Roo.log(e.getTarget());
858 // Roo.log(this.triggerEl.dom);
859 if (Roo.get(e.getTarget()).findParent('.dropdown-menu')) {
862 var isActive = this.triggerEl.hasClass('open');
863 // if disabled.. ingore
865 //if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
866 // if mobile we use a backdrop because click events don't delegate
867 // $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
870 //var relatedTarget = { relatedTarget: this }
871 //$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
873 //if (e.isDefaultPrevented()) return;
875 this.triggerEl[isActive ? 'removeClass' : 'addClass']('open');
877 // .trigger('shown.bs.dropdown', relatedTarget)
879 this.triggerEl.focus();
885 clearMenus : function()
887 //$(backdrop).remove()
888 Roo.select('.dropdown-toggle',true).each(function(aa) {
889 if (!aa.hasClass('open')) {
893 aa.removeClass('open');
894 //var parent = getParent($(this))
895 //var relatedTarget = { relatedTarget: this }
897 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
898 //if (e.isDefaultPrevented()) return
899 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
917 * @class Roo.bootstrap.MenuItem
918 * @extends Roo.bootstrap.Component
919 * Bootstrap MenuItem class
920 * @cfg {String} html the menu label
921 * @cfg {String} href the link
925 * Create a new MenuItem
926 * @param {Object} config The config object
930 Roo.bootstrap.MenuItem = function(config){
931 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
934 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
939 getAutoCreate : function(){
951 cfg.cn[0].href = this.href || cfg.cn[0].href ;
952 cfg.cn[0].html = this.html || cfg.cn[0].html ;
969 * @class Roo.bootstrap.MenuSeparator
970 * @extends Roo.bootstrap.Component
971 * Bootstrap MenuSeparator class
974 * Create a new MenuItem
975 * @param {Object} config The config object
979 Roo.bootstrap.MenuSeparator = function(config){
980 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
983 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
985 getAutoCreate : function(){
1000 <div class="modal fade">
1001 <div class="modal-dialog">
1002 <div class="modal-content">
1003 <div class="modal-header">
1004 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
1005 <h4 class="modal-title">Modal title</h4>
1007 <div class="modal-body">
1008 <p>One fine body…</p>
1010 <div class="modal-footer">
1011 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
1012 <button type="button" class="btn btn-primary">Save changes</button>
1014 </div><!-- /.modal-content -->
1015 </div><!-- /.modal-dialog -->
1016 </div><!-- /.modal -->
1026 * @class Roo.bootstrap.Modal
1027 * @extends Roo.bootstrap.Component
1028 * Bootstrap Modal class
1029 * @cfg {String} title Title of dialog
1030 * @cfg {Array} buttons Array of buttons
1033 * Create a new Modal Dialog
1034 * @param {Object} config The config object
1037 Roo.bootstrap.Modal = function(config){
1038 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
1041 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
1043 title : 'test dialog',
1047 onRender : function(ct, position)
1049 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1051 var cfg = Roo.apply({}, this.getAutoCreate());
1054 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
1056 //if (!cfg.name.length) {
1060 cfg.cls += ' ' + this.cls;
1063 cfg.style = this.style;
1065 this.el = Roo.get(document.body).createChild(cfg, position);
1067 //var type = this.el.dom.type;
1069 if(this.tabIndex !== undefined){
1070 this.el.dom.setAttribute('tabIndex', this.tabIndex);
1073 //this.el.addClass([this.fieldClass, this.cls]);
1076 getAutoCreate : function(){
1082 cls: "modal-dialog",
1085 cls : "modal-content",
1088 cls : 'modal-header',
1097 cls : 'modal-title',
1108 cls : 'modal-footer'
1113 cls : 'btn btn-default',
1118 cls : 'btn btn-primary',
1139 getChildContainer : function() {
1141 return this.el.select('.modal-body',true).first();
1144 getButtonContainer : function() {
1145 return this.el.select('.modal-footer',true).first();
1148 initEvents : function()
1150 this.el.select('.modal-header .close').on('click', this.hide, this);
1153 this.el.addClass('on');
1154 this.el.removeClass('fade');
1155 this.el.setStyle('display', 'block');
1158 this.el.removeClass('on');
1159 this.el.addClass('fade');
1160 this.el.setStyle('display', 'none');
1172 * @class Roo.bootstrap.Navbar
1173 * @extends Roo.bootstrap.Component
1174 * Bootstrap Navbar class
1175 * @cfg {Boolean} sidebar has side bar
1176 * @cfg {Boolean} bar is a bar?
1177 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
1178 * @cfg {String} brand what is brand
1179 * @cfg {Boolean} inverse is inverted color
1180 * @cfg {String} type (nav | pills | tabs)
1181 * @cfg {Boolean} arrangement stacked | justified
1182 * @cfg {String} align (left | right) alignment
1186 * Create a new Navbar
1187 * @param {Object} config The config object
1191 Roo.bootstrap.Navbar = function(config){
1192 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
1195 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
1207 getAutoCreate : function(){
1212 if (this.sidebar === true) {
1220 if (this.bar === true) {
1228 cls: 'navbar-header',
1233 cls: 'navbar-toggle',
1234 'data-toggle': 'collapse',
1239 html: 'Toggle navigation'
1259 cls: 'collapse navbar-collapse'
1264 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
1266 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
1267 cfg.cls += ' navbar-' + this.position;
1268 cfg.tag = this.position == 'fixed-bottom' ? 'footer' : 'header';
1271 if (this.brand !== '') {
1275 cls: 'navbar-brand',
1284 } else if (this.bar === false) {
1287 Roo.log('Property \'bar\' in of Navbar must be either true or false')
1297 if (['tabs','pills'].indexOf(this.type)!==-1) {
1298 cfg.cn[0].cls += ' nav-' + this.type
1300 if (this.type!=='nav') {
1301 Roo.log('nav type must be nav/tabs/pills')
1303 cfg.cn[0].cls += ' navbar-nav'
1306 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
1307 cfg.cn[0].cls += ' nav-' + this.arrangement;
1310 if (this.align === 'right') {
1311 cfg.cn[0].cls += ' navbar-right';
1314 cfg.cls += ' navbar-inverse';
1322 getChildContainer : function() {
1323 if (this.bar === true) {
1324 return this.el.select('.collapse',true).first();
1342 * @class Roo.bootstrap.NavGroup
1343 * @extends Roo.bootstrap.Component
1344 * Bootstrap NavGroup class
1345 * @cfg {String} align left | right
1346 * @cfg {Boolean} inverse false | true
1349 * Create a new nav group
1350 * @param {Object} config The config object
1353 Roo.bootstrap.NavGroup = function(config){
1354 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
1357 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
1363 getAutoCreate : function(){
1364 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
1368 cls: 'nav navbar-nav'
1371 if (this.parent().sidebar === true) {
1374 cls: 'dashboard-menu'
1380 if (this.form === true) {
1386 if (this.align === 'right') {
1387 cfg.cls += ' navbar-right';
1389 cfg.cls += ' navbar-left';
1394 if (this.align === 'right') {
1395 cfg.cls += ' navbar-right';
1399 cfg.cls += ' navbar-inverse';
1418 * @class Roo.bootstrap.Navbar.Button
1419 * @extends Roo.bootstrap.Component
1420 * Bootstrap Navbar.Button class
1421 * @cfg {String} href link to
1422 * @cfg {String} html content of button
1425 * Create a new Navbar Button
1426 * @param {Object} config The config object
1430 Roo.bootstrap.Navbar.Button = function(config){
1431 Roo.bootstrap.Navbar.Button.superclass.constructor.call(this, config);
1434 Roo.extend(Roo.bootstrap.Navbar.Button, Roo.bootstrap.Component, {
1445 getAutoCreate : function(){
1455 html : this.html || ''
1479 * @class Roo.bootstrap.Navbar.Item
1480 * @extends Roo.bootstrap.Component
1481 * Bootstrap Navbar.Button class
1482 * @cfg {String} href link to
1483 * @cfg {String} html content of button
1484 * @cfg {String} badge text inside badge
1485 * @cfg {String} glyphicon name of glyphicon
1488 * Create a new Navbar Button
1489 * @param {Object} config The config object
1491 Roo.bootstrap.Navbar.Item = function(config){
1492 Roo.bootstrap.Navbar.Item.superclass.constructor.call(this, config);
1495 Roo.extend(Roo.bootstrap.Navbar.Item, Roo.bootstrap.Component, {
1503 getAutoCreate : function(){
1505 var cfg = Roo.apply({}, Roo.bootstrap.Navbar.Item.superclass.getAutoCreate.call(this));
1507 if (this.parent().parent().sidebar === true) {
1520 cfg.cn[0].html = this.html;
1524 this.cls += ' active';
1528 cfg.cn[0].cls += ' dropdown-toggle';
1529 cfg.cn[0].html = (cfg.cn[0].html || this.html) + '<span class="glyphicon glyphicon-chevron-down"></span>';
1533 cfg.cn[0].tag = 'a',
1534 cfg.cn[0].href = this.href;
1537 if (this.glyphicon) {
1538 cfg.cn[0].html = '<i class="glyphicon glyphicon-'+this.glyphicon+'"></i><span>' + cfg.cn[0].html || this.html + '</span>'
1554 if (this.glyphicon) {
1555 if(cfg.html){cfg.html = ' ' + this.html};
1559 cls: 'glyphicon glyphicon-' + this.glyphicon
1564 cfg.cn[0].html = this.html || cfg.cn[0].html ;
1568 cfg.cn[0].html += " <span class='caret'></span>";
1569 //}else if (!this.href) {
1570 // cfg.cn[0].tag='p';
1571 // cfg.cn[0].cls='navbar-text';
1574 cfg.cn[0].href=this.href||'#';
1575 cfg.cn[0].html=this.html;
1578 if (this.badge !== '') {
1581 cfg.cn[0].html + ' ',
1594 initEvents: function() {
1595 // Roo.log('init events?');
1596 // Roo.log(this.el.dom);
1597 this.el.select('a',true).on('click',
1599 this.fireEvent('click', this);
1616 * @class Roo.bootstrap.Row
1617 * @extends Roo.bootstrap.Component
1618 * Bootstrap Row class (contains columns...)
1622 * @param {Object} config The config object
1625 Roo.bootstrap.Row = function(config){
1626 Roo.bootstrap.Row.superclass.constructor.call(this, config);
1629 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
1648 * @class Roo.bootstrap.Element
1649 * @extends Roo.bootstrap.Component
1650 * Bootstrap Element class
1651 * @cfg {String} html contents of the element
1652 * @cfg {String} tag tag of the element
1653 * @cfg {String} cls class of the element
1656 * Create a new Element
1657 * @param {Object} config The config object
1660 Roo.bootstrap.Element = function(config){
1661 Roo.bootstrap.Element.superclass.constructor.call(this, config);
1664 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
1672 getAutoCreate : function(){
1673 var cfg = Roo.apply({}, Roo.bootstrap.Element.superclass.getAutoCreate.call(this));
1696 * @class Roo.bootstrap.Pagination
1697 * @extends Roo.bootstrap.Component
1698 * Bootstrap Pagination class
1699 * @cfg {String} size xs | sm | md | lg
1700 * @cfg {Boolean} inverse false | true
1701 * @cfg {Number} from pagination starting number
1702 * @cfg {Number} to pagination ending number
1703 * @cfg {String} align empty or left | right
1704 * @cfg {Number} active active page number
1707 * Create a new Pagination
1708 * @param {Object} config The config object
1711 Roo.bootstrap.Pagination = function(config){
1712 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
1715 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
1725 getAutoCreate : function(){
1732 cfg.cls += ' inverse';
1750 var from=this.from>0?this.from:1;
1751 var to=this.to-from<=10?this.to:from+10;
1752 var active=this.active>=from&&this.active<=to?this.active:null;
1753 for (var i=from;i<=to;i++) {
1757 cls: active===i?'active':'',
1798 * @class Roo.bootstrap.Slider
1799 * @extends Roo.bootstrap.Component
1800 * Bootstrap Slider class
1803 * Create a new Slider
1804 * @param {Object} config The config object
1807 Roo.bootstrap.Slider = function(config){
1808 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
1811 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
1813 getAutoCreate : function(){
1817 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
1821 cls: 'ui-slider-handle ui-state-default ui-corner-all'
1839 * @class Roo.bootstrap.Table
1840 * @extends Roo.bootstrap.Component
1841 * Bootstrap Table class
1844 * Create a new Table
1845 * @param {Object} config The config object
1848 Roo.bootstrap.Table = function(config){
1849 Roo.bootstrap.Table.superclass.constructor.call(this, config);
1852 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
1857 getAutoCreate : function(){
1858 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
1890 * @class Roo.bootstrap.TableCell
1891 * @extends Roo.bootstrap.Component
1892 * Bootstrap TableCell class
1895 * Create a new TableCell
1896 * @param {Object} config The config object
1899 Roo.bootstrap.TableCell = function(config){
1900 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
1903 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
1905 getAutoCreate : function(){
1906 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
1933 * @class Roo.bootstrap.TableRow
1934 * @extends Roo.bootstrap.Component
1935 * Bootstrap TableRow class
1938 * Create a new TableRow
1939 * @param {Object} config The config object
1942 Roo.bootstrap.TableRow = function(config){
1943 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
1946 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
1948 getAutoCreate : function(){
1949 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
1970 * @class Roo.bootstrap.Form
1971 * @extends Roo.bootstrap.Component
1972 * Bootstrap Form class
1973 * @cfg {String} method GET | POST (default POST)
1974 * @cfg {String} labelAlign top | left (default top)
1978 * @param {Object} config The config object
1982 Roo.bootstrap.Form = function(config){
1983 Roo.bootstrap.Form.superclass.constructor.call(this, config);
1986 * @event clientvalidation
1987 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
1988 * @param {Form} this
1989 * @param {Boolean} valid true if the form has passed client-side validation
1991 clientvalidation: true,
1994 * Fires when the form is rendered
1995 * @param {Roo.form.Form} form
2001 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
2004 getAutoCreate : function(){
2008 method : this.method || 'POST',
2009 id : this.id || Roo.id(),
2013 if (this.labelAlign == 'left' ) {
2014 cfg.cls += ' form-horizontal';
2024 * Ext JS Library 1.1.1
2025 * Copyright(c) 2006-2007, Ext JS, LLC.
2027 * Originally Released Under LGPL - original licence link has changed is not relivant.
2030 * <script type="text/javascript">
2033 * @class Roo.form.VTypes
2034 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
2037 Roo.form.VTypes = function(){
2038 // closure these in so they are only created once.
2039 var alpha = /^[a-zA-Z_]+$/;
2040 var alphanum = /^[a-zA-Z0-9_]+$/;
2041 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
2042 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
2044 // All these messages and functions are configurable
2047 * The function used to validate email addresses
2048 * @param {String} value The email address
2050 'email' : function(v){
2051 return email.test(v);
2054 * The error text to display when the email validation function returns false
2057 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
2059 * The keystroke filter mask to be applied on email input
2062 'emailMask' : /[a-z0-9_\.\-@]/i,
2065 * The function used to validate URLs
2066 * @param {String} value The URL
2068 'url' : function(v){
2072 * The error text to display when the url validation function returns false
2075 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
2078 * The function used to validate alpha values
2079 * @param {String} value The value
2081 'alpha' : function(v){
2082 return alpha.test(v);
2085 * The error text to display when the alpha validation function returns false
2088 'alphaText' : 'This field should only contain letters and _',
2090 * The keystroke filter mask to be applied on alpha input
2093 'alphaMask' : /[a-z_]/i,
2096 * The function used to validate alphanumeric values
2097 * @param {String} value The value
2099 'alphanum' : function(v){
2100 return alphanum.test(v);
2103 * The error text to display when the alphanumeric validation function returns false
2106 'alphanumText' : 'This field should only contain letters, numbers and _',
2108 * The keystroke filter mask to be applied on alphanumeric input
2111 'alphanumMask' : /[a-z0-9_]/i
2121 * @class Roo.bootstrap.Input
2122 * @extends Roo.bootstrap.Component
2123 * Bootstrap Input class
2124 * @cfg {Boolean} disabled is it disabled
2125 * @cfg {String} fieldLabel - the label associated
2126 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
2127 * @cfg {String} name name of the input
2128 * @cfg {string} fieldLabel - the label associated
2129 * @cfg {string} inputType - input / file submit ...
2130 * @cfg {string} placeholder - placeholder to put in text.
2131 * @cfg {string} before - input group add on before
2132 * @cfg {string} after - input group add on after
2136 * Create a new Input
2137 * @param {Object} config The config object
2140 Roo.bootstrap.Input = function(config){
2141 Roo.bootstrap.Input.superclass.constructor.call(this, config);
2146 * Fires when this field receives input focus.
2147 * @param {Roo.form.Field} this
2152 * Fires when this field loses input focus.
2153 * @param {Roo.form.Field} this
2158 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
2159 * {@link Roo.EventObject#getKey} to determine which key was pressed.
2160 * @param {Roo.form.Field} this
2161 * @param {Roo.EventObject} e The event object
2166 * Fires just before the field blurs if the field value has changed.
2167 * @param {Roo.form.Field} this
2168 * @param {Mixed} newValue The new value
2169 * @param {Mixed} oldValue The original value
2174 * Fires after the field has been marked as invalid.
2175 * @param {Roo.form.Field} this
2176 * @param {String} msg The validation message
2181 * Fires after the field has been validated with no errors.
2182 * @param {Roo.form.Field} this
2187 * Fires after the key up
2188 * @param {Roo.form.Field} this
2189 * @param {Roo.EventObject} e The event Object
2195 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
2197 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
2198 automatic validation (defaults to "keyup").
2200 validationEvent : "keyup",
2202 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
2204 validateOnBlur : true,
2206 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
2208 validationDelay : 250,
2210 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
2212 focusClass : "x-form-focus", // not needed???
2216 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
2218 invalidClass : "has-error",
2221 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
2223 selectOnFocus : false,
2226 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
2230 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
2235 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
2237 disableKeyFilter : false,
2240 * @cfg {Boolean} disabled True to disable the field (defaults to false).
2244 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
2248 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
2250 blankText : "This field is required",
2253 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
2257 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
2259 maxLength : Number.MAX_VALUE,
2261 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
2263 minLengthText : "The minimum length for this field is {0}",
2265 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
2267 maxLengthText : "The maximum length for this field is {0}",
2271 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
2272 * If available, this function will be called only after the basic validators all return true, and will be passed the
2273 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
2277 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
2278 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
2279 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
2283 * @cfg {String} regexText The error text to display if {@link #regex} is used and the test fails during validation (defaults to "")
2301 getAutoCreate : function(){
2303 var parent = this.parent();
2305 var align = parent.labelAlign;
2310 cls: 'form-group' //input-group
2316 type : this.inputType,
2317 cls : 'form-control',
2318 placeholder : this.placeholder || ''
2325 var inputblock = input;
2327 if (this.before || this.after) {
2330 cls : 'input-group',
2334 inputblock.cn.push({
2336 cls : 'input-group-addon',
2340 inputblock.cn.push(input);
2342 inputblock.cn.push({
2344 cls : 'input-group-addon',
2352 Roo.log(this.fieldLabel.length);
2354 if (align ==='left' && this.fieldLabel.length) {
2355 Roo.log("left and has label");
2361 cls : 'col-sm-2 control-label',
2362 html : this.fieldLabel
2373 } else if ( this.fieldLabel.length) {
2379 //cls : 'input-group-addon',
2380 html : this.fieldLabel
2390 Roo.log(" no label && no align");
2403 if (this.disabled) {
2404 input.disabled=true;
2410 * return the real input element.
2412 inputEl: function ()
2414 return this.el.select('input.form-control',true).first();
2416 setDisabled : function(v)
2418 var i = this.inputEl().dom;
2420 i.removeAttribute('disabled');
2424 i.setAttribute('disabled','true');
2426 initEvents : function()
2429 this.inputEl().on("keydown" , this.fireKey, this);
2430 this.inputEl().on("focus", this.onFocus, this);
2431 this.inputEl().on("blur", this.onBlur, this);
2432 this.inputEl().relayEvent('keyup', this);
2434 // reference to original value for reset
2435 this.originalValue = this.getValue();
2436 //Roo.form.TextField.superclass.initEvents.call(this);
2437 if(this.validationEvent == 'keyup'){
2438 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
2439 this.inputEl().on('keyup', this.filterValidation, this);
2441 else if(this.validationEvent !== false){
2442 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
2445 if(this.selectOnFocus){
2446 this.on("focus", this.preFocus, this);
2449 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
2450 this.inputEl().on("keypress", this.filterKeys, this);
2453 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
2454 this.el.on("click", this.autoSize, this);
2457 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
2458 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
2462 filterValidation : function(e){
2463 if(!e.isNavKeyPress()){
2464 this.validationTask.delay(this.validationDelay);
2468 * Validates the field value
2469 * @return {Boolean} True if the value is valid, else false
2471 validate : function(){
2472 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
2473 if(this.disabled || this.validateValue(this.getRawValue())){
2474 this.clearInvalid();
2482 * Validates a value according to the field's validation rules and marks the field as invalid
2483 * if the validation fails
2484 * @param {Mixed} value The value to validate
2485 * @return {Boolean} True if the value is valid, else false
2487 validateValue : function(value){
2488 if(value.length < 1) { // if it's blank
2489 if(this.allowBlank){
2490 this.clearInvalid();
2493 this.markInvalid(this.blankText);
2497 if(value.length < this.minLength){
2498 this.markInvalid(String.format(this.minLengthText, this.minLength));
2501 if(value.length > this.maxLength){
2502 this.markInvalid(String.format(this.maxLengthText, this.maxLength));
2506 var vt = Roo.form.VTypes;
2507 if(!vt[this.vtype](value, this)){
2508 this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
2512 if(typeof this.validator == "function"){
2513 var msg = this.validator(value);
2515 this.markInvalid(msg);
2519 if(this.regex && !this.regex.test(value)){
2520 this.markInvalid(this.regexText);
2529 fireKey : function(e){
2530 //Roo.log('field ' + e.getKey());
2531 if(e.isNavKeyPress()){
2532 this.fireEvent("specialkey", this, e);
2535 onFocus : function(){
2536 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
2537 // this.el.addClass(this.focusClass);
2540 this.hasFocus = true;
2541 this.startValue = this.getValue();
2542 this.fireEvent("focus", this);
2546 beforeBlur : Roo.emptyFn,
2550 onBlur : function(){
2552 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
2553 //this.el.removeClass(this.focusClass);
2555 this.hasFocus = false;
2556 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
2559 var v = this.getValue();
2560 if(String(v) !== String(this.startValue)){
2561 this.fireEvent('change', this, v, this.startValue);
2563 this.fireEvent("blur", this);
2566 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
2567 * @return {Mixed} value The field value
2569 getValue : function(){
2570 var v = this.inputEl().getValue();
2574 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
2575 * @return {Mixed} value The field value
2577 getRawValue : function(){
2578 var v = this.inputEl().getValue();
2583 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
2584 * @param {Mixed} value The value to set
2586 setValue : function(v){
2589 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
2595 processValue : function(value){
2596 if(this.stripCharsRe){
2597 var newValue = value.replace(this.stripCharsRe, '');
2598 if(newValue !== value){
2599 this.setRawValue(newValue);
2606 preFocus : function(){
2608 if(this.selectOnFocus){
2609 this.inputEl().dom.select();
2612 filterKeys : function(e){
2614 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
2617 var c = e.getCharCode(), cc = String.fromCharCode(c);
2618 if(Roo.isIE && (e.isSpecialKey() || !cc)){
2621 if(!this.maskRe.test(cc)){
2626 * Clear any invalid styles/messages for this field
2628 clearInvalid : function(){
2630 if(!this.el || this.preventMark){ // not rendered
2633 this.el.removeClass(this.invalidClass);
2635 switch(this.msgTarget){
2637 this.el.dom.qtip = '';
2640 this.el.dom.title = '';
2644 Roo.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
2649 this.errorIcon.dom.qtip = '';
2650 this.errorIcon.hide();
2651 this.un('resize', this.alignErrorIcon, this);
2655 var t = Roo.getDom(this.msgTarget);
2657 t.style.display = 'none';
2661 this.fireEvent('valid', this);
2664 * Mark this field as invalid
2665 * @param {String} msg The validation message
2667 markInvalid : function(msg){
2668 if(!this.el || this.preventMark){ // not rendered
2671 this.el.addClass(this.invalidClass);
2673 msg = msg || this.invalidText;
2674 switch(this.msgTarget){
2676 this.el.dom.qtip = msg;
2677 this.el.dom.qclass = 'x-form-invalid-tip';
2678 if(Roo.QuickTips){ // fix for floating editors interacting with DND
2679 Roo.QuickTips.enable();
2683 this.el.dom.title = msg;
2687 var elp = this.el.findParent('.x-form-element', 5, true);
2688 this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
2689 this.errorEl.setWidth(elp.getWidth(true)-20);
2691 this.errorEl.update(msg);
2692 Roo.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
2695 if(!this.errorIcon){
2696 var elp = this.el.findParent('.x-form-element', 5, true);
2697 this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
2699 this.alignErrorIcon();
2700 this.errorIcon.dom.qtip = msg;
2701 this.errorIcon.dom.qclass = 'x-form-invalid-tip';
2702 this.errorIcon.show();
2703 this.on('resize', this.alignErrorIcon, this);
2706 var t = Roo.getDom(this.msgTarget);
2708 t.style.display = this.msgDisplay;
2712 this.fireEvent('invalid', this, msg);
2715 SafariOnKeyDown : function(event)
2717 // this is a workaround for a password hang bug on chrome/ webkit.
2719 var isSelectAll = false;
2721 if(this.inputEl().dom.selectionEnd > 0){
2722 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
2724 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
2725 event.preventDefault();
2730 if(isSelectAll){ // backspace and delete key
2732 event.preventDefault();
2733 // this is very hacky as keydown always get's upper case.
2735 var cc = String.fromCharCode(event.getCharCode());
2736 this.setValue( event.shiftKey ? cc : cc.toLowerCase());