2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets, function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
585 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
586 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
587 * @cfg {String} size ( lg | sm | xs)
588 * @cfg {String} tag ( a | input | submit)
589 * @cfg {String} href empty or href
590 * @cfg {Boolean} disabled default false;
591 * @cfg {Boolean} isClose default false;
592 * @cfg {String} glyphicon depricated - use fa
593 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
594 * @cfg {String} badge text for badge
595 * @cfg {String} theme (default|glow)
596 * @cfg {Boolean} inverse dark themed version
597 * @cfg {Boolean} toggle is it a slidy toggle button
598 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
599 * @cfg {String} ontext text for on slidy toggle state
600 * @cfg {String} offtext text for off slidy toggle state
601 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
602 * @cfg {Boolean} removeClass remove the standard class..
603 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
606 * Create a new button
607 * @param {Object} config The config object
611 Roo.bootstrap.Button = function(config){
612 Roo.bootstrap.Button.superclass.constructor.call(this, config);
613 this.weightClass = ["btn-default btn-outline-secondary",
625 * When a butotn is pressed
626 * @param {Roo.bootstrap.Button} btn
627 * @param {Roo.EventObject} e
632 * After the button has been toggles
633 * @param {Roo.bootstrap.Button} btn
634 * @param {Roo.EventObject} e
635 * @param {boolean} pressed (also available as button.pressed)
641 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
662 preventDefault: true,
670 getAutoCreate : function(){
678 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
679 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
684 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
686 if (this.toggle == true) {
689 cls: 'slider-frame roo-button',
694 'data-off-text':'OFF',
695 cls: 'slider-button',
701 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
702 cfg.cls += ' '+this.weight;
711 cfg["aria-hidden"] = true;
713 cfg.html = "×";
719 if (this.theme==='default') {
720 cfg.cls = 'btn roo-button';
722 //if (this.parentType != 'Navbar') {
723 this.weight = this.weight.length ? this.weight : 'default';
725 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
727 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
728 var weight = this.weight == 'default' ? 'secondary' : this.weight;
729 cfg.cls += ' btn-' + outline + weight;
730 if (this.weight == 'default') {
732 cfg.cls += ' btn-' + this.weight;
735 } else if (this.theme==='glow') {
738 cfg.cls = 'btn-glow roo-button';
740 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
742 cfg.cls += ' ' + this.weight;
748 this.cls += ' inverse';
752 if (this.active || this.pressed === true) {
753 cfg.cls += ' active';
757 cfg.disabled = 'disabled';
761 Roo.log('changing to ul' );
763 this.glyphicon = 'caret';
764 if (Roo.bootstrap.version == 4) {
765 this.fa = 'caret-down';
770 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
772 //gsRoo.log(this.parentType);
773 if (this.parentType === 'Navbar' && !this.parent().bar) {
774 Roo.log('changing to li?');
783 href : this.href || '#'
786 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
787 cfg.cls += ' dropdown';
794 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
796 if (this.glyphicon) {
797 cfg.html = ' ' + cfg.html;
802 cls: 'glyphicon glyphicon-' + this.glyphicon
807 cfg.html = ' ' + cfg.html;
812 cls: 'fa fas fa-' + this.fa
822 // cfg.cls='btn roo-button';
826 var value = cfg.html;
831 cls: 'glyphicon glyphicon-' + this.glyphicon,
838 cls: 'fa fas fa-' + this.fa,
843 var bw = this.badge_weight.length ? this.badge_weight :
844 (this.weight.length ? this.weight : 'secondary');
845 bw = bw == 'default' ? 'secondary' : bw;
851 cls: 'badge badge-' + bw,
860 cfg.cls += ' dropdown';
861 cfg.html = typeof(cfg.html) != 'undefined' ?
862 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
865 if (cfg.tag !== 'a' && this.href !== '') {
866 throw "Tag must be a to set href.";
867 } else if (this.href.length > 0) {
868 cfg.href = this.href;
871 if(this.removeClass){
876 cfg.target = this.target;
881 initEvents: function() {
882 // Roo.log('init events?');
883 // Roo.log(this.el.dom);
886 if (typeof (this.menu) != 'undefined') {
887 this.menu.parentType = this.xtype;
888 this.menu.triggerEl = this.el;
889 this.addxtype(Roo.apply({}, this.menu));
893 if (this.el.hasClass('roo-button')) {
894 this.el.on('click', this.onClick, this);
896 this.el.select('.roo-button').on('click', this.onClick, this);
899 if(this.removeClass){
900 this.el.on('click', this.onClick, this);
903 this.el.enableDisplayMode();
906 onClick : function(e)
912 Roo.log('button on click ');
913 if(this.preventDefault){
917 if (this.pressed === true || this.pressed === false) {
918 this.toggleActive(e);
922 this.fireEvent('click', this, e);
926 * Enables this button
930 this.disabled = false;
931 this.el.removeClass('disabled');
935 * Disable this button
939 this.disabled = true;
940 this.el.addClass('disabled');
943 * sets the active state on/off,
944 * @param {Boolean} state (optional) Force a particular state
946 setActive : function(v) {
948 this.el[v ? 'addClass' : 'removeClass']('active');
952 * toggles the current active state
954 toggleActive : function(e)
956 this.setActive(!this.pressed);
957 this.fireEvent('toggle', this, e, !this.pressed);
960 * get the current active state
961 * @return {boolean} true if it's active
963 isActive : function()
965 return this.el.hasClass('active');
968 * set the text of the first selected button
970 setText : function(str)
972 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
975 * get the text of the first selected button
979 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
982 setWeight : function(str)
984 this.el.removeClass(this.weightClass);
986 var outline = this.outline ? 'outline-' : '';
987 if (str == 'default') {
988 this.el.addClass('btn-default btn-outline-secondary');
991 this.el.addClass('btn-' + outline + str);
1005 * @class Roo.bootstrap.Column
1006 * @extends Roo.bootstrap.Component
1007 * Bootstrap Column class
1008 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1009 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1010 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1011 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1012 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1013 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1014 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1015 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1018 * @cfg {Boolean} hidden (true|false) hide the element
1019 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1020 * @cfg {String} fa (ban|check|...) font awesome icon
1021 * @cfg {Number} fasize (1|2|....) font awsome size
1023 * @cfg {String} icon (info-sign|check|...) glyphicon name
1025 * @cfg {String} html content of column.
1028 * Create a new Column
1029 * @param {Object} config The config object
1032 Roo.bootstrap.Column = function(config){
1033 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1036 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1054 getAutoCreate : function(){
1055 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1063 ['xs','sm','md','lg'].map(function(size){
1064 //Roo.log( size + ':' + settings[size]);
1066 if (settings[size+'off'] !== false) {
1067 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1070 if (settings[size] === false) {
1074 if (!settings[size]) { // 0 = hidden
1075 cfg.cls += ' hidden-' + size + ' hidden' + size + '-down';;
1078 cfg.cls += ' col-' + size + '-' + settings[size] + (
1079 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1085 cfg.cls += ' hidden';
1088 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1089 cfg.cls +=' alert alert-' + this.alert;
1093 if (this.html.length) {
1094 cfg.html = this.html;
1098 if (this.fasize > 1) {
1099 fasize = ' fa-' + this.fasize + 'x';
1101 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1106 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1125 * @class Roo.bootstrap.Container
1126 * @extends Roo.bootstrap.Component
1127 * Bootstrap Container class
1128 * @cfg {Boolean} jumbotron is it a jumbotron element
1129 * @cfg {String} html content of element
1130 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1131 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1132 * @cfg {String} header content of header (for panel)
1133 * @cfg {String} footer content of footer (for panel)
1134 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1135 * @cfg {String} tag (header|aside|section) type of HTML tag.
1136 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1137 * @cfg {String} fa font awesome icon
1138 * @cfg {String} icon (info-sign|check|...) glyphicon name
1139 * @cfg {Boolean} hidden (true|false) hide the element
1140 * @cfg {Boolean} expandable (true|false) default false
1141 * @cfg {Boolean} expanded (true|false) default true
1142 * @cfg {String} rheader contet on the right of header
1143 * @cfg {Boolean} clickable (true|false) default false
1147 * Create a new Container
1148 * @param {Object} config The config object
1151 Roo.bootstrap.Container = function(config){
1152 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1158 * After the panel has been expand
1160 * @param {Roo.bootstrap.Container} this
1165 * After the panel has been collapsed
1167 * @param {Roo.bootstrap.Container} this
1172 * When a element is chick
1173 * @param {Roo.bootstrap.Container} this
1174 * @param {Roo.EventObject} e
1180 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1198 getChildContainer : function() {
1204 if (this.panel.length) {
1205 return this.el.select('.panel-body',true).first();
1212 getAutoCreate : function(){
1215 tag : this.tag || 'div',
1219 if (this.jumbotron) {
1220 cfg.cls = 'jumbotron';
1225 // - this is applied by the parent..
1227 // cfg.cls = this.cls + '';
1230 if (this.sticky.length) {
1232 var bd = Roo.get(document.body);
1233 if (!bd.hasClass('bootstrap-sticky')) {
1234 bd.addClass('bootstrap-sticky');
1235 Roo.select('html',true).setStyle('height', '100%');
1238 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1242 if (this.well.length) {
1243 switch (this.well) {
1246 cfg.cls +=' well well-' +this.well;
1255 cfg.cls += ' hidden';
1259 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1260 cfg.cls +=' alert alert-' + this.alert;
1265 if (this.panel.length) {
1266 cfg.cls += ' panel panel-' + this.panel;
1268 if (this.header.length) {
1272 if(this.expandable){
1274 cfg.cls = cfg.cls + ' expandable';
1278 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1286 cls : 'panel-title',
1287 html : (this.expandable ? ' ' : '') + this.header
1291 cls: 'panel-header-right',
1297 cls : 'panel-heading',
1298 style : this.expandable ? 'cursor: pointer' : '',
1306 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1311 if (this.footer.length) {
1313 cls : 'panel-footer',
1322 body.html = this.html || cfg.html;
1323 // prefix with the icons..
1325 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1328 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1333 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1334 cfg.cls = 'container';
1340 initEvents: function()
1342 if(this.expandable){
1343 var headerEl = this.headerEl();
1346 headerEl.on('click', this.onToggleClick, this);
1351 this.el.on('click', this.onClick, this);
1356 onToggleClick : function()
1358 var headerEl = this.headerEl();
1374 if(this.fireEvent('expand', this)) {
1376 this.expanded = true;
1378 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1380 this.el.select('.panel-body',true).first().removeClass('hide');
1382 var toggleEl = this.toggleEl();
1388 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1393 collapse : function()
1395 if(this.fireEvent('collapse', this)) {
1397 this.expanded = false;
1399 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1400 this.el.select('.panel-body',true).first().addClass('hide');
1402 var toggleEl = this.toggleEl();
1408 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1412 toggleEl : function()
1414 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1418 return this.el.select('.panel-heading .fa',true).first();
1421 headerEl : function()
1423 if(!this.el || !this.panel.length || !this.header.length){
1427 return this.el.select('.panel-heading',true).first()
1432 if(!this.el || !this.panel.length){
1436 return this.el.select('.panel-body',true).first()
1439 titleEl : function()
1441 if(!this.el || !this.panel.length || !this.header.length){
1445 return this.el.select('.panel-title',true).first();
1448 setTitle : function(v)
1450 var titleEl = this.titleEl();
1456 titleEl.dom.innerHTML = v;
1459 getTitle : function()
1462 var titleEl = this.titleEl();
1468 return titleEl.dom.innerHTML;
1471 setRightTitle : function(v)
1473 var t = this.el.select('.panel-header-right',true).first();
1479 t.dom.innerHTML = v;
1482 onClick : function(e)
1486 this.fireEvent('click', this, e);
1499 * @class Roo.bootstrap.Img
1500 * @extends Roo.bootstrap.Component
1501 * Bootstrap Img class
1502 * @cfg {Boolean} imgResponsive false | true
1503 * @cfg {String} border rounded | circle | thumbnail
1504 * @cfg {String} src image source
1505 * @cfg {String} alt image alternative text
1506 * @cfg {String} href a tag href
1507 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1508 * @cfg {String} xsUrl xs image source
1509 * @cfg {String} smUrl sm image source
1510 * @cfg {String} mdUrl md image source
1511 * @cfg {String} lgUrl lg image source
1514 * Create a new Input
1515 * @param {Object} config The config object
1518 Roo.bootstrap.Img = function(config){
1519 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1525 * The img click event for the img.
1526 * @param {Roo.EventObject} e
1532 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1534 imgResponsive: true,
1544 getAutoCreate : function()
1546 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1547 return this.createSingleImg();
1552 cls: 'roo-image-responsive-group',
1557 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1559 if(!_this[size + 'Url']){
1565 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1566 html: _this.html || cfg.html,
1567 src: _this[size + 'Url']
1570 img.cls += ' roo-image-responsive-' + size;
1572 var s = ['xs', 'sm', 'md', 'lg'];
1574 s.splice(s.indexOf(size), 1);
1576 Roo.each(s, function(ss){
1577 img.cls += ' hidden-' + ss;
1580 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1581 cfg.cls += ' img-' + _this.border;
1585 cfg.alt = _this.alt;
1598 a.target = _this.target;
1602 cfg.cn.push((_this.href) ? a : img);
1609 createSingleImg : function()
1613 cls: (this.imgResponsive) ? 'img-responsive' : '',
1615 src : 'about:blank' // just incase src get's set to undefined?!?
1618 cfg.html = this.html || cfg.html;
1620 cfg.src = this.src || cfg.src;
1622 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1623 cfg.cls += ' img-' + this.border;
1640 a.target = this.target;
1645 return (this.href) ? a : cfg;
1648 initEvents: function()
1651 this.el.on('click', this.onClick, this);
1656 onClick : function(e)
1658 Roo.log('img onclick');
1659 this.fireEvent('click', this, e);
1662 * Sets the url of the image - used to update it
1663 * @param {String} url the url of the image
1666 setSrc : function(url)
1670 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1671 this.el.dom.src = url;
1675 this.el.select('img', true).first().dom.src = url;
1691 * @class Roo.bootstrap.Link
1692 * @extends Roo.bootstrap.Component
1693 * Bootstrap Link Class
1694 * @cfg {String} alt image alternative text
1695 * @cfg {String} href a tag href
1696 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1697 * @cfg {String} html the content of the link.
1698 * @cfg {String} anchor name for the anchor link
1699 * @cfg {String} fa - favicon
1701 * @cfg {Boolean} preventDefault (true | false) default false
1705 * Create a new Input
1706 * @param {Object} config The config object
1709 Roo.bootstrap.Link = function(config){
1710 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1716 * The img click event for the img.
1717 * @param {Roo.EventObject} e
1723 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1727 preventDefault: false,
1733 getAutoCreate : function()
1735 var html = this.html || '';
1737 if (this.fa !== false) {
1738 html = '<i class="fa fa-' + this.fa + '"></i>';
1743 // anchor's do not require html/href...
1744 if (this.anchor === false) {
1746 cfg.href = this.href || '#';
1748 cfg.name = this.anchor;
1749 if (this.html !== false || this.fa !== false) {
1752 if (this.href !== false) {
1753 cfg.href = this.href;
1757 if(this.alt !== false){
1762 if(this.target !== false) {
1763 cfg.target = this.target;
1769 initEvents: function() {
1771 if(!this.href || this.preventDefault){
1772 this.el.on('click', this.onClick, this);
1776 onClick : function(e)
1778 if(this.preventDefault){
1781 //Roo.log('img onclick');
1782 this.fireEvent('click', this, e);
1795 * @class Roo.bootstrap.Header
1796 * @extends Roo.bootstrap.Component
1797 * Bootstrap Header class
1798 * @cfg {String} html content of header
1799 * @cfg {Number} level (1|2|3|4|5|6) default 1
1802 * Create a new Header
1803 * @param {Object} config The config object
1807 Roo.bootstrap.Header = function(config){
1808 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1811 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1819 getAutoCreate : function(){
1824 tag: 'h' + (1 *this.level),
1825 html: this.html || ''
1837 * Ext JS Library 1.1.1
1838 * Copyright(c) 2006-2007, Ext JS, LLC.
1840 * Originally Released Under LGPL - original licence link has changed is not relivant.
1843 * <script type="text/javascript">
1847 * @class Roo.bootstrap.MenuMgr
1848 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1851 Roo.bootstrap.MenuMgr = function(){
1852 var menus, active, groups = {}, attached = false, lastShow = new Date();
1854 // private - called when first menu is created
1857 active = new Roo.util.MixedCollection();
1858 Roo.get(document).addKeyListener(27, function(){
1859 if(active.length > 0){
1867 if(active && active.length > 0){
1868 var c = active.clone();
1878 if(active.length < 1){
1879 Roo.get(document).un("mouseup", onMouseDown);
1887 var last = active.last();
1888 lastShow = new Date();
1891 Roo.get(document).on("mouseup", onMouseDown);
1896 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1897 m.parentMenu.activeChild = m;
1898 }else if(last && last.isVisible()){
1899 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1904 function onBeforeHide(m){
1906 m.activeChild.hide();
1908 if(m.autoHideTimer){
1909 clearTimeout(m.autoHideTimer);
1910 delete m.autoHideTimer;
1915 function onBeforeShow(m){
1916 var pm = m.parentMenu;
1917 if(!pm && !m.allowOtherMenus){
1919 }else if(pm && pm.activeChild && active != m){
1920 pm.activeChild.hide();
1924 // private this should really trigger on mouseup..
1925 function onMouseDown(e){
1926 Roo.log("on Mouse Up");
1928 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1929 Roo.log("MenuManager hideAll");
1938 function onBeforeCheck(mi, state){
1940 var g = groups[mi.group];
1941 for(var i = 0, l = g.length; i < l; i++){
1943 g[i].setChecked(false);
1952 * Hides all menus that are currently visible
1954 hideAll : function(){
1959 register : function(menu){
1963 menus[menu.id] = menu;
1964 menu.on("beforehide", onBeforeHide);
1965 menu.on("hide", onHide);
1966 menu.on("beforeshow", onBeforeShow);
1967 menu.on("show", onShow);
1969 if(g && menu.events["checkchange"]){
1973 groups[g].push(menu);
1974 menu.on("checkchange", onCheck);
1979 * Returns a {@link Roo.menu.Menu} object
1980 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1981 * be used to generate and return a new Menu instance.
1983 get : function(menu){
1984 if(typeof menu == "string"){ // menu id
1986 }else if(menu.events){ // menu instance
1989 /*else if(typeof menu.length == 'number'){ // array of menu items?
1990 return new Roo.bootstrap.Menu({items:menu});
1991 }else{ // otherwise, must be a config
1992 return new Roo.bootstrap.Menu(menu);
1999 unregister : function(menu){
2000 delete menus[menu.id];
2001 menu.un("beforehide", onBeforeHide);
2002 menu.un("hide", onHide);
2003 menu.un("beforeshow", onBeforeShow);
2004 menu.un("show", onShow);
2006 if(g && menu.events["checkchange"]){
2007 groups[g].remove(menu);
2008 menu.un("checkchange", onCheck);
2013 registerCheckable : function(menuItem){
2014 var g = menuItem.group;
2019 groups[g].push(menuItem);
2020 menuItem.on("beforecheckchange", onBeforeCheck);
2025 unregisterCheckable : function(menuItem){
2026 var g = menuItem.group;
2028 groups[g].remove(menuItem);
2029 menuItem.un("beforecheckchange", onBeforeCheck);
2041 * @class Roo.bootstrap.Menu
2042 * @extends Roo.bootstrap.Component
2043 * Bootstrap Menu class - container for MenuItems
2044 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2045 * @cfg {bool} hidden if the menu should be hidden when rendered.
2046 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2047 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2051 * @param {Object} config The config object
2055 Roo.bootstrap.Menu = function(config){
2056 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2057 if (this.registerMenu && this.type != 'treeview') {
2058 Roo.bootstrap.MenuMgr.register(this);
2065 * Fires before this menu is displayed (return false to block)
2066 * @param {Roo.menu.Menu} this
2071 * Fires before this menu is hidden (return false to block)
2072 * @param {Roo.menu.Menu} this
2077 * Fires after this menu is displayed
2078 * @param {Roo.menu.Menu} this
2083 * Fires after this menu is hidden
2084 * @param {Roo.menu.Menu} this
2089 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2090 * @param {Roo.menu.Menu} this
2091 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2092 * @param {Roo.EventObject} e
2097 * Fires when the mouse is hovering over this menu
2098 * @param {Roo.menu.Menu} this
2099 * @param {Roo.EventObject} e
2100 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2105 * Fires when the mouse exits this menu
2106 * @param {Roo.menu.Menu} this
2107 * @param {Roo.EventObject} e
2108 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2113 * Fires when a menu item contained in this menu is clicked
2114 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2115 * @param {Roo.EventObject} e
2119 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2122 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2126 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2129 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2131 registerMenu : true,
2133 menuItems :false, // stores the menu items..
2143 getChildContainer : function() {
2147 getAutoCreate : function(){
2149 //if (['right'].indexOf(this.align)!==-1) {
2150 // cfg.cn[1].cls += ' pull-right'
2156 cls : 'dropdown-menu' ,
2157 style : 'z-index:1000'
2161 if (this.type === 'submenu') {
2162 cfg.cls = 'submenu active';
2164 if (this.type === 'treeview') {
2165 cfg.cls = 'treeview-menu';
2170 initEvents : function() {
2172 // Roo.log("ADD event");
2173 // Roo.log(this.triggerEl.dom);
2175 this.triggerEl.on('click', this.onTriggerClick, this);
2177 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2180 if (this.triggerEl.hasClass('nav-item')) {
2181 // dropdown toggle on the 'a' in BS4?
2182 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2184 this.triggerEl.addClass('dropdown-toggle');
2187 this.el.on('touchstart' , this.onTouch, this);
2189 this.el.on('click' , this.onClick, this);
2191 this.el.on("mouseover", this.onMouseOver, this);
2192 this.el.on("mouseout", this.onMouseOut, this);
2196 findTargetItem : function(e)
2198 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2202 //Roo.log(t); Roo.log(t.id);
2204 //Roo.log(this.menuitems);
2205 return this.menuitems.get(t.id);
2207 //return this.items.get(t.menuItemId);
2213 onTouch : function(e)
2215 Roo.log("menu.onTouch");
2216 //e.stopEvent(); this make the user popdown broken
2220 onClick : function(e)
2222 Roo.log("menu.onClick");
2224 var t = this.findTargetItem(e);
2225 if(!t || t.isContainer){
2230 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2231 if(t == this.activeItem && t.shouldDeactivate(e)){
2232 this.activeItem.deactivate();
2233 delete this.activeItem;
2237 this.setActiveItem(t, true);
2245 Roo.log('pass click event');
2249 this.fireEvent("click", this, t, e);
2253 if(!t.href.length || t.href == '#'){
2254 (function() { _this.hide(); }).defer(100);
2259 onMouseOver : function(e){
2260 var t = this.findTargetItem(e);
2263 // if(t.canActivate && !t.disabled){
2264 // this.setActiveItem(t, true);
2268 this.fireEvent("mouseover", this, e, t);
2270 isVisible : function(){
2271 return !this.hidden;
2273 onMouseOut : function(e){
2274 var t = this.findTargetItem(e);
2277 // if(t == this.activeItem && t.shouldDeactivate(e)){
2278 // this.activeItem.deactivate();
2279 // delete this.activeItem;
2282 this.fireEvent("mouseout", this, e, t);
2287 * Displays this menu relative to another element
2288 * @param {String/HTMLElement/Roo.Element} element The element to align to
2289 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2290 * the element (defaults to this.defaultAlign)
2291 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2293 show : function(el, pos, parentMenu)
2295 if (false === this.fireEvent("beforeshow", this)) {
2296 Roo.log("show canceled");
2299 this.parentMenu = parentMenu;
2304 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2307 * Displays this menu at a specific xy position
2308 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2309 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2311 showAt : function(xy, parentMenu, /* private: */_e){
2312 this.parentMenu = parentMenu;
2317 this.fireEvent("beforeshow", this);
2318 //xy = this.el.adjustForConstraints(xy);
2322 this.hideMenuItems();
2323 this.hidden = false;
2324 this.triggerEl.addClass('open');
2325 this.el.addClass('show');
2327 // reassign x when hitting right
2328 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2329 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2332 // reassign y when hitting bottom
2333 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2334 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2337 // but the list may align on trigger left or trigger top... should it be a properity?
2339 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2344 this.fireEvent("show", this);
2350 this.doFocus.defer(50, this);
2354 doFocus : function(){
2356 this.focusEl.focus();
2361 * Hides this menu and optionally all parent menus
2362 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2364 hide : function(deep)
2366 if (false === this.fireEvent("beforehide", this)) {
2367 Roo.log("hide canceled");
2370 this.hideMenuItems();
2371 if(this.el && this.isVisible()){
2373 if(this.activeItem){
2374 this.activeItem.deactivate();
2375 this.activeItem = null;
2377 this.triggerEl.removeClass('open');;
2378 this.el.removeClass('show');
2380 this.fireEvent("hide", this);
2382 if(deep === true && this.parentMenu){
2383 this.parentMenu.hide(true);
2387 onTriggerClick : function(e)
2389 Roo.log('trigger click');
2391 var target = e.getTarget();
2393 Roo.log(target.nodeName.toLowerCase());
2395 if(target.nodeName.toLowerCase() === 'i'){
2401 onTriggerPress : function(e)
2403 Roo.log('trigger press');
2404 //Roo.log(e.getTarget());
2405 // Roo.log(this.triggerEl.dom);
2407 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2408 var pel = Roo.get(e.getTarget());
2409 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2410 Roo.log('is treeview or dropdown?');
2414 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2418 if (this.isVisible()) {
2423 this.show(this.triggerEl, '?', false);
2426 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2433 hideMenuItems : function()
2435 Roo.log("hide Menu Items");
2440 this.el.select('.open',true).each(function(aa) {
2442 aa.removeClass('open');
2446 addxtypeChild : function (tree, cntr) {
2447 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2449 this.menuitems.add(comp);
2461 this.getEl().dom.innerHTML = '';
2462 this.menuitems.clear();
2476 * @class Roo.bootstrap.MenuItem
2477 * @extends Roo.bootstrap.Component
2478 * Bootstrap MenuItem class
2479 * @cfg {String} html the menu label
2480 * @cfg {String} href the link
2481 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2482 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2483 * @cfg {Boolean} active used on sidebars to highlight active itesm
2484 * @cfg {String} fa favicon to show on left of menu item.
2485 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2489 * Create a new MenuItem
2490 * @param {Object} config The config object
2494 Roo.bootstrap.MenuItem = function(config){
2495 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2500 * The raw click event for the entire grid.
2501 * @param {Roo.bootstrap.MenuItem} this
2502 * @param {Roo.EventObject} e
2508 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2512 preventDefault: false,
2513 isContainer : false,
2517 getAutoCreate : function(){
2519 if(this.isContainer){
2522 cls: 'dropdown-menu-item '
2532 cls : 'dropdown-item',
2537 if (this.fa !== false) {
2540 cls : 'fa fa-' + this.fa
2549 cls: 'dropdown-menu-item',
2552 if (this.parent().type == 'treeview') {
2553 cfg.cls = 'treeview-menu';
2556 cfg.cls += ' active';
2561 anc.href = this.href || cfg.cn[0].href ;
2562 ctag.html = this.html || cfg.cn[0].html ;
2566 initEvents: function()
2568 if (this.parent().type == 'treeview') {
2569 this.el.select('a').on('click', this.onClick, this);
2573 this.menu.parentType = this.xtype;
2574 this.menu.triggerEl = this.el;
2575 this.menu = this.addxtype(Roo.apply({}, this.menu));
2579 onClick : function(e)
2581 Roo.log('item on click ');
2583 if(this.preventDefault){
2586 //this.parent().hideMenuItems();
2588 this.fireEvent('click', this, e);
2607 * @class Roo.bootstrap.MenuSeparator
2608 * @extends Roo.bootstrap.Component
2609 * Bootstrap MenuSeparator class
2612 * Create a new MenuItem
2613 * @param {Object} config The config object
2617 Roo.bootstrap.MenuSeparator = function(config){
2618 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2621 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2623 getAutoCreate : function(){
2642 * @class Roo.bootstrap.Modal
2643 * @extends Roo.bootstrap.Component
2644 * Bootstrap Modal class
2645 * @cfg {String} title Title of dialog
2646 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2647 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2648 * @cfg {Boolean} specificTitle default false
2649 * @cfg {Array} buttons Array of buttons or standard button set..
2650 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2651 * @cfg {Boolean} animate default true
2652 * @cfg {Boolean} allow_close default true
2653 * @cfg {Boolean} fitwindow default false
2654 * @cfg {String} size (sm|lg) default empty
2655 * @cfg {Number} max_width set the max width of modal
2659 * Create a new Modal Dialog
2660 * @param {Object} config The config object
2663 Roo.bootstrap.Modal = function(config){
2664 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2669 * The raw btnclick event for the button
2670 * @param {Roo.EventObject} e
2675 * Fire when dialog resize
2676 * @param {Roo.bootstrap.Modal} this
2677 * @param {Roo.EventObject} e
2681 this.buttons = this.buttons || [];
2684 this.tmpl = Roo.factory(this.tmpl);
2689 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2691 title : 'test dialog',
2701 specificTitle: false,
2703 buttonPosition: 'right',
2726 onRender : function(ct, position)
2728 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2731 var cfg = Roo.apply({}, this.getAutoCreate());
2734 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2736 //if (!cfg.name.length) {
2740 cfg.cls += ' ' + this.cls;
2743 cfg.style = this.style;
2745 this.el = Roo.get(document.body).createChild(cfg, position);
2747 //var type = this.el.dom.type;
2750 if(this.tabIndex !== undefined){
2751 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2754 this.dialogEl = this.el.select('.modal-dialog',true).first();
2755 this.bodyEl = this.el.select('.modal-body',true).first();
2756 this.closeEl = this.el.select('.modal-header .close', true).first();
2757 this.headerEl = this.el.select('.modal-header',true).first();
2758 this.titleEl = this.el.select('.modal-title',true).first();
2759 this.footerEl = this.el.select('.modal-footer',true).first();
2761 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2763 //this.el.addClass("x-dlg-modal");
2765 if (this.buttons.length) {
2766 Roo.each(this.buttons, function(bb) {
2767 var b = Roo.apply({}, bb);
2768 b.xns = b.xns || Roo.bootstrap;
2769 b.xtype = b.xtype || 'Button';
2770 if (typeof(b.listeners) == 'undefined') {
2771 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2774 var btn = Roo.factory(b);
2776 btn.render(this.getButtonContainer());
2780 // render the children.
2783 if(typeof(this.items) != 'undefined'){
2784 var items = this.items;
2787 for(var i =0;i < items.length;i++) {
2788 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2792 this.items = nitems;
2794 // where are these used - they used to be body/close/footer
2798 //this.el.addClass([this.fieldClass, this.cls]);
2802 getAutoCreate : function()
2806 html : this.html || ''
2811 cls : 'modal-title',
2815 if(this.specificTitle){
2821 if (this.allow_close && Roo.bootstrap.version == 3) {
2831 if (this.allow_close && Roo.bootstrap.version == 4) {
2841 if(this.size.length){
2842 size = 'modal-' + this.size;
2845 var footer = Roo.bootstrap.version == 3 ?
2847 cls : 'modal-footer',
2851 cls: 'btn-' + this.buttonPosition
2856 { // BS4 uses mr-auto on left buttons....
2857 cls : 'modal-footer'
2868 cls: "modal-dialog " + size,
2871 cls : "modal-content",
2874 cls : 'modal-header',
2889 modal.cls += ' fade';
2895 getChildContainer : function() {
2900 getButtonContainer : function() {
2902 return Roo.bootstrap.version == 4 ?
2903 this.el.select('.modal-footer',true).first()
2904 : this.el.select('.modal-footer div',true).first();
2907 initEvents : function()
2909 if (this.allow_close) {
2910 this.closeEl.on('click', this.hide, this);
2912 Roo.EventManager.onWindowResize(this.resize, this, true);
2920 this.maskEl.setSize(
2921 Roo.lib.Dom.getViewWidth(true),
2922 Roo.lib.Dom.getViewHeight(true)
2925 if (this.fitwindow) {
2929 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2930 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2935 if(this.max_width !== 0) {
2937 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2940 this.setSize(w, this.height);
2944 if(this.max_height) {
2945 this.setSize(w,Math.min(
2947 Roo.lib.Dom.getViewportHeight(true) - 60
2953 if(!this.fit_content) {
2954 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2958 this.setSize(w, Math.min(
2960 this.headerEl.getHeight() +
2961 this.footerEl.getHeight() +
2962 this.getChildHeight(this.bodyEl.dom.childNodes),
2963 Roo.lib.Dom.getViewportHeight(true) - 60)
2969 setSize : function(w,h)
2980 if (!this.rendered) {
2984 //this.el.setStyle('display', 'block');
2985 this.el.removeClass('hideing');
2986 this.el.dom.style.display='block';
2988 Roo.get(document.body).addClass('modal-open');
2990 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2993 this.el.addClass('show');
2994 this.el.addClass('in');
2997 this.el.addClass('show');
2998 this.el.addClass('in');
3001 // not sure how we can show data in here..
3003 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3006 Roo.get(document.body).addClass("x-body-masked");
3008 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3009 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3010 this.maskEl.dom.style.display = 'block';
3011 this.maskEl.addClass('show');
3016 this.fireEvent('show', this);
3018 // set zindex here - otherwise it appears to be ignored...
3019 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3022 this.items.forEach( function(e) {
3023 e.layout ? e.layout() : false;
3031 if(this.fireEvent("beforehide", this) !== false){
3033 this.maskEl.removeClass('show');
3035 this.maskEl.dom.style.display = '';
3036 Roo.get(document.body).removeClass("x-body-masked");
3037 this.el.removeClass('in');
3038 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3040 if(this.animate){ // why
3041 this.el.addClass('hideing');
3042 this.el.removeClass('show');
3044 if (!this.el.hasClass('hideing')) {
3045 return; // it's been shown again...
3048 this.el.dom.style.display='';
3050 Roo.get(document.body).removeClass('modal-open');
3051 this.el.removeClass('hideing');
3055 this.el.removeClass('show');
3056 this.el.dom.style.display='';
3057 Roo.get(document.body).removeClass('modal-open');
3060 this.fireEvent('hide', this);
3063 isVisible : function()
3066 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3070 addButton : function(str, cb)
3074 var b = Roo.apply({}, { html : str } );
3075 b.xns = b.xns || Roo.bootstrap;
3076 b.xtype = b.xtype || 'Button';
3077 if (typeof(b.listeners) == 'undefined') {
3078 b.listeners = { click : cb.createDelegate(this) };
3081 var btn = Roo.factory(b);
3083 btn.render(this.getButtonContainer());
3089 setDefaultButton : function(btn)
3091 //this.el.select('.modal-footer').()
3094 resizeTo: function(w,h)
3096 this.dialogEl.setWidth(w);
3098 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3100 this.bodyEl.setHeight(h - diff);
3102 this.fireEvent('resize', this);
3105 setContentSize : function(w, h)
3109 onButtonClick: function(btn,e)
3112 this.fireEvent('btnclick', btn.name, e);
3115 * Set the title of the Dialog
3116 * @param {String} str new Title
3118 setTitle: function(str) {
3119 this.titleEl.dom.innerHTML = str;
3122 * Set the body of the Dialog
3123 * @param {String} str new Title
3125 setBody: function(str) {
3126 this.bodyEl.dom.innerHTML = str;
3129 * Set the body of the Dialog using the template
3130 * @param {Obj} data - apply this data to the template and replace the body contents.
3132 applyBody: function(obj)
3135 Roo.log("Error - using apply Body without a template");
3138 this.tmpl.overwrite(this.bodyEl, obj);
3141 getChildHeight : function(child_nodes)
3145 child_nodes.length == 0
3150 var child_height = 0;
3152 for(var i = 0; i < child_nodes.length; i++) {
3155 * for modal with tabs...
3156 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3158 var layout_childs = child_nodes[i].childNodes;
3160 for(var j = 0; j < layout_childs.length; j++) {
3162 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3164 var layout_body_childs = layout_childs[j].childNodes;
3166 for(var k = 0; k < layout_body_childs.length; k++) {
3168 if(layout_body_childs[k].classList.contains('navbar')) {
3169 child_height += layout_body_childs[k].offsetHeight;
3173 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3175 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3177 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3179 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3180 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3195 child_height += child_nodes[i].offsetHeight;
3196 // Roo.log(child_nodes[i].offsetHeight);
3199 return child_height;
3205 Roo.apply(Roo.bootstrap.Modal, {
3207 * Button config that displays a single OK button
3216 * Button config that displays Yes and No buttons
3232 * Button config that displays OK and Cancel buttons
3247 * Button config that displays Yes, No and Cancel buttons
3271 * messagebox - can be used as a replace
3275 * @class Roo.MessageBox
3276 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3280 Roo.Msg.alert('Status', 'Changes saved successfully.');
3282 // Prompt for user data:
3283 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3285 // process text value...
3289 // Show a dialog using config options:
3291 title:'Save Changes?',
3292 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3293 buttons: Roo.Msg.YESNOCANCEL,
3300 Roo.bootstrap.MessageBox = function(){
3301 var dlg, opt, mask, waitTimer;
3302 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3303 var buttons, activeTextEl, bwidth;
3307 var handleButton = function(button){
3309 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3313 var handleHide = function(){
3315 dlg.el.removeClass(opt.cls);
3318 // Roo.TaskMgr.stop(waitTimer);
3319 // waitTimer = null;
3324 var updateButtons = function(b){
3327 buttons["ok"].hide();
3328 buttons["cancel"].hide();
3329 buttons["yes"].hide();
3330 buttons["no"].hide();
3331 dlg.footerEl.hide();
3335 dlg.footerEl.show();
3336 for(var k in buttons){
3337 if(typeof buttons[k] != "function"){
3340 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3341 width += buttons[k].el.getWidth()+15;
3351 var handleEsc = function(d, k, e){
3352 if(opt && opt.closable !== false){
3362 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3363 * @return {Roo.BasicDialog} The BasicDialog element
3365 getDialog : function(){
3367 dlg = new Roo.bootstrap.Modal( {
3370 //constraintoviewport:false,
3372 //collapsible : false,
3377 //buttonAlign:"center",
3378 closeClick : function(){
3379 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3382 handleButton("cancel");
3387 dlg.on("hide", handleHide);
3389 //dlg.addKeyListener(27, handleEsc);
3391 this.buttons = buttons;
3392 var bt = this.buttonText;
3393 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3394 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3395 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3396 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3398 bodyEl = dlg.bodyEl.createChild({
3400 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3401 '<textarea class="roo-mb-textarea"></textarea>' +
3402 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3404 msgEl = bodyEl.dom.firstChild;
3405 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3406 textboxEl.enableDisplayMode();
3407 textboxEl.addKeyListener([10,13], function(){
3408 if(dlg.isVisible() && opt && opt.buttons){
3411 }else if(opt.buttons.yes){
3412 handleButton("yes");
3416 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3417 textareaEl.enableDisplayMode();
3418 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3419 progressEl.enableDisplayMode();
3421 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3422 var pf = progressEl.dom.firstChild;
3424 pp = Roo.get(pf.firstChild);
3425 pp.setHeight(pf.offsetHeight);
3433 * Updates the message box body text
3434 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3435 * the XHTML-compliant non-breaking space character '&#160;')
3436 * @return {Roo.MessageBox} This message box
3438 updateText : function(text)
3440 if(!dlg.isVisible() && !opt.width){
3441 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3442 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3444 msgEl.innerHTML = text || ' ';
3446 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3447 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3449 Math.min(opt.width || cw , this.maxWidth),
3450 Math.max(opt.minWidth || this.minWidth, bwidth)
3453 activeTextEl.setWidth(w);
3455 if(dlg.isVisible()){
3456 dlg.fixedcenter = false;
3458 // to big, make it scroll. = But as usual stupid IE does not support
3461 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3462 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3463 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3465 bodyEl.dom.style.height = '';
3466 bodyEl.dom.style.overflowY = '';
3469 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3471 bodyEl.dom.style.overflowX = '';
3474 dlg.setContentSize(w, bodyEl.getHeight());
3475 if(dlg.isVisible()){
3476 dlg.fixedcenter = true;
3482 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3483 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3484 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3485 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3486 * @return {Roo.MessageBox} This message box
3488 updateProgress : function(value, text){
3490 this.updateText(text);
3493 if (pp) { // weird bug on my firefox - for some reason this is not defined
3494 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3495 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3501 * Returns true if the message box is currently displayed
3502 * @return {Boolean} True if the message box is visible, else false
3504 isVisible : function(){
3505 return dlg && dlg.isVisible();
3509 * Hides the message box if it is displayed
3512 if(this.isVisible()){
3518 * Displays a new message box, or reinitializes an existing message box, based on the config options
3519 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3520 * The following config object properties are supported:
3522 Property Type Description
3523 ---------- --------------- ------------------------------------------------------------------------------------
3524 animEl String/Element An id or Element from which the message box should animate as it opens and
3525 closes (defaults to undefined)
3526 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3527 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3528 closable Boolean False to hide the top-right close button (defaults to true). Note that
3529 progress and wait dialogs will ignore this property and always hide the
3530 close button as they can only be closed programmatically.
3531 cls String A custom CSS class to apply to the message box element
3532 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3533 displayed (defaults to 75)
3534 fn Function A callback function to execute after closing the dialog. The arguments to the
3535 function will be btn (the name of the button that was clicked, if applicable,
3536 e.g. "ok"), and text (the value of the active text field, if applicable).
3537 Progress and wait dialogs will ignore this option since they do not respond to
3538 user actions and can only be closed programmatically, so any required function
3539 should be called by the same code after it closes the dialog.
3540 icon String A CSS class that provides a background image to be used as an icon for
3541 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3542 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3543 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3544 modal Boolean False to allow user interaction with the page while the message box is
3545 displayed (defaults to true)
3546 msg String A string that will replace the existing message box body text (defaults
3547 to the XHTML-compliant non-breaking space character ' ')
3548 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3549 progress Boolean True to display a progress bar (defaults to false)
3550 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3551 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3552 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3553 title String The title text
3554 value String The string value to set into the active textbox element if displayed
3555 wait Boolean True to display a progress bar (defaults to false)
3556 width Number The width of the dialog in pixels
3563 msg: 'Please enter your address:',
3565 buttons: Roo.MessageBox.OKCANCEL,
3568 animEl: 'addAddressBtn'
3571 * @param {Object} config Configuration options
3572 * @return {Roo.MessageBox} This message box
3574 show : function(options)
3577 // this causes nightmares if you show one dialog after another
3578 // especially on callbacks..
3580 if(this.isVisible()){
3583 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3584 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3585 Roo.log("New Dialog Message:" + options.msg )
3586 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3587 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3590 var d = this.getDialog();
3592 d.setTitle(opt.title || " ");
3593 d.closeEl.setDisplayed(opt.closable !== false);
3594 activeTextEl = textboxEl;
3595 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3600 textareaEl.setHeight(typeof opt.multiline == "number" ?
3601 opt.multiline : this.defaultTextHeight);
3602 activeTextEl = textareaEl;
3611 progressEl.setDisplayed(opt.progress === true);
3613 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3615 this.updateProgress(0);
3616 activeTextEl.dom.value = opt.value || "";
3618 dlg.setDefaultButton(activeTextEl);
3620 var bs = opt.buttons;
3624 }else if(bs && bs.yes){
3625 db = buttons["yes"];
3627 dlg.setDefaultButton(db);
3629 bwidth = updateButtons(opt.buttons);
3630 this.updateText(opt.msg);
3632 d.el.addClass(opt.cls);
3634 d.proxyDrag = opt.proxyDrag === true;
3635 d.modal = opt.modal !== false;
3636 d.mask = opt.modal !== false ? mask : false;
3638 // force it to the end of the z-index stack so it gets a cursor in FF
3639 document.body.appendChild(dlg.el.dom);
3640 d.animateTarget = null;
3641 d.show(options.animEl);
3647 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3648 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3649 * and closing the message box when the process is complete.
3650 * @param {String} title The title bar text
3651 * @param {String} msg The message box body text
3652 * @return {Roo.MessageBox} This message box
3654 progress : function(title, msg){
3661 minWidth: this.minProgressWidth,
3668 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3669 * If a callback function is passed it will be called after the user clicks the button, and the
3670 * id of the button that was clicked will be passed as the only parameter to the callback
3671 * (could also be the top-right close button).
3672 * @param {String} title The title bar text
3673 * @param {String} msg The message box body text
3674 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3675 * @param {Object} scope (optional) The scope of the callback function
3676 * @return {Roo.MessageBox} This message box
3678 alert : function(title, msg, fn, scope)
3693 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3694 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3695 * You are responsible for closing the message box when the process is complete.
3696 * @param {String} msg The message box body text
3697 * @param {String} title (optional) The title bar text
3698 * @return {Roo.MessageBox} This message box
3700 wait : function(msg, title){
3711 waitTimer = Roo.TaskMgr.start({
3713 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3721 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3722 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3723 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3724 * @param {String} title The title bar text
3725 * @param {String} msg The message box body text
3726 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3727 * @param {Object} scope (optional) The scope of the callback function
3728 * @return {Roo.MessageBox} This message box
3730 confirm : function(title, msg, fn, scope){
3734 buttons: this.YESNO,
3743 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3744 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3745 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3746 * (could also be the top-right close button) and the text that was entered will be passed as the two
3747 * parameters to the callback.
3748 * @param {String} title The title bar text
3749 * @param {String} msg The message box body text
3750 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3751 * @param {Object} scope (optional) The scope of the callback function
3752 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3753 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3754 * @return {Roo.MessageBox} This message box
3756 prompt : function(title, msg, fn, scope, multiline){
3760 buttons: this.OKCANCEL,
3765 multiline: multiline,
3772 * Button config that displays a single OK button
3777 * Button config that displays Yes and No buttons
3780 YESNO : {yes:true, no:true},
3782 * Button config that displays OK and Cancel buttons
3785 OKCANCEL : {ok:true, cancel:true},
3787 * Button config that displays Yes, No and Cancel buttons
3790 YESNOCANCEL : {yes:true, no:true, cancel:true},
3793 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3796 defaultTextHeight : 75,
3798 * The maximum width in pixels of the message box (defaults to 600)
3803 * The minimum width in pixels of the message box (defaults to 100)
3808 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3809 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3812 minProgressWidth : 250,
3814 * An object containing the default button text strings that can be overriden for localized language support.
3815 * Supported properties are: ok, cancel, yes and no.
3816 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3829 * Shorthand for {@link Roo.MessageBox}
3831 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3832 Roo.Msg = Roo.Msg || Roo.MessageBox;
3841 * @class Roo.bootstrap.Navbar
3842 * @extends Roo.bootstrap.Component
3843 * Bootstrap Navbar class
3846 * Create a new Navbar
3847 * @param {Object} config The config object
3851 Roo.bootstrap.Navbar = function(config){
3852 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3856 * @event beforetoggle
3857 * Fire before toggle the menu
3858 * @param {Roo.EventObject} e
3860 "beforetoggle" : true
3864 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3873 getAutoCreate : function(){
3876 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3880 initEvents :function ()
3882 //Roo.log(this.el.select('.navbar-toggle',true));
3883 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
3890 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3892 var size = this.el.getSize();
3893 this.maskEl.setSize(size.width, size.height);
3894 this.maskEl.enableDisplayMode("block");
3903 getChildContainer : function()
3905 if (this.el && this.el.select('.collapse').getCount()) {
3906 return this.el.select('.collapse',true).first();
3921 onToggle : function()
3924 if(this.fireEvent('beforetoggle', this) === false){
3927 var ce = this.el.select('.roo-navbar-collapse',true).first();
3929 if (!ce.hasClass('show')) {
3939 * Expand the navbar pulldown
3941 expand : function ()
3944 var ce = this.el.select('.roo-navbar-collapse',true).first();
3945 if (ce.hasClass('collapsing')) {
3948 ce.dom.style.height = '';
3950 ce.addClass('in'); // old...
3951 ce.removeClass('collapse');
3952 ce.addClass('show');
3953 var h = ce.getHeight();
3955 ce.removeClass('show');
3956 // at this point we should be able to see it..
3957 ce.addClass('collapsing');
3959 ce.setHeight(0); // resize it ...
3960 ce.on('transitionend', function() {
3961 //Roo.log('done transition');
3962 ce.removeClass('collapsing');
3963 ce.addClass('show');
3964 ce.removeClass('collapse');
3966 ce.dom.style.height = '';
3967 }, this, { single: true} );
3969 ce.dom.scrollTop = 0;
3972 * Collapse the navbar pulldown
3974 collapse : function()
3976 var ce = this.el.select('.roo-navbar-collapse',true).first();
3978 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
3979 // it's collapsed or collapsing..
3982 ce.removeClass('in'); // old...
3983 ce.setHeight(ce.getHeight());
3984 ce.removeClass('show');
3985 ce.addClass('collapsing');
3987 ce.on('transitionend', function() {
3988 ce.dom.style.height = '';
3989 ce.removeClass('collapsing');
3990 ce.addClass('collapse');
3991 }, this, { single: true} );
4011 * @class Roo.bootstrap.NavSimplebar
4012 * @extends Roo.bootstrap.Navbar
4013 * Bootstrap Sidebar class
4015 * @cfg {Boolean} inverse is inverted color
4017 * @cfg {String} type (nav | pills | tabs)
4018 * @cfg {Boolean} arrangement stacked | justified
4019 * @cfg {String} align (left | right) alignment
4021 * @cfg {Boolean} main (true|false) main nav bar? default false
4022 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
4024 * @cfg {String} tag (header|footer|nav|div) default is nav
4026 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
4030 * Create a new Sidebar
4031 * @param {Object} config The config object
4035 Roo.bootstrap.NavSimplebar = function(config){
4036 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4039 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4055 getAutoCreate : function(){
4059 tag : this.tag || 'div',
4060 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4062 if (['light','white'].indexOf(this.weight) > -1) {
4063 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4065 cfg.cls += ' bg-' + this.weight;
4068 cfg.cls += ' navbar-inverse';
4072 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4074 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
4083 cls: 'nav nav-' + this.xtype,
4089 this.type = this.type || 'nav';
4090 if (['tabs','pills'].indexOf(this.type) != -1) {
4091 cfg.cn[0].cls += ' nav-' + this.type
4095 if (this.type!=='nav') {
4096 Roo.log('nav type must be nav/tabs/pills')
4098 cfg.cn[0].cls += ' navbar-nav'
4104 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4105 cfg.cn[0].cls += ' nav-' + this.arrangement;
4109 if (this.align === 'right') {
4110 cfg.cn[0].cls += ' navbar-right';
4135 * navbar-expand-md fixed-top
4139 * @class Roo.bootstrap.NavHeaderbar
4140 * @extends Roo.bootstrap.NavSimplebar
4141 * Bootstrap Sidebar class
4143 * @cfg {String} brand what is brand
4144 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4145 * @cfg {String} brand_href href of the brand
4146 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4147 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4148 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4149 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4152 * Create a new Sidebar
4153 * @param {Object} config The config object
4157 Roo.bootstrap.NavHeaderbar = function(config){
4158 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4162 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4169 desktopCenter : false,
4172 getAutoCreate : function(){
4175 tag: this.nav || 'nav',
4176 cls: 'navbar navbar-expand-md',
4182 if (this.desktopCenter) {
4183 cn.push({cls : 'container', cn : []});
4191 cls: 'navbar-toggle navbar-toggler',
4192 'data-toggle': 'collapse',
4197 html: 'Toggle navigation'
4201 cls: 'icon-bar navbar-toggler-icon'
4214 cn.push( Roo.bootstrap.version == 4 ? btn : {
4216 cls: 'navbar-header',
4225 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
4229 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4231 if (['light','white'].indexOf(this.weight) > -1) {
4232 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4234 cfg.cls += ' bg-' + this.weight;
4237 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4238 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4240 // tag can override this..
4242 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4245 if (this.brand !== '') {
4246 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4247 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4249 href: this.brand_href ? this.brand_href : '#',
4250 cls: 'navbar-brand',
4258 cfg.cls += ' main-nav';
4266 getHeaderChildContainer : function()
4268 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4269 return this.el.select('.navbar-header',true).first();
4272 return this.getChildContainer();
4276 initEvents : function()
4278 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4280 if (this.autohide) {
4285 Roo.get(document).on('scroll',function(e) {
4286 var ns = Roo.get(document).getScroll().top;
4287 var os = prevScroll;
4291 ft.removeClass('slideDown');
4292 ft.addClass('slideUp');
4295 ft.removeClass('slideUp');
4296 ft.addClass('slideDown');
4317 * @class Roo.bootstrap.NavSidebar
4318 * @extends Roo.bootstrap.Navbar
4319 * Bootstrap Sidebar class
4322 * Create a new Sidebar
4323 * @param {Object} config The config object
4327 Roo.bootstrap.NavSidebar = function(config){
4328 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4331 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4333 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4335 getAutoCreate : function(){
4340 cls: 'sidebar sidebar-nav'
4362 * @class Roo.bootstrap.NavGroup
4363 * @extends Roo.bootstrap.Component
4364 * Bootstrap NavGroup class
4365 * @cfg {String} align (left|right)
4366 * @cfg {Boolean} inverse
4367 * @cfg {String} type (nav|pills|tab) default nav
4368 * @cfg {String} navId - reference Id for navbar.
4372 * Create a new nav group
4373 * @param {Object} config The config object
4376 Roo.bootstrap.NavGroup = function(config){
4377 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4380 Roo.bootstrap.NavGroup.register(this);
4384 * Fires when the active item changes
4385 * @param {Roo.bootstrap.NavGroup} this
4386 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4387 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4394 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4405 getAutoCreate : function()
4407 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4413 if (Roo.bootstrap.version == 4) {
4414 if (['tabs','pills'].indexOf(this.type) != -1) {
4415 cfg.cls += ' nav-' + this.type;
4417 cfg.cls += ' navbar-nav';
4420 if (['tabs','pills'].indexOf(this.type) != -1) {
4421 cfg.cls += ' nav-' + this.type
4423 if (this.type !== 'nav') {
4424 Roo.log('nav type must be nav/tabs/pills')
4426 cfg.cls += ' navbar-nav'
4430 if (this.parent() && this.parent().sidebar) {
4433 cls: 'dashboard-menu sidebar-menu'
4439 if (this.form === true) {
4442 cls: 'navbar-form form-inline'
4445 if (this.align === 'right') {
4446 cfg.cls += ' navbar-right ml-md-auto';
4448 cfg.cls += ' navbar-left';
4452 if (this.align === 'right') {
4453 cfg.cls += ' navbar-right ml-md-auto';
4455 cfg.cls += ' mr-auto';
4459 cfg.cls += ' navbar-inverse';
4467 * sets the active Navigation item
4468 * @param {Roo.bootstrap.NavItem} the new current navitem
4470 setActiveItem : function(item)
4473 Roo.each(this.navItems, function(v){
4478 v.setActive(false, true);
4485 item.setActive(true, true);
4486 this.fireEvent('changed', this, item, prev);
4491 * gets the active Navigation item
4492 * @return {Roo.bootstrap.NavItem} the current navitem
4494 getActive : function()
4498 Roo.each(this.navItems, function(v){
4509 indexOfNav : function()
4513 Roo.each(this.navItems, function(v,i){
4524 * adds a Navigation item
4525 * @param {Roo.bootstrap.NavItem} the navitem to add
4527 addItem : function(cfg)
4529 if (this.form && Roo.bootstrap.version == 4) {
4532 var cn = new Roo.bootstrap.NavItem(cfg);
4534 cn.parentId = this.id;
4535 cn.onRender(this.el, null);
4539 * register a Navigation item
4540 * @param {Roo.bootstrap.NavItem} the navitem to add
4542 register : function(item)
4544 this.navItems.push( item);
4545 item.navId = this.navId;
4550 * clear all the Navigation item
4553 clearAll : function()
4556 this.el.dom.innerHTML = '';
4559 getNavItem: function(tabId)
4562 Roo.each(this.navItems, function(e) {
4563 if (e.tabId == tabId) {
4573 setActiveNext : function()
4575 var i = this.indexOfNav(this.getActive());
4576 if (i > this.navItems.length) {
4579 this.setActiveItem(this.navItems[i+1]);
4581 setActivePrev : function()
4583 var i = this.indexOfNav(this.getActive());
4587 this.setActiveItem(this.navItems[i-1]);
4589 clearWasActive : function(except) {
4590 Roo.each(this.navItems, function(e) {
4591 if (e.tabId != except.tabId && e.was_active) {
4592 e.was_active = false;
4599 getWasActive : function ()
4602 Roo.each(this.navItems, function(e) {
4617 Roo.apply(Roo.bootstrap.NavGroup, {
4621 * register a Navigation Group
4622 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4624 register : function(navgrp)
4626 this.groups[navgrp.navId] = navgrp;
4630 * fetch a Navigation Group based on the navigation ID
4631 * @param {string} the navgroup to add
4632 * @returns {Roo.bootstrap.NavGroup} the navgroup
4634 get: function(navId) {
4635 if (typeof(this.groups[navId]) == 'undefined') {
4637 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4639 return this.groups[navId] ;
4654 * @class Roo.bootstrap.NavItem
4655 * @extends Roo.bootstrap.Component
4656 * Bootstrap Navbar.NavItem class
4657 * @cfg {String} href link to
4658 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4660 * @cfg {String} html content of button
4661 * @cfg {String} badge text inside badge
4662 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4663 * @cfg {String} glyphicon DEPRICATED - use fa
4664 * @cfg {String} icon DEPRICATED - use fa
4665 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4666 * @cfg {Boolean} active Is item active
4667 * @cfg {Boolean} disabled Is item disabled
4669 * @cfg {Boolean} preventDefault (true | false) default false
4670 * @cfg {String} tabId the tab that this item activates.
4671 * @cfg {String} tagtype (a|span) render as a href or span?
4672 * @cfg {Boolean} animateRef (true|false) link to element default false
4675 * Create a new Navbar Item
4676 * @param {Object} config The config object
4678 Roo.bootstrap.NavItem = function(config){
4679 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4684 * The raw click event for the entire grid.
4685 * @param {Roo.EventObject} e
4690 * Fires when the active item active state changes
4691 * @param {Roo.bootstrap.NavItem} this
4692 * @param {boolean} state the new state
4698 * Fires when scroll to element
4699 * @param {Roo.bootstrap.NavItem} this
4700 * @param {Object} options
4701 * @param {Roo.EventObject} e
4709 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4718 preventDefault : false,
4726 button_outline : false,
4730 getAutoCreate : function(){
4738 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4740 if (this.disabled) {
4741 cfg.cls += ' disabled';
4745 if (this.button_weight.length) {
4746 cfg.tag = this.href ? 'a' : 'button';
4747 cfg.html = this.html || '';
4748 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4750 cfg.href = this.href;
4753 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4756 // menu .. should add dropdown-menu class - so no need for carat..
4758 if (this.badge !== '') {
4760 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4765 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4769 href : this.href || "#",
4770 html: this.html || ''
4773 if (this.tagtype == 'a') {
4774 cfg.cn[0].cls = 'nav-link';
4777 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4780 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4782 if(this.glyphicon) {
4783 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4788 cfg.cn[0].html += " <span class='caret'></span>";
4792 if (this.badge !== '') {
4794 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4802 onRender : function(ct, position)
4804 // Roo.log("Call onRender: " + this.xtype);
4805 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4809 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4810 this.navLink = this.el.select('.nav-link',true).first();
4815 initEvents: function()
4817 if (typeof (this.menu) != 'undefined') {
4818 this.menu.parentType = this.xtype;
4819 this.menu.triggerEl = this.el;
4820 this.menu = this.addxtype(Roo.apply({}, this.menu));
4823 this.el.select('a',true).on('click', this.onClick, this);
4825 if(this.tagtype == 'span'){
4826 this.el.select('span',true).on('click', this.onClick, this);
4829 // at this point parent should be available..
4830 this.parent().register(this);
4833 onClick : function(e)
4835 if (e.getTarget('.dropdown-menu-item')) {
4836 // did you click on a menu itemm.... - then don't trigger onclick..
4841 this.preventDefault ||
4844 Roo.log("NavItem - prevent Default?");
4848 if (this.disabled) {
4852 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4853 if (tg && tg.transition) {
4854 Roo.log("waiting for the transitionend");
4860 //Roo.log("fire event clicked");
4861 if(this.fireEvent('click', this, e) === false){
4865 if(this.tagtype == 'span'){
4869 //Roo.log(this.href);
4870 var ael = this.el.select('a',true).first();
4873 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4874 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4875 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4876 return; // ignore... - it's a 'hash' to another page.
4878 Roo.log("NavItem - prevent Default?");
4880 this.scrollToElement(e);
4884 var p = this.parent();
4886 if (['tabs','pills'].indexOf(p.type)!==-1) {
4887 if (typeof(p.setActiveItem) !== 'undefined') {
4888 p.setActiveItem(this);
4892 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4893 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4894 // remove the collapsed menu expand...
4895 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
4899 isActive: function () {
4902 setActive : function(state, fire, is_was_active)
4904 if (this.active && !state && this.navId) {
4905 this.was_active = true;
4906 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4908 nv.clearWasActive(this);
4912 this.active = state;
4915 this.el.removeClass('active');
4916 this.navLink ? this.navLink.removeClass('active') : false;
4917 } else if (!this.el.hasClass('active')) {
4919 this.el.addClass('active');
4920 if (Roo.bootstrap.version == 4 && this.navLink ) {
4921 this.navLink.addClass('active');
4926 this.fireEvent('changed', this, state);
4929 // show a panel if it's registered and related..
4931 if (!this.navId || !this.tabId || !state || is_was_active) {
4935 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4939 var pan = tg.getPanelByName(this.tabId);
4943 // if we can not flip to new panel - go back to old nav highlight..
4944 if (false == tg.showPanel(pan)) {
4945 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4947 var onav = nv.getWasActive();
4949 onav.setActive(true, false, true);
4958 // this should not be here...
4959 setDisabled : function(state)
4961 this.disabled = state;
4963 this.el.removeClass('disabled');
4964 } else if (!this.el.hasClass('disabled')) {
4965 this.el.addClass('disabled');
4971 * Fetch the element to display the tooltip on.
4972 * @return {Roo.Element} defaults to this.el
4974 tooltipEl : function()
4976 return this.el.select('' + this.tagtype + '', true).first();
4979 scrollToElement : function(e)
4981 var c = document.body;
4984 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4986 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4987 c = document.documentElement;
4990 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4996 var o = target.calcOffsetsTo(c);
5003 this.fireEvent('scrollto', this, options, e);
5005 Roo.get(c).scrollTo('top', options.value, true);
5018 * <span> icon </span>
5019 * <span> text </span>
5020 * <span>badge </span>
5024 * @class Roo.bootstrap.NavSidebarItem
5025 * @extends Roo.bootstrap.NavItem
5026 * Bootstrap Navbar.NavSidebarItem class
5027 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
5028 * {Boolean} open is the menu open
5029 * {Boolean} buttonView use button as the tigger el rather that a (default false)
5030 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
5031 * {String} buttonSize (sm|md|lg)the extra classes for the button
5032 * {Boolean} showArrow show arrow next to the text (default true)
5034 * Create a new Navbar Button
5035 * @param {Object} config The config object
5037 Roo.bootstrap.NavSidebarItem = function(config){
5038 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5043 * The raw click event for the entire grid.
5044 * @param {Roo.EventObject} e
5049 * Fires when the active item active state changes
5050 * @param {Roo.bootstrap.NavSidebarItem} this
5051 * @param {boolean} state the new state
5059 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5061 badgeWeight : 'default',
5067 buttonWeight : 'default',
5073 getAutoCreate : function(){
5078 href : this.href || '#',
5084 if(this.buttonView){
5087 href : this.href || '#',
5088 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5101 cfg.cls += ' active';
5104 if (this.disabled) {
5105 cfg.cls += ' disabled';
5108 cfg.cls += ' open x-open';
5111 if (this.glyphicon || this.icon) {
5112 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5113 a.cn.push({ tag : 'i', cls : c }) ;
5116 if(!this.buttonView){
5119 html : this.html || ''
5126 if (this.badge !== '') {
5127 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5133 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5136 a.cls += ' dropdown-toggle treeview' ;
5142 initEvents : function()
5144 if (typeof (this.menu) != 'undefined') {
5145 this.menu.parentType = this.xtype;
5146 this.menu.triggerEl = this.el;
5147 this.menu = this.addxtype(Roo.apply({}, this.menu));
5150 this.el.on('click', this.onClick, this);
5152 if(this.badge !== ''){
5153 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5158 onClick : function(e)
5165 if(this.preventDefault){
5169 this.fireEvent('click', this, e);
5172 disable : function()
5174 this.setDisabled(true);
5179 this.setDisabled(false);
5182 setDisabled : function(state)
5184 if(this.disabled == state){
5188 this.disabled = state;
5191 this.el.addClass('disabled');
5195 this.el.removeClass('disabled');
5200 setActive : function(state)
5202 if(this.active == state){
5206 this.active = state;
5209 this.el.addClass('active');
5213 this.el.removeClass('active');
5218 isActive: function ()
5223 setBadge : function(str)
5229 this.badgeEl.dom.innerHTML = str;
5246 * @class Roo.bootstrap.Row
5247 * @extends Roo.bootstrap.Component
5248 * Bootstrap Row class (contains columns...)
5252 * @param {Object} config The config object
5255 Roo.bootstrap.Row = function(config){
5256 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5259 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5261 getAutoCreate : function(){
5280 * @class Roo.bootstrap.Element
5281 * @extends Roo.bootstrap.Component
5282 * Bootstrap Element class
5283 * @cfg {String} html contents of the element
5284 * @cfg {String} tag tag of the element
5285 * @cfg {String} cls class of the element
5286 * @cfg {Boolean} preventDefault (true|false) default false
5287 * @cfg {Boolean} clickable (true|false) default false
5290 * Create a new Element
5291 * @param {Object} config The config object
5294 Roo.bootstrap.Element = function(config){
5295 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5301 * When a element is chick
5302 * @param {Roo.bootstrap.Element} this
5303 * @param {Roo.EventObject} e
5309 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5314 preventDefault: false,
5317 getAutoCreate : function(){
5321 // cls: this.cls, double assign in parent class Component.js :: onRender
5328 initEvents: function()
5330 Roo.bootstrap.Element.superclass.initEvents.call(this);
5333 this.el.on('click', this.onClick, this);
5338 onClick : function(e)
5340 if(this.preventDefault){
5344 this.fireEvent('click', this, e);
5347 getValue : function()
5349 return this.el.dom.innerHTML;
5352 setValue : function(value)
5354 this.el.dom.innerHTML = value;
5369 * @class Roo.bootstrap.Pagination
5370 * @extends Roo.bootstrap.Component
5371 * Bootstrap Pagination class
5372 * @cfg {String} size xs | sm | md | lg
5373 * @cfg {Boolean} inverse false | true
5376 * Create a new Pagination
5377 * @param {Object} config The config object
5380 Roo.bootstrap.Pagination = function(config){
5381 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5384 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5390 getAutoCreate : function(){
5396 cfg.cls += ' inverse';
5402 cfg.cls += " " + this.cls;
5420 * @class Roo.bootstrap.PaginationItem
5421 * @extends Roo.bootstrap.Component
5422 * Bootstrap PaginationItem class
5423 * @cfg {String} html text
5424 * @cfg {String} href the link
5425 * @cfg {Boolean} preventDefault (true | false) default true
5426 * @cfg {Boolean} active (true | false) default false
5427 * @cfg {Boolean} disabled default false
5431 * Create a new PaginationItem
5432 * @param {Object} config The config object
5436 Roo.bootstrap.PaginationItem = function(config){
5437 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5442 * The raw click event for the entire grid.
5443 * @param {Roo.EventObject} e
5449 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5453 preventDefault: true,
5458 getAutoCreate : function(){
5464 href : this.href ? this.href : '#',
5465 html : this.html ? this.html : ''
5475 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5479 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5485 initEvents: function() {
5487 this.el.on('click', this.onClick, this);
5490 onClick : function(e)
5492 Roo.log('PaginationItem on click ');
5493 if(this.preventDefault){
5501 this.fireEvent('click', this, e);
5517 * @class Roo.bootstrap.Slider
5518 * @extends Roo.bootstrap.Component
5519 * Bootstrap Slider class
5522 * Create a new Slider
5523 * @param {Object} config The config object
5526 Roo.bootstrap.Slider = function(config){
5527 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5530 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5532 getAutoCreate : function(){
5536 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5540 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5552 * Ext JS Library 1.1.1
5553 * Copyright(c) 2006-2007, Ext JS, LLC.
5555 * Originally Released Under LGPL - original licence link has changed is not relivant.
5558 * <script type="text/javascript">
5563 * @class Roo.grid.ColumnModel
5564 * @extends Roo.util.Observable
5565 * This is the default implementation of a ColumnModel used by the Grid. It defines
5566 * the columns in the grid.
5569 var colModel = new Roo.grid.ColumnModel([
5570 {header: "Ticker", width: 60, sortable: true, locked: true},
5571 {header: "Company Name", width: 150, sortable: true},
5572 {header: "Market Cap.", width: 100, sortable: true},
5573 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5574 {header: "Employees", width: 100, sortable: true, resizable: false}
5579 * The config options listed for this class are options which may appear in each
5580 * individual column definition.
5581 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5583 * @param {Object} config An Array of column config objects. See this class's
5584 * config objects for details.
5586 Roo.grid.ColumnModel = function(config){
5588 * The config passed into the constructor
5590 this.config = config;
5593 // if no id, create one
5594 // if the column does not have a dataIndex mapping,
5595 // map it to the order it is in the config
5596 for(var i = 0, len = config.length; i < len; i++){
5598 if(typeof c.dataIndex == "undefined"){
5601 if(typeof c.renderer == "string"){
5602 c.renderer = Roo.util.Format[c.renderer];
5604 if(typeof c.id == "undefined"){
5607 if(c.editor && c.editor.xtype){
5608 c.editor = Roo.factory(c.editor, Roo.grid);
5610 if(c.editor && c.editor.isFormField){
5611 c.editor = new Roo.grid.GridEditor(c.editor);
5613 this.lookup[c.id] = c;
5617 * The width of columns which have no width specified (defaults to 100)
5620 this.defaultWidth = 100;
5623 * Default sortable of columns which have no sortable specified (defaults to false)
5626 this.defaultSortable = false;
5630 * @event widthchange
5631 * Fires when the width of a column changes.
5632 * @param {ColumnModel} this
5633 * @param {Number} columnIndex The column index
5634 * @param {Number} newWidth The new width
5636 "widthchange": true,
5638 * @event headerchange
5639 * Fires when the text of a header changes.
5640 * @param {ColumnModel} this
5641 * @param {Number} columnIndex The column index
5642 * @param {Number} newText The new header text
5644 "headerchange": true,
5646 * @event hiddenchange
5647 * Fires when a column is hidden or "unhidden".
5648 * @param {ColumnModel} this
5649 * @param {Number} columnIndex The column index
5650 * @param {Boolean} hidden true if hidden, false otherwise
5652 "hiddenchange": true,
5654 * @event columnmoved
5655 * Fires when a column is moved.
5656 * @param {ColumnModel} this
5657 * @param {Number} oldIndex
5658 * @param {Number} newIndex
5660 "columnmoved" : true,
5662 * @event columlockchange
5663 * Fires when a column's locked state is changed
5664 * @param {ColumnModel} this
5665 * @param {Number} colIndex
5666 * @param {Boolean} locked true if locked
5668 "columnlockchange" : true
5670 Roo.grid.ColumnModel.superclass.constructor.call(this);
5672 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5674 * @cfg {String} header The header text to display in the Grid view.
5677 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5678 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5679 * specified, the column's index is used as an index into the Record's data Array.
5682 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5683 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5686 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5687 * Defaults to the value of the {@link #defaultSortable} property.
5688 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5691 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5694 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5697 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5700 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5703 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5704 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5705 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5706 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5709 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5712 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5715 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5718 * @cfg {String} cursor (Optional)
5721 * @cfg {String} tooltip (Optional)
5724 * @cfg {Number} xs (Optional)
5727 * @cfg {Number} sm (Optional)
5730 * @cfg {Number} md (Optional)
5733 * @cfg {Number} lg (Optional)
5736 * Returns the id of the column at the specified index.
5737 * @param {Number} index The column index
5738 * @return {String} the id
5740 getColumnId : function(index){
5741 return this.config[index].id;
5745 * Returns the column for a specified id.
5746 * @param {String} id The column id
5747 * @return {Object} the column
5749 getColumnById : function(id){
5750 return this.lookup[id];
5755 * Returns the column for a specified dataIndex.
5756 * @param {String} dataIndex The column dataIndex
5757 * @return {Object|Boolean} the column or false if not found
5759 getColumnByDataIndex: function(dataIndex){
5760 var index = this.findColumnIndex(dataIndex);
5761 return index > -1 ? this.config[index] : false;
5765 * Returns the index for a specified column id.
5766 * @param {String} id The column id
5767 * @return {Number} the index, or -1 if not found
5769 getIndexById : function(id){
5770 for(var i = 0, len = this.config.length; i < len; i++){
5771 if(this.config[i].id == id){
5779 * Returns the index for a specified column dataIndex.
5780 * @param {String} dataIndex The column dataIndex
5781 * @return {Number} the index, or -1 if not found
5784 findColumnIndex : function(dataIndex){
5785 for(var i = 0, len = this.config.length; i < len; i++){
5786 if(this.config[i].dataIndex == dataIndex){
5794 moveColumn : function(oldIndex, newIndex){
5795 var c = this.config[oldIndex];
5796 this.config.splice(oldIndex, 1);
5797 this.config.splice(newIndex, 0, c);
5798 this.dataMap = null;
5799 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5802 isLocked : function(colIndex){
5803 return this.config[colIndex].locked === true;
5806 setLocked : function(colIndex, value, suppressEvent){
5807 if(this.isLocked(colIndex) == value){
5810 this.config[colIndex].locked = value;
5812 this.fireEvent("columnlockchange", this, colIndex, value);
5816 getTotalLockedWidth : function(){
5818 for(var i = 0; i < this.config.length; i++){
5819 if(this.isLocked(i) && !this.isHidden(i)){
5820 this.totalWidth += this.getColumnWidth(i);
5826 getLockedCount : function(){
5827 for(var i = 0, len = this.config.length; i < len; i++){
5828 if(!this.isLocked(i)){
5833 return this.config.length;
5837 * Returns the number of columns.
5840 getColumnCount : function(visibleOnly){
5841 if(visibleOnly === true){
5843 for(var i = 0, len = this.config.length; i < len; i++){
5844 if(!this.isHidden(i)){
5850 return this.config.length;
5854 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5855 * @param {Function} fn
5856 * @param {Object} scope (optional)
5857 * @return {Array} result
5859 getColumnsBy : function(fn, scope){
5861 for(var i = 0, len = this.config.length; i < len; i++){
5862 var c = this.config[i];
5863 if(fn.call(scope||this, c, i) === true){
5871 * Returns true if the specified column is sortable.
5872 * @param {Number} col The column index
5875 isSortable : function(col){
5876 if(typeof this.config[col].sortable == "undefined"){
5877 return this.defaultSortable;
5879 return this.config[col].sortable;
5883 * Returns the rendering (formatting) function defined for the column.
5884 * @param {Number} col The column index.
5885 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5887 getRenderer : function(col){
5888 if(!this.config[col].renderer){
5889 return Roo.grid.ColumnModel.defaultRenderer;
5891 return this.config[col].renderer;
5895 * Sets the rendering (formatting) function for a column.
5896 * @param {Number} col The column index
5897 * @param {Function} fn The function to use to process the cell's raw data
5898 * to return HTML markup for the grid view. The render function is called with
5899 * the following parameters:<ul>
5900 * <li>Data value.</li>
5901 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5902 * <li>css A CSS style string to apply to the table cell.</li>
5903 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5904 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5905 * <li>Row index</li>
5906 * <li>Column index</li>
5907 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5909 setRenderer : function(col, fn){
5910 this.config[col].renderer = fn;
5914 * Returns the width for the specified column.
5915 * @param {Number} col The column index
5918 getColumnWidth : function(col){
5919 return this.config[col].width * 1 || this.defaultWidth;
5923 * Sets the width for a column.
5924 * @param {Number} col The column index
5925 * @param {Number} width The new width
5927 setColumnWidth : function(col, width, suppressEvent){
5928 this.config[col].width = width;
5929 this.totalWidth = null;
5931 this.fireEvent("widthchange", this, col, width);
5936 * Returns the total width of all columns.
5937 * @param {Boolean} includeHidden True to include hidden column widths
5940 getTotalWidth : function(includeHidden){
5941 if(!this.totalWidth){
5942 this.totalWidth = 0;
5943 for(var i = 0, len = this.config.length; i < len; i++){
5944 if(includeHidden || !this.isHidden(i)){
5945 this.totalWidth += this.getColumnWidth(i);
5949 return this.totalWidth;
5953 * Returns the header for the specified column.
5954 * @param {Number} col The column index
5957 getColumnHeader : function(col){
5958 return this.config[col].header;
5962 * Sets the header for a column.
5963 * @param {Number} col The column index
5964 * @param {String} header The new header
5966 setColumnHeader : function(col, header){
5967 this.config[col].header = header;
5968 this.fireEvent("headerchange", this, col, header);
5972 * Returns the tooltip for the specified column.
5973 * @param {Number} col The column index
5976 getColumnTooltip : function(col){
5977 return this.config[col].tooltip;
5980 * Sets the tooltip for a column.
5981 * @param {Number} col The column index
5982 * @param {String} tooltip The new tooltip
5984 setColumnTooltip : function(col, tooltip){
5985 this.config[col].tooltip = tooltip;
5989 * Returns the dataIndex for the specified column.
5990 * @param {Number} col The column index
5993 getDataIndex : function(col){
5994 return this.config[col].dataIndex;
5998 * Sets the dataIndex for a column.
5999 * @param {Number} col The column index
6000 * @param {Number} dataIndex The new dataIndex
6002 setDataIndex : function(col, dataIndex){
6003 this.config[col].dataIndex = dataIndex;
6009 * Returns true if the cell is editable.
6010 * @param {Number} colIndex The column index
6011 * @param {Number} rowIndex The row index - this is nto actually used..?
6014 isCellEditable : function(colIndex, rowIndex){
6015 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
6019 * Returns the editor defined for the cell/column.
6020 * return false or null to disable editing.
6021 * @param {Number} colIndex The column index
6022 * @param {Number} rowIndex The row index
6025 getCellEditor : function(colIndex, rowIndex){
6026 return this.config[colIndex].editor;
6030 * Sets if a column is editable.
6031 * @param {Number} col The column index
6032 * @param {Boolean} editable True if the column is editable
6034 setEditable : function(col, editable){
6035 this.config[col].editable = editable;
6040 * Returns true if the column is hidden.
6041 * @param {Number} colIndex The column index
6044 isHidden : function(colIndex){
6045 return this.config[colIndex].hidden;
6050 * Returns true if the column width cannot be changed
6052 isFixed : function(colIndex){
6053 return this.config[colIndex].fixed;
6057 * Returns true if the column can be resized
6060 isResizable : function(colIndex){
6061 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6064 * Sets if a column is hidden.
6065 * @param {Number} colIndex The column index
6066 * @param {Boolean} hidden True if the column is hidden
6068 setHidden : function(colIndex, hidden){
6069 this.config[colIndex].hidden = hidden;
6070 this.totalWidth = null;
6071 this.fireEvent("hiddenchange", this, colIndex, hidden);
6075 * Sets the editor for a column.
6076 * @param {Number} col The column index
6077 * @param {Object} editor The editor object
6079 setEditor : function(col, editor){
6080 this.config[col].editor = editor;
6084 Roo.grid.ColumnModel.defaultRenderer = function(value)
6086 if(typeof value == "object") {
6089 if(typeof value == "string" && value.length < 1){
6093 return String.format("{0}", value);
6096 // Alias for backwards compatibility
6097 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6100 * Ext JS Library 1.1.1
6101 * Copyright(c) 2006-2007, Ext JS, LLC.
6103 * Originally Released Under LGPL - original licence link has changed is not relivant.
6106 * <script type="text/javascript">
6110 * @class Roo.LoadMask
6111 * A simple utility class for generically masking elements while loading data. If the element being masked has
6112 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6113 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6114 * element's UpdateManager load indicator and will be destroyed after the initial load.
6116 * Create a new LoadMask
6117 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6118 * @param {Object} config The config object
6120 Roo.LoadMask = function(el, config){
6121 this.el = Roo.get(el);
6122 Roo.apply(this, config);
6124 this.store.on('beforeload', this.onBeforeLoad, this);
6125 this.store.on('load', this.onLoad, this);
6126 this.store.on('loadexception', this.onLoadException, this);
6127 this.removeMask = false;
6129 var um = this.el.getUpdateManager();
6130 um.showLoadIndicator = false; // disable the default indicator
6131 um.on('beforeupdate', this.onBeforeLoad, this);
6132 um.on('update', this.onLoad, this);
6133 um.on('failure', this.onLoad, this);
6134 this.removeMask = true;
6138 Roo.LoadMask.prototype = {
6140 * @cfg {Boolean} removeMask
6141 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6142 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6146 * The text to display in a centered loading message box (defaults to 'Loading...')
6150 * @cfg {String} msgCls
6151 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6153 msgCls : 'x-mask-loading',
6156 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6162 * Disables the mask to prevent it from being displayed
6164 disable : function(){
6165 this.disabled = true;
6169 * Enables the mask so that it can be displayed
6171 enable : function(){
6172 this.disabled = false;
6175 onLoadException : function()
6179 if (typeof(arguments[3]) != 'undefined') {
6180 Roo.MessageBox.alert("Error loading",arguments[3]);
6184 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6185 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6192 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6197 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6201 onBeforeLoad : function(){
6203 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6208 destroy : function(){
6210 this.store.un('beforeload', this.onBeforeLoad, this);
6211 this.store.un('load', this.onLoad, this);
6212 this.store.un('loadexception', this.onLoadException, this);
6214 var um = this.el.getUpdateManager();
6215 um.un('beforeupdate', this.onBeforeLoad, this);
6216 um.un('update', this.onLoad, this);
6217 um.un('failure', this.onLoad, this);
6228 * @class Roo.bootstrap.Table
6229 * @extends Roo.bootstrap.Component
6230 * Bootstrap Table class
6231 * @cfg {String} cls table class
6232 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6233 * @cfg {String} bgcolor Specifies the background color for a table
6234 * @cfg {Number} border Specifies whether the table cells should have borders or not
6235 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6236 * @cfg {Number} cellspacing Specifies the space between cells
6237 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6238 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6239 * @cfg {String} sortable Specifies that the table should be sortable
6240 * @cfg {String} summary Specifies a summary of the content of a table
6241 * @cfg {Number} width Specifies the width of a table
6242 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6244 * @cfg {boolean} striped Should the rows be alternative striped
6245 * @cfg {boolean} bordered Add borders to the table
6246 * @cfg {boolean} hover Add hover highlighting
6247 * @cfg {boolean} condensed Format condensed
6248 * @cfg {boolean} responsive Format condensed
6249 * @cfg {Boolean} loadMask (true|false) default false
6250 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6251 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6252 * @cfg {Boolean} rowSelection (true|false) default false
6253 * @cfg {Boolean} cellSelection (true|false) default false
6254 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6255 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6256 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6257 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6261 * Create a new Table
6262 * @param {Object} config The config object
6265 Roo.bootstrap.Table = function(config){
6266 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6271 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6272 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6273 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6274 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6276 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6278 this.sm.grid = this;
6279 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6280 this.sm = this.selModel;
6281 this.sm.xmodule = this.xmodule || false;
6284 if (this.cm && typeof(this.cm.config) == 'undefined') {
6285 this.colModel = new Roo.grid.ColumnModel(this.cm);
6286 this.cm = this.colModel;
6287 this.cm.xmodule = this.xmodule || false;
6290 this.store= Roo.factory(this.store, Roo.data);
6291 this.ds = this.store;
6292 this.ds.xmodule = this.xmodule || false;
6295 if (this.footer && this.store) {
6296 this.footer.dataSource = this.ds;
6297 this.footer = Roo.factory(this.footer);
6304 * Fires when a cell is clicked
6305 * @param {Roo.bootstrap.Table} this
6306 * @param {Roo.Element} el
6307 * @param {Number} rowIndex
6308 * @param {Number} columnIndex
6309 * @param {Roo.EventObject} e
6313 * @event celldblclick
6314 * Fires when a cell is double clicked
6315 * @param {Roo.bootstrap.Table} this
6316 * @param {Roo.Element} el
6317 * @param {Number} rowIndex
6318 * @param {Number} columnIndex
6319 * @param {Roo.EventObject} e
6321 "celldblclick" : true,
6324 * Fires when a row is clicked
6325 * @param {Roo.bootstrap.Table} this
6326 * @param {Roo.Element} el
6327 * @param {Number} rowIndex
6328 * @param {Roo.EventObject} e
6332 * @event rowdblclick
6333 * Fires when a row is double clicked
6334 * @param {Roo.bootstrap.Table} this
6335 * @param {Roo.Element} el
6336 * @param {Number} rowIndex
6337 * @param {Roo.EventObject} e
6339 "rowdblclick" : true,
6342 * Fires when a mouseover occur
6343 * @param {Roo.bootstrap.Table} this
6344 * @param {Roo.Element} el
6345 * @param {Number} rowIndex
6346 * @param {Number} columnIndex
6347 * @param {Roo.EventObject} e
6352 * Fires when a mouseout occur
6353 * @param {Roo.bootstrap.Table} this
6354 * @param {Roo.Element} el
6355 * @param {Number} rowIndex
6356 * @param {Number} columnIndex
6357 * @param {Roo.EventObject} e
6362 * Fires when a row is rendered, so you can change add a style to it.
6363 * @param {Roo.bootstrap.Table} this
6364 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6368 * @event rowsrendered
6369 * Fires when all the rows have been rendered
6370 * @param {Roo.bootstrap.Table} this
6372 'rowsrendered' : true,
6374 * @event contextmenu
6375 * The raw contextmenu event for the entire grid.
6376 * @param {Roo.EventObject} e
6378 "contextmenu" : true,
6380 * @event rowcontextmenu
6381 * Fires when a row is right clicked
6382 * @param {Roo.bootstrap.Table} this
6383 * @param {Number} rowIndex
6384 * @param {Roo.EventObject} e
6386 "rowcontextmenu" : true,
6388 * @event cellcontextmenu
6389 * Fires when a cell is right clicked
6390 * @param {Roo.bootstrap.Table} this
6391 * @param {Number} rowIndex
6392 * @param {Number} cellIndex
6393 * @param {Roo.EventObject} e
6395 "cellcontextmenu" : true,
6397 * @event headercontextmenu
6398 * Fires when a header is right clicked
6399 * @param {Roo.bootstrap.Table} this
6400 * @param {Number} columnIndex
6401 * @param {Roo.EventObject} e
6403 "headercontextmenu" : true
6407 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6433 rowSelection : false,
6434 cellSelection : false,
6437 // Roo.Element - the tbody
6439 // Roo.Element - thead element
6442 container: false, // used by gridpanel...
6448 auto_hide_footer : false,
6450 getAutoCreate : function()
6452 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6459 if (this.scrollBody) {
6460 cfg.cls += ' table-body-fixed';
6463 cfg.cls += ' table-striped';
6467 cfg.cls += ' table-hover';
6469 if (this.bordered) {
6470 cfg.cls += ' table-bordered';
6472 if (this.condensed) {
6473 cfg.cls += ' table-condensed';
6475 if (this.responsive) {
6476 cfg.cls += ' table-responsive';
6480 cfg.cls+= ' ' +this.cls;
6483 // this lot should be simplifed...
6496 ].forEach(function(k) {
6504 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6507 if(this.store || this.cm){
6508 if(this.headerShow){
6509 cfg.cn.push(this.renderHeader());
6512 cfg.cn.push(this.renderBody());
6514 if(this.footerShow){
6515 cfg.cn.push(this.renderFooter());
6517 // where does this come from?
6518 //cfg.cls+= ' TableGrid';
6521 return { cn : [ cfg ] };
6524 initEvents : function()
6526 if(!this.store || !this.cm){
6529 if (this.selModel) {
6530 this.selModel.initEvents();
6534 //Roo.log('initEvents with ds!!!!');
6536 this.mainBody = this.el.select('tbody', true).first();
6537 this.mainHead = this.el.select('thead', true).first();
6538 this.mainFoot = this.el.select('tfoot', true).first();
6544 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6545 e.on('click', _this.sort, _this);
6548 this.mainBody.on("click", this.onClick, this);
6549 this.mainBody.on("dblclick", this.onDblClick, this);
6551 // why is this done????? = it breaks dialogs??
6552 //this.parent().el.setStyle('position', 'relative');
6556 this.footer.parentId = this.id;
6557 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6560 this.el.select('tfoot tr td').first().addClass('hide');
6565 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6568 this.store.on('load', this.onLoad, this);
6569 this.store.on('beforeload', this.onBeforeLoad, this);
6570 this.store.on('update', this.onUpdate, this);
6571 this.store.on('add', this.onAdd, this);
6572 this.store.on("clear", this.clear, this);
6574 this.el.on("contextmenu", this.onContextMenu, this);
6576 this.mainBody.on('scroll', this.onBodyScroll, this);
6578 this.cm.on("headerchange", this.onHeaderChange, this);
6580 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6584 onContextMenu : function(e, t)
6586 this.processEvent("contextmenu", e);
6589 processEvent : function(name, e)
6591 if (name != 'touchstart' ) {
6592 this.fireEvent(name, e);
6595 var t = e.getTarget();
6597 var cell = Roo.get(t);
6603 if(cell.findParent('tfoot', false, true)){
6607 if(cell.findParent('thead', false, true)){
6609 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6610 cell = Roo.get(t).findParent('th', false, true);
6612 Roo.log("failed to find th in thead?");
6613 Roo.log(e.getTarget());
6618 var cellIndex = cell.dom.cellIndex;
6620 var ename = name == 'touchstart' ? 'click' : name;
6621 this.fireEvent("header" + ename, this, cellIndex, e);
6626 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6627 cell = Roo.get(t).findParent('td', false, true);
6629 Roo.log("failed to find th in tbody?");
6630 Roo.log(e.getTarget());
6635 var row = cell.findParent('tr', false, true);
6636 var cellIndex = cell.dom.cellIndex;
6637 var rowIndex = row.dom.rowIndex - 1;
6641 this.fireEvent("row" + name, this, rowIndex, e);
6645 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6651 onMouseover : function(e, el)
6653 var cell = Roo.get(el);
6659 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6660 cell = cell.findParent('td', false, true);
6663 var row = cell.findParent('tr', false, true);
6664 var cellIndex = cell.dom.cellIndex;
6665 var rowIndex = row.dom.rowIndex - 1; // start from 0
6667 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6671 onMouseout : function(e, el)
6673 var cell = Roo.get(el);
6679 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6680 cell = cell.findParent('td', false, true);
6683 var row = cell.findParent('tr', false, true);
6684 var cellIndex = cell.dom.cellIndex;
6685 var rowIndex = row.dom.rowIndex - 1; // start from 0
6687 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6691 onClick : function(e, el)
6693 var cell = Roo.get(el);
6695 if(!cell || (!this.cellSelection && !this.rowSelection)){
6699 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6700 cell = cell.findParent('td', false, true);
6703 if(!cell || typeof(cell) == 'undefined'){
6707 var row = cell.findParent('tr', false, true);
6709 if(!row || typeof(row) == 'undefined'){
6713 var cellIndex = cell.dom.cellIndex;
6714 var rowIndex = this.getRowIndex(row);
6716 // why??? - should these not be based on SelectionModel?
6717 if(this.cellSelection){
6718 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6721 if(this.rowSelection){
6722 this.fireEvent('rowclick', this, row, rowIndex, e);
6728 onDblClick : function(e,el)
6730 var cell = Roo.get(el);
6732 if(!cell || (!this.cellSelection && !this.rowSelection)){
6736 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6737 cell = cell.findParent('td', false, true);
6740 if(!cell || typeof(cell) == 'undefined'){
6744 var row = cell.findParent('tr', false, true);
6746 if(!row || typeof(row) == 'undefined'){
6750 var cellIndex = cell.dom.cellIndex;
6751 var rowIndex = this.getRowIndex(row);
6753 if(this.cellSelection){
6754 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6757 if(this.rowSelection){
6758 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6762 sort : function(e,el)
6764 var col = Roo.get(el);
6766 if(!col.hasClass('sortable')){
6770 var sort = col.attr('sort');
6773 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6777 this.store.sortInfo = {field : sort, direction : dir};
6780 Roo.log("calling footer first");
6781 this.footer.onClick('first');
6784 this.store.load({ params : { start : 0 } });
6788 renderHeader : function()
6796 this.totalWidth = 0;
6798 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6800 var config = cm.config[i];
6804 cls : 'x-hcol-' + i,
6806 html: cm.getColumnHeader(i)
6811 if(typeof(config.sortable) != 'undefined' && config.sortable){
6813 c.html = '<i class="glyphicon"></i>' + c.html;
6816 // could use BS4 hidden-..-down
6818 if(typeof(config.lgHeader) != 'undefined'){
6819 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
6822 if(typeof(config.mdHeader) != 'undefined'){
6823 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6826 if(typeof(config.smHeader) != 'undefined'){
6827 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6830 if(typeof(config.xsHeader) != 'undefined'){
6831 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6838 if(typeof(config.tooltip) != 'undefined'){
6839 c.tooltip = config.tooltip;
6842 if(typeof(config.colspan) != 'undefined'){
6843 c.colspan = config.colspan;
6846 if(typeof(config.hidden) != 'undefined' && config.hidden){
6847 c.style += ' display:none;';
6850 if(typeof(config.dataIndex) != 'undefined'){
6851 c.sort = config.dataIndex;
6856 if(typeof(config.align) != 'undefined' && config.align.length){
6857 c.style += ' text-align:' + config.align + ';';
6860 if(typeof(config.width) != 'undefined'){
6861 c.style += ' width:' + config.width + 'px;';
6862 this.totalWidth += config.width;
6864 this.totalWidth += 100; // assume minimum of 100 per column?
6867 if(typeof(config.cls) != 'undefined'){
6868 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6871 ['xs','sm','md','lg'].map(function(size){
6873 if(typeof(config[size]) == 'undefined'){
6877 if (!config[size]) { // 0 = hidden
6878 // BS 4 '0' is treated as hide that column and below.
6879 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
6883 c.cls += ' col-' + size + '-' + config[size] + (
6884 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
6896 renderBody : function()
6906 colspan : this.cm.getColumnCount()
6916 renderFooter : function()
6926 colspan : this.cm.getColumnCount()
6940 // Roo.log('ds onload');
6945 var ds = this.store;
6947 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6948 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6949 if (_this.store.sortInfo) {
6951 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6952 e.select('i', true).addClass(['glyphicon-arrow-up']);
6955 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6956 e.select('i', true).addClass(['glyphicon-arrow-down']);
6961 var tbody = this.mainBody;
6963 if(ds.getCount() > 0){
6964 ds.data.each(function(d,rowIndex){
6965 var row = this.renderRow(cm, ds, rowIndex);
6967 tbody.createChild(row);
6971 if(row.cellObjects.length){
6972 Roo.each(row.cellObjects, function(r){
6973 _this.renderCellObject(r);
6980 var tfoot = this.el.select('tfoot', true).first();
6982 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6984 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6986 var total = this.ds.getTotalCount();
6988 if(this.footer.pageSize < total){
6989 this.mainFoot.show();
6993 Roo.each(this.el.select('tbody td', true).elements, function(e){
6994 e.on('mouseover', _this.onMouseover, _this);
6997 Roo.each(this.el.select('tbody td', true).elements, function(e){
6998 e.on('mouseout', _this.onMouseout, _this);
7000 this.fireEvent('rowsrendered', this);
7006 onUpdate : function(ds,record)
7008 this.refreshRow(record);
7012 onRemove : function(ds, record, index, isUpdate){
7013 if(isUpdate !== true){
7014 this.fireEvent("beforerowremoved", this, index, record);
7016 var bt = this.mainBody.dom;
7018 var rows = this.el.select('tbody > tr', true).elements;
7020 if(typeof(rows[index]) != 'undefined'){
7021 bt.removeChild(rows[index].dom);
7024 // if(bt.rows[index]){
7025 // bt.removeChild(bt.rows[index]);
7028 if(isUpdate !== true){
7029 //this.stripeRows(index);
7030 //this.syncRowHeights(index, index);
7032 this.fireEvent("rowremoved", this, index, record);
7036 onAdd : function(ds, records, rowIndex)
7038 //Roo.log('on Add called');
7039 // - note this does not handle multiple adding very well..
7040 var bt = this.mainBody.dom;
7041 for (var i =0 ; i < records.length;i++) {
7042 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7043 //Roo.log(records[i]);
7044 //Roo.log(this.store.getAt(rowIndex+i));
7045 this.insertRow(this.store, rowIndex + i, false);
7052 refreshRow : function(record){
7053 var ds = this.store, index;
7054 if(typeof record == 'number'){
7056 record = ds.getAt(index);
7058 index = ds.indexOf(record);
7060 this.insertRow(ds, index, true);
7062 this.onRemove(ds, record, index+1, true);
7064 //this.syncRowHeights(index, index);
7066 this.fireEvent("rowupdated", this, index, record);
7069 insertRow : function(dm, rowIndex, isUpdate){
7072 this.fireEvent("beforerowsinserted", this, rowIndex);
7074 //var s = this.getScrollState();
7075 var row = this.renderRow(this.cm, this.store, rowIndex);
7076 // insert before rowIndex..
7077 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7081 if(row.cellObjects.length){
7082 Roo.each(row.cellObjects, function(r){
7083 _this.renderCellObject(r);
7088 this.fireEvent("rowsinserted", this, rowIndex);
7089 //this.syncRowHeights(firstRow, lastRow);
7090 //this.stripeRows(firstRow);
7097 getRowDom : function(rowIndex)
7099 var rows = this.el.select('tbody > tr', true).elements;
7101 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7104 // returns the object tree for a tr..
7107 renderRow : function(cm, ds, rowIndex)
7109 var d = ds.getAt(rowIndex);
7113 cls : 'x-row-' + rowIndex,
7117 var cellObjects = [];
7119 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7120 var config = cm.config[i];
7122 var renderer = cm.getRenderer(i);
7126 if(typeof(renderer) !== 'undefined'){
7127 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7129 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7130 // and are rendered into the cells after the row is rendered - using the id for the element.
7132 if(typeof(value) === 'object'){
7142 rowIndex : rowIndex,
7147 this.fireEvent('rowclass', this, rowcfg);
7151 cls : rowcfg.rowClass + ' x-col-' + i,
7153 html: (typeof(value) === 'object') ? '' : value
7160 if(typeof(config.colspan) != 'undefined'){
7161 td.colspan = config.colspan;
7164 if(typeof(config.hidden) != 'undefined' && config.hidden){
7165 td.style += ' display:none;';
7168 if(typeof(config.align) != 'undefined' && config.align.length){
7169 td.style += ' text-align:' + config.align + ';';
7171 if(typeof(config.valign) != 'undefined' && config.valign.length){
7172 td.style += ' vertical-align:' + config.valign + ';';
7175 if(typeof(config.width) != 'undefined'){
7176 td.style += ' width:' + config.width + 'px;';
7179 if(typeof(config.cursor) != 'undefined'){
7180 td.style += ' cursor:' + config.cursor + ';';
7183 if(typeof(config.cls) != 'undefined'){
7184 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7187 ['xs','sm','md','lg'].map(function(size){
7189 if(typeof(config[size]) == 'undefined'){
7195 if (!config[size]) { // 0 = hidden
7196 // BS 4 '0' is treated as hide that column and below.
7197 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
7201 td.cls += ' col-' + size + '-' + config[size] + (
7202 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
7212 row.cellObjects = cellObjects;
7220 onBeforeLoad : function()
7229 this.el.select('tbody', true).first().dom.innerHTML = '';
7232 * Show or hide a row.
7233 * @param {Number} rowIndex to show or hide
7234 * @param {Boolean} state hide
7236 setRowVisibility : function(rowIndex, state)
7238 var bt = this.mainBody.dom;
7240 var rows = this.el.select('tbody > tr', true).elements;
7242 if(typeof(rows[rowIndex]) == 'undefined'){
7245 rows[rowIndex].dom.style.display = state ? '' : 'none';
7249 getSelectionModel : function(){
7251 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7253 return this.selModel;
7256 * Render the Roo.bootstrap object from renderder
7258 renderCellObject : function(r)
7262 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7264 var t = r.cfg.render(r.container);
7267 Roo.each(r.cfg.cn, function(c){
7269 container: t.getChildContainer(),
7272 _this.renderCellObject(child);
7277 getRowIndex : function(row)
7281 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7292 * Returns the grid's underlying element = used by panel.Grid
7293 * @return {Element} The element
7295 getGridEl : function(){
7299 * Forces a resize - used by panel.Grid
7300 * @return {Element} The element
7302 autoSize : function()
7304 //var ctr = Roo.get(this.container.dom.parentElement);
7305 var ctr = Roo.get(this.el.dom);
7307 var thd = this.getGridEl().select('thead',true).first();
7308 var tbd = this.getGridEl().select('tbody', true).first();
7309 var tfd = this.getGridEl().select('tfoot', true).first();
7311 var cw = ctr.getWidth();
7315 tbd.setSize(ctr.getWidth(),
7316 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7318 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7321 cw = Math.max(cw, this.totalWidth);
7322 this.getGridEl().select('tr',true).setWidth(cw);
7323 // resize 'expandable coloumn?
7325 return; // we doe not have a view in this design..
7328 onBodyScroll: function()
7330 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7332 this.mainHead.setStyle({
7333 'position' : 'relative',
7334 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7340 var scrollHeight = this.mainBody.dom.scrollHeight;
7342 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7344 var height = this.mainBody.getHeight();
7346 if(scrollHeight - height == scrollTop) {
7348 var total = this.ds.getTotalCount();
7350 if(this.footer.cursor + this.footer.pageSize < total){
7352 this.footer.ds.load({
7354 start : this.footer.cursor + this.footer.pageSize,
7355 limit : this.footer.pageSize
7365 onHeaderChange : function()
7367 var header = this.renderHeader();
7368 var table = this.el.select('table', true).first();
7370 this.mainHead.remove();
7371 this.mainHead = table.createChild(header, this.mainBody, false);
7374 onHiddenChange : function(colModel, colIndex, hidden)
7376 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7377 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7379 this.CSS.updateRule(thSelector, "display", "");
7380 this.CSS.updateRule(tdSelector, "display", "");
7383 this.CSS.updateRule(thSelector, "display", "none");
7384 this.CSS.updateRule(tdSelector, "display", "none");
7387 this.onHeaderChange();
7391 setColumnWidth: function(col_index, width)
7393 // width = "md-2 xs-2..."
7394 if(!this.colModel.config[col_index]) {
7398 var w = width.split(" ");
7400 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7402 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7405 for(var j = 0; j < w.length; j++) {
7411 var size_cls = w[j].split("-");
7413 if(!Number.isInteger(size_cls[1] * 1)) {
7417 if(!this.colModel.config[col_index][size_cls[0]]) {
7421 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7425 h_row[0].classList.replace(
7426 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7427 "col-"+size_cls[0]+"-"+size_cls[1]
7430 for(var i = 0; i < rows.length; i++) {
7432 var size_cls = w[j].split("-");
7434 if(!Number.isInteger(size_cls[1] * 1)) {
7438 if(!this.colModel.config[col_index][size_cls[0]]) {
7442 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7446 rows[i].classList.replace(
7447 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7448 "col-"+size_cls[0]+"-"+size_cls[1]
7452 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7467 * @class Roo.bootstrap.TableCell
7468 * @extends Roo.bootstrap.Component
7469 * Bootstrap TableCell class
7470 * @cfg {String} html cell contain text
7471 * @cfg {String} cls cell class
7472 * @cfg {String} tag cell tag (td|th) default td
7473 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7474 * @cfg {String} align Aligns the content in a cell
7475 * @cfg {String} axis Categorizes cells
7476 * @cfg {String} bgcolor Specifies the background color of a cell
7477 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7478 * @cfg {Number} colspan Specifies the number of columns a cell should span
7479 * @cfg {String} headers Specifies one or more header cells a cell is related to
7480 * @cfg {Number} height Sets the height of a cell
7481 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7482 * @cfg {Number} rowspan Sets the number of rows a cell should span
7483 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7484 * @cfg {String} valign Vertical aligns the content in a cell
7485 * @cfg {Number} width Specifies the width of a cell
7488 * Create a new TableCell
7489 * @param {Object} config The config object
7492 Roo.bootstrap.TableCell = function(config){
7493 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7496 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7516 getAutoCreate : function(){
7517 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7537 cfg.align=this.align
7543 cfg.bgcolor=this.bgcolor
7546 cfg.charoff=this.charoff
7549 cfg.colspan=this.colspan
7552 cfg.headers=this.headers
7555 cfg.height=this.height
7558 cfg.nowrap=this.nowrap
7561 cfg.rowspan=this.rowspan
7564 cfg.scope=this.scope
7567 cfg.valign=this.valign
7570 cfg.width=this.width
7589 * @class Roo.bootstrap.TableRow
7590 * @extends Roo.bootstrap.Component
7591 * Bootstrap TableRow class
7592 * @cfg {String} cls row class
7593 * @cfg {String} align Aligns the content in a table row
7594 * @cfg {String} bgcolor Specifies a background color for a table row
7595 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7596 * @cfg {String} valign Vertical aligns the content in a table row
7599 * Create a new TableRow
7600 * @param {Object} config The config object
7603 Roo.bootstrap.TableRow = function(config){
7604 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7607 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7615 getAutoCreate : function(){
7616 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7626 cfg.align = this.align;
7629 cfg.bgcolor = this.bgcolor;
7632 cfg.charoff = this.charoff;
7635 cfg.valign = this.valign;
7653 * @class Roo.bootstrap.TableBody
7654 * @extends Roo.bootstrap.Component
7655 * Bootstrap TableBody class
7656 * @cfg {String} cls element class
7657 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7658 * @cfg {String} align Aligns the content inside the element
7659 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7660 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7663 * Create a new TableBody
7664 * @param {Object} config The config object
7667 Roo.bootstrap.TableBody = function(config){
7668 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7671 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7679 getAutoCreate : function(){
7680 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7694 cfg.align = this.align;
7697 cfg.charoff = this.charoff;
7700 cfg.valign = this.valign;
7707 // initEvents : function()
7714 // this.store = Roo.factory(this.store, Roo.data);
7715 // this.store.on('load', this.onLoad, this);
7717 // this.store.load();
7721 // onLoad: function ()
7723 // this.fireEvent('load', this);
7733 * Ext JS Library 1.1.1
7734 * Copyright(c) 2006-2007, Ext JS, LLC.
7736 * Originally Released Under LGPL - original licence link has changed is not relivant.
7739 * <script type="text/javascript">
7742 // as we use this in bootstrap.
7743 Roo.namespace('Roo.form');
7745 * @class Roo.form.Action
7746 * Internal Class used to handle form actions
7748 * @param {Roo.form.BasicForm} el The form element or its id
7749 * @param {Object} config Configuration options
7754 // define the action interface
7755 Roo.form.Action = function(form, options){
7757 this.options = options || {};
7760 * Client Validation Failed
7763 Roo.form.Action.CLIENT_INVALID = 'client';
7765 * Server Validation Failed
7768 Roo.form.Action.SERVER_INVALID = 'server';
7770 * Connect to Server Failed
7773 Roo.form.Action.CONNECT_FAILURE = 'connect';
7775 * Reading Data from Server Failed
7778 Roo.form.Action.LOAD_FAILURE = 'load';
7780 Roo.form.Action.prototype = {
7782 failureType : undefined,
7783 response : undefined,
7787 run : function(options){
7792 success : function(response){
7797 handleResponse : function(response){
7801 // default connection failure
7802 failure : function(response){
7804 this.response = response;
7805 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7806 this.form.afterAction(this, false);
7809 processResponse : function(response){
7810 this.response = response;
7811 if(!response.responseText){
7814 this.result = this.handleResponse(response);
7818 // utility functions used internally
7819 getUrl : function(appendParams){
7820 var url = this.options.url || this.form.url || this.form.el.dom.action;
7822 var p = this.getParams();
7824 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7830 getMethod : function(){
7831 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7834 getParams : function(){
7835 var bp = this.form.baseParams;
7836 var p = this.options.params;
7838 if(typeof p == "object"){
7839 p = Roo.urlEncode(Roo.applyIf(p, bp));
7840 }else if(typeof p == 'string' && bp){
7841 p += '&' + Roo.urlEncode(bp);
7844 p = Roo.urlEncode(bp);
7849 createCallback : function(){
7851 success: this.success,
7852 failure: this.failure,
7854 timeout: (this.form.timeout*1000),
7855 upload: this.form.fileUpload ? this.success : undefined
7860 Roo.form.Action.Submit = function(form, options){
7861 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7864 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7867 haveProgress : false,
7868 uploadComplete : false,
7870 // uploadProgress indicator.
7871 uploadProgress : function()
7873 if (!this.form.progressUrl) {
7877 if (!this.haveProgress) {
7878 Roo.MessageBox.progress("Uploading", "Uploading");
7880 if (this.uploadComplete) {
7881 Roo.MessageBox.hide();
7885 this.haveProgress = true;
7887 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7889 var c = new Roo.data.Connection();
7891 url : this.form.progressUrl,
7896 success : function(req){
7897 //console.log(data);
7901 rdata = Roo.decode(req.responseText)
7903 Roo.log("Invalid data from server..");
7907 if (!rdata || !rdata.success) {
7909 Roo.MessageBox.alert(Roo.encode(rdata));
7912 var data = rdata.data;
7914 if (this.uploadComplete) {
7915 Roo.MessageBox.hide();
7920 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7921 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7924 this.uploadProgress.defer(2000,this);
7927 failure: function(data) {
7928 Roo.log('progress url failed ');
7939 // run get Values on the form, so it syncs any secondary forms.
7940 this.form.getValues();
7942 var o = this.options;
7943 var method = this.getMethod();
7944 var isPost = method == 'POST';
7945 if(o.clientValidation === false || this.form.isValid()){
7947 if (this.form.progressUrl) {
7948 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7949 (new Date() * 1) + '' + Math.random());
7954 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7955 form:this.form.el.dom,
7956 url:this.getUrl(!isPost),
7958 params:isPost ? this.getParams() : null,
7959 isUpload: this.form.fileUpload,
7960 formData : this.form.formData
7963 this.uploadProgress();
7965 }else if (o.clientValidation !== false){ // client validation failed
7966 this.failureType = Roo.form.Action.CLIENT_INVALID;
7967 this.form.afterAction(this, false);
7971 success : function(response)
7973 this.uploadComplete= true;
7974 if (this.haveProgress) {
7975 Roo.MessageBox.hide();
7979 var result = this.processResponse(response);
7980 if(result === true || result.success){
7981 this.form.afterAction(this, true);
7985 this.form.markInvalid(result.errors);
7986 this.failureType = Roo.form.Action.SERVER_INVALID;
7988 this.form.afterAction(this, false);
7990 failure : function(response)
7992 this.uploadComplete= true;
7993 if (this.haveProgress) {
7994 Roo.MessageBox.hide();
7997 this.response = response;
7998 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7999 this.form.afterAction(this, false);
8002 handleResponse : function(response){
8003 if(this.form.errorReader){
8004 var rs = this.form.errorReader.read(response);
8007 for(var i = 0, len = rs.records.length; i < len; i++) {
8008 var r = rs.records[i];
8012 if(errors.length < 1){
8016 success : rs.success,
8022 ret = Roo.decode(response.responseText);
8026 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
8036 Roo.form.Action.Load = function(form, options){
8037 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
8038 this.reader = this.form.reader;
8041 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8046 Roo.Ajax.request(Roo.apply(
8047 this.createCallback(), {
8048 method:this.getMethod(),
8049 url:this.getUrl(false),
8050 params:this.getParams()
8054 success : function(response){
8056 var result = this.processResponse(response);
8057 if(result === true || !result.success || !result.data){
8058 this.failureType = Roo.form.Action.LOAD_FAILURE;
8059 this.form.afterAction(this, false);
8062 this.form.clearInvalid();
8063 this.form.setValues(result.data);
8064 this.form.afterAction(this, true);
8067 handleResponse : function(response){
8068 if(this.form.reader){
8069 var rs = this.form.reader.read(response);
8070 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8072 success : rs.success,
8076 return Roo.decode(response.responseText);
8080 Roo.form.Action.ACTION_TYPES = {
8081 'load' : Roo.form.Action.Load,
8082 'submit' : Roo.form.Action.Submit
8091 * @class Roo.bootstrap.Form
8092 * @extends Roo.bootstrap.Component
8093 * Bootstrap Form class
8094 * @cfg {String} method GET | POST (default POST)
8095 * @cfg {String} labelAlign top | left (default top)
8096 * @cfg {String} align left | right - for navbars
8097 * @cfg {Boolean} loadMask load mask when submit (default true)
8102 * @param {Object} config The config object
8106 Roo.bootstrap.Form = function(config){
8108 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8110 Roo.bootstrap.Form.popover.apply();
8114 * @event clientvalidation
8115 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8116 * @param {Form} this
8117 * @param {Boolean} valid true if the form has passed client-side validation
8119 clientvalidation: true,
8121 * @event beforeaction
8122 * Fires before any action is performed. Return false to cancel the action.
8123 * @param {Form} this
8124 * @param {Action} action The action to be performed
8128 * @event actionfailed
8129 * Fires when an action fails.
8130 * @param {Form} this
8131 * @param {Action} action The action that failed
8133 actionfailed : true,
8135 * @event actioncomplete
8136 * Fires when an action is completed.
8137 * @param {Form} this
8138 * @param {Action} action The action that completed
8140 actioncomplete : true
8144 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8147 * @cfg {String} method
8148 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8153 * The URL to use for form actions if one isn't supplied in the action options.
8156 * @cfg {Boolean} fileUpload
8157 * Set to true if this form is a file upload.
8161 * @cfg {Object} baseParams
8162 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8166 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8170 * @cfg {Sting} align (left|right) for navbar forms
8175 activeAction : null,
8178 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8179 * element by passing it or its id or mask the form itself by passing in true.
8182 waitMsgTarget : false,
8187 * @cfg {Boolean} errorMask (true|false) default false
8192 * @cfg {Number} maskOffset Default 100
8197 * @cfg {Boolean} maskBody
8201 getAutoCreate : function(){
8205 method : this.method || 'POST',
8206 id : this.id || Roo.id(),
8209 if (this.parent().xtype.match(/^Nav/)) {
8210 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8214 if (this.labelAlign == 'left' ) {
8215 cfg.cls += ' form-horizontal';
8221 initEvents : function()
8223 this.el.on('submit', this.onSubmit, this);
8224 // this was added as random key presses on the form where triggering form submit.
8225 this.el.on('keypress', function(e) {
8226 if (e.getCharCode() != 13) {
8229 // we might need to allow it for textareas.. and some other items.
8230 // check e.getTarget().
8232 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8236 Roo.log("keypress blocked");
8244 onSubmit : function(e){
8249 * Returns true if client-side validation on the form is successful.
8252 isValid : function(){
8253 var items = this.getItems();
8257 items.each(function(f){
8263 Roo.log('invalid field: ' + f.name);
8267 if(!target && f.el.isVisible(true)){
8273 if(this.errorMask && !valid){
8274 Roo.bootstrap.Form.popover.mask(this, target);
8281 * Returns true if any fields in this form have changed since their original load.
8284 isDirty : function(){
8286 var items = this.getItems();
8287 items.each(function(f){
8297 * Performs a predefined action (submit or load) or custom actions you define on this form.
8298 * @param {String} actionName The name of the action type
8299 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8300 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8301 * accept other config options):
8303 Property Type Description
8304 ---------------- --------------- ----------------------------------------------------------------------------------
8305 url String The url for the action (defaults to the form's url)
8306 method String The form method to use (defaults to the form's method, or POST if not defined)
8307 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8308 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8309 validate the form on the client (defaults to false)
8311 * @return {BasicForm} this
8313 doAction : function(action, options){
8314 if(typeof action == 'string'){
8315 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8317 if(this.fireEvent('beforeaction', this, action) !== false){
8318 this.beforeAction(action);
8319 action.run.defer(100, action);
8325 beforeAction : function(action){
8326 var o = action.options;
8331 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8333 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8336 // not really supported yet.. ??
8338 //if(this.waitMsgTarget === true){
8339 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8340 //}else if(this.waitMsgTarget){
8341 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8342 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8344 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8350 afterAction : function(action, success){
8351 this.activeAction = null;
8352 var o = action.options;
8357 Roo.get(document.body).unmask();
8363 //if(this.waitMsgTarget === true){
8364 // this.el.unmask();
8365 //}else if(this.waitMsgTarget){
8366 // this.waitMsgTarget.unmask();
8368 // Roo.MessageBox.updateProgress(1);
8369 // Roo.MessageBox.hide();
8376 Roo.callback(o.success, o.scope, [this, action]);
8377 this.fireEvent('actioncomplete', this, action);
8381 // failure condition..
8382 // we have a scenario where updates need confirming.
8383 // eg. if a locking scenario exists..
8384 // we look for { errors : { needs_confirm : true }} in the response.
8386 (typeof(action.result) != 'undefined') &&
8387 (typeof(action.result.errors) != 'undefined') &&
8388 (typeof(action.result.errors.needs_confirm) != 'undefined')
8391 Roo.log("not supported yet");
8394 Roo.MessageBox.confirm(
8395 "Change requires confirmation",
8396 action.result.errorMsg,
8401 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8411 Roo.callback(o.failure, o.scope, [this, action]);
8412 // show an error message if no failed handler is set..
8413 if (!this.hasListener('actionfailed')) {
8414 Roo.log("need to add dialog support");
8416 Roo.MessageBox.alert("Error",
8417 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8418 action.result.errorMsg :
8419 "Saving Failed, please check your entries or try again"
8424 this.fireEvent('actionfailed', this, action);
8429 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8430 * @param {String} id The value to search for
8433 findField : function(id){
8434 var items = this.getItems();
8435 var field = items.get(id);
8437 items.each(function(f){
8438 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8445 return field || null;
8448 * Mark fields in this form invalid in bulk.
8449 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8450 * @return {BasicForm} this
8452 markInvalid : function(errors){
8453 if(errors instanceof Array){
8454 for(var i = 0, len = errors.length; i < len; i++){
8455 var fieldError = errors[i];
8456 var f = this.findField(fieldError.id);
8458 f.markInvalid(fieldError.msg);
8464 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8465 field.markInvalid(errors[id]);
8469 //Roo.each(this.childForms || [], function (f) {
8470 // f.markInvalid(errors);
8477 * Set values for fields in this form in bulk.
8478 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8479 * @return {BasicForm} this
8481 setValues : function(values){
8482 if(values instanceof Array){ // array of objects
8483 for(var i = 0, len = values.length; i < len; i++){
8485 var f = this.findField(v.id);
8487 f.setValue(v.value);
8488 if(this.trackResetOnLoad){
8489 f.originalValue = f.getValue();
8493 }else{ // object hash
8496 if(typeof values[id] != 'function' && (field = this.findField(id))){
8498 if (field.setFromData &&
8500 field.displayField &&
8501 // combos' with local stores can
8502 // be queried via setValue()
8503 // to set their value..
8504 (field.store && !field.store.isLocal)
8508 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8509 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8510 field.setFromData(sd);
8512 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8514 field.setFromData(values);
8517 field.setValue(values[id]);
8521 if(this.trackResetOnLoad){
8522 field.originalValue = field.getValue();
8528 //Roo.each(this.childForms || [], function (f) {
8529 // f.setValues(values);
8536 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8537 * they are returned as an array.
8538 * @param {Boolean} asString
8541 getValues : function(asString){
8542 //if (this.childForms) {
8543 // copy values from the child forms
8544 // Roo.each(this.childForms, function (f) {
8545 // this.setValues(f.getValues());
8551 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8552 if(asString === true){
8555 return Roo.urlDecode(fs);
8559 * Returns the fields in this form as an object with key/value pairs.
8560 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8563 getFieldValues : function(with_hidden)
8565 var items = this.getItems();
8567 items.each(function(f){
8573 var v = f.getValue();
8575 if (f.inputType =='radio') {
8576 if (typeof(ret[f.getName()]) == 'undefined') {
8577 ret[f.getName()] = ''; // empty..
8580 if (!f.el.dom.checked) {
8588 if(f.xtype == 'MoneyField'){
8589 ret[f.currencyName] = f.getCurrency();
8592 // not sure if this supported any more..
8593 if ((typeof(v) == 'object') && f.getRawValue) {
8594 v = f.getRawValue() ; // dates..
8596 // combo boxes where name != hiddenName...
8597 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8598 ret[f.name] = f.getRawValue();
8600 ret[f.getName()] = v;
8607 * Clears all invalid messages in this form.
8608 * @return {BasicForm} this
8610 clearInvalid : function(){
8611 var items = this.getItems();
8613 items.each(function(f){
8622 * @return {BasicForm} this
8625 var items = this.getItems();
8626 items.each(function(f){
8630 Roo.each(this.childForms || [], function (f) {
8638 getItems : function()
8640 var r=new Roo.util.MixedCollection(false, function(o){
8641 return o.id || (o.id = Roo.id());
8643 var iter = function(el) {
8650 Roo.each(el.items,function(e) {
8659 hideFields : function(items)
8661 Roo.each(items, function(i){
8663 var f = this.findField(i);
8674 showFields : function(items)
8676 Roo.each(items, function(i){
8678 var f = this.findField(i);
8691 Roo.apply(Roo.bootstrap.Form, {
8718 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8719 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8720 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8721 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8724 this.maskEl.top.enableDisplayMode("block");
8725 this.maskEl.left.enableDisplayMode("block");
8726 this.maskEl.bottom.enableDisplayMode("block");
8727 this.maskEl.right.enableDisplayMode("block");
8729 this.toolTip = new Roo.bootstrap.Tooltip({
8730 cls : 'roo-form-error-popover',
8732 'left' : ['r-l', [-2,0], 'right'],
8733 'right' : ['l-r', [2,0], 'left'],
8734 'bottom' : ['tl-bl', [0,2], 'top'],
8735 'top' : [ 'bl-tl', [0,-2], 'bottom']
8739 this.toolTip.render(Roo.get(document.body));
8741 this.toolTip.el.enableDisplayMode("block");
8743 Roo.get(document.body).on('click', function(){
8747 Roo.get(document.body).on('touchstart', function(){
8751 this.isApplied = true
8754 mask : function(form, target)
8758 this.target = target;
8760 if(!this.form.errorMask || !target.el){
8764 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8766 Roo.log(scrollable);
8768 var ot = this.target.el.calcOffsetsTo(scrollable);
8770 var scrollTo = ot[1] - this.form.maskOffset;
8772 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8774 scrollable.scrollTo('top', scrollTo);
8776 var box = this.target.el.getBox();
8778 var zIndex = Roo.bootstrap.Modal.zIndex++;
8781 this.maskEl.top.setStyle('position', 'absolute');
8782 this.maskEl.top.setStyle('z-index', zIndex);
8783 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8784 this.maskEl.top.setLeft(0);
8785 this.maskEl.top.setTop(0);
8786 this.maskEl.top.show();
8788 this.maskEl.left.setStyle('position', 'absolute');
8789 this.maskEl.left.setStyle('z-index', zIndex);
8790 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8791 this.maskEl.left.setLeft(0);
8792 this.maskEl.left.setTop(box.y - this.padding);
8793 this.maskEl.left.show();
8795 this.maskEl.bottom.setStyle('position', 'absolute');
8796 this.maskEl.bottom.setStyle('z-index', zIndex);
8797 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8798 this.maskEl.bottom.setLeft(0);
8799 this.maskEl.bottom.setTop(box.bottom + this.padding);
8800 this.maskEl.bottom.show();
8802 this.maskEl.right.setStyle('position', 'absolute');
8803 this.maskEl.right.setStyle('z-index', zIndex);
8804 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8805 this.maskEl.right.setLeft(box.right + this.padding);
8806 this.maskEl.right.setTop(box.y - this.padding);
8807 this.maskEl.right.show();
8809 this.toolTip.bindEl = this.target.el;
8811 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8813 var tip = this.target.blankText;
8815 if(this.target.getValue() !== '' ) {
8817 if (this.target.invalidText.length) {
8818 tip = this.target.invalidText;
8819 } else if (this.target.regexText.length){
8820 tip = this.target.regexText;
8824 this.toolTip.show(tip);
8826 this.intervalID = window.setInterval(function() {
8827 Roo.bootstrap.Form.popover.unmask();
8830 window.onwheel = function(){ return false;};
8832 (function(){ this.isMasked = true; }).defer(500, this);
8838 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8842 this.maskEl.top.setStyle('position', 'absolute');
8843 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8844 this.maskEl.top.hide();
8846 this.maskEl.left.setStyle('position', 'absolute');
8847 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8848 this.maskEl.left.hide();
8850 this.maskEl.bottom.setStyle('position', 'absolute');
8851 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8852 this.maskEl.bottom.hide();
8854 this.maskEl.right.setStyle('position', 'absolute');
8855 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8856 this.maskEl.right.hide();
8858 this.toolTip.hide();
8860 this.toolTip.el.hide();
8862 window.onwheel = function(){ return true;};
8864 if(this.intervalID){
8865 window.clearInterval(this.intervalID);
8866 this.intervalID = false;
8869 this.isMasked = false;
8879 * Ext JS Library 1.1.1
8880 * Copyright(c) 2006-2007, Ext JS, LLC.
8882 * Originally Released Under LGPL - original licence link has changed is not relivant.
8885 * <script type="text/javascript">
8888 * @class Roo.form.VTypes
8889 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8892 Roo.form.VTypes = function(){
8893 // closure these in so they are only created once.
8894 var alpha = /^[a-zA-Z_]+$/;
8895 var alphanum = /^[a-zA-Z0-9_]+$/;
8896 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8897 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8899 // All these messages and functions are configurable
8902 * The function used to validate email addresses
8903 * @param {String} value The email address
8905 'email' : function(v){
8906 return email.test(v);
8909 * The error text to display when the email validation function returns false
8912 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8914 * The keystroke filter mask to be applied on email input
8917 'emailMask' : /[a-z0-9_\.\-@]/i,
8920 * The function used to validate URLs
8921 * @param {String} value The URL
8923 'url' : function(v){
8927 * The error text to display when the url validation function returns false
8930 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8933 * The function used to validate alpha values
8934 * @param {String} value The value
8936 'alpha' : function(v){
8937 return alpha.test(v);
8940 * The error text to display when the alpha validation function returns false
8943 'alphaText' : 'This field should only contain letters and _',
8945 * The keystroke filter mask to be applied on alpha input
8948 'alphaMask' : /[a-z_]/i,
8951 * The function used to validate alphanumeric values
8952 * @param {String} value The value
8954 'alphanum' : function(v){
8955 return alphanum.test(v);
8958 * The error text to display when the alphanumeric validation function returns false
8961 'alphanumText' : 'This field should only contain letters, numbers and _',
8963 * The keystroke filter mask to be applied on alphanumeric input
8966 'alphanumMask' : /[a-z0-9_]/i
8976 * @class Roo.bootstrap.Input
8977 * @extends Roo.bootstrap.Component
8978 * Bootstrap Input class
8979 * @cfg {Boolean} disabled is it disabled
8980 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8981 * @cfg {String} name name of the input
8982 * @cfg {string} fieldLabel - the label associated
8983 * @cfg {string} placeholder - placeholder to put in text.
8984 * @cfg {string} before - input group add on before
8985 * @cfg {string} after - input group add on after
8986 * @cfg {string} size - (lg|sm) or leave empty..
8987 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8988 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8989 * @cfg {Number} md colspan out of 12 for computer-sized screens
8990 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8991 * @cfg {string} value default value of the input
8992 * @cfg {Number} labelWidth set the width of label
8993 * @cfg {Number} labellg set the width of label (1-12)
8994 * @cfg {Number} labelmd set the width of label (1-12)
8995 * @cfg {Number} labelsm set the width of label (1-12)
8996 * @cfg {Number} labelxs set the width of label (1-12)
8997 * @cfg {String} labelAlign (top|left)
8998 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8999 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
9000 * @cfg {String} indicatorpos (left|right) default left
9001 * @cfg {String} capture (user|camera) use for file input only. (default empty)
9002 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
9004 * @cfg {String} align (left|center|right) Default left
9005 * @cfg {Boolean} forceFeedback (true|false) Default false
9008 * Create a new Input
9009 * @param {Object} config The config object
9012 Roo.bootstrap.Input = function(config){
9014 Roo.bootstrap.Input.superclass.constructor.call(this, config);
9019 * Fires when this field receives input focus.
9020 * @param {Roo.form.Field} this
9025 * Fires when this field loses input focus.
9026 * @param {Roo.form.Field} this
9031 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
9032 * {@link Roo.EventObject#getKey} to determine which key was pressed.
9033 * @param {Roo.form.Field} this
9034 * @param {Roo.EventObject} e The event object
9039 * Fires just before the field blurs if the field value has changed.
9040 * @param {Roo.form.Field} this
9041 * @param {Mixed} newValue The new value
9042 * @param {Mixed} oldValue The original value
9047 * Fires after the field has been marked as invalid.
9048 * @param {Roo.form.Field} this
9049 * @param {String} msg The validation message
9054 * Fires after the field has been validated with no errors.
9055 * @param {Roo.form.Field} this
9060 * Fires after the key up
9061 * @param {Roo.form.Field} this
9062 * @param {Roo.EventObject} e The event Object
9068 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9070 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9071 automatic validation (defaults to "keyup").
9073 validationEvent : "keyup",
9075 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9077 validateOnBlur : true,
9079 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9081 validationDelay : 250,
9083 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9085 focusClass : "x-form-focus", // not needed???
9089 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9091 invalidClass : "has-warning",
9094 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9096 validClass : "has-success",
9099 * @cfg {Boolean} hasFeedback (true|false) default true
9104 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9106 invalidFeedbackClass : "glyphicon-warning-sign",
9109 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9111 validFeedbackClass : "glyphicon-ok",
9114 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9116 selectOnFocus : false,
9119 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9123 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9128 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9130 disableKeyFilter : false,
9133 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9137 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9141 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9143 blankText : "Please complete this mandatory field",
9146 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9150 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9152 maxLength : Number.MAX_VALUE,
9154 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9156 minLengthText : "The minimum length for this field is {0}",
9158 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9160 maxLengthText : "The maximum length for this field is {0}",
9164 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9165 * If available, this function will be called only after the basic validators all return true, and will be passed the
9166 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9170 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9171 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9172 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9176 * @cfg {String} regexText -- Depricated - use Invalid Text
9181 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9187 autocomplete: false,
9206 formatedValue : false,
9207 forceFeedback : false,
9209 indicatorpos : 'left',
9219 parentLabelAlign : function()
9222 while (parent.parent()) {
9223 parent = parent.parent();
9224 if (typeof(parent.labelAlign) !='undefined') {
9225 return parent.labelAlign;
9232 getAutoCreate : function()
9234 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9240 if(this.inputType != 'hidden'){
9241 cfg.cls = 'form-group' //input-group
9247 type : this.inputType,
9249 cls : 'form-control',
9250 placeholder : this.placeholder || '',
9251 autocomplete : this.autocomplete || 'new-password'
9254 if(this.capture.length){
9255 input.capture = this.capture;
9258 if(this.accept.length){
9259 input.accept = this.accept + "/*";
9263 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9266 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9267 input.maxLength = this.maxLength;
9270 if (this.disabled) {
9271 input.disabled=true;
9274 if (this.readOnly) {
9275 input.readonly=true;
9279 input.name = this.name;
9283 input.cls += ' input-' + this.size;
9287 ['xs','sm','md','lg'].map(function(size){
9288 if (settings[size]) {
9289 cfg.cls += ' col-' + size + '-' + settings[size];
9293 var inputblock = input;
9297 cls: 'glyphicon form-control-feedback'
9300 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9303 cls : 'has-feedback',
9311 if (this.before || this.after) {
9314 cls : 'input-group',
9318 if (this.before && typeof(this.before) == 'string') {
9320 inputblock.cn.push({
9322 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9326 if (this.before && typeof(this.before) == 'object') {
9327 this.before = Roo.factory(this.before);
9329 inputblock.cn.push({
9331 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9332 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9336 inputblock.cn.push(input);
9338 if (this.after && typeof(this.after) == 'string') {
9339 inputblock.cn.push({
9341 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9345 if (this.after && typeof(this.after) == 'object') {
9346 this.after = Roo.factory(this.after);
9348 inputblock.cn.push({
9350 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9351 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9355 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9356 inputblock.cls += ' has-feedback';
9357 inputblock.cn.push(feedback);
9362 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9363 tooltip : 'This field is required'
9365 if (Roo.bootstrap.version == 4) {
9368 style : 'display-none'
9371 if (align ==='left' && this.fieldLabel.length) {
9373 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9380 cls : 'control-label col-form-label',
9381 html : this.fieldLabel
9392 var labelCfg = cfg.cn[1];
9393 var contentCfg = cfg.cn[2];
9395 if(this.indicatorpos == 'right'){
9400 cls : 'control-label col-form-label',
9404 html : this.fieldLabel
9418 labelCfg = cfg.cn[0];
9419 contentCfg = cfg.cn[1];
9423 if(this.labelWidth > 12){
9424 labelCfg.style = "width: " + this.labelWidth + 'px';
9427 if(this.labelWidth < 13 && this.labelmd == 0){
9428 this.labelmd = this.labelWidth;
9431 if(this.labellg > 0){
9432 labelCfg.cls += ' col-lg-' + this.labellg;
9433 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9436 if(this.labelmd > 0){
9437 labelCfg.cls += ' col-md-' + this.labelmd;
9438 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9441 if(this.labelsm > 0){
9442 labelCfg.cls += ' col-sm-' + this.labelsm;
9443 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9446 if(this.labelxs > 0){
9447 labelCfg.cls += ' col-xs-' + this.labelxs;
9448 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9452 } else if ( this.fieldLabel.length) {
9457 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9458 tooltip : 'This field is required'
9462 //cls : 'input-group-addon',
9463 html : this.fieldLabel
9471 if(this.indicatorpos == 'right'){
9476 //cls : 'input-group-addon',
9477 html : this.fieldLabel
9482 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9483 tooltip : 'This field is required'
9503 if (this.parentType === 'Navbar' && this.parent().bar) {
9504 cfg.cls += ' navbar-form';
9507 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9508 // on BS4 we do this only if not form
9509 cfg.cls += ' navbar-form';
9517 * return the real input element.
9519 inputEl: function ()
9521 return this.el.select('input.form-control',true).first();
9524 tooltipEl : function()
9526 return this.inputEl();
9529 indicatorEl : function()
9531 if (Roo.bootstrap.version == 4) {
9532 return false; // not enabled in v4 yet.
9535 var indicator = this.el.select('i.roo-required-indicator',true).first();
9545 setDisabled : function(v)
9547 var i = this.inputEl().dom;
9549 i.removeAttribute('disabled');
9553 i.setAttribute('disabled','true');
9555 initEvents : function()
9558 this.inputEl().on("keydown" , this.fireKey, this);
9559 this.inputEl().on("focus", this.onFocus, this);
9560 this.inputEl().on("blur", this.onBlur, this);
9562 this.inputEl().relayEvent('keyup', this);
9564 this.indicator = this.indicatorEl();
9567 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9570 // reference to original value for reset
9571 this.originalValue = this.getValue();
9572 //Roo.form.TextField.superclass.initEvents.call(this);
9573 if(this.validationEvent == 'keyup'){
9574 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9575 this.inputEl().on('keyup', this.filterValidation, this);
9577 else if(this.validationEvent !== false){
9578 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9581 if(this.selectOnFocus){
9582 this.on("focus", this.preFocus, this);
9585 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9586 this.inputEl().on("keypress", this.filterKeys, this);
9588 this.inputEl().relayEvent('keypress', this);
9591 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9592 this.el.on("click", this.autoSize, this);
9595 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9596 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9599 if (typeof(this.before) == 'object') {
9600 this.before.render(this.el.select('.roo-input-before',true).first());
9602 if (typeof(this.after) == 'object') {
9603 this.after.render(this.el.select('.roo-input-after',true).first());
9606 this.inputEl().on('change', this.onChange, this);
9609 filterValidation : function(e){
9610 if(!e.isNavKeyPress()){
9611 this.validationTask.delay(this.validationDelay);
9615 * Validates the field value
9616 * @return {Boolean} True if the value is valid, else false
9618 validate : function(){
9619 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9620 if(this.disabled || this.validateValue(this.getRawValue())){
9631 * Validates a value according to the field's validation rules and marks the field as invalid
9632 * if the validation fails
9633 * @param {Mixed} value The value to validate
9634 * @return {Boolean} True if the value is valid, else false
9636 validateValue : function(value)
9638 if(this.getVisibilityEl().hasClass('hidden')){
9642 if(value.length < 1) { // if it's blank
9643 if(this.allowBlank){
9649 if(value.length < this.minLength){
9652 if(value.length > this.maxLength){
9656 var vt = Roo.form.VTypes;
9657 if(!vt[this.vtype](value, this)){
9661 if(typeof this.validator == "function"){
9662 var msg = this.validator(value);
9666 if (typeof(msg) == 'string') {
9667 this.invalidText = msg;
9671 if(this.regex && !this.regex.test(value)){
9679 fireKey : function(e){
9680 //Roo.log('field ' + e.getKey());
9681 if(e.isNavKeyPress()){
9682 this.fireEvent("specialkey", this, e);
9685 focus : function (selectText){
9687 this.inputEl().focus();
9688 if(selectText === true){
9689 this.inputEl().dom.select();
9695 onFocus : function(){
9696 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9697 // this.el.addClass(this.focusClass);
9700 this.hasFocus = true;
9701 this.startValue = this.getValue();
9702 this.fireEvent("focus", this);
9706 beforeBlur : Roo.emptyFn,
9710 onBlur : function(){
9712 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9713 //this.el.removeClass(this.focusClass);
9715 this.hasFocus = false;
9716 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9719 var v = this.getValue();
9720 if(String(v) !== String(this.startValue)){
9721 this.fireEvent('change', this, v, this.startValue);
9723 this.fireEvent("blur", this);
9726 onChange : function(e)
9728 var v = this.getValue();
9729 if(String(v) !== String(this.startValue)){
9730 this.fireEvent('change', this, v, this.startValue);
9736 * Resets the current field value to the originally loaded value and clears any validation messages
9739 this.setValue(this.originalValue);
9743 * Returns the name of the field
9744 * @return {Mixed} name The name field
9746 getName: function(){
9750 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9751 * @return {Mixed} value The field value
9753 getValue : function(){
9755 var v = this.inputEl().getValue();
9760 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9761 * @return {Mixed} value The field value
9763 getRawValue : function(){
9764 var v = this.inputEl().getValue();
9770 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9771 * @param {Mixed} value The value to set
9773 setRawValue : function(v){
9774 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9777 selectText : function(start, end){
9778 var v = this.getRawValue();
9780 start = start === undefined ? 0 : start;
9781 end = end === undefined ? v.length : end;
9782 var d = this.inputEl().dom;
9783 if(d.setSelectionRange){
9784 d.setSelectionRange(start, end);
9785 }else if(d.createTextRange){
9786 var range = d.createTextRange();
9787 range.moveStart("character", start);
9788 range.moveEnd("character", v.length-end);
9795 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9796 * @param {Mixed} value The value to set
9798 setValue : function(v){
9801 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9807 processValue : function(value){
9808 if(this.stripCharsRe){
9809 var newValue = value.replace(this.stripCharsRe, '');
9810 if(newValue !== value){
9811 this.setRawValue(newValue);
9818 preFocus : function(){
9820 if(this.selectOnFocus){
9821 this.inputEl().dom.select();
9824 filterKeys : function(e){
9826 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9829 var c = e.getCharCode(), cc = String.fromCharCode(c);
9830 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9833 if(!this.maskRe.test(cc)){
9838 * Clear any invalid styles/messages for this field
9840 clearInvalid : function(){
9842 if(!this.el || this.preventMark){ // not rendered
9847 this.el.removeClass([this.invalidClass, 'is-invalid']);
9849 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9851 var feedback = this.el.select('.form-control-feedback', true).first();
9854 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9860 this.indicator.removeClass('visible');
9861 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9864 this.fireEvent('valid', this);
9868 * Mark this field as valid
9870 markValid : function()
9872 if(!this.el || this.preventMark){ // not rendered...
9876 this.el.removeClass([this.invalidClass, this.validClass]);
9877 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9879 var feedback = this.el.select('.form-control-feedback', true).first();
9882 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9886 this.indicator.removeClass('visible');
9887 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9894 if(this.allowBlank && !this.getRawValue().length){
9897 if (Roo.bootstrap.version == 3) {
9898 this.el.addClass(this.validClass);
9900 this.inputEl().addClass('is-valid');
9903 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9905 var feedback = this.el.select('.form-control-feedback', true).first();
9908 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9909 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9914 this.fireEvent('valid', this);
9918 * Mark this field as invalid
9919 * @param {String} msg The validation message
9921 markInvalid : function(msg)
9923 if(!this.el || this.preventMark){ // not rendered
9927 this.el.removeClass([this.invalidClass, this.validClass]);
9928 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9930 var feedback = this.el.select('.form-control-feedback', true).first();
9933 this.el.select('.form-control-feedback', true).first().removeClass(
9934 [this.invalidFeedbackClass, this.validFeedbackClass]);
9941 if(this.allowBlank && !this.getRawValue().length){
9946 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9947 this.indicator.addClass('visible');
9949 if (Roo.bootstrap.version == 3) {
9950 this.el.addClass(this.invalidClass);
9952 this.inputEl().addClass('is-invalid');
9957 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9959 var feedback = this.el.select('.form-control-feedback', true).first();
9962 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9964 if(this.getValue().length || this.forceFeedback){
9965 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9972 this.fireEvent('invalid', this, msg);
9975 SafariOnKeyDown : function(event)
9977 // this is a workaround for a password hang bug on chrome/ webkit.
9978 if (this.inputEl().dom.type != 'password') {
9982 var isSelectAll = false;
9984 if(this.inputEl().dom.selectionEnd > 0){
9985 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9987 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9988 event.preventDefault();
9993 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9995 event.preventDefault();
9996 // this is very hacky as keydown always get's upper case.
9998 var cc = String.fromCharCode(event.getCharCode());
9999 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
10003 adjustWidth : function(tag, w){
10004 tag = tag.toLowerCase();
10005 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
10006 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
10007 if(tag == 'input'){
10010 if(tag == 'textarea'){
10013 }else if(Roo.isOpera){
10014 if(tag == 'input'){
10017 if(tag == 'textarea'){
10025 setFieldLabel : function(v)
10027 if(!this.rendered){
10031 if(this.indicatorEl()){
10032 var ar = this.el.select('label > span',true);
10034 if (ar.elements.length) {
10035 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10036 this.fieldLabel = v;
10040 var br = this.el.select('label',true);
10042 if(br.elements.length) {
10043 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10044 this.fieldLabel = v;
10048 Roo.log('Cannot Found any of label > span || label in input');
10052 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10053 this.fieldLabel = v;
10068 * @class Roo.bootstrap.TextArea
10069 * @extends Roo.bootstrap.Input
10070 * Bootstrap TextArea class
10071 * @cfg {Number} cols Specifies the visible width of a text area
10072 * @cfg {Number} rows Specifies the visible number of lines in a text area
10073 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10074 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10075 * @cfg {string} html text
10078 * Create a new TextArea
10079 * @param {Object} config The config object
10082 Roo.bootstrap.TextArea = function(config){
10083 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10087 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10097 getAutoCreate : function(){
10099 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10105 if(this.inputType != 'hidden'){
10106 cfg.cls = 'form-group' //input-group
10114 value : this.value || '',
10115 html: this.html || '',
10116 cls : 'form-control',
10117 placeholder : this.placeholder || ''
10121 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10122 input.maxLength = this.maxLength;
10126 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10130 input.cols = this.cols;
10133 if (this.readOnly) {
10134 input.readonly = true;
10138 input.name = this.name;
10142 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10146 ['xs','sm','md','lg'].map(function(size){
10147 if (settings[size]) {
10148 cfg.cls += ' col-' + size + '-' + settings[size];
10152 var inputblock = input;
10154 if(this.hasFeedback && !this.allowBlank){
10158 cls: 'glyphicon form-control-feedback'
10162 cls : 'has-feedback',
10171 if (this.before || this.after) {
10174 cls : 'input-group',
10178 inputblock.cn.push({
10180 cls : 'input-group-addon',
10185 inputblock.cn.push(input);
10187 if(this.hasFeedback && !this.allowBlank){
10188 inputblock.cls += ' has-feedback';
10189 inputblock.cn.push(feedback);
10193 inputblock.cn.push({
10195 cls : 'input-group-addon',
10202 if (align ==='left' && this.fieldLabel.length) {
10207 cls : 'control-label',
10208 html : this.fieldLabel
10219 if(this.labelWidth > 12){
10220 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10223 if(this.labelWidth < 13 && this.labelmd == 0){
10224 this.labelmd = this.labelWidth;
10227 if(this.labellg > 0){
10228 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10229 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10232 if(this.labelmd > 0){
10233 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10234 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10237 if(this.labelsm > 0){
10238 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10239 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10242 if(this.labelxs > 0){
10243 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10244 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10247 } else if ( this.fieldLabel.length) {
10252 //cls : 'input-group-addon',
10253 html : this.fieldLabel
10271 if (this.disabled) {
10272 input.disabled=true;
10279 * return the real textarea element.
10281 inputEl: function ()
10283 return this.el.select('textarea.form-control',true).first();
10287 * Clear any invalid styles/messages for this field
10289 clearInvalid : function()
10292 if(!this.el || this.preventMark){ // not rendered
10296 var label = this.el.select('label', true).first();
10297 var icon = this.el.select('i.fa-star', true).first();
10302 this.el.removeClass( this.validClass);
10303 this.inputEl().removeClass('is-invalid');
10305 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10307 var feedback = this.el.select('.form-control-feedback', true).first();
10310 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10315 this.fireEvent('valid', this);
10319 * Mark this field as valid
10321 markValid : function()
10323 if(!this.el || this.preventMark){ // not rendered
10327 this.el.removeClass([this.invalidClass, this.validClass]);
10328 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10330 var feedback = this.el.select('.form-control-feedback', true).first();
10333 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10336 if(this.disabled || this.allowBlank){
10340 var label = this.el.select('label', true).first();
10341 var icon = this.el.select('i.fa-star', true).first();
10346 if (Roo.bootstrap.version == 3) {
10347 this.el.addClass(this.validClass);
10349 this.inputEl().addClass('is-valid');
10353 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10355 var feedback = this.el.select('.form-control-feedback', true).first();
10358 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10359 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10364 this.fireEvent('valid', this);
10368 * Mark this field as invalid
10369 * @param {String} msg The validation message
10371 markInvalid : function(msg)
10373 if(!this.el || this.preventMark){ // not rendered
10377 this.el.removeClass([this.invalidClass, this.validClass]);
10378 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10380 var feedback = this.el.select('.form-control-feedback', true).first();
10383 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10386 if(this.disabled || this.allowBlank){
10390 var label = this.el.select('label', true).first();
10391 var icon = this.el.select('i.fa-star', true).first();
10393 if(!this.getValue().length && label && !icon){
10394 this.el.createChild({
10396 cls : 'text-danger fa fa-lg fa-star',
10397 tooltip : 'This field is required',
10398 style : 'margin-right:5px;'
10402 if (Roo.bootstrap.version == 3) {
10403 this.el.addClass(this.invalidClass);
10405 this.inputEl().addClass('is-invalid');
10408 // fixme ... this may be depricated need to test..
10409 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10411 var feedback = this.el.select('.form-control-feedback', true).first();
10414 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10416 if(this.getValue().length || this.forceFeedback){
10417 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10424 this.fireEvent('invalid', this, msg);
10432 * trigger field - base class for combo..
10437 * @class Roo.bootstrap.TriggerField
10438 * @extends Roo.bootstrap.Input
10439 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10440 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10441 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10442 * for which you can provide a custom implementation. For example:
10444 var trigger = new Roo.bootstrap.TriggerField();
10445 trigger.onTriggerClick = myTriggerFn;
10446 trigger.applyTo('my-field');
10449 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10450 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10451 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10452 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10453 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
10456 * Create a new TriggerField.
10457 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10458 * to the base TextField)
10460 Roo.bootstrap.TriggerField = function(config){
10461 this.mimicing = false;
10462 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10465 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10467 * @cfg {String} triggerClass A CSS class to apply to the trigger
10470 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10475 * @cfg {Boolean} removable (true|false) special filter default false
10479 /** @cfg {Boolean} grow @hide */
10480 /** @cfg {Number} growMin @hide */
10481 /** @cfg {Number} growMax @hide */
10487 autoSize: Roo.emptyFn,
10491 deferHeight : true,
10494 actionMode : 'wrap',
10499 getAutoCreate : function(){
10501 var align = this.labelAlign || this.parentLabelAlign();
10506 cls: 'form-group' //input-group
10513 type : this.inputType,
10514 cls : 'form-control',
10515 autocomplete: 'new-password',
10516 placeholder : this.placeholder || ''
10520 input.name = this.name;
10523 input.cls += ' input-' + this.size;
10526 if (this.disabled) {
10527 input.disabled=true;
10530 var inputblock = input;
10532 if(this.hasFeedback && !this.allowBlank){
10536 cls: 'glyphicon form-control-feedback'
10539 if(this.removable && !this.editable && !this.tickable){
10541 cls : 'has-feedback',
10547 cls : 'roo-combo-removable-btn close'
10554 cls : 'has-feedback',
10563 if(this.removable && !this.editable && !this.tickable){
10565 cls : 'roo-removable',
10571 cls : 'roo-combo-removable-btn close'
10578 if (this.before || this.after) {
10581 cls : 'input-group',
10585 inputblock.cn.push({
10587 cls : 'input-group-addon input-group-prepend input-group-text',
10592 inputblock.cn.push(input);
10594 if(this.hasFeedback && !this.allowBlank){
10595 inputblock.cls += ' has-feedback';
10596 inputblock.cn.push(feedback);
10600 inputblock.cn.push({
10602 cls : 'input-group-addon input-group-append input-group-text',
10611 var ibwrap = inputblock;
10616 cls: 'roo-select2-choices',
10620 cls: 'roo-select2-search-field',
10632 cls: 'roo-select2-container input-group',
10637 cls: 'form-hidden-field'
10643 if(!this.multiple && this.showToggleBtn){
10649 if (this.caret != false) {
10652 cls: 'fa fa-' + this.caret
10659 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10661 Roo.bootstrap.version == 3 ? caret : '',
10664 cls: 'combobox-clear',
10678 combobox.cls += ' roo-select2-container-multi';
10682 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10683 tooltip : 'This field is required'
10685 if (Roo.bootstrap.version == 4) {
10688 style : 'display:none'
10693 if (align ==='left' && this.fieldLabel.length) {
10695 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10702 cls : 'control-label',
10703 html : this.fieldLabel
10715 var labelCfg = cfg.cn[1];
10716 var contentCfg = cfg.cn[2];
10718 if(this.indicatorpos == 'right'){
10723 cls : 'control-label',
10727 html : this.fieldLabel
10741 labelCfg = cfg.cn[0];
10742 contentCfg = cfg.cn[1];
10745 if(this.labelWidth > 12){
10746 labelCfg.style = "width: " + this.labelWidth + 'px';
10749 if(this.labelWidth < 13 && this.labelmd == 0){
10750 this.labelmd = this.labelWidth;
10753 if(this.labellg > 0){
10754 labelCfg.cls += ' col-lg-' + this.labellg;
10755 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10758 if(this.labelmd > 0){
10759 labelCfg.cls += ' col-md-' + this.labelmd;
10760 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10763 if(this.labelsm > 0){
10764 labelCfg.cls += ' col-sm-' + this.labelsm;
10765 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10768 if(this.labelxs > 0){
10769 labelCfg.cls += ' col-xs-' + this.labelxs;
10770 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10773 } else if ( this.fieldLabel.length) {
10774 // Roo.log(" label");
10779 //cls : 'input-group-addon',
10780 html : this.fieldLabel
10788 if(this.indicatorpos == 'right'){
10796 html : this.fieldLabel
10810 // Roo.log(" no label && no align");
10817 ['xs','sm','md','lg'].map(function(size){
10818 if (settings[size]) {
10819 cfg.cls += ' col-' + size + '-' + settings[size];
10830 onResize : function(w, h){
10831 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10832 // if(typeof w == 'number'){
10833 // var x = w - this.trigger.getWidth();
10834 // this.inputEl().setWidth(this.adjustWidth('input', x));
10835 // this.trigger.setStyle('left', x+'px');
10840 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10843 getResizeEl : function(){
10844 return this.inputEl();
10848 getPositionEl : function(){
10849 return this.inputEl();
10853 alignErrorIcon : function(){
10854 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10858 initEvents : function(){
10862 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10863 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10864 if(!this.multiple && this.showToggleBtn){
10865 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10866 if(this.hideTrigger){
10867 this.trigger.setDisplayed(false);
10869 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10873 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10876 if(this.removable && !this.editable && !this.tickable){
10877 var close = this.closeTriggerEl();
10880 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10881 close.on('click', this.removeBtnClick, this, close);
10885 //this.trigger.addClassOnOver('x-form-trigger-over');
10886 //this.trigger.addClassOnClick('x-form-trigger-click');
10889 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10893 closeTriggerEl : function()
10895 var close = this.el.select('.roo-combo-removable-btn', true).first();
10896 return close ? close : false;
10899 removeBtnClick : function(e, h, el)
10901 e.preventDefault();
10903 if(this.fireEvent("remove", this) !== false){
10905 this.fireEvent("afterremove", this)
10909 createList : function()
10911 this.list = Roo.get(document.body).createChild({
10912 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10913 cls: 'typeahead typeahead-long dropdown-menu',
10914 style: 'display:none'
10917 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10922 initTrigger : function(){
10927 onDestroy : function(){
10929 this.trigger.removeAllListeners();
10930 // this.trigger.remove();
10933 // this.wrap.remove();
10935 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10939 onFocus : function(){
10940 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10942 if(!this.mimicing){
10943 this.wrap.addClass('x-trigger-wrap-focus');
10944 this.mimicing = true;
10945 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10946 if(this.monitorTab){
10947 this.el.on("keydown", this.checkTab, this);
10954 checkTab : function(e){
10955 if(e.getKey() == e.TAB){
10956 this.triggerBlur();
10961 onBlur : function(){
10966 mimicBlur : function(e, t){
10968 if(!this.wrap.contains(t) && this.validateBlur()){
10969 this.triggerBlur();
10975 triggerBlur : function(){
10976 this.mimicing = false;
10977 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10978 if(this.monitorTab){
10979 this.el.un("keydown", this.checkTab, this);
10981 //this.wrap.removeClass('x-trigger-wrap-focus');
10982 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10986 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10987 validateBlur : function(e, t){
10992 onDisable : function(){
10993 this.inputEl().dom.disabled = true;
10994 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10996 // this.wrap.addClass('x-item-disabled');
11001 onEnable : function(){
11002 this.inputEl().dom.disabled = false;
11003 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
11005 // this.el.removeClass('x-item-disabled');
11010 onShow : function(){
11011 var ae = this.getActionEl();
11014 ae.dom.style.display = '';
11015 ae.dom.style.visibility = 'visible';
11021 onHide : function(){
11022 var ae = this.getActionEl();
11023 ae.dom.style.display = 'none';
11027 * The function that should handle the trigger's click event. This method does nothing by default until overridden
11028 * by an implementing function.
11030 * @param {EventObject} e
11032 onTriggerClick : Roo.emptyFn
11036 * Ext JS Library 1.1.1
11037 * Copyright(c) 2006-2007, Ext JS, LLC.
11039 * Originally Released Under LGPL - original licence link has changed is not relivant.
11042 * <script type="text/javascript">
11047 * @class Roo.data.SortTypes
11049 * Defines the default sorting (casting?) comparison functions used when sorting data.
11051 Roo.data.SortTypes = {
11053 * Default sort that does nothing
11054 * @param {Mixed} s The value being converted
11055 * @return {Mixed} The comparison value
11057 none : function(s){
11062 * The regular expression used to strip tags
11066 stripTagsRE : /<\/?[^>]+>/gi,
11069 * Strips all HTML tags to sort on text only
11070 * @param {Mixed} s The value being converted
11071 * @return {String} The comparison value
11073 asText : function(s){
11074 return String(s).replace(this.stripTagsRE, "");
11078 * Strips all HTML tags to sort on text only - Case insensitive
11079 * @param {Mixed} s The value being converted
11080 * @return {String} The comparison value
11082 asUCText : function(s){
11083 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11087 * Case insensitive string
11088 * @param {Mixed} s The value being converted
11089 * @return {String} The comparison value
11091 asUCString : function(s) {
11092 return String(s).toUpperCase();
11097 * @param {Mixed} s The value being converted
11098 * @return {Number} The comparison value
11100 asDate : function(s) {
11104 if(s instanceof Date){
11105 return s.getTime();
11107 return Date.parse(String(s));
11112 * @param {Mixed} s The value being converted
11113 * @return {Float} The comparison value
11115 asFloat : function(s) {
11116 var val = parseFloat(String(s).replace(/,/g, ""));
11125 * @param {Mixed} s The value being converted
11126 * @return {Number} The comparison value
11128 asInt : function(s) {
11129 var val = parseInt(String(s).replace(/,/g, ""));
11137 * Ext JS Library 1.1.1
11138 * Copyright(c) 2006-2007, Ext JS, LLC.
11140 * Originally Released Under LGPL - original licence link has changed is not relivant.
11143 * <script type="text/javascript">
11147 * @class Roo.data.Record
11148 * Instances of this class encapsulate both record <em>definition</em> information, and record
11149 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11150 * to access Records cached in an {@link Roo.data.Store} object.<br>
11152 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11153 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11156 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11158 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11159 * {@link #create}. The parameters are the same.
11160 * @param {Array} data An associative Array of data values keyed by the field name.
11161 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11162 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11163 * not specified an integer id is generated.
11165 Roo.data.Record = function(data, id){
11166 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11171 * Generate a constructor for a specific record layout.
11172 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11173 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11174 * Each field definition object may contain the following properties: <ul>
11175 * <li><b>name</b> : String<p style="margin-left:1em">The name by which the field is referenced within the Record. This is referenced by,
11176 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11177 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11178 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11179 * is being used, then this is a string containing the javascript expression to reference the data relative to
11180 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11181 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11182 * this may be omitted.</p></li>
11183 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11184 * <ul><li>auto (Default, implies no conversion)</li>
11189 * <li>date</li></ul></p></li>
11190 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11191 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11192 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11193 * by the Reader into an object that will be stored in the Record. It is passed the
11194 * following parameters:<ul>
11195 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11197 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11199 * <br>usage:<br><pre><code>
11200 var TopicRecord = Roo.data.Record.create(
11201 {name: 'title', mapping: 'topic_title'},
11202 {name: 'author', mapping: 'username'},
11203 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11204 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11205 {name: 'lastPoster', mapping: 'user2'},
11206 {name: 'excerpt', mapping: 'post_text'}
11209 var myNewRecord = new TopicRecord({
11210 title: 'Do my job please',
11213 lastPost: new Date(),
11214 lastPoster: 'Animal',
11215 excerpt: 'No way dude!'
11217 myStore.add(myNewRecord);
11222 Roo.data.Record.create = function(o){
11223 var f = function(){
11224 f.superclass.constructor.apply(this, arguments);
11226 Roo.extend(f, Roo.data.Record);
11227 var p = f.prototype;
11228 p.fields = new Roo.util.MixedCollection(false, function(field){
11231 for(var i = 0, len = o.length; i < len; i++){
11232 p.fields.add(new Roo.data.Field(o[i]));
11234 f.getField = function(name){
11235 return p.fields.get(name);
11240 Roo.data.Record.AUTO_ID = 1000;
11241 Roo.data.Record.EDIT = 'edit';
11242 Roo.data.Record.REJECT = 'reject';
11243 Roo.data.Record.COMMIT = 'commit';
11245 Roo.data.Record.prototype = {
11247 * Readonly flag - true if this record has been modified.
11256 join : function(store){
11257 this.store = store;
11261 * Set the named field to the specified value.
11262 * @param {String} name The name of the field to set.
11263 * @param {Object} value The value to set the field to.
11265 set : function(name, value){
11266 if(this.data[name] == value){
11270 if(!this.modified){
11271 this.modified = {};
11273 if(typeof this.modified[name] == 'undefined'){
11274 this.modified[name] = this.data[name];
11276 this.data[name] = value;
11277 if(!this.editing && this.store){
11278 this.store.afterEdit(this);
11283 * Get the value of the named field.
11284 * @param {String} name The name of the field to get the value of.
11285 * @return {Object} The value of the field.
11287 get : function(name){
11288 return this.data[name];
11292 beginEdit : function(){
11293 this.editing = true;
11294 this.modified = {};
11298 cancelEdit : function(){
11299 this.editing = false;
11300 delete this.modified;
11304 endEdit : function(){
11305 this.editing = false;
11306 if(this.dirty && this.store){
11307 this.store.afterEdit(this);
11312 * Usually called by the {@link Roo.data.Store} which owns the Record.
11313 * Rejects all changes made to the Record since either creation, or the last commit operation.
11314 * Modified fields are reverted to their original values.
11316 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11317 * of reject operations.
11319 reject : function(){
11320 var m = this.modified;
11322 if(typeof m[n] != "function"){
11323 this.data[n] = m[n];
11326 this.dirty = false;
11327 delete this.modified;
11328 this.editing = false;
11330 this.store.afterReject(this);
11335 * Usually called by the {@link Roo.data.Store} which owns the Record.
11336 * Commits all changes made to the Record since either creation, or the last commit operation.
11338 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11339 * of commit operations.
11341 commit : function(){
11342 this.dirty = false;
11343 delete this.modified;
11344 this.editing = false;
11346 this.store.afterCommit(this);
11351 hasError : function(){
11352 return this.error != null;
11356 clearError : function(){
11361 * Creates a copy of this record.
11362 * @param {String} id (optional) A new record id if you don't want to use this record's id
11365 copy : function(newId) {
11366 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11370 * Ext JS Library 1.1.1
11371 * Copyright(c) 2006-2007, Ext JS, LLC.
11373 * Originally Released Under LGPL - original licence link has changed is not relivant.
11376 * <script type="text/javascript">
11382 * @class Roo.data.Store
11383 * @extends Roo.util.Observable
11384 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11385 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11387 * A Store object uses an implementation of {@link Roo.data.DataProxy} to access a data object unless you call loadData() directly and pass in your data. The Store object
11388 * has no knowledge of the format of the data returned by the Proxy.<br>
11390 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11391 * instances from the data object. These records are cached and made available through accessor functions.
11393 * Creates a new Store.
11394 * @param {Object} config A config object containing the objects needed for the Store to access data,
11395 * and read the data into Records.
11397 Roo.data.Store = function(config){
11398 this.data = new Roo.util.MixedCollection(false);
11399 this.data.getKey = function(o){
11402 this.baseParams = {};
11404 this.paramNames = {
11409 "multisort" : "_multisort"
11412 if(config && config.data){
11413 this.inlineData = config.data;
11414 delete config.data;
11417 Roo.apply(this, config);
11419 if(this.reader){ // reader passed
11420 this.reader = Roo.factory(this.reader, Roo.data);
11421 this.reader.xmodule = this.xmodule || false;
11422 if(!this.recordType){
11423 this.recordType = this.reader.recordType;
11425 if(this.reader.onMetaChange){
11426 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11430 if(this.recordType){
11431 this.fields = this.recordType.prototype.fields;
11433 this.modified = [];
11437 * @event datachanged
11438 * Fires when the data cache has changed, and a widget which is using this Store
11439 * as a Record cache should refresh its view.
11440 * @param {Store} this
11442 datachanged : true,
11444 * @event metachange
11445 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11446 * @param {Store} this
11447 * @param {Object} meta The JSON metadata
11452 * Fires when Records have been added to the Store
11453 * @param {Store} this
11454 * @param {Roo.data.Record[]} records The array of Records added
11455 * @param {Number} index The index at which the record(s) were added
11460 * Fires when a Record has been removed from the Store
11461 * @param {Store} this
11462 * @param {Roo.data.Record} record The Record that was removed
11463 * @param {Number} index The index at which the record was removed
11468 * Fires when a Record has been updated
11469 * @param {Store} this
11470 * @param {Roo.data.Record} record The Record that was updated
11471 * @param {String} operation The update operation being performed. Value may be one of:
11473 Roo.data.Record.EDIT
11474 Roo.data.Record.REJECT
11475 Roo.data.Record.COMMIT
11481 * Fires when the data cache has been cleared.
11482 * @param {Store} this
11486 * @event beforeload
11487 * Fires before a request is made for a new data object. If the beforeload handler returns false
11488 * the load action will be canceled.
11489 * @param {Store} this
11490 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11494 * @event beforeloadadd
11495 * Fires after a new set of Records has been loaded.
11496 * @param {Store} this
11497 * @param {Roo.data.Record[]} records The Records that were loaded
11498 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11500 beforeloadadd : true,
11503 * Fires after a new set of Records has been loaded, before they are added to the store.
11504 * @param {Store} this
11505 * @param {Roo.data.Record[]} records The Records that were loaded
11506 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11507 * @params {Object} return from reader
11511 * @event loadexception
11512 * Fires if an exception occurs in the Proxy during loading.
11513 * Called with the signature of the Proxy's "loadexception" event.
11514 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11517 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11518 * @param {Object} load options
11519 * @param {Object} jsonData from your request (normally this contains the Exception)
11521 loadexception : true
11525 this.proxy = Roo.factory(this.proxy, Roo.data);
11526 this.proxy.xmodule = this.xmodule || false;
11527 this.relayEvents(this.proxy, ["loadexception"]);
11529 this.sortToggle = {};
11530 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11532 Roo.data.Store.superclass.constructor.call(this);
11534 if(this.inlineData){
11535 this.loadData(this.inlineData);
11536 delete this.inlineData;
11540 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11542 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11543 * without a remote query - used by combo/forms at present.
11547 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11550 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11553 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11554 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11557 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11558 * on any HTTP request
11561 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11564 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11568 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11569 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11571 remoteSort : false,
11574 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11575 * loaded or when a record is removed. (defaults to false).
11577 pruneModifiedRecords : false,
11580 lastOptions : null,
11583 * Add Records to the Store and fires the add event.
11584 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11586 add : function(records){
11587 records = [].concat(records);
11588 for(var i = 0, len = records.length; i < len; i++){
11589 records[i].join(this);
11591 var index = this.data.length;
11592 this.data.addAll(records);
11593 this.fireEvent("add", this, records, index);
11597 * Remove a Record from the Store and fires the remove event.
11598 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11600 remove : function(record){
11601 var index = this.data.indexOf(record);
11602 this.data.removeAt(index);
11604 if(this.pruneModifiedRecords){
11605 this.modified.remove(record);
11607 this.fireEvent("remove", this, record, index);
11611 * Remove all Records from the Store and fires the clear event.
11613 removeAll : function(){
11615 if(this.pruneModifiedRecords){
11616 this.modified = [];
11618 this.fireEvent("clear", this);
11622 * Inserts Records to the Store at the given index and fires the add event.
11623 * @param {Number} index The start index at which to insert the passed Records.
11624 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11626 insert : function(index, records){
11627 records = [].concat(records);
11628 for(var i = 0, len = records.length; i < len; i++){
11629 this.data.insert(index, records[i]);
11630 records[i].join(this);
11632 this.fireEvent("add", this, records, index);
11636 * Get the index within the cache of the passed Record.
11637 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11638 * @return {Number} The index of the passed Record. Returns -1 if not found.
11640 indexOf : function(record){
11641 return this.data.indexOf(record);
11645 * Get the index within the cache of the Record with the passed id.
11646 * @param {String} id The id of the Record to find.
11647 * @return {Number} The index of the Record. Returns -1 if not found.
11649 indexOfId : function(id){
11650 return this.data.indexOfKey(id);
11654 * Get the Record with the specified id.
11655 * @param {String} id The id of the Record to find.
11656 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11658 getById : function(id){
11659 return this.data.key(id);
11663 * Get the Record at the specified index.
11664 * @param {Number} index The index of the Record to find.
11665 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11667 getAt : function(index){
11668 return this.data.itemAt(index);
11672 * Returns a range of Records between specified indices.
11673 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11674 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11675 * @return {Roo.data.Record[]} An array of Records
11677 getRange : function(start, end){
11678 return this.data.getRange(start, end);
11682 storeOptions : function(o){
11683 o = Roo.apply({}, o);
11686 this.lastOptions = o;
11690 * Loads the Record cache from the configured Proxy using the configured Reader.
11692 * If using remote paging, then the first load call must specify the <em>start</em>
11693 * and <em>limit</em> properties in the options.params property to establish the initial
11694 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11696 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11697 * and this call will return before the new data has been loaded. Perform any post-processing
11698 * in a callback function, or in a "load" event handler.</strong>
11700 * @param {Object} options An object containing properties which control loading options:<ul>
11701 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11702 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11703 * passed the following arguments:<ul>
11704 * <li>r : Roo.data.Record[]</li>
11705 * <li>options: Options object from the load call</li>
11706 * <li>success: Boolean success indicator</li></ul></li>
11707 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11708 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11711 load : function(options){
11712 options = options || {};
11713 if(this.fireEvent("beforeload", this, options) !== false){
11714 this.storeOptions(options);
11715 var p = Roo.apply(options.params || {}, this.baseParams);
11716 // if meta was not loaded from remote source.. try requesting it.
11717 if (!this.reader.metaFromRemote) {
11718 p._requestMeta = 1;
11720 if(this.sortInfo && this.remoteSort){
11721 var pn = this.paramNames;
11722 p[pn["sort"]] = this.sortInfo.field;
11723 p[pn["dir"]] = this.sortInfo.direction;
11725 if (this.multiSort) {
11726 var pn = this.paramNames;
11727 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11730 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11735 * Reloads the Record cache from the configured Proxy using the configured Reader and
11736 * the options from the last load operation performed.
11737 * @param {Object} options (optional) An object containing properties which may override the options
11738 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11739 * the most recently used options are reused).
11741 reload : function(options){
11742 this.load(Roo.applyIf(options||{}, this.lastOptions));
11746 // Called as a callback by the Reader during a load operation.
11747 loadRecords : function(o, options, success){
11748 if(!o || success === false){
11749 if(success !== false){
11750 this.fireEvent("load", this, [], options, o);
11752 if(options.callback){
11753 options.callback.call(options.scope || this, [], options, false);
11757 // if data returned failure - throw an exception.
11758 if (o.success === false) {
11759 // show a message if no listener is registered.
11760 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11761 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11763 // loadmask wil be hooked into this..
11764 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11767 var r = o.records, t = o.totalRecords || r.length;
11769 this.fireEvent("beforeloadadd", this, r, options, o);
11771 if(!options || options.add !== true){
11772 if(this.pruneModifiedRecords){
11773 this.modified = [];
11775 for(var i = 0, len = r.length; i < len; i++){
11779 this.data = this.snapshot;
11780 delete this.snapshot;
11783 this.data.addAll(r);
11784 this.totalLength = t;
11786 this.fireEvent("datachanged", this);
11788 this.totalLength = Math.max(t, this.data.length+r.length);
11792 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11794 var e = new Roo.data.Record({});
11796 e.set(this.parent.displayField, this.parent.emptyTitle);
11797 e.set(this.parent.valueField, '');
11802 this.fireEvent("load", this, r, options, o);
11803 if(options.callback){
11804 options.callback.call(options.scope || this, r, options, true);
11810 * Loads data from a passed data block. A Reader which understands the format of the data
11811 * must have been configured in the constructor.
11812 * @param {Object} data The data block from which to read the Records. The format of the data expected
11813 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11814 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11816 loadData : function(o, append){
11817 var r = this.reader.readRecords(o);
11818 this.loadRecords(r, {add: append}, true);
11822 * Gets the number of cached records.
11824 * <em>If using paging, this may not be the total size of the dataset. If the data object
11825 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11826 * the data set size</em>
11828 getCount : function(){
11829 return this.data.length || 0;
11833 * Gets the total number of records in the dataset as returned by the server.
11835 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11836 * the dataset size</em>
11838 getTotalCount : function(){
11839 return this.totalLength || 0;
11843 * Returns the sort state of the Store as an object with two properties:
11845 field {String} The name of the field by which the Records are sorted
11846 direction {String} The sort order, "ASC" or "DESC"
11849 getSortState : function(){
11850 return this.sortInfo;
11854 applySort : function(){
11855 if(this.sortInfo && !this.remoteSort){
11856 var s = this.sortInfo, f = s.field;
11857 var st = this.fields.get(f).sortType;
11858 var fn = function(r1, r2){
11859 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11860 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11862 this.data.sort(s.direction, fn);
11863 if(this.snapshot && this.snapshot != this.data){
11864 this.snapshot.sort(s.direction, fn);
11870 * Sets the default sort column and order to be used by the next load operation.
11871 * @param {String} fieldName The name of the field to sort by.
11872 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11874 setDefaultSort : function(field, dir){
11875 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11879 * Sort the Records.
11880 * If remote sorting is used, the sort is performed on the server, and the cache is
11881 * reloaded. If local sorting is used, the cache is sorted internally.
11882 * @param {String} fieldName The name of the field to sort by.
11883 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11885 sort : function(fieldName, dir){
11886 var f = this.fields.get(fieldName);
11888 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11890 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11891 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11896 this.sortToggle[f.name] = dir;
11897 this.sortInfo = {field: f.name, direction: dir};
11898 if(!this.remoteSort){
11900 this.fireEvent("datachanged", this);
11902 this.load(this.lastOptions);
11907 * Calls the specified function for each of the Records in the cache.
11908 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11909 * Returning <em>false</em> aborts and exits the iteration.
11910 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11912 each : function(fn, scope){
11913 this.data.each(fn, scope);
11917 * Gets all records modified since the last commit. Modified records are persisted across load operations
11918 * (e.g., during paging).
11919 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11921 getModifiedRecords : function(){
11922 return this.modified;
11926 createFilterFn : function(property, value, anyMatch){
11927 if(!value.exec){ // not a regex
11928 value = String(value);
11929 if(value.length == 0){
11932 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11934 return function(r){
11935 return value.test(r.data[property]);
11940 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11941 * @param {String} property A field on your records
11942 * @param {Number} start The record index to start at (defaults to 0)
11943 * @param {Number} end The last record index to include (defaults to length - 1)
11944 * @return {Number} The sum
11946 sum : function(property, start, end){
11947 var rs = this.data.items, v = 0;
11948 start = start || 0;
11949 end = (end || end === 0) ? end : rs.length-1;
11951 for(var i = start; i <= end; i++){
11952 v += (rs[i].data[property] || 0);
11958 * Filter the records by a specified property.
11959 * @param {String} field A field on your records
11960 * @param {String/RegExp} value Either a string that the field
11961 * should start with or a RegExp to test against the field
11962 * @param {Boolean} anyMatch True to match any part not just the beginning
11964 filter : function(property, value, anyMatch){
11965 var fn = this.createFilterFn(property, value, anyMatch);
11966 return fn ? this.filterBy(fn) : this.clearFilter();
11970 * Filter by a function. The specified function will be called with each
11971 * record in this data source. If the function returns true the record is included,
11972 * otherwise it is filtered.
11973 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11974 * @param {Object} scope (optional) The scope of the function (defaults to this)
11976 filterBy : function(fn, scope){
11977 this.snapshot = this.snapshot || this.data;
11978 this.data = this.queryBy(fn, scope||this);
11979 this.fireEvent("datachanged", this);
11983 * Query the records by a specified property.
11984 * @param {String} field A field on your records
11985 * @param {String/RegExp} value Either a string that the field
11986 * should start with or a RegExp to test against the field
11987 * @param {Boolean} anyMatch True to match any part not just the beginning
11988 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11990 query : function(property, value, anyMatch){
11991 var fn = this.createFilterFn(property, value, anyMatch);
11992 return fn ? this.queryBy(fn) : this.data.clone();
11996 * Query by a function. The specified function will be called with each
11997 * record in this data source. If the function returns true the record is included
11999 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
12000 * @param {Object} scope (optional) The scope of the function (defaults to this)
12001 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
12003 queryBy : function(fn, scope){
12004 var data = this.snapshot || this.data;
12005 return data.filterBy(fn, scope||this);
12009 * Collects unique values for a particular dataIndex from this store.
12010 * @param {String} dataIndex The property to collect
12011 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
12012 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
12013 * @return {Array} An array of the unique values
12015 collect : function(dataIndex, allowNull, bypassFilter){
12016 var d = (bypassFilter === true && this.snapshot) ?
12017 this.snapshot.items : this.data.items;
12018 var v, sv, r = [], l = {};
12019 for(var i = 0, len = d.length; i < len; i++){
12020 v = d[i].data[dataIndex];
12022 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
12031 * Revert to a view of the Record cache with no filtering applied.
12032 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
12034 clearFilter : function(suppressEvent){
12035 if(this.snapshot && this.snapshot != this.data){
12036 this.data = this.snapshot;
12037 delete this.snapshot;
12038 if(suppressEvent !== true){
12039 this.fireEvent("datachanged", this);
12045 afterEdit : function(record){
12046 if(this.modified.indexOf(record) == -1){
12047 this.modified.push(record);
12049 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12053 afterReject : function(record){
12054 this.modified.remove(record);
12055 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12059 afterCommit : function(record){
12060 this.modified.remove(record);
12061 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12065 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12066 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12068 commitChanges : function(){
12069 var m = this.modified.slice(0);
12070 this.modified = [];
12071 for(var i = 0, len = m.length; i < len; i++){
12077 * Cancel outstanding changes on all changed records.
12079 rejectChanges : function(){
12080 var m = this.modified.slice(0);
12081 this.modified = [];
12082 for(var i = 0, len = m.length; i < len; i++){
12087 onMetaChange : function(meta, rtype, o){
12088 this.recordType = rtype;
12089 this.fields = rtype.prototype.fields;
12090 delete this.snapshot;
12091 this.sortInfo = meta.sortInfo || this.sortInfo;
12092 this.modified = [];
12093 this.fireEvent('metachange', this, this.reader.meta);
12096 moveIndex : function(data, type)
12098 var index = this.indexOf(data);
12100 var newIndex = index + type;
12104 this.insert(newIndex, data);
12109 * Ext JS Library 1.1.1
12110 * Copyright(c) 2006-2007, Ext JS, LLC.
12112 * Originally Released Under LGPL - original licence link has changed is not relivant.
12115 * <script type="text/javascript">
12119 * @class Roo.data.SimpleStore
12120 * @extends Roo.data.Store
12121 * Small helper class to make creating Stores from Array data easier.
12122 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12123 * @cfg {Array} fields An array of field definition objects, or field name strings.
12124 * @cfg {Array} data The multi-dimensional array of data
12126 * @param {Object} config
12128 Roo.data.SimpleStore = function(config){
12129 Roo.data.SimpleStore.superclass.constructor.call(this, {
12131 reader: new Roo.data.ArrayReader({
12134 Roo.data.Record.create(config.fields)
12136 proxy : new Roo.data.MemoryProxy(config.data)
12140 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12142 * Ext JS Library 1.1.1
12143 * Copyright(c) 2006-2007, Ext JS, LLC.
12145 * Originally Released Under LGPL - original licence link has changed is not relivant.
12148 * <script type="text/javascript">
12153 * @extends Roo.data.Store
12154 * @class Roo.data.JsonStore
12155 * Small helper class to make creating Stores for JSON data easier. <br/>
12157 var store = new Roo.data.JsonStore({
12158 url: 'get-images.php',
12160 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12163 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12164 * JsonReader and HttpProxy (unless inline data is provided).</b>
12165 * @cfg {Array} fields An array of field definition objects, or field name strings.
12167 * @param {Object} config
12169 Roo.data.JsonStore = function(c){
12170 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12171 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12172 reader: new Roo.data.JsonReader(c, c.fields)
12175 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12177 * Ext JS Library 1.1.1
12178 * Copyright(c) 2006-2007, Ext JS, LLC.
12180 * Originally Released Under LGPL - original licence link has changed is not relivant.
12183 * <script type="text/javascript">
12187 Roo.data.Field = function(config){
12188 if(typeof config == "string"){
12189 config = {name: config};
12191 Roo.apply(this, config);
12194 this.type = "auto";
12197 var st = Roo.data.SortTypes;
12198 // named sortTypes are supported, here we look them up
12199 if(typeof this.sortType == "string"){
12200 this.sortType = st[this.sortType];
12203 // set default sortType for strings and dates
12204 if(!this.sortType){
12207 this.sortType = st.asUCString;
12210 this.sortType = st.asDate;
12213 this.sortType = st.none;
12218 var stripRe = /[\$,%]/g;
12220 // prebuilt conversion function for this field, instead of
12221 // switching every time we're reading a value
12223 var cv, dateFormat = this.dateFormat;
12228 cv = function(v){ return v; };
12231 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12235 return v !== undefined && v !== null && v !== '' ?
12236 parseInt(String(v).replace(stripRe, ""), 10) : '';
12241 return v !== undefined && v !== null && v !== '' ?
12242 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12247 cv = function(v){ return v === true || v === "true" || v == 1; };
12254 if(v instanceof Date){
12258 if(dateFormat == "timestamp"){
12259 return new Date(v*1000);
12261 return Date.parseDate(v, dateFormat);
12263 var parsed = Date.parse(v);
12264 return parsed ? new Date(parsed) : null;
12273 Roo.data.Field.prototype = {
12281 * Ext JS Library 1.1.1
12282 * Copyright(c) 2006-2007, Ext JS, LLC.
12284 * Originally Released Under LGPL - original licence link has changed is not relivant.
12287 * <script type="text/javascript">
12290 // Base class for reading structured data from a data source. This class is intended to be
12291 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12294 * @class Roo.data.DataReader
12295 * Base class for reading structured data from a data source. This class is intended to be
12296 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12299 Roo.data.DataReader = function(meta, recordType){
12303 this.recordType = recordType instanceof Array ?
12304 Roo.data.Record.create(recordType) : recordType;
12307 Roo.data.DataReader.prototype = {
12309 * Create an empty record
12310 * @param {Object} data (optional) - overlay some values
12311 * @return {Roo.data.Record} record created.
12313 newRow : function(d) {
12315 this.recordType.prototype.fields.each(function(c) {
12317 case 'int' : da[c.name] = 0; break;
12318 case 'date' : da[c.name] = new Date(); break;
12319 case 'float' : da[c.name] = 0.0; break;
12320 case 'boolean' : da[c.name] = false; break;
12321 default : da[c.name] = ""; break;
12325 return new this.recordType(Roo.apply(da, d));
12330 * Ext JS Library 1.1.1
12331 * Copyright(c) 2006-2007, Ext JS, LLC.
12333 * Originally Released Under LGPL - original licence link has changed is not relivant.
12336 * <script type="text/javascript">
12340 * @class Roo.data.DataProxy
12341 * @extends Roo.data.Observable
12342 * This class is an abstract base class for implementations which provide retrieval of
12343 * unformatted data objects.<br>
12345 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12346 * (of the appropriate type which knows how to parse the data object) to provide a block of
12347 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12349 * Custom implementations must implement the load method as described in
12350 * {@link Roo.data.HttpProxy#load}.
12352 Roo.data.DataProxy = function(){
12355 * @event beforeload
12356 * Fires before a network request is made to retrieve a data object.
12357 * @param {Object} This DataProxy object.
12358 * @param {Object} params The params parameter to the load function.
12363 * Fires before the load method's callback is called.
12364 * @param {Object} This DataProxy object.
12365 * @param {Object} o The data object.
12366 * @param {Object} arg The callback argument object passed to the load function.
12370 * @event loadexception
12371 * Fires if an Exception occurs during data retrieval.
12372 * @param {Object} This DataProxy object.
12373 * @param {Object} o The data object.
12374 * @param {Object} arg The callback argument object passed to the load function.
12375 * @param {Object} e The Exception.
12377 loadexception : true
12379 Roo.data.DataProxy.superclass.constructor.call(this);
12382 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12385 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12389 * Ext JS Library 1.1.1
12390 * Copyright(c) 2006-2007, Ext JS, LLC.
12392 * Originally Released Under LGPL - original licence link has changed is not relivant.
12395 * <script type="text/javascript">
12398 * @class Roo.data.MemoryProxy
12399 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12400 * to the Reader when its load method is called.
12402 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12404 Roo.data.MemoryProxy = function(data){
12408 Roo.data.MemoryProxy.superclass.constructor.call(this);
12412 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12415 * Load data from the requested source (in this case an in-memory
12416 * data object passed to the constructor), read the data object into
12417 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12418 * process that block using the passed callback.
12419 * @param {Object} params This parameter is not used by the MemoryProxy class.
12420 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12421 * object into a block of Roo.data.Records.
12422 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12423 * The function must be passed <ul>
12424 * <li>The Record block object</li>
12425 * <li>The "arg" argument from the load function</li>
12426 * <li>A boolean success indicator</li>
12428 * @param {Object} scope The scope in which to call the callback
12429 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12431 load : function(params, reader, callback, scope, arg){
12432 params = params || {};
12435 result = reader.readRecords(params.data ? params.data :this.data);
12437 this.fireEvent("loadexception", this, arg, null, e);
12438 callback.call(scope, null, arg, false);
12441 callback.call(scope, result, arg, true);
12445 update : function(params, records){
12450 * Ext JS Library 1.1.1
12451 * Copyright(c) 2006-2007, Ext JS, LLC.
12453 * Originally Released Under LGPL - original licence link has changed is not relivant.
12456 * <script type="text/javascript">
12459 * @class Roo.data.HttpProxy
12460 * @extends Roo.data.DataProxy
12461 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12462 * configured to reference a certain URL.<br><br>
12464 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12465 * from which the running page was served.<br><br>
12467 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12469 * Be aware that to enable the browser to parse an XML document, the server must set
12470 * the Content-Type header in the HTTP response to "text/xml".
12472 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12473 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12474 * will be used to make the request.
12476 Roo.data.HttpProxy = function(conn){
12477 Roo.data.HttpProxy.superclass.constructor.call(this);
12478 // is conn a conn config or a real conn?
12480 this.useAjax = !conn || !conn.events;
12484 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12485 // thse are take from connection...
12488 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12491 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12492 * extra parameters to each request made by this object. (defaults to undefined)
12495 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12496 * to each request made by this object. (defaults to undefined)
12499 * @cfg {String} method (Optional) The default HTTP method to be used for requests. (defaults to undefined; if not set but parms are present will use POST, otherwise GET)
12502 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12505 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12511 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12515 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12516 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12517 * a finer-grained basis than the DataProxy events.
12519 getConnection : function(){
12520 return this.useAjax ? Roo.Ajax : this.conn;
12524 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12525 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12526 * process that block using the passed callback.
12527 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12528 * for the request to the remote server.
12529 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12530 * object into a block of Roo.data.Records.
12531 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12532 * The function must be passed <ul>
12533 * <li>The Record block object</li>
12534 * <li>The "arg" argument from the load function</li>
12535 * <li>A boolean success indicator</li>
12537 * @param {Object} scope The scope in which to call the callback
12538 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12540 load : function(params, reader, callback, scope, arg){
12541 if(this.fireEvent("beforeload", this, params) !== false){
12543 params : params || {},
12545 callback : callback,
12550 callback : this.loadResponse,
12554 Roo.applyIf(o, this.conn);
12555 if(this.activeRequest){
12556 Roo.Ajax.abort(this.activeRequest);
12558 this.activeRequest = Roo.Ajax.request(o);
12560 this.conn.request(o);
12563 callback.call(scope||this, null, arg, false);
12568 loadResponse : function(o, success, response){
12569 delete this.activeRequest;
12571 this.fireEvent("loadexception", this, o, response);
12572 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12577 result = o.reader.read(response);
12579 this.fireEvent("loadexception", this, o, response, e);
12580 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12584 this.fireEvent("load", this, o, o.request.arg);
12585 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12589 update : function(dataSet){
12594 updateResponse : function(dataSet){
12599 * Ext JS Library 1.1.1
12600 * Copyright(c) 2006-2007, Ext JS, LLC.
12602 * Originally Released Under LGPL - original licence link has changed is not relivant.
12605 * <script type="text/javascript">
12609 * @class Roo.data.ScriptTagProxy
12610 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12611 * other than the originating domain of the running page.<br><br>
12613 * <em>Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain
12614 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12616 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12617 * source code that is used as the source inside a <script> tag.<br><br>
12619 * In order for the browser to process the returned data, the server must wrap the data object
12620 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12621 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12622 * depending on whether the callback name was passed:
12625 boolean scriptTag = false;
12626 String cb = request.getParameter("callback");
12629 response.setContentType("text/javascript");
12631 response.setContentType("application/x-json");
12633 Writer out = response.getWriter();
12635 out.write(cb + "(");
12637 out.print(dataBlock.toJsonString());
12644 * @param {Object} config A configuration object.
12646 Roo.data.ScriptTagProxy = function(config){
12647 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12648 Roo.apply(this, config);
12649 this.head = document.getElementsByTagName("head")[0];
12652 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12654 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12656 * @cfg {String} url The URL from which to request the data object.
12659 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12663 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12664 * the server the name of the callback function set up by the load call to process the returned data object.
12665 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12666 * javascript output which calls this named function passing the data object as its only parameter.
12668 callbackParam : "callback",
12670 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12671 * name to the request.
12676 * Load data from the configured URL, read the data object into
12677 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12678 * process that block using the passed callback.
12679 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12680 * for the request to the remote server.
12681 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12682 * object into a block of Roo.data.Records.
12683 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12684 * The function must be passed <ul>
12685 * <li>The Record block object</li>
12686 * <li>The "arg" argument from the load function</li>
12687 * <li>A boolean success indicator</li>
12689 * @param {Object} scope The scope in which to call the callback
12690 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12692 load : function(params, reader, callback, scope, arg){
12693 if(this.fireEvent("beforeload", this, params) !== false){
12695 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12697 var url = this.url;
12698 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12700 url += "&_dc=" + (new Date().getTime());
12702 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12705 cb : "stcCallback"+transId,
12706 scriptId : "stcScript"+transId,
12710 callback : callback,
12716 window[trans.cb] = function(o){
12717 conn.handleResponse(o, trans);
12720 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12722 if(this.autoAbort !== false){
12726 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12728 var script = document.createElement("script");
12729 script.setAttribute("src", url);
12730 script.setAttribute("type", "text/javascript");
12731 script.setAttribute("id", trans.scriptId);
12732 this.head.appendChild(script);
12734 this.trans = trans;
12736 callback.call(scope||this, null, arg, false);
12741 isLoading : function(){
12742 return this.trans ? true : false;
12746 * Abort the current server request.
12748 abort : function(){
12749 if(this.isLoading()){
12750 this.destroyTrans(this.trans);
12755 destroyTrans : function(trans, isLoaded){
12756 this.head.removeChild(document.getElementById(trans.scriptId));
12757 clearTimeout(trans.timeoutId);
12759 window[trans.cb] = undefined;
12761 delete window[trans.cb];
12764 // if hasn't been loaded, wait for load to remove it to prevent script error
12765 window[trans.cb] = function(){
12766 window[trans.cb] = undefined;
12768 delete window[trans.cb];
12775 handleResponse : function(o, trans){
12776 this.trans = false;
12777 this.destroyTrans(trans, true);
12780 result = trans.reader.readRecords(o);
12782 this.fireEvent("loadexception", this, o, trans.arg, e);
12783 trans.callback.call(trans.scope||window, null, trans.arg, false);
12786 this.fireEvent("load", this, o, trans.arg);
12787 trans.callback.call(trans.scope||window, result, trans.arg, true);
12791 handleFailure : function(trans){
12792 this.trans = false;
12793 this.destroyTrans(trans, false);
12794 this.fireEvent("loadexception", this, null, trans.arg);
12795 trans.callback.call(trans.scope||window, null, trans.arg, false);
12799 * Ext JS Library 1.1.1
12800 * Copyright(c) 2006-2007, Ext JS, LLC.
12802 * Originally Released Under LGPL - original licence link has changed is not relivant.
12805 * <script type="text/javascript">
12809 * @class Roo.data.JsonReader
12810 * @extends Roo.data.DataReader
12811 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12812 * based on mappings in a provided Roo.data.Record constructor.
12814 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12815 * in the reply previously.
12820 var RecordDef = Roo.data.Record.create([
12821 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12822 {name: 'occupation'} // This field will use "occupation" as the mapping.
12824 var myReader = new Roo.data.JsonReader({
12825 totalProperty: "results", // The property which contains the total dataset size (optional)
12826 root: "rows", // The property which contains an Array of row objects
12827 id: "id" // The property within each row object that provides an ID for the record (optional)
12831 * This would consume a JSON file like this:
12833 { 'results': 2, 'rows': [
12834 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12835 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12838 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12839 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12840 * paged from the remote server.
12841 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12842 * @cfg {String} root name of the property which contains the Array of row objects.
12843 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12844 * @cfg {Array} fields Array of field definition objects
12846 * Create a new JsonReader
12847 * @param {Object} meta Metadata configuration options
12848 * @param {Object} recordType Either an Array of field definition objects,
12849 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12851 Roo.data.JsonReader = function(meta, recordType){
12854 // set some defaults:
12855 Roo.applyIf(meta, {
12856 totalProperty: 'total',
12857 successProperty : 'success',
12862 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12864 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12867 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12868 * Used by Store query builder to append _requestMeta to params.
12871 metaFromRemote : false,
12873 * This method is only used by a DataProxy which has retrieved data from a remote server.
12874 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12875 * @return {Object} data A data block which is used by an Roo.data.Store object as
12876 * a cache of Roo.data.Records.
12878 read : function(response){
12879 var json = response.responseText;
12881 var o = /* eval:var:o */ eval("("+json+")");
12883 throw {message: "JsonReader.read: Json object not found"};
12889 this.metaFromRemote = true;
12890 this.meta = o.metaData;
12891 this.recordType = Roo.data.Record.create(o.metaData.fields);
12892 this.onMetaChange(this.meta, this.recordType, o);
12894 return this.readRecords(o);
12897 // private function a store will implement
12898 onMetaChange : function(meta, recordType, o){
12905 simpleAccess: function(obj, subsc) {
12912 getJsonAccessor: function(){
12914 return function(expr) {
12916 return(re.test(expr))
12917 ? new Function("obj", "return obj." + expr)
12922 return Roo.emptyFn;
12927 * Create a data block containing Roo.data.Records from an XML document.
12928 * @param {Object} o An object which contains an Array of row objects in the property specified
12929 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12930 * which contains the total size of the dataset.
12931 * @return {Object} data A data block which is used by an Roo.data.Store object as
12932 * a cache of Roo.data.Records.
12934 readRecords : function(o){
12936 * After any data loads, the raw JSON data is available for further custom processing.
12940 var s = this.meta, Record = this.recordType,
12941 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12943 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12945 if(s.totalProperty) {
12946 this.getTotal = this.getJsonAccessor(s.totalProperty);
12948 if(s.successProperty) {
12949 this.getSuccess = this.getJsonAccessor(s.successProperty);
12951 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12953 var g = this.getJsonAccessor(s.id);
12954 this.getId = function(rec) {
12956 return (r === undefined || r === "") ? null : r;
12959 this.getId = function(){return null;};
12962 for(var jj = 0; jj < fl; jj++){
12964 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12965 this.ef[jj] = this.getJsonAccessor(map);
12969 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12970 if(s.totalProperty){
12971 var vt = parseInt(this.getTotal(o), 10);
12976 if(s.successProperty){
12977 var vs = this.getSuccess(o);
12978 if(vs === false || vs === 'false'){
12983 for(var i = 0; i < c; i++){
12986 var id = this.getId(n);
12987 for(var j = 0; j < fl; j++){
12989 var v = this.ef[j](n);
12991 Roo.log('missing convert for ' + f.name);
12995 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12997 var record = new Record(values, id);
12999 records[i] = record;
13005 totalRecords : totalRecords
13010 * Ext JS Library 1.1.1
13011 * Copyright(c) 2006-2007, Ext JS, LLC.
13013 * Originally Released Under LGPL - original licence link has changed is not relivant.
13016 * <script type="text/javascript">
13020 * @class Roo.data.ArrayReader
13021 * @extends Roo.data.DataReader
13022 * Data reader class to create an Array of Roo.data.Record objects from an Array.
13023 * Each element of that Array represents a row of data fields. The
13024 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
13025 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
13029 var RecordDef = Roo.data.Record.create([
13030 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
13031 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
13033 var myReader = new Roo.data.ArrayReader({
13034 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
13038 * This would consume an Array like this:
13040 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13044 * Create a new JsonReader
13045 * @param {Object} meta Metadata configuration options.
13046 * @param {Object|Array} recordType Either an Array of field definition objects
13048 * @cfg {Array} fields Array of field definition objects
13049 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
13050 * as specified to {@link Roo.data.Record#create},
13051 * or an {@link Roo.data.Record} object
13054 * created using {@link Roo.data.Record#create}.
13056 Roo.data.ArrayReader = function(meta, recordType){
13059 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13062 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13064 * Create a data block containing Roo.data.Records from an XML document.
13065 * @param {Object} o An Array of row objects which represents the dataset.
13066 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
13067 * a cache of Roo.data.Records.
13069 readRecords : function(o){
13070 var sid = this.meta ? this.meta.id : null;
13071 var recordType = this.recordType, fields = recordType.prototype.fields;
13074 for(var i = 0; i < root.length; i++){
13077 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13078 for(var j = 0, jlen = fields.length; j < jlen; j++){
13079 var f = fields.items[j];
13080 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13081 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13083 values[f.name] = v;
13085 var record = new recordType(values, id);
13087 records[records.length] = record;
13091 totalRecords : records.length
13100 * @class Roo.bootstrap.ComboBox
13101 * @extends Roo.bootstrap.TriggerField
13102 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13103 * @cfg {Boolean} append (true|false) default false
13104 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13105 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13106 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13107 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13108 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13109 * @cfg {Boolean} animate default true
13110 * @cfg {Boolean} emptyResultText only for touch device
13111 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13112 * @cfg {String} emptyTitle default ''
13114 * Create a new ComboBox.
13115 * @param {Object} config Configuration options
13117 Roo.bootstrap.ComboBox = function(config){
13118 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13122 * Fires when the dropdown list is expanded
13123 * @param {Roo.bootstrap.ComboBox} combo This combo box
13128 * Fires when the dropdown list is collapsed
13129 * @param {Roo.bootstrap.ComboBox} combo This combo box
13133 * @event beforeselect
13134 * Fires before a list item is selected. Return false to cancel the selection.
13135 * @param {Roo.bootstrap.ComboBox} combo This combo box
13136 * @param {Roo.data.Record} record The data record returned from the underlying store
13137 * @param {Number} index The index of the selected item in the dropdown list
13139 'beforeselect' : true,
13142 * Fires when a list item is selected
13143 * @param {Roo.bootstrap.ComboBox} combo This combo box
13144 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13145 * @param {Number} index The index of the selected item in the dropdown list
13149 * @event beforequery
13150 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13151 * The event object passed has these properties:
13152 * @param {Roo.bootstrap.ComboBox} combo This combo box
13153 * @param {String} query The query
13154 * @param {Boolean} forceAll true to force "all" query
13155 * @param {Boolean} cancel true to cancel the query
13156 * @param {Object} e The query event object
13158 'beforequery': true,
13161 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13162 * @param {Roo.bootstrap.ComboBox} combo This combo box
13167 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13168 * @param {Roo.bootstrap.ComboBox} combo This combo box
13169 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13174 * Fires when the remove value from the combobox array
13175 * @param {Roo.bootstrap.ComboBox} combo This combo box
13179 * @event afterremove
13180 * Fires when the remove value from the combobox array
13181 * @param {Roo.bootstrap.ComboBox} combo This combo box
13183 'afterremove' : true,
13185 * @event specialfilter
13186 * Fires when specialfilter
13187 * @param {Roo.bootstrap.ComboBox} combo This combo box
13189 'specialfilter' : true,
13192 * Fires when tick the element
13193 * @param {Roo.bootstrap.ComboBox} combo This combo box
13197 * @event touchviewdisplay
13198 * Fires when touch view require special display (default is using displayField)
13199 * @param {Roo.bootstrap.ComboBox} combo This combo box
13200 * @param {Object} cfg set html .
13202 'touchviewdisplay' : true
13207 this.tickItems = [];
13209 this.selectedIndex = -1;
13210 if(this.mode == 'local'){
13211 if(config.queryDelay === undefined){
13212 this.queryDelay = 10;
13214 if(config.minChars === undefined){
13220 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13223 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13224 * rendering into an Roo.Editor, defaults to false)
13227 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13228 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13231 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13234 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13235 * the dropdown list (defaults to undefined, with no header element)
13239 * @cfg {String/Roo.Template} tpl The template to use to render the output
13243 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13245 listWidth: undefined,
13247 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13248 * mode = 'remote' or 'text' if mode = 'local')
13250 displayField: undefined,
13253 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13254 * mode = 'remote' or 'value' if mode = 'local').
13255 * Note: use of a valueField requires the user make a selection
13256 * in order for a value to be mapped.
13258 valueField: undefined,
13260 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13265 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13266 * field's data value (defaults to the underlying DOM element's name)
13268 hiddenName: undefined,
13270 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13274 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13276 selectedClass: 'active',
13279 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13283 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13284 * anchor positions (defaults to 'tl-bl')
13286 listAlign: 'tl-bl?',
13288 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13292 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13293 * query specified by the allQuery config option (defaults to 'query')
13295 triggerAction: 'query',
13297 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13298 * (defaults to 4, does not apply if editable = false)
13302 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13303 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13307 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13308 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13312 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13313 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13317 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13318 * when editable = true (defaults to false)
13320 selectOnFocus:false,
13322 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13324 queryParam: 'query',
13326 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13327 * when mode = 'remote' (defaults to 'Loading...')
13329 loadingText: 'Loading...',
13331 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13335 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13339 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13340 * traditional select (defaults to true)
13344 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13348 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13352 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13353 * listWidth has a higher value)
13357 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13358 * allow the user to set arbitrary text into the field (defaults to false)
13360 forceSelection:false,
13362 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13363 * if typeAhead = true (defaults to 250)
13365 typeAheadDelay : 250,
13367 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13368 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13370 valueNotFoundText : undefined,
13372 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13374 blockFocus : false,
13377 * @cfg {Boolean} disableClear Disable showing of clear button.
13379 disableClear : false,
13381 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13383 alwaysQuery : false,
13386 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13391 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13393 invalidClass : "has-warning",
13396 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13398 validClass : "has-success",
13401 * @cfg {Boolean} specialFilter (true|false) special filter default false
13403 specialFilter : false,
13406 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13408 mobileTouchView : true,
13411 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13413 useNativeIOS : false,
13416 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13418 mobile_restrict_height : false,
13420 ios_options : false,
13432 btnPosition : 'right',
13433 triggerList : true,
13434 showToggleBtn : true,
13436 emptyResultText: 'Empty',
13437 triggerText : 'Select',
13440 // element that contains real text value.. (when hidden is used..)
13442 getAutoCreate : function()
13447 * Render classic select for iso
13450 if(Roo.isIOS && this.useNativeIOS){
13451 cfg = this.getAutoCreateNativeIOS();
13459 if(Roo.isTouch && this.mobileTouchView){
13460 cfg = this.getAutoCreateTouchView();
13467 if(!this.tickable){
13468 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13473 * ComboBox with tickable selections
13476 var align = this.labelAlign || this.parentLabelAlign();
13479 cls : 'form-group roo-combobox-tickable' //input-group
13482 var btn_text_select = '';
13483 var btn_text_done = '';
13484 var btn_text_cancel = '';
13486 if (this.btn_text_show) {
13487 btn_text_select = 'Select';
13488 btn_text_done = 'Done';
13489 btn_text_cancel = 'Cancel';
13494 cls : 'tickable-buttons',
13499 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13500 //html : this.triggerText
13501 html: btn_text_select
13507 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13509 html: btn_text_done
13515 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13517 html: btn_text_cancel
13523 buttons.cn.unshift({
13525 cls: 'roo-select2-search-field-input'
13531 Roo.each(buttons.cn, function(c){
13533 c.cls += ' btn-' + _this.size;
13536 if (_this.disabled) {
13543 style : 'display: contents',
13548 cls: 'form-hidden-field'
13552 cls: 'roo-select2-choices',
13556 cls: 'roo-select2-search-field',
13567 cls: 'roo-select2-container input-group roo-select2-container-multi',
13573 // cls: 'typeahead typeahead-long dropdown-menu',
13574 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13579 if(this.hasFeedback && !this.allowBlank){
13583 cls: 'glyphicon form-control-feedback'
13586 combobox.cn.push(feedback);
13591 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13592 tooltip : 'This field is required'
13594 if (Roo.bootstrap.version == 4) {
13597 style : 'display:none'
13600 if (align ==='left' && this.fieldLabel.length) {
13602 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13609 cls : 'control-label col-form-label',
13610 html : this.fieldLabel
13622 var labelCfg = cfg.cn[1];
13623 var contentCfg = cfg.cn[2];
13626 if(this.indicatorpos == 'right'){
13632 cls : 'control-label col-form-label',
13636 html : this.fieldLabel
13652 labelCfg = cfg.cn[0];
13653 contentCfg = cfg.cn[1];
13657 if(this.labelWidth > 12){
13658 labelCfg.style = "width: " + this.labelWidth + 'px';
13661 if(this.labelWidth < 13 && this.labelmd == 0){
13662 this.labelmd = this.labelWidth;
13665 if(this.labellg > 0){
13666 labelCfg.cls += ' col-lg-' + this.labellg;
13667 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13670 if(this.labelmd > 0){
13671 labelCfg.cls += ' col-md-' + this.labelmd;
13672 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13675 if(this.labelsm > 0){
13676 labelCfg.cls += ' col-sm-' + this.labelsm;
13677 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13680 if(this.labelxs > 0){
13681 labelCfg.cls += ' col-xs-' + this.labelxs;
13682 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13686 } else if ( this.fieldLabel.length) {
13687 // Roo.log(" label");
13692 //cls : 'input-group-addon',
13693 html : this.fieldLabel
13698 if(this.indicatorpos == 'right'){
13702 //cls : 'input-group-addon',
13703 html : this.fieldLabel
13713 // Roo.log(" no label && no align");
13720 ['xs','sm','md','lg'].map(function(size){
13721 if (settings[size]) {
13722 cfg.cls += ' col-' + size + '-' + settings[size];
13730 _initEventsCalled : false,
13733 initEvents: function()
13735 if (this._initEventsCalled) { // as we call render... prevent looping...
13738 this._initEventsCalled = true;
13741 throw "can not find store for combo";
13744 this.indicator = this.indicatorEl();
13746 this.store = Roo.factory(this.store, Roo.data);
13747 this.store.parent = this;
13749 // if we are building from html. then this element is so complex, that we can not really
13750 // use the rendered HTML.
13751 // so we have to trash and replace the previous code.
13752 if (Roo.XComponent.build_from_html) {
13753 // remove this element....
13754 var e = this.el.dom, k=0;
13755 while (e ) { e = e.previousSibling; ++k;}
13760 this.rendered = false;
13762 this.render(this.parent().getChildContainer(true), k);
13765 if(Roo.isIOS && this.useNativeIOS){
13766 this.initIOSView();
13774 if(Roo.isTouch && this.mobileTouchView){
13775 this.initTouchView();
13780 this.initTickableEvents();
13784 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13786 if(this.hiddenName){
13788 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13790 this.hiddenField.dom.value =
13791 this.hiddenValue !== undefined ? this.hiddenValue :
13792 this.value !== undefined ? this.value : '';
13794 // prevent input submission
13795 this.el.dom.removeAttribute('name');
13796 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13801 // this.el.dom.setAttribute('autocomplete', 'off');
13804 var cls = 'x-combo-list';
13806 //this.list = new Roo.Layer({
13807 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13813 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13814 _this.list.setWidth(lw);
13817 this.list.on('mouseover', this.onViewOver, this);
13818 this.list.on('mousemove', this.onViewMove, this);
13819 this.list.on('scroll', this.onViewScroll, this);
13822 this.list.swallowEvent('mousewheel');
13823 this.assetHeight = 0;
13826 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13827 this.assetHeight += this.header.getHeight();
13830 this.innerList = this.list.createChild({cls:cls+'-inner'});
13831 this.innerList.on('mouseover', this.onViewOver, this);
13832 this.innerList.on('mousemove', this.onViewMove, this);
13833 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13835 if(this.allowBlank && !this.pageSize && !this.disableClear){
13836 this.footer = this.list.createChild({cls:cls+'-ft'});
13837 this.pageTb = new Roo.Toolbar(this.footer);
13841 this.footer = this.list.createChild({cls:cls+'-ft'});
13842 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13843 {pageSize: this.pageSize});
13847 if (this.pageTb && this.allowBlank && !this.disableClear) {
13849 this.pageTb.add(new Roo.Toolbar.Fill(), {
13850 cls: 'x-btn-icon x-btn-clear',
13852 handler: function()
13855 _this.clearValue();
13856 _this.onSelect(false, -1);
13861 this.assetHeight += this.footer.getHeight();
13866 this.tpl = Roo.bootstrap.version == 4 ?
13867 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13868 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13871 this.view = new Roo.View(this.list, this.tpl, {
13872 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13874 //this.view.wrapEl.setDisplayed(false);
13875 this.view.on('click', this.onViewClick, this);
13878 this.store.on('beforeload', this.onBeforeLoad, this);
13879 this.store.on('load', this.onLoad, this);
13880 this.store.on('loadexception', this.onLoadException, this);
13882 if(this.resizable){
13883 this.resizer = new Roo.Resizable(this.list, {
13884 pinned:true, handles:'se'
13886 this.resizer.on('resize', function(r, w, h){
13887 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13888 this.listWidth = w;
13889 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13890 this.restrictHeight();
13892 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13895 if(!this.editable){
13896 this.editable = true;
13897 this.setEditable(false);
13902 if (typeof(this.events.add.listeners) != 'undefined') {
13904 this.addicon = this.wrap.createChild(
13905 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13907 this.addicon.on('click', function(e) {
13908 this.fireEvent('add', this);
13911 if (typeof(this.events.edit.listeners) != 'undefined') {
13913 this.editicon = this.wrap.createChild(
13914 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13915 if (this.addicon) {
13916 this.editicon.setStyle('margin-left', '40px');
13918 this.editicon.on('click', function(e) {
13920 // we fire even if inothing is selected..
13921 this.fireEvent('edit', this, this.lastData );
13927 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13928 "up" : function(e){
13929 this.inKeyMode = true;
13933 "down" : function(e){
13934 if(!this.isExpanded()){
13935 this.onTriggerClick();
13937 this.inKeyMode = true;
13942 "enter" : function(e){
13943 // this.onViewClick();
13947 if(this.fireEvent("specialkey", this, e)){
13948 this.onViewClick(false);
13954 "esc" : function(e){
13958 "tab" : function(e){
13961 if(this.fireEvent("specialkey", this, e)){
13962 this.onViewClick(false);
13970 doRelay : function(foo, bar, hname){
13971 if(hname == 'down' || this.scope.isExpanded()){
13972 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13981 this.queryDelay = Math.max(this.queryDelay || 10,
13982 this.mode == 'local' ? 10 : 250);
13985 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13987 if(this.typeAhead){
13988 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13990 if(this.editable !== false){
13991 this.inputEl().on("keyup", this.onKeyUp, this);
13993 if(this.forceSelection){
13994 this.inputEl().on('blur', this.doForce, this);
13998 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13999 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14003 initTickableEvents: function()
14007 if(this.hiddenName){
14009 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14011 this.hiddenField.dom.value =
14012 this.hiddenValue !== undefined ? this.hiddenValue :
14013 this.value !== undefined ? this.value : '';
14015 // prevent input submission
14016 this.el.dom.removeAttribute('name');
14017 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14022 // this.list = this.el.select('ul.dropdown-menu',true).first();
14024 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14025 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14026 if(this.triggerList){
14027 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
14030 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
14031 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
14033 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
14034 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
14036 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
14037 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
14039 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
14040 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
14041 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
14044 this.cancelBtn.hide();
14049 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14050 _this.list.setWidth(lw);
14053 this.list.on('mouseover', this.onViewOver, this);
14054 this.list.on('mousemove', this.onViewMove, this);
14056 this.list.on('scroll', this.onViewScroll, this);
14059 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14060 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14063 this.view = new Roo.View(this.list, this.tpl, {
14068 selectedClass: this.selectedClass
14071 //this.view.wrapEl.setDisplayed(false);
14072 this.view.on('click', this.onViewClick, this);
14076 this.store.on('beforeload', this.onBeforeLoad, this);
14077 this.store.on('load', this.onLoad, this);
14078 this.store.on('loadexception', this.onLoadException, this);
14081 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14082 "up" : function(e){
14083 this.inKeyMode = true;
14087 "down" : function(e){
14088 this.inKeyMode = true;
14092 "enter" : function(e){
14093 if(this.fireEvent("specialkey", this, e)){
14094 this.onViewClick(false);
14100 "esc" : function(e){
14101 this.onTickableFooterButtonClick(e, false, false);
14104 "tab" : function(e){
14105 this.fireEvent("specialkey", this, e);
14107 this.onTickableFooterButtonClick(e, false, false);
14114 doRelay : function(e, fn, key){
14115 if(this.scope.isExpanded()){
14116 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14125 this.queryDelay = Math.max(this.queryDelay || 10,
14126 this.mode == 'local' ? 10 : 250);
14129 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14131 if(this.typeAhead){
14132 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14135 if(this.editable !== false){
14136 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14139 this.indicator = this.indicatorEl();
14141 if(this.indicator){
14142 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14143 this.indicator.hide();
14148 onDestroy : function(){
14150 this.view.setStore(null);
14151 this.view.el.removeAllListeners();
14152 this.view.el.remove();
14153 this.view.purgeListeners();
14156 this.list.dom.innerHTML = '';
14160 this.store.un('beforeload', this.onBeforeLoad, this);
14161 this.store.un('load', this.onLoad, this);
14162 this.store.un('loadexception', this.onLoadException, this);
14164 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14168 fireKey : function(e){
14169 if(e.isNavKeyPress() && !this.list.isVisible()){
14170 this.fireEvent("specialkey", this, e);
14175 onResize: function(w, h){
14176 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14178 // if(typeof w != 'number'){
14179 // // we do not handle it!?!?
14182 // var tw = this.trigger.getWidth();
14183 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14184 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14186 // this.inputEl().setWidth( this.adjustWidth('input', x));
14188 // //this.trigger.setStyle('left', x+'px');
14190 // if(this.list && this.listWidth === undefined){
14191 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14192 // this.list.setWidth(lw);
14193 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14201 * Allow or prevent the user from directly editing the field text. If false is passed,
14202 * the user will only be able to select from the items defined in the dropdown list. This method
14203 * is the runtime equivalent of setting the 'editable' config option at config time.
14204 * @param {Boolean} value True to allow the user to directly edit the field text
14206 setEditable : function(value){
14207 if(value == this.editable){
14210 this.editable = value;
14212 this.inputEl().dom.setAttribute('readOnly', true);
14213 this.inputEl().on('mousedown', this.onTriggerClick, this);
14214 this.inputEl().addClass('x-combo-noedit');
14216 this.inputEl().dom.setAttribute('readOnly', false);
14217 this.inputEl().un('mousedown', this.onTriggerClick, this);
14218 this.inputEl().removeClass('x-combo-noedit');
14224 onBeforeLoad : function(combo,opts){
14225 if(!this.hasFocus){
14229 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14231 this.restrictHeight();
14232 this.selectedIndex = -1;
14236 onLoad : function(){
14238 this.hasQuery = false;
14240 if(!this.hasFocus){
14244 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14245 this.loading.hide();
14248 if(this.store.getCount() > 0){
14251 this.restrictHeight();
14252 if(this.lastQuery == this.allQuery){
14253 if(this.editable && !this.tickable){
14254 this.inputEl().dom.select();
14258 !this.selectByValue(this.value, true) &&
14261 !this.store.lastOptions ||
14262 typeof(this.store.lastOptions.add) == 'undefined' ||
14263 this.store.lastOptions.add != true
14266 this.select(0, true);
14269 if(this.autoFocus){
14272 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14273 this.taTask.delay(this.typeAheadDelay);
14277 this.onEmptyResults();
14283 onLoadException : function()
14285 this.hasQuery = false;
14287 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14288 this.loading.hide();
14291 if(this.tickable && this.editable){
14296 // only causes errors at present
14297 //Roo.log(this.store.reader.jsonData);
14298 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14300 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14306 onTypeAhead : function(){
14307 if(this.store.getCount() > 0){
14308 var r = this.store.getAt(0);
14309 var newValue = r.data[this.displayField];
14310 var len = newValue.length;
14311 var selStart = this.getRawValue().length;
14313 if(selStart != len){
14314 this.setRawValue(newValue);
14315 this.selectText(selStart, newValue.length);
14321 onSelect : function(record, index){
14323 if(this.fireEvent('beforeselect', this, record, index) !== false){
14325 this.setFromData(index > -1 ? record.data : false);
14328 this.fireEvent('select', this, record, index);
14333 * Returns the currently selected field value or empty string if no value is set.
14334 * @return {String} value The selected value
14336 getValue : function()
14338 if(Roo.isIOS && this.useNativeIOS){
14339 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14343 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14346 if(this.valueField){
14347 return typeof this.value != 'undefined' ? this.value : '';
14349 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14353 getRawValue : function()
14355 if(Roo.isIOS && this.useNativeIOS){
14356 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14359 var v = this.inputEl().getValue();
14365 * Clears any text/value currently set in the field
14367 clearValue : function(){
14369 if(this.hiddenField){
14370 this.hiddenField.dom.value = '';
14373 this.setRawValue('');
14374 this.lastSelectionText = '';
14375 this.lastData = false;
14377 var close = this.closeTriggerEl();
14388 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14389 * will be displayed in the field. If the value does not match the data value of an existing item,
14390 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14391 * Otherwise the field will be blank (although the value will still be set).
14392 * @param {String} value The value to match
14394 setValue : function(v)
14396 if(Roo.isIOS && this.useNativeIOS){
14397 this.setIOSValue(v);
14407 if(this.valueField){
14408 var r = this.findRecord(this.valueField, v);
14410 text = r.data[this.displayField];
14411 }else if(this.valueNotFoundText !== undefined){
14412 text = this.valueNotFoundText;
14415 this.lastSelectionText = text;
14416 if(this.hiddenField){
14417 this.hiddenField.dom.value = v;
14419 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14422 var close = this.closeTriggerEl();
14425 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14431 * @property {Object} the last set data for the element
14436 * Sets the value of the field based on a object which is related to the record format for the store.
14437 * @param {Object} value the value to set as. or false on reset?
14439 setFromData : function(o){
14446 var dv = ''; // display value
14447 var vv = ''; // value value..
14449 if (this.displayField) {
14450 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14452 // this is an error condition!!!
14453 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14456 if(this.valueField){
14457 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14460 var close = this.closeTriggerEl();
14463 if(dv.length || vv * 1 > 0){
14465 this.blockFocus=true;
14471 if(this.hiddenField){
14472 this.hiddenField.dom.value = vv;
14474 this.lastSelectionText = dv;
14475 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14479 // no hidden field.. - we store the value in 'value', but still display
14480 // display field!!!!
14481 this.lastSelectionText = dv;
14482 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14489 reset : function(){
14490 // overridden so that last data is reset..
14497 this.setValue(this.originalValue);
14498 //this.clearInvalid();
14499 this.lastData = false;
14501 this.view.clearSelections();
14507 findRecord : function(prop, value){
14509 if(this.store.getCount() > 0){
14510 this.store.each(function(r){
14511 if(r.data[prop] == value){
14521 getName: function()
14523 // returns hidden if it's set..
14524 if (!this.rendered) {return ''};
14525 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14529 onViewMove : function(e, t){
14530 this.inKeyMode = false;
14534 onViewOver : function(e, t){
14535 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14538 var item = this.view.findItemFromChild(t);
14541 var index = this.view.indexOf(item);
14542 this.select(index, false);
14547 onViewClick : function(view, doFocus, el, e)
14549 var index = this.view.getSelectedIndexes()[0];
14551 var r = this.store.getAt(index);
14555 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14562 Roo.each(this.tickItems, function(v,k){
14564 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14566 _this.tickItems.splice(k, 1);
14568 if(typeof(e) == 'undefined' && view == false){
14569 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14581 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14582 this.tickItems.push(r.data);
14585 if(typeof(e) == 'undefined' && view == false){
14586 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14593 this.onSelect(r, index);
14595 if(doFocus !== false && !this.blockFocus){
14596 this.inputEl().focus();
14601 restrictHeight : function(){
14602 //this.innerList.dom.style.height = '';
14603 //var inner = this.innerList.dom;
14604 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14605 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14606 //this.list.beginUpdate();
14607 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14608 this.list.alignTo(this.inputEl(), this.listAlign);
14609 this.list.alignTo(this.inputEl(), this.listAlign);
14610 //this.list.endUpdate();
14614 onEmptyResults : function(){
14616 if(this.tickable && this.editable){
14617 this.hasFocus = false;
14618 this.restrictHeight();
14626 * Returns true if the dropdown list is expanded, else false.
14628 isExpanded : function(){
14629 return this.list.isVisible();
14633 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14634 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14635 * @param {String} value The data value of the item to select
14636 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14637 * selected item if it is not currently in view (defaults to true)
14638 * @return {Boolean} True if the value matched an item in the list, else false
14640 selectByValue : function(v, scrollIntoView){
14641 if(v !== undefined && v !== null){
14642 var r = this.findRecord(this.valueField || this.displayField, v);
14644 this.select(this.store.indexOf(r), scrollIntoView);
14652 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14653 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14654 * @param {Number} index The zero-based index of the list item to select
14655 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14656 * selected item if it is not currently in view (defaults to true)
14658 select : function(index, scrollIntoView){
14659 this.selectedIndex = index;
14660 this.view.select(index);
14661 if(scrollIntoView !== false){
14662 var el = this.view.getNode(index);
14664 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14667 this.list.scrollChildIntoView(el, false);
14673 selectNext : function(){
14674 var ct = this.store.getCount();
14676 if(this.selectedIndex == -1){
14678 }else if(this.selectedIndex < ct-1){
14679 this.select(this.selectedIndex+1);
14685 selectPrev : function(){
14686 var ct = this.store.getCount();
14688 if(this.selectedIndex == -1){
14690 }else if(this.selectedIndex != 0){
14691 this.select(this.selectedIndex-1);
14697 onKeyUp : function(e){
14698 if(this.editable !== false && !e.isSpecialKey()){
14699 this.lastKey = e.getKey();
14700 this.dqTask.delay(this.queryDelay);
14705 validateBlur : function(){
14706 return !this.list || !this.list.isVisible();
14710 initQuery : function(){
14712 var v = this.getRawValue();
14714 if(this.tickable && this.editable){
14715 v = this.tickableInputEl().getValue();
14722 doForce : function(){
14723 if(this.inputEl().dom.value.length > 0){
14724 this.inputEl().dom.value =
14725 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14731 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14732 * query allowing the query action to be canceled if needed.
14733 * @param {String} query The SQL query to execute
14734 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14735 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14736 * saved in the current store (defaults to false)
14738 doQuery : function(q, forceAll){
14740 if(q === undefined || q === null){
14745 forceAll: forceAll,
14749 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14754 forceAll = qe.forceAll;
14755 if(forceAll === true || (q.length >= this.minChars)){
14757 this.hasQuery = true;
14759 if(this.lastQuery != q || this.alwaysQuery){
14760 this.lastQuery = q;
14761 if(this.mode == 'local'){
14762 this.selectedIndex = -1;
14764 this.store.clearFilter();
14767 if(this.specialFilter){
14768 this.fireEvent('specialfilter', this);
14773 this.store.filter(this.displayField, q);
14776 this.store.fireEvent("datachanged", this.store);
14783 this.store.baseParams[this.queryParam] = q;
14785 var options = {params : this.getParams(q)};
14788 options.add = true;
14789 options.params.start = this.page * this.pageSize;
14792 this.store.load(options);
14795 * this code will make the page width larger, at the beginning, the list not align correctly,
14796 * we should expand the list on onLoad
14797 * so command out it
14802 this.selectedIndex = -1;
14807 this.loadNext = false;
14811 getParams : function(q){
14813 //p[this.queryParam] = q;
14817 p.limit = this.pageSize;
14823 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14825 collapse : function(){
14826 if(!this.isExpanded()){
14832 this.hasFocus = false;
14836 this.cancelBtn.hide();
14837 this.trigger.show();
14840 this.tickableInputEl().dom.value = '';
14841 this.tickableInputEl().blur();
14846 Roo.get(document).un('mousedown', this.collapseIf, this);
14847 Roo.get(document).un('mousewheel', this.collapseIf, this);
14848 if (!this.editable) {
14849 Roo.get(document).un('keydown', this.listKeyPress, this);
14851 this.fireEvent('collapse', this);
14857 collapseIf : function(e){
14858 var in_combo = e.within(this.el);
14859 var in_list = e.within(this.list);
14860 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14862 if (in_combo || in_list || is_list) {
14863 //e.stopPropagation();
14868 this.onTickableFooterButtonClick(e, false, false);
14876 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14878 expand : function(){
14880 if(this.isExpanded() || !this.hasFocus){
14884 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14885 this.list.setWidth(lw);
14891 this.restrictHeight();
14895 this.tickItems = Roo.apply([], this.item);
14898 this.cancelBtn.show();
14899 this.trigger.hide();
14902 this.tickableInputEl().focus();
14907 Roo.get(document).on('mousedown', this.collapseIf, this);
14908 Roo.get(document).on('mousewheel', this.collapseIf, this);
14909 if (!this.editable) {
14910 Roo.get(document).on('keydown', this.listKeyPress, this);
14913 this.fireEvent('expand', this);
14917 // Implements the default empty TriggerField.onTriggerClick function
14918 onTriggerClick : function(e)
14920 Roo.log('trigger click');
14922 if(this.disabled || !this.triggerList){
14927 this.loadNext = false;
14929 if(this.isExpanded()){
14931 if (!this.blockFocus) {
14932 this.inputEl().focus();
14936 this.hasFocus = true;
14937 if(this.triggerAction == 'all') {
14938 this.doQuery(this.allQuery, true);
14940 this.doQuery(this.getRawValue());
14942 if (!this.blockFocus) {
14943 this.inputEl().focus();
14948 onTickableTriggerClick : function(e)
14955 this.loadNext = false;
14956 this.hasFocus = true;
14958 if(this.triggerAction == 'all') {
14959 this.doQuery(this.allQuery, true);
14961 this.doQuery(this.getRawValue());
14965 onSearchFieldClick : function(e)
14967 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14968 this.onTickableFooterButtonClick(e, false, false);
14972 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14977 this.loadNext = false;
14978 this.hasFocus = true;
14980 if(this.triggerAction == 'all') {
14981 this.doQuery(this.allQuery, true);
14983 this.doQuery(this.getRawValue());
14987 listKeyPress : function(e)
14989 //Roo.log('listkeypress');
14990 // scroll to first matching element based on key pres..
14991 if (e.isSpecialKey()) {
14994 var k = String.fromCharCode(e.getKey()).toUpperCase();
14997 var csel = this.view.getSelectedNodes();
14998 var cselitem = false;
15000 var ix = this.view.indexOf(csel[0]);
15001 cselitem = this.store.getAt(ix);
15002 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
15008 this.store.each(function(v) {
15010 // start at existing selection.
15011 if (cselitem.id == v.id) {
15017 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
15018 match = this.store.indexOf(v);
15024 if (match === false) {
15025 return true; // no more action?
15028 this.view.select(match);
15029 var sn = Roo.get(this.view.getSelectedNodes()[0]);
15030 sn.scrollIntoView(sn.dom.parentNode, false);
15033 onViewScroll : function(e, t){
15035 if(this.view.el.getScroll().top == 0 ||this.view.el.getScroll().top < this.view.el.dom.scrollHeight - this.view.el.dom.clientHeight || !this.hasFocus || !this.append || this.hasQuery){
15039 this.hasQuery = true;
15041 this.loading = this.list.select('.loading', true).first();
15043 if(this.loading === null){
15044 this.list.createChild({
15046 cls: 'loading roo-select2-more-results roo-select2-active',
15047 html: 'Loading more results...'
15050 this.loading = this.list.select('.loading', true).first();
15052 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15054 this.loading.hide();
15057 this.loading.show();
15062 this.loadNext = true;
15064 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15069 addItem : function(o)
15071 var dv = ''; // display value
15073 if (this.displayField) {
15074 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15076 // this is an error condition!!!
15077 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15084 var choice = this.choices.createChild({
15086 cls: 'roo-select2-search-choice',
15095 cls: 'roo-select2-search-choice-close fa fa-times',
15100 }, this.searchField);
15102 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15104 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15112 this.inputEl().dom.value = '';
15117 onRemoveItem : function(e, _self, o)
15119 e.preventDefault();
15121 this.lastItem = Roo.apply([], this.item);
15123 var index = this.item.indexOf(o.data) * 1;
15126 Roo.log('not this item?!');
15130 this.item.splice(index, 1);
15135 this.fireEvent('remove', this, e);
15141 syncValue : function()
15143 if(!this.item.length){
15150 Roo.each(this.item, function(i){
15151 if(_this.valueField){
15152 value.push(i[_this.valueField]);
15159 this.value = value.join(',');
15161 if(this.hiddenField){
15162 this.hiddenField.dom.value = this.value;
15165 this.store.fireEvent("datachanged", this.store);
15170 clearItem : function()
15172 if(!this.multiple){
15178 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15186 if(this.tickable && !Roo.isTouch){
15187 this.view.refresh();
15191 inputEl: function ()
15193 if(Roo.isIOS && this.useNativeIOS){
15194 return this.el.select('select.roo-ios-select', true).first();
15197 if(Roo.isTouch && this.mobileTouchView){
15198 return this.el.select('input.form-control',true).first();
15202 return this.searchField;
15205 return this.el.select('input.form-control',true).first();
15208 onTickableFooterButtonClick : function(e, btn, el)
15210 e.preventDefault();
15212 this.lastItem = Roo.apply([], this.item);
15214 if(btn && btn.name == 'cancel'){
15215 this.tickItems = Roo.apply([], this.item);
15224 Roo.each(this.tickItems, function(o){
15232 validate : function()
15234 if(this.getVisibilityEl().hasClass('hidden')){
15238 var v = this.getRawValue();
15241 v = this.getValue();
15244 if(this.disabled || this.allowBlank || v.length){
15249 this.markInvalid();
15253 tickableInputEl : function()
15255 if(!this.tickable || !this.editable){
15256 return this.inputEl();
15259 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15263 getAutoCreateTouchView : function()
15268 cls: 'form-group' //input-group
15274 type : this.inputType,
15275 cls : 'form-control x-combo-noedit',
15276 autocomplete: 'new-password',
15277 placeholder : this.placeholder || '',
15282 input.name = this.name;
15286 input.cls += ' input-' + this.size;
15289 if (this.disabled) {
15290 input.disabled = true;
15301 inputblock.cls += ' input-group';
15303 inputblock.cn.unshift({
15305 cls : 'input-group-addon input-group-prepend input-group-text',
15310 if(this.removable && !this.multiple){
15311 inputblock.cls += ' roo-removable';
15313 inputblock.cn.push({
15316 cls : 'roo-combo-removable-btn close'
15320 if(this.hasFeedback && !this.allowBlank){
15322 inputblock.cls += ' has-feedback';
15324 inputblock.cn.push({
15326 cls: 'glyphicon form-control-feedback'
15333 inputblock.cls += (this.before) ? '' : ' input-group';
15335 inputblock.cn.push({
15337 cls : 'input-group-addon input-group-append input-group-text',
15343 var ibwrap = inputblock;
15348 cls: 'roo-select2-choices',
15352 cls: 'roo-select2-search-field',
15365 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15370 cls: 'form-hidden-field'
15376 if(!this.multiple && this.showToggleBtn){
15382 if (this.caret != false) {
15385 cls: 'fa fa-' + this.caret
15392 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15394 Roo.bootstrap.version == 3 ? caret : '',
15397 cls: 'combobox-clear',
15411 combobox.cls += ' roo-select2-container-multi';
15414 var align = this.labelAlign || this.parentLabelAlign();
15416 if (align ==='left' && this.fieldLabel.length) {
15421 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15422 tooltip : 'This field is required'
15426 cls : 'control-label col-form-label',
15427 html : this.fieldLabel
15438 var labelCfg = cfg.cn[1];
15439 var contentCfg = cfg.cn[2];
15442 if(this.indicatorpos == 'right'){
15447 cls : 'control-label col-form-label',
15451 html : this.fieldLabel
15455 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15456 tooltip : 'This field is required'
15469 labelCfg = cfg.cn[0];
15470 contentCfg = cfg.cn[1];
15475 if(this.labelWidth > 12){
15476 labelCfg.style = "width: " + this.labelWidth + 'px';
15479 if(this.labelWidth < 13 && this.labelmd == 0){
15480 this.labelmd = this.labelWidth;
15483 if(this.labellg > 0){
15484 labelCfg.cls += ' col-lg-' + this.labellg;
15485 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15488 if(this.labelmd > 0){
15489 labelCfg.cls += ' col-md-' + this.labelmd;
15490 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15493 if(this.labelsm > 0){
15494 labelCfg.cls += ' col-sm-' + this.labelsm;
15495 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15498 if(this.labelxs > 0){
15499 labelCfg.cls += ' col-xs-' + this.labelxs;
15500 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15504 } else if ( this.fieldLabel.length) {
15508 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15509 tooltip : 'This field is required'
15513 cls : 'control-label',
15514 html : this.fieldLabel
15525 if(this.indicatorpos == 'right'){
15529 cls : 'control-label',
15530 html : this.fieldLabel,
15534 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15535 tooltip : 'This field is required'
15552 var settings = this;
15554 ['xs','sm','md','lg'].map(function(size){
15555 if (settings[size]) {
15556 cfg.cls += ' col-' + size + '-' + settings[size];
15563 initTouchView : function()
15565 this.renderTouchView();
15567 this.touchViewEl.on('scroll', function(){
15568 this.el.dom.scrollTop = 0;
15571 this.originalValue = this.getValue();
15573 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15575 this.inputEl().on("click", this.showTouchView, this);
15576 if (this.triggerEl) {
15577 this.triggerEl.on("click", this.showTouchView, this);
15581 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15582 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15584 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15586 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15587 this.store.on('load', this.onTouchViewLoad, this);
15588 this.store.on('loadexception', this.onTouchViewLoadException, this);
15590 if(this.hiddenName){
15592 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15594 this.hiddenField.dom.value =
15595 this.hiddenValue !== undefined ? this.hiddenValue :
15596 this.value !== undefined ? this.value : '';
15598 this.el.dom.removeAttribute('name');
15599 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15603 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15604 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15607 if(this.removable && !this.multiple){
15608 var close = this.closeTriggerEl();
15610 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15611 close.on('click', this.removeBtnClick, this, close);
15615 * fix the bug in Safari iOS8
15617 this.inputEl().on("focus", function(e){
15618 document.activeElement.blur();
15621 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15628 renderTouchView : function()
15630 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15631 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15633 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15634 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15636 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15637 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15638 this.touchViewBodyEl.setStyle('overflow', 'auto');
15640 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15641 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15643 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15644 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15648 showTouchView : function()
15654 this.touchViewHeaderEl.hide();
15656 if(this.modalTitle.length){
15657 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15658 this.touchViewHeaderEl.show();
15661 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15662 this.touchViewEl.show();
15664 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15666 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15667 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15669 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15671 if(this.modalTitle.length){
15672 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15675 this.touchViewBodyEl.setHeight(bodyHeight);
15679 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15681 this.touchViewEl.addClass('in');
15684 if(this._touchViewMask){
15685 Roo.get(document.body).addClass("x-body-masked");
15686 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15687 this._touchViewMask.setStyle('z-index', 10000);
15688 this._touchViewMask.addClass('show');
15691 this.doTouchViewQuery();
15695 hideTouchView : function()
15697 this.touchViewEl.removeClass('in');
15701 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15703 this.touchViewEl.setStyle('display', 'none');
15706 if(this._touchViewMask){
15707 this._touchViewMask.removeClass('show');
15708 Roo.get(document.body).removeClass("x-body-masked");
15712 setTouchViewValue : function()
15719 Roo.each(this.tickItems, function(o){
15724 this.hideTouchView();
15727 doTouchViewQuery : function()
15736 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15740 if(!this.alwaysQuery || this.mode == 'local'){
15741 this.onTouchViewLoad();
15748 onTouchViewBeforeLoad : function(combo,opts)
15754 onTouchViewLoad : function()
15756 if(this.store.getCount() < 1){
15757 this.onTouchViewEmptyResults();
15761 this.clearTouchView();
15763 var rawValue = this.getRawValue();
15765 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15767 this.tickItems = [];
15769 this.store.data.each(function(d, rowIndex){
15770 var row = this.touchViewListGroup.createChild(template);
15772 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15773 row.addClass(d.data.cls);
15776 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15779 html : d.data[this.displayField]
15782 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15783 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15786 row.removeClass('selected');
15787 if(!this.multiple && this.valueField &&
15788 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15791 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15792 row.addClass('selected');
15795 if(this.multiple && this.valueField &&
15796 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15800 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15801 this.tickItems.push(d.data);
15804 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15808 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15810 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15812 if(this.modalTitle.length){
15813 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15816 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15818 if(this.mobile_restrict_height && listHeight < bodyHeight){
15819 this.touchViewBodyEl.setHeight(listHeight);
15824 if(firstChecked && listHeight > bodyHeight){
15825 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15830 onTouchViewLoadException : function()
15832 this.hideTouchView();
15835 onTouchViewEmptyResults : function()
15837 this.clearTouchView();
15839 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15841 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15845 clearTouchView : function()
15847 this.touchViewListGroup.dom.innerHTML = '';
15850 onTouchViewClick : function(e, el, o)
15852 e.preventDefault();
15855 var rowIndex = o.rowIndex;
15857 var r = this.store.getAt(rowIndex);
15859 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15861 if(!this.multiple){
15862 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15863 c.dom.removeAttribute('checked');
15866 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15868 this.setFromData(r.data);
15870 var close = this.closeTriggerEl();
15876 this.hideTouchView();
15878 this.fireEvent('select', this, r, rowIndex);
15883 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15884 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15885 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15889 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15890 this.addItem(r.data);
15891 this.tickItems.push(r.data);
15895 getAutoCreateNativeIOS : function()
15898 cls: 'form-group' //input-group,
15903 cls : 'roo-ios-select'
15907 combobox.name = this.name;
15910 if (this.disabled) {
15911 combobox.disabled = true;
15914 var settings = this;
15916 ['xs','sm','md','lg'].map(function(size){
15917 if (settings[size]) {
15918 cfg.cls += ' col-' + size + '-' + settings[size];
15928 initIOSView : function()
15930 this.store.on('load', this.onIOSViewLoad, this);
15935 onIOSViewLoad : function()
15937 if(this.store.getCount() < 1){
15941 this.clearIOSView();
15943 if(this.allowBlank) {
15945 var default_text = '-- SELECT --';
15947 if(this.placeholder.length){
15948 default_text = this.placeholder;
15951 if(this.emptyTitle.length){
15952 default_text += ' - ' + this.emptyTitle + ' -';
15955 var opt = this.inputEl().createChild({
15958 html : default_text
15962 o[this.valueField] = 0;
15963 o[this.displayField] = default_text;
15965 this.ios_options.push({
15972 this.store.data.each(function(d, rowIndex){
15976 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15977 html = d.data[this.displayField];
15982 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15983 value = d.data[this.valueField];
15992 if(this.value == d.data[this.valueField]){
15993 option['selected'] = true;
15996 var opt = this.inputEl().createChild(option);
15998 this.ios_options.push({
16005 this.inputEl().on('change', function(){
16006 this.fireEvent('select', this);
16011 clearIOSView: function()
16013 this.inputEl().dom.innerHTML = '';
16015 this.ios_options = [];
16018 setIOSValue: function(v)
16022 if(!this.ios_options){
16026 Roo.each(this.ios_options, function(opts){
16028 opts.el.dom.removeAttribute('selected');
16030 if(opts.data[this.valueField] != v){
16034 opts.el.dom.setAttribute('selected', true);
16040 * @cfg {Boolean} grow
16044 * @cfg {Number} growMin
16048 * @cfg {Number} growMax
16057 Roo.apply(Roo.bootstrap.ComboBox, {
16061 cls: 'modal-header',
16083 cls: 'list-group-item',
16087 cls: 'roo-combobox-list-group-item-value'
16091 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16105 listItemCheckbox : {
16107 cls: 'list-group-item',
16111 cls: 'roo-combobox-list-group-item-value'
16115 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16131 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16136 cls: 'modal-footer',
16144 cls: 'col-xs-6 text-left',
16147 cls: 'btn btn-danger roo-touch-view-cancel',
16153 cls: 'col-xs-6 text-right',
16156 cls: 'btn btn-success roo-touch-view-ok',
16167 Roo.apply(Roo.bootstrap.ComboBox, {
16169 touchViewTemplate : {
16171 cls: 'modal fade roo-combobox-touch-view',
16175 cls: 'modal-dialog',
16176 style : 'position:fixed', // we have to fix position....
16180 cls: 'modal-content',
16182 Roo.bootstrap.ComboBox.header,
16183 Roo.bootstrap.ComboBox.body,
16184 Roo.bootstrap.ComboBox.footer
16193 * Ext JS Library 1.1.1
16194 * Copyright(c) 2006-2007, Ext JS, LLC.
16196 * Originally Released Under LGPL - original licence link has changed is not relivant.
16199 * <script type="text/javascript">
16204 * @extends Roo.util.Observable
16205 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16206 * This class also supports single and multi selection modes. <br>
16207 * Create a data model bound view:
16209 var store = new Roo.data.Store(...);
16211 var view = new Roo.View({
16213 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16215 singleSelect: true,
16216 selectedClass: "ydataview-selected",
16220 // listen for node click?
16221 view.on("click", function(vw, index, node, e){
16222 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16226 dataModel.load("foobar.xml");
16228 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16230 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16231 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16233 * Note: old style constructor is still suported (container, template, config)
16236 * Create a new View
16237 * @param {Object} config The config object
16240 Roo.View = function(config, depreciated_tpl, depreciated_config){
16242 this.parent = false;
16244 if (typeof(depreciated_tpl) == 'undefined') {
16245 // new way.. - universal constructor.
16246 Roo.apply(this, config);
16247 this.el = Roo.get(this.el);
16250 this.el = Roo.get(config);
16251 this.tpl = depreciated_tpl;
16252 Roo.apply(this, depreciated_config);
16254 this.wrapEl = this.el.wrap().wrap();
16255 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16258 if(typeof(this.tpl) == "string"){
16259 this.tpl = new Roo.Template(this.tpl);
16261 // support xtype ctors..
16262 this.tpl = new Roo.factory(this.tpl, Roo);
16266 this.tpl.compile();
16271 * @event beforeclick
16272 * Fires before a click is processed. Returns false to cancel the default action.
16273 * @param {Roo.View} this
16274 * @param {Number} index The index of the target node
16275 * @param {HTMLElement} node The target node
16276 * @param {Roo.EventObject} e The raw event object
16278 "beforeclick" : true,
16281 * Fires when a template node is clicked.
16282 * @param {Roo.View} this
16283 * @param {Number} index The index of the target node
16284 * @param {HTMLElement} node The target node
16285 * @param {Roo.EventObject} e The raw event object
16290 * Fires when a template node is double clicked.
16291 * @param {Roo.View} this
16292 * @param {Number} index The index of the target node
16293 * @param {HTMLElement} node The target node
16294 * @param {Roo.EventObject} e The raw event object
16298 * @event contextmenu
16299 * Fires when a template node is right clicked.
16300 * @param {Roo.View} this
16301 * @param {Number} index The index of the target node
16302 * @param {HTMLElement} node The target node
16303 * @param {Roo.EventObject} e The raw event object
16305 "contextmenu" : true,
16307 * @event selectionchange
16308 * Fires when the selected nodes change.
16309 * @param {Roo.View} this
16310 * @param {Array} selections Array of the selected nodes
16312 "selectionchange" : true,
16315 * @event beforeselect
16316 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16317 * @param {Roo.View} this
16318 * @param {HTMLElement} node The node to be selected
16319 * @param {Array} selections Array of currently selected nodes
16321 "beforeselect" : true,
16323 * @event preparedata
16324 * Fires on every row to render, to allow you to change the data.
16325 * @param {Roo.View} this
16326 * @param {Object} data to be rendered (change this)
16328 "preparedata" : true
16336 "click": this.onClick,
16337 "dblclick": this.onDblClick,
16338 "contextmenu": this.onContextMenu,
16342 this.selections = [];
16344 this.cmp = new Roo.CompositeElementLite([]);
16346 this.store = Roo.factory(this.store, Roo.data);
16347 this.setStore(this.store, true);
16350 if ( this.footer && this.footer.xtype) {
16352 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16354 this.footer.dataSource = this.store;
16355 this.footer.container = fctr;
16356 this.footer = Roo.factory(this.footer, Roo);
16357 fctr.insertFirst(this.el);
16359 // this is a bit insane - as the paging toolbar seems to detach the el..
16360 // dom.parentNode.parentNode.parentNode
16361 // they get detached?
16365 Roo.View.superclass.constructor.call(this);
16370 Roo.extend(Roo.View, Roo.util.Observable, {
16373 * @cfg {Roo.data.Store} store Data store to load data from.
16378 * @cfg {String|Roo.Element} el The container element.
16383 * @cfg {String|Roo.Template} tpl The template used by this View
16387 * @cfg {String} dataName the named area of the template to use as the data area
16388 * Works with domtemplates roo-name="name"
16392 * @cfg {String} selectedClass The css class to add to selected nodes
16394 selectedClass : "x-view-selected",
16396 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16401 * @cfg {String} text to display on mask (default Loading)
16405 * @cfg {Boolean} multiSelect Allow multiple selection
16407 multiSelect : false,
16409 * @cfg {Boolean} singleSelect Allow single selection
16411 singleSelect: false,
16414 * @cfg {Boolean} toggleSelect - selecting
16416 toggleSelect : false,
16419 * @cfg {Boolean} tickable - selecting
16424 * Returns the element this view is bound to.
16425 * @return {Roo.Element}
16427 getEl : function(){
16428 return this.wrapEl;
16434 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16436 refresh : function(){
16437 //Roo.log('refresh');
16440 // if we are using something like 'domtemplate', then
16441 // the what gets used is:
16442 // t.applySubtemplate(NAME, data, wrapping data..)
16443 // the outer template then get' applied with
16444 // the store 'extra data'
16445 // and the body get's added to the
16446 // roo-name="data" node?
16447 // <span class='roo-tpl-{name}'></span> ?????
16451 this.clearSelections();
16452 this.el.update("");
16454 var records = this.store.getRange();
16455 if(records.length < 1) {
16457 // is this valid?? = should it render a template??
16459 this.el.update(this.emptyText);
16463 if (this.dataName) {
16464 this.el.update(t.apply(this.store.meta)); //????
16465 el = this.el.child('.roo-tpl-' + this.dataName);
16468 for(var i = 0, len = records.length; i < len; i++){
16469 var data = this.prepareData(records[i].data, i, records[i]);
16470 this.fireEvent("preparedata", this, data, i, records[i]);
16472 var d = Roo.apply({}, data);
16475 Roo.apply(d, {'roo-id' : Roo.id()});
16479 Roo.each(this.parent.item, function(item){
16480 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16483 Roo.apply(d, {'roo-data-checked' : 'checked'});
16487 html[html.length] = Roo.util.Format.trim(
16489 t.applySubtemplate(this.dataName, d, this.store.meta) :
16496 el.update(html.join(""));
16497 this.nodes = el.dom.childNodes;
16498 this.updateIndexes(0);
16503 * Function to override to reformat the data that is sent to
16504 * the template for each node.
16505 * DEPRICATED - use the preparedata event handler.
16506 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16507 * a JSON object for an UpdateManager bound view).
16509 prepareData : function(data, index, record)
16511 this.fireEvent("preparedata", this, data, index, record);
16515 onUpdate : function(ds, record){
16516 // Roo.log('on update');
16517 this.clearSelections();
16518 var index = this.store.indexOf(record);
16519 var n = this.nodes[index];
16520 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16521 n.parentNode.removeChild(n);
16522 this.updateIndexes(index, index);
16528 onAdd : function(ds, records, index)
16530 //Roo.log(['on Add', ds, records, index] );
16531 this.clearSelections();
16532 if(this.nodes.length == 0){
16536 var n = this.nodes[index];
16537 for(var i = 0, len = records.length; i < len; i++){
16538 var d = this.prepareData(records[i].data, i, records[i]);
16540 this.tpl.insertBefore(n, d);
16543 this.tpl.append(this.el, d);
16546 this.updateIndexes(index);
16549 onRemove : function(ds, record, index){
16550 // Roo.log('onRemove');
16551 this.clearSelections();
16552 var el = this.dataName ?
16553 this.el.child('.roo-tpl-' + this.dataName) :
16556 el.dom.removeChild(this.nodes[index]);
16557 this.updateIndexes(index);
16561 * Refresh an individual node.
16562 * @param {Number} index
16564 refreshNode : function(index){
16565 this.onUpdate(this.store, this.store.getAt(index));
16568 updateIndexes : function(startIndex, endIndex){
16569 var ns = this.nodes;
16570 startIndex = startIndex || 0;
16571 endIndex = endIndex || ns.length - 1;
16572 for(var i = startIndex; i <= endIndex; i++){
16573 ns[i].nodeIndex = i;
16578 * Changes the data store this view uses and refresh the view.
16579 * @param {Store} store
16581 setStore : function(store, initial){
16582 if(!initial && this.store){
16583 this.store.un("datachanged", this.refresh);
16584 this.store.un("add", this.onAdd);
16585 this.store.un("remove", this.onRemove);
16586 this.store.un("update", this.onUpdate);
16587 this.store.un("clear", this.refresh);
16588 this.store.un("beforeload", this.onBeforeLoad);
16589 this.store.un("load", this.onLoad);
16590 this.store.un("loadexception", this.onLoad);
16594 store.on("datachanged", this.refresh, this);
16595 store.on("add", this.onAdd, this);
16596 store.on("remove", this.onRemove, this);
16597 store.on("update", this.onUpdate, this);
16598 store.on("clear", this.refresh, this);
16599 store.on("beforeload", this.onBeforeLoad, this);
16600 store.on("load", this.onLoad, this);
16601 store.on("loadexception", this.onLoad, this);
16609 * onbeforeLoad - masks the loading area.
16612 onBeforeLoad : function(store,opts)
16614 //Roo.log('onBeforeLoad');
16616 this.el.update("");
16618 this.el.mask(this.mask ? this.mask : "Loading" );
16620 onLoad : function ()
16627 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16628 * @param {HTMLElement} node
16629 * @return {HTMLElement} The template node
16631 findItemFromChild : function(node){
16632 var el = this.dataName ?
16633 this.el.child('.roo-tpl-' + this.dataName,true) :
16636 if(!node || node.parentNode == el){
16639 var p = node.parentNode;
16640 while(p && p != el){
16641 if(p.parentNode == el){
16650 onClick : function(e){
16651 var item = this.findItemFromChild(e.getTarget());
16653 var index = this.indexOf(item);
16654 if(this.onItemClick(item, index, e) !== false){
16655 this.fireEvent("click", this, index, item, e);
16658 this.clearSelections();
16663 onContextMenu : function(e){
16664 var item = this.findItemFromChild(e.getTarget());
16666 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16671 onDblClick : function(e){
16672 var item = this.findItemFromChild(e.getTarget());
16674 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16678 onItemClick : function(item, index, e)
16680 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16683 if (this.toggleSelect) {
16684 var m = this.isSelected(item) ? 'unselect' : 'select';
16687 _t[m](item, true, false);
16690 if(this.multiSelect || this.singleSelect){
16691 if(this.multiSelect && e.shiftKey && this.lastSelection){
16692 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16694 this.select(item, this.multiSelect && e.ctrlKey);
16695 this.lastSelection = item;
16698 if(!this.tickable){
16699 e.preventDefault();
16707 * Get the number of selected nodes.
16710 getSelectionCount : function(){
16711 return this.selections.length;
16715 * Get the currently selected nodes.
16716 * @return {Array} An array of HTMLElements
16718 getSelectedNodes : function(){
16719 return this.selections;
16723 * Get the indexes of the selected nodes.
16726 getSelectedIndexes : function(){
16727 var indexes = [], s = this.selections;
16728 for(var i = 0, len = s.length; i < len; i++){
16729 indexes.push(s[i].nodeIndex);
16735 * Clear all selections
16736 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16738 clearSelections : function(suppressEvent){
16739 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16740 this.cmp.elements = this.selections;
16741 this.cmp.removeClass(this.selectedClass);
16742 this.selections = [];
16743 if(!suppressEvent){
16744 this.fireEvent("selectionchange", this, this.selections);
16750 * Returns true if the passed node is selected
16751 * @param {HTMLElement/Number} node The node or node index
16752 * @return {Boolean}
16754 isSelected : function(node){
16755 var s = this.selections;
16759 node = this.getNode(node);
16760 return s.indexOf(node) !== -1;
16765 * @param {Array/HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node, id of a template node or an array of any of those to select
16766 * @param {Boolean} keepExisting (optional) true to keep existing selections
16767 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16769 select : function(nodeInfo, keepExisting, suppressEvent){
16770 if(nodeInfo instanceof Array){
16772 this.clearSelections(true);
16774 for(var i = 0, len = nodeInfo.length; i < len; i++){
16775 this.select(nodeInfo[i], true, true);
16779 var node = this.getNode(nodeInfo);
16780 if(!node || this.isSelected(node)){
16781 return; // already selected.
16784 this.clearSelections(true);
16787 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16788 Roo.fly(node).addClass(this.selectedClass);
16789 this.selections.push(node);
16790 if(!suppressEvent){
16791 this.fireEvent("selectionchange", this, this.selections);
16799 * @param {Array/HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node, id of a template node or an array of any of those to select
16800 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16801 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16803 unselect : function(nodeInfo, keepExisting, suppressEvent)
16805 if(nodeInfo instanceof Array){
16806 Roo.each(this.selections, function(s) {
16807 this.unselect(s, nodeInfo);
16811 var node = this.getNode(nodeInfo);
16812 if(!node || !this.isSelected(node)){
16813 //Roo.log("not selected");
16814 return; // not selected.
16818 Roo.each(this.selections, function(s) {
16820 Roo.fly(node).removeClass(this.selectedClass);
16827 this.selections= ns;
16828 this.fireEvent("selectionchange", this, this.selections);
16832 * Gets a template node.
16833 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16834 * @return {HTMLElement} The node or null if it wasn't found
16836 getNode : function(nodeInfo){
16837 if(typeof nodeInfo == "string"){
16838 return document.getElementById(nodeInfo);
16839 }else if(typeof nodeInfo == "number"){
16840 return this.nodes[nodeInfo];
16846 * Gets a range template nodes.
16847 * @param {Number} startIndex
16848 * @param {Number} endIndex
16849 * @return {Array} An array of nodes
16851 getNodes : function(start, end){
16852 var ns = this.nodes;
16853 start = start || 0;
16854 end = typeof end == "undefined" ? ns.length - 1 : end;
16857 for(var i = start; i <= end; i++){
16861 for(var i = start; i >= end; i--){
16869 * Finds the index of the passed node
16870 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16871 * @return {Number} The index of the node or -1
16873 indexOf : function(node){
16874 node = this.getNode(node);
16875 if(typeof node.nodeIndex == "number"){
16876 return node.nodeIndex;
16878 var ns = this.nodes;
16879 for(var i = 0, len = ns.length; i < len; i++){
16890 * based on jquery fullcalendar
16894 Roo.bootstrap = Roo.bootstrap || {};
16896 * @class Roo.bootstrap.Calendar
16897 * @extends Roo.bootstrap.Component
16898 * Bootstrap Calendar class
16899 * @cfg {Boolean} loadMask (true|false) default false
16900 * @cfg {Object} header generate the user specific header of the calendar, default false
16903 * Create a new Container
16904 * @param {Object} config The config object
16909 Roo.bootstrap.Calendar = function(config){
16910 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16914 * Fires when a date is selected
16915 * @param {DatePicker} this
16916 * @param {Date} date The selected date
16920 * @event monthchange
16921 * Fires when the displayed month changes
16922 * @param {DatePicker} this
16923 * @param {Date} date The selected month
16925 'monthchange': true,
16927 * @event evententer
16928 * Fires when mouse over an event
16929 * @param {Calendar} this
16930 * @param {event} Event
16932 'evententer': true,
16934 * @event eventleave
16935 * Fires when the mouse leaves an
16936 * @param {Calendar} this
16939 'eventleave': true,
16941 * @event eventclick
16942 * Fires when the mouse click an
16943 * @param {Calendar} this
16952 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16955 * @cfg {Number} startDay
16956 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16964 getAutoCreate : function(){
16967 var fc_button = function(name, corner, style, content ) {
16968 return Roo.apply({},{
16970 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16972 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16975 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16986 style : 'width:100%',
16993 cls : 'fc-header-left',
16995 fc_button('prev', 'left', 'arrow', '‹' ),
16996 fc_button('next', 'right', 'arrow', '›' ),
16997 { tag: 'span', cls: 'fc-header-space' },
16998 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
17006 cls : 'fc-header-center',
17010 cls: 'fc-header-title',
17013 html : 'month / year'
17021 cls : 'fc-header-right',
17023 /* fc_button('month', 'left', '', 'month' ),
17024 fc_button('week', '', '', 'week' ),
17025 fc_button('day', 'right', '', 'day' )
17037 header = this.header;
17040 var cal_heads = function() {
17042 // fixme - handle this.
17044 for (var i =0; i < Date.dayNames.length; i++) {
17045 var d = Date.dayNames[i];
17048 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17049 html : d.substring(0,3)
17053 ret[0].cls += ' fc-first';
17054 ret[6].cls += ' fc-last';
17057 var cal_cell = function(n) {
17060 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17065 cls: 'fc-day-number',
17069 cls: 'fc-day-content',
17073 style: 'position: relative;' // height: 17px;
17085 var cal_rows = function() {
17088 for (var r = 0; r < 6; r++) {
17095 for (var i =0; i < Date.dayNames.length; i++) {
17096 var d = Date.dayNames[i];
17097 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17100 row.cn[0].cls+=' fc-first';
17101 row.cn[0].cn[0].style = 'min-height:90px';
17102 row.cn[6].cls+=' fc-last';
17106 ret[0].cls += ' fc-first';
17107 ret[4].cls += ' fc-prev-last';
17108 ret[5].cls += ' fc-last';
17115 cls: 'fc-border-separate',
17116 style : 'width:100%',
17124 cls : 'fc-first fc-last',
17142 cls : 'fc-content',
17143 style : "position: relative;",
17146 cls : 'fc-view fc-view-month fc-grid',
17147 style : 'position: relative',
17148 unselectable : 'on',
17151 cls : 'fc-event-container',
17152 style : 'position:absolute;z-index:8;top:0;left:0;'
17170 initEvents : function()
17173 throw "can not find store for calendar";
17179 style: "text-align:center",
17183 style: "background-color:white;width:50%;margin:250 auto",
17187 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17198 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17200 var size = this.el.select('.fc-content', true).first().getSize();
17201 this.maskEl.setSize(size.width, size.height);
17202 this.maskEl.enableDisplayMode("block");
17203 if(!this.loadMask){
17204 this.maskEl.hide();
17207 this.store = Roo.factory(this.store, Roo.data);
17208 this.store.on('load', this.onLoad, this);
17209 this.store.on('beforeload', this.onBeforeLoad, this);
17213 this.cells = this.el.select('.fc-day',true);
17214 //Roo.log(this.cells);
17215 this.textNodes = this.el.query('.fc-day-number');
17216 this.cells.addClassOnOver('fc-state-hover');
17218 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17219 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17220 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17221 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17223 this.on('monthchange', this.onMonthChange, this);
17225 this.update(new Date().clearTime());
17228 resize : function() {
17229 var sz = this.el.getSize();
17231 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17232 this.el.select('.fc-day-content div',true).setHeight(34);
17237 showPrevMonth : function(e){
17238 this.update(this.activeDate.add("mo", -1));
17240 showToday : function(e){
17241 this.update(new Date().clearTime());
17244 showNextMonth : function(e){
17245 this.update(this.activeDate.add("mo", 1));
17249 showPrevYear : function(){
17250 this.update(this.activeDate.add("y", -1));
17254 showNextYear : function(){
17255 this.update(this.activeDate.add("y", 1));
17260 update : function(date)
17262 var vd = this.activeDate;
17263 this.activeDate = date;
17264 // if(vd && this.el){
17265 // var t = date.getTime();
17266 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17267 // Roo.log('using add remove');
17269 // this.fireEvent('monthchange', this, date);
17271 // this.cells.removeClass("fc-state-highlight");
17272 // this.cells.each(function(c){
17273 // if(c.dateValue == t){
17274 // c.addClass("fc-state-highlight");
17275 // setTimeout(function(){
17276 // try{c.dom.firstChild.focus();}catch(e){}
17286 var days = date.getDaysInMonth();
17288 var firstOfMonth = date.getFirstDateOfMonth();
17289 var startingPos = firstOfMonth.getDay()-this.startDay;
17291 if(startingPos < this.startDay){
17295 var pm = date.add(Date.MONTH, -1);
17296 var prevStart = pm.getDaysInMonth()-startingPos;
17298 this.cells = this.el.select('.fc-day',true);
17299 this.textNodes = this.el.query('.fc-day-number');
17300 this.cells.addClassOnOver('fc-state-hover');
17302 var cells = this.cells.elements;
17303 var textEls = this.textNodes;
17305 Roo.each(cells, function(cell){
17306 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17309 days += startingPos;
17311 // convert everything to numbers so it's fast
17312 var day = 86400000;
17313 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17316 //Roo.log(prevStart);
17318 var today = new Date().clearTime().getTime();
17319 var sel = date.clearTime().getTime();
17320 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17321 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17322 var ddMatch = this.disabledDatesRE;
17323 var ddText = this.disabledDatesText;
17324 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17325 var ddaysText = this.disabledDaysText;
17326 var format = this.format;
17328 var setCellClass = function(cal, cell){
17332 //Roo.log('set Cell Class');
17334 var t = d.getTime();
17338 cell.dateValue = t;
17340 cell.className += " fc-today";
17341 cell.className += " fc-state-highlight";
17342 cell.title = cal.todayText;
17345 // disable highlight in other month..
17346 //cell.className += " fc-state-highlight";
17351 cell.className = " fc-state-disabled";
17352 cell.title = cal.minText;
17356 cell.className = " fc-state-disabled";
17357 cell.title = cal.maxText;
17361 if(ddays.indexOf(d.getDay()) != -1){
17362 cell.title = ddaysText;
17363 cell.className = " fc-state-disabled";
17366 if(ddMatch && format){
17367 var fvalue = d.dateFormat(format);
17368 if(ddMatch.test(fvalue)){
17369 cell.title = ddText.replace("%0", fvalue);
17370 cell.className = " fc-state-disabled";
17374 if (!cell.initialClassName) {
17375 cell.initialClassName = cell.dom.className;
17378 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17383 for(; i < startingPos; i++) {
17384 textEls[i].innerHTML = (++prevStart);
17385 d.setDate(d.getDate()+1);
17387 cells[i].className = "fc-past fc-other-month";
17388 setCellClass(this, cells[i]);
17393 for(; i < days; i++){
17394 intDay = i - startingPos + 1;
17395 textEls[i].innerHTML = (intDay);
17396 d.setDate(d.getDate()+1);
17398 cells[i].className = ''; // "x-date-active";
17399 setCellClass(this, cells[i]);
17403 for(; i < 42; i++) {
17404 textEls[i].innerHTML = (++extraDays);
17405 d.setDate(d.getDate()+1);
17407 cells[i].className = "fc-future fc-other-month";
17408 setCellClass(this, cells[i]);
17411 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17413 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17415 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17416 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17418 if(totalRows != 6){
17419 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17420 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17423 this.fireEvent('monthchange', this, date);
17427 if(!this.internalRender){
17428 var main = this.el.dom.firstChild;
17429 var w = main.offsetWidth;
17430 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17431 Roo.fly(main).setWidth(w);
17432 this.internalRender = true;
17433 // opera does not respect the auto grow header center column
17434 // then, after it gets a width opera refuses to recalculate
17435 // without a second pass
17436 if(Roo.isOpera && !this.secondPass){
17437 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17438 this.secondPass = true;
17439 this.update.defer(10, this, [date]);
17446 findCell : function(dt) {
17447 dt = dt.clearTime().getTime();
17449 this.cells.each(function(c){
17450 //Roo.log("check " +c.dateValue + '?=' + dt);
17451 if(c.dateValue == dt){
17461 findCells : function(ev) {
17462 var s = ev.start.clone().clearTime().getTime();
17464 var e= ev.end.clone().clearTime().getTime();
17467 this.cells.each(function(c){
17468 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17470 if(c.dateValue > e){
17473 if(c.dateValue < s){
17482 // findBestRow: function(cells)
17486 // for (var i =0 ; i < cells.length;i++) {
17487 // ret = Math.max(cells[i].rows || 0,ret);
17494 addItem : function(ev)
17496 // look for vertical location slot in
17497 var cells = this.findCells(ev);
17499 // ev.row = this.findBestRow(cells);
17501 // work out the location.
17505 for(var i =0; i < cells.length; i++) {
17507 cells[i].row = cells[0].row;
17510 cells[i].row = cells[i].row + 1;
17520 if (crow.start.getY() == cells[i].getY()) {
17522 crow.end = cells[i];
17539 cells[0].events.push(ev);
17541 this.calevents.push(ev);
17544 clearEvents: function() {
17546 if(!this.calevents){
17550 Roo.each(this.cells.elements, function(c){
17556 Roo.each(this.calevents, function(e) {
17557 Roo.each(e.els, function(el) {
17558 el.un('mouseenter' ,this.onEventEnter, this);
17559 el.un('mouseleave' ,this.onEventLeave, this);
17564 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17570 renderEvents: function()
17574 this.cells.each(function(c) {
17583 if(c.row != c.events.length){
17584 r = 4 - (4 - (c.row - c.events.length));
17587 c.events = ev.slice(0, r);
17588 c.more = ev.slice(r);
17590 if(c.more.length && c.more.length == 1){
17591 c.events.push(c.more.pop());
17594 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17598 this.cells.each(function(c) {
17600 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17603 for (var e = 0; e < c.events.length; e++){
17604 var ev = c.events[e];
17605 var rows = ev.rows;
17607 for(var i = 0; i < rows.length; i++) {
17609 // how many rows should it span..
17612 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17613 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17615 unselectable : "on",
17618 cls: 'fc-event-inner',
17622 // cls: 'fc-event-time',
17623 // html : cells.length > 1 ? '' : ev.time
17627 cls: 'fc-event-title',
17628 html : String.format('{0}', ev.title)
17635 cls: 'ui-resizable-handle ui-resizable-e',
17636 html : '  '
17643 cfg.cls += ' fc-event-start';
17645 if ((i+1) == rows.length) {
17646 cfg.cls += ' fc-event-end';
17649 var ctr = _this.el.select('.fc-event-container',true).first();
17650 var cg = ctr.createChild(cfg);
17652 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17653 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17655 var r = (c.more.length) ? 1 : 0;
17656 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17657 cg.setWidth(ebox.right - sbox.x -2);
17659 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17660 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17661 cg.on('click', _this.onEventClick, _this, ev);
17672 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17673 style : 'position: absolute',
17674 unselectable : "on",
17677 cls: 'fc-event-inner',
17681 cls: 'fc-event-title',
17689 cls: 'ui-resizable-handle ui-resizable-e',
17690 html : '  '
17696 var ctr = _this.el.select('.fc-event-container',true).first();
17697 var cg = ctr.createChild(cfg);
17699 var sbox = c.select('.fc-day-content',true).first().getBox();
17700 var ebox = c.select('.fc-day-content',true).first().getBox();
17702 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17703 cg.setWidth(ebox.right - sbox.x -2);
17705 cg.on('click', _this.onMoreEventClick, _this, c.more);
17715 onEventEnter: function (e, el,event,d) {
17716 this.fireEvent('evententer', this, el, event);
17719 onEventLeave: function (e, el,event,d) {
17720 this.fireEvent('eventleave', this, el, event);
17723 onEventClick: function (e, el,event,d) {
17724 this.fireEvent('eventclick', this, el, event);
17727 onMonthChange: function () {
17731 onMoreEventClick: function(e, el, more)
17735 this.calpopover.placement = 'right';
17736 this.calpopover.setTitle('More');
17738 this.calpopover.setContent('');
17740 var ctr = this.calpopover.el.select('.popover-content', true).first();
17742 Roo.each(more, function(m){
17744 cls : 'fc-event-hori fc-event-draggable',
17747 var cg = ctr.createChild(cfg);
17749 cg.on('click', _this.onEventClick, _this, m);
17752 this.calpopover.show(el);
17757 onLoad: function ()
17759 this.calevents = [];
17762 if(this.store.getCount() > 0){
17763 this.store.data.each(function(d){
17766 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17767 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17768 time : d.data.start_time,
17769 title : d.data.title,
17770 description : d.data.description,
17771 venue : d.data.venue
17776 this.renderEvents();
17778 if(this.calevents.length && this.loadMask){
17779 this.maskEl.hide();
17783 onBeforeLoad: function()
17785 this.clearEvents();
17787 this.maskEl.show();
17801 * @class Roo.bootstrap.Popover
17802 * @extends Roo.bootstrap.Component
17803 * Bootstrap Popover class
17804 * @cfg {String} html contents of the popover (or false to use children..)
17805 * @cfg {String} title of popover (or false to hide)
17806 * @cfg {String} placement how it is placed
17807 * @cfg {String} trigger click || hover (or false to trigger manually)
17808 * @cfg {String} over what (parent or false to trigger manually.)
17809 * @cfg {Number} delay - delay before showing
17812 * Create a new Popover
17813 * @param {Object} config The config object
17816 Roo.bootstrap.Popover = function(config){
17817 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17823 * After the popover show
17825 * @param {Roo.bootstrap.Popover} this
17830 * After the popover hide
17832 * @param {Roo.bootstrap.Popover} this
17838 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17840 title: 'Fill in a title',
17843 placement : 'right',
17844 trigger : 'hover', // hover
17850 can_build_overlaid : false,
17852 getChildContainer : function()
17854 return this.el.select('.popover-content',true).first();
17857 getAutoCreate : function(){
17860 cls : 'popover roo-dynamic',
17861 style: 'display:block',
17867 cls : 'popover-inner',
17871 cls: 'popover-title popover-header',
17875 cls : 'popover-content popover-body',
17886 setTitle: function(str)
17889 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17891 setContent: function(str)
17894 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17896 // as it get's added to the bottom of the page.
17897 onRender : function(ct, position)
17899 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17901 var cfg = Roo.apply({}, this.getAutoCreate());
17905 cfg.cls += ' ' + this.cls;
17908 cfg.style = this.style;
17910 //Roo.log("adding to ");
17911 this.el = Roo.get(document.body).createChild(cfg, position);
17912 // Roo.log(this.el);
17917 initEvents : function()
17919 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17920 this.el.enableDisplayMode('block');
17922 if (this.over === false) {
17925 if (this.triggers === false) {
17928 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17929 var triggers = this.trigger ? this.trigger.split(' ') : [];
17930 Roo.each(triggers, function(trigger) {
17932 if (trigger == 'click') {
17933 on_el.on('click', this.toggle, this);
17934 } else if (trigger != 'manual') {
17935 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17936 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17938 on_el.on(eventIn ,this.enter, this);
17939 on_el.on(eventOut, this.leave, this);
17950 toggle : function () {
17951 this.hoverState == 'in' ? this.leave() : this.enter();
17954 enter : function () {
17956 clearTimeout(this.timeout);
17958 this.hoverState = 'in';
17960 if (!this.delay || !this.delay.show) {
17965 this.timeout = setTimeout(function () {
17966 if (_t.hoverState == 'in') {
17969 }, this.delay.show)
17972 leave : function() {
17973 clearTimeout(this.timeout);
17975 this.hoverState = 'out';
17977 if (!this.delay || !this.delay.hide) {
17982 this.timeout = setTimeout(function () {
17983 if (_t.hoverState == 'out') {
17986 }, this.delay.hide)
17989 show : function (on_el)
17992 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17996 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17997 if (this.html !== false) {
17998 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
18000 this.el.removeClass([
18001 'fade','top','bottom', 'left', 'right','in',
18002 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
18004 if (!this.title.length) {
18005 this.el.select('.popover-title',true).hide();
18008 var placement = typeof this.placement == 'function' ?
18009 this.placement.call(this, this.el, on_el) :
18012 var autoToken = /\s?auto?\s?/i;
18013 var autoPlace = autoToken.test(placement);
18015 placement = placement.replace(autoToken, '') || 'top';
18019 //this.el.setXY([0,0]);
18021 this.el.dom.style.display='block';
18022 this.el.addClass(placement);
18024 //this.el.appendTo(on_el);
18026 var p = this.getPosition();
18027 var box = this.el.getBox();
18032 var align = Roo.bootstrap.Popover.alignment[placement];
18035 this.el.alignTo(on_el, align[0],align[1]);
18036 //var arrow = this.el.select('.arrow',true).first();
18037 //arrow.set(align[2],
18039 this.el.addClass('in');
18042 if (this.el.hasClass('fade')) {
18046 this.hoverState = 'in';
18048 this.fireEvent('show', this);
18053 this.el.setXY([0,0]);
18054 this.el.removeClass('in');
18056 this.hoverState = null;
18058 this.fireEvent('hide', this);
18063 Roo.bootstrap.Popover.alignment = {
18064 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18065 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18066 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18067 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18078 * @class Roo.bootstrap.Progress
18079 * @extends Roo.bootstrap.Component
18080 * Bootstrap Progress class
18081 * @cfg {Boolean} striped striped of the progress bar
18082 * @cfg {Boolean} active animated of the progress bar
18086 * Create a new Progress
18087 * @param {Object} config The config object
18090 Roo.bootstrap.Progress = function(config){
18091 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18094 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18099 getAutoCreate : function(){
18107 cfg.cls += ' progress-striped';
18111 cfg.cls += ' active';
18130 * @class Roo.bootstrap.ProgressBar
18131 * @extends Roo.bootstrap.Component
18132 * Bootstrap ProgressBar class
18133 * @cfg {Number} aria_valuenow aria-value now
18134 * @cfg {Number} aria_valuemin aria-value min
18135 * @cfg {Number} aria_valuemax aria-value max
18136 * @cfg {String} label label for the progress bar
18137 * @cfg {String} panel (success | info | warning | danger )
18138 * @cfg {String} role role of the progress bar
18139 * @cfg {String} sr_only text
18143 * Create a new ProgressBar
18144 * @param {Object} config The config object
18147 Roo.bootstrap.ProgressBar = function(config){
18148 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18151 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18155 aria_valuemax : 100,
18161 getAutoCreate : function()
18166 cls: 'progress-bar',
18167 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18179 cfg.role = this.role;
18182 if(this.aria_valuenow){
18183 cfg['aria-valuenow'] = this.aria_valuenow;
18186 if(this.aria_valuemin){
18187 cfg['aria-valuemin'] = this.aria_valuemin;
18190 if(this.aria_valuemax){
18191 cfg['aria-valuemax'] = this.aria_valuemax;
18194 if(this.label && !this.sr_only){
18195 cfg.html = this.label;
18199 cfg.cls += ' progress-bar-' + this.panel;
18205 update : function(aria_valuenow)
18207 this.aria_valuenow = aria_valuenow;
18209 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18224 * @class Roo.bootstrap.TabGroup
18225 * @extends Roo.bootstrap.Column
18226 * Bootstrap Column class
18227 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18228 * @cfg {Boolean} carousel true to make the group behave like a carousel
18229 * @cfg {Boolean} bullets show bullets for the panels
18230 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18231 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18232 * @cfg {Boolean} showarrow (true|false) show arrow default true
18235 * Create a new TabGroup
18236 * @param {Object} config The config object
18239 Roo.bootstrap.TabGroup = function(config){
18240 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18242 this.navId = Roo.id();
18245 Roo.bootstrap.TabGroup.register(this);
18249 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18252 transition : false,
18257 slideOnTouch : false,
18260 getAutoCreate : function()
18262 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18264 cfg.cls += ' tab-content';
18266 if (this.carousel) {
18267 cfg.cls += ' carousel slide';
18270 cls : 'carousel-inner',
18274 if(this.bullets && !Roo.isTouch){
18277 cls : 'carousel-bullets',
18281 if(this.bullets_cls){
18282 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18289 cfg.cn[0].cn.push(bullets);
18292 if(this.showarrow){
18293 cfg.cn[0].cn.push({
18295 class : 'carousel-arrow',
18299 class : 'carousel-prev',
18303 class : 'fa fa-chevron-left'
18309 class : 'carousel-next',
18313 class : 'fa fa-chevron-right'
18326 initEvents: function()
18328 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18329 // this.el.on("touchstart", this.onTouchStart, this);
18332 if(this.autoslide){
18335 this.slideFn = window.setInterval(function() {
18336 _this.showPanelNext();
18340 if(this.showarrow){
18341 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18342 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18348 // onTouchStart : function(e, el, o)
18350 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18354 // this.showPanelNext();
18358 getChildContainer : function()
18360 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18364 * register a Navigation item
18365 * @param {Roo.bootstrap.NavItem} the navitem to add
18367 register : function(item)
18369 this.tabs.push( item);
18370 item.navId = this.navId; // not really needed..
18375 getActivePanel : function()
18378 Roo.each(this.tabs, function(t) {
18388 getPanelByName : function(n)
18391 Roo.each(this.tabs, function(t) {
18392 if (t.tabId == n) {
18400 indexOfPanel : function(p)
18403 Roo.each(this.tabs, function(t,i) {
18404 if (t.tabId == p.tabId) {
18413 * show a specific panel
18414 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18415 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18417 showPanel : function (pan)
18419 if(this.transition || typeof(pan) == 'undefined'){
18420 Roo.log("waiting for the transitionend");
18424 if (typeof(pan) == 'number') {
18425 pan = this.tabs[pan];
18428 if (typeof(pan) == 'string') {
18429 pan = this.getPanelByName(pan);
18432 var cur = this.getActivePanel();
18435 Roo.log('pan or acitve pan is undefined');
18439 if (pan.tabId == this.getActivePanel().tabId) {
18443 if (false === cur.fireEvent('beforedeactivate')) {
18447 if(this.bullets > 0 && !Roo.isTouch){
18448 this.setActiveBullet(this.indexOfPanel(pan));
18451 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18453 //class="carousel-item carousel-item-next carousel-item-left"
18455 this.transition = true;
18456 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18457 var lr = dir == 'next' ? 'left' : 'right';
18458 pan.el.addClass(dir); // or prev
18459 pan.el.addClass('carousel-item-' + dir); // or prev
18460 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18461 cur.el.addClass(lr); // or right
18462 pan.el.addClass(lr);
18463 cur.el.addClass('carousel-item-' +lr); // or right
18464 pan.el.addClass('carousel-item-' +lr);
18468 cur.el.on('transitionend', function() {
18469 Roo.log("trans end?");
18471 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18472 pan.setActive(true);
18474 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18475 cur.setActive(false);
18477 _this.transition = false;
18479 }, this, { single: true } );
18484 cur.setActive(false);
18485 pan.setActive(true);
18490 showPanelNext : function()
18492 var i = this.indexOfPanel(this.getActivePanel());
18494 if (i >= this.tabs.length - 1 && !this.autoslide) {
18498 if (i >= this.tabs.length - 1 && this.autoslide) {
18502 this.showPanel(this.tabs[i+1]);
18505 showPanelPrev : function()
18507 var i = this.indexOfPanel(this.getActivePanel());
18509 if (i < 1 && !this.autoslide) {
18513 if (i < 1 && this.autoslide) {
18514 i = this.tabs.length;
18517 this.showPanel(this.tabs[i-1]);
18521 addBullet: function()
18523 if(!this.bullets || Roo.isTouch){
18526 var ctr = this.el.select('.carousel-bullets',true).first();
18527 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18528 var bullet = ctr.createChild({
18529 cls : 'bullet bullet-' + i
18530 },ctr.dom.lastChild);
18535 bullet.on('click', (function(e, el, o, ii, t){
18537 e.preventDefault();
18539 this.showPanel(ii);
18541 if(this.autoslide && this.slideFn){
18542 clearInterval(this.slideFn);
18543 this.slideFn = window.setInterval(function() {
18544 _this.showPanelNext();
18548 }).createDelegate(this, [i, bullet], true));
18553 setActiveBullet : function(i)
18559 Roo.each(this.el.select('.bullet', true).elements, function(el){
18560 el.removeClass('selected');
18563 var bullet = this.el.select('.bullet-' + i, true).first();
18569 bullet.addClass('selected');
18580 Roo.apply(Roo.bootstrap.TabGroup, {
18584 * register a Navigation Group
18585 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18587 register : function(navgrp)
18589 this.groups[navgrp.navId] = navgrp;
18593 * fetch a Navigation Group based on the navigation ID
18594 * if one does not exist , it will get created.
18595 * @param {string} the navgroup to add
18596 * @returns {Roo.bootstrap.NavGroup} the navgroup
18598 get: function(navId) {
18599 if (typeof(this.groups[navId]) == 'undefined') {
18600 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18602 return this.groups[navId] ;
18617 * @class Roo.bootstrap.TabPanel
18618 * @extends Roo.bootstrap.Component
18619 * Bootstrap TabPanel class
18620 * @cfg {Boolean} active panel active
18621 * @cfg {String} html panel content
18622 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18623 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18624 * @cfg {String} href click to link..
18628 * Create a new TabPanel
18629 * @param {Object} config The config object
18632 Roo.bootstrap.TabPanel = function(config){
18633 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18637 * Fires when the active status changes
18638 * @param {Roo.bootstrap.TabPanel} this
18639 * @param {Boolean} state the new state
18644 * @event beforedeactivate
18645 * Fires before a tab is de-activated - can be used to do validation on a form.
18646 * @param {Roo.bootstrap.TabPanel} this
18647 * @return {Boolean} false if there is an error
18650 'beforedeactivate': true
18653 this.tabId = this.tabId || Roo.id();
18657 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18665 getAutoCreate : function(){
18670 // item is needed for carousel - not sure if it has any effect otherwise
18671 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18672 html: this.html || ''
18676 cfg.cls += ' active';
18680 cfg.tabId = this.tabId;
18688 initEvents: function()
18690 var p = this.parent();
18692 this.navId = this.navId || p.navId;
18694 if (typeof(this.navId) != 'undefined') {
18695 // not really needed.. but just in case.. parent should be a NavGroup.
18696 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18700 var i = tg.tabs.length - 1;
18702 if(this.active && tg.bullets > 0 && i < tg.bullets){
18703 tg.setActiveBullet(i);
18707 this.el.on('click', this.onClick, this);
18710 this.el.on("touchstart", this.onTouchStart, this);
18711 this.el.on("touchmove", this.onTouchMove, this);
18712 this.el.on("touchend", this.onTouchEnd, this);
18717 onRender : function(ct, position)
18719 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18722 setActive : function(state)
18724 Roo.log("panel - set active " + this.tabId + "=" + state);
18726 this.active = state;
18728 this.el.removeClass('active');
18730 } else if (!this.el.hasClass('active')) {
18731 this.el.addClass('active');
18734 this.fireEvent('changed', this, state);
18737 onClick : function(e)
18739 e.preventDefault();
18741 if(!this.href.length){
18745 window.location.href = this.href;
18754 onTouchStart : function(e)
18756 this.swiping = false;
18758 this.startX = e.browserEvent.touches[0].clientX;
18759 this.startY = e.browserEvent.touches[0].clientY;
18762 onTouchMove : function(e)
18764 this.swiping = true;
18766 this.endX = e.browserEvent.touches[0].clientX;
18767 this.endY = e.browserEvent.touches[0].clientY;
18770 onTouchEnd : function(e)
18777 var tabGroup = this.parent();
18779 if(this.endX > this.startX){ // swiping right
18780 tabGroup.showPanelPrev();
18784 if(this.startX > this.endX){ // swiping left
18785 tabGroup.showPanelNext();
18804 * @class Roo.bootstrap.DateField
18805 * @extends Roo.bootstrap.Input
18806 * Bootstrap DateField class
18807 * @cfg {Number} weekStart default 0
18808 * @cfg {String} viewMode default empty, (months|years)
18809 * @cfg {String} minViewMode default empty, (months|years)
18810 * @cfg {Number} startDate default -Infinity
18811 * @cfg {Number} endDate default Infinity
18812 * @cfg {Boolean} todayHighlight default false
18813 * @cfg {Boolean} todayBtn default false
18814 * @cfg {Boolean} calendarWeeks default false
18815 * @cfg {Object} daysOfWeekDisabled default empty
18816 * @cfg {Boolean} singleMode default false (true | false)
18818 * @cfg {Boolean} keyboardNavigation default true
18819 * @cfg {String} language default en
18822 * Create a new DateField
18823 * @param {Object} config The config object
18826 Roo.bootstrap.DateField = function(config){
18827 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18831 * Fires when this field show.
18832 * @param {Roo.bootstrap.DateField} this
18833 * @param {Mixed} date The date value
18838 * Fires when this field hide.
18839 * @param {Roo.bootstrap.DateField} this
18840 * @param {Mixed} date The date value
18845 * Fires when select a date.
18846 * @param {Roo.bootstrap.DateField} this
18847 * @param {Mixed} date The date value
18851 * @event beforeselect
18852 * Fires when before select a date.
18853 * @param {Roo.bootstrap.DateField} this
18854 * @param {Mixed} date The date value
18856 beforeselect : true
18860 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18863 * @cfg {String} format
18864 * The default date format string which can be overriden for localization support. The format must be
18865 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18869 * @cfg {String} altFormats
18870 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18871 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18873 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18881 todayHighlight : false,
18887 keyboardNavigation: true,
18889 calendarWeeks: false,
18891 startDate: -Infinity,
18895 daysOfWeekDisabled: [],
18899 singleMode : false,
18901 UTCDate: function()
18903 return new Date(Date.UTC.apply(Date, arguments));
18906 UTCToday: function()
18908 var today = new Date();
18909 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18912 getDate: function() {
18913 var d = this.getUTCDate();
18914 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18917 getUTCDate: function() {
18921 setDate: function(d) {
18922 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18925 setUTCDate: function(d) {
18927 this.setValue(this.formatDate(this.date));
18930 onRender: function(ct, position)
18933 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18935 this.language = this.language || 'en';
18936 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18937 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18939 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18940 this.format = this.format || 'm/d/y';
18941 this.isInline = false;
18942 this.isInput = true;
18943 this.component = this.el.select('.add-on', true).first() || false;
18944 this.component = (this.component && this.component.length === 0) ? false : this.component;
18945 this.hasInput = this.component && this.inputEl().length;
18947 if (typeof(this.minViewMode === 'string')) {
18948 switch (this.minViewMode) {
18950 this.minViewMode = 1;
18953 this.minViewMode = 2;
18956 this.minViewMode = 0;
18961 if (typeof(this.viewMode === 'string')) {
18962 switch (this.viewMode) {
18975 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18977 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18979 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18981 this.picker().on('mousedown', this.onMousedown, this);
18982 this.picker().on('click', this.onClick, this);
18984 this.picker().addClass('datepicker-dropdown');
18986 this.startViewMode = this.viewMode;
18988 if(this.singleMode){
18989 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18990 v.setVisibilityMode(Roo.Element.DISPLAY);
18994 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18995 v.setStyle('width', '189px');
18999 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
19000 if(!this.calendarWeeks){
19005 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19006 v.attr('colspan', function(i, val){
19007 return parseInt(val) + 1;
19012 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
19014 this.setStartDate(this.startDate);
19015 this.setEndDate(this.endDate);
19017 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
19024 if(this.isInline) {
19029 picker : function()
19031 return this.pickerEl;
19032 // return this.el.select('.datepicker', true).first();
19035 fillDow: function()
19037 var dowCnt = this.weekStart;
19046 if(this.calendarWeeks){
19054 while (dowCnt < this.weekStart + 7) {
19058 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19062 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19065 fillMonths: function()
19068 var months = this.picker().select('>.datepicker-months td', true).first();
19070 months.dom.innerHTML = '';
19076 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19079 months.createChild(month);
19086 this.date = (typeof(this.date) === 'undefined' || ((typeof(this.date) === 'string') && !this.date.length)) ? this.UTCToday() : (typeof(this.date) === 'string') ? this.parseDate(this.date) : this.date;
19088 if (this.date < this.startDate) {
19089 this.viewDate = new Date(this.startDate);
19090 } else if (this.date > this.endDate) {
19091 this.viewDate = new Date(this.endDate);
19093 this.viewDate = new Date(this.date);
19101 var d = new Date(this.viewDate),
19102 year = d.getUTCFullYear(),
19103 month = d.getUTCMonth(),
19104 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19105 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19106 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19107 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19108 currentDate = this.date && this.date.valueOf(),
19109 today = this.UTCToday();
19111 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19113 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19115 // this.picker.select('>tfoot th.today').
19116 // .text(dates[this.language].today)
19117 // .toggle(this.todayBtn !== false);
19119 this.updateNavArrows();
19122 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19124 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19126 prevMonth.setUTCDate(day);
19128 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19130 var nextMonth = new Date(prevMonth);
19132 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19134 nextMonth = nextMonth.valueOf();
19136 var fillMonths = false;
19138 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19140 while(prevMonth.valueOf() <= nextMonth) {
19143 if (prevMonth.getUTCDay() === this.weekStart) {
19145 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19153 if(this.calendarWeeks){
19154 // ISO 8601: First week contains first thursday.
19155 // ISO also states week starts on Monday, but we can be more abstract here.
19157 // Start of current week: based on weekstart/current date
19158 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19159 // Thursday of this week
19160 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19161 // First Thursday of year, year from thursday
19162 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19163 // Calendar week: ms between thursdays, div ms per day, div 7 days
19164 calWeek = (th - yth) / 864e5 / 7 + 1;
19166 fillMonths.cn.push({
19174 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19176 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19179 if (this.todayHighlight &&
19180 prevMonth.getUTCFullYear() == today.getFullYear() &&
19181 prevMonth.getUTCMonth() == today.getMonth() &&
19182 prevMonth.getUTCDate() == today.getDate()) {
19183 clsName += ' today';
19186 if (currentDate && prevMonth.valueOf() === currentDate) {
19187 clsName += ' active';
19190 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19191 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19192 clsName += ' disabled';
19195 fillMonths.cn.push({
19197 cls: 'day ' + clsName,
19198 html: prevMonth.getDate()
19201 prevMonth.setDate(prevMonth.getDate()+1);
19204 var currentYear = this.date && this.date.getUTCFullYear();
19205 var currentMonth = this.date && this.date.getUTCMonth();
19207 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19209 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19210 v.removeClass('active');
19212 if(currentYear === year && k === currentMonth){
19213 v.addClass('active');
19216 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19217 v.addClass('disabled');
19223 year = parseInt(year/10, 10) * 10;
19225 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19227 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19230 for (var i = -1; i < 11; i++) {
19231 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19233 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19241 showMode: function(dir)
19244 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19247 Roo.each(this.picker().select('>div',true).elements, function(v){
19248 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19251 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19256 if(this.isInline) {
19260 this.picker().removeClass(['bottom', 'top']);
19262 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19264 * place to the top of element!
19268 this.picker().addClass('top');
19269 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19274 this.picker().addClass('bottom');
19276 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19279 parseDate : function(value)
19281 if(!value || value instanceof Date){
19284 var v = Date.parseDate(value, this.format);
19285 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19286 v = Date.parseDate(value, 'Y-m-d');
19288 if(!v && this.altFormats){
19289 if(!this.altFormatsArray){
19290 this.altFormatsArray = this.altFormats.split("|");
19292 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19293 v = Date.parseDate(value, this.altFormatsArray[i]);
19299 formatDate : function(date, fmt)
19301 return (!date || !(date instanceof Date)) ?
19302 date : date.dateFormat(fmt || this.format);
19305 onFocus : function()
19307 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19311 onBlur : function()
19313 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19315 var d = this.inputEl().getValue();
19322 showPopup : function()
19324 this.picker().show();
19328 this.fireEvent('showpopup', this, this.date);
19331 hidePopup : function()
19333 if(this.isInline) {
19336 this.picker().hide();
19337 this.viewMode = this.startViewMode;
19340 this.fireEvent('hidepopup', this, this.date);
19344 onMousedown: function(e)
19346 e.stopPropagation();
19347 e.preventDefault();
19352 Roo.bootstrap.DateField.superclass.keyup.call(this);
19356 setValue: function(v)
19358 if(this.fireEvent('beforeselect', this, v) !== false){
19359 var d = new Date(this.parseDate(v) ).clearTime();
19361 if(isNaN(d.getTime())){
19362 this.date = this.viewDate = '';
19363 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19367 v = this.formatDate(d);
19369 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19371 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19375 this.fireEvent('select', this, this.date);
19379 getValue: function()
19381 return this.formatDate(this.date);
19384 fireKey: function(e)
19386 if (!this.picker().isVisible()){
19387 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19393 var dateChanged = false,
19395 newDate, newViewDate;
19400 e.preventDefault();
19404 if (!this.keyboardNavigation) {
19407 dir = e.keyCode == 37 ? -1 : 1;
19410 newDate = this.moveYear(this.date, dir);
19411 newViewDate = this.moveYear(this.viewDate, dir);
19412 } else if (e.shiftKey){
19413 newDate = this.moveMonth(this.date, dir);
19414 newViewDate = this.moveMonth(this.viewDate, dir);
19416 newDate = new Date(this.date);
19417 newDate.setUTCDate(this.date.getUTCDate() + dir);
19418 newViewDate = new Date(this.viewDate);
19419 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19421 if (this.dateWithinRange(newDate)){
19422 this.date = newDate;
19423 this.viewDate = newViewDate;
19424 this.setValue(this.formatDate(this.date));
19426 e.preventDefault();
19427 dateChanged = true;
19432 if (!this.keyboardNavigation) {
19435 dir = e.keyCode == 38 ? -1 : 1;
19437 newDate = this.moveYear(this.date, dir);
19438 newViewDate = this.moveYear(this.viewDate, dir);
19439 } else if (e.shiftKey){
19440 newDate = this.moveMonth(this.date, dir);
19441 newViewDate = this.moveMonth(this.viewDate, dir);
19443 newDate = new Date(this.date);
19444 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19445 newViewDate = new Date(this.viewDate);
19446 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19448 if (this.dateWithinRange(newDate)){
19449 this.date = newDate;
19450 this.viewDate = newViewDate;
19451 this.setValue(this.formatDate(this.date));
19453 e.preventDefault();
19454 dateChanged = true;
19458 this.setValue(this.formatDate(this.date));
19460 e.preventDefault();
19463 this.setValue(this.formatDate(this.date));
19477 onClick: function(e)
19479 e.stopPropagation();
19480 e.preventDefault();
19482 var target = e.getTarget();
19484 if(target.nodeName.toLowerCase() === 'i'){
19485 target = Roo.get(target).dom.parentNode;
19488 var nodeName = target.nodeName;
19489 var className = target.className;
19490 var html = target.innerHTML;
19491 //Roo.log(nodeName);
19493 switch(nodeName.toLowerCase()) {
19495 switch(className) {
19501 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19502 switch(this.viewMode){
19504 this.viewDate = this.moveMonth(this.viewDate, dir);
19508 this.viewDate = this.moveYear(this.viewDate, dir);
19514 var date = new Date();
19515 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19517 this.setValue(this.formatDate(this.date));
19524 if (className.indexOf('disabled') < 0) {
19525 this.viewDate.setUTCDate(1);
19526 if (className.indexOf('month') > -1) {
19527 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19529 var year = parseInt(html, 10) || 0;
19530 this.viewDate.setUTCFullYear(year);
19534 if(this.singleMode){
19535 this.setValue(this.formatDate(this.viewDate));
19546 //Roo.log(className);
19547 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19548 var day = parseInt(html, 10) || 1;
19549 var year = this.viewDate.getUTCFullYear(),
19550 month = this.viewDate.getUTCMonth();
19552 if (className.indexOf('old') > -1) {
19559 } else if (className.indexOf('new') > -1) {
19567 //Roo.log([year,month,day]);
19568 this.date = this.UTCDate(year, month, day,0,0,0,0);
19569 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19571 //Roo.log(this.formatDate(this.date));
19572 this.setValue(this.formatDate(this.date));
19579 setStartDate: function(startDate)
19581 this.startDate = startDate || -Infinity;
19582 if (this.startDate !== -Infinity) {
19583 this.startDate = this.parseDate(this.startDate);
19586 this.updateNavArrows();
19589 setEndDate: function(endDate)
19591 this.endDate = endDate || Infinity;
19592 if (this.endDate !== Infinity) {
19593 this.endDate = this.parseDate(this.endDate);
19596 this.updateNavArrows();
19599 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19601 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19602 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19603 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19605 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19606 return parseInt(d, 10);
19609 this.updateNavArrows();
19612 updateNavArrows: function()
19614 if(this.singleMode){
19618 var d = new Date(this.viewDate),
19619 year = d.getUTCFullYear(),
19620 month = d.getUTCMonth();
19622 Roo.each(this.picker().select('.prev', true).elements, function(v){
19624 switch (this.viewMode) {
19627 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19633 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19640 Roo.each(this.picker().select('.next', true).elements, function(v){
19642 switch (this.viewMode) {
19645 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19651 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19659 moveMonth: function(date, dir)
19664 var new_date = new Date(date.valueOf()),
19665 day = new_date.getUTCDate(),
19666 month = new_date.getUTCMonth(),
19667 mag = Math.abs(dir),
19669 dir = dir > 0 ? 1 : -1;
19672 // If going back one month, make sure month is not current month
19673 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19675 return new_date.getUTCMonth() == month;
19677 // If going forward one month, make sure month is as expected
19678 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19680 return new_date.getUTCMonth() != new_month;
19682 new_month = month + dir;
19683 new_date.setUTCMonth(new_month);
19684 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19685 if (new_month < 0 || new_month > 11) {
19686 new_month = (new_month + 12) % 12;
19689 // For magnitudes >1, move one month at a time...
19690 for (var i=0; i<mag; i++) {
19691 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19692 new_date = this.moveMonth(new_date, dir);
19694 // ...then reset the day, keeping it in the new month
19695 new_month = new_date.getUTCMonth();
19696 new_date.setUTCDate(day);
19698 return new_month != new_date.getUTCMonth();
19701 // Common date-resetting loop -- if date is beyond end of month, make it
19704 new_date.setUTCDate(--day);
19705 new_date.setUTCMonth(new_month);
19710 moveYear: function(date, dir)
19712 return this.moveMonth(date, dir*12);
19715 dateWithinRange: function(date)
19717 return date >= this.startDate && date <= this.endDate;
19723 this.picker().remove();
19726 validateValue : function(value)
19728 if(this.getVisibilityEl().hasClass('hidden')){
19732 if(value.length < 1) {
19733 if(this.allowBlank){
19739 if(value.length < this.minLength){
19742 if(value.length > this.maxLength){
19746 var vt = Roo.form.VTypes;
19747 if(!vt[this.vtype](value, this)){
19751 if(typeof this.validator == "function"){
19752 var msg = this.validator(value);
19758 if(this.regex && !this.regex.test(value)){
19762 if(typeof(this.parseDate(value)) == 'undefined'){
19766 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19770 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19780 this.date = this.viewDate = '';
19782 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19787 Roo.apply(Roo.bootstrap.DateField, {
19798 html: '<i class="fa fa-arrow-left"/>'
19808 html: '<i class="fa fa-arrow-right"/>'
19850 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19851 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19852 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19853 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19854 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19867 navFnc: 'FullYear',
19872 navFnc: 'FullYear',
19877 Roo.apply(Roo.bootstrap.DateField, {
19881 cls: 'datepicker dropdown-menu roo-dynamic',
19885 cls: 'datepicker-days',
19889 cls: 'table-condensed',
19891 Roo.bootstrap.DateField.head,
19895 Roo.bootstrap.DateField.footer
19902 cls: 'datepicker-months',
19906 cls: 'table-condensed',
19908 Roo.bootstrap.DateField.head,
19909 Roo.bootstrap.DateField.content,
19910 Roo.bootstrap.DateField.footer
19917 cls: 'datepicker-years',
19921 cls: 'table-condensed',
19923 Roo.bootstrap.DateField.head,
19924 Roo.bootstrap.DateField.content,
19925 Roo.bootstrap.DateField.footer
19944 * @class Roo.bootstrap.TimeField
19945 * @extends Roo.bootstrap.Input
19946 * Bootstrap DateField class
19950 * Create a new TimeField
19951 * @param {Object} config The config object
19954 Roo.bootstrap.TimeField = function(config){
19955 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19959 * Fires when this field show.
19960 * @param {Roo.bootstrap.DateField} thisthis
19961 * @param {Mixed} date The date value
19966 * Fires when this field hide.
19967 * @param {Roo.bootstrap.DateField} this
19968 * @param {Mixed} date The date value
19973 * Fires when select a date.
19974 * @param {Roo.bootstrap.DateField} this
19975 * @param {Mixed} date The date value
19981 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19984 * @cfg {String} format
19985 * The default time format string which can be overriden for localization support. The format must be
19986 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19990 onRender: function(ct, position)
19993 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19995 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19997 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19999 this.pop = this.picker().select('>.datepicker-time',true).first();
20000 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20002 this.picker().on('mousedown', this.onMousedown, this);
20003 this.picker().on('click', this.onClick, this);
20005 this.picker().addClass('datepicker-dropdown');
20010 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
20011 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
20012 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
20013 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
20014 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
20015 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
20019 fireKey: function(e){
20020 if (!this.picker().isVisible()){
20021 if (e.keyCode == 27) { // allow escape to hide and re-show picker
20027 e.preventDefault();
20035 this.onTogglePeriod();
20038 this.onIncrementMinutes();
20041 this.onDecrementMinutes();
20050 onClick: function(e) {
20051 e.stopPropagation();
20052 e.preventDefault();
20055 picker : function()
20057 return this.el.select('.datepicker', true).first();
20060 fillTime: function()
20062 var time = this.pop.select('tbody', true).first();
20064 time.dom.innerHTML = '';
20079 cls: 'hours-up glyphicon glyphicon-chevron-up'
20099 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20120 cls: 'timepicker-hour',
20135 cls: 'timepicker-minute',
20150 cls: 'btn btn-primary period',
20172 cls: 'hours-down glyphicon glyphicon-chevron-down'
20192 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20210 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20217 var hours = this.time.getHours();
20218 var minutes = this.time.getMinutes();
20231 hours = hours - 12;
20235 hours = '0' + hours;
20239 minutes = '0' + minutes;
20242 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20243 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20244 this.pop.select('button', true).first().dom.innerHTML = period;
20250 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20252 var cls = ['bottom'];
20254 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20261 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20266 this.picker().addClass(cls.join('-'));
20270 Roo.each(cls, function(c){
20272 _this.picker().setTop(_this.inputEl().getHeight());
20276 _this.picker().setTop(0 - _this.picker().getHeight());
20281 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20285 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20292 onFocus : function()
20294 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20298 onBlur : function()
20300 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20306 this.picker().show();
20311 this.fireEvent('show', this, this.date);
20316 this.picker().hide();
20319 this.fireEvent('hide', this, this.date);
20322 setTime : function()
20325 this.setValue(this.time.format(this.format));
20327 this.fireEvent('select', this, this.date);
20332 onMousedown: function(e){
20333 e.stopPropagation();
20334 e.preventDefault();
20337 onIncrementHours: function()
20339 Roo.log('onIncrementHours');
20340 this.time = this.time.add(Date.HOUR, 1);
20345 onDecrementHours: function()
20347 Roo.log('onDecrementHours');
20348 this.time = this.time.add(Date.HOUR, -1);
20352 onIncrementMinutes: function()
20354 Roo.log('onIncrementMinutes');
20355 this.time = this.time.add(Date.MINUTE, 1);
20359 onDecrementMinutes: function()
20361 Roo.log('onDecrementMinutes');
20362 this.time = this.time.add(Date.MINUTE, -1);
20366 onTogglePeriod: function()
20368 Roo.log('onTogglePeriod');
20369 this.time = this.time.add(Date.HOUR, 12);
20376 Roo.apply(Roo.bootstrap.TimeField, {
20406 cls: 'btn btn-info ok',
20418 Roo.apply(Roo.bootstrap.TimeField, {
20422 cls: 'datepicker dropdown-menu',
20426 cls: 'datepicker-time',
20430 cls: 'table-condensed',
20432 Roo.bootstrap.TimeField.content,
20433 Roo.bootstrap.TimeField.footer
20452 * @class Roo.bootstrap.MonthField
20453 * @extends Roo.bootstrap.Input
20454 * Bootstrap MonthField class
20456 * @cfg {String} language default en
20459 * Create a new MonthField
20460 * @param {Object} config The config object
20463 Roo.bootstrap.MonthField = function(config){
20464 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20469 * Fires when this field show.
20470 * @param {Roo.bootstrap.MonthField} this
20471 * @param {Mixed} date The date value
20476 * Fires when this field hide.
20477 * @param {Roo.bootstrap.MonthField} this
20478 * @param {Mixed} date The date value
20483 * Fires when select a date.
20484 * @param {Roo.bootstrap.MonthField} this
20485 * @param {String} oldvalue The old value
20486 * @param {String} newvalue The new value
20492 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20494 onRender: function(ct, position)
20497 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20499 this.language = this.language || 'en';
20500 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20501 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20503 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20504 this.isInline = false;
20505 this.isInput = true;
20506 this.component = this.el.select('.add-on', true).first() || false;
20507 this.component = (this.component && this.component.length === 0) ? false : this.component;
20508 this.hasInput = this.component && this.inputEL().length;
20510 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20512 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20514 this.picker().on('mousedown', this.onMousedown, this);
20515 this.picker().on('click', this.onClick, this);
20517 this.picker().addClass('datepicker-dropdown');
20519 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20520 v.setStyle('width', '189px');
20527 if(this.isInline) {
20533 setValue: function(v, suppressEvent)
20535 var o = this.getValue();
20537 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20541 if(suppressEvent !== true){
20542 this.fireEvent('select', this, o, v);
20547 getValue: function()
20552 onClick: function(e)
20554 e.stopPropagation();
20555 e.preventDefault();
20557 var target = e.getTarget();
20559 if(target.nodeName.toLowerCase() === 'i'){
20560 target = Roo.get(target).dom.parentNode;
20563 var nodeName = target.nodeName;
20564 var className = target.className;
20565 var html = target.innerHTML;
20567 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20571 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20573 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20579 picker : function()
20581 return this.pickerEl;
20584 fillMonths: function()
20587 var months = this.picker().select('>.datepicker-months td', true).first();
20589 months.dom.innerHTML = '';
20595 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20598 months.createChild(month);
20607 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20608 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20611 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20612 e.removeClass('active');
20614 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20615 e.addClass('active');
20622 if(this.isInline) {
20626 this.picker().removeClass(['bottom', 'top']);
20628 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20630 * place to the top of element!
20634 this.picker().addClass('top');
20635 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20640 this.picker().addClass('bottom');
20642 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20645 onFocus : function()
20647 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20651 onBlur : function()
20653 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20655 var d = this.inputEl().getValue();
20664 this.picker().show();
20665 this.picker().select('>.datepicker-months', true).first().show();
20669 this.fireEvent('show', this, this.date);
20674 if(this.isInline) {
20677 this.picker().hide();
20678 this.fireEvent('hide', this, this.date);
20682 onMousedown: function(e)
20684 e.stopPropagation();
20685 e.preventDefault();
20690 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20694 fireKey: function(e)
20696 if (!this.picker().isVisible()){
20697 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20708 e.preventDefault();
20712 dir = e.keyCode == 37 ? -1 : 1;
20714 this.vIndex = this.vIndex + dir;
20716 if(this.vIndex < 0){
20720 if(this.vIndex > 11){
20724 if(isNaN(this.vIndex)){
20728 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20734 dir = e.keyCode == 38 ? -1 : 1;
20736 this.vIndex = this.vIndex + dir * 4;
20738 if(this.vIndex < 0){
20742 if(this.vIndex > 11){
20746 if(isNaN(this.vIndex)){
20750 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20755 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20756 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20760 e.preventDefault();
20763 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20764 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20780 this.picker().remove();
20785 Roo.apply(Roo.bootstrap.MonthField, {
20804 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20805 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20810 Roo.apply(Roo.bootstrap.MonthField, {
20814 cls: 'datepicker dropdown-menu roo-dynamic',
20818 cls: 'datepicker-months',
20822 cls: 'table-condensed',
20824 Roo.bootstrap.DateField.content
20844 * @class Roo.bootstrap.CheckBox
20845 * @extends Roo.bootstrap.Input
20846 * Bootstrap CheckBox class
20848 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20849 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20850 * @cfg {String} boxLabel The text that appears beside the checkbox
20851 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20852 * @cfg {Boolean} checked initnal the element
20853 * @cfg {Boolean} inline inline the element (default false)
20854 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20855 * @cfg {String} tooltip label tooltip
20858 * Create a new CheckBox
20859 * @param {Object} config The config object
20862 Roo.bootstrap.CheckBox = function(config){
20863 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20868 * Fires when the element is checked or unchecked.
20869 * @param {Roo.bootstrap.CheckBox} this This input
20870 * @param {Boolean} checked The new checked value
20875 * Fires when the element is click.
20876 * @param {Roo.bootstrap.CheckBox} this This input
20883 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20885 inputType: 'checkbox',
20894 getAutoCreate : function()
20896 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20902 cfg.cls = 'form-group ' + this.inputType; //input-group
20905 cfg.cls += ' ' + this.inputType + '-inline';
20911 type : this.inputType,
20912 value : this.inputValue,
20913 cls : 'roo-' + this.inputType, //'form-box',
20914 placeholder : this.placeholder || ''
20918 if(this.inputType != 'radio'){
20922 cls : 'roo-hidden-value',
20923 value : this.checked ? this.inputValue : this.valueOff
20928 if (this.weight) { // Validity check?
20929 cfg.cls += " " + this.inputType + "-" + this.weight;
20932 if (this.disabled) {
20933 input.disabled=true;
20937 input.checked = this.checked;
20942 input.name = this.name;
20944 if(this.inputType != 'radio'){
20945 hidden.name = this.name;
20946 input.name = '_hidden_' + this.name;
20951 input.cls += ' input-' + this.size;
20956 ['xs','sm','md','lg'].map(function(size){
20957 if (settings[size]) {
20958 cfg.cls += ' col-' + size + '-' + settings[size];
20962 var inputblock = input;
20964 if (this.before || this.after) {
20967 cls : 'input-group',
20972 inputblock.cn.push({
20974 cls : 'input-group-addon',
20979 inputblock.cn.push(input);
20981 if(this.inputType != 'radio'){
20982 inputblock.cn.push(hidden);
20986 inputblock.cn.push({
20988 cls : 'input-group-addon',
20995 if (align ==='left' && this.fieldLabel.length) {
20996 // Roo.log("left and has label");
21001 cls : 'control-label',
21002 html : this.fieldLabel
21012 if(this.labelWidth > 12){
21013 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
21016 if(this.labelWidth < 13 && this.labelmd == 0){
21017 this.labelmd = this.labelWidth;
21020 if(this.labellg > 0){
21021 cfg.cn[0].cls += ' col-lg-' + this.labellg;
21022 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
21025 if(this.labelmd > 0){
21026 cfg.cn[0].cls += ' col-md-' + this.labelmd;
21027 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
21030 if(this.labelsm > 0){
21031 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
21032 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
21035 if(this.labelxs > 0){
21036 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
21037 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
21040 } else if ( this.fieldLabel.length) {
21041 // Roo.log(" label");
21045 tag: this.boxLabel ? 'span' : 'label',
21047 cls: 'control-label box-input-label',
21048 //cls : 'input-group-addon',
21049 html : this.fieldLabel
21058 // Roo.log(" no label && no align");
21059 cfg.cn = [ inputblock ] ;
21065 var boxLabelCfg = {
21067 //'for': id, // box label is handled by onclick - so no for...
21069 html: this.boxLabel
21073 boxLabelCfg.tooltip = this.tooltip;
21076 cfg.cn.push(boxLabelCfg);
21079 if(this.inputType != 'radio'){
21080 cfg.cn.push(hidden);
21088 * return the real input element.
21090 inputEl: function ()
21092 return this.el.select('input.roo-' + this.inputType,true).first();
21094 hiddenEl: function ()
21096 return this.el.select('input.roo-hidden-value',true).first();
21099 labelEl: function()
21101 return this.el.select('label.control-label',true).first();
21103 /* depricated... */
21107 return this.labelEl();
21110 boxLabelEl: function()
21112 return this.el.select('label.box-label',true).first();
21115 initEvents : function()
21117 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21119 this.inputEl().on('click', this.onClick, this);
21121 if (this.boxLabel) {
21122 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21125 this.startValue = this.getValue();
21128 Roo.bootstrap.CheckBox.register(this);
21132 onClick : function(e)
21134 if(this.fireEvent('click', this, e) !== false){
21135 this.setChecked(!this.checked);
21140 setChecked : function(state,suppressEvent)
21142 this.startValue = this.getValue();
21144 if(this.inputType == 'radio'){
21146 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21147 e.dom.checked = false;
21150 this.inputEl().dom.checked = true;
21152 this.inputEl().dom.value = this.inputValue;
21154 if(suppressEvent !== true){
21155 this.fireEvent('check', this, true);
21163 this.checked = state;
21165 this.inputEl().dom.checked = state;
21168 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21170 if(suppressEvent !== true){
21171 this.fireEvent('check', this, state);
21177 getValue : function()
21179 if(this.inputType == 'radio'){
21180 return this.getGroupValue();
21183 return this.hiddenEl().dom.value;
21187 getGroupValue : function()
21189 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21193 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21196 setValue : function(v,suppressEvent)
21198 if(this.inputType == 'radio'){
21199 this.setGroupValue(v, suppressEvent);
21203 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21208 setGroupValue : function(v, suppressEvent)
21210 this.startValue = this.getValue();
21212 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21213 e.dom.checked = false;
21215 if(e.dom.value == v){
21216 e.dom.checked = true;
21220 if(suppressEvent !== true){
21221 this.fireEvent('check', this, true);
21229 validate : function()
21231 if(this.getVisibilityEl().hasClass('hidden')){
21237 (this.inputType == 'radio' && this.validateRadio()) ||
21238 (this.inputType == 'checkbox' && this.validateCheckbox())
21244 this.markInvalid();
21248 validateRadio : function()
21250 if(this.getVisibilityEl().hasClass('hidden')){
21254 if(this.allowBlank){
21260 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21261 if(!e.dom.checked){
21273 validateCheckbox : function()
21276 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21277 //return (this.getValue() == this.inputValue) ? true : false;
21280 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21288 for(var i in group){
21289 if(group[i].el.isVisible(true)){
21297 for(var i in group){
21302 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21309 * Mark this field as valid
21311 markValid : function()
21315 this.fireEvent('valid', this);
21317 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21320 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21327 if(this.inputType == 'radio'){
21328 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21329 var fg = e.findParent('.form-group', false, true);
21330 if (Roo.bootstrap.version == 3) {
21331 fg.removeClass([_this.invalidClass, _this.validClass]);
21332 fg.addClass(_this.validClass);
21334 fg.removeClass(['is-valid', 'is-invalid']);
21335 fg.addClass('is-valid');
21343 var fg = this.el.findParent('.form-group', false, true);
21344 if (Roo.bootstrap.version == 3) {
21345 fg.removeClass([this.invalidClass, this.validClass]);
21346 fg.addClass(this.validClass);
21348 fg.removeClass(['is-valid', 'is-invalid']);
21349 fg.addClass('is-valid');
21354 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21360 for(var i in group){
21361 var fg = group[i].el.findParent('.form-group', false, true);
21362 if (Roo.bootstrap.version == 3) {
21363 fg.removeClass([this.invalidClass, this.validClass]);
21364 fg.addClass(this.validClass);
21366 fg.removeClass(['is-valid', 'is-invalid']);
21367 fg.addClass('is-valid');
21373 * Mark this field as invalid
21374 * @param {String} msg The validation message
21376 markInvalid : function(msg)
21378 if(this.allowBlank){
21384 this.fireEvent('invalid', this, msg);
21386 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21389 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21393 label.markInvalid();
21396 if(this.inputType == 'radio'){
21398 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21399 var fg = e.findParent('.form-group', false, true);
21400 if (Roo.bootstrap.version == 3) {
21401 fg.removeClass([_this.invalidClass, _this.validClass]);
21402 fg.addClass(_this.invalidClass);
21404 fg.removeClass(['is-invalid', 'is-valid']);
21405 fg.addClass('is-invalid');
21413 var fg = this.el.findParent('.form-group', false, true);
21414 if (Roo.bootstrap.version == 3) {
21415 fg.removeClass([_this.invalidClass, _this.validClass]);
21416 fg.addClass(_this.invalidClass);
21418 fg.removeClass(['is-invalid', 'is-valid']);
21419 fg.addClass('is-invalid');
21424 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21430 for(var i in group){
21431 var fg = group[i].el.findParent('.form-group', false, true);
21432 if (Roo.bootstrap.version == 3) {
21433 fg.removeClass([_this.invalidClass, _this.validClass]);
21434 fg.addClass(_this.invalidClass);
21436 fg.removeClass(['is-invalid', 'is-valid']);
21437 fg.addClass('is-invalid');
21443 clearInvalid : function()
21445 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21447 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21449 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21451 if (label && label.iconEl) {
21452 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21453 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21457 disable : function()
21459 if(this.inputType != 'radio'){
21460 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21467 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21468 _this.getActionEl().addClass(this.disabledClass);
21469 e.dom.disabled = true;
21473 this.disabled = true;
21474 this.fireEvent("disable", this);
21478 enable : function()
21480 if(this.inputType != 'radio'){
21481 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21488 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21489 _this.getActionEl().removeClass(this.disabledClass);
21490 e.dom.disabled = false;
21494 this.disabled = false;
21495 this.fireEvent("enable", this);
21499 setBoxLabel : function(v)
21504 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21510 Roo.apply(Roo.bootstrap.CheckBox, {
21515 * register a CheckBox Group
21516 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21518 register : function(checkbox)
21520 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21521 this.groups[checkbox.groupId] = {};
21524 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21528 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21532 * fetch a CheckBox Group based on the group ID
21533 * @param {string} the group ID
21534 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21536 get: function(groupId) {
21537 if (typeof(this.groups[groupId]) == 'undefined') {
21541 return this.groups[groupId] ;
21554 * @class Roo.bootstrap.Radio
21555 * @extends Roo.bootstrap.Component
21556 * Bootstrap Radio class
21557 * @cfg {String} boxLabel - the label associated
21558 * @cfg {String} value - the value of radio
21561 * Create a new Radio
21562 * @param {Object} config The config object
21564 Roo.bootstrap.Radio = function(config){
21565 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21569 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21575 getAutoCreate : function()
21579 cls : 'form-group radio',
21584 html : this.boxLabel
21592 initEvents : function()
21594 this.parent().register(this);
21596 this.el.on('click', this.onClick, this);
21600 onClick : function(e)
21602 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21603 this.setChecked(true);
21607 setChecked : function(state, suppressEvent)
21609 this.parent().setValue(this.value, suppressEvent);
21613 setBoxLabel : function(v)
21618 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21633 * @class Roo.bootstrap.SecurePass
21634 * @extends Roo.bootstrap.Input
21635 * Bootstrap SecurePass class
21639 * Create a new SecurePass
21640 * @param {Object} config The config object
21643 Roo.bootstrap.SecurePass = function (config) {
21644 // these go here, so the translation tool can replace them..
21646 PwdEmpty: "Please type a password, and then retype it to confirm.",
21647 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21648 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21649 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21650 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21651 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21652 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21653 TooWeak: "Your password is Too Weak."
21655 this.meterLabel = "Password strength:";
21656 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21657 this.meterClass = [
21658 "roo-password-meter-tooweak",
21659 "roo-password-meter-weak",
21660 "roo-password-meter-medium",
21661 "roo-password-meter-strong",
21662 "roo-password-meter-grey"
21667 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21670 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21672 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21674 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21675 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21676 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21677 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21678 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21679 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21680 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21690 * @cfg {String/Object} Label for the strength meter (defaults to
21691 * 'Password strength:')
21696 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21697 * ['Weak', 'Medium', 'Strong'])
21700 pwdStrengths: false,
21713 initEvents: function ()
21715 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21717 if (this.el.is('input[type=password]') && Roo.isSafari) {
21718 this.el.on('keydown', this.SafariOnKeyDown, this);
21721 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21724 onRender: function (ct, position)
21726 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21727 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21728 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21730 this.trigger.createChild({
21735 cls: 'roo-password-meter-grey col-xs-12',
21738 //width: this.meterWidth + 'px'
21742 cls: 'roo-password-meter-text'
21748 if (this.hideTrigger) {
21749 this.trigger.setDisplayed(false);
21751 this.setSize(this.width || '', this.height || '');
21754 onDestroy: function ()
21756 if (this.trigger) {
21757 this.trigger.removeAllListeners();
21758 this.trigger.remove();
21761 this.wrap.remove();
21763 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21766 checkStrength: function ()
21768 var pwd = this.inputEl().getValue();
21769 if (pwd == this._lastPwd) {
21774 if (this.ClientSideStrongPassword(pwd)) {
21776 } else if (this.ClientSideMediumPassword(pwd)) {
21778 } else if (this.ClientSideWeakPassword(pwd)) {
21784 Roo.log('strength1: ' + strength);
21786 //var pm = this.trigger.child('div/div/div').dom;
21787 var pm = this.trigger.child('div/div');
21788 pm.removeClass(this.meterClass);
21789 pm.addClass(this.meterClass[strength]);
21792 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21794 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21796 this._lastPwd = pwd;
21800 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21802 this._lastPwd = '';
21804 var pm = this.trigger.child('div/div');
21805 pm.removeClass(this.meterClass);
21806 pm.addClass('roo-password-meter-grey');
21809 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21812 this.inputEl().dom.type='password';
21815 validateValue: function (value)
21818 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21821 if (value.length == 0) {
21822 if (this.allowBlank) {
21823 this.clearInvalid();
21827 this.markInvalid(this.errors.PwdEmpty);
21828 this.errorMsg = this.errors.PwdEmpty;
21836 if ('[\x21-\x7e]*'.match(value)) {
21837 this.markInvalid(this.errors.PwdBadChar);
21838 this.errorMsg = this.errors.PwdBadChar;
21841 if (value.length < 6) {
21842 this.markInvalid(this.errors.PwdShort);
21843 this.errorMsg = this.errors.PwdShort;
21846 if (value.length > 16) {
21847 this.markInvalid(this.errors.PwdLong);
21848 this.errorMsg = this.errors.PwdLong;
21852 if (this.ClientSideStrongPassword(value)) {
21854 } else if (this.ClientSideMediumPassword(value)) {
21856 } else if (this.ClientSideWeakPassword(value)) {
21863 if (strength < 2) {
21864 //this.markInvalid(this.errors.TooWeak);
21865 this.errorMsg = this.errors.TooWeak;
21870 console.log('strength2: ' + strength);
21872 //var pm = this.trigger.child('div/div/div').dom;
21874 var pm = this.trigger.child('div/div');
21875 pm.removeClass(this.meterClass);
21876 pm.addClass(this.meterClass[strength]);
21878 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21880 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21882 this.errorMsg = '';
21886 CharacterSetChecks: function (type)
21889 this.fResult = false;
21892 isctype: function (character, type)
21895 case this.kCapitalLetter:
21896 if (character >= 'A' && character <= 'Z') {
21901 case this.kSmallLetter:
21902 if (character >= 'a' && character <= 'z') {
21908 if (character >= '0' && character <= '9') {
21913 case this.kPunctuation:
21914 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21925 IsLongEnough: function (pwd, size)
21927 return !(pwd == null || isNaN(size) || pwd.length < size);
21930 SpansEnoughCharacterSets: function (word, nb)
21932 if (!this.IsLongEnough(word, nb))
21937 var characterSetChecks = new Array(
21938 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21939 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21942 for (var index = 0; index < word.length; ++index) {
21943 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21944 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21945 characterSetChecks[nCharSet].fResult = true;
21952 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21953 if (characterSetChecks[nCharSet].fResult) {
21958 if (nCharSets < nb) {
21964 ClientSideStrongPassword: function (pwd)
21966 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21969 ClientSideMediumPassword: function (pwd)
21971 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21974 ClientSideWeakPassword: function (pwd)
21976 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21979 })//<script type="text/javascript">
21982 * Based Ext JS Library 1.1.1
21983 * Copyright(c) 2006-2007, Ext JS, LLC.
21989 * @class Roo.HtmlEditorCore
21990 * @extends Roo.Component
21991 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21993 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21996 Roo.HtmlEditorCore = function(config){
21999 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
22004 * @event initialize
22005 * Fires when the editor is fully initialized (including the iframe)
22006 * @param {Roo.HtmlEditorCore} this
22011 * Fires when the editor is first receives the focus. Any insertion must wait
22012 * until after this event.
22013 * @param {Roo.HtmlEditorCore} this
22017 * @event beforesync
22018 * Fires before the textarea is updated with content from the editor iframe. Return false
22019 * to cancel the sync.
22020 * @param {Roo.HtmlEditorCore} this
22021 * @param {String} html
22025 * @event beforepush
22026 * Fires before the iframe editor is updated with content from the textarea. Return false
22027 * to cancel the push.
22028 * @param {Roo.HtmlEditorCore} this
22029 * @param {String} html
22034 * Fires when the textarea is updated with content from the editor iframe.
22035 * @param {Roo.HtmlEditorCore} this
22036 * @param {String} html
22041 * Fires when the iframe editor is updated with content from the textarea.
22042 * @param {Roo.HtmlEditorCore} this
22043 * @param {String} html
22048 * @event editorevent
22049 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22050 * @param {Roo.HtmlEditorCore} this
22056 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22058 // defaults : white / black...
22059 this.applyBlacklists();
22066 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22070 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22076 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22081 * @cfg {Number} height (in pixels)
22085 * @cfg {Number} width (in pixels)
22090 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22093 stylesheets: false,
22098 // private properties
22099 validationEvent : false,
22101 initialized : false,
22103 sourceEditMode : false,
22104 onFocus : Roo.emptyFn,
22106 hideMode:'offsets',
22110 // blacklist + whitelisted elements..
22117 * Protected method that will not generally be called directly. It
22118 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22119 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22121 getDocMarkup : function(){
22125 // inherit styels from page...??
22126 if (this.stylesheets === false) {
22128 Roo.get(document.head).select('style').each(function(node) {
22129 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22132 Roo.get(document.head).select('link').each(function(node) {
22133 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22136 } else if (!this.stylesheets.length) {
22138 st = '<style type="text/css">' +
22139 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22142 st = '<style type="text/css">' +
22147 st += '<style type="text/css">' +
22148 'IMG { cursor: pointer } ' +
22151 var cls = 'roo-htmleditor-body';
22153 if(this.bodyCls.length){
22154 cls += ' ' + this.bodyCls;
22157 return '<html><head>' + st +
22158 //<style type="text/css">' +
22159 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22161 ' </head><body class="' + cls + '"></body></html>';
22165 onRender : function(ct, position)
22168 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22169 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22172 this.el.dom.style.border = '0 none';
22173 this.el.dom.setAttribute('tabIndex', -1);
22174 this.el.addClass('x-hidden hide');
22178 if(Roo.isIE){ // fix IE 1px bogus margin
22179 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22183 this.frameId = Roo.id();
22187 var iframe = this.owner.wrap.createChild({
22189 cls: 'form-control', // bootstrap..
22191 name: this.frameId,
22192 frameBorder : 'no',
22193 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22198 this.iframe = iframe.dom;
22200 this.assignDocWin();
22202 this.doc.designMode = 'on';
22205 this.doc.write(this.getDocMarkup());
22209 var task = { // must defer to wait for browser to be ready
22211 //console.log("run task?" + this.doc.readyState);
22212 this.assignDocWin();
22213 if(this.doc.body || this.doc.readyState == 'complete'){
22215 this.doc.designMode="on";
22219 Roo.TaskMgr.stop(task);
22220 this.initEditor.defer(10, this);
22227 Roo.TaskMgr.start(task);
22232 onResize : function(w, h)
22234 Roo.log('resize: ' +w + ',' + h );
22235 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22239 if(typeof w == 'number'){
22241 this.iframe.style.width = w + 'px';
22243 if(typeof h == 'number'){
22245 this.iframe.style.height = h + 'px';
22247 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22254 * Toggles the editor between standard and source edit mode.
22255 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22257 toggleSourceEdit : function(sourceEditMode){
22259 this.sourceEditMode = sourceEditMode === true;
22261 if(this.sourceEditMode){
22263 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22266 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22267 //this.iframe.className = '';
22270 //this.setSize(this.owner.wrap.getSize());
22271 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22278 * Protected method that will not generally be called directly. If you need/want
22279 * custom HTML cleanup, this is the method you should override.
22280 * @param {String} html The HTML to be cleaned
22281 * return {String} The cleaned HTML
22283 cleanHtml : function(html){
22284 html = String(html);
22285 if(html.length > 5){
22286 if(Roo.isSafari){ // strip safari nonsense
22287 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22290 if(html == ' '){
22297 * HTML Editor -> Textarea
22298 * Protected method that will not generally be called directly. Syncs the contents
22299 * of the editor iframe with the textarea.
22301 syncValue : function(){
22302 if(this.initialized){
22303 var bd = (this.doc.body || this.doc.documentElement);
22304 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22305 var html = bd.innerHTML;
22307 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22308 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22310 html = '<div style="'+m[0]+'">' + html + '</div>';
22313 html = this.cleanHtml(html);
22314 // fix up the special chars.. normaly like back quotes in word...
22315 // however we do not want to do this with chinese..
22316 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22317 var cc = b.charCodeAt();
22319 (cc >= 0x4E00 && cc < 0xA000 ) ||
22320 (cc >= 0x3400 && cc < 0x4E00 ) ||
22321 (cc >= 0xf900 && cc < 0xfb00 )
22327 if(this.owner.fireEvent('beforesync', this, html) !== false){
22328 this.el.dom.value = html;
22329 this.owner.fireEvent('sync', this, html);
22335 * Protected method that will not generally be called directly. Pushes the value of the textarea
22336 * into the iframe editor.
22338 pushValue : function(){
22339 if(this.initialized){
22340 var v = this.el.dom.value.trim();
22342 // if(v.length < 1){
22346 if(this.owner.fireEvent('beforepush', this, v) !== false){
22347 var d = (this.doc.body || this.doc.documentElement);
22349 this.cleanUpPaste();
22350 this.el.dom.value = d.innerHTML;
22351 this.owner.fireEvent('push', this, v);
22357 deferFocus : function(){
22358 this.focus.defer(10, this);
22362 focus : function(){
22363 if(this.win && !this.sourceEditMode){
22370 assignDocWin: function()
22372 var iframe = this.iframe;
22375 this.doc = iframe.contentWindow.document;
22376 this.win = iframe.contentWindow;
22378 // if (!Roo.get(this.frameId)) {
22381 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22382 // this.win = Roo.get(this.frameId).dom.contentWindow;
22384 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22388 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22389 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22394 initEditor : function(){
22395 //console.log("INIT EDITOR");
22396 this.assignDocWin();
22400 this.doc.designMode="on";
22402 this.doc.write(this.getDocMarkup());
22405 var dbody = (this.doc.body || this.doc.documentElement);
22406 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22407 // this copies styles from the containing element into thsi one..
22408 // not sure why we need all of this..
22409 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22411 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22412 //ss['background-attachment'] = 'fixed'; // w3c
22413 dbody.bgProperties = 'fixed'; // ie
22414 //Roo.DomHelper.applyStyles(dbody, ss);
22415 Roo.EventManager.on(this.doc, {
22416 //'mousedown': this.onEditorEvent,
22417 'mouseup': this.onEditorEvent,
22418 'dblclick': this.onEditorEvent,
22419 'click': this.onEditorEvent,
22420 'keyup': this.onEditorEvent,
22425 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22427 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22428 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22430 this.initialized = true;
22432 this.owner.fireEvent('initialize', this);
22437 onDestroy : function(){
22443 //for (var i =0; i < this.toolbars.length;i++) {
22444 // // fixme - ask toolbars for heights?
22445 // this.toolbars[i].onDestroy();
22448 //this.wrap.dom.innerHTML = '';
22449 //this.wrap.remove();
22454 onFirstFocus : function(){
22456 this.assignDocWin();
22459 this.activated = true;
22462 if(Roo.isGecko){ // prevent silly gecko errors
22464 var s = this.win.getSelection();
22465 if(!s.focusNode || s.focusNode.nodeType != 3){
22466 var r = s.getRangeAt(0);
22467 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22472 this.execCmd('useCSS', true);
22473 this.execCmd('styleWithCSS', false);
22476 this.owner.fireEvent('activate', this);
22480 adjustFont: function(btn){
22481 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22482 //if(Roo.isSafari){ // safari
22485 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22486 if(Roo.isSafari){ // safari
22487 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22488 v = (v < 10) ? 10 : v;
22489 v = (v > 48) ? 48 : v;
22490 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22495 v = Math.max(1, v+adjust);
22497 this.execCmd('FontSize', v );
22500 onEditorEvent : function(e)
22502 this.owner.fireEvent('editorevent', this, e);
22503 // this.updateToolbar();
22504 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22507 insertTag : function(tg)
22509 // could be a bit smarter... -> wrap the current selected tRoo..
22510 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22512 range = this.createRange(this.getSelection());
22513 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22514 wrappingNode.appendChild(range.extractContents());
22515 range.insertNode(wrappingNode);
22522 this.execCmd("formatblock", tg);
22526 insertText : function(txt)
22530 var range = this.createRange();
22531 range.deleteContents();
22532 //alert(Sender.getAttribute('label'));
22534 range.insertNode(this.doc.createTextNode(txt));
22540 * Executes a Midas editor command on the editor document and performs necessary focus and
22541 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22542 * @param {String} cmd The Midas command
22543 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22545 relayCmd : function(cmd, value){
22547 this.execCmd(cmd, value);
22548 this.owner.fireEvent('editorevent', this);
22549 //this.updateToolbar();
22550 this.owner.deferFocus();
22554 * Executes a Midas editor command directly on the editor document.
22555 * For visual commands, you should use {@link #relayCmd} instead.
22556 * <b>This should only be called after the editor is initialized.</b>
22557 * @param {String} cmd The Midas command
22558 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22560 execCmd : function(cmd, value){
22561 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22568 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22570 * @param {String} text | dom node..
22572 insertAtCursor : function(text)
22575 if(!this.activated){
22581 var r = this.doc.selection.createRange();
22592 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22596 // from jquery ui (MIT licenced)
22598 var win = this.win;
22600 if (win.getSelection && win.getSelection().getRangeAt) {
22601 range = win.getSelection().getRangeAt(0);
22602 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22603 range.insertNode(node);
22604 } else if (win.document.selection && win.document.selection.createRange) {
22605 // no firefox support
22606 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22607 win.document.selection.createRange().pasteHTML(txt);
22609 // no firefox support
22610 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22611 this.execCmd('InsertHTML', txt);
22620 mozKeyPress : function(e){
22622 var c = e.getCharCode(), cmd;
22625 c = String.fromCharCode(c).toLowerCase();
22639 this.cleanUpPaste.defer(100, this);
22647 e.preventDefault();
22655 fixKeys : function(){ // load time branching for fastest keydown performance
22657 return function(e){
22658 var k = e.getKey(), r;
22661 r = this.doc.selection.createRange();
22664 r.pasteHTML('    ');
22671 r = this.doc.selection.createRange();
22673 var target = r.parentElement();
22674 if(!target || target.tagName.toLowerCase() != 'li'){
22676 r.pasteHTML('<br />');
22682 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22683 this.cleanUpPaste.defer(100, this);
22689 }else if(Roo.isOpera){
22690 return function(e){
22691 var k = e.getKey();
22695 this.execCmd('InsertHTML','    ');
22698 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22699 this.cleanUpPaste.defer(100, this);
22704 }else if(Roo.isSafari){
22705 return function(e){
22706 var k = e.getKey();
22710 this.execCmd('InsertText','\t');
22714 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22715 this.cleanUpPaste.defer(100, this);
22723 getAllAncestors: function()
22725 var p = this.getSelectedNode();
22728 a.push(p); // push blank onto stack..
22729 p = this.getParentElement();
22733 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22737 a.push(this.doc.body);
22741 lastSelNode : false,
22744 getSelection : function()
22746 this.assignDocWin();
22747 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22750 getSelectedNode: function()
22752 // this may only work on Gecko!!!
22754 // should we cache this!!!!
22759 var range = this.createRange(this.getSelection()).cloneRange();
22762 var parent = range.parentElement();
22764 var testRange = range.duplicate();
22765 testRange.moveToElementText(parent);
22766 if (testRange.inRange(range)) {
22769 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22772 parent = parent.parentElement;
22777 // is ancestor a text element.
22778 var ac = range.commonAncestorContainer;
22779 if (ac.nodeType == 3) {
22780 ac = ac.parentNode;
22783 var ar = ac.childNodes;
22786 var other_nodes = [];
22787 var has_other_nodes = false;
22788 for (var i=0;i<ar.length;i++) {
22789 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22792 // fullly contained node.
22794 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22799 // probably selected..
22800 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22801 other_nodes.push(ar[i]);
22805 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22810 has_other_nodes = true;
22812 if (!nodes.length && other_nodes.length) {
22813 nodes= other_nodes;
22815 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22821 createRange: function(sel)
22823 // this has strange effects when using with
22824 // top toolbar - not sure if it's a great idea.
22825 //this.editor.contentWindow.focus();
22826 if (typeof sel != "undefined") {
22828 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22830 return this.doc.createRange();
22833 return this.doc.createRange();
22836 getParentElement: function()
22839 this.assignDocWin();
22840 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22842 var range = this.createRange(sel);
22845 var p = range.commonAncestorContainer;
22846 while (p.nodeType == 3) { // text node
22857 * Range intersection.. the hard stuff...
22861 * [ -- selected range --- ]
22865 * if end is before start or hits it. fail.
22866 * if start is after end or hits it fail.
22868 * if either hits (but other is outside. - then it's not
22874 // @see http://www.thismuchiknow.co.uk/?p=64.
22875 rangeIntersectsNode : function(range, node)
22877 var nodeRange = node.ownerDocument.createRange();
22879 nodeRange.selectNode(node);
22881 nodeRange.selectNodeContents(node);
22884 var rangeStartRange = range.cloneRange();
22885 rangeStartRange.collapse(true);
22887 var rangeEndRange = range.cloneRange();
22888 rangeEndRange.collapse(false);
22890 var nodeStartRange = nodeRange.cloneRange();
22891 nodeStartRange.collapse(true);
22893 var nodeEndRange = nodeRange.cloneRange();
22894 nodeEndRange.collapse(false);
22896 return rangeStartRange.compareBoundaryPoints(
22897 Range.START_TO_START, nodeEndRange) == -1 &&
22898 rangeEndRange.compareBoundaryPoints(
22899 Range.START_TO_START, nodeStartRange) == 1;
22903 rangeCompareNode : function(range, node)
22905 var nodeRange = node.ownerDocument.createRange();
22907 nodeRange.selectNode(node);
22909 nodeRange.selectNodeContents(node);
22913 range.collapse(true);
22915 nodeRange.collapse(true);
22917 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22918 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22920 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22922 var nodeIsBefore = ss == 1;
22923 var nodeIsAfter = ee == -1;
22925 if (nodeIsBefore && nodeIsAfter) {
22928 if (!nodeIsBefore && nodeIsAfter) {
22929 return 1; //right trailed.
22932 if (nodeIsBefore && !nodeIsAfter) {
22933 return 2; // left trailed.
22939 // private? - in a new class?
22940 cleanUpPaste : function()
22942 // cleans up the whole document..
22943 Roo.log('cleanuppaste');
22945 this.cleanUpChildren(this.doc.body);
22946 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22947 if (clean != this.doc.body.innerHTML) {
22948 this.doc.body.innerHTML = clean;
22953 cleanWordChars : function(input) {// change the chars to hex code
22954 var he = Roo.HtmlEditorCore;
22956 var output = input;
22957 Roo.each(he.swapCodes, function(sw) {
22958 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22960 output = output.replace(swapper, sw[1]);
22967 cleanUpChildren : function (n)
22969 if (!n.childNodes.length) {
22972 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22973 this.cleanUpChild(n.childNodes[i]);
22980 cleanUpChild : function (node)
22983 //console.log(node);
22984 if (node.nodeName == "#text") {
22985 // clean up silly Windows -- stuff?
22988 if (node.nodeName == "#comment") {
22989 node.parentNode.removeChild(node);
22990 // clean up silly Windows -- stuff?
22993 var lcname = node.tagName.toLowerCase();
22994 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22995 // whitelist of tags..
22997 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22999 node.parentNode.removeChild(node);
23004 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
23006 // remove <a name=....> as rendering on yahoo mailer is borked with this.
23007 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
23009 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
23010 // remove_keep_children = true;
23013 if (remove_keep_children) {
23014 this.cleanUpChildren(node);
23015 // inserts everything just before this node...
23016 while (node.childNodes.length) {
23017 var cn = node.childNodes[0];
23018 node.removeChild(cn);
23019 node.parentNode.insertBefore(cn, node);
23021 node.parentNode.removeChild(node);
23025 if (!node.attributes || !node.attributes.length) {
23026 this.cleanUpChildren(node);
23030 function cleanAttr(n,v)
23033 if (v.match(/^\./) || v.match(/^\//)) {
23036 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
23039 if (v.match(/^#/)) {
23042 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
23043 node.removeAttribute(n);
23047 var cwhite = this.cwhite;
23048 var cblack = this.cblack;
23050 function cleanStyle(n,v)
23052 if (v.match(/expression/)) { //XSS?? should we even bother..
23053 node.removeAttribute(n);
23057 var parts = v.split(/;/);
23060 Roo.each(parts, function(p) {
23061 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23065 var l = p.split(':').shift().replace(/\s+/g,'');
23066 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23068 if ( cwhite.length && cblack.indexOf(l) > -1) {
23069 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23070 //node.removeAttribute(n);
23074 // only allow 'c whitelisted system attributes'
23075 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23076 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23077 //node.removeAttribute(n);
23087 if (clean.length) {
23088 node.setAttribute(n, clean.join(';'));
23090 node.removeAttribute(n);
23096 for (var i = node.attributes.length-1; i > -1 ; i--) {
23097 var a = node.attributes[i];
23100 if (a.name.toLowerCase().substr(0,2)=='on') {
23101 node.removeAttribute(a.name);
23104 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23105 node.removeAttribute(a.name);
23108 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23109 cleanAttr(a.name,a.value); // fixme..
23112 if (a.name == 'style') {
23113 cleanStyle(a.name,a.value);
23116 /// clean up MS crap..
23117 // tecnically this should be a list of valid class'es..
23120 if (a.name == 'class') {
23121 if (a.value.match(/^Mso/)) {
23122 node.className = '';
23125 if (a.value.match(/^body$/)) {
23126 node.className = '';
23137 this.cleanUpChildren(node);
23143 * Clean up MS wordisms...
23145 cleanWord : function(node)
23150 this.cleanWord(this.doc.body);
23153 if (node.nodeName == "#text") {
23154 // clean up silly Windows -- stuff?
23157 if (node.nodeName == "#comment") {
23158 node.parentNode.removeChild(node);
23159 // clean up silly Windows -- stuff?
23163 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23164 node.parentNode.removeChild(node);
23168 // remove - but keep children..
23169 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23170 while (node.childNodes.length) {
23171 var cn = node.childNodes[0];
23172 node.removeChild(cn);
23173 node.parentNode.insertBefore(cn, node);
23175 node.parentNode.removeChild(node);
23176 this.iterateChildren(node, this.cleanWord);
23180 if (node.className.length) {
23182 var cn = node.className.split(/\W+/);
23184 Roo.each(cn, function(cls) {
23185 if (cls.match(/Mso[a-zA-Z]+/)) {
23190 node.className = cna.length ? cna.join(' ') : '';
23192 node.removeAttribute("class");
23196 if (node.hasAttribute("lang")) {
23197 node.removeAttribute("lang");
23200 if (node.hasAttribute("style")) {
23202 var styles = node.getAttribute("style").split(";");
23204 Roo.each(styles, function(s) {
23205 if (!s.match(/:/)) {
23208 var kv = s.split(":");
23209 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23212 // what ever is left... we allow.
23215 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23216 if (!nstyle.length) {
23217 node.removeAttribute('style');
23220 this.iterateChildren(node, this.cleanWord);
23226 * iterateChildren of a Node, calling fn each time, using this as the scole..
23227 * @param {DomNode} node node to iterate children of.
23228 * @param {Function} fn method of this class to call on each item.
23230 iterateChildren : function(node, fn)
23232 if (!node.childNodes.length) {
23235 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23236 fn.call(this, node.childNodes[i])
23242 * cleanTableWidths.
23244 * Quite often pasting from word etc.. results in tables with column and widths.
23245 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23248 cleanTableWidths : function(node)
23253 this.cleanTableWidths(this.doc.body);
23258 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23261 Roo.log(node.tagName);
23262 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23263 this.iterateChildren(node, this.cleanTableWidths);
23266 if (node.hasAttribute('width')) {
23267 node.removeAttribute('width');
23271 if (node.hasAttribute("style")) {
23274 var styles = node.getAttribute("style").split(";");
23276 Roo.each(styles, function(s) {
23277 if (!s.match(/:/)) {
23280 var kv = s.split(":");
23281 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23284 // what ever is left... we allow.
23287 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23288 if (!nstyle.length) {
23289 node.removeAttribute('style');
23293 this.iterateChildren(node, this.cleanTableWidths);
23301 domToHTML : function(currentElement, depth, nopadtext) {
23303 depth = depth || 0;
23304 nopadtext = nopadtext || false;
23306 if (!currentElement) {
23307 return this.domToHTML(this.doc.body);
23310 //Roo.log(currentElement);
23312 var allText = false;
23313 var nodeName = currentElement.nodeName;
23314 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23316 if (nodeName == '#text') {
23318 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23323 if (nodeName != 'BODY') {
23326 // Prints the node tagName, such as <A>, <IMG>, etc
23329 for(i = 0; i < currentElement.attributes.length;i++) {
23331 var aname = currentElement.attributes.item(i).name;
23332 if (!currentElement.attributes.item(i).value.length) {
23335 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23338 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23347 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23350 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23355 // Traverse the tree
23357 var currentElementChild = currentElement.childNodes.item(i);
23358 var allText = true;
23359 var innerHTML = '';
23361 while (currentElementChild) {
23362 // Formatting code (indent the tree so it looks nice on the screen)
23363 var nopad = nopadtext;
23364 if (lastnode == 'SPAN') {
23368 if (currentElementChild.nodeName == '#text') {
23369 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23370 toadd = nopadtext ? toadd : toadd.trim();
23371 if (!nopad && toadd.length > 80) {
23372 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23374 innerHTML += toadd;
23377 currentElementChild = currentElement.childNodes.item(i);
23383 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23385 // Recursively traverse the tree structure of the child node
23386 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23387 lastnode = currentElementChild.nodeName;
23389 currentElementChild=currentElement.childNodes.item(i);
23395 // The remaining code is mostly for formatting the tree
23396 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23401 ret+= "</"+tagName+">";
23407 applyBlacklists : function()
23409 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23410 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23414 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23415 if (b.indexOf(tag) > -1) {
23418 this.white.push(tag);
23422 Roo.each(w, function(tag) {
23423 if (b.indexOf(tag) > -1) {
23426 if (this.white.indexOf(tag) > -1) {
23429 this.white.push(tag);
23434 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23435 if (w.indexOf(tag) > -1) {
23438 this.black.push(tag);
23442 Roo.each(b, function(tag) {
23443 if (w.indexOf(tag) > -1) {
23446 if (this.black.indexOf(tag) > -1) {
23449 this.black.push(tag);
23454 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23455 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23459 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23460 if (b.indexOf(tag) > -1) {
23463 this.cwhite.push(tag);
23467 Roo.each(w, function(tag) {
23468 if (b.indexOf(tag) > -1) {
23471 if (this.cwhite.indexOf(tag) > -1) {
23474 this.cwhite.push(tag);
23479 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23480 if (w.indexOf(tag) > -1) {
23483 this.cblack.push(tag);
23487 Roo.each(b, function(tag) {
23488 if (w.indexOf(tag) > -1) {
23491 if (this.cblack.indexOf(tag) > -1) {
23494 this.cblack.push(tag);
23499 setStylesheets : function(stylesheets)
23501 if(typeof(stylesheets) == 'string'){
23502 Roo.get(this.iframe.contentDocument.head).createChild({
23504 rel : 'stylesheet',
23513 Roo.each(stylesheets, function(s) {
23518 Roo.get(_this.iframe.contentDocument.head).createChild({
23520 rel : 'stylesheet',
23529 removeStylesheets : function()
23533 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23538 setStyle : function(style)
23540 Roo.get(this.iframe.contentDocument.head).createChild({
23549 // hide stuff that is not compatible
23563 * @event specialkey
23567 * @cfg {String} fieldClass @hide
23570 * @cfg {String} focusClass @hide
23573 * @cfg {String} autoCreate @hide
23576 * @cfg {String} inputType @hide
23579 * @cfg {String} invalidClass @hide
23582 * @cfg {String} invalidText @hide
23585 * @cfg {String} msgFx @hide
23588 * @cfg {String} validateOnBlur @hide
23592 Roo.HtmlEditorCore.white = [
23593 'area', 'br', 'img', 'input', 'hr', 'wbr',
23595 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23596 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23597 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23598 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23599 'table', 'ul', 'xmp',
23601 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23604 'dir', 'menu', 'ol', 'ul', 'dl',
23610 Roo.HtmlEditorCore.black = [
23611 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23613 'base', 'basefont', 'bgsound', 'blink', 'body',
23614 'frame', 'frameset', 'head', 'html', 'ilayer',
23615 'iframe', 'layer', 'link', 'meta', 'object',
23616 'script', 'style' ,'title', 'xml' // clean later..
23618 Roo.HtmlEditorCore.clean = [
23619 'script', 'style', 'title', 'xml'
23621 Roo.HtmlEditorCore.remove = [
23626 Roo.HtmlEditorCore.ablack = [
23630 Roo.HtmlEditorCore.aclean = [
23631 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23635 Roo.HtmlEditorCore.pwhite= [
23636 'http', 'https', 'mailto'
23639 // white listed style attributes.
23640 Roo.HtmlEditorCore.cwhite= [
23641 // 'text-align', /// default is to allow most things..
23647 // black listed style attributes.
23648 Roo.HtmlEditorCore.cblack= [
23649 // 'font-size' -- this can be set by the project
23653 Roo.HtmlEditorCore.swapCodes =[
23672 * @class Roo.bootstrap.HtmlEditor
23673 * @extends Roo.bootstrap.TextArea
23674 * Bootstrap HtmlEditor class
23677 * Create a new HtmlEditor
23678 * @param {Object} config The config object
23681 Roo.bootstrap.HtmlEditor = function(config){
23682 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23683 if (!this.toolbars) {
23684 this.toolbars = [];
23687 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23690 * @event initialize
23691 * Fires when the editor is fully initialized (including the iframe)
23692 * @param {HtmlEditor} this
23697 * Fires when the editor is first receives the focus. Any insertion must wait
23698 * until after this event.
23699 * @param {HtmlEditor} this
23703 * @event beforesync
23704 * Fires before the textarea is updated with content from the editor iframe. Return false
23705 * to cancel the sync.
23706 * @param {HtmlEditor} this
23707 * @param {String} html
23711 * @event beforepush
23712 * Fires before the iframe editor is updated with content from the textarea. Return false
23713 * to cancel the push.
23714 * @param {HtmlEditor} this
23715 * @param {String} html
23720 * Fires when the textarea is updated with content from the editor iframe.
23721 * @param {HtmlEditor} this
23722 * @param {String} html
23727 * Fires when the iframe editor is updated with content from the textarea.
23728 * @param {HtmlEditor} this
23729 * @param {String} html
23733 * @event editmodechange
23734 * Fires when the editor switches edit modes
23735 * @param {HtmlEditor} this
23736 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23738 editmodechange: true,
23740 * @event editorevent
23741 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23742 * @param {HtmlEditor} this
23746 * @event firstfocus
23747 * Fires when on first focus - needed by toolbars..
23748 * @param {HtmlEditor} this
23753 * Auto save the htmlEditor value as a file into Events
23754 * @param {HtmlEditor} this
23758 * @event savedpreview
23759 * preview the saved version of htmlEditor
23760 * @param {HtmlEditor} this
23767 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23771 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23776 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23781 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23786 * @cfg {Number} height (in pixels)
23790 * @cfg {Number} width (in pixels)
23795 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23798 stylesheets: false,
23803 // private properties
23804 validationEvent : false,
23806 initialized : false,
23809 onFocus : Roo.emptyFn,
23811 hideMode:'offsets',
23813 tbContainer : false,
23817 toolbarContainer :function() {
23818 return this.wrap.select('.x-html-editor-tb',true).first();
23822 * Protected method that will not generally be called directly. It
23823 * is called when the editor creates its toolbar. Override this method if you need to
23824 * add custom toolbar buttons.
23825 * @param {HtmlEditor} editor
23827 createToolbar : function(){
23828 Roo.log('renewing');
23829 Roo.log("create toolbars");
23831 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23832 this.toolbars[0].render(this.toolbarContainer());
23836 // if (!editor.toolbars || !editor.toolbars.length) {
23837 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23840 // for (var i =0 ; i < editor.toolbars.length;i++) {
23841 // editor.toolbars[i] = Roo.factory(
23842 // typeof(editor.toolbars[i]) == 'string' ?
23843 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23844 // Roo.bootstrap.HtmlEditor);
23845 // editor.toolbars[i].init(editor);
23851 onRender : function(ct, position)
23853 // Roo.log("Call onRender: " + this.xtype);
23855 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23857 this.wrap = this.inputEl().wrap({
23858 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23861 this.editorcore.onRender(ct, position);
23863 if (this.resizable) {
23864 this.resizeEl = new Roo.Resizable(this.wrap, {
23868 minHeight : this.height,
23869 height: this.height,
23870 handles : this.resizable,
23873 resize : function(r, w, h) {
23874 _t.onResize(w,h); // -something
23880 this.createToolbar(this);
23883 if(!this.width && this.resizable){
23884 this.setSize(this.wrap.getSize());
23886 if (this.resizeEl) {
23887 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23888 // should trigger onReize..
23894 onResize : function(w, h)
23896 Roo.log('resize: ' +w + ',' + h );
23897 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23901 if(this.inputEl() ){
23902 if(typeof w == 'number'){
23903 var aw = w - this.wrap.getFrameWidth('lr');
23904 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23907 if(typeof h == 'number'){
23908 var tbh = -11; // fixme it needs to tool bar size!
23909 for (var i =0; i < this.toolbars.length;i++) {
23910 // fixme - ask toolbars for heights?
23911 tbh += this.toolbars[i].el.getHeight();
23912 //if (this.toolbars[i].footer) {
23913 // tbh += this.toolbars[i].footer.el.getHeight();
23921 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23922 ah -= 5; // knock a few pixes off for look..
23923 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23927 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23928 this.editorcore.onResize(ew,eh);
23933 * Toggles the editor between standard and source edit mode.
23934 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23936 toggleSourceEdit : function(sourceEditMode)
23938 this.editorcore.toggleSourceEdit(sourceEditMode);
23940 if(this.editorcore.sourceEditMode){
23941 Roo.log('editor - showing textarea');
23944 // Roo.log(this.syncValue());
23946 this.inputEl().removeClass(['hide', 'x-hidden']);
23947 this.inputEl().dom.removeAttribute('tabIndex');
23948 this.inputEl().focus();
23950 Roo.log('editor - hiding textarea');
23952 // Roo.log(this.pushValue());
23955 this.inputEl().addClass(['hide', 'x-hidden']);
23956 this.inputEl().dom.setAttribute('tabIndex', -1);
23957 //this.deferFocus();
23960 if(this.resizable){
23961 this.setSize(this.wrap.getSize());
23964 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23967 // private (for BoxComponent)
23968 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23970 // private (for BoxComponent)
23971 getResizeEl : function(){
23975 // private (for BoxComponent)
23976 getPositionEl : function(){
23981 initEvents : function(){
23982 this.originalValue = this.getValue();
23986 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23989 // markInvalid : Roo.emptyFn,
23991 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23994 // clearInvalid : Roo.emptyFn,
23996 setValue : function(v){
23997 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23998 this.editorcore.pushValue();
24003 deferFocus : function(){
24004 this.focus.defer(10, this);
24008 focus : function(){
24009 this.editorcore.focus();
24015 onDestroy : function(){
24021 for (var i =0; i < this.toolbars.length;i++) {
24022 // fixme - ask toolbars for heights?
24023 this.toolbars[i].onDestroy();
24026 this.wrap.dom.innerHTML = '';
24027 this.wrap.remove();
24032 onFirstFocus : function(){
24033 //Roo.log("onFirstFocus");
24034 this.editorcore.onFirstFocus();
24035 for (var i =0; i < this.toolbars.length;i++) {
24036 this.toolbars[i].onFirstFocus();
24042 syncValue : function()
24044 this.editorcore.syncValue();
24047 pushValue : function()
24049 this.editorcore.pushValue();
24053 // hide stuff that is not compatible
24067 * @event specialkey
24071 * @cfg {String} fieldClass @hide
24074 * @cfg {String} focusClass @hide
24077 * @cfg {String} autoCreate @hide
24080 * @cfg {String} inputType @hide
24084 * @cfg {String} invalidText @hide
24087 * @cfg {String} msgFx @hide
24090 * @cfg {String} validateOnBlur @hide
24099 Roo.namespace('Roo.bootstrap.htmleditor');
24101 * @class Roo.bootstrap.HtmlEditorToolbar1
24107 new Roo.bootstrap.HtmlEditor({
24110 new Roo.bootstrap.HtmlEditorToolbar1({
24111 disable : { fonts: 1 , format: 1, ..., ... , ...],
24117 * @cfg {Object} disable List of elements to disable..
24118 * @cfg {Array} btns List of additional buttons.
24122 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24125 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24128 Roo.apply(this, config);
24130 // default disabled, based on 'good practice'..
24131 this.disable = this.disable || {};
24132 Roo.applyIf(this.disable, {
24135 specialElements : true
24137 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24139 this.editor = config.editor;
24140 this.editorcore = config.editor.editorcore;
24142 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24144 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24145 // dont call parent... till later.
24147 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24152 editorcore : false,
24157 "h1","h2","h3","h4","h5","h6",
24159 "abbr", "acronym", "address", "cite", "samp", "var",
24163 onRender : function(ct, position)
24165 // Roo.log("Call onRender: " + this.xtype);
24167 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24169 this.el.dom.style.marginBottom = '0';
24171 var editorcore = this.editorcore;
24172 var editor= this.editor;
24175 var btn = function(id,cmd , toggle, handler, html){
24177 var event = toggle ? 'toggle' : 'click';
24182 xns: Roo.bootstrap,
24186 enableToggle:toggle !== false,
24188 pressed : toggle ? false : null,
24191 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24192 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24198 // var cb_box = function...
24203 xns: Roo.bootstrap,
24208 xns: Roo.bootstrap,
24212 Roo.each(this.formats, function(f) {
24213 style.menu.items.push({
24215 xns: Roo.bootstrap,
24216 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24221 editorcore.insertTag(this.tagname);
24228 children.push(style);
24230 btn('bold',false,true);
24231 btn('italic',false,true);
24232 btn('align-left', 'justifyleft',true);
24233 btn('align-center', 'justifycenter',true);
24234 btn('align-right' , 'justifyright',true);
24235 btn('link', false, false, function(btn) {
24236 //Roo.log("create link?");
24237 var url = prompt(this.createLinkText, this.defaultLinkValue);
24238 if(url && url != 'http:/'+'/'){
24239 this.editorcore.relayCmd('createlink', url);
24242 btn('list','insertunorderedlist',true);
24243 btn('pencil', false,true, function(btn){
24245 this.toggleSourceEdit(btn.pressed);
24248 if (this.editor.btns.length > 0) {
24249 for (var i = 0; i<this.editor.btns.length; i++) {
24250 children.push(this.editor.btns[i]);
24258 xns: Roo.bootstrap,
24263 xns: Roo.bootstrap,
24268 cog.menu.items.push({
24270 xns: Roo.bootstrap,
24271 html : Clean styles,
24276 editorcore.insertTag(this.tagname);
24285 this.xtype = 'NavSimplebar';
24287 for(var i=0;i< children.length;i++) {
24289 this.buttons.add(this.addxtypeChild(children[i]));
24293 editor.on('editorevent', this.updateToolbar, this);
24295 onBtnClick : function(id)
24297 this.editorcore.relayCmd(id);
24298 this.editorcore.focus();
24302 * Protected method that will not generally be called directly. It triggers
24303 * a toolbar update by reading the markup state of the current selection in the editor.
24305 updateToolbar: function(){
24307 if(!this.editorcore.activated){
24308 this.editor.onFirstFocus(); // is this neeed?
24312 var btns = this.buttons;
24313 var doc = this.editorcore.doc;
24314 btns.get('bold').setActive(doc.queryCommandState('bold'));
24315 btns.get('italic').setActive(doc.queryCommandState('italic'));
24316 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24318 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24319 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24320 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24322 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24323 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24326 var ans = this.editorcore.getAllAncestors();
24327 if (this.formatCombo) {
24330 var store = this.formatCombo.store;
24331 this.formatCombo.setValue("");
24332 for (var i =0; i < ans.length;i++) {
24333 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24335 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24343 // hides menus... - so this cant be on a menu...
24344 Roo.bootstrap.MenuMgr.hideAll();
24346 Roo.bootstrap.MenuMgr.hideAll();
24347 //this.editorsyncValue();
24349 onFirstFocus: function() {
24350 this.buttons.each(function(item){
24354 toggleSourceEdit : function(sourceEditMode){
24357 if(sourceEditMode){
24358 Roo.log("disabling buttons");
24359 this.buttons.each( function(item){
24360 if(item.cmd != 'pencil'){
24366 Roo.log("enabling buttons");
24367 if(this.editorcore.initialized){
24368 this.buttons.each( function(item){
24374 Roo.log("calling toggole on editor");
24375 // tell the editor that it's been pressed..
24376 this.editor.toggleSourceEdit(sourceEditMode);
24386 * @class Roo.bootstrap.Table.AbstractSelectionModel
24387 * @extends Roo.util.Observable
24388 * Abstract base class for grid SelectionModels. It provides the interface that should be
24389 * implemented by descendant classes. This class should not be directly instantiated.
24392 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24393 this.locked = false;
24394 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24398 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24399 /** @ignore Called by the grid automatically. Do not call directly. */
24400 init : function(grid){
24406 * Locks the selections.
24409 this.locked = true;
24413 * Unlocks the selections.
24415 unlock : function(){
24416 this.locked = false;
24420 * Returns true if the selections are locked.
24421 * @return {Boolean}
24423 isLocked : function(){
24424 return this.locked;
24428 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24429 * @class Roo.bootstrap.Table.RowSelectionModel
24430 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24431 * It supports multiple selections and keyboard selection/navigation.
24433 * @param {Object} config
24436 Roo.bootstrap.Table.RowSelectionModel = function(config){
24437 Roo.apply(this, config);
24438 this.selections = new Roo.util.MixedCollection(false, function(o){
24443 this.lastActive = false;
24447 * @event selectionchange
24448 * Fires when the selection changes
24449 * @param {SelectionModel} this
24451 "selectionchange" : true,
24453 * @event afterselectionchange
24454 * Fires after the selection changes (eg. by key press or clicking)
24455 * @param {SelectionModel} this
24457 "afterselectionchange" : true,
24459 * @event beforerowselect
24460 * Fires when a row is selected being selected, return false to cancel.
24461 * @param {SelectionModel} this
24462 * @param {Number} rowIndex The selected index
24463 * @param {Boolean} keepExisting False if other selections will be cleared
24465 "beforerowselect" : true,
24468 * Fires when a row is selected.
24469 * @param {SelectionModel} this
24470 * @param {Number} rowIndex The selected index
24471 * @param {Roo.data.Record} r The record
24473 "rowselect" : true,
24475 * @event rowdeselect
24476 * Fires when a row is deselected.
24477 * @param {SelectionModel} this
24478 * @param {Number} rowIndex The selected index
24480 "rowdeselect" : true
24482 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24483 this.locked = false;
24486 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24488 * @cfg {Boolean} singleSelect
24489 * True to allow selection of only one row at a time (defaults to false)
24491 singleSelect : false,
24494 initEvents : function()
24497 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24498 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24499 //}else{ // allow click to work like normal
24500 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24502 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24503 this.grid.on("rowclick", this.handleMouseDown, this);
24505 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24506 "up" : function(e){
24508 this.selectPrevious(e.shiftKey);
24509 }else if(this.last !== false && this.lastActive !== false){
24510 var last = this.last;
24511 this.selectRange(this.last, this.lastActive-1);
24512 this.grid.getView().focusRow(this.lastActive);
24513 if(last !== false){
24517 this.selectFirstRow();
24519 this.fireEvent("afterselectionchange", this);
24521 "down" : function(e){
24523 this.selectNext(e.shiftKey);
24524 }else if(this.last !== false && this.lastActive !== false){
24525 var last = this.last;
24526 this.selectRange(this.last, this.lastActive+1);
24527 this.grid.getView().focusRow(this.lastActive);
24528 if(last !== false){
24532 this.selectFirstRow();
24534 this.fireEvent("afterselectionchange", this);
24538 this.grid.store.on('load', function(){
24539 this.selections.clear();
24542 var view = this.grid.view;
24543 view.on("refresh", this.onRefresh, this);
24544 view.on("rowupdated", this.onRowUpdated, this);
24545 view.on("rowremoved", this.onRemove, this);
24550 onRefresh : function()
24552 var ds = this.grid.store, i, v = this.grid.view;
24553 var s = this.selections;
24554 s.each(function(r){
24555 if((i = ds.indexOfId(r.id)) != -1){
24564 onRemove : function(v, index, r){
24565 this.selections.remove(r);
24569 onRowUpdated : function(v, index, r){
24570 if(this.isSelected(r)){
24571 v.onRowSelect(index);
24577 * @param {Array} records The records to select
24578 * @param {Boolean} keepExisting (optional) True to keep existing selections
24580 selectRecords : function(records, keepExisting)
24583 this.clearSelections();
24585 var ds = this.grid.store;
24586 for(var i = 0, len = records.length; i < len; i++){
24587 this.selectRow(ds.indexOf(records[i]), true);
24592 * Gets the number of selected rows.
24595 getCount : function(){
24596 return this.selections.length;
24600 * Selects the first row in the grid.
24602 selectFirstRow : function(){
24607 * Select the last row.
24608 * @param {Boolean} keepExisting (optional) True to keep existing selections
24610 selectLastRow : function(keepExisting){
24611 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24612 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24616 * Selects the row immediately following the last selected row.
24617 * @param {Boolean} keepExisting (optional) True to keep existing selections
24619 selectNext : function(keepExisting)
24621 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24622 this.selectRow(this.last+1, keepExisting);
24623 this.grid.getView().focusRow(this.last);
24628 * Selects the row that precedes the last selected row.
24629 * @param {Boolean} keepExisting (optional) True to keep existing selections
24631 selectPrevious : function(keepExisting){
24633 this.selectRow(this.last-1, keepExisting);
24634 this.grid.getView().focusRow(this.last);
24639 * Returns the selected records
24640 * @return {Array} Array of selected records
24642 getSelections : function(){
24643 return [].concat(this.selections.items);
24647 * Returns the first selected record.
24650 getSelected : function(){
24651 return this.selections.itemAt(0);
24656 * Clears all selections.
24658 clearSelections : function(fast)
24664 var ds = this.grid.store;
24665 var s = this.selections;
24666 s.each(function(r){
24667 this.deselectRow(ds.indexOfId(r.id));
24671 this.selections.clear();
24678 * Selects all rows.
24680 selectAll : function(){
24684 this.selections.clear();
24685 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24686 this.selectRow(i, true);
24691 * Returns True if there is a selection.
24692 * @return {Boolean}
24694 hasSelection : function(){
24695 return this.selections.length > 0;
24699 * Returns True if the specified row is selected.
24700 * @param {Number/Record} record The record or index of the record to check
24701 * @return {Boolean}
24703 isSelected : function(index){
24704 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24705 return (r && this.selections.key(r.id) ? true : false);
24709 * Returns True if the specified record id is selected.
24710 * @param {String} id The id of record to check
24711 * @return {Boolean}
24713 isIdSelected : function(id){
24714 return (this.selections.key(id) ? true : false);
24719 handleMouseDBClick : function(e, t){
24723 handleMouseDown : function(e, t)
24725 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24726 if(this.isLocked() || rowIndex < 0 ){
24729 if(e.shiftKey && this.last !== false){
24730 var last = this.last;
24731 this.selectRange(last, rowIndex, e.ctrlKey);
24732 this.last = last; // reset the last
24736 var isSelected = this.isSelected(rowIndex);
24737 //Roo.log("select row:" + rowIndex);
24739 this.deselectRow(rowIndex);
24741 this.selectRow(rowIndex, true);
24745 if(e.button !== 0 && isSelected){
24746 alert('rowIndex 2: ' + rowIndex);
24747 view.focusRow(rowIndex);
24748 }else if(e.ctrlKey && isSelected){
24749 this.deselectRow(rowIndex);
24750 }else if(!isSelected){
24751 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24752 view.focusRow(rowIndex);
24756 this.fireEvent("afterselectionchange", this);
24759 handleDragableRowClick : function(grid, rowIndex, e)
24761 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24762 this.selectRow(rowIndex, false);
24763 grid.view.focusRow(rowIndex);
24764 this.fireEvent("afterselectionchange", this);
24769 * Selects multiple rows.
24770 * @param {Array} rows Array of the indexes of the row to select
24771 * @param {Boolean} keepExisting (optional) True to keep existing selections
24773 selectRows : function(rows, keepExisting){
24775 this.clearSelections();
24777 for(var i = 0, len = rows.length; i < len; i++){
24778 this.selectRow(rows[i], true);
24783 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24784 * @param {Number} startRow The index of the first row in the range
24785 * @param {Number} endRow The index of the last row in the range
24786 * @param {Boolean} keepExisting (optional) True to retain existing selections
24788 selectRange : function(startRow, endRow, keepExisting){
24793 this.clearSelections();
24795 if(startRow <= endRow){
24796 for(var i = startRow; i <= endRow; i++){
24797 this.selectRow(i, true);
24800 for(var i = startRow; i >= endRow; i--){
24801 this.selectRow(i, true);
24807 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24808 * @param {Number} startRow The index of the first row in the range
24809 * @param {Number} endRow The index of the last row in the range
24811 deselectRange : function(startRow, endRow, preventViewNotify){
24815 for(var i = startRow; i <= endRow; i++){
24816 this.deselectRow(i, preventViewNotify);
24822 * @param {Number} row The index of the row to select
24823 * @param {Boolean} keepExisting (optional) True to keep existing selections
24825 selectRow : function(index, keepExisting, preventViewNotify)
24827 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24830 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24831 if(!keepExisting || this.singleSelect){
24832 this.clearSelections();
24835 var r = this.grid.store.getAt(index);
24836 //console.log('selectRow - record id :' + r.id);
24838 this.selections.add(r);
24839 this.last = this.lastActive = index;
24840 if(!preventViewNotify){
24841 var proxy = new Roo.Element(
24842 this.grid.getRowDom(index)
24844 proxy.addClass('bg-info info');
24846 this.fireEvent("rowselect", this, index, r);
24847 this.fireEvent("selectionchange", this);
24853 * @param {Number} row The index of the row to deselect
24855 deselectRow : function(index, preventViewNotify)
24860 if(this.last == index){
24863 if(this.lastActive == index){
24864 this.lastActive = false;
24867 var r = this.grid.store.getAt(index);
24872 this.selections.remove(r);
24873 //.console.log('deselectRow - record id :' + r.id);
24874 if(!preventViewNotify){
24876 var proxy = new Roo.Element(
24877 this.grid.getRowDom(index)
24879 proxy.removeClass('bg-info info');
24881 this.fireEvent("rowdeselect", this, index);
24882 this.fireEvent("selectionchange", this);
24886 restoreLast : function(){
24888 this.last = this._last;
24893 acceptsNav : function(row, col, cm){
24894 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24898 onEditorKey : function(field, e){
24899 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24904 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24906 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24908 }else if(k == e.ENTER && !e.ctrlKey){
24912 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24914 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24916 }else if(k == e.ESC){
24920 g.startEditing(newCell[0], newCell[1]);
24926 * Ext JS Library 1.1.1
24927 * Copyright(c) 2006-2007, Ext JS, LLC.
24929 * Originally Released Under LGPL - original licence link has changed is not relivant.
24932 * <script type="text/javascript">
24936 * @class Roo.bootstrap.PagingToolbar
24937 * @extends Roo.bootstrap.NavSimplebar
24938 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24940 * Create a new PagingToolbar
24941 * @param {Object} config The config object
24942 * @param {Roo.data.Store} store
24944 Roo.bootstrap.PagingToolbar = function(config)
24946 // old args format still supported... - xtype is prefered..
24947 // created from xtype...
24949 this.ds = config.dataSource;
24951 if (config.store && !this.ds) {
24952 this.store= Roo.factory(config.store, Roo.data);
24953 this.ds = this.store;
24954 this.ds.xmodule = this.xmodule || false;
24957 this.toolbarItems = [];
24958 if (config.items) {
24959 this.toolbarItems = config.items;
24962 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24967 this.bind(this.ds);
24970 if (Roo.bootstrap.version == 4) {
24971 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24973 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24978 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24980 * @cfg {Roo.data.Store} dataSource
24981 * The underlying data store providing the paged data
24984 * @cfg {String/HTMLElement/Element} container
24985 * container The id or element that will contain the toolbar
24988 * @cfg {Boolean} displayInfo
24989 * True to display the displayMsg (defaults to false)
24992 * @cfg {Number} pageSize
24993 * The number of records to display per page (defaults to 20)
24997 * @cfg {String} displayMsg
24998 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
25000 displayMsg : 'Displaying {0} - {1} of {2}',
25002 * @cfg {String} emptyMsg
25003 * The message to display when no records are found (defaults to "No data to display")
25005 emptyMsg : 'No data to display',
25007 * Customizable piece of the default paging text (defaults to "Page")
25010 beforePageText : "Page",
25012 * Customizable piece of the default paging text (defaults to "of %0")
25015 afterPageText : "of {0}",
25017 * Customizable piece of the default paging text (defaults to "First Page")
25020 firstText : "First Page",
25022 * Customizable piece of the default paging text (defaults to "Previous Page")
25025 prevText : "Previous Page",
25027 * Customizable piece of the default paging text (defaults to "Next Page")
25030 nextText : "Next Page",
25032 * Customizable piece of the default paging text (defaults to "Last Page")
25035 lastText : "Last Page",
25037 * Customizable piece of the default paging text (defaults to "Refresh")
25040 refreshText : "Refresh",
25044 onRender : function(ct, position)
25046 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
25047 this.navgroup.parentId = this.id;
25048 this.navgroup.onRender(this.el, null);
25049 // add the buttons to the navgroup
25051 if(this.displayInfo){
25052 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25053 this.displayEl = this.el.select('.x-paging-info', true).first();
25054 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25055 // this.displayEl = navel.el.select('span',true).first();
25061 Roo.each(_this.buttons, function(e){ // this might need to use render????
25062 Roo.factory(e).render(_this.el);
25066 Roo.each(_this.toolbarItems, function(e) {
25067 _this.navgroup.addItem(e);
25071 this.first = this.navgroup.addItem({
25072 tooltip: this.firstText,
25073 cls: "prev btn-outline-secondary",
25074 html : ' <i class="fa fa-step-backward"></i>',
25076 preventDefault: true,
25077 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25080 this.prev = this.navgroup.addItem({
25081 tooltip: this.prevText,
25082 cls: "prev btn-outline-secondary",
25083 html : ' <i class="fa fa-backward"></i>',
25085 preventDefault: true,
25086 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25088 //this.addSeparator();
25091 var field = this.navgroup.addItem( {
25093 cls : 'x-paging-position btn-outline-secondary',
25095 html : this.beforePageText +
25096 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25097 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25100 this.field = field.el.select('input', true).first();
25101 this.field.on("keydown", this.onPagingKeydown, this);
25102 this.field.on("focus", function(){this.dom.select();});
25105 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25106 //this.field.setHeight(18);
25107 //this.addSeparator();
25108 this.next = this.navgroup.addItem({
25109 tooltip: this.nextText,
25110 cls: "next btn-outline-secondary",
25111 html : ' <i class="fa fa-forward"></i>',
25113 preventDefault: true,
25114 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25116 this.last = this.navgroup.addItem({
25117 tooltip: this.lastText,
25118 html : ' <i class="fa fa-step-forward"></i>',
25119 cls: "next btn-outline-secondary",
25121 preventDefault: true,
25122 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25124 //this.addSeparator();
25125 this.loading = this.navgroup.addItem({
25126 tooltip: this.refreshText,
25127 cls: "btn-outline-secondary",
25128 html : ' <i class="fa fa-refresh"></i>',
25129 preventDefault: true,
25130 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25136 updateInfo : function(){
25137 if(this.displayEl){
25138 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25139 var msg = count == 0 ?
25143 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25145 this.displayEl.update(msg);
25150 onLoad : function(ds, r, o)
25152 this.cursor = o.params.start ? o.params.start : 0;
25154 var d = this.getPageData(),
25159 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25160 this.field.dom.value = ap;
25161 this.first.setDisabled(ap == 1);
25162 this.prev.setDisabled(ap == 1);
25163 this.next.setDisabled(ap == ps);
25164 this.last.setDisabled(ap == ps);
25165 this.loading.enable();
25170 getPageData : function(){
25171 var total = this.ds.getTotalCount();
25174 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25175 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25180 onLoadError : function(){
25181 this.loading.enable();
25185 onPagingKeydown : function(e){
25186 var k = e.getKey();
25187 var d = this.getPageData();
25189 var v = this.field.dom.value, pageNum;
25190 if(!v || isNaN(pageNum = parseInt(v, 10))){
25191 this.field.dom.value = d.activePage;
25194 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25195 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25198 else if(k == e.HOME || (k == e.UP && e.ctrlKey) || (k == e.PAGEUP && e.ctrlKey) || (k == e.RIGHT && e.ctrlKey) || k == e.END || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey))
25200 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25201 this.field.dom.value = pageNum;
25202 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25205 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25207 var v = this.field.dom.value, pageNum;
25208 var increment = (e.shiftKey) ? 10 : 1;
25209 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25212 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25213 this.field.dom.value = d.activePage;
25216 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25218 this.field.dom.value = parseInt(v, 10) + increment;
25219 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25220 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25227 beforeLoad : function(){
25229 this.loading.disable();
25234 onClick : function(which){
25243 ds.load({params:{start: 0, limit: this.pageSize}});
25246 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25249 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25252 var total = ds.getTotalCount();
25253 var extra = total % this.pageSize;
25254 var lastStart = extra ? (total - extra) : total-this.pageSize;
25255 ds.load({params:{start: lastStart, limit: this.pageSize}});
25258 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25264 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25265 * @param {Roo.data.Store} store The data store to unbind
25267 unbind : function(ds){
25268 ds.un("beforeload", this.beforeLoad, this);
25269 ds.un("load", this.onLoad, this);
25270 ds.un("loadexception", this.onLoadError, this);
25271 ds.un("remove", this.updateInfo, this);
25272 ds.un("add", this.updateInfo, this);
25273 this.ds = undefined;
25277 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25278 * @param {Roo.data.Store} store The data store to bind
25280 bind : function(ds){
25281 ds.on("beforeload", this.beforeLoad, this);
25282 ds.on("load", this.onLoad, this);
25283 ds.on("loadexception", this.onLoadError, this);
25284 ds.on("remove", this.updateInfo, this);
25285 ds.on("add", this.updateInfo, this);
25296 * @class Roo.bootstrap.MessageBar
25297 * @extends Roo.bootstrap.Component
25298 * Bootstrap MessageBar class
25299 * @cfg {String} html contents of the MessageBar
25300 * @cfg {String} weight (info | success | warning | danger) default info
25301 * @cfg {String} beforeClass insert the bar before the given class
25302 * @cfg {Boolean} closable (true | false) default false
25303 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25306 * Create a new Element
25307 * @param {Object} config The config object
25310 Roo.bootstrap.MessageBar = function(config){
25311 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25314 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25320 beforeClass: 'bootstrap-sticky-wrap',
25322 getAutoCreate : function(){
25326 cls: 'alert alert-dismissable alert-' + this.weight,
25331 html: this.html || ''
25337 cfg.cls += ' alert-messages-fixed';
25351 onRender : function(ct, position)
25353 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25356 var cfg = Roo.apply({}, this.getAutoCreate());
25360 cfg.cls += ' ' + this.cls;
25363 cfg.style = this.style;
25365 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25367 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25370 this.el.select('>button.close').on('click', this.hide, this);
25376 if (!this.rendered) {
25382 this.fireEvent('show', this);
25388 if (!this.rendered) {
25394 this.fireEvent('hide', this);
25397 update : function()
25399 // var e = this.el.dom.firstChild;
25401 // if(this.closable){
25402 // e = e.nextSibling;
25405 // e.data = this.html || '';
25407 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25423 * @class Roo.bootstrap.Graph
25424 * @extends Roo.bootstrap.Component
25425 * Bootstrap Graph class
25429 @cfg {String} graphtype bar | vbar | pie
25430 @cfg {number} g_x coodinator | centre x (pie)
25431 @cfg {number} g_y coodinator | centre y (pie)
25432 @cfg {number} g_r radius (pie)
25433 @cfg {number} g_height height of the chart (respected by all elements in the set)
25434 @cfg {number} g_width width of the chart (respected by all elements in the set)
25435 @cfg {Object} title The title of the chart
25438 -opts (object) options for the chart
25440 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25441 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25443 o colors (array) colors be used repeatedly to plot the bars. If multicolumn bar is used each sequence of bars with use a different color.
25444 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25446 o stretch (boolean)
25448 -opts (object) options for the pie
25451 o startAngle (number)
25452 o endAngle (number)
25456 * Create a new Input
25457 * @param {Object} config The config object
25460 Roo.bootstrap.Graph = function(config){
25461 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25467 * The img click event for the img.
25468 * @param {Roo.EventObject} e
25474 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25485 //g_colors: this.colors,
25492 getAutoCreate : function(){
25503 onRender : function(ct,position){
25506 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25508 if (typeof(Raphael) == 'undefined') {
25509 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25513 this.raphael = Raphael(this.el.dom);
25515 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25516 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25517 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25518 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25520 r.text(160, 10, "Single Series Chart").attr(txtattr);
25521 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25522 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25523 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25525 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25526 r.barchart(330, 10, 300, 220, data1);
25527 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25528 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25531 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25532 // r.barchart(30, 30, 560, 250, xdata, {
25533 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25534 // axis : "0 0 1 1",
25535 // axisxlabels : xdata
25536 // //yvalues : cols,
25539 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25541 // this.load(null,xdata,{
25542 // axis : "0 0 1 1",
25543 // axisxlabels : xdata
25548 load : function(graphtype,xdata,opts)
25550 this.raphael.clear();
25552 graphtype = this.graphtype;
25557 var r = this.raphael,
25558 fin = function () {
25559 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25561 fout = function () {
25562 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25564 pfin = function() {
25565 this.sector.stop();
25566 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25569 this.label[0].stop();
25570 this.label[0].attr({ r: 7.5 });
25571 this.label[1].attr({ "font-weight": 800 });
25574 pfout = function() {
25575 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25578 this.label[0].animate({ r: 5 }, 500, "bounce");
25579 this.label[1].attr({ "font-weight": 400 });
25585 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25588 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25591 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25592 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25594 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25601 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25606 setTitle: function(o)
25611 initEvents: function() {
25614 this.el.on('click', this.onClick, this);
25618 onClick : function(e)
25620 Roo.log('img onclick');
25621 this.fireEvent('click', this, e);
25633 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25636 * @class Roo.bootstrap.dash.NumberBox
25637 * @extends Roo.bootstrap.Component
25638 * Bootstrap NumberBox class
25639 * @cfg {String} headline Box headline
25640 * @cfg {String} content Box content
25641 * @cfg {String} icon Box icon
25642 * @cfg {String} footer Footer text
25643 * @cfg {String} fhref Footer href
25646 * Create a new NumberBox
25647 * @param {Object} config The config object
25651 Roo.bootstrap.dash.NumberBox = function(config){
25652 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25656 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25665 getAutoCreate : function(){
25669 cls : 'small-box ',
25677 cls : 'roo-headline',
25678 html : this.headline
25682 cls : 'roo-content',
25683 html : this.content
25697 cls : 'ion ' + this.icon
25706 cls : 'small-box-footer',
25707 href : this.fhref || '#',
25711 cfg.cn.push(footer);
25718 onRender : function(ct,position){
25719 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25726 setHeadline: function (value)
25728 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25731 setFooter: function (value, href)
25733 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25736 this.el.select('a.small-box-footer',true).first().attr('href', href);
25741 setContent: function (value)
25743 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25746 initEvents: function()
25760 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25763 * @class Roo.bootstrap.dash.TabBox
25764 * @extends Roo.bootstrap.Component
25765 * Bootstrap TabBox class
25766 * @cfg {String} title Title of the TabBox
25767 * @cfg {String} icon Icon of the TabBox
25768 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25769 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25772 * Create a new TabBox
25773 * @param {Object} config The config object
25777 Roo.bootstrap.dash.TabBox = function(config){
25778 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25783 * When a pane is added
25784 * @param {Roo.bootstrap.dash.TabPane} pane
25788 * @event activatepane
25789 * When a pane is activated
25790 * @param {Roo.bootstrap.dash.TabPane} pane
25792 "activatepane" : true
25800 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25805 tabScrollable : false,
25807 getChildContainer : function()
25809 return this.el.select('.tab-content', true).first();
25812 getAutoCreate : function(){
25816 cls: 'pull-left header',
25824 cls: 'fa ' + this.icon
25830 cls: 'nav nav-tabs pull-right',
25836 if(this.tabScrollable){
25843 cls: 'nav nav-tabs pull-right',
25854 cls: 'nav-tabs-custom',
25859 cls: 'tab-content no-padding',
25867 initEvents : function()
25869 //Roo.log('add add pane handler');
25870 this.on('addpane', this.onAddPane, this);
25873 * Updates the box title
25874 * @param {String} html to set the title to.
25876 setTitle : function(value)
25878 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25880 onAddPane : function(pane)
25882 this.panes.push(pane);
25883 //Roo.log('addpane');
25885 // tabs are rendere left to right..
25886 if(!this.showtabs){
25890 var ctr = this.el.select('.nav-tabs', true).first();
25893 var existing = ctr.select('.nav-tab',true);
25894 var qty = existing.getCount();;
25897 var tab = ctr.createChild({
25899 cls : 'nav-tab' + (qty ? '' : ' active'),
25907 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25910 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25912 pane.el.addClass('active');
25917 onTabClick : function(ev,un,ob,pane)
25919 //Roo.log('tab - prev default');
25920 ev.preventDefault();
25923 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25924 pane.tab.addClass('active');
25925 //Roo.log(pane.title);
25926 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25927 // technically we should have a deactivate event.. but maybe add later.
25928 // and it should not de-activate the selected tab...
25929 this.fireEvent('activatepane', pane);
25930 pane.el.addClass('active');
25931 pane.fireEvent('activate');
25936 getActivePane : function()
25939 Roo.each(this.panes, function(p) {
25940 if(p.el.hasClass('active')){
25961 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25963 * @class Roo.bootstrap.TabPane
25964 * @extends Roo.bootstrap.Component
25965 * Bootstrap TabPane class
25966 * @cfg {Boolean} active (false | true) Default false
25967 * @cfg {String} title title of panel
25971 * Create a new TabPane
25972 * @param {Object} config The config object
25975 Roo.bootstrap.dash.TabPane = function(config){
25976 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25982 * When a pane is activated
25983 * @param {Roo.bootstrap.dash.TabPane} pane
25990 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25995 // the tabBox that this is attached to.
25998 getAutoCreate : function()
26006 cfg.cls += ' active';
26011 initEvents : function()
26013 //Roo.log('trigger add pane handler');
26014 this.parent().fireEvent('addpane', this)
26018 * Updates the tab title
26019 * @param {String} html to set the title to.
26021 setTitle: function(str)
26027 this.tab.select('a', true).first().dom.innerHTML = str;
26044 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26047 * @class Roo.bootstrap.menu.Menu
26048 * @extends Roo.bootstrap.Component
26049 * Bootstrap Menu class - container for Menu
26050 * @cfg {String} html Text of the menu
26051 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26052 * @cfg {String} icon Font awesome icon
26053 * @cfg {String} pos Menu align to (top | bottom) default bottom
26057 * Create a new Menu
26058 * @param {Object} config The config object
26062 Roo.bootstrap.menu.Menu = function(config){
26063 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26067 * @event beforeshow
26068 * Fires before this menu is displayed
26069 * @param {Roo.bootstrap.menu.Menu} this
26073 * @event beforehide
26074 * Fires before this menu is hidden
26075 * @param {Roo.bootstrap.menu.Menu} this
26080 * Fires after this menu is displayed
26081 * @param {Roo.bootstrap.menu.Menu} this
26086 * Fires after this menu is hidden
26087 * @param {Roo.bootstrap.menu.Menu} this
26092 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26093 * @param {Roo.bootstrap.menu.Menu} this
26094 * @param {Roo.EventObject} e
26101 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26105 weight : 'default',
26110 getChildContainer : function() {
26111 if(this.isSubMenu){
26115 return this.el.select('ul.dropdown-menu', true).first();
26118 getAutoCreate : function()
26123 cls : 'roo-menu-text',
26131 cls : 'fa ' + this.icon
26142 cls : 'dropdown-button btn btn-' + this.weight,
26147 cls : 'dropdown-toggle btn btn-' + this.weight,
26157 cls : 'dropdown-menu'
26163 if(this.pos == 'top'){
26164 cfg.cls += ' dropup';
26167 if(this.isSubMenu){
26170 cls : 'dropdown-menu'
26177 onRender : function(ct, position)
26179 this.isSubMenu = ct.hasClass('dropdown-submenu');
26181 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26184 initEvents : function()
26186 if(this.isSubMenu){
26190 this.hidden = true;
26192 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26193 this.triggerEl.on('click', this.onTriggerPress, this);
26195 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26196 this.buttonEl.on('click', this.onClick, this);
26202 if(this.isSubMenu){
26206 return this.el.select('ul.dropdown-menu', true).first();
26209 onClick : function(e)
26211 this.fireEvent("click", this, e);
26214 onTriggerPress : function(e)
26216 if (this.isVisible()) {
26223 isVisible : function(){
26224 return !this.hidden;
26229 this.fireEvent("beforeshow", this);
26231 this.hidden = false;
26232 this.el.addClass('open');
26234 Roo.get(document).on("mouseup", this.onMouseUp, this);
26236 this.fireEvent("show", this);
26243 this.fireEvent("beforehide", this);
26245 this.hidden = true;
26246 this.el.removeClass('open');
26248 Roo.get(document).un("mouseup", this.onMouseUp);
26250 this.fireEvent("hide", this);
26253 onMouseUp : function()
26267 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26270 * @class Roo.bootstrap.menu.Item
26271 * @extends Roo.bootstrap.Component
26272 * Bootstrap MenuItem class
26273 * @cfg {Boolean} submenu (true | false) default false
26274 * @cfg {String} html text of the item
26275 * @cfg {String} href the link
26276 * @cfg {Boolean} disable (true | false) default false
26277 * @cfg {Boolean} preventDefault (true | false) default true
26278 * @cfg {String} icon Font awesome icon
26279 * @cfg {String} pos Submenu align to (left | right) default right
26283 * Create a new Item
26284 * @param {Object} config The config object
26288 Roo.bootstrap.menu.Item = function(config){
26289 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26293 * Fires when the mouse is hovering over this menu
26294 * @param {Roo.bootstrap.menu.Item} this
26295 * @param {Roo.EventObject} e
26300 * Fires when the mouse exits this menu
26301 * @param {Roo.bootstrap.menu.Item} this
26302 * @param {Roo.EventObject} e
26308 * The raw click event for the entire grid.
26309 * @param {Roo.EventObject} e
26315 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26320 preventDefault: true,
26325 getAutoCreate : function()
26330 cls : 'roo-menu-item-text',
26338 cls : 'fa ' + this.icon
26347 href : this.href || '#',
26354 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26358 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26360 if(this.pos == 'left'){
26361 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26368 initEvents : function()
26370 this.el.on('mouseover', this.onMouseOver, this);
26371 this.el.on('mouseout', this.onMouseOut, this);
26373 this.el.select('a', true).first().on('click', this.onClick, this);
26377 onClick : function(e)
26379 if(this.preventDefault){
26380 e.preventDefault();
26383 this.fireEvent("click", this, e);
26386 onMouseOver : function(e)
26388 if(this.submenu && this.pos == 'left'){
26389 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26392 this.fireEvent("mouseover", this, e);
26395 onMouseOut : function(e)
26397 this.fireEvent("mouseout", this, e);
26409 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26412 * @class Roo.bootstrap.menu.Separator
26413 * @extends Roo.bootstrap.Component
26414 * Bootstrap Separator class
26417 * Create a new Separator
26418 * @param {Object} config The config object
26422 Roo.bootstrap.menu.Separator = function(config){
26423 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26426 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26428 getAutoCreate : function(){
26449 * @class Roo.bootstrap.Tooltip
26450 * Bootstrap Tooltip class
26451 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26452 * to determine which dom element triggers the tooltip.
26454 * It needs to add support for additional attributes like tooltip-position
26457 * Create a new Toolti
26458 * @param {Object} config The config object
26461 Roo.bootstrap.Tooltip = function(config){
26462 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26464 this.alignment = Roo.bootstrap.Tooltip.alignment;
26466 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26467 this.alignment = config.alignment;
26472 Roo.apply(Roo.bootstrap.Tooltip, {
26474 * @function init initialize tooltip monitoring.
26478 currentTip : false,
26479 currentRegion : false,
26485 Roo.get(document).on('mouseover', this.enter ,this);
26486 Roo.get(document).on('mouseout', this.leave, this);
26489 this.currentTip = new Roo.bootstrap.Tooltip();
26492 enter : function(ev)
26494 var dom = ev.getTarget();
26496 //Roo.log(['enter',dom]);
26497 var el = Roo.fly(dom);
26498 if (this.currentEl) {
26500 //Roo.log(this.currentEl);
26501 //Roo.log(this.currentEl.contains(dom));
26502 if (this.currentEl == el) {
26505 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26511 if (this.currentTip.el) {
26512 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26516 if(!el || el.dom == document){
26522 // you can not look for children, as if el is the body.. then everythign is the child..
26523 if (!el.attr('tooltip')) { //
26524 if (!el.select("[tooltip]").elements.length) {
26527 // is the mouse over this child...?
26528 bindEl = el.select("[tooltip]").first();
26529 var xy = ev.getXY();
26530 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26531 //Roo.log("not in region.");
26534 //Roo.log("child element over..");
26537 this.currentEl = bindEl;
26538 this.currentTip.bind(bindEl);
26539 this.currentRegion = Roo.lib.Region.getRegion(dom);
26540 this.currentTip.enter();
26543 leave : function(ev)
26545 var dom = ev.getTarget();
26546 //Roo.log(['leave',dom]);
26547 if (!this.currentEl) {
26552 if (dom != this.currentEl.dom) {
26555 var xy = ev.getXY();
26556 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26559 // only activate leave if mouse cursor is outside... bounding box..
26564 if (this.currentTip) {
26565 this.currentTip.leave();
26567 //Roo.log('clear currentEl');
26568 this.currentEl = false;
26573 'left' : ['r-l', [-2,0], 'right'],
26574 'right' : ['l-r', [2,0], 'left'],
26575 'bottom' : ['t-b', [0,2], 'top'],
26576 'top' : [ 'b-t', [0,-2], 'bottom']
26582 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26587 delay : null, // can be { show : 300 , hide: 500}
26591 hoverState : null, //???
26593 placement : 'bottom',
26597 getAutoCreate : function(){
26604 cls : 'tooltip-arrow'
26607 cls : 'tooltip-inner'
26614 bind : function(el)
26620 enter : function () {
26622 if (this.timeout != null) {
26623 clearTimeout(this.timeout);
26626 this.hoverState = 'in';
26627 //Roo.log("enter - show");
26628 if (!this.delay || !this.delay.show) {
26633 this.timeout = setTimeout(function () {
26634 if (_t.hoverState == 'in') {
26637 }, this.delay.show);
26641 clearTimeout(this.timeout);
26643 this.hoverState = 'out';
26644 if (!this.delay || !this.delay.hide) {
26650 this.timeout = setTimeout(function () {
26651 //Roo.log("leave - timeout");
26653 if (_t.hoverState == 'out') {
26655 Roo.bootstrap.Tooltip.currentEl = false;
26660 show : function (msg)
26663 this.render(document.body);
26666 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26668 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26670 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26672 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26674 var placement = typeof this.placement == 'function' ?
26675 this.placement.call(this, this.el, on_el) :
26678 var autoToken = /\s?auto?\s?/i;
26679 var autoPlace = autoToken.test(placement);
26681 placement = placement.replace(autoToken, '') || 'top';
26685 //this.el.setXY([0,0]);
26687 //this.el.dom.style.display='block';
26689 //this.el.appendTo(on_el);
26691 var p = this.getPosition();
26692 var box = this.el.getBox();
26698 var align = this.alignment[placement];
26700 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26702 if(placement == 'top' || placement == 'bottom'){
26704 placement = 'right';
26707 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26708 placement = 'left';
26711 var scroll = Roo.select('body', true).first().getScroll();
26713 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26717 align = this.alignment[placement];
26720 this.el.alignTo(this.bindEl, align[0],align[1]);
26721 //var arrow = this.el.select('.arrow',true).first();
26722 //arrow.set(align[2],
26724 this.el.addClass(placement);
26726 this.el.addClass('in fade');
26728 this.hoverState = null;
26730 if (this.el.hasClass('fade')) {
26741 //this.el.setXY([0,0]);
26742 this.el.removeClass('in');
26758 * @class Roo.bootstrap.LocationPicker
26759 * @extends Roo.bootstrap.Component
26760 * Bootstrap LocationPicker class
26761 * @cfg {Number} latitude Position when init default 0
26762 * @cfg {Number} longitude Position when init default 0
26763 * @cfg {Number} zoom default 15
26764 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26765 * @cfg {Boolean} mapTypeControl default false
26766 * @cfg {Boolean} disableDoubleClickZoom default false
26767 * @cfg {Boolean} scrollwheel default true
26768 * @cfg {Boolean} streetViewControl default false
26769 * @cfg {Number} radius default 0
26770 * @cfg {String} locationName
26771 * @cfg {Boolean} draggable default true
26772 * @cfg {Boolean} enableAutocomplete default false
26773 * @cfg {Boolean} enableReverseGeocode default true
26774 * @cfg {String} markerTitle
26777 * Create a new LocationPicker
26778 * @param {Object} config The config object
26782 Roo.bootstrap.LocationPicker = function(config){
26784 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26789 * Fires when the picker initialized.
26790 * @param {Roo.bootstrap.LocationPicker} this
26791 * @param {Google Location} location
26795 * @event positionchanged
26796 * Fires when the picker position changed.
26797 * @param {Roo.bootstrap.LocationPicker} this
26798 * @param {Google Location} location
26800 positionchanged : true,
26803 * Fires when the map resize.
26804 * @param {Roo.bootstrap.LocationPicker} this
26809 * Fires when the map show.
26810 * @param {Roo.bootstrap.LocationPicker} this
26815 * Fires when the map hide.
26816 * @param {Roo.bootstrap.LocationPicker} this
26821 * Fires when click the map.
26822 * @param {Roo.bootstrap.LocationPicker} this
26823 * @param {Map event} e
26827 * @event mapRightClick
26828 * Fires when right click the map.
26829 * @param {Roo.bootstrap.LocationPicker} this
26830 * @param {Map event} e
26832 mapRightClick : true,
26834 * @event markerClick
26835 * Fires when click the marker.
26836 * @param {Roo.bootstrap.LocationPicker} this
26837 * @param {Map event} e
26839 markerClick : true,
26841 * @event markerRightClick
26842 * Fires when right click the marker.
26843 * @param {Roo.bootstrap.LocationPicker} this
26844 * @param {Map event} e
26846 markerRightClick : true,
26848 * @event OverlayViewDraw
26849 * Fires when OverlayView Draw
26850 * @param {Roo.bootstrap.LocationPicker} this
26852 OverlayViewDraw : true,
26854 * @event OverlayViewOnAdd
26855 * Fires when OverlayView Draw
26856 * @param {Roo.bootstrap.LocationPicker} this
26858 OverlayViewOnAdd : true,
26860 * @event OverlayViewOnRemove
26861 * Fires when OverlayView Draw
26862 * @param {Roo.bootstrap.LocationPicker} this
26864 OverlayViewOnRemove : true,
26866 * @event OverlayViewShow
26867 * Fires when OverlayView Draw
26868 * @param {Roo.bootstrap.LocationPicker} this
26869 * @param {Pixel} cpx
26871 OverlayViewShow : true,
26873 * @event OverlayViewHide
26874 * Fires when OverlayView Draw
26875 * @param {Roo.bootstrap.LocationPicker} this
26877 OverlayViewHide : true,
26879 * @event loadexception
26880 * Fires when load google lib failed.
26881 * @param {Roo.bootstrap.LocationPicker} this
26883 loadexception : true
26888 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26890 gMapContext: false,
26896 mapTypeControl: false,
26897 disableDoubleClickZoom: false,
26899 streetViewControl: false,
26903 enableAutocomplete: false,
26904 enableReverseGeocode: true,
26907 getAutoCreate: function()
26912 cls: 'roo-location-picker'
26918 initEvents: function(ct, position)
26920 if(!this.el.getWidth() || this.isApplied()){
26924 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26929 initial: function()
26931 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26932 this.fireEvent('loadexception', this);
26936 if(!this.mapTypeId){
26937 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26940 this.gMapContext = this.GMapContext();
26942 this.initOverlayView();
26944 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26948 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26949 _this.setPosition(_this.gMapContext.marker.position);
26952 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26953 _this.fireEvent('mapClick', this, event);
26957 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26958 _this.fireEvent('mapRightClick', this, event);
26962 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26963 _this.fireEvent('markerClick', this, event);
26967 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26968 _this.fireEvent('markerRightClick', this, event);
26972 this.setPosition(this.gMapContext.location);
26974 this.fireEvent('initial', this, this.gMapContext.location);
26977 initOverlayView: function()
26981 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26985 _this.fireEvent('OverlayViewDraw', _this);
26990 _this.fireEvent('OverlayViewOnAdd', _this);
26993 onRemove: function()
26995 _this.fireEvent('OverlayViewOnRemove', _this);
26998 show: function(cpx)
27000 _this.fireEvent('OverlayViewShow', _this, cpx);
27005 _this.fireEvent('OverlayViewHide', _this);
27011 fromLatLngToContainerPixel: function(event)
27013 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
27016 isApplied: function()
27018 return this.getGmapContext() == false ? false : true;
27021 getGmapContext: function()
27023 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
27026 GMapContext: function()
27028 var position = new google.maps.LatLng(this.latitude, this.longitude);
27030 var _map = new google.maps.Map(this.el.dom, {
27033 mapTypeId: this.mapTypeId,
27034 mapTypeControl: this.mapTypeControl,
27035 disableDoubleClickZoom: this.disableDoubleClickZoom,
27036 scrollwheel: this.scrollwheel,
27037 streetViewControl: this.streetViewControl,
27038 locationName: this.locationName,
27039 draggable: this.draggable,
27040 enableAutocomplete: this.enableAutocomplete,
27041 enableReverseGeocode: this.enableReverseGeocode
27044 var _marker = new google.maps.Marker({
27045 position: position,
27047 title: this.markerTitle,
27048 draggable: this.draggable
27055 location: position,
27056 radius: this.radius,
27057 locationName: this.locationName,
27058 addressComponents: {
27059 formatted_address: null,
27060 addressLine1: null,
27061 addressLine2: null,
27063 streetNumber: null,
27067 stateOrProvince: null
27070 domContainer: this.el.dom,
27071 geodecoder: new google.maps.Geocoder()
27075 drawCircle: function(center, radius, options)
27077 if (this.gMapContext.circle != null) {
27078 this.gMapContext.circle.setMap(null);
27082 options = Roo.apply({}, options, {
27083 strokeColor: "#0000FF",
27084 strokeOpacity: .35,
27086 fillColor: "#0000FF",
27090 options.map = this.gMapContext.map;
27091 options.radius = radius;
27092 options.center = center;
27093 this.gMapContext.circle = new google.maps.Circle(options);
27094 return this.gMapContext.circle;
27100 setPosition: function(location)
27102 this.gMapContext.location = location;
27103 this.gMapContext.marker.setPosition(location);
27104 this.gMapContext.map.panTo(location);
27105 this.drawCircle(location, this.gMapContext.radius, {});
27109 if (this.gMapContext.settings.enableReverseGeocode) {
27110 this.gMapContext.geodecoder.geocode({
27111 latLng: this.gMapContext.location
27112 }, function(results, status) {
27114 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27115 _this.gMapContext.locationName = results[0].formatted_address;
27116 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27118 _this.fireEvent('positionchanged', this, location);
27125 this.fireEvent('positionchanged', this, location);
27130 google.maps.event.trigger(this.gMapContext.map, "resize");
27132 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27134 this.fireEvent('resize', this);
27137 setPositionByLatLng: function(latitude, longitude)
27139 this.setPosition(new google.maps.LatLng(latitude, longitude));
27142 getCurrentPosition: function()
27145 latitude: this.gMapContext.location.lat(),
27146 longitude: this.gMapContext.location.lng()
27150 getAddressName: function()
27152 return this.gMapContext.locationName;
27155 getAddressComponents: function()
27157 return this.gMapContext.addressComponents;
27160 address_component_from_google_geocode: function(address_components)
27164 for (var i = 0; i < address_components.length; i++) {
27165 var component = address_components[i];
27166 if (component.types.indexOf("postal_code") >= 0) {
27167 result.postalCode = component.short_name;
27168 } else if (component.types.indexOf("street_number") >= 0) {
27169 result.streetNumber = component.short_name;
27170 } else if (component.types.indexOf("route") >= 0) {
27171 result.streetName = component.short_name;
27172 } else if (component.types.indexOf("neighborhood") >= 0) {
27173 result.city = component.short_name;
27174 } else if (component.types.indexOf("locality") >= 0) {
27175 result.city = component.short_name;
27176 } else if (component.types.indexOf("sublocality") >= 0) {
27177 result.district = component.short_name;
27178 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27179 result.stateOrProvince = component.short_name;
27180 } else if (component.types.indexOf("country") >= 0) {
27181 result.country = component.short_name;
27185 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27186 result.addressLine2 = "";
27190 setZoomLevel: function(zoom)
27192 this.gMapContext.map.setZoom(zoom);
27205 this.fireEvent('show', this);
27216 this.fireEvent('hide', this);
27221 Roo.apply(Roo.bootstrap.LocationPicker, {
27223 OverlayView : function(map, options)
27225 options = options || {};
27232 * @class Roo.bootstrap.Alert
27233 * @extends Roo.bootstrap.Component
27234 * Bootstrap Alert class - shows an alert area box
27236 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
27237 Enter a valid email address
27240 * @cfg {String} title The title of alert
27241 * @cfg {String} html The content of alert
27242 * @cfg {String} weight ( success | info | warning | danger )
27243 * @cfg {String} faicon font-awesomeicon
27246 * Create a new alert
27247 * @param {Object} config The config object
27251 Roo.bootstrap.Alert = function(config){
27252 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27256 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27263 getAutoCreate : function()
27272 cls : 'roo-alert-icon'
27277 cls : 'roo-alert-title',
27282 cls : 'roo-alert-text',
27289 cfg.cn[0].cls += ' fa ' + this.faicon;
27293 cfg.cls += ' alert-' + this.weight;
27299 initEvents: function()
27301 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27304 setTitle : function(str)
27306 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27309 setText : function(str)
27311 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27314 setWeight : function(weight)
27317 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27320 this.weight = weight;
27322 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27325 setIcon : function(icon)
27328 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27331 this.faicon = icon;
27333 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27354 * @class Roo.bootstrap.UploadCropbox
27355 * @extends Roo.bootstrap.Component
27356 * Bootstrap UploadCropbox class
27357 * @cfg {String} emptyText show when image has been loaded
27358 * @cfg {String} rotateNotify show when image too small to rotate
27359 * @cfg {Number} errorTimeout default 3000
27360 * @cfg {Number} minWidth default 300
27361 * @cfg {Number} minHeight default 300
27362 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27363 * @cfg {Boolean} isDocument (true|false) default false
27364 * @cfg {String} url action url
27365 * @cfg {String} paramName default 'imageUpload'
27366 * @cfg {String} method default POST
27367 * @cfg {Boolean} loadMask (true|false) default true
27368 * @cfg {Boolean} loadingText default 'Loading...'
27371 * Create a new UploadCropbox
27372 * @param {Object} config The config object
27375 Roo.bootstrap.UploadCropbox = function(config){
27376 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27380 * @event beforeselectfile
27381 * Fire before select file
27382 * @param {Roo.bootstrap.UploadCropbox} this
27384 "beforeselectfile" : true,
27387 * Fire after initEvent
27388 * @param {Roo.bootstrap.UploadCropbox} this
27393 * Fire after initEvent
27394 * @param {Roo.bootstrap.UploadCropbox} this
27395 * @param {String} data
27400 * Fire when preparing the file data
27401 * @param {Roo.bootstrap.UploadCropbox} this
27402 * @param {Object} file
27407 * Fire when get exception
27408 * @param {Roo.bootstrap.UploadCropbox} this
27409 * @param {XMLHttpRequest} xhr
27411 "exception" : true,
27413 * @event beforeloadcanvas
27414 * Fire before load the canvas
27415 * @param {Roo.bootstrap.UploadCropbox} this
27416 * @param {String} src
27418 "beforeloadcanvas" : true,
27421 * Fire when trash image
27422 * @param {Roo.bootstrap.UploadCropbox} this
27427 * Fire when download the image
27428 * @param {Roo.bootstrap.UploadCropbox} this
27432 * @event footerbuttonclick
27433 * Fire when footerbuttonclick
27434 * @param {Roo.bootstrap.UploadCropbox} this
27435 * @param {String} type
27437 "footerbuttonclick" : true,
27441 * @param {Roo.bootstrap.UploadCropbox} this
27446 * Fire when rotate the image
27447 * @param {Roo.bootstrap.UploadCropbox} this
27448 * @param {String} pos
27453 * Fire when inspect the file
27454 * @param {Roo.bootstrap.UploadCropbox} this
27455 * @param {Object} file
27460 * Fire when xhr upload the file
27461 * @param {Roo.bootstrap.UploadCropbox} this
27462 * @param {Object} data
27467 * Fire when arrange the file data
27468 * @param {Roo.bootstrap.UploadCropbox} this
27469 * @param {Object} formData
27474 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27477 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27479 emptyText : 'Click to upload image',
27480 rotateNotify : 'Image is too small to rotate',
27481 errorTimeout : 3000,
27495 cropType : 'image/jpeg',
27497 canvasLoaded : false,
27498 isDocument : false,
27500 paramName : 'imageUpload',
27502 loadingText : 'Loading...',
27505 getAutoCreate : function()
27509 cls : 'roo-upload-cropbox',
27513 cls : 'roo-upload-cropbox-selector',
27518 cls : 'roo-upload-cropbox-body',
27519 style : 'cursor:pointer',
27523 cls : 'roo-upload-cropbox-preview'
27527 cls : 'roo-upload-cropbox-thumb'
27531 cls : 'roo-upload-cropbox-empty-notify',
27532 html : this.emptyText
27536 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27537 html : this.rotateNotify
27543 cls : 'roo-upload-cropbox-footer',
27546 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27556 onRender : function(ct, position)
27558 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27560 if (this.buttons.length) {
27562 Roo.each(this.buttons, function(bb) {
27564 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27566 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27572 this.maskEl = this.el;
27576 initEvents : function()
27578 this.urlAPI = (window.createObjectURL && window) ||
27579 (window.URL && URL.revokeObjectURL && URL) ||
27580 (window.webkitURL && webkitURL);
27582 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27583 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27585 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27586 this.selectorEl.hide();
27588 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27589 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27591 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27592 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27593 this.thumbEl.hide();
27595 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27596 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27598 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27599 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27600 this.errorEl.hide();
27602 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27603 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27604 this.footerEl.hide();
27606 this.setThumbBoxSize();
27612 this.fireEvent('initial', this);
27619 window.addEventListener("resize", function() { _this.resize(); } );
27621 this.bodyEl.on('click', this.beforeSelectFile, this);
27624 this.bodyEl.on('touchstart', this.onTouchStart, this);
27625 this.bodyEl.on('touchmove', this.onTouchMove, this);
27626 this.bodyEl.on('touchend', this.onTouchEnd, this);
27630 this.bodyEl.on('mousedown', this.onMouseDown, this);
27631 this.bodyEl.on('mousemove', this.onMouseMove, this);
27632 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27633 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27634 Roo.get(document).on('mouseup', this.onMouseUp, this);
27637 this.selectorEl.on('change', this.onFileSelected, this);
27643 this.baseScale = 1;
27645 this.baseRotate = 1;
27646 this.dragable = false;
27647 this.pinching = false;
27650 this.cropData = false;
27651 this.notifyEl.dom.innerHTML = this.emptyText;
27653 this.selectorEl.dom.value = '';
27657 resize : function()
27659 if(this.fireEvent('resize', this) != false){
27660 this.setThumbBoxPosition();
27661 this.setCanvasPosition();
27665 onFooterButtonClick : function(e, el, o, type)
27668 case 'rotate-left' :
27669 this.onRotateLeft(e);
27671 case 'rotate-right' :
27672 this.onRotateRight(e);
27675 this.beforeSelectFile(e);
27690 this.fireEvent('footerbuttonclick', this, type);
27693 beforeSelectFile : function(e)
27695 e.preventDefault();
27697 if(this.fireEvent('beforeselectfile', this) != false){
27698 this.selectorEl.dom.click();
27702 onFileSelected : function(e)
27704 e.preventDefault();
27706 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27710 var file = this.selectorEl.dom.files[0];
27712 if(this.fireEvent('inspect', this, file) != false){
27713 this.prepare(file);
27718 trash : function(e)
27720 this.fireEvent('trash', this);
27723 download : function(e)
27725 this.fireEvent('download', this);
27728 loadCanvas : function(src)
27730 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27734 this.imageEl = document.createElement('img');
27738 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27740 this.imageEl.src = src;
27744 onLoadCanvas : function()
27746 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27747 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27749 this.bodyEl.un('click', this.beforeSelectFile, this);
27751 this.notifyEl.hide();
27752 this.thumbEl.show();
27753 this.footerEl.show();
27755 this.baseRotateLevel();
27757 if(this.isDocument){
27758 this.setThumbBoxSize();
27761 this.setThumbBoxPosition();
27763 this.baseScaleLevel();
27769 this.canvasLoaded = true;
27772 this.maskEl.unmask();
27777 setCanvasPosition : function()
27779 if(!this.canvasEl){
27783 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27784 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27786 this.previewEl.setLeft(pw);
27787 this.previewEl.setTop(ph);
27791 onMouseDown : function(e)
27795 this.dragable = true;
27796 this.pinching = false;
27798 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27799 this.dragable = false;
27803 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27804 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27808 onMouseMove : function(e)
27812 if(!this.canvasLoaded){
27816 if (!this.dragable){
27820 var minX = Math.ceil(this.thumbEl.getLeft(true));
27821 var minY = Math.ceil(this.thumbEl.getTop(true));
27823 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27824 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27826 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27827 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27829 x = x - this.mouseX;
27830 y = y - this.mouseY;
27832 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27833 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27835 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27836 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27838 this.previewEl.setLeft(bgX);
27839 this.previewEl.setTop(bgY);
27841 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27842 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27845 onMouseUp : function(e)
27849 this.dragable = false;
27852 onMouseWheel : function(e)
27856 this.startScale = this.scale;
27858 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27860 if(!this.zoomable()){
27861 this.scale = this.startScale;
27870 zoomable : function()
27872 var minScale = this.thumbEl.getWidth() / this.minWidth;
27874 if(this.minWidth < this.minHeight){
27875 minScale = this.thumbEl.getHeight() / this.minHeight;
27878 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27879 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27883 (this.rotate == 0 || this.rotate == 180) &&
27885 width > this.imageEl.OriginWidth ||
27886 height > this.imageEl.OriginHeight ||
27887 (width < this.minWidth && height < this.minHeight)
27895 (this.rotate == 90 || this.rotate == 270) &&
27897 width > this.imageEl.OriginWidth ||
27898 height > this.imageEl.OriginHeight ||
27899 (width < this.minHeight && height < this.minWidth)
27906 !this.isDocument &&
27907 (this.rotate == 0 || this.rotate == 180) &&
27909 width < this.minWidth ||
27910 width > this.imageEl.OriginWidth ||
27911 height < this.minHeight ||
27912 height > this.imageEl.OriginHeight
27919 !this.isDocument &&
27920 (this.rotate == 90 || this.rotate == 270) &&
27922 width < this.minHeight ||
27923 width > this.imageEl.OriginWidth ||
27924 height < this.minWidth ||
27925 height > this.imageEl.OriginHeight
27935 onRotateLeft : function(e)
27937 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27939 var minScale = this.thumbEl.getWidth() / this.minWidth;
27941 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27942 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27944 this.startScale = this.scale;
27946 while (this.getScaleLevel() < minScale){
27948 this.scale = this.scale + 1;
27950 if(!this.zoomable()){
27955 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27956 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27961 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27968 this.scale = this.startScale;
27970 this.onRotateFail();
27975 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27977 if(this.isDocument){
27978 this.setThumbBoxSize();
27979 this.setThumbBoxPosition();
27980 this.setCanvasPosition();
27985 this.fireEvent('rotate', this, 'left');
27989 onRotateRight : function(e)
27991 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27993 var minScale = this.thumbEl.getWidth() / this.minWidth;
27995 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27996 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27998 this.startScale = this.scale;
28000 while (this.getScaleLevel() < minScale){
28002 this.scale = this.scale + 1;
28004 if(!this.zoomable()){
28009 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
28010 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
28015 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28022 this.scale = this.startScale;
28024 this.onRotateFail();
28029 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28031 if(this.isDocument){
28032 this.setThumbBoxSize();
28033 this.setThumbBoxPosition();
28034 this.setCanvasPosition();
28039 this.fireEvent('rotate', this, 'right');
28042 onRotateFail : function()
28044 this.errorEl.show(true);
28048 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28053 this.previewEl.dom.innerHTML = '';
28055 var canvasEl = document.createElement("canvas");
28057 var contextEl = canvasEl.getContext("2d");
28059 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28060 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28061 var center = this.imageEl.OriginWidth / 2;
28063 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28064 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28065 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28066 center = this.imageEl.OriginHeight / 2;
28069 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28071 contextEl.translate(center, center);
28072 contextEl.rotate(this.rotate * Math.PI / 180);
28074 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28076 this.canvasEl = document.createElement("canvas");
28078 this.contextEl = this.canvasEl.getContext("2d");
28080 switch (this.rotate) {
28083 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28084 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28086 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28091 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28092 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28094 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28095 this.contextEl.drawImage(canvasEl, Math.abs(this.canvasEl.width - this.canvasEl.height), 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28099 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28104 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28105 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28107 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28108 this.contextEl.drawImage(canvasEl, 0, Math.abs(this.canvasEl.width - this.canvasEl.height), this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28112 this.contextEl.drawImage(canvasEl, Math.abs(this.canvasEl.width - this.canvasEl.height), 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28117 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28118 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28120 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28121 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28125 this.contextEl.drawImage(canvasEl, 0, Math.abs(this.canvasEl.width - this.canvasEl.height), this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28132 this.previewEl.appendChild(this.canvasEl);
28134 this.setCanvasPosition();
28139 if(!this.canvasLoaded){
28143 var imageCanvas = document.createElement("canvas");
28145 var imageContext = imageCanvas.getContext("2d");
28147 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28148 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28150 var center = imageCanvas.width / 2;
28152 imageContext.translate(center, center);
28154 imageContext.rotate(this.rotate * Math.PI / 180);
28156 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28158 var canvas = document.createElement("canvas");
28160 var context = canvas.getContext("2d");
28162 canvas.width = this.minWidth;
28163 canvas.height = this.minHeight;
28165 switch (this.rotate) {
28168 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28169 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28171 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28172 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28174 var targetWidth = this.minWidth - 2 * x;
28175 var targetHeight = this.minHeight - 2 * y;
28179 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28180 scale = targetWidth / width;
28183 if(x > 0 && y == 0){
28184 scale = targetHeight / height;
28187 if(x > 0 && y > 0){
28188 scale = targetWidth / width;
28190 if(width < height){
28191 scale = targetHeight / height;
28195 context.scale(scale, scale);
28197 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28198 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28200 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28201 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28203 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28208 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28209 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28211 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28212 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28214 var targetWidth = this.minWidth - 2 * x;
28215 var targetHeight = this.minHeight - 2 * y;
28219 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28220 scale = targetWidth / width;
28223 if(x > 0 && y == 0){
28224 scale = targetHeight / height;
28227 if(x > 0 && y > 0){
28228 scale = targetWidth / width;
28230 if(width < height){
28231 scale = targetHeight / height;
28235 context.scale(scale, scale);
28237 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28238 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28240 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28241 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28243 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28245 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28250 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28251 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28253 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28254 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28256 var targetWidth = this.minWidth - 2 * x;
28257 var targetHeight = this.minHeight - 2 * y;
28261 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28262 scale = targetWidth / width;
28265 if(x > 0 && y == 0){
28266 scale = targetHeight / height;
28269 if(x > 0 && y > 0){
28270 scale = targetWidth / width;
28272 if(width < height){
28273 scale = targetHeight / height;
28277 context.scale(scale, scale);
28279 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28280 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28282 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28283 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28285 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28286 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28288 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28293 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28294 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28296 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28297 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28299 var targetWidth = this.minWidth - 2 * x;
28300 var targetHeight = this.minHeight - 2 * y;
28304 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28305 scale = targetWidth / width;
28308 if(x > 0 && y == 0){
28309 scale = targetHeight / height;
28312 if(x > 0 && y > 0){
28313 scale = targetWidth / width;
28315 if(width < height){
28316 scale = targetHeight / height;
28320 context.scale(scale, scale);
28322 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28323 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28325 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28326 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28328 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28330 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28337 this.cropData = canvas.toDataURL(this.cropType);
28339 if(this.fireEvent('crop', this, this.cropData) !== false){
28340 this.process(this.file, this.cropData);
28347 setThumbBoxSize : function()
28351 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28352 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28353 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28355 this.minWidth = width;
28356 this.minHeight = height;
28358 if(this.rotate == 90 || this.rotate == 270){
28359 this.minWidth = height;
28360 this.minHeight = width;
28365 width = Math.ceil(this.minWidth * height / this.minHeight);
28367 if(this.minWidth > this.minHeight){
28369 height = Math.ceil(this.minHeight * width / this.minWidth);
28372 this.thumbEl.setStyle({
28373 width : width + 'px',
28374 height : height + 'px'
28381 setThumbBoxPosition : function()
28383 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28384 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28386 this.thumbEl.setLeft(x);
28387 this.thumbEl.setTop(y);
28391 baseRotateLevel : function()
28393 this.baseRotate = 1;
28396 typeof(this.exif) != 'undefined' &&
28397 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28398 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28400 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28403 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28407 baseScaleLevel : function()
28411 if(this.isDocument){
28413 if(this.baseRotate == 6 || this.baseRotate == 8){
28415 height = this.thumbEl.getHeight();
28416 this.baseScale = height / this.imageEl.OriginWidth;
28418 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28419 width = this.thumbEl.getWidth();
28420 this.baseScale = width / this.imageEl.OriginHeight;
28426 height = this.thumbEl.getHeight();
28427 this.baseScale = height / this.imageEl.OriginHeight;
28429 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28430 width = this.thumbEl.getWidth();
28431 this.baseScale = width / this.imageEl.OriginWidth;
28437 if(this.baseRotate == 6 || this.baseRotate == 8){
28439 width = this.thumbEl.getHeight();
28440 this.baseScale = width / this.imageEl.OriginHeight;
28442 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28443 height = this.thumbEl.getWidth();
28444 this.baseScale = height / this.imageEl.OriginHeight;
28447 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28448 height = this.thumbEl.getWidth();
28449 this.baseScale = height / this.imageEl.OriginHeight;
28451 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28452 width = this.thumbEl.getHeight();
28453 this.baseScale = width / this.imageEl.OriginWidth;
28460 width = this.thumbEl.getWidth();
28461 this.baseScale = width / this.imageEl.OriginWidth;
28463 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28464 height = this.thumbEl.getHeight();
28465 this.baseScale = height / this.imageEl.OriginHeight;
28468 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28470 height = this.thumbEl.getHeight();
28471 this.baseScale = height / this.imageEl.OriginHeight;
28473 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28474 width = this.thumbEl.getWidth();
28475 this.baseScale = width / this.imageEl.OriginWidth;
28483 getScaleLevel : function()
28485 return this.baseScale * Math.pow(1.1, this.scale);
28488 onTouchStart : function(e)
28490 if(!this.canvasLoaded){
28491 this.beforeSelectFile(e);
28495 var touches = e.browserEvent.touches;
28501 if(touches.length == 1){
28502 this.onMouseDown(e);
28506 if(touches.length != 2){
28512 for(var i = 0, finger; finger = touches[i]; i++){
28513 coords.push(finger.pageX, finger.pageY);
28516 var x = Math.pow(coords[0] - coords[2], 2);
28517 var y = Math.pow(coords[1] - coords[3], 2);
28519 this.startDistance = Math.sqrt(x + y);
28521 this.startScale = this.scale;
28523 this.pinching = true;
28524 this.dragable = false;
28528 onTouchMove : function(e)
28530 if(!this.pinching && !this.dragable){
28534 var touches = e.browserEvent.touches;
28541 this.onMouseMove(e);
28547 for(var i = 0, finger; finger = touches[i]; i++){
28548 coords.push(finger.pageX, finger.pageY);
28551 var x = Math.pow(coords[0] - coords[2], 2);
28552 var y = Math.pow(coords[1] - coords[3], 2);
28554 this.endDistance = Math.sqrt(x + y);
28556 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28558 if(!this.zoomable()){
28559 this.scale = this.startScale;
28567 onTouchEnd : function(e)
28569 this.pinching = false;
28570 this.dragable = false;
28574 process : function(file, crop)
28577 this.maskEl.mask(this.loadingText);
28580 this.xhr = new XMLHttpRequest();
28582 file.xhr = this.xhr;
28584 this.xhr.open(this.method, this.url, true);
28587 "Accept": "application/json",
28588 "Cache-Control": "no-cache",
28589 "X-Requested-With": "XMLHttpRequest"
28592 for (var headerName in headers) {
28593 var headerValue = headers[headerName];
28595 this.xhr.setRequestHeader(headerName, headerValue);
28601 this.xhr.onload = function()
28603 _this.xhrOnLoad(_this.xhr);
28606 this.xhr.onerror = function()
28608 _this.xhrOnError(_this.xhr);
28611 var formData = new FormData();
28613 formData.append('returnHTML', 'NO');
28616 formData.append('crop', crop);
28619 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28620 formData.append(this.paramName, file, file.name);
28623 if(typeof(file.filename) != 'undefined'){
28624 formData.append('filename', file.filename);
28627 if(typeof(file.mimetype) != 'undefined'){
28628 formData.append('mimetype', file.mimetype);
28631 if(this.fireEvent('arrange', this, formData) != false){
28632 this.xhr.send(formData);
28636 xhrOnLoad : function(xhr)
28639 this.maskEl.unmask();
28642 if (xhr.readyState !== 4) {
28643 this.fireEvent('exception', this, xhr);
28647 var response = Roo.decode(xhr.responseText);
28649 if(!response.success){
28650 this.fireEvent('exception', this, xhr);
28654 var response = Roo.decode(xhr.responseText);
28656 this.fireEvent('upload', this, response);
28660 xhrOnError : function()
28663 this.maskEl.unmask();
28666 Roo.log('xhr on error');
28668 var response = Roo.decode(xhr.responseText);
28674 prepare : function(file)
28677 this.maskEl.mask(this.loadingText);
28683 if(typeof(file) === 'string'){
28684 this.loadCanvas(file);
28688 if(!file || !this.urlAPI){
28693 this.cropType = file.type;
28697 if(this.fireEvent('prepare', this, this.file) != false){
28699 var reader = new FileReader();
28701 reader.onload = function (e) {
28702 if (e.target.error) {
28703 Roo.log(e.target.error);
28707 var buffer = e.target.result,
28708 dataView = new DataView(buffer),
28710 maxOffset = dataView.byteLength - 4,
28714 if (dataView.getUint16(0) === 0xffd8) {
28715 while (offset < maxOffset) {
28716 markerBytes = dataView.getUint16(offset);
28718 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28719 markerLength = dataView.getUint16(offset + 2) + 2;
28720 if (offset + markerLength > dataView.byteLength) {
28721 Roo.log('Invalid meta data: Invalid segment size.');
28725 if(markerBytes == 0xffe1){
28726 _this.parseExifData(
28733 offset += markerLength;
28743 var url = _this.urlAPI.createObjectURL(_this.file);
28745 _this.loadCanvas(url);
28750 reader.readAsArrayBuffer(this.file);
28756 parseExifData : function(dataView, offset, length)
28758 var tiffOffset = offset + 10,
28762 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28763 // No Exif data, might be XMP data instead
28767 // Check for the ASCII code for "Exif" (0x45786966):
28768 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28769 // No Exif data, might be XMP data instead
28772 if (tiffOffset + 8 > dataView.byteLength) {
28773 Roo.log('Invalid Exif data: Invalid segment size.');
28776 // Check for the two null bytes:
28777 if (dataView.getUint16(offset + 8) !== 0x0000) {
28778 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28781 // Check the byte alignment:
28782 switch (dataView.getUint16(tiffOffset)) {
28784 littleEndian = true;
28787 littleEndian = false;
28790 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28793 // Check for the TIFF tag marker (0x002A):
28794 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28795 Roo.log('Invalid Exif data: Missing TIFF marker.');
28798 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28799 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28801 this.parseExifTags(
28804 tiffOffset + dirOffset,
28809 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28814 if (dirOffset + 6 > dataView.byteLength) {
28815 Roo.log('Invalid Exif data: Invalid directory offset.');
28818 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28819 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28820 if (dirEndOffset + 4 > dataView.byteLength) {
28821 Roo.log('Invalid Exif data: Invalid directory size.');
28824 for (i = 0; i < tagsNumber; i += 1) {
28828 dirOffset + 2 + 12 * i, // tag offset
28832 // Return the offset to the next directory:
28833 return dataView.getUint32(dirEndOffset, littleEndian);
28836 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28838 var tag = dataView.getUint16(offset, littleEndian);
28840 this.exif[tag] = this.getExifValue(
28844 dataView.getUint16(offset + 2, littleEndian), // tag type
28845 dataView.getUint32(offset + 4, littleEndian), // tag length
28850 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28852 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28861 Roo.log('Invalid Exif data: Invalid tag type.');
28865 tagSize = tagType.size * length;
28866 // Determine if the value is contained in the dataOffset bytes,
28867 // or if the value at the dataOffset is a pointer to the actual data:
28868 dataOffset = tagSize > 4 ?
28869 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28870 if (dataOffset + tagSize > dataView.byteLength) {
28871 Roo.log('Invalid Exif data: Invalid data offset.');
28874 if (length === 1) {
28875 return tagType.getValue(dataView, dataOffset, littleEndian);
28878 for (i = 0; i < length; i += 1) {
28879 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28882 if (tagType.ascii) {
28884 // Concatenate the chars:
28885 for (i = 0; i < values.length; i += 1) {
28887 // Ignore the terminating NULL byte(s):
28888 if (c === '\u0000') {
28900 Roo.apply(Roo.bootstrap.UploadCropbox, {
28902 'Orientation': 0x0112
28906 1: 0, //'top-left',
28908 3: 180, //'bottom-right',
28909 // 4: 'bottom-left',
28911 6: 90, //'right-top',
28912 // 7: 'right-bottom',
28913 8: 270 //'left-bottom'
28917 // byte, 8-bit unsigned int:
28919 getValue: function (dataView, dataOffset) {
28920 return dataView.getUint8(dataOffset);
28924 // ascii, 8-bit byte:
28926 getValue: function (dataView, dataOffset) {
28927 return String.fromCharCode(dataView.getUint8(dataOffset));
28932 // short, 16 bit int:
28934 getValue: function (dataView, dataOffset, littleEndian) {
28935 return dataView.getUint16(dataOffset, littleEndian);
28939 // long, 32 bit int:
28941 getValue: function (dataView, dataOffset, littleEndian) {
28942 return dataView.getUint32(dataOffset, littleEndian);
28946 // rational = two long values, first is numerator, second is denominator:
28948 getValue: function (dataView, dataOffset, littleEndian) {
28949 return dataView.getUint32(dataOffset, littleEndian) /
28950 dataView.getUint32(dataOffset + 4, littleEndian);
28954 // slong, 32 bit signed int:
28956 getValue: function (dataView, dataOffset, littleEndian) {
28957 return dataView.getInt32(dataOffset, littleEndian);
28961 // srational, two slongs, first is numerator, second is denominator:
28963 getValue: function (dataView, dataOffset, littleEndian) {
28964 return dataView.getInt32(dataOffset, littleEndian) /
28965 dataView.getInt32(dataOffset + 4, littleEndian);
28975 cls : 'btn-group roo-upload-cropbox-rotate-left',
28976 action : 'rotate-left',
28980 cls : 'btn btn-default',
28981 html : '<i class="fa fa-undo"></i>'
28987 cls : 'btn-group roo-upload-cropbox-picture',
28988 action : 'picture',
28992 cls : 'btn btn-default',
28993 html : '<i class="fa fa-picture-o"></i>'
28999 cls : 'btn-group roo-upload-cropbox-rotate-right',
29000 action : 'rotate-right',
29004 cls : 'btn btn-default',
29005 html : '<i class="fa fa-repeat"></i>'
29013 cls : 'btn-group roo-upload-cropbox-rotate-left',
29014 action : 'rotate-left',
29018 cls : 'btn btn-default',
29019 html : '<i class="fa fa-undo"></i>'
29025 cls : 'btn-group roo-upload-cropbox-download',
29026 action : 'download',
29030 cls : 'btn btn-default',
29031 html : '<i class="fa fa-download"></i>'
29037 cls : 'btn-group roo-upload-cropbox-crop',
29042 cls : 'btn btn-default',
29043 html : '<i class="fa fa-crop"></i>'
29049 cls : 'btn-group roo-upload-cropbox-trash',
29054 cls : 'btn btn-default',
29055 html : '<i class="fa fa-trash"></i>'
29061 cls : 'btn-group roo-upload-cropbox-rotate-right',
29062 action : 'rotate-right',
29066 cls : 'btn btn-default',
29067 html : '<i class="fa fa-repeat"></i>'
29075 cls : 'btn-group roo-upload-cropbox-rotate-left',
29076 action : 'rotate-left',
29080 cls : 'btn btn-default',
29081 html : '<i class="fa fa-undo"></i>'
29087 cls : 'btn-group roo-upload-cropbox-rotate-right',
29088 action : 'rotate-right',
29092 cls : 'btn btn-default',
29093 html : '<i class="fa fa-repeat"></i>'
29106 * @class Roo.bootstrap.DocumentManager
29107 * @extends Roo.bootstrap.Component
29108 * Bootstrap DocumentManager class
29109 * @cfg {String} paramName default 'imageUpload'
29110 * @cfg {String} toolTipName default 'filename'
29111 * @cfg {String} method default POST
29112 * @cfg {String} url action url
29113 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29114 * @cfg {Boolean} multiple multiple upload default true
29115 * @cfg {Number} thumbSize default 300
29116 * @cfg {String} fieldLabel
29117 * @cfg {Number} labelWidth default 4
29118 * @cfg {String} labelAlign (left|top) default left
29119 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29120 * @cfg {Number} labellg set the width of label (1-12)
29121 * @cfg {Number} labelmd set the width of label (1-12)
29122 * @cfg {Number} labelsm set the width of label (1-12)
29123 * @cfg {Number} labelxs set the width of label (1-12)
29126 * Create a new DocumentManager
29127 * @param {Object} config The config object
29130 Roo.bootstrap.DocumentManager = function(config){
29131 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29134 this.delegates = [];
29139 * Fire when initial the DocumentManager
29140 * @param {Roo.bootstrap.DocumentManager} this
29145 * inspect selected file
29146 * @param {Roo.bootstrap.DocumentManager} this
29147 * @param {File} file
29152 * Fire when xhr load exception
29153 * @param {Roo.bootstrap.DocumentManager} this
29154 * @param {XMLHttpRequest} xhr
29156 "exception" : true,
29158 * @event afterupload
29159 * Fire when xhr load exception
29160 * @param {Roo.bootstrap.DocumentManager} this
29161 * @param {XMLHttpRequest} xhr
29163 "afterupload" : true,
29166 * prepare the form data
29167 * @param {Roo.bootstrap.DocumentManager} this
29168 * @param {Object} formData
29173 * Fire when remove the file
29174 * @param {Roo.bootstrap.DocumentManager} this
29175 * @param {Object} file
29180 * Fire after refresh the file
29181 * @param {Roo.bootstrap.DocumentManager} this
29186 * Fire after click the image
29187 * @param {Roo.bootstrap.DocumentManager} this
29188 * @param {Object} file
29193 * Fire when upload a image and editable set to true
29194 * @param {Roo.bootstrap.DocumentManager} this
29195 * @param {Object} file
29199 * @event beforeselectfile
29200 * Fire before select file
29201 * @param {Roo.bootstrap.DocumentManager} this
29203 "beforeselectfile" : true,
29206 * Fire before process file
29207 * @param {Roo.bootstrap.DocumentManager} this
29208 * @param {Object} file
29212 * @event previewrendered
29213 * Fire when preview rendered
29214 * @param {Roo.bootstrap.DocumentManager} this
29215 * @param {Object} file
29217 "previewrendered" : true,
29220 "previewResize" : true
29225 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29234 paramName : 'imageUpload',
29235 toolTipName : 'filename',
29238 labelAlign : 'left',
29248 getAutoCreate : function()
29250 var managerWidget = {
29252 cls : 'roo-document-manager',
29256 cls : 'roo-document-manager-selector',
29261 cls : 'roo-document-manager-uploader',
29265 cls : 'roo-document-manager-upload-btn',
29266 html : '<i class="fa fa-plus"></i>'
29277 cls : 'column col-md-12',
29282 if(this.fieldLabel.length){
29287 cls : 'column col-md-12',
29288 html : this.fieldLabel
29292 cls : 'column col-md-12',
29297 if(this.labelAlign == 'left'){
29302 html : this.fieldLabel
29311 if(this.labelWidth > 12){
29312 content[0].style = "width: " + this.labelWidth + 'px';
29315 if(this.labelWidth < 13 && this.labelmd == 0){
29316 this.labelmd = this.labelWidth;
29319 if(this.labellg > 0){
29320 content[0].cls += ' col-lg-' + this.labellg;
29321 content[1].cls += ' col-lg-' + (12 - this.labellg);
29324 if(this.labelmd > 0){
29325 content[0].cls += ' col-md-' + this.labelmd;
29326 content[1].cls += ' col-md-' + (12 - this.labelmd);
29329 if(this.labelsm > 0){
29330 content[0].cls += ' col-sm-' + this.labelsm;
29331 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29334 if(this.labelxs > 0){
29335 content[0].cls += ' col-xs-' + this.labelxs;
29336 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29344 cls : 'row clearfix',
29352 initEvents : function()
29354 this.managerEl = this.el.select('.roo-document-manager', true).first();
29355 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29357 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29358 this.selectorEl.hide();
29361 this.selectorEl.attr('multiple', 'multiple');
29364 this.selectorEl.on('change', this.onFileSelected, this);
29366 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29367 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29369 this.uploader.on('click', this.onUploaderClick, this);
29371 this.renderProgressDialog();
29375 window.addEventListener("resize", function() { _this.refresh(); } );
29377 this.fireEvent('initial', this);
29380 renderProgressDialog : function()
29384 this.progressDialog = new Roo.bootstrap.Modal({
29385 cls : 'roo-document-manager-progress-dialog',
29386 allow_close : false,
29397 btnclick : function() {
29398 _this.uploadCancel();
29404 this.progressDialog.render(Roo.get(document.body));
29406 this.progress = new Roo.bootstrap.Progress({
29407 cls : 'roo-document-manager-progress',
29412 this.progress.render(this.progressDialog.getChildContainer());
29414 this.progressBar = new Roo.bootstrap.ProgressBar({
29415 cls : 'roo-document-manager-progress-bar',
29418 aria_valuemax : 12,
29422 this.progressBar.render(this.progress.getChildContainer());
29425 onUploaderClick : function(e)
29427 e.preventDefault();
29429 if(this.fireEvent('beforeselectfile', this) != false){
29430 this.selectorEl.dom.click();
29435 onFileSelected : function(e)
29437 e.preventDefault();
29439 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29443 Roo.each(this.selectorEl.dom.files, function(file){
29444 if(this.fireEvent('inspect', this, file) != false){
29445 this.files.push(file);
29455 this.selectorEl.dom.value = '';
29457 if(!this.files || !this.files.length){
29461 if(this.boxes > 0 && this.files.length > this.boxes){
29462 this.files = this.files.slice(0, this.boxes);
29465 this.uploader.show();
29467 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29468 this.uploader.hide();
29477 Roo.each(this.files, function(file){
29479 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29480 var f = this.renderPreview(file);
29485 if(file.type.indexOf('image') != -1){
29486 this.delegates.push(
29488 _this.process(file);
29489 }).createDelegate(this)
29497 _this.process(file);
29498 }).createDelegate(this)
29503 this.files = files;
29505 this.delegates = this.delegates.concat(docs);
29507 if(!this.delegates.length){
29512 this.progressBar.aria_valuemax = this.delegates.length;
29519 arrange : function()
29521 if(!this.delegates.length){
29522 this.progressDialog.hide();
29527 var delegate = this.delegates.shift();
29529 this.progressDialog.show();
29531 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29533 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29538 refresh : function()
29540 this.uploader.show();
29542 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29543 this.uploader.hide();
29546 Roo.isTouch ? this.closable(false) : this.closable(true);
29548 this.fireEvent('refresh', this);
29551 onRemove : function(e, el, o)
29553 e.preventDefault();
29555 this.fireEvent('remove', this, o);
29559 remove : function(o)
29563 Roo.each(this.files, function(file){
29564 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29573 this.files = files;
29580 Roo.each(this.files, function(file){
29585 file.target.remove();
29594 onClick : function(e, el, o)
29596 e.preventDefault();
29598 this.fireEvent('click', this, o);
29602 closable : function(closable)
29604 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29606 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29618 xhrOnLoad : function(xhr)
29620 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29624 if (xhr.readyState !== 4) {
29626 this.fireEvent('exception', this, xhr);
29630 var response = Roo.decode(xhr.responseText);
29632 if(!response.success){
29634 this.fireEvent('exception', this, xhr);
29638 var file = this.renderPreview(response.data);
29640 this.files.push(file);
29644 this.fireEvent('afterupload', this, xhr);
29648 xhrOnError : function(xhr)
29650 Roo.log('xhr on error');
29652 var response = Roo.decode(xhr.responseText);
29659 process : function(file)
29661 if(this.fireEvent('process', this, file) !== false){
29662 if(this.editable && file.type.indexOf('image') != -1){
29663 this.fireEvent('edit', this, file);
29667 this.uploadStart(file, false);
29674 uploadStart : function(file, crop)
29676 this.xhr = new XMLHttpRequest();
29678 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29683 file.xhr = this.xhr;
29685 this.managerEl.createChild({
29687 cls : 'roo-document-manager-loading',
29691 tooltip : file.name,
29692 cls : 'roo-document-manager-thumb',
29693 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29699 this.xhr.open(this.method, this.url, true);
29702 "Accept": "application/json",
29703 "Cache-Control": "no-cache",
29704 "X-Requested-With": "XMLHttpRequest"
29707 for (var headerName in headers) {
29708 var headerValue = headers[headerName];
29710 this.xhr.setRequestHeader(headerName, headerValue);
29716 this.xhr.onload = function()
29718 _this.xhrOnLoad(_this.xhr);
29721 this.xhr.onerror = function()
29723 _this.xhrOnError(_this.xhr);
29726 var formData = new FormData();
29728 formData.append('returnHTML', 'NO');
29731 formData.append('crop', crop);
29734 formData.append(this.paramName, file, file.name);
29741 if(this.fireEvent('prepare', this, formData, options) != false){
29743 if(options.manually){
29747 this.xhr.send(formData);
29751 this.uploadCancel();
29754 uploadCancel : function()
29760 this.delegates = [];
29762 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29769 renderPreview : function(file)
29771 if(typeof(file.target) != 'undefined' && file.target){
29775 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29777 var previewEl = this.managerEl.createChild({
29779 cls : 'roo-document-manager-preview',
29783 tooltip : file[this.toolTipName],
29784 cls : 'roo-document-manager-thumb',
29785 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29790 html : '<i class="fa fa-times-circle"></i>'
29795 var close = previewEl.select('button.close', true).first();
29797 close.on('click', this.onRemove, this, file);
29799 file.target = previewEl;
29801 var image = previewEl.select('img', true).first();
29805 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29807 image.on('click', this.onClick, this, file);
29809 this.fireEvent('previewrendered', this, file);
29815 onPreviewLoad : function(file, image)
29817 if(typeof(file.target) == 'undefined' || !file.target){
29821 var width = image.dom.naturalWidth || image.dom.width;
29822 var height = image.dom.naturalHeight || image.dom.height;
29824 if(!this.previewResize) {
29828 if(width > height){
29829 file.target.addClass('wide');
29833 file.target.addClass('tall');
29838 uploadFromSource : function(file, crop)
29840 this.xhr = new XMLHttpRequest();
29842 this.managerEl.createChild({
29844 cls : 'roo-document-manager-loading',
29848 tooltip : file.name,
29849 cls : 'roo-document-manager-thumb',
29850 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29856 this.xhr.open(this.method, this.url, true);
29859 "Accept": "application/json",
29860 "Cache-Control": "no-cache",
29861 "X-Requested-With": "XMLHttpRequest"
29864 for (var headerName in headers) {
29865 var headerValue = headers[headerName];
29867 this.xhr.setRequestHeader(headerName, headerValue);
29873 this.xhr.onload = function()
29875 _this.xhrOnLoad(_this.xhr);
29878 this.xhr.onerror = function()
29880 _this.xhrOnError(_this.xhr);
29883 var formData = new FormData();
29885 formData.append('returnHTML', 'NO');
29887 formData.append('crop', crop);
29889 if(typeof(file.filename) != 'undefined'){
29890 formData.append('filename', file.filename);
29893 if(typeof(file.mimetype) != 'undefined'){
29894 formData.append('mimetype', file.mimetype);
29899 if(this.fireEvent('prepare', this, formData) != false){
29900 this.xhr.send(formData);
29910 * @class Roo.bootstrap.DocumentViewer
29911 * @extends Roo.bootstrap.Component
29912 * Bootstrap DocumentViewer class
29913 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29914 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29917 * Create a new DocumentViewer
29918 * @param {Object} config The config object
29921 Roo.bootstrap.DocumentViewer = function(config){
29922 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29927 * Fire after initEvent
29928 * @param {Roo.bootstrap.DocumentViewer} this
29934 * @param {Roo.bootstrap.DocumentViewer} this
29939 * Fire after download button
29940 * @param {Roo.bootstrap.DocumentViewer} this
29945 * Fire after trash button
29946 * @param {Roo.bootstrap.DocumentViewer} this
29953 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29955 showDownload : true,
29959 getAutoCreate : function()
29963 cls : 'roo-document-viewer',
29967 cls : 'roo-document-viewer-body',
29971 cls : 'roo-document-viewer-thumb',
29975 cls : 'roo-document-viewer-image'
29983 cls : 'roo-document-viewer-footer',
29986 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29990 cls : 'btn-group roo-document-viewer-download',
29994 cls : 'btn btn-default',
29995 html : '<i class="fa fa-download"></i>'
30001 cls : 'btn-group roo-document-viewer-trash',
30005 cls : 'btn btn-default',
30006 html : '<i class="fa fa-trash"></i>'
30019 initEvents : function()
30021 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
30022 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
30024 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
30025 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
30027 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
30028 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
30030 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
30031 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
30033 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
30034 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
30036 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
30037 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
30039 this.bodyEl.on('click', this.onClick, this);
30040 this.downloadBtn.on('click', this.onDownload, this);
30041 this.trashBtn.on('click', this.onTrash, this);
30043 this.downloadBtn.hide();
30044 this.trashBtn.hide();
30046 if(this.showDownload){
30047 this.downloadBtn.show();
30050 if(this.showTrash){
30051 this.trashBtn.show();
30054 if(!this.showDownload && !this.showTrash) {
30055 this.footerEl.hide();
30060 initial : function()
30062 this.fireEvent('initial', this);
30066 onClick : function(e)
30068 e.preventDefault();
30070 this.fireEvent('click', this);
30073 onDownload : function(e)
30075 e.preventDefault();
30077 this.fireEvent('download', this);
30080 onTrash : function(e)
30082 e.preventDefault();
30084 this.fireEvent('trash', this);
30096 * @class Roo.bootstrap.NavProgressBar
30097 * @extends Roo.bootstrap.Component
30098 * Bootstrap NavProgressBar class
30101 * Create a new nav progress bar
30102 * @param {Object} config The config object
30105 Roo.bootstrap.NavProgressBar = function(config){
30106 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30108 this.bullets = this.bullets || [];
30110 // Roo.bootstrap.NavProgressBar.register(this);
30114 * Fires when the active item changes
30115 * @param {Roo.bootstrap.NavProgressBar} this
30116 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30117 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30124 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30129 getAutoCreate : function()
30131 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30135 cls : 'roo-navigation-bar-group',
30139 cls : 'roo-navigation-top-bar'
30143 cls : 'roo-navigation-bullets-bar',
30147 cls : 'roo-navigation-bar'
30154 cls : 'roo-navigation-bottom-bar'
30164 initEvents: function()
30169 onRender : function(ct, position)
30171 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30173 if(this.bullets.length){
30174 Roo.each(this.bullets, function(b){
30183 addItem : function(cfg)
30185 var item = new Roo.bootstrap.NavProgressItem(cfg);
30187 item.parentId = this.id;
30188 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30191 var top = new Roo.bootstrap.Element({
30193 cls : 'roo-navigation-bar-text'
30196 var bottom = new Roo.bootstrap.Element({
30198 cls : 'roo-navigation-bar-text'
30201 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30202 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30204 var topText = new Roo.bootstrap.Element({
30206 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30209 var bottomText = new Roo.bootstrap.Element({
30211 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30214 topText.onRender(top.el, null);
30215 bottomText.onRender(bottom.el, null);
30218 item.bottomEl = bottom;
30221 this.barItems.push(item);
30226 getActive : function()
30228 var active = false;
30230 Roo.each(this.barItems, function(v){
30232 if (!v.isActive()) {
30244 setActiveItem : function(item)
30248 Roo.each(this.barItems, function(v){
30249 if (v.rid == item.rid) {
30253 if (v.isActive()) {
30254 v.setActive(false);
30259 item.setActive(true);
30261 this.fireEvent('changed', this, item, prev);
30264 getBarItem: function(rid)
30268 Roo.each(this.barItems, function(e) {
30269 if (e.rid != rid) {
30280 indexOfItem : function(item)
30284 Roo.each(this.barItems, function(v, i){
30286 if (v.rid != item.rid) {
30297 setActiveNext : function()
30299 var i = this.indexOfItem(this.getActive());
30301 if (i > this.barItems.length) {
30305 this.setActiveItem(this.barItems[i+1]);
30308 setActivePrev : function()
30310 var i = this.indexOfItem(this.getActive());
30316 this.setActiveItem(this.barItems[i-1]);
30319 format : function()
30321 if(!this.barItems.length){
30325 var width = 100 / this.barItems.length;
30327 Roo.each(this.barItems, function(i){
30328 i.el.setStyle('width', width + '%');
30329 i.topEl.el.setStyle('width', width + '%');
30330 i.bottomEl.el.setStyle('width', width + '%');
30339 * Nav Progress Item
30344 * @class Roo.bootstrap.NavProgressItem
30345 * @extends Roo.bootstrap.Component
30346 * Bootstrap NavProgressItem class
30347 * @cfg {String} rid the reference id
30348 * @cfg {Boolean} active (true|false) Is item active default false
30349 * @cfg {Boolean} disabled (true|false) Is item active default false
30350 * @cfg {String} html
30351 * @cfg {String} position (top|bottom) text position default bottom
30352 * @cfg {String} icon show icon instead of number
30355 * Create a new NavProgressItem
30356 * @param {Object} config The config object
30358 Roo.bootstrap.NavProgressItem = function(config){
30359 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30364 * The raw click event for the entire grid.
30365 * @param {Roo.bootstrap.NavProgressItem} this
30366 * @param {Roo.EventObject} e
30373 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30379 position : 'bottom',
30382 getAutoCreate : function()
30384 var iconCls = 'roo-navigation-bar-item-icon';
30386 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30390 cls: 'roo-navigation-bar-item',
30400 cfg.cls += ' active';
30403 cfg.cls += ' disabled';
30409 disable : function()
30411 this.setDisabled(true);
30414 enable : function()
30416 this.setDisabled(false);
30419 initEvents: function()
30421 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30423 this.iconEl.on('click', this.onClick, this);
30426 onClick : function(e)
30428 e.preventDefault();
30434 if(this.fireEvent('click', this, e) === false){
30438 this.parent().setActiveItem(this);
30441 isActive: function ()
30443 return this.active;
30446 setActive : function(state)
30448 if(this.active == state){
30452 this.active = state;
30455 this.el.addClass('active');
30459 this.el.removeClass('active');
30464 setDisabled : function(state)
30466 if(this.disabled == state){
30470 this.disabled = state;
30473 this.el.addClass('disabled');
30477 this.el.removeClass('disabled');
30480 tooltipEl : function()
30482 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30495 * @class Roo.bootstrap.FieldLabel
30496 * @extends Roo.bootstrap.Component
30497 * Bootstrap FieldLabel class
30498 * @cfg {String} html contents of the element
30499 * @cfg {String} tag tag of the element default label
30500 * @cfg {String} cls class of the element
30501 * @cfg {String} target label target
30502 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30503 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30504 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30505 * @cfg {String} iconTooltip default "This field is required"
30506 * @cfg {String} indicatorpos (left|right) default left
30509 * Create a new FieldLabel
30510 * @param {Object} config The config object
30513 Roo.bootstrap.FieldLabel = function(config){
30514 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30519 * Fires after the field has been marked as invalid.
30520 * @param {Roo.form.FieldLabel} this
30521 * @param {String} msg The validation message
30526 * Fires after the field has been validated with no errors.
30527 * @param {Roo.form.FieldLabel} this
30533 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30540 invalidClass : 'has-warning',
30541 validClass : 'has-success',
30542 iconTooltip : 'This field is required',
30543 indicatorpos : 'left',
30545 getAutoCreate : function(){
30548 if (!this.allowBlank) {
30554 cls : 'roo-bootstrap-field-label ' + this.cls,
30559 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30560 tooltip : this.iconTooltip
30569 if(this.indicatorpos == 'right'){
30572 cls : 'roo-bootstrap-field-label ' + this.cls,
30581 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30582 tooltip : this.iconTooltip
30591 initEvents: function()
30593 Roo.bootstrap.Element.superclass.initEvents.call(this);
30595 this.indicator = this.indicatorEl();
30597 if(this.indicator){
30598 this.indicator.removeClass('visible');
30599 this.indicator.addClass('invisible');
30602 Roo.bootstrap.FieldLabel.register(this);
30605 indicatorEl : function()
30607 var indicator = this.el.select('i.roo-required-indicator',true).first();
30618 * Mark this field as valid
30620 markValid : function()
30622 if(this.indicator){
30623 this.indicator.removeClass('visible');
30624 this.indicator.addClass('invisible');
30626 if (Roo.bootstrap.version == 3) {
30627 this.el.removeClass(this.invalidClass);
30628 this.el.addClass(this.validClass);
30630 this.el.removeClass('is-invalid');
30631 this.el.addClass('is-valid');
30635 this.fireEvent('valid', this);
30639 * Mark this field as invalid
30640 * @param {String} msg The validation message
30642 markInvalid : function(msg)
30644 if(this.indicator){
30645 this.indicator.removeClass('invisible');
30646 this.indicator.addClass('visible');
30648 if (Roo.bootstrap.version == 3) {
30649 this.el.removeClass(this.validClass);
30650 this.el.addClass(this.invalidClass);
30652 this.el.removeClass('is-valid');
30653 this.el.addClass('is-invalid');
30657 this.fireEvent('invalid', this, msg);
30663 Roo.apply(Roo.bootstrap.FieldLabel, {
30668 * register a FieldLabel Group
30669 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30671 register : function(label)
30673 if(this.groups.hasOwnProperty(label.target)){
30677 this.groups[label.target] = label;
30681 * fetch a FieldLabel Group based on the target
30682 * @param {string} target
30683 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30685 get: function(target) {
30686 if (typeof(this.groups[target]) == 'undefined') {
30690 return this.groups[target] ;
30699 * page DateSplitField.
30705 * @class Roo.bootstrap.DateSplitField
30706 * @extends Roo.bootstrap.Component
30707 * Bootstrap DateSplitField class
30708 * @cfg {string} fieldLabel - the label associated
30709 * @cfg {Number} labelWidth set the width of label (0-12)
30710 * @cfg {String} labelAlign (top|left)
30711 * @cfg {Boolean} dayAllowBlank (true|false) default false
30712 * @cfg {Boolean} monthAllowBlank (true|false) default false
30713 * @cfg {Boolean} yearAllowBlank (true|false) default false
30714 * @cfg {string} dayPlaceholder
30715 * @cfg {string} monthPlaceholder
30716 * @cfg {string} yearPlaceholder
30717 * @cfg {string} dayFormat default 'd'
30718 * @cfg {string} monthFormat default 'm'
30719 * @cfg {string} yearFormat default 'Y'
30720 * @cfg {Number} labellg set the width of label (1-12)
30721 * @cfg {Number} labelmd set the width of label (1-12)
30722 * @cfg {Number} labelsm set the width of label (1-12)
30723 * @cfg {Number} labelxs set the width of label (1-12)
30727 * Create a new DateSplitField
30728 * @param {Object} config The config object
30731 Roo.bootstrap.DateSplitField = function(config){
30732 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30738 * getting the data of years
30739 * @param {Roo.bootstrap.DateSplitField} this
30740 * @param {Object} years
30745 * getting the data of days
30746 * @param {Roo.bootstrap.DateSplitField} this
30747 * @param {Object} days
30752 * Fires after the field has been marked as invalid.
30753 * @param {Roo.form.Field} this
30754 * @param {String} msg The validation message
30759 * Fires after the field has been validated with no errors.
30760 * @param {Roo.form.Field} this
30766 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30769 labelAlign : 'top',
30771 dayAllowBlank : false,
30772 monthAllowBlank : false,
30773 yearAllowBlank : false,
30774 dayPlaceholder : '',
30775 monthPlaceholder : '',
30776 yearPlaceholder : '',
30780 isFormField : true,
30786 getAutoCreate : function()
30790 cls : 'row roo-date-split-field-group',
30795 cls : 'form-hidden-field roo-date-split-field-group-value',
30801 var labelCls = 'col-md-12';
30802 var contentCls = 'col-md-4';
30804 if(this.fieldLabel){
30808 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30812 html : this.fieldLabel
30817 if(this.labelAlign == 'left'){
30819 if(this.labelWidth > 12){
30820 label.style = "width: " + this.labelWidth + 'px';
30823 if(this.labelWidth < 13 && this.labelmd == 0){
30824 this.labelmd = this.labelWidth;
30827 if(this.labellg > 0){
30828 labelCls = ' col-lg-' + this.labellg;
30829 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30832 if(this.labelmd > 0){
30833 labelCls = ' col-md-' + this.labelmd;
30834 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30837 if(this.labelsm > 0){
30838 labelCls = ' col-sm-' + this.labelsm;
30839 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30842 if(this.labelxs > 0){
30843 labelCls = ' col-xs-' + this.labelxs;
30844 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30848 label.cls += ' ' + labelCls;
30850 cfg.cn.push(label);
30853 Roo.each(['day', 'month', 'year'], function(t){
30856 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30863 inputEl: function ()
30865 return this.el.select('.roo-date-split-field-group-value', true).first();
30868 onRender : function(ct, position)
30872 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30874 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30876 this.dayField = new Roo.bootstrap.ComboBox({
30877 allowBlank : this.dayAllowBlank,
30878 alwaysQuery : true,
30879 displayField : 'value',
30882 forceSelection : true,
30884 placeholder : this.dayPlaceholder,
30885 selectOnFocus : true,
30886 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30887 triggerAction : 'all',
30889 valueField : 'value',
30890 store : new Roo.data.SimpleStore({
30891 data : (function() {
30893 _this.fireEvent('days', _this, days);
30896 fields : [ 'value' ]
30899 select : function (_self, record, index)
30901 _this.setValue(_this.getValue());
30906 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30908 this.monthField = new Roo.bootstrap.MonthField({
30909 after : '<i class=\"fa fa-calendar\"></i>',
30910 allowBlank : this.monthAllowBlank,
30911 placeholder : this.monthPlaceholder,
30914 render : function (_self)
30916 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30917 e.preventDefault();
30921 select : function (_self, oldvalue, newvalue)
30923 _this.setValue(_this.getValue());
30928 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30930 this.yearField = new Roo.bootstrap.ComboBox({
30931 allowBlank : this.yearAllowBlank,
30932 alwaysQuery : true,
30933 displayField : 'value',
30936 forceSelection : true,
30938 placeholder : this.yearPlaceholder,
30939 selectOnFocus : true,
30940 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30941 triggerAction : 'all',
30943 valueField : 'value',
30944 store : new Roo.data.SimpleStore({
30945 data : (function() {
30947 _this.fireEvent('years', _this, years);
30950 fields : [ 'value' ]
30953 select : function (_self, record, index)
30955 _this.setValue(_this.getValue());
30960 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30963 setValue : function(v, format)
30965 this.inputEl.dom.value = v;
30967 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30969 var d = Date.parseDate(v, f);
30976 this.setDay(d.format(this.dayFormat));
30977 this.setMonth(d.format(this.monthFormat));
30978 this.setYear(d.format(this.yearFormat));
30985 setDay : function(v)
30987 this.dayField.setValue(v);
30988 this.inputEl.dom.value = this.getValue();
30993 setMonth : function(v)
30995 this.monthField.setValue(v, true);
30996 this.inputEl.dom.value = this.getValue();
31001 setYear : function(v)
31003 this.yearField.setValue(v);
31004 this.inputEl.dom.value = this.getValue();
31009 getDay : function()
31011 return this.dayField.getValue();
31014 getMonth : function()
31016 return this.monthField.getValue();
31019 getYear : function()
31021 return this.yearField.getValue();
31024 getValue : function()
31026 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
31028 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
31038 this.inputEl.dom.value = '';
31043 validate : function()
31045 var d = this.dayField.validate();
31046 var m = this.monthField.validate();
31047 var y = this.yearField.validate();
31052 (!this.dayAllowBlank && !d) ||
31053 (!this.monthAllowBlank && !m) ||
31054 (!this.yearAllowBlank && !y)
31059 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31068 this.markInvalid();
31073 markValid : function()
31076 var label = this.el.select('label', true).first();
31077 var icon = this.el.select('i.fa-star', true).first();
31083 this.fireEvent('valid', this);
31087 * Mark this field as invalid
31088 * @param {String} msg The validation message
31090 markInvalid : function(msg)
31093 var label = this.el.select('label', true).first();
31094 var icon = this.el.select('i.fa-star', true).first();
31096 if(label && !icon){
31097 this.el.select('.roo-date-split-field-label', true).createChild({
31099 cls : 'text-danger fa fa-lg fa-star',
31100 tooltip : 'This field is required',
31101 style : 'margin-right:5px;'
31105 this.fireEvent('invalid', this, msg);
31108 clearInvalid : function()
31110 var label = this.el.select('label', true).first();
31111 var icon = this.el.select('i.fa-star', true).first();
31117 this.fireEvent('valid', this);
31120 getName: function()
31130 * http://masonry.desandro.com
31132 * The idea is to render all the bricks based on vertical width...
31134 * The original code extends 'outlayer' - we might need to use that....
31140 * @class Roo.bootstrap.LayoutMasonry
31141 * @extends Roo.bootstrap.Component
31142 * Bootstrap Layout Masonry class
31145 * Create a new Element
31146 * @param {Object} config The config object
31149 Roo.bootstrap.LayoutMasonry = function(config){
31151 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31155 Roo.bootstrap.LayoutMasonry.register(this);
31161 * Fire after layout the items
31162 * @param {Roo.bootstrap.LayoutMasonry} this
31163 * @param {Roo.EventObject} e
31170 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31173 * @cfg {Boolean} isLayoutInstant = no animation?
31175 isLayoutInstant : false, // needed?
31178 * @cfg {Number} boxWidth width of the columns
31183 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31188 * @cfg {Number} padWidth padding below box..
31193 * @cfg {Number} gutter gutter width..
31198 * @cfg {Number} maxCols maximum number of columns
31204 * @cfg {Boolean} isAutoInitial defalut true
31206 isAutoInitial : true,
31211 * @cfg {Boolean} isHorizontal defalut false
31213 isHorizontal : false,
31215 currentSize : null,
31221 bricks: null, //CompositeElement
31225 _isLayoutInited : false,
31227 // isAlternative : false, // only use for vertical layout...
31230 * @cfg {Number} alternativePadWidth padding below box..
31232 alternativePadWidth : 50,
31234 selectedBrick : [],
31236 getAutoCreate : function(){
31238 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31242 cls: 'blog-masonary-wrapper ' + this.cls,
31244 cls : 'mas-boxes masonary'
31251 getChildContainer: function( )
31253 if (this.boxesEl) {
31254 return this.boxesEl;
31257 this.boxesEl = this.el.select('.mas-boxes').first();
31259 return this.boxesEl;
31263 initEvents : function()
31267 if(this.isAutoInitial){
31268 Roo.log('hook children rendered');
31269 this.on('childrenrendered', function() {
31270 Roo.log('children rendered');
31276 initial : function()
31278 this.selectedBrick = [];
31280 this.currentSize = this.el.getBox(true);
31282 Roo.EventManager.onWindowResize(this.resize, this);
31284 if(!this.isAutoInitial){
31292 //this.layout.defer(500,this);
31296 resize : function()
31298 var cs = this.el.getBox(true);
31301 this.currentSize.width == cs.width &&
31302 this.currentSize.x == cs.x &&
31303 this.currentSize.height == cs.height &&
31304 this.currentSize.y == cs.y
31306 Roo.log("no change in with or X or Y");
31310 this.currentSize = cs;
31316 layout : function()
31318 this._resetLayout();
31320 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31322 this.layoutItems( isInstant );
31324 this._isLayoutInited = true;
31326 this.fireEvent('layout', this);
31330 _resetLayout : function()
31332 if(this.isHorizontal){
31333 this.horizontalMeasureColumns();
31337 this.verticalMeasureColumns();
31341 verticalMeasureColumns : function()
31343 this.getContainerWidth();
31345 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31346 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31350 var boxWidth = this.boxWidth + this.padWidth;
31352 if(this.containerWidth < this.boxWidth){
31353 boxWidth = this.containerWidth
31356 var containerWidth = this.containerWidth;
31358 var cols = Math.floor(containerWidth / boxWidth);
31360 this.cols = Math.max( cols, 1 );
31362 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31364 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31366 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31368 this.colWidth = boxWidth + avail - this.padWidth;
31370 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31371 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31374 horizontalMeasureColumns : function()
31376 this.getContainerWidth();
31378 var boxWidth = this.boxWidth;
31380 if(this.containerWidth < boxWidth){
31381 boxWidth = this.containerWidth;
31384 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31386 this.el.setHeight(boxWidth);
31390 getContainerWidth : function()
31392 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31395 layoutItems : function( isInstant )
31397 Roo.log(this.bricks);
31399 var items = Roo.apply([], this.bricks);
31401 if(this.isHorizontal){
31402 this._horizontalLayoutItems( items , isInstant );
31406 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31407 // this._verticalAlternativeLayoutItems( items , isInstant );
31411 this._verticalLayoutItems( items , isInstant );
31415 _verticalLayoutItems : function ( items , isInstant)
31417 if ( !items || !items.length ) {
31422 ['xs', 'xs', 'xs', 'tall'],
31423 ['xs', 'xs', 'tall'],
31424 ['xs', 'xs', 'sm'],
31425 ['xs', 'xs', 'xs'],
31431 ['sm', 'xs', 'xs'],
31435 ['tall', 'xs', 'xs', 'xs'],
31436 ['tall', 'xs', 'xs'],
31448 Roo.each(items, function(item, k){
31450 switch (item.size) {
31451 // these layouts take up a full box,
31462 boxes.push([item]);
31485 var filterPattern = function(box, length)
31493 var pattern = box.slice(0, length);
31497 Roo.each(pattern, function(i){
31498 format.push(i.size);
31501 Roo.each(standard, function(s){
31503 if(String(s) != String(format)){
31512 if(!match && length == 1){
31517 filterPattern(box, length - 1);
31521 queue.push(pattern);
31523 box = box.slice(length, box.length);
31525 filterPattern(box, 4);
31531 Roo.each(boxes, function(box, k){
31537 if(box.length == 1){
31542 filterPattern(box, 4);
31546 this._processVerticalLayoutQueue( queue, isInstant );
31550 // _verticalAlternativeLayoutItems : function( items , isInstant )
31552 // if ( !items || !items.length ) {
31556 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31560 _horizontalLayoutItems : function ( items , isInstant)
31562 if ( !items || !items.length || items.length < 3) {
31568 var eItems = items.slice(0, 3);
31570 items = items.slice(3, items.length);
31573 ['xs', 'xs', 'xs', 'wide'],
31574 ['xs', 'xs', 'wide'],
31575 ['xs', 'xs', 'sm'],
31576 ['xs', 'xs', 'xs'],
31582 ['sm', 'xs', 'xs'],
31586 ['wide', 'xs', 'xs', 'xs'],
31587 ['wide', 'xs', 'xs'],
31600 Roo.each(items, function(item, k){
31602 switch (item.size) {
31613 boxes.push([item]);
31637 var filterPattern = function(box, length)
31645 var pattern = box.slice(0, length);
31649 Roo.each(pattern, function(i){
31650 format.push(i.size);
31653 Roo.each(standard, function(s){
31655 if(String(s) != String(format)){
31664 if(!match && length == 1){
31669 filterPattern(box, length - 1);
31673 queue.push(pattern);
31675 box = box.slice(length, box.length);
31677 filterPattern(box, 4);
31683 Roo.each(boxes, function(box, k){
31689 if(box.length == 1){
31694 filterPattern(box, 4);
31701 var pos = this.el.getBox(true);
31705 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31707 var hit_end = false;
31709 Roo.each(queue, function(box){
31713 Roo.each(box, function(b){
31715 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31725 Roo.each(box, function(b){
31727 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31730 mx = Math.max(mx, b.x);
31734 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31738 Roo.each(box, function(b){
31740 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31754 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31757 /** Sets position of item in DOM
31758 * @param {Element} item
31759 * @param {Number} x - horizontal position
31760 * @param {Number} y - vertical position
31761 * @param {Boolean} isInstant - disables transitions
31763 _processVerticalLayoutQueue : function( queue, isInstant )
31765 var pos = this.el.getBox(true);
31770 for (var i = 0; i < this.cols; i++){
31774 Roo.each(queue, function(box, k){
31776 var col = k % this.cols;
31778 Roo.each(box, function(b,kk){
31780 b.el.position('absolute');
31782 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31783 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31785 if(b.size == 'md-left' || b.size == 'md-right'){
31786 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31787 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31790 b.el.setWidth(width);
31791 b.el.setHeight(height);
31793 b.el.select('iframe',true).setSize(width,height);
31797 for (var i = 0; i < this.cols; i++){
31799 if(maxY[i] < maxY[col]){
31804 col = Math.min(col, i);
31808 x = pos.x + col * (this.colWidth + this.padWidth);
31812 var positions = [];
31814 switch (box.length){
31816 positions = this.getVerticalOneBoxColPositions(x, y, box);
31819 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31822 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31825 positions = this.getVerticalFourBoxColPositions(x, y, box);
31831 Roo.each(box, function(b,kk){
31833 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31835 var sz = b.el.getSize();
31837 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31845 for (var i = 0; i < this.cols; i++){
31846 mY = Math.max(mY, maxY[i]);
31849 this.el.setHeight(mY - pos.y);
31853 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31855 // var pos = this.el.getBox(true);
31858 // var maxX = pos.right;
31860 // var maxHeight = 0;
31862 // Roo.each(items, function(item, k){
31866 // item.el.position('absolute');
31868 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31870 // item.el.setWidth(width);
31872 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31874 // item.el.setHeight(height);
31877 // item.el.setXY([x, y], isInstant ? false : true);
31879 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31882 // y = y + height + this.alternativePadWidth;
31884 // maxHeight = maxHeight + height + this.alternativePadWidth;
31888 // this.el.setHeight(maxHeight);
31892 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31894 var pos = this.el.getBox(true);
31899 var maxX = pos.right;
31901 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31903 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31905 Roo.each(queue, function(box, k){
31907 Roo.each(box, function(b, kk){
31909 b.el.position('absolute');
31911 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31912 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31914 if(b.size == 'md-left' || b.size == 'md-right'){
31915 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31916 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31919 b.el.setWidth(width);
31920 b.el.setHeight(height);
31928 var positions = [];
31930 switch (box.length){
31932 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31935 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31938 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31941 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31947 Roo.each(box, function(b,kk){
31949 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31951 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31959 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31961 Roo.each(eItems, function(b,k){
31963 b.size = (k == 0) ? 'sm' : 'xs';
31964 b.x = (k == 0) ? 2 : 1;
31965 b.y = (k == 0) ? 2 : 1;
31967 b.el.position('absolute');
31969 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31971 b.el.setWidth(width);
31973 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31975 b.el.setHeight(height);
31979 var positions = [];
31982 x : maxX - this.unitWidth * 2 - this.gutter,
31987 x : maxX - this.unitWidth,
31988 y : minY + (this.unitWidth + this.gutter) * 2
31992 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31996 Roo.each(eItems, function(b,k){
31998 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
32004 getVerticalOneBoxColPositions : function(x, y, box)
32008 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
32010 if(box[0].size == 'md-left'){
32014 if(box[0].size == 'md-right'){
32019 x : x + (this.unitWidth + this.gutter) * rand,
32026 getVerticalTwoBoxColPositions : function(x, y, box)
32030 if(box[0].size == 'xs'){
32034 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
32038 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32052 x : x + (this.unitWidth + this.gutter) * 2,
32053 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32060 getVerticalThreeBoxColPositions : function(x, y, box)
32064 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32072 x : x + (this.unitWidth + this.gutter) * 1,
32077 x : x + (this.unitWidth + this.gutter) * 2,
32085 if(box[0].size == 'xs' && box[1].size == 'xs'){
32094 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32098 x : x + (this.unitWidth + this.gutter) * 1,
32112 x : x + (this.unitWidth + this.gutter) * 2,
32117 x : x + (this.unitWidth + this.gutter) * 2,
32118 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32125 getVerticalFourBoxColPositions : function(x, y, box)
32129 if(box[0].size == 'xs'){
32138 y : y + (this.unitHeight + this.gutter) * 1
32143 y : y + (this.unitHeight + this.gutter) * 2
32147 x : x + (this.unitWidth + this.gutter) * 1,
32161 x : x + (this.unitWidth + this.gutter) * 2,
32166 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32167 y : y + (this.unitHeight + this.gutter) * 1
32171 x : x + (this.unitWidth + this.gutter) * 2,
32172 y : y + (this.unitWidth + this.gutter) * 2
32179 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32183 if(box[0].size == 'md-left'){
32185 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32192 if(box[0].size == 'md-right'){
32194 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32195 y : minY + (this.unitWidth + this.gutter) * 1
32201 var rand = Math.floor(Math.random() * (4 - box[0].y));
32204 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32205 y : minY + (this.unitWidth + this.gutter) * rand
32212 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32216 if(box[0].size == 'xs'){
32219 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32224 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32225 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32233 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32238 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32239 y : minY + (this.unitWidth + this.gutter) * 2
32246 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32250 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32253 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32258 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32259 y : minY + (this.unitWidth + this.gutter) * 1
32263 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32264 y : minY + (this.unitWidth + this.gutter) * 2
32271 if(box[0].size == 'xs' && box[1].size == 'xs'){
32274 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32279 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32284 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32285 y : minY + (this.unitWidth + this.gutter) * 1
32293 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32298 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32299 y : minY + (this.unitWidth + this.gutter) * 2
32303 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32304 y : minY + (this.unitWidth + this.gutter) * 2
32311 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32315 if(box[0].size == 'xs'){
32318 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32323 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32328 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32333 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32334 y : minY + (this.unitWidth + this.gutter) * 1
32342 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32347 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32348 y : minY + (this.unitWidth + this.gutter) * 2
32352 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32353 y : minY + (this.unitWidth + this.gutter) * 2
32357 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1) - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32358 y : minY + (this.unitWidth + this.gutter) * 2
32366 * remove a Masonry Brick
32367 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32369 removeBrick : function(brick_id)
32375 for (var i = 0; i<this.bricks.length; i++) {
32376 if (this.bricks[i].id == brick_id) {
32377 this.bricks.splice(i,1);
32378 this.el.dom.removeChild(Roo.get(brick_id).dom);
32385 * adds a Masonry Brick
32386 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32388 addBrick : function(cfg)
32390 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32391 //this.register(cn);
32392 cn.parentId = this.id;
32393 cn.render(this.el);
32398 * register a Masonry Brick
32399 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32402 register : function(brick)
32404 this.bricks.push(brick);
32405 brick.masonryId = this.id;
32409 * clear all the Masonry Brick
32411 clearAll : function()
32414 //this.getChildContainer().dom.innerHTML = "";
32415 this.el.dom.innerHTML = '';
32418 getSelected : function()
32420 if (!this.selectedBrick) {
32424 return this.selectedBrick;
32428 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32432 * register a Masonry Layout
32433 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32436 register : function(layout)
32438 this.groups[layout.id] = layout;
32441 * fetch a Masonry Layout based on the masonry layout ID
32442 * @param {string} the masonry layout to add
32443 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32446 get: function(layout_id) {
32447 if (typeof(this.groups[layout_id]) == 'undefined') {
32450 return this.groups[layout_id] ;
32462 * http://masonry.desandro.com
32464 * The idea is to render all the bricks based on vertical width...
32466 * The original code extends 'outlayer' - we might need to use that....
32472 * @class Roo.bootstrap.LayoutMasonryAuto
32473 * @extends Roo.bootstrap.Component
32474 * Bootstrap Layout Masonry class
32477 * Create a new Element
32478 * @param {Object} config The config object
32481 Roo.bootstrap.LayoutMasonryAuto = function(config){
32482 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32485 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32488 * @cfg {Boolean} isFitWidth - resize the width..
32490 isFitWidth : false, // options..
32492 * @cfg {Boolean} isOriginLeft = left align?
32494 isOriginLeft : true,
32496 * @cfg {Boolean} isOriginTop = top align?
32498 isOriginTop : false,
32500 * @cfg {Boolean} isLayoutInstant = no animation?
32502 isLayoutInstant : false, // needed?
32504 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32506 isResizingContainer : true,
32508 * @cfg {Number} columnWidth width of the columns
32514 * @cfg {Number} maxCols maximum number of columns
32519 * @cfg {Number} padHeight padding below box..
32525 * @cfg {Boolean} isAutoInitial defalut true
32528 isAutoInitial : true,
32534 initialColumnWidth : 0,
32535 currentSize : null,
32537 colYs : null, // array.
32544 bricks: null, //CompositeElement
32545 cols : 0, // array?
32546 // element : null, // wrapped now this.el
32547 _isLayoutInited : null,
32550 getAutoCreate : function(){
32554 cls: 'blog-masonary-wrapper ' + this.cls,
32556 cls : 'mas-boxes masonary'
32563 getChildContainer: function( )
32565 if (this.boxesEl) {
32566 return this.boxesEl;
32569 this.boxesEl = this.el.select('.mas-boxes').first();
32571 return this.boxesEl;
32575 initEvents : function()
32579 if(this.isAutoInitial){
32580 Roo.log('hook children rendered');
32581 this.on('childrenrendered', function() {
32582 Roo.log('children rendered');
32589 initial : function()
32591 this.reloadItems();
32593 this.currentSize = this.el.getBox(true);
32595 /// was window resize... - let's see if this works..
32596 Roo.EventManager.onWindowResize(this.resize, this);
32598 if(!this.isAutoInitial){
32603 this.layout.defer(500,this);
32606 reloadItems: function()
32608 this.bricks = this.el.select('.masonry-brick', true);
32610 this.bricks.each(function(b) {
32611 //Roo.log(b.getSize());
32612 if (!b.attr('originalwidth')) {
32613 b.attr('originalwidth', b.getSize().width);
32618 Roo.log(this.bricks.elements.length);
32621 resize : function()
32624 var cs = this.el.getBox(true);
32626 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32627 Roo.log("no change in with or X");
32630 this.currentSize = cs;
32634 layout : function()
32637 this._resetLayout();
32638 //this._manageStamps();
32640 // don't animate first layout
32641 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32642 this.layoutItems( isInstant );
32644 // flag for initalized
32645 this._isLayoutInited = true;
32648 layoutItems : function( isInstant )
32650 //var items = this._getItemsForLayout( this.items );
32651 // original code supports filtering layout items.. we just ignore it..
32653 this._layoutItems( this.bricks , isInstant );
32655 this._postLayout();
32657 _layoutItems : function ( items , isInstant)
32659 //this.fireEvent( 'layout', this, items );
32662 if ( !items || !items.elements.length ) {
32663 // no items, emit event with empty array
32668 items.each(function(item) {
32669 Roo.log("layout item");
32671 // get x/y object from method
32672 var position = this._getItemLayoutPosition( item );
32674 position.item = item;
32675 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32676 queue.push( position );
32679 this._processLayoutQueue( queue );
32681 /** Sets position of item in DOM
32682 * @param {Element} item
32683 * @param {Number} x - horizontal position
32684 * @param {Number} y - vertical position
32685 * @param {Boolean} isInstant - disables transitions
32687 _processLayoutQueue : function( queue )
32689 for ( var i=0, len = queue.length; i < len; i++ ) {
32690 var obj = queue[i];
32691 obj.item.position('absolute');
32692 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32698 * Any logic you want to do after each layout,
32699 * i.e. size the container
32701 _postLayout : function()
32703 this.resizeContainer();
32706 resizeContainer : function()
32708 if ( !this.isResizingContainer ) {
32711 var size = this._getContainerSize();
32713 this.el.setSize(size.width,size.height);
32714 this.boxesEl.setSize(size.width,size.height);
32720 _resetLayout : function()
32722 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32723 this.colWidth = this.el.getWidth();
32724 //this.gutter = this.el.getWidth();
32726 this.measureColumns();
32732 this.colYs.push( 0 );
32738 measureColumns : function()
32740 this.getContainerWidth();
32741 // if columnWidth is 0, default to outerWidth of first item
32742 if ( !this.columnWidth ) {
32743 var firstItem = this.bricks.first();
32744 Roo.log(firstItem);
32745 this.columnWidth = this.containerWidth;
32746 if (firstItem && firstItem.attr('originalwidth') ) {
32747 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32749 // columnWidth fall back to item of first element
32750 Roo.log("set column width?");
32751 this.initialColumnWidth = this.columnWidth ;
32753 // if first elem has no width, default to size of container
32758 if (this.initialColumnWidth) {
32759 this.columnWidth = this.initialColumnWidth;
32764 // column width is fixed at the top - however if container width get's smaller we should
32767 // this bit calcs how man columns..
32769 var columnWidth = this.columnWidth += this.gutter;
32771 // calculate columns
32772 var containerWidth = this.containerWidth + this.gutter;
32774 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32775 // fix rounding errors, typically with gutters
32776 var excess = columnWidth - containerWidth % columnWidth;
32779 // if overshoot is less than a pixel, round up, otherwise floor it
32780 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32781 cols = Math[ mathMethod ]( cols );
32782 this.cols = Math.max( cols, 1 );
32783 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32785 // padding positioning..
32786 var totalColWidth = this.cols * this.columnWidth;
32787 var padavail = this.containerWidth - totalColWidth;
32788 // so for 2 columns - we need 3 'pads'
32790 var padNeeded = (1+this.cols) * this.padWidth;
32792 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32794 this.columnWidth += padExtra
32795 //this.padWidth = Math.floor(padavail / ( this.cols));
32797 // adjust colum width so that padding is fixed??
32799 // we have 3 columns ... total = width * 3
32800 // we have X left over... that should be used by
32802 //if (this.expandC) {
32810 getContainerWidth : function()
32812 /* // container is parent if fit width
32813 var container = this.isFitWidth ? this.element.parentNode : this.element;
32814 // check that this.size and size are there
32815 // IE8 triggers resize on body size change, so they might not be
32817 var size = getSize( container ); //FIXME
32818 this.containerWidth = size && size.innerWidth; //FIXME
32821 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32825 _getItemLayoutPosition : function( item ) // what is item?
32827 // we resize the item to our columnWidth..
32829 item.setWidth(this.columnWidth);
32830 item.autoBoxAdjust = false;
32832 var sz = item.getSize();
32834 // how many columns does this brick span
32835 var remainder = this.containerWidth % this.columnWidth;
32837 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32838 // round if off by 1 pixel, otherwise use ceil
32839 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32840 colSpan = Math.min( colSpan, this.cols );
32842 // normally this should be '1' as we dont' currently allow multi width columns..
32844 var colGroup = this._getColGroup( colSpan );
32845 // get the minimum Y value from the columns
32846 var minimumY = Math.min.apply( Math, colGroup );
32847 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32849 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32851 // position the brick
32853 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32854 y: this.currentSize.y + minimumY + this.padHeight
32858 // apply setHeight to necessary columns
32859 var setHeight = minimumY + sz.height + this.padHeight;
32860 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32862 var setSpan = this.cols + 1 - colGroup.length;
32863 for ( var i = 0; i < setSpan; i++ ) {
32864 this.colYs[ shortColIndex + i ] = setHeight ;
32871 * @param {Number} colSpan - number of columns the element spans
32872 * @returns {Array} colGroup
32874 _getColGroup : function( colSpan )
32876 if ( colSpan < 2 ) {
32877 // if brick spans only one column, use all the column Ys
32882 // how many different places could this brick fit horizontally
32883 var groupCount = this.cols + 1 - colSpan;
32884 // for each group potential horizontal position
32885 for ( var i = 0; i < groupCount; i++ ) {
32886 // make an array of colY values for that one group
32887 var groupColYs = this.colYs.slice( i, i + colSpan );
32888 // and get the max value of the array
32889 colGroup[i] = Math.max.apply( Math, groupColYs );
32894 _manageStamp : function( stamp )
32896 var stampSize = stamp.getSize();
32897 var offset = stamp.getBox();
32898 // get the columns that this stamp affects
32899 var firstX = this.isOriginLeft ? offset.x : offset.right;
32900 var lastX = firstX + stampSize.width;
32901 var firstCol = Math.floor( firstX / this.columnWidth );
32902 firstCol = Math.max( 0, firstCol );
32904 var lastCol = Math.floor( lastX / this.columnWidth );
32905 // lastCol should not go over if multiple of columnWidth #425
32906 lastCol -= lastX % this.columnWidth ? 0 : 1;
32907 lastCol = Math.min( this.cols - 1, lastCol );
32909 // set colYs to bottom of the stamp
32910 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32913 for ( var i = firstCol; i <= lastCol; i++ ) {
32914 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32919 _getContainerSize : function()
32921 this.maxY = Math.max.apply( Math, this.colYs );
32926 if ( this.isFitWidth ) {
32927 size.width = this._getContainerFitWidth();
32933 _getContainerFitWidth : function()
32935 var unusedCols = 0;
32936 // count unused columns
32939 if ( this.colYs[i] !== 0 ) {
32944 // fit container to columns that have been used
32945 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32948 needsResizeLayout : function()
32950 var previousWidth = this.containerWidth;
32951 this.getContainerWidth();
32952 return previousWidth !== this.containerWidth;
32967 * @class Roo.bootstrap.MasonryBrick
32968 * @extends Roo.bootstrap.Component
32969 * Bootstrap MasonryBrick class
32972 * Create a new MasonryBrick
32973 * @param {Object} config The config object
32976 Roo.bootstrap.MasonryBrick = function(config){
32978 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32980 Roo.bootstrap.MasonryBrick.register(this);
32986 * When a MasonryBrick is clcik
32987 * @param {Roo.bootstrap.MasonryBrick} this
32988 * @param {Roo.EventObject} e
32994 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32997 * @cfg {String} title
33001 * @cfg {String} html
33005 * @cfg {String} bgimage
33009 * @cfg {String} videourl
33013 * @cfg {String} cls
33017 * @cfg {String} href
33021 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
33026 * @cfg {String} placetitle (center|bottom)
33031 * @cfg {Boolean} isFitContainer defalut true
33033 isFitContainer : true,
33036 * @cfg {Boolean} preventDefault defalut false
33038 preventDefault : false,
33041 * @cfg {Boolean} inverse defalut false
33043 maskInverse : false,
33045 getAutoCreate : function()
33047 if(!this.isFitContainer){
33048 return this.getSplitAutoCreate();
33051 var cls = 'masonry-brick masonry-brick-full';
33053 if(this.href.length){
33054 cls += ' masonry-brick-link';
33057 if(this.bgimage.length){
33058 cls += ' masonry-brick-image';
33061 if(this.maskInverse){
33062 cls += ' mask-inverse';
33065 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33066 cls += ' enable-mask';
33070 cls += ' masonry-' + this.size + '-brick';
33073 if(this.placetitle.length){
33075 switch (this.placetitle) {
33077 cls += ' masonry-center-title';
33080 cls += ' masonry-bottom-title';
33087 if(!this.html.length && !this.bgimage.length){
33088 cls += ' masonry-center-title';
33091 if(!this.html.length && this.bgimage.length){
33092 cls += ' masonry-bottom-title';
33097 cls += ' ' + this.cls;
33101 tag: (this.href.length) ? 'a' : 'div',
33106 cls: 'masonry-brick-mask'
33110 cls: 'masonry-brick-paragraph',
33116 if(this.href.length){
33117 cfg.href = this.href;
33120 var cn = cfg.cn[1].cn;
33122 if(this.title.length){
33125 cls: 'masonry-brick-title',
33130 if(this.html.length){
33133 cls: 'masonry-brick-text',
33138 if (!this.title.length && !this.html.length) {
33139 cfg.cn[1].cls += ' hide';
33142 if(this.bgimage.length){
33145 cls: 'masonry-brick-image-view',
33150 if(this.videourl.length){
33151 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33152 // youtube support only?
33155 cls: 'masonry-brick-image-view',
33158 allowfullscreen : true
33166 getSplitAutoCreate : function()
33168 var cls = 'masonry-brick masonry-brick-split';
33170 if(this.href.length){
33171 cls += ' masonry-brick-link';
33174 if(this.bgimage.length){
33175 cls += ' masonry-brick-image';
33179 cls += ' masonry-' + this.size + '-brick';
33182 switch (this.placetitle) {
33184 cls += ' masonry-center-title';
33187 cls += ' masonry-bottom-title';
33190 if(!this.bgimage.length){
33191 cls += ' masonry-center-title';
33194 if(this.bgimage.length){
33195 cls += ' masonry-bottom-title';
33201 cls += ' ' + this.cls;
33205 tag: (this.href.length) ? 'a' : 'div',
33210 cls: 'masonry-brick-split-head',
33214 cls: 'masonry-brick-paragraph',
33221 cls: 'masonry-brick-split-body',
33227 if(this.href.length){
33228 cfg.href = this.href;
33231 if(this.title.length){
33232 cfg.cn[0].cn[0].cn.push({
33234 cls: 'masonry-brick-title',
33239 if(this.html.length){
33240 cfg.cn[1].cn.push({
33242 cls: 'masonry-brick-text',
33247 if(this.bgimage.length){
33248 cfg.cn[0].cn.push({
33250 cls: 'masonry-brick-image-view',
33255 if(this.videourl.length){
33256 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33257 // youtube support only?
33258 cfg.cn[0].cn.cn.push({
33260 cls: 'masonry-brick-image-view',
33263 allowfullscreen : true
33270 initEvents: function()
33272 switch (this.size) {
33305 this.el.on('touchstart', this.onTouchStart, this);
33306 this.el.on('touchmove', this.onTouchMove, this);
33307 this.el.on('touchend', this.onTouchEnd, this);
33308 this.el.on('contextmenu', this.onContextMenu, this);
33310 this.el.on('mouseenter' ,this.enter, this);
33311 this.el.on('mouseleave', this.leave, this);
33312 this.el.on('click', this.onClick, this);
33315 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33316 this.parent().bricks.push(this);
33321 onClick: function(e, el)
33323 var time = this.endTimer - this.startTimer;
33324 // Roo.log(e.preventDefault());
33327 e.preventDefault();
33332 if(!this.preventDefault){
33336 e.preventDefault();
33338 if (this.activeClass != '') {
33339 this.selectBrick();
33342 this.fireEvent('click', this, e);
33345 enter: function(e, el)
33347 e.preventDefault();
33349 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33353 if(this.bgimage.length && this.html.length){
33354 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33358 leave: function(e, el)
33360 e.preventDefault();
33362 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33366 if(this.bgimage.length && this.html.length){
33367 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33371 onTouchStart: function(e, el)
33373 // e.preventDefault();
33375 this.touchmoved = false;
33377 if(!this.isFitContainer){
33381 if(!this.bgimage.length || !this.html.length){
33385 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33387 this.timer = new Date().getTime();
33391 onTouchMove: function(e, el)
33393 this.touchmoved = true;
33396 onContextMenu : function(e,el)
33398 e.preventDefault();
33399 e.stopPropagation();
33403 onTouchEnd: function(e, el)
33405 // e.preventDefault();
33407 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33414 if(!this.bgimage.length || !this.html.length){
33416 if(this.href.length){
33417 window.location.href = this.href;
33423 if(!this.isFitContainer){
33427 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33429 window.location.href = this.href;
33432 //selection on single brick only
33433 selectBrick : function() {
33435 if (!this.parentId) {
33439 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33440 var index = m.selectedBrick.indexOf(this.id);
33443 m.selectedBrick.splice(index,1);
33444 this.el.removeClass(this.activeClass);
33448 for(var i = 0; i < m.selectedBrick.length; i++) {
33449 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33450 b.el.removeClass(b.activeClass);
33453 m.selectedBrick = [];
33455 m.selectedBrick.push(this.id);
33456 this.el.addClass(this.activeClass);
33460 isSelected : function(){
33461 return this.el.hasClass(this.activeClass);
33466 Roo.apply(Roo.bootstrap.MasonryBrick, {
33469 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33471 * register a Masonry Brick
33472 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33475 register : function(brick)
33477 //this.groups[brick.id] = brick;
33478 this.groups.add(brick.id, brick);
33481 * fetch a masonry brick based on the masonry brick ID
33482 * @param {string} the masonry brick to add
33483 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33486 get: function(brick_id)
33488 // if (typeof(this.groups[brick_id]) == 'undefined') {
33491 // return this.groups[brick_id] ;
33493 if(this.groups.key(brick_id)) {
33494 return this.groups.key(brick_id);
33512 * @class Roo.bootstrap.Brick
33513 * @extends Roo.bootstrap.Component
33514 * Bootstrap Brick class
33517 * Create a new Brick
33518 * @param {Object} config The config object
33521 Roo.bootstrap.Brick = function(config){
33522 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33528 * When a Brick is click
33529 * @param {Roo.bootstrap.Brick} this
33530 * @param {Roo.EventObject} e
33536 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33539 * @cfg {String} title
33543 * @cfg {String} html
33547 * @cfg {String} bgimage
33551 * @cfg {String} cls
33555 * @cfg {String} href
33559 * @cfg {String} video
33563 * @cfg {Boolean} square
33567 getAutoCreate : function()
33569 var cls = 'roo-brick';
33571 if(this.href.length){
33572 cls += ' roo-brick-link';
33575 if(this.bgimage.length){
33576 cls += ' roo-brick-image';
33579 if(!this.html.length && !this.bgimage.length){
33580 cls += ' roo-brick-center-title';
33583 if(!this.html.length && this.bgimage.length){
33584 cls += ' roo-brick-bottom-title';
33588 cls += ' ' + this.cls;
33592 tag: (this.href.length) ? 'a' : 'div',
33597 cls: 'roo-brick-paragraph',
33603 if(this.href.length){
33604 cfg.href = this.href;
33607 var cn = cfg.cn[0].cn;
33609 if(this.title.length){
33612 cls: 'roo-brick-title',
33617 if(this.html.length){
33620 cls: 'roo-brick-text',
33627 if(this.bgimage.length){
33630 cls: 'roo-brick-image-view',
33638 initEvents: function()
33640 if(this.title.length || this.html.length){
33641 this.el.on('mouseenter' ,this.enter, this);
33642 this.el.on('mouseleave', this.leave, this);
33645 Roo.EventManager.onWindowResize(this.resize, this);
33647 if(this.bgimage.length){
33648 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33649 this.imageEl.on('load', this.onImageLoad, this);
33656 onImageLoad : function()
33661 resize : function()
33663 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33665 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33667 if(this.bgimage.length){
33668 var image = this.el.select('.roo-brick-image-view', true).first();
33670 image.setWidth(paragraph.getWidth());
33673 image.setHeight(paragraph.getWidth());
33676 this.el.setHeight(image.getHeight());
33677 paragraph.setHeight(image.getHeight());
33683 enter: function(e, el)
33685 e.preventDefault();
33687 if(this.bgimage.length){
33688 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33689 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33693 leave: function(e, el)
33695 e.preventDefault();
33697 if(this.bgimage.length){
33698 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33699 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33714 * @class Roo.bootstrap.NumberField
33715 * @extends Roo.bootstrap.Input
33716 * Bootstrap NumberField class
33722 * Create a new NumberField
33723 * @param {Object} config The config object
33726 Roo.bootstrap.NumberField = function(config){
33727 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33730 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33733 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33735 allowDecimals : true,
33737 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33739 decimalSeparator : ".",
33741 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33743 decimalPrecision : 2,
33745 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33747 allowNegative : true,
33750 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33754 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33756 minValue : Number.NEGATIVE_INFINITY,
33758 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33760 maxValue : Number.MAX_VALUE,
33762 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33764 minText : "The minimum value for this field is {0}",
33766 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33768 maxText : "The maximum value for this field is {0}",
33770 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33771 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33773 nanText : "{0} is not a valid number",
33775 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33777 thousandsDelimiter : false,
33779 * @cfg {String} valueAlign alignment of value
33781 valueAlign : "left",
33783 getAutoCreate : function()
33785 var hiddenInput = {
33789 cls: 'hidden-number-input'
33793 hiddenInput.name = this.name;
33798 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33800 this.name = hiddenInput.name;
33802 if(cfg.cn.length > 0) {
33803 cfg.cn.push(hiddenInput);
33810 initEvents : function()
33812 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33814 var allowed = "0123456789";
33816 if(this.allowDecimals){
33817 allowed += this.decimalSeparator;
33820 if(this.allowNegative){
33824 if(this.thousandsDelimiter) {
33828 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33830 var keyPress = function(e){
33832 var k = e.getKey();
33834 var c = e.getCharCode();
33837 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33838 allowed.indexOf(String.fromCharCode(c)) === -1
33844 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33848 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33853 this.el.on("keypress", keyPress, this);
33856 validateValue : function(value)
33859 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33863 var num = this.parseValue(value);
33866 this.markInvalid(String.format(this.nanText, value));
33870 if(num < this.minValue){
33871 this.markInvalid(String.format(this.minText, this.minValue));
33875 if(num > this.maxValue){
33876 this.markInvalid(String.format(this.maxText, this.maxValue));
33883 getValue : function()
33885 var v = this.hiddenEl().getValue();
33887 return this.fixPrecision(this.parseValue(v));
33890 parseValue : function(value)
33892 if(this.thousandsDelimiter) {
33894 r = new RegExp(",", "g");
33895 value = value.replace(r, "");
33898 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33899 return isNaN(value) ? '' : value;
33902 fixPrecision : function(value)
33904 if(this.thousandsDelimiter) {
33906 r = new RegExp(",", "g");
33907 value = value.replace(r, "");
33910 var nan = isNaN(value);
33912 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33913 return nan ? '' : value;
33915 return parseFloat(value).toFixed(this.decimalPrecision);
33918 setValue : function(v)
33920 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33926 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33928 this.inputEl().dom.value = (v == '') ? '' :
33929 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33931 if(!this.allowZero && v === '0') {
33932 this.hiddenEl().dom.value = '';
33933 this.inputEl().dom.value = '';
33940 decimalPrecisionFcn : function(v)
33942 return Math.floor(v);
33945 beforeBlur : function()
33947 var v = this.parseValue(this.getRawValue());
33949 if(v || v === 0 || v === ''){
33954 hiddenEl : function()
33956 return this.el.select('input.hidden-number-input',true).first();
33968 * @class Roo.bootstrap.DocumentSlider
33969 * @extends Roo.bootstrap.Component
33970 * Bootstrap DocumentSlider class
33973 * Create a new DocumentViewer
33974 * @param {Object} config The config object
33977 Roo.bootstrap.DocumentSlider = function(config){
33978 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33985 * Fire after initEvent
33986 * @param {Roo.bootstrap.DocumentSlider} this
33991 * Fire after update
33992 * @param {Roo.bootstrap.DocumentSlider} this
33998 * @param {Roo.bootstrap.DocumentSlider} this
34004 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
34010 getAutoCreate : function()
34014 cls : 'roo-document-slider',
34018 cls : 'roo-document-slider-header',
34022 cls : 'roo-document-slider-header-title'
34028 cls : 'roo-document-slider-body',
34032 cls : 'roo-document-slider-prev',
34036 cls : 'fa fa-chevron-left'
34042 cls : 'roo-document-slider-thumb',
34046 cls : 'roo-document-slider-image'
34052 cls : 'roo-document-slider-next',
34056 cls : 'fa fa-chevron-right'
34068 initEvents : function()
34070 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34071 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34073 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34074 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34076 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34077 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34079 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34080 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34082 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34083 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34085 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34086 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34088 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34089 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34091 this.thumbEl.on('click', this.onClick, this);
34093 this.prevIndicator.on('click', this.prev, this);
34095 this.nextIndicator.on('click', this.next, this);
34099 initial : function()
34101 if(this.files.length){
34102 this.indicator = 1;
34106 this.fireEvent('initial', this);
34109 update : function()
34111 this.imageEl.attr('src', this.files[this.indicator - 1]);
34113 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34115 this.prevIndicator.show();
34117 if(this.indicator == 1){
34118 this.prevIndicator.hide();
34121 this.nextIndicator.show();
34123 if(this.indicator == this.files.length){
34124 this.nextIndicator.hide();
34127 this.thumbEl.scrollTo('top');
34129 this.fireEvent('update', this);
34132 onClick : function(e)
34134 e.preventDefault();
34136 this.fireEvent('click', this);
34141 e.preventDefault();
34143 this.indicator = Math.max(1, this.indicator - 1);
34150 e.preventDefault();
34152 this.indicator = Math.min(this.files.length, this.indicator + 1);
34166 * @class Roo.bootstrap.RadioSet
34167 * @extends Roo.bootstrap.Input
34168 * Bootstrap RadioSet class
34169 * @cfg {String} indicatorpos (left|right) default left
34170 * @cfg {Boolean} inline (true|false) inline the element (default true)
34171 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34173 * Create a new RadioSet
34174 * @param {Object} config The config object
34177 Roo.bootstrap.RadioSet = function(config){
34179 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34183 Roo.bootstrap.RadioSet.register(this);
34188 * Fires when the element is checked or unchecked.
34189 * @param {Roo.bootstrap.RadioSet} this This radio
34190 * @param {Roo.bootstrap.Radio} item The checked item
34195 * Fires when the element is click.
34196 * @param {Roo.bootstrap.RadioSet} this This radio set
34197 * @param {Roo.bootstrap.Radio} item The checked item
34198 * @param {Roo.EventObject} e The event object
34205 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34213 indicatorpos : 'left',
34215 getAutoCreate : function()
34219 cls : 'roo-radio-set-label',
34223 html : this.fieldLabel
34227 if (Roo.bootstrap.version == 3) {
34230 if(this.indicatorpos == 'left'){
34233 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34234 tooltip : 'This field is required'
34239 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34240 tooltip : 'This field is required'
34246 cls : 'roo-radio-set-items'
34249 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34251 if (align === 'left' && this.fieldLabel.length) {
34254 cls : "roo-radio-set-right",
34260 if(this.labelWidth > 12){
34261 label.style = "width: " + this.labelWidth + 'px';
34264 if(this.labelWidth < 13 && this.labelmd == 0){
34265 this.labelmd = this.labelWidth;
34268 if(this.labellg > 0){
34269 label.cls += ' col-lg-' + this.labellg;
34270 items.cls += ' col-lg-' + (12 - this.labellg);
34273 if(this.labelmd > 0){
34274 label.cls += ' col-md-' + this.labelmd;
34275 items.cls += ' col-md-' + (12 - this.labelmd);
34278 if(this.labelsm > 0){
34279 label.cls += ' col-sm-' + this.labelsm;
34280 items.cls += ' col-sm-' + (12 - this.labelsm);
34283 if(this.labelxs > 0){
34284 label.cls += ' col-xs-' + this.labelxs;
34285 items.cls += ' col-xs-' + (12 - this.labelxs);
34291 cls : 'roo-radio-set',
34295 cls : 'roo-radio-set-input',
34298 value : this.value ? this.value : ''
34305 if(this.weight.length){
34306 cfg.cls += ' roo-radio-' + this.weight;
34310 cfg.cls += ' roo-radio-set-inline';
34314 ['xs','sm','md','lg'].map(function(size){
34315 if (settings[size]) {
34316 cfg.cls += ' col-' + size + '-' + settings[size];
34324 initEvents : function()
34326 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34327 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34329 if(!this.fieldLabel.length){
34330 this.labelEl.hide();
34333 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34334 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34336 this.indicator = this.indicatorEl();
34338 if(this.indicator){
34339 this.indicator.addClass('invisible');
34342 this.originalValue = this.getValue();
34346 inputEl: function ()
34348 return this.el.select('.roo-radio-set-input', true).first();
34351 getChildContainer : function()
34353 return this.itemsEl;
34356 register : function(item)
34358 this.radioes.push(item);
34362 validate : function()
34364 if(this.getVisibilityEl().hasClass('hidden')){
34370 Roo.each(this.radioes, function(i){
34379 if(this.allowBlank) {
34383 if(this.disabled || valid){
34388 this.markInvalid();
34393 markValid : function()
34395 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34396 this.indicatorEl().removeClass('visible');
34397 this.indicatorEl().addClass('invisible');
34401 if (Roo.bootstrap.version == 3) {
34402 this.el.removeClass([this.invalidClass, this.validClass]);
34403 this.el.addClass(this.validClass);
34405 this.el.removeClass(['is-invalid','is-valid']);
34406 this.el.addClass(['is-valid']);
34408 this.fireEvent('valid', this);
34411 markInvalid : function(msg)
34413 if(this.allowBlank || this.disabled){
34417 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34418 this.indicatorEl().removeClass('invisible');
34419 this.indicatorEl().addClass('visible');
34421 if (Roo.bootstrap.version == 3) {
34422 this.el.removeClass([this.invalidClass, this.validClass]);
34423 this.el.addClass(this.invalidClass);
34425 this.el.removeClass(['is-invalid','is-valid']);
34426 this.el.addClass(['is-invalid']);
34429 this.fireEvent('invalid', this, msg);
34433 setValue : function(v, suppressEvent)
34435 if(this.value === v){
34442 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34445 Roo.each(this.radioes, function(i){
34447 i.el.removeClass('checked');
34450 Roo.each(this.radioes, function(i){
34452 if(i.value === v || i.value.toString() === v.toString()){
34454 i.el.addClass('checked');
34456 if(suppressEvent !== true){
34457 this.fireEvent('check', this, i);
34468 clearInvalid : function(){
34470 if(!this.el || this.preventMark){
34474 this.el.removeClass([this.invalidClass]);
34476 this.fireEvent('valid', this);
34481 Roo.apply(Roo.bootstrap.RadioSet, {
34485 register : function(set)
34487 this.groups[set.name] = set;
34490 get: function(name)
34492 if (typeof(this.groups[name]) == 'undefined') {
34496 return this.groups[name] ;
34502 * Ext JS Library 1.1.1
34503 * Copyright(c) 2006-2007, Ext JS, LLC.
34505 * Originally Released Under LGPL - original licence link has changed is not relivant.
34508 * <script type="text/javascript">
34513 * @class Roo.bootstrap.SplitBar
34514 * @extends Roo.util.Observable
34515 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34519 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34520 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34521 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34522 split.minSize = 100;
34523 split.maxSize = 600;
34524 split.animate = true;
34525 split.on('moved', splitterMoved);
34528 * Create a new SplitBar
34529 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34530 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34531 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34532 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34533 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34534 position of the SplitBar).
34536 Roo.bootstrap.SplitBar = function(cfg){
34541 // dragElement : elm
34542 // resizingElement: el,
34544 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34545 // placement : Roo.bootstrap.SplitBar.LEFT ,
34546 // existingProxy ???
34549 this.el = Roo.get(cfg.dragElement, true);
34550 this.el.dom.unselectable = "on";
34552 this.resizingEl = Roo.get(cfg.resizingElement, true);
34556 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34557 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34560 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34563 * The minimum size of the resizing element. (Defaults to 0)
34569 * The maximum size of the resizing element. (Defaults to 2000)
34572 this.maxSize = 2000;
34575 * Whether to animate the transition to the new size
34578 this.animate = false;
34581 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34584 this.useShim = false;
34589 if(!cfg.existingProxy){
34591 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34593 this.proxy = Roo.get(cfg.existingProxy).dom;
34596 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34599 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34602 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34605 this.dragSpecs = {};
34608 * @private The adapter to use to positon and resize elements
34610 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34611 this.adapter.init(this);
34613 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34615 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34616 this.el.addClass("roo-splitbar-h");
34619 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34620 this.el.addClass("roo-splitbar-v");
34626 * Fires when the splitter is moved (alias for {@link #event-moved})
34627 * @param {Roo.bootstrap.SplitBar} this
34628 * @param {Number} newSize the new width or height
34633 * Fires when the splitter is moved
34634 * @param {Roo.bootstrap.SplitBar} this
34635 * @param {Number} newSize the new width or height
34639 * @event beforeresize
34640 * Fires before the splitter is dragged
34641 * @param {Roo.bootstrap.SplitBar} this
34643 "beforeresize" : true,
34645 "beforeapply" : true
34648 Roo.util.Observable.call(this);
34651 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34652 onStartProxyDrag : function(x, y){
34653 this.fireEvent("beforeresize", this);
34655 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34657 o.enableDisplayMode("block");
34658 // all splitbars share the same overlay
34659 Roo.bootstrap.SplitBar.prototype.overlay = o;
34661 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34662 this.overlay.show();
34663 Roo.get(this.proxy).setDisplayed("block");
34664 var size = this.adapter.getElementSize(this);
34665 this.activeMinSize = this.getMinimumSize();;
34666 this.activeMaxSize = this.getMaximumSize();;
34667 var c1 = size - this.activeMinSize;
34668 var c2 = Math.max(this.activeMaxSize - size, 0);
34669 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34670 this.dd.resetConstraints();
34671 this.dd.setXConstraint(
34672 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34673 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34675 this.dd.setYConstraint(0, 0);
34677 this.dd.resetConstraints();
34678 this.dd.setXConstraint(0, 0);
34679 this.dd.setYConstraint(
34680 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34681 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34684 this.dragSpecs.startSize = size;
34685 this.dragSpecs.startPoint = [x, y];
34686 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34690 * @private Called after the drag operation by the DDProxy
34692 onEndProxyDrag : function(e){
34693 Roo.get(this.proxy).setDisplayed(false);
34694 var endPoint = Roo.lib.Event.getXY(e);
34696 this.overlay.hide();
34699 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34700 newSize = this.dragSpecs.startSize +
34701 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34702 endPoint[0] - this.dragSpecs.startPoint[0] :
34703 this.dragSpecs.startPoint[0] - endPoint[0]
34706 newSize = this.dragSpecs.startSize +
34707 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34708 endPoint[1] - this.dragSpecs.startPoint[1] :
34709 this.dragSpecs.startPoint[1] - endPoint[1]
34712 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34713 if(newSize != this.dragSpecs.startSize){
34714 if(this.fireEvent('beforeapply', this, newSize) !== false){
34715 this.adapter.setElementSize(this, newSize);
34716 this.fireEvent("moved", this, newSize);
34717 this.fireEvent("resize", this, newSize);
34723 * Get the adapter this SplitBar uses
34724 * @return The adapter object
34726 getAdapter : function(){
34727 return this.adapter;
34731 * Set the adapter this SplitBar uses
34732 * @param {Object} adapter A SplitBar adapter object
34734 setAdapter : function(adapter){
34735 this.adapter = adapter;
34736 this.adapter.init(this);
34740 * Gets the minimum size for the resizing element
34741 * @return {Number} The minimum size
34743 getMinimumSize : function(){
34744 return this.minSize;
34748 * Sets the minimum size for the resizing element
34749 * @param {Number} minSize The minimum size
34751 setMinimumSize : function(minSize){
34752 this.minSize = minSize;
34756 * Gets the maximum size for the resizing element
34757 * @return {Number} The maximum size
34759 getMaximumSize : function(){
34760 return this.maxSize;
34764 * Sets the maximum size for the resizing element
34765 * @param {Number} maxSize The maximum size
34767 setMaximumSize : function(maxSize){
34768 this.maxSize = maxSize;
34772 * Sets the initialize size for the resizing element
34773 * @param {Number} size The initial size
34775 setCurrentSize : function(size){
34776 var oldAnimate = this.animate;
34777 this.animate = false;
34778 this.adapter.setElementSize(this, size);
34779 this.animate = oldAnimate;
34783 * Destroy this splitbar.
34784 * @param {Boolean} removeEl True to remove the element
34786 destroy : function(removeEl){
34788 this.shim.remove();
34791 this.proxy.parentNode.removeChild(this.proxy);
34799 * @private static Create our own proxy element element. So it will be the same same size on all browsers, we won't use borders. Instead we use a background color.
34801 Roo.bootstrap.SplitBar.createProxy = function(dir){
34802 var proxy = new Roo.Element(document.createElement("div"));
34803 proxy.unselectable();
34804 var cls = 'roo-splitbar-proxy';
34805 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34806 document.body.appendChild(proxy.dom);
34811 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34812 * Default Adapter. It assumes the splitter and resizing element are not positioned
34813 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34815 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34818 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34819 // do nothing for now
34820 init : function(s){
34824 * Called before drag operations to get the current size of the resizing element.
34825 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34827 getElementSize : function(s){
34828 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34829 return s.resizingEl.getWidth();
34831 return s.resizingEl.getHeight();
34836 * Called after drag operations to set the size of the resizing element.
34837 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34838 * @param {Number} newSize The new size to set
34839 * @param {Function} onComplete A function to be invoked when resizing is complete
34841 setElementSize : function(s, newSize, onComplete){
34842 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34844 s.resizingEl.setWidth(newSize);
34846 onComplete(s, newSize);
34849 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34854 s.resizingEl.setHeight(newSize);
34856 onComplete(s, newSize);
34859 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34866 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34867 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34868 * Adapter that moves the splitter element to align with the resized sizing element.
34869 * Used with an absolute positioned SplitBar.
34870 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34871 * document.body, make sure you assign an id to the body element.
34873 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34874 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34875 this.container = Roo.get(container);
34878 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34879 init : function(s){
34880 this.basic.init(s);
34883 getElementSize : function(s){
34884 return this.basic.getElementSize(s);
34887 setElementSize : function(s, newSize, onComplete){
34888 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34891 moveSplitter : function(s){
34892 var yes = Roo.bootstrap.SplitBar;
34893 switch(s.placement){
34895 s.el.setX(s.resizingEl.getRight());
34898 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34901 s.el.setY(s.resizingEl.getBottom());
34904 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34911 * Orientation constant - Create a vertical SplitBar
34915 Roo.bootstrap.SplitBar.VERTICAL = 1;
34918 * Orientation constant - Create a horizontal SplitBar
34922 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34925 * Placement constant - The resizing element is to the left of the splitter element
34929 Roo.bootstrap.SplitBar.LEFT = 1;
34932 * Placement constant - The resizing element is to the right of the splitter element
34936 Roo.bootstrap.SplitBar.RIGHT = 2;
34939 * Placement constant - The resizing element is positioned above the splitter element
34943 Roo.bootstrap.SplitBar.TOP = 3;
34946 * Placement constant - The resizing element is positioned under splitter element
34950 Roo.bootstrap.SplitBar.BOTTOM = 4;
34951 Roo.namespace("Roo.bootstrap.layout");/*
34953 * Ext JS Library 1.1.1
34954 * Copyright(c) 2006-2007, Ext JS, LLC.
34956 * Originally Released Under LGPL - original licence link has changed is not relivant.
34959 * <script type="text/javascript">
34963 * @class Roo.bootstrap.layout.Manager
34964 * @extends Roo.bootstrap.Component
34965 * Base class for layout managers.
34967 Roo.bootstrap.layout.Manager = function(config)
34969 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34975 /** false to disable window resize monitoring @type Boolean */
34976 this.monitorWindowResize = true;
34981 * Fires when a layout is performed.
34982 * @param {Roo.LayoutManager} this
34986 * @event regionresized
34987 * Fires when the user resizes a region.
34988 * @param {Roo.LayoutRegion} region The resized region
34989 * @param {Number} newSize The new size (width for east/west, height for north/south)
34991 "regionresized" : true,
34993 * @event regioncollapsed
34994 * Fires when a region is collapsed.
34995 * @param {Roo.LayoutRegion} region The collapsed region
34997 "regioncollapsed" : true,
34999 * @event regionexpanded
35000 * Fires when a region is expanded.
35001 * @param {Roo.LayoutRegion} region The expanded region
35003 "regionexpanded" : true
35005 this.updating = false;
35008 this.el = Roo.get(config.el);
35014 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
35019 monitorWindowResize : true,
35025 onRender : function(ct, position)
35028 this.el = Roo.get(ct);
35031 //this.fireEvent('render',this);
35035 initEvents: function()
35039 // ie scrollbar fix
35040 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
35041 document.body.scroll = "no";
35042 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
35043 this.el.position('relative');
35045 this.id = this.el.id;
35046 this.el.addClass("roo-layout-container");
35047 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35048 if(this.el.dom != document.body ) {
35049 this.el.on('resize', this.layout,this);
35050 this.el.on('show', this.layout,this);
35056 * Returns true if this layout is currently being updated
35057 * @return {Boolean}
35059 isUpdating : function(){
35060 return this.updating;
35064 * Suspend the LayoutManager from doing auto-layouts while
35065 * making multiple add or remove calls
35067 beginUpdate : function(){
35068 this.updating = true;
35072 * Restore auto-layouts and optionally disable the manager from performing a layout
35073 * @param {Boolean} noLayout true to disable a layout update
35075 endUpdate : function(noLayout){
35076 this.updating = false;
35082 layout: function(){
35086 onRegionResized : function(region, newSize){
35087 this.fireEvent("regionresized", region, newSize);
35091 onRegionCollapsed : function(region){
35092 this.fireEvent("regioncollapsed", region);
35095 onRegionExpanded : function(region){
35096 this.fireEvent("regionexpanded", region);
35100 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35101 * performs box-model adjustments.
35102 * @return {Object} The size as an object {width: (the width), height: (the height)}
35104 getViewSize : function()
35107 if(this.el.dom != document.body){
35108 size = this.el.getSize();
35110 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35112 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35113 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35118 * Returns the Element this layout is bound to.
35119 * @return {Roo.Element}
35121 getEl : function(){
35126 * Returns the specified region.
35127 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35128 * @return {Roo.LayoutRegion}
35130 getRegion : function(target){
35131 return this.regions[target.toLowerCase()];
35134 onWindowResize : function(){
35135 if(this.monitorWindowResize){
35142 * Ext JS Library 1.1.1
35143 * Copyright(c) 2006-2007, Ext JS, LLC.
35145 * Originally Released Under LGPL - original licence link has changed is not relivant.
35148 * <script type="text/javascript">
35151 * @class Roo.bootstrap.layout.Border
35152 * @extends Roo.bootstrap.layout.Manager
35153 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35154 * please see: examples/bootstrap/nested.html<br><br>
35156 <b>The container the layout is rendered into can be either the body element or any other element.
35157 If it is not the body element, the container needs to either be an absolute positioned element,
35158 or you will need to add "position:relative" to the css of the container. You will also need to specify
35159 the container size if it is not the body element.</b>
35162 * Create a new Border
35163 * @param {Object} config Configuration options
35165 Roo.bootstrap.layout.Border = function(config){
35166 config = config || {};
35167 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35171 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35172 if(config[region]){
35173 config[region].region = region;
35174 this.addRegion(config[region]);
35180 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35182 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35184 parent : false, // this might point to a 'nest' or a ???
35187 * Creates and adds a new region if it doesn't already exist.
35188 * @param {String} target The target region key (north, south, east, west or center).
35189 * @param {Object} config The regions config object
35190 * @return {BorderLayoutRegion} The new region
35192 addRegion : function(config)
35194 if(!this.regions[config.region]){
35195 var r = this.factory(config);
35196 this.bindRegion(r);
35198 return this.regions[config.region];
35202 bindRegion : function(r){
35203 this.regions[r.config.region] = r;
35205 r.on("visibilitychange", this.layout, this);
35206 r.on("paneladded", this.layout, this);
35207 r.on("panelremoved", this.layout, this);
35208 r.on("invalidated", this.layout, this);
35209 r.on("resized", this.onRegionResized, this);
35210 r.on("collapsed", this.onRegionCollapsed, this);
35211 r.on("expanded", this.onRegionExpanded, this);
35215 * Performs a layout update.
35217 layout : function()
35219 if(this.updating) {
35223 // render all the rebions if they have not been done alreayd?
35224 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35225 if(this.regions[region] && !this.regions[region].bodyEl){
35226 this.regions[region].onRender(this.el)
35230 var size = this.getViewSize();
35231 var w = size.width;
35232 var h = size.height;
35237 //var x = 0, y = 0;
35239 var rs = this.regions;
35240 var north = rs["north"];
35241 var south = rs["south"];
35242 var west = rs["west"];
35243 var east = rs["east"];
35244 var center = rs["center"];
35245 //if(this.hideOnLayout){ // not supported anymore
35246 //c.el.setStyle("display", "none");
35248 if(north && north.isVisible()){
35249 var b = north.getBox();
35250 var m = north.getMargins();
35251 b.width = w - (m.left+m.right);
35254 centerY = b.height + b.y + m.bottom;
35255 centerH -= centerY;
35256 north.updateBox(this.safeBox(b));
35258 if(south && south.isVisible()){
35259 var b = south.getBox();
35260 var m = south.getMargins();
35261 b.width = w - (m.left+m.right);
35263 var totalHeight = (b.height + m.top + m.bottom);
35264 b.y = h - totalHeight + m.top;
35265 centerH -= totalHeight;
35266 south.updateBox(this.safeBox(b));
35268 if(west && west.isVisible()){
35269 var b = west.getBox();
35270 var m = west.getMargins();
35271 b.height = centerH - (m.top+m.bottom);
35273 b.y = centerY + m.top;
35274 var totalWidth = (b.width + m.left + m.right);
35275 centerX += totalWidth;
35276 centerW -= totalWidth;
35277 west.updateBox(this.safeBox(b));
35279 if(east && east.isVisible()){
35280 var b = east.getBox();
35281 var m = east.getMargins();
35282 b.height = centerH - (m.top+m.bottom);
35283 var totalWidth = (b.width + m.left + m.right);
35284 b.x = w - totalWidth + m.left;
35285 b.y = centerY + m.top;
35286 centerW -= totalWidth;
35287 east.updateBox(this.safeBox(b));
35290 var m = center.getMargins();
35292 x: centerX + m.left,
35293 y: centerY + m.top,
35294 width: centerW - (m.left+m.right),
35295 height: centerH - (m.top+m.bottom)
35297 //if(this.hideOnLayout){
35298 //center.el.setStyle("display", "block");
35300 center.updateBox(this.safeBox(centerBox));
35303 this.fireEvent("layout", this);
35307 safeBox : function(box){
35308 box.width = Math.max(0, box.width);
35309 box.height = Math.max(0, box.height);
35314 * Adds a ContentPanel (or subclass) to this layout.
35315 * @param {String} target The target region key (north, south, east, west or center).
35316 * @param {Roo.ContentPanel} panel The panel to add
35317 * @return {Roo.ContentPanel} The added panel
35319 add : function(target, panel){
35321 target = target.toLowerCase();
35322 return this.regions[target].add(panel);
35326 * Remove a ContentPanel (or subclass) to this layout.
35327 * @param {String} target The target region key (north, south, east, west or center).
35328 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35329 * @return {Roo.ContentPanel} The removed panel
35331 remove : function(target, panel){
35332 target = target.toLowerCase();
35333 return this.regions[target].remove(panel);
35337 * Searches all regions for a panel with the specified id
35338 * @param {String} panelId
35339 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35341 findPanel : function(panelId){
35342 var rs = this.regions;
35343 for(var target in rs){
35344 if(typeof rs[target] != "function"){
35345 var p = rs[target].getPanel(panelId);
35355 * Searches all regions for a panel with the specified id and activates (shows) it.
35356 * @param {String/ContentPanel} panelId The panels id or the panel itself
35357 * @return {Roo.ContentPanel} The shown panel or null
35359 showPanel : function(panelId) {
35360 var rs = this.regions;
35361 for(var target in rs){
35362 var r = rs[target];
35363 if(typeof r != "function"){
35364 if(r.hasPanel(panelId)){
35365 return r.showPanel(panelId);
35373 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35374 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35377 restoreState : function(provider){
35379 provider = Roo.state.Manager;
35381 var sm = new Roo.LayoutStateManager();
35382 sm.init(this, provider);
35388 * Adds a xtype elements to the layout.
35392 xtype : 'ContentPanel',
35399 xtype : 'NestedLayoutPanel',
35405 items : [ ... list of content panels or nested layout panels.. ]
35409 * @param {Object} cfg Xtype definition of item to add.
35411 addxtype : function(cfg)
35413 // basically accepts a pannel...
35414 // can accept a layout region..!?!?
35415 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35418 // theory? children can only be panels??
35420 //if (!cfg.xtype.match(/Panel$/)) {
35425 if (typeof(cfg.region) == 'undefined') {
35426 Roo.log("Failed to add Panel, region was not set");
35430 var region = cfg.region;
35436 xitems = cfg.items;
35441 if ( region == 'center') {
35442 Roo.log("Center: " + cfg.title);
35448 case 'Content': // ContentPanel (el, cfg)
35449 case 'Scroll': // ContentPanel (el, cfg)
35451 cfg.autoCreate = cfg.autoCreate || true;
35452 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35454 // var el = this.el.createChild();
35455 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35458 this.add(region, ret);
35462 case 'TreePanel': // our new panel!
35463 cfg.el = this.el.createChild();
35464 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35465 this.add(region, ret);
35470 // create a new Layout (which is a Border Layout...
35472 var clayout = cfg.layout;
35473 clayout.el = this.el.createChild();
35474 clayout.items = clayout.items || [];
35478 // replace this exitems with the clayout ones..
35479 xitems = clayout.items;
35481 // force background off if it's in center...
35482 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35483 cfg.background = false;
35485 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35488 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35489 //console.log('adding nested layout panel ' + cfg.toSource());
35490 this.add(region, ret);
35491 nb = {}; /// find first...
35496 // needs grid and region
35498 //var el = this.getRegion(region).el.createChild();
35500 *var el = this.el.createChild();
35501 // create the grid first...
35502 cfg.grid.container = el;
35503 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35506 if (region == 'center' && this.active ) {
35507 cfg.background = false;
35510 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35512 this.add(region, ret);
35514 if (cfg.background) {
35515 // render grid on panel activation (if panel background)
35516 ret.on('activate', function(gp) {
35517 if (!gp.grid.rendered) {
35518 // gp.grid.render(el);
35522 // cfg.grid.render(el);
35528 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35529 // it was the old xcomponent building that caused this before.
35530 // espeically if border is the top element in the tree.
35540 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35542 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35543 this.add(region, ret);
35547 throw "Can not add '" + cfg.xtype + "' to Border";
35553 this.beginUpdate();
35557 Roo.each(xitems, function(i) {
35558 region = nb && i.region ? i.region : false;
35560 var add = ret.addxtype(i);
35563 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35564 if (!i.background) {
35565 abn[region] = nb[region] ;
35572 // make the last non-background panel active..
35573 //if (nb) { Roo.log(abn); }
35576 for(var r in abn) {
35577 region = this.getRegion(r);
35579 // tried using nb[r], but it does not work..
35581 region.showPanel(abn[r]);
35592 factory : function(cfg)
35595 var validRegions = Roo.bootstrap.layout.Border.regions;
35597 var target = cfg.region;
35600 var r = Roo.bootstrap.layout;
35604 return new r.North(cfg);
35606 return new r.South(cfg);
35608 return new r.East(cfg);
35610 return new r.West(cfg);
35612 return new r.Center(cfg);
35614 throw 'Layout region "'+target+'" not supported.';
35621 * Ext JS Library 1.1.1
35622 * Copyright(c) 2006-2007, Ext JS, LLC.
35624 * Originally Released Under LGPL - original licence link has changed is not relivant.
35627 * <script type="text/javascript">
35631 * @class Roo.bootstrap.layout.Basic
35632 * @extends Roo.util.Observable
35633 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35634 * and does not have a titlebar, tabs or any other features. All it does is size and position
35635 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35636 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35637 * @cfg {string} region the region that it inhabits..
35638 * @cfg {bool} skipConfig skip config?
35642 Roo.bootstrap.layout.Basic = function(config){
35644 this.mgr = config.mgr;
35646 this.position = config.region;
35648 var skipConfig = config.skipConfig;
35652 * @scope Roo.BasicLayoutRegion
35656 * @event beforeremove
35657 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35658 * @param {Roo.LayoutRegion} this
35659 * @param {Roo.ContentPanel} panel The panel
35660 * @param {Object} e The cancel event object
35662 "beforeremove" : true,
35664 * @event invalidated
35665 * Fires when the layout for this region is changed.
35666 * @param {Roo.LayoutRegion} this
35668 "invalidated" : true,
35670 * @event visibilitychange
35671 * Fires when this region is shown or hidden
35672 * @param {Roo.LayoutRegion} this
35673 * @param {Boolean} visibility true or false
35675 "visibilitychange" : true,
35677 * @event paneladded
35678 * Fires when a panel is added.
35679 * @param {Roo.LayoutRegion} this
35680 * @param {Roo.ContentPanel} panel The panel
35682 "paneladded" : true,
35684 * @event panelremoved
35685 * Fires when a panel is removed.
35686 * @param {Roo.LayoutRegion} this
35687 * @param {Roo.ContentPanel} panel The panel
35689 "panelremoved" : true,
35691 * @event beforecollapse
35692 * Fires when this region before collapse.
35693 * @param {Roo.LayoutRegion} this
35695 "beforecollapse" : true,
35698 * Fires when this region is collapsed.
35699 * @param {Roo.LayoutRegion} this
35701 "collapsed" : true,
35704 * Fires when this region is expanded.
35705 * @param {Roo.LayoutRegion} this
35710 * Fires when this region is slid into view.
35711 * @param {Roo.LayoutRegion} this
35713 "slideshow" : true,
35716 * Fires when this region slides out of view.
35717 * @param {Roo.LayoutRegion} this
35719 "slidehide" : true,
35721 * @event panelactivated
35722 * Fires when a panel is activated.
35723 * @param {Roo.LayoutRegion} this
35724 * @param {Roo.ContentPanel} panel The activated panel
35726 "panelactivated" : true,
35729 * Fires when the user resizes this region.
35730 * @param {Roo.LayoutRegion} this
35731 * @param {Number} newSize The new size (width for east/west, height for north/south)
35735 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35736 this.panels = new Roo.util.MixedCollection();
35737 this.panels.getKey = this.getPanelId.createDelegate(this);
35739 this.activePanel = null;
35740 // ensure listeners are added...
35742 if (config.listeners || config.events) {
35743 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35744 listeners : config.listeners || {},
35745 events : config.events || {}
35749 if(skipConfig !== true){
35750 this.applyConfig(config);
35754 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35756 getPanelId : function(p){
35760 applyConfig : function(config){
35761 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35762 this.config = config;
35767 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35768 * the width, for horizontal (north, south) the height.
35769 * @param {Number} newSize The new width or height
35771 resizeTo : function(newSize){
35772 var el = this.el ? this.el :
35773 (this.activePanel ? this.activePanel.getEl() : null);
35775 switch(this.position){
35778 el.setWidth(newSize);
35779 this.fireEvent("resized", this, newSize);
35783 el.setHeight(newSize);
35784 this.fireEvent("resized", this, newSize);
35790 getBox : function(){
35791 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35794 getMargins : function(){
35795 return this.margins;
35798 updateBox : function(box){
35800 var el = this.activePanel.getEl();
35801 el.dom.style.left = box.x + "px";
35802 el.dom.style.top = box.y + "px";
35803 this.activePanel.setSize(box.width, box.height);
35807 * Returns the container element for this region.
35808 * @return {Roo.Element}
35810 getEl : function(){
35811 return this.activePanel;
35815 * Returns true if this region is currently visible.
35816 * @return {Boolean}
35818 isVisible : function(){
35819 return this.activePanel ? true : false;
35822 setActivePanel : function(panel){
35823 panel = this.getPanel(panel);
35824 if(this.activePanel && this.activePanel != panel){
35825 this.activePanel.setActiveState(false);
35826 this.activePanel.getEl().setLeftTop(-10000,-10000);
35828 this.activePanel = panel;
35829 panel.setActiveState(true);
35831 panel.setSize(this.box.width, this.box.height);
35833 this.fireEvent("panelactivated", this, panel);
35834 this.fireEvent("invalidated");
35838 * Show the specified panel.
35839 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35840 * @return {Roo.ContentPanel} The shown panel or null
35842 showPanel : function(panel){
35843 panel = this.getPanel(panel);
35845 this.setActivePanel(panel);
35851 * Get the active panel for this region.
35852 * @return {Roo.ContentPanel} The active panel or null
35854 getActivePanel : function(){
35855 return this.activePanel;
35859 * Add the passed ContentPanel(s)
35860 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35861 * @return {Roo.ContentPanel} The panel added (if only one was added)
35863 add : function(panel){
35864 if(arguments.length > 1){
35865 for(var i = 0, len = arguments.length; i < len; i++) {
35866 this.add(arguments[i]);
35870 if(this.hasPanel(panel)){
35871 this.showPanel(panel);
35874 var el = panel.getEl();
35875 if(el.dom.parentNode != this.mgr.el.dom){
35876 this.mgr.el.dom.appendChild(el.dom);
35878 if(panel.setRegion){
35879 panel.setRegion(this);
35881 this.panels.add(panel);
35882 el.setStyle("position", "absolute");
35883 if(!panel.background){
35884 this.setActivePanel(panel);
35885 if(this.config.initialSize && this.panels.getCount()==1){
35886 this.resizeTo(this.config.initialSize);
35889 this.fireEvent("paneladded", this, panel);
35894 * Returns true if the panel is in this region.
35895 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35896 * @return {Boolean}
35898 hasPanel : function(panel){
35899 if(typeof panel == "object"){ // must be panel obj
35900 panel = panel.getId();
35902 return this.getPanel(panel) ? true : false;
35906 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35907 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35908 * @param {Boolean} preservePanel Overrides the config preservePanel option
35909 * @return {Roo.ContentPanel} The panel that was removed
35911 remove : function(panel, preservePanel){
35912 panel = this.getPanel(panel);
35917 this.fireEvent("beforeremove", this, panel, e);
35918 if(e.cancel === true){
35921 var panelId = panel.getId();
35922 this.panels.removeKey(panelId);
35927 * Returns the panel specified or null if it's not in this region.
35928 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35929 * @return {Roo.ContentPanel}
35931 getPanel : function(id){
35932 if(typeof id == "object"){ // must be panel obj
35935 return this.panels.get(id);
35939 * Returns this regions position (north/south/east/west/center).
35942 getPosition: function(){
35943 return this.position;
35947 * Ext JS Library 1.1.1
35948 * Copyright(c) 2006-2007, Ext JS, LLC.
35950 * Originally Released Under LGPL - original licence link has changed is not relivant.
35953 * <script type="text/javascript">
35957 * @class Roo.bootstrap.layout.Region
35958 * @extends Roo.bootstrap.layout.Basic
35959 * This class represents a region in a layout manager.
35961 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35962 * @cfg {Object} cmargins Margins for the element when collapsed (defaults to: north/south {top: 2, left: 0, right:0, bottom: 2} or east/west {top: 0, left: 2, right:2, bottom: 0})
35963 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35964 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35965 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35966 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35967 * @cfg {String} title The title for the region (overrides panel titles)
35968 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35969 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35970 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35971 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35972 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35973 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35974 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35975 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35976 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35977 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35979 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35980 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35981 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35982 * @cfg {Number} width For East/West panels
35983 * @cfg {Number} height For North/South panels
35984 * @cfg {Boolean} split To show the splitter
35985 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35987 * @cfg {string} cls Extra CSS classes to add to region
35989 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35990 * @cfg {string} region the region that it inhabits..
35993 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35994 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35996 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35997 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35998 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
36000 Roo.bootstrap.layout.Region = function(config)
36002 this.applyConfig(config);
36004 var mgr = config.mgr;
36005 var pos = config.region;
36006 config.skipConfig = true;
36007 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
36010 this.onRender(mgr.el);
36013 this.visible = true;
36014 this.collapsed = false;
36015 this.unrendered_panels = [];
36018 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
36020 position: '', // set by wrapper (eg. north/south etc..)
36021 unrendered_panels : null, // unrendered panels.
36023 tabPosition : false,
36025 mgr: false, // points to 'Border'
36028 createBody : function(){
36029 /** This region's body element
36030 * @type Roo.Element */
36031 this.bodyEl = this.el.createChild({
36033 cls: "roo-layout-panel-body tab-content" // bootstrap added...
36037 onRender: function(ctr, pos)
36039 var dh = Roo.DomHelper;
36040 /** This region's container element
36041 * @type Roo.Element */
36042 this.el = dh.append(ctr.dom, {
36044 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
36046 /** This region's title element
36047 * @type Roo.Element */
36049 this.titleEl = dh.append(this.el.dom, {
36051 unselectable: "on",
36052 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36054 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36055 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36059 this.titleEl.enableDisplayMode();
36060 /** This region's title text element
36061 * @type HTMLElement */
36062 this.titleTextEl = this.titleEl.dom.firstChild;
36063 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36065 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36066 this.closeBtn.enableDisplayMode();
36067 this.closeBtn.on("click", this.closeClicked, this);
36068 this.closeBtn.hide();
36070 this.createBody(this.config);
36071 if(this.config.hideWhenEmpty){
36073 this.on("paneladded", this.validateVisibility, this);
36074 this.on("panelremoved", this.validateVisibility, this);
36076 if(this.autoScroll){
36077 this.bodyEl.setStyle("overflow", "auto");
36079 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36081 //if(c.titlebar !== false){
36082 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36083 this.titleEl.hide();
36085 this.titleEl.show();
36086 if(this.config.title){
36087 this.titleTextEl.innerHTML = this.config.title;
36091 if(this.config.collapsed){
36092 this.collapse(true);
36094 if(this.config.hidden){
36098 if (this.unrendered_panels && this.unrendered_panels.length) {
36099 for (var i =0;i< this.unrendered_panels.length; i++) {
36100 this.add(this.unrendered_panels[i]);
36102 this.unrendered_panels = null;
36108 applyConfig : function(c)
36111 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36112 var dh = Roo.DomHelper;
36113 if(c.titlebar !== false){
36114 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36115 this.collapseBtn.on("click", this.collapse, this);
36116 this.collapseBtn.enableDisplayMode();
36118 if(c.showPin === true || this.showPin){
36119 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36120 this.stickBtn.enableDisplayMode();
36121 this.stickBtn.on("click", this.expand, this);
36122 this.stickBtn.hide();
36127 /** This region's collapsed element
36128 * @type Roo.Element */
36131 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36132 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36135 if(c.floatable !== false){
36136 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36137 this.collapsedEl.on("click", this.collapseClick, this);
36140 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36141 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36142 id: "message", unselectable: "on", style:{"float":"left"}});
36143 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36145 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36146 this.expandBtn.on("click", this.expand, this);
36150 if(this.collapseBtn){
36151 this.collapseBtn.setVisible(c.collapsible == true);
36154 this.cmargins = c.cmargins || this.cmargins ||
36155 (this.position == "west" || this.position == "east" ?
36156 {top: 0, left: 2, right:2, bottom: 0} :
36157 {top: 2, left: 0, right:0, bottom: 2});
36159 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36162 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36164 this.autoScroll = c.autoScroll || false;
36169 this.duration = c.duration || .30;
36170 this.slideDuration = c.slideDuration || .45;
36175 * Returns true if this region is currently visible.
36176 * @return {Boolean}
36178 isVisible : function(){
36179 return this.visible;
36183 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36184 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36186 //setCollapsedTitle : function(title){
36187 // title = title || " ";
36188 // if(this.collapsedTitleTextEl){
36189 // this.collapsedTitleTextEl.innerHTML = title;
36193 getBox : function(){
36195 // if(!this.collapsed){
36196 b = this.el.getBox(false, true);
36198 // b = this.collapsedEl.getBox(false, true);
36203 getMargins : function(){
36204 return this.margins;
36205 //return this.collapsed ? this.cmargins : this.margins;
36208 highlight : function(){
36209 this.el.addClass("x-layout-panel-dragover");
36212 unhighlight : function(){
36213 this.el.removeClass("x-layout-panel-dragover");
36216 updateBox : function(box)
36218 if (!this.bodyEl) {
36219 return; // not rendered yet..
36223 if(!this.collapsed){
36224 this.el.dom.style.left = box.x + "px";
36225 this.el.dom.style.top = box.y + "px";
36226 this.updateBody(box.width, box.height);
36228 this.collapsedEl.dom.style.left = box.x + "px";
36229 this.collapsedEl.dom.style.top = box.y + "px";
36230 this.collapsedEl.setSize(box.width, box.height);
36233 this.tabs.autoSizeTabs();
36237 updateBody : function(w, h)
36240 this.el.setWidth(w);
36241 w -= this.el.getBorderWidth("rl");
36242 if(this.config.adjustments){
36243 w += this.config.adjustments[0];
36246 if(h !== null && h > 0){
36247 this.el.setHeight(h);
36248 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36249 h -= this.el.getBorderWidth("tb");
36250 if(this.config.adjustments){
36251 h += this.config.adjustments[1];
36253 this.bodyEl.setHeight(h);
36255 h = this.tabs.syncHeight(h);
36258 if(this.panelSize){
36259 w = w !== null ? w : this.panelSize.width;
36260 h = h !== null ? h : this.panelSize.height;
36262 if(this.activePanel){
36263 var el = this.activePanel.getEl();
36264 w = w !== null ? w : el.getWidth();
36265 h = h !== null ? h : el.getHeight();
36266 this.panelSize = {width: w, height: h};
36267 this.activePanel.setSize(w, h);
36269 if(Roo.isIE && this.tabs){
36270 this.tabs.el.repaint();
36275 * Returns the container element for this region.
36276 * @return {Roo.Element}
36278 getEl : function(){
36283 * Hides this region.
36286 //if(!this.collapsed){
36287 this.el.dom.style.left = "-2000px";
36290 // this.collapsedEl.dom.style.left = "-2000px";
36291 // this.collapsedEl.hide();
36293 this.visible = false;
36294 this.fireEvent("visibilitychange", this, false);
36298 * Shows this region if it was previously hidden.
36301 //if(!this.collapsed){
36304 // this.collapsedEl.show();
36306 this.visible = true;
36307 this.fireEvent("visibilitychange", this, true);
36310 closeClicked : function(){
36311 if(this.activePanel){
36312 this.remove(this.activePanel);
36316 collapseClick : function(e){
36318 e.stopPropagation();
36321 e.stopPropagation();
36327 * Collapses this region.
36328 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36331 collapse : function(skipAnim, skipCheck = false){
36332 if(this.collapsed) {
36336 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36338 this.collapsed = true;
36340 this.split.el.hide();
36342 if(this.config.animate && skipAnim !== true){
36343 this.fireEvent("invalidated", this);
36344 this.animateCollapse();
36346 this.el.setLocation(-20000,-20000);
36348 this.collapsedEl.show();
36349 this.fireEvent("collapsed", this);
36350 this.fireEvent("invalidated", this);
36356 animateCollapse : function(){
36361 * Expands this region if it was previously collapsed.
36362 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36363 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36366 expand : function(e, skipAnim){
36368 e.stopPropagation();
36370 if(!this.collapsed || this.el.hasActiveFx()) {
36374 this.afterSlideIn();
36377 this.collapsed = false;
36378 if(this.config.animate && skipAnim !== true){
36379 this.animateExpand();
36383 this.split.el.show();
36385 this.collapsedEl.setLocation(-2000,-2000);
36386 this.collapsedEl.hide();
36387 this.fireEvent("invalidated", this);
36388 this.fireEvent("expanded", this);
36392 animateExpand : function(){
36396 initTabs : function()
36398 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36400 var ts = new Roo.bootstrap.panel.Tabs({
36401 el: this.bodyEl.dom,
36403 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36404 disableTooltips: this.config.disableTabTips,
36405 toolbar : this.config.toolbar
36408 if(this.config.hideTabs){
36409 ts.stripWrap.setDisplayed(false);
36412 ts.resizeTabs = this.config.resizeTabs === true;
36413 ts.minTabWidth = this.config.minTabWidth || 40;
36414 ts.maxTabWidth = this.config.maxTabWidth || 250;
36415 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36416 ts.monitorResize = false;
36417 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36418 ts.bodyEl.addClass('roo-layout-tabs-body');
36419 this.panels.each(this.initPanelAsTab, this);
36422 initPanelAsTab : function(panel){
36423 var ti = this.tabs.addTab(
36427 this.config.closeOnTab && panel.isClosable(),
36430 if(panel.tabTip !== undefined){
36431 ti.setTooltip(panel.tabTip);
36433 ti.on("activate", function(){
36434 this.setActivePanel(panel);
36437 if(this.config.closeOnTab){
36438 ti.on("beforeclose", function(t, e){
36440 this.remove(panel);
36444 panel.tabItem = ti;
36449 updatePanelTitle : function(panel, title)
36451 if(this.activePanel == panel){
36452 this.updateTitle(title);
36455 var ti = this.tabs.getTab(panel.getEl().id);
36457 if(panel.tabTip !== undefined){
36458 ti.setTooltip(panel.tabTip);
36463 updateTitle : function(title){
36464 if(this.titleTextEl && !this.config.title){
36465 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36469 setActivePanel : function(panel)
36471 panel = this.getPanel(panel);
36472 if(this.activePanel && this.activePanel != panel){
36473 if(this.activePanel.setActiveState(false) === false){
36477 this.activePanel = panel;
36478 panel.setActiveState(true);
36479 if(this.panelSize){
36480 panel.setSize(this.panelSize.width, this.panelSize.height);
36483 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36485 this.updateTitle(panel.getTitle());
36487 this.fireEvent("invalidated", this);
36489 this.fireEvent("panelactivated", this, panel);
36493 * Shows the specified panel.
36494 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36495 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36497 showPanel : function(panel)
36499 panel = this.getPanel(panel);
36502 var tab = this.tabs.getTab(panel.getEl().id);
36503 if(tab.isHidden()){
36504 this.tabs.unhideTab(tab.id);
36508 this.setActivePanel(panel);
36515 * Get the active panel for this region.
36516 * @return {Roo.ContentPanel} The active panel or null
36518 getActivePanel : function(){
36519 return this.activePanel;
36522 validateVisibility : function(){
36523 if(this.panels.getCount() < 1){
36524 this.updateTitle(" ");
36525 this.closeBtn.hide();
36528 if(!this.isVisible()){
36535 * Adds the passed ContentPanel(s) to this region.
36536 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36537 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36539 add : function(panel)
36541 if(arguments.length > 1){
36542 for(var i = 0, len = arguments.length; i < len; i++) {
36543 this.add(arguments[i]);
36548 // if we have not been rendered yet, then we can not really do much of this..
36549 if (!this.bodyEl) {
36550 this.unrendered_panels.push(panel);
36557 if(this.hasPanel(panel)){
36558 this.showPanel(panel);
36561 panel.setRegion(this);
36562 this.panels.add(panel);
36563 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36564 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36565 // and hide them... ???
36566 this.bodyEl.dom.appendChild(panel.getEl().dom);
36567 if(panel.background !== true){
36568 this.setActivePanel(panel);
36570 this.fireEvent("paneladded", this, panel);
36577 this.initPanelAsTab(panel);
36581 if(panel.background !== true){
36582 this.tabs.activate(panel.getEl().id);
36584 this.fireEvent("paneladded", this, panel);
36589 * Hides the tab for the specified panel.
36590 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36592 hidePanel : function(panel){
36593 if(this.tabs && (panel = this.getPanel(panel))){
36594 this.tabs.hideTab(panel.getEl().id);
36599 * Unhides the tab for a previously hidden panel.
36600 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36602 unhidePanel : function(panel){
36603 if(this.tabs && (panel = this.getPanel(panel))){
36604 this.tabs.unhideTab(panel.getEl().id);
36608 clearPanels : function(){
36609 while(this.panels.getCount() > 0){
36610 this.remove(this.panels.first());
36615 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36616 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36617 * @param {Boolean} preservePanel Overrides the config preservePanel option
36618 * @return {Roo.ContentPanel} The panel that was removed
36620 remove : function(panel, preservePanel)
36622 panel = this.getPanel(panel);
36627 this.fireEvent("beforeremove", this, panel, e);
36628 if(e.cancel === true){
36631 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36632 var panelId = panel.getId();
36633 this.panels.removeKey(panelId);
36635 document.body.appendChild(panel.getEl().dom);
36638 this.tabs.removeTab(panel.getEl().id);
36639 }else if (!preservePanel){
36640 this.bodyEl.dom.removeChild(panel.getEl().dom);
36642 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36643 var p = this.panels.first();
36644 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36645 tempEl.appendChild(p.getEl().dom);
36646 this.bodyEl.update("");
36647 this.bodyEl.dom.appendChild(p.getEl().dom);
36649 this.updateTitle(p.getTitle());
36651 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36652 this.setActivePanel(p);
36654 panel.setRegion(null);
36655 if(this.activePanel == panel){
36656 this.activePanel = null;
36658 if(this.config.autoDestroy !== false && preservePanel !== true){
36659 try{panel.destroy();}catch(e){}
36661 this.fireEvent("panelremoved", this, panel);
36666 * Returns the TabPanel component used by this region
36667 * @return {Roo.TabPanel}
36669 getTabs : function(){
36673 createTool : function(parentEl, className){
36674 var btn = Roo.DomHelper.append(parentEl, {
36676 cls: "x-layout-tools-button",
36679 cls: "roo-layout-tools-button-inner " + className,
36683 btn.addClassOnOver("roo-layout-tools-button-over");
36688 * Ext JS Library 1.1.1
36689 * Copyright(c) 2006-2007, Ext JS, LLC.
36691 * Originally Released Under LGPL - original licence link has changed is not relivant.
36694 * <script type="text/javascript">
36700 * @class Roo.SplitLayoutRegion
36701 * @extends Roo.LayoutRegion
36702 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36704 Roo.bootstrap.layout.Split = function(config){
36705 this.cursor = config.cursor;
36706 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36709 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36711 splitTip : "Drag to resize.",
36712 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36713 useSplitTips : false,
36715 applyConfig : function(config){
36716 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36719 onRender : function(ctr,pos) {
36721 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36722 if(!this.config.split){
36727 var splitEl = Roo.DomHelper.append(ctr.dom, {
36729 id: this.el.id + "-split",
36730 cls: "roo-layout-split roo-layout-split-"+this.position,
36733 /** The SplitBar for this region
36734 * @type Roo.SplitBar */
36735 // does not exist yet...
36736 Roo.log([this.position, this.orientation]);
36738 this.split = new Roo.bootstrap.SplitBar({
36739 dragElement : splitEl,
36740 resizingElement: this.el,
36741 orientation : this.orientation
36744 this.split.on("moved", this.onSplitMove, this);
36745 this.split.useShim = this.config.useShim === true;
36746 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36747 if(this.useSplitTips){
36748 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36750 //if(config.collapsible){
36751 // this.split.el.on("dblclick", this.collapse, this);
36754 if(typeof this.config.minSize != "undefined"){
36755 this.split.minSize = this.config.minSize;
36757 if(typeof this.config.maxSize != "undefined"){
36758 this.split.maxSize = this.config.maxSize;
36760 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36761 this.hideSplitter();
36766 getHMaxSize : function(){
36767 var cmax = this.config.maxSize || 10000;
36768 var center = this.mgr.getRegion("center");
36769 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36772 getVMaxSize : function(){
36773 var cmax = this.config.maxSize || 10000;
36774 var center = this.mgr.getRegion("center");
36775 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36778 onSplitMove : function(split, newSize){
36779 this.fireEvent("resized", this, newSize);
36783 * Returns the {@link Roo.SplitBar} for this region.
36784 * @return {Roo.SplitBar}
36786 getSplitBar : function(){
36791 this.hideSplitter();
36792 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36795 hideSplitter : function(){
36797 this.split.el.setLocation(-2000,-2000);
36798 this.split.el.hide();
36804 this.split.el.show();
36806 Roo.bootstrap.layout.Split.superclass.show.call(this);
36809 beforeSlide: function(){
36810 if(Roo.isGecko){// firefox overflow auto bug workaround
36811 this.bodyEl.clip();
36813 this.tabs.bodyEl.clip();
36815 if(this.activePanel){
36816 this.activePanel.getEl().clip();
36818 if(this.activePanel.beforeSlide){
36819 this.activePanel.beforeSlide();
36825 afterSlide : function(){
36826 if(Roo.isGecko){// firefox overflow auto bug workaround
36827 this.bodyEl.unclip();
36829 this.tabs.bodyEl.unclip();
36831 if(this.activePanel){
36832 this.activePanel.getEl().unclip();
36833 if(this.activePanel.afterSlide){
36834 this.activePanel.afterSlide();
36840 initAutoHide : function(){
36841 if(this.autoHide !== false){
36842 if(!this.autoHideHd){
36843 var st = new Roo.util.DelayedTask(this.slideIn, this);
36844 this.autoHideHd = {
36845 "mouseout": function(e){
36846 if(!e.within(this.el, true)){
36850 "mouseover" : function(e){
36856 this.el.on(this.autoHideHd);
36860 clearAutoHide : function(){
36861 if(this.autoHide !== false){
36862 this.el.un("mouseout", this.autoHideHd.mouseout);
36863 this.el.un("mouseover", this.autoHideHd.mouseover);
36867 clearMonitor : function(){
36868 Roo.get(document).un("click", this.slideInIf, this);
36871 // these names are backwards but not changed for compat
36872 slideOut : function(){
36873 if(this.isSlid || this.el.hasActiveFx()){
36876 this.isSlid = true;
36877 if(this.collapseBtn){
36878 this.collapseBtn.hide();
36880 this.closeBtnState = this.closeBtn.getStyle('display');
36881 this.closeBtn.hide();
36883 this.stickBtn.show();
36886 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36887 this.beforeSlide();
36888 this.el.setStyle("z-index", 10001);
36889 this.el.slideIn(this.getSlideAnchor(), {
36890 callback: function(){
36892 this.initAutoHide();
36893 Roo.get(document).on("click", this.slideInIf, this);
36894 this.fireEvent("slideshow", this);
36901 afterSlideIn : function(){
36902 this.clearAutoHide();
36903 this.isSlid = false;
36904 this.clearMonitor();
36905 this.el.setStyle("z-index", "");
36906 if(this.collapseBtn){
36907 this.collapseBtn.show();
36909 this.closeBtn.setStyle('display', this.closeBtnState);
36911 this.stickBtn.hide();
36913 this.fireEvent("slidehide", this);
36916 slideIn : function(cb){
36917 if(!this.isSlid || this.el.hasActiveFx()){
36921 this.isSlid = false;
36922 this.beforeSlide();
36923 this.el.slideOut(this.getSlideAnchor(), {
36924 callback: function(){
36925 this.el.setLeftTop(-10000, -10000);
36927 this.afterSlideIn();
36935 slideInIf : function(e){
36936 if(!e.within(this.el)){
36941 animateCollapse : function(){
36942 this.beforeSlide();
36943 this.el.setStyle("z-index", 20000);
36944 var anchor = this.getSlideAnchor();
36945 this.el.slideOut(anchor, {
36946 callback : function(){
36947 this.el.setStyle("z-index", "");
36948 this.collapsedEl.slideIn(anchor, {duration:.3});
36950 this.el.setLocation(-10000,-10000);
36952 this.fireEvent("collapsed", this);
36959 animateExpand : function(){
36960 this.beforeSlide();
36961 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36962 this.el.setStyle("z-index", 20000);
36963 this.collapsedEl.hide({
36966 this.el.slideIn(this.getSlideAnchor(), {
36967 callback : function(){
36968 this.el.setStyle("z-index", "");
36971 this.split.el.show();
36973 this.fireEvent("invalidated", this);
36974 this.fireEvent("expanded", this);
37002 getAnchor : function(){
37003 return this.anchors[this.position];
37006 getCollapseAnchor : function(){
37007 return this.canchors[this.position];
37010 getSlideAnchor : function(){
37011 return this.sanchors[this.position];
37014 getAlignAdj : function(){
37015 var cm = this.cmargins;
37016 switch(this.position){
37032 getExpandAdj : function(){
37033 var c = this.collapsedEl, cm = this.cmargins;
37034 switch(this.position){
37036 return [-(cm.right+c.getWidth()+cm.left), 0];
37039 return [cm.right+c.getWidth()+cm.left, 0];
37042 return [0, -(cm.top+cm.bottom+c.getHeight())];
37045 return [0, cm.top+cm.bottom+c.getHeight()];
37051 * Ext JS Library 1.1.1
37052 * Copyright(c) 2006-2007, Ext JS, LLC.
37054 * Originally Released Under LGPL - original licence link has changed is not relivant.
37057 * <script type="text/javascript">
37060 * These classes are private internal classes
37062 Roo.bootstrap.layout.Center = function(config){
37063 config.region = "center";
37064 Roo.bootstrap.layout.Region.call(this, config);
37065 this.visible = true;
37066 this.minWidth = config.minWidth || 20;
37067 this.minHeight = config.minHeight || 20;
37070 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37072 // center panel can't be hidden
37076 // center panel can't be hidden
37079 getMinWidth: function(){
37080 return this.minWidth;
37083 getMinHeight: function(){
37084 return this.minHeight;
37098 Roo.bootstrap.layout.North = function(config)
37100 config.region = 'north';
37101 config.cursor = 'n-resize';
37103 Roo.bootstrap.layout.Split.call(this, config);
37107 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37108 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37109 this.split.el.addClass("roo-layout-split-v");
37111 var size = config.initialSize || config.height;
37112 if(typeof size != "undefined"){
37113 this.el.setHeight(size);
37116 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37118 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37122 getBox : function(){
37123 if(this.collapsed){
37124 return this.collapsedEl.getBox();
37126 var box = this.el.getBox();
37128 box.height += this.split.el.getHeight();
37133 updateBox : function(box){
37134 if(this.split && !this.collapsed){
37135 box.height -= this.split.el.getHeight();
37136 this.split.el.setLeft(box.x);
37137 this.split.el.setTop(box.y+box.height);
37138 this.split.el.setWidth(box.width);
37140 if(this.collapsed){
37141 this.updateBody(box.width, null);
37143 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37151 Roo.bootstrap.layout.South = function(config){
37152 config.region = 'south';
37153 config.cursor = 's-resize';
37154 Roo.bootstrap.layout.Split.call(this, config);
37156 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37157 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37158 this.split.el.addClass("roo-layout-split-v");
37160 var size = config.initialSize || config.height;
37161 if(typeof size != "undefined"){
37162 this.el.setHeight(size);
37166 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37167 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37168 getBox : function(){
37169 if(this.collapsed){
37170 return this.collapsedEl.getBox();
37172 var box = this.el.getBox();
37174 var sh = this.split.el.getHeight();
37181 updateBox : function(box){
37182 if(this.split && !this.collapsed){
37183 var sh = this.split.el.getHeight();
37186 this.split.el.setLeft(box.x);
37187 this.split.el.setTop(box.y-sh);
37188 this.split.el.setWidth(box.width);
37190 if(this.collapsed){
37191 this.updateBody(box.width, null);
37193 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37197 Roo.bootstrap.layout.East = function(config){
37198 config.region = "east";
37199 config.cursor = "e-resize";
37200 Roo.bootstrap.layout.Split.call(this, config);
37202 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37203 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37204 this.split.el.addClass("roo-layout-split-h");
37206 var size = config.initialSize || config.width;
37207 if(typeof size != "undefined"){
37208 this.el.setWidth(size);
37211 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37212 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37213 getBox : function(){
37214 if(this.collapsed){
37215 return this.collapsedEl.getBox();
37217 var box = this.el.getBox();
37219 var sw = this.split.el.getWidth();
37226 updateBox : function(box){
37227 if(this.split && !this.collapsed){
37228 var sw = this.split.el.getWidth();
37230 this.split.el.setLeft(box.x);
37231 this.split.el.setTop(box.y);
37232 this.split.el.setHeight(box.height);
37235 if(this.collapsed){
37236 this.updateBody(null, box.height);
37238 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37242 Roo.bootstrap.layout.West = function(config){
37243 config.region = "west";
37244 config.cursor = "w-resize";
37246 Roo.bootstrap.layout.Split.call(this, config);
37248 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37249 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37250 this.split.el.addClass("roo-layout-split-h");
37254 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37255 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37257 onRender: function(ctr, pos)
37259 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37260 var size = this.config.initialSize || this.config.width;
37261 if(typeof size != "undefined"){
37262 this.el.setWidth(size);
37266 getBox : function(){
37267 if(this.collapsed){
37268 return this.collapsedEl.getBox();
37270 var box = this.el.getBox();
37272 box.width += this.split.el.getWidth();
37277 updateBox : function(box){
37278 if(this.split && !this.collapsed){
37279 var sw = this.split.el.getWidth();
37281 this.split.el.setLeft(box.x+box.width);
37282 this.split.el.setTop(box.y);
37283 this.split.el.setHeight(box.height);
37285 if(this.collapsed){
37286 this.updateBody(null, box.height);
37288 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37290 });Roo.namespace("Roo.bootstrap.panel");/*
37292 * Ext JS Library 1.1.1
37293 * Copyright(c) 2006-2007, Ext JS, LLC.
37295 * Originally Released Under LGPL - original licence link has changed is not relivant.
37298 * <script type="text/javascript">
37301 * @class Roo.ContentPanel
37302 * @extends Roo.util.Observable
37303 * A basic ContentPanel element.
37304 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37305 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37306 * @cfg {Boolean/Object} autoCreate True to auto generate the DOM element for this panel, or a {@link Roo.DomHelper} config of the element to create
37307 * @cfg {Boolean} closable True if the panel can be closed/removed
37308 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37309 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37310 * @cfg {Toolbar} toolbar A toolbar for this panel
37311 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37312 * @cfg {String} title The title for this panel
37313 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37314 * @cfg {String} url Calls {@link #setUrl} with this value
37315 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37316 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37317 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37318 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37319 * @cfg {Boolean} badges render the badges
37322 * Create a new ContentPanel.
37323 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37324 * @param {String/Object} config A string to set only the title or a config object
37325 * @param {String} content (optional) Set the HTML content for this panel
37326 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37328 Roo.bootstrap.panel.Content = function( config){
37330 this.tpl = config.tpl || false;
37332 var el = config.el;
37333 var content = config.content;
37335 if(config.autoCreate){ // xtype is available if this is called from factory
37338 this.el = Roo.get(el);
37339 if(!this.el && config && config.autoCreate){
37340 if(typeof config.autoCreate == "object"){
37341 if(!config.autoCreate.id){
37342 config.autoCreate.id = config.id||el;
37344 this.el = Roo.DomHelper.append(document.body,
37345 config.autoCreate, true);
37347 var elcfg = { tag: "div",
37348 cls: "roo-layout-inactive-content",
37352 elcfg.html = config.html;
37356 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37359 this.closable = false;
37360 this.loaded = false;
37361 this.active = false;
37364 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37366 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37368 this.wrapEl = this.el; //this.el.wrap();
37370 if (config.toolbar.items) {
37371 ti = config.toolbar.items ;
37372 delete config.toolbar.items ;
37376 this.toolbar.render(this.wrapEl, 'before');
37377 for(var i =0;i < ti.length;i++) {
37378 // Roo.log(['add child', items[i]]);
37379 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37381 this.toolbar.items = nitems;
37382 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37383 delete config.toolbar;
37387 // xtype created footer. - not sure if will work as we normally have to render first..
37388 if (this.footer && !this.footer.el && this.footer.xtype) {
37389 if (!this.wrapEl) {
37390 this.wrapEl = this.el.wrap();
37393 this.footer.container = this.wrapEl.createChild();
37395 this.footer = Roo.factory(this.footer, Roo);
37400 if(typeof config == "string"){
37401 this.title = config;
37403 Roo.apply(this, config);
37407 this.resizeEl = Roo.get(this.resizeEl, true);
37409 this.resizeEl = this.el;
37411 // handle view.xtype
37419 * Fires when this panel is activated.
37420 * @param {Roo.ContentPanel} this
37424 * @event deactivate
37425 * Fires when this panel is activated.
37426 * @param {Roo.ContentPanel} this
37428 "deactivate" : true,
37432 * Fires when this panel is resized if fitToFrame is true.
37433 * @param {Roo.ContentPanel} this
37434 * @param {Number} width The width after any component adjustments
37435 * @param {Number} height The height after any component adjustments
37441 * Fires when this tab is created
37442 * @param {Roo.ContentPanel} this
37453 if(this.autoScroll){
37454 this.resizeEl.setStyle("overflow", "auto");
37456 // fix randome scrolling
37457 //this.el.on('scroll', function() {
37458 // Roo.log('fix random scolling');
37459 // this.scrollTo('top',0);
37462 content = content || this.content;
37464 this.setContent(content);
37466 if(config && config.url){
37467 this.setUrl(this.url, this.params, this.loadOnce);
37472 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37474 if (this.view && typeof(this.view.xtype) != 'undefined') {
37475 this.view.el = this.el.appendChild(document.createElement("div"));
37476 this.view = Roo.factory(this.view);
37477 this.view.render && this.view.render(false, '');
37481 this.fireEvent('render', this);
37484 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37488 setRegion : function(region){
37489 this.region = region;
37490 this.setActiveClass(region && !this.background);
37494 setActiveClass: function(state)
37497 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37498 this.el.setStyle('position','relative');
37500 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37501 this.el.setStyle('position', 'absolute');
37506 * Returns the toolbar for this Panel if one was configured.
37507 * @return {Roo.Toolbar}
37509 getToolbar : function(){
37510 return this.toolbar;
37513 setActiveState : function(active)
37515 this.active = active;
37516 this.setActiveClass(active);
37518 if(this.fireEvent("deactivate", this) === false){
37523 this.fireEvent("activate", this);
37527 * Updates this panel's element
37528 * @param {String} content The new content
37529 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37531 setContent : function(content, loadScripts){
37532 this.el.update(content, loadScripts);
37535 ignoreResize : function(w, h){
37536 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37539 this.lastSize = {width: w, height: h};
37544 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37545 * @return {Roo.UpdateManager} The UpdateManager
37547 getUpdateManager : function(){
37548 return this.el.getUpdateManager();
37551 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37552 * @param {Object/String/Function} url The url for this request or a function to call to get the url or a config object containing any of the following options:
37555 url: "your-url.php",
37556 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37557 callback: yourFunction,
37558 scope: yourObject, //(optional scope)
37561 text: "Loading...",
37566 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37567 * are shorthand for <i>disableCaching</i>, <i>indicatorText</i> and <i>loadScripts</i> and are used to set their associated property on this panel UpdateManager instance.
37568 * @param {String/Object} params (optional) The parameters to pass as either a URL encoded string "param1=1&param2=2" or an object {param1: 1, param2: 2}
37569 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37570 * @param {Boolean} discardUrl (optional) By default when you execute an update the defaultUrl is changed to the last used URL. If true, it will not store the URL.
37571 * @return {Roo.ContentPanel} this
37574 var um = this.el.getUpdateManager();
37575 um.update.apply(um, arguments);
37581 * Set a URL to be used to load the content for this panel. When this panel is activated, the content will be loaded from that URL.
37582 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37583 * @param {String/Object} params (optional) The string params for the update call or an object of the params. See {@link Roo.UpdateManager#update} for more details. (Defaults to null)
37584 * @param {Boolean} loadOnce (optional) Whether to only load the content once. If this is false it makes the Ajax call every time this panel is activated. (Defaults to false)
37585 * @return {Roo.UpdateManager} The UpdateManager
37587 setUrl : function(url, params, loadOnce){
37588 if(this.refreshDelegate){
37589 this.removeListener("activate", this.refreshDelegate);
37591 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37592 this.on("activate", this.refreshDelegate);
37593 return this.el.getUpdateManager();
37596 _handleRefresh : function(url, params, loadOnce){
37597 if(!loadOnce || !this.loaded){
37598 var updater = this.el.getUpdateManager();
37599 updater.update(url, params, this._setLoaded.createDelegate(this));
37603 _setLoaded : function(){
37604 this.loaded = true;
37608 * Returns this panel's id
37611 getId : function(){
37616 * Returns this panel's element - used by regiosn to add.
37617 * @return {Roo.Element}
37619 getEl : function(){
37620 return this.wrapEl || this.el;
37625 adjustForComponents : function(width, height)
37627 //Roo.log('adjustForComponents ');
37628 if(this.resizeEl != this.el){
37629 width -= this.el.getFrameWidth('lr');
37630 height -= this.el.getFrameWidth('tb');
37633 var te = this.toolbar.getEl();
37634 te.setWidth(width);
37635 height -= te.getHeight();
37638 var te = this.footer.getEl();
37639 te.setWidth(width);
37640 height -= te.getHeight();
37644 if(this.adjustments){
37645 width += this.adjustments[0];
37646 height += this.adjustments[1];
37648 return {"width": width, "height": height};
37651 setSize : function(width, height){
37652 if(this.fitToFrame && !this.ignoreResize(width, height)){
37653 if(this.fitContainer && this.resizeEl != this.el){
37654 this.el.setSize(width, height);
37656 var size = this.adjustForComponents(width, height);
37657 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37658 this.fireEvent('resize', this, size.width, size.height);
37663 * Returns this panel's title
37666 getTitle : function(){
37668 if (typeof(this.title) != 'object') {
37673 for (var k in this.title) {
37674 if (!this.title.hasOwnProperty(k)) {
37678 if (k.indexOf('-') >= 0) {
37679 var s = k.split('-');
37680 for (var i = 0; i<s.length; i++) {
37681 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37684 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37691 * Set this panel's title
37692 * @param {String} title
37694 setTitle : function(title){
37695 this.title = title;
37697 this.region.updatePanelTitle(this, title);
37702 * Returns true is this panel was configured to be closable
37703 * @return {Boolean}
37705 isClosable : function(){
37706 return this.closable;
37709 beforeSlide : function(){
37711 this.resizeEl.clip();
37714 afterSlide : function(){
37716 this.resizeEl.unclip();
37720 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37721 * Will fail silently if the {@link #setUrl} method has not been called.
37722 * This does not activate the panel, just updates its content.
37724 refresh : function(){
37725 if(this.refreshDelegate){
37726 this.loaded = false;
37727 this.refreshDelegate();
37732 * Destroys this panel
37734 destroy : function(){
37735 this.el.removeAllListeners();
37736 var tempEl = document.createElement("span");
37737 tempEl.appendChild(this.el.dom);
37738 tempEl.innerHTML = "";
37744 * form - if the content panel contains a form - this is a reference to it.
37745 * @type {Roo.form.Form}
37749 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37750 * This contains a reference to it.
37756 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37766 * @param {Object} cfg Xtype definition of item to add.
37770 getChildContainer: function () {
37771 return this.getEl();
37776 var ret = new Roo.factory(cfg);
37781 if (cfg.xtype.match(/^Form$/)) {
37784 //if (this.footer) {
37785 // el = this.footer.container.insertSibling(false, 'before');
37787 el = this.el.createChild();
37790 this.form = new Roo.form.Form(cfg);
37793 if ( this.form.allItems.length) {
37794 this.form.render(el.dom);
37798 // should only have one of theses..
37799 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37800 // views.. should not be just added - used named prop 'view''
37802 cfg.el = this.el.appendChild(document.createElement("div"));
37805 var ret = new Roo.factory(cfg);
37807 ret.render && ret.render(false, ''); // render blank..
37817 * @class Roo.bootstrap.panel.Grid
37818 * @extends Roo.bootstrap.panel.Content
37820 * Create a new GridPanel.
37821 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37822 * @param {Object} config A the config object
37828 Roo.bootstrap.panel.Grid = function(config)
37832 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37833 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37835 config.el = this.wrapper;
37836 //this.el = this.wrapper;
37838 if (config.container) {
37839 // ctor'ed from a Border/panel.grid
37842 this.wrapper.setStyle("overflow", "hidden");
37843 this.wrapper.addClass('roo-grid-container');
37848 if(config.toolbar){
37849 var tool_el = this.wrapper.createChild();
37850 this.toolbar = Roo.factory(config.toolbar);
37852 if (config.toolbar.items) {
37853 ti = config.toolbar.items ;
37854 delete config.toolbar.items ;
37858 this.toolbar.render(tool_el);
37859 for(var i =0;i < ti.length;i++) {
37860 // Roo.log(['add child', items[i]]);
37861 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37863 this.toolbar.items = nitems;
37865 delete config.toolbar;
37868 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37869 config.grid.scrollBody = true;;
37870 config.grid.monitorWindowResize = false; // turn off autosizing
37871 config.grid.autoHeight = false;
37872 config.grid.autoWidth = false;
37874 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37876 if (config.background) {
37877 // render grid on panel activation (if panel background)
37878 this.on('activate', function(gp) {
37879 if (!gp.grid.rendered) {
37880 gp.grid.render(this.wrapper);
37881 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37886 this.grid.render(this.wrapper);
37887 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37890 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37891 // ??? needed ??? config.el = this.wrapper;
37896 // xtype created footer. - not sure if will work as we normally have to render first..
37897 if (this.footer && !this.footer.el && this.footer.xtype) {
37899 var ctr = this.grid.getView().getFooterPanel(true);
37900 this.footer.dataSource = this.grid.dataSource;
37901 this.footer = Roo.factory(this.footer, Roo);
37902 this.footer.render(ctr);
37912 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37913 getId : function(){
37914 return this.grid.id;
37918 * Returns the grid for this panel
37919 * @return {Roo.bootstrap.Table}
37921 getGrid : function(){
37925 setSize : function(width, height){
37926 if(!this.ignoreResize(width, height)){
37927 var grid = this.grid;
37928 var size = this.adjustForComponents(width, height);
37929 var gridel = grid.getGridEl();
37930 gridel.setSize(size.width, size.height);
37932 var thd = grid.getGridEl().select('thead',true).first();
37933 var tbd = grid.getGridEl().select('tbody', true).first();
37935 tbd.setSize(width, height - thd.getHeight());
37944 beforeSlide : function(){
37945 this.grid.getView().scroller.clip();
37948 afterSlide : function(){
37949 this.grid.getView().scroller.unclip();
37952 destroy : function(){
37953 this.grid.destroy();
37955 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37960 * @class Roo.bootstrap.panel.Nest
37961 * @extends Roo.bootstrap.panel.Content
37963 * Create a new Panel, that can contain a layout.Border.
37966 * @param {Roo.BorderLayout} layout The layout for this panel
37967 * @param {String/Object} config A string to set only the title or a config object
37969 Roo.bootstrap.panel.Nest = function(config)
37971 // construct with only one argument..
37972 /* FIXME - implement nicer consturctors
37973 if (layout.layout) {
37975 layout = config.layout;
37976 delete config.layout;
37978 if (layout.xtype && !layout.getEl) {
37979 // then layout needs constructing..
37980 layout = Roo.factory(layout, Roo);
37984 config.el = config.layout.getEl();
37986 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37988 config.layout.monitorWindowResize = false; // turn off autosizing
37989 this.layout = config.layout;
37990 this.layout.getEl().addClass("roo-layout-nested-layout");
37991 this.layout.parent = this;
37998 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
38000 setSize : function(width, height){
38001 if(!this.ignoreResize(width, height)){
38002 var size = this.adjustForComponents(width, height);
38003 var el = this.layout.getEl();
38004 if (size.height < 1) {
38005 el.setWidth(size.width);
38007 el.setSize(size.width, size.height);
38009 var touch = el.dom.offsetWidth;
38010 this.layout.layout();
38011 // ie requires a double layout on the first pass
38012 if(Roo.isIE && !this.initialized){
38013 this.initialized = true;
38014 this.layout.layout();
38019 // activate all subpanels if not currently active..
38021 setActiveState : function(active){
38022 this.active = active;
38023 this.setActiveClass(active);
38026 this.fireEvent("deactivate", this);
38030 this.fireEvent("activate", this);
38031 // not sure if this should happen before or after..
38032 if (!this.layout) {
38033 return; // should not happen..
38036 for (var r in this.layout.regions) {
38037 reg = this.layout.getRegion(r);
38038 if (reg.getActivePanel()) {
38039 //reg.showPanel(reg.getActivePanel()); // force it to activate..
38040 reg.setActivePanel(reg.getActivePanel());
38043 if (!reg.panels.length) {
38046 reg.showPanel(reg.getPanel(0));
38055 * Returns the nested BorderLayout for this panel
38056 * @return {Roo.BorderLayout}
38058 getLayout : function(){
38059 return this.layout;
38063 * Adds a xtype elements to the layout of the nested panel
38067 xtype : 'ContentPanel',
38074 xtype : 'NestedLayoutPanel',
38080 items : [ ... list of content panels or nested layout panels.. ]
38084 * @param {Object} cfg Xtype definition of item to add.
38086 addxtype : function(cfg) {
38087 return this.layout.addxtype(cfg);
38092 * Ext JS Library 1.1.1
38093 * Copyright(c) 2006-2007, Ext JS, LLC.
38095 * Originally Released Under LGPL - original licence link has changed is not relivant.
38098 * <script type="text/javascript">
38101 * @class Roo.TabPanel
38102 * @extends Roo.util.Observable
38103 * A lightweight tab container.
38107 // basic tabs 1, built from existing content
38108 var tabs = new Roo.TabPanel("tabs1");
38109 tabs.addTab("script", "View Script");
38110 tabs.addTab("markup", "View Markup");
38111 tabs.activate("script");
38113 // more advanced tabs, built from javascript
38114 var jtabs = new Roo.TabPanel("jtabs");
38115 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38117 // set up the UpdateManager
38118 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38119 var updater = tab2.getUpdateManager();
38120 updater.setDefaultUrl("ajax1.htm");
38121 tab2.on('activate', updater.refresh, updater, true);
38123 // Use setUrl for Ajax loading
38124 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38125 tab3.setUrl("ajax2.htm", null, true);
38128 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38131 jtabs.activate("jtabs-1");
38134 * Create a new TabPanel.
38135 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38136 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38138 Roo.bootstrap.panel.Tabs = function(config){
38140 * The container element for this TabPanel.
38141 * @type Roo.Element
38143 this.el = Roo.get(config.el);
38146 if(typeof config == "boolean"){
38147 this.tabPosition = config ? "bottom" : "top";
38149 Roo.apply(this, config);
38153 if(this.tabPosition == "bottom"){
38154 // if tabs are at the bottom = create the body first.
38155 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38156 this.el.addClass("roo-tabs-bottom");
38158 // next create the tabs holders
38160 if (this.tabPosition == "west"){
38162 var reg = this.region; // fake it..
38164 if (!reg.mgr.parent) {
38167 reg = reg.mgr.parent.region;
38169 Roo.log("got nest?");
38171 if (reg.mgr.getRegion('west')) {
38172 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38173 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38174 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38175 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38176 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38184 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38185 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38186 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38187 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38192 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38195 // finally - if tabs are at the top, then create the body last..
38196 if(this.tabPosition != "bottom"){
38197 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38198 * @type Roo.Element
38200 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38201 this.el.addClass("roo-tabs-top");
38205 this.bodyEl.setStyle("position", "relative");
38207 this.active = null;
38208 this.activateDelegate = this.activate.createDelegate(this);
38213 * Fires when the active tab changes
38214 * @param {Roo.TabPanel} this
38215 * @param {Roo.TabPanelItem} activePanel The new active tab
38219 * @event beforetabchange
38220 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38221 * @param {Roo.TabPanel} this
38222 * @param {Object} e Set cancel to true on this object to cancel the tab change
38223 * @param {Roo.TabPanelItem} tab The tab being changed to
38225 "beforetabchange" : true
38228 Roo.EventManager.onWindowResize(this.onResize, this);
38229 this.cpad = this.el.getPadding("lr");
38230 this.hiddenCount = 0;
38233 // toolbar on the tabbar support...
38234 if (this.toolbar) {
38235 alert("no toolbar support yet");
38236 this.toolbar = false;
38238 var tcfg = this.toolbar;
38239 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38240 this.toolbar = new Roo.Toolbar(tcfg);
38241 if (Roo.isSafari) {
38242 var tbl = tcfg.container.child('table', true);
38243 tbl.setAttribute('width', '100%');
38251 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38254 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38256 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38258 tabPosition : "top",
38260 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38262 currentTabWidth : 0,
38264 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38268 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38272 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38274 preferredTabWidth : 175,
38276 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38278 resizeTabs : false,
38280 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38282 monitorResize : true,
38284 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38286 toolbar : false, // set by caller..
38288 region : false, /// set by caller
38290 disableTooltips : true, // not used yet...
38293 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38294 * @param {String} id The id of the div to use <b>or create</b>
38295 * @param {String} text The text for the tab
38296 * @param {String} content (optional) Content to put in the TabPanelItem body
38297 * @param {Boolean} closable (optional) True to create a close icon on the tab
38298 * @return {Roo.TabPanelItem} The created TabPanelItem
38300 addTab : function(id, text, content, closable, tpl)
38302 var item = new Roo.bootstrap.panel.TabItem({
38306 closable : closable,
38309 this.addTabItem(item);
38311 item.setContent(content);
38317 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38318 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38319 * @return {Roo.TabPanelItem}
38321 getTab : function(id){
38322 return this.items[id];
38326 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38327 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38329 hideTab : function(id){
38330 var t = this.items[id];
38333 this.hiddenCount++;
38334 this.autoSizeTabs();
38339 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38340 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38342 unhideTab : function(id){
38343 var t = this.items[id];
38345 t.setHidden(false);
38346 this.hiddenCount--;
38347 this.autoSizeTabs();
38352 * Adds an existing {@link Roo.TabPanelItem}.
38353 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38355 addTabItem : function(item)
38357 this.items[item.id] = item;
38358 this.items.push(item);
38359 this.autoSizeTabs();
38360 // if(this.resizeTabs){
38361 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38362 // this.autoSizeTabs();
38364 // item.autoSize();
38369 * Removes a {@link Roo.TabPanelItem}.
38370 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38372 removeTab : function(id){
38373 var items = this.items;
38374 var tab = items[id];
38375 if(!tab) { return; }
38376 var index = items.indexOf(tab);
38377 if(this.active == tab && items.length > 1){
38378 var newTab = this.getNextAvailable(index);
38383 this.stripEl.dom.removeChild(tab.pnode.dom);
38384 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38385 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38387 items.splice(index, 1);
38388 delete this.items[tab.id];
38389 tab.fireEvent("close", tab);
38390 tab.purgeListeners();
38391 this.autoSizeTabs();
38394 getNextAvailable : function(start){
38395 var items = this.items;
38397 // look for a next tab that will slide over to
38398 // replace the one being removed
38399 while(index < items.length){
38400 var item = items[++index];
38401 if(item && !item.isHidden()){
38405 // if one isn't found select the previous tab (on the left)
38408 var item = items[--index];
38409 if(item && !item.isHidden()){
38417 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38418 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38420 disableTab : function(id){
38421 var tab = this.items[id];
38422 if(tab && this.active != tab){
38428 * Enables a {@link Roo.TabPanelItem} that is disabled.
38429 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38431 enableTab : function(id){
38432 var tab = this.items[id];
38437 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38438 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38439 * @return {Roo.TabPanelItem} The TabPanelItem.
38441 activate : function(id)
38443 //Roo.log('activite:' + id);
38445 var tab = this.items[id];
38449 if(tab == this.active || tab.disabled){
38453 this.fireEvent("beforetabchange", this, e, tab);
38454 if(e.cancel !== true && !tab.disabled){
38456 this.active.hide();
38458 this.active = this.items[id];
38459 this.active.show();
38460 this.fireEvent("tabchange", this, this.active);
38466 * Gets the active {@link Roo.TabPanelItem}.
38467 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38469 getActiveTab : function(){
38470 return this.active;
38474 * Updates the tab body element to fit the height of the container element
38475 * for overflow scrolling
38476 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38478 syncHeight : function(targetHeight){
38479 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38480 var bm = this.bodyEl.getMargins();
38481 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38482 this.bodyEl.setHeight(newHeight);
38486 onResize : function(){
38487 if(this.monitorResize){
38488 this.autoSizeTabs();
38493 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38495 beginUpdate : function(){
38496 this.updating = true;
38500 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38502 endUpdate : function(){
38503 this.updating = false;
38504 this.autoSizeTabs();
38508 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38510 autoSizeTabs : function()
38512 var count = this.items.length;
38513 var vcount = count - this.hiddenCount;
38516 this.stripEl.hide();
38518 this.stripEl.show();
38521 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38526 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38527 var availWidth = Math.floor(w / vcount);
38528 var b = this.stripBody;
38529 if(b.getWidth() > w){
38530 var tabs = this.items;
38531 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38532 if(availWidth < this.minTabWidth){
38533 /*if(!this.sleft){ // incomplete scrolling code
38534 this.createScrollButtons();
38537 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38540 if(this.currentTabWidth < this.preferredTabWidth){
38541 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38547 * Returns the number of tabs in this TabPanel.
38550 getCount : function(){
38551 return this.items.length;
38555 * Resizes all the tabs to the passed width
38556 * @param {Number} The new width
38558 setTabWidth : function(width){
38559 this.currentTabWidth = width;
38560 for(var i = 0, len = this.items.length; i < len; i++) {
38561 if(!this.items[i].isHidden()) {
38562 this.items[i].setWidth(width);
38568 * Destroys this TabPanel
38569 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38571 destroy : function(removeEl){
38572 Roo.EventManager.removeResizeListener(this.onResize, this);
38573 for(var i = 0, len = this.items.length; i < len; i++){
38574 this.items[i].purgeListeners();
38576 if(removeEl === true){
38577 this.el.update("");
38582 createStrip : function(container)
38584 var strip = document.createElement("nav");
38585 strip.className = Roo.bootstrap.version == 4 ?
38586 "navbar-light bg-light" :
38587 "navbar navbar-default"; //"x-tabs-wrap";
38588 container.appendChild(strip);
38592 createStripList : function(strip)
38594 // div wrapper for retard IE
38595 // returns the "tr" element.
38596 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38597 //'<div class="x-tabs-strip-wrap">'+
38598 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38599 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38600 return strip.firstChild; //.firstChild.firstChild.firstChild;
38602 createBody : function(container)
38604 var body = document.createElement("div");
38605 Roo.id(body, "tab-body");
38606 //Roo.fly(body).addClass("x-tabs-body");
38607 Roo.fly(body).addClass("tab-content");
38608 container.appendChild(body);
38611 createItemBody :function(bodyEl, id){
38612 var body = Roo.getDom(id);
38614 body = document.createElement("div");
38617 //Roo.fly(body).addClass("x-tabs-item-body");
38618 Roo.fly(body).addClass("tab-pane");
38619 bodyEl.insertBefore(body, bodyEl.firstChild);
38623 createStripElements : function(stripEl, text, closable, tpl)
38625 var td = document.createElement("li"); // was td..
38626 td.className = 'nav-item';
38628 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38631 stripEl.appendChild(td);
38633 td.className = "x-tabs-closable";
38634 if(!this.closeTpl){
38635 this.closeTpl = new Roo.Template(
38636 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38637 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38638 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38641 var el = this.closeTpl.overwrite(td, {"text": text});
38642 var close = el.getElementsByTagName("div")[0];
38643 var inner = el.getElementsByTagName("em")[0];
38644 return {"el": el, "close": close, "inner": inner};
38647 // not sure what this is..
38648 // if(!this.tabTpl){
38649 //this.tabTpl = new Roo.Template(
38650 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38651 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38653 // this.tabTpl = new Roo.Template(
38654 // '<a href="#">' +
38655 // '<span unselectable="on"' +
38656 // (this.disableTooltips ? '' : ' title="{text}"') +
38657 // ' >{text}</span></a>'
38663 var template = tpl || this.tabTpl || false;
38666 template = new Roo.Template(
38667 Roo.bootstrap.version == 4 ?
38669 '<a class="nav-link" href="#" unselectable="on"' +
38670 (this.disableTooltips ? '' : ' title="{text}"') +
38673 '<a class="nav-link" href="#">' +
38674 '<span unselectable="on"' +
38675 (this.disableTooltips ? '' : ' title="{text}"') +
38676 ' >{text}</span></a>'
38681 switch (typeof(template)) {
38685 template = new Roo.Template(template);
38691 var el = template.overwrite(td, {"text": text});
38693 var inner = el.getElementsByTagName("span")[0];
38695 return {"el": el, "inner": inner};
38703 * @class Roo.TabPanelItem
38704 * @extends Roo.util.Observable
38705 * Represents an individual item (tab plus body) in a TabPanel.
38706 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38707 * @param {String} id The id of this TabPanelItem
38708 * @param {String} text The text for the tab of this TabPanelItem
38709 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38711 Roo.bootstrap.panel.TabItem = function(config){
38713 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38714 * @type Roo.TabPanel
38716 this.tabPanel = config.panel;
38718 * The id for this TabPanelItem
38721 this.id = config.id;
38723 this.disabled = false;
38725 this.text = config.text;
38727 this.loaded = false;
38728 this.closable = config.closable;
38731 * The body element for this TabPanelItem.
38732 * @type Roo.Element
38734 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38735 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38736 this.bodyEl.setStyle("display", "block");
38737 this.bodyEl.setStyle("zoom", "1");
38738 //this.hideAction();
38740 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38742 this.el = Roo.get(els.el);
38743 this.inner = Roo.get(els.inner, true);
38744 this.textEl = Roo.bootstrap.version == 4 ?
38745 this.el : Roo.get(this.el.dom.firstChild, true);
38747 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38748 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38751 // this.el.on("mousedown", this.onTabMouseDown, this);
38752 this.el.on("click", this.onTabClick, this);
38754 if(config.closable){
38755 var c = Roo.get(els.close, true);
38756 c.dom.title = this.closeText;
38757 c.addClassOnOver("close-over");
38758 c.on("click", this.closeClick, this);
38764 * Fires when this tab becomes the active tab.
38765 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38766 * @param {Roo.TabPanelItem} this
38770 * @event beforeclose
38771 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38772 * @param {Roo.TabPanelItem} this
38773 * @param {Object} e Set cancel to true on this object to cancel the close.
38775 "beforeclose": true,
38778 * Fires when this tab is closed.
38779 * @param {Roo.TabPanelItem} this
38783 * @event deactivate
38784 * Fires when this tab is no longer the active tab.
38785 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38786 * @param {Roo.TabPanelItem} this
38788 "deactivate" : true
38790 this.hidden = false;
38792 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38795 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38797 purgeListeners : function(){
38798 Roo.util.Observable.prototype.purgeListeners.call(this);
38799 this.el.removeAllListeners();
38802 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38805 this.status_node.addClass("active");
38808 this.tabPanel.stripWrap.repaint();
38810 this.fireEvent("activate", this.tabPanel, this);
38814 * Returns true if this tab is the active tab.
38815 * @return {Boolean}
38817 isActive : function(){
38818 return this.tabPanel.getActiveTab() == this;
38822 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38825 this.status_node.removeClass("active");
38827 this.fireEvent("deactivate", this.tabPanel, this);
38830 hideAction : function(){
38831 this.bodyEl.hide();
38832 this.bodyEl.setStyle("position", "absolute");
38833 this.bodyEl.setLeft("-20000px");
38834 this.bodyEl.setTop("-20000px");
38837 showAction : function(){
38838 this.bodyEl.setStyle("position", "relative");
38839 this.bodyEl.setTop("");
38840 this.bodyEl.setLeft("");
38841 this.bodyEl.show();
38845 * Set the tooltip for the tab.
38846 * @param {String} tooltip The tab's tooltip
38848 setTooltip : function(text){
38849 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38850 this.textEl.dom.qtip = text;
38851 this.textEl.dom.removeAttribute('title');
38853 this.textEl.dom.title = text;
38857 onTabClick : function(e){
38858 e.preventDefault();
38859 this.tabPanel.activate(this.id);
38862 onTabMouseDown : function(e){
38863 e.preventDefault();
38864 this.tabPanel.activate(this.id);
38867 getWidth : function(){
38868 return this.inner.getWidth();
38871 setWidth : function(width){
38872 var iwidth = width - this.linode.getPadding("lr");
38873 this.inner.setWidth(iwidth);
38874 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38875 this.linode.setWidth(width);
38879 * Show or hide the tab
38880 * @param {Boolean} hidden True to hide or false to show.
38882 setHidden : function(hidden){
38883 this.hidden = hidden;
38884 this.linode.setStyle("display", hidden ? "none" : "");
38888 * Returns true if this tab is "hidden"
38889 * @return {Boolean}
38891 isHidden : function(){
38892 return this.hidden;
38896 * Returns the text for this tab
38899 getText : function(){
38903 autoSize : function(){
38904 //this.el.beginMeasure();
38905 this.textEl.setWidth(1);
38907 * #2804 [new] Tabs in Roojs
38908 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38910 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38911 //this.el.endMeasure();
38915 * Sets the text for the tab (Note: this also sets the tooltip text)
38916 * @param {String} text The tab's text and tooltip
38918 setText : function(text){
38920 this.textEl.update(text);
38921 this.setTooltip(text);
38922 //if(!this.tabPanel.resizeTabs){
38923 // this.autoSize();
38927 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38929 activate : function(){
38930 this.tabPanel.activate(this.id);
38934 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38936 disable : function(){
38937 if(this.tabPanel.active != this){
38938 this.disabled = true;
38939 this.status_node.addClass("disabled");
38944 * Enables this TabPanelItem if it was previously disabled.
38946 enable : function(){
38947 this.disabled = false;
38948 this.status_node.removeClass("disabled");
38952 * Sets the content for this TabPanelItem.
38953 * @param {String} content The content
38954 * @param {Boolean} loadScripts true to look for and load scripts
38956 setContent : function(content, loadScripts){
38957 this.bodyEl.update(content, loadScripts);
38961 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38962 * @return {Roo.UpdateManager} The UpdateManager
38964 getUpdateManager : function(){
38965 return this.bodyEl.getUpdateManager();
38969 * Set a URL to be used to load the content for this TabPanelItem.
38970 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38971 * @param {String/Object} params (optional) The string params for the update call or an object of the params. See {@link Roo.UpdateManager#update} for more details. (Defaults to null)
38972 * @param {Boolean} loadOnce (optional) Whether to only load the content once. If this is false it makes the Ajax call every time this TabPanelItem is activated. (Defaults to false)
38973 * @return {Roo.UpdateManager} The UpdateManager
38975 setUrl : function(url, params, loadOnce){
38976 if(this.refreshDelegate){
38977 this.un('activate', this.refreshDelegate);
38979 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38980 this.on("activate", this.refreshDelegate);
38981 return this.bodyEl.getUpdateManager();
38985 _handleRefresh : function(url, params, loadOnce){
38986 if(!loadOnce || !this.loaded){
38987 var updater = this.bodyEl.getUpdateManager();
38988 updater.update(url, params, this._setLoaded.createDelegate(this));
38993 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38994 * Will fail silently if the setUrl method has not been called.
38995 * This does not activate the panel, just updates its content.
38997 refresh : function(){
38998 if(this.refreshDelegate){
38999 this.loaded = false;
39000 this.refreshDelegate();
39005 _setLoaded : function(){
39006 this.loaded = true;
39010 closeClick : function(e){
39013 this.fireEvent("beforeclose", this, o);
39014 if(o.cancel !== true){
39015 this.tabPanel.removeTab(this.id);
39019 * The text displayed in the tooltip for the close icon.
39022 closeText : "Close this tab"
39025 * This script refer to:
39026 * Title: International Telephone Input
39027 * Author: Jack O'Connor
39028 * Code version: v12.1.12
39029 * Availability: https://github.com/jackocnr/intl-tel-input.git
39032 Roo.bootstrap.PhoneInputData = function() {
39035 "Afghanistan (افغانستان)",
39040 "Albania (Shqipëri)",
39045 "Algeria (الجزائر)",
39070 "Antigua and Barbuda",
39080 "Armenia (Հայաստան)",
39096 "Austria (Österreich)",
39101 "Azerbaijan (Azərbaycan)",
39111 "Bahrain (البحرين)",
39116 "Bangladesh (বাংলাদেশ)",
39126 "Belarus (Беларусь)",
39131 "Belgium (België)",
39161 "Bosnia and Herzegovina (Босна и Херцеговина)",
39176 "British Indian Ocean Territory",
39181 "British Virgin Islands",
39191 "Bulgaria (България)",
39201 "Burundi (Uburundi)",
39206 "Cambodia (កម្ពុជា)",
39211 "Cameroon (Cameroun)",
39220 ["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]
39223 "Cape Verde (Kabu Verdi)",
39228 "Caribbean Netherlands",
39239 "Central African Republic (République centrafricaine)",
39259 "Christmas Island",
39265 "Cocos (Keeling) Islands",
39276 "Comoros (جزر القمر)",
39281 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39286 "Congo (Republic) (Congo-Brazzaville)",
39306 "Croatia (Hrvatska)",
39327 "Czech Republic (Česká republika)",
39332 "Denmark (Danmark)",
39347 "Dominican Republic (República Dominicana)",
39351 ["809", "829", "849"]
39369 "Equatorial Guinea (Guinea Ecuatorial)",
39389 "Falkland Islands (Islas Malvinas)",
39394 "Faroe Islands (Føroyar)",
39415 "French Guiana (Guyane française)",
39420 "French Polynesia (Polynésie française)",
39435 "Georgia (საქართველო)",
39440 "Germany (Deutschland)",
39460 "Greenland (Kalaallit Nunaat)",
39497 "Guinea-Bissau (Guiné Bissau)",
39522 "Hungary (Magyarország)",
39527 "Iceland (Ísland)",
39547 "Iraq (العراق)",
39563 "Israel (ישראל)",
39590 "Jordan (الأردن)",
39595 "Kazakhstan (Казахстан)",
39616 "Kuwait (الكويت)",
39621 "Kyrgyzstan (Кыргызстан)",
39631 "Latvia (Latvija)",
39636 "Lebanon (لبنان)",
39651 "Libya (ليبيا)",
39661 "Lithuania (Lietuva)",
39676 "Macedonia (FYROM) (Македонија)",
39681 "Madagascar (Madagasikara)",
39711 "Marshall Islands",
39721 "Mauritania (موريتانيا)",
39726 "Mauritius (Moris)",
39747 "Moldova (Republica Moldova)",
39757 "Mongolia (Монгол)",
39762 "Montenegro (Crna Gora)",
39772 "Morocco (المغرب)",
39778 "Mozambique (Moçambique)",
39783 "Myanmar (Burma) (မြန်မာ)",
39788 "Namibia (Namibië)",
39803 "Netherlands (Nederland)",
39808 "New Caledonia (Nouvelle-Calédonie)",
39843 "North Korea (조선 민주주의 인민 공화국)",
39848 "Northern Mariana Islands",
39864 "Pakistan (پاکستان)",
39874 "Palestine (فلسطين)",
39884 "Papua New Guinea",
39926 "Réunion (La Réunion)",
39932 "Romania (România)",
39948 "Saint Barthélemy",
39959 "Saint Kitts and Nevis",
39969 "Saint Martin (Saint-Martin (partie française))",
39975 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39980 "Saint Vincent and the Grenadines",
39995 "São Tomé and Príncipe (São Tomé e Príncipe)",
40000 "Saudi Arabia (المملكة العربية السعودية)",
40005 "Senegal (Sénégal)",
40035 "Slovakia (Slovensko)",
40040 "Slovenia (Slovenija)",
40050 "Somalia (Soomaaliya)",
40060 "South Korea (대한민국)",
40065 "South Sudan (جنوب السودان)",
40075 "Sri Lanka (ශ්රී ලංකාව)",
40080 "Sudan (السودان)",
40090 "Svalbard and Jan Mayen",
40101 "Sweden (Sverige)",
40106 "Switzerland (Schweiz)",
40111 "Syria (سوريا)",
40156 "Trinidad and Tobago",
40161 "Tunisia (تونس)",
40166 "Turkey (Türkiye)",
40176 "Turks and Caicos Islands",
40186 "U.S. Virgin Islands",
40196 "Ukraine (Україна)",
40201 "United Arab Emirates (الإمارات العربية المتحدة)",
40223 "Uzbekistan (Oʻzbekiston)",
40233 "Vatican City (Città del Vaticano)",
40244 "Vietnam (Việt Nam)",
40249 "Wallis and Futuna (Wallis-et-Futuna)",
40254 "Western Sahara (الصحراء الغربية)",
40260 "Yemen (اليمن)",
40284 * This script refer to:
40285 * Title: International Telephone Input
40286 * Author: Jack O'Connor
40287 * Code version: v12.1.12
40288 * Availability: https://github.com/jackocnr/intl-tel-input.git
40292 * @class Roo.bootstrap.PhoneInput
40293 * @extends Roo.bootstrap.TriggerField
40294 * An input with International dial-code selection
40296 * @cfg {String} defaultDialCode default '+852'
40297 * @cfg {Array} preferedCountries default []
40300 * Create a new PhoneInput.
40301 * @param {Object} config Configuration options
40304 Roo.bootstrap.PhoneInput = function(config) {
40305 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40308 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40310 listWidth: undefined,
40312 selectedClass: 'active',
40314 invalidClass : "has-warning",
40316 validClass: 'has-success',
40318 allowed: '0123456789',
40323 * @cfg {String} defaultDialCode The default dial code when initializing the input
40325 defaultDialCode: '+852',
40328 * @cfg {Array} preferedCountries A list of iso2 in array (e.g. ['hk','us']). Those related countries will show at the top of the input's choices
40330 preferedCountries: false,
40332 getAutoCreate : function()
40334 var data = Roo.bootstrap.PhoneInputData();
40335 var align = this.labelAlign || this.parentLabelAlign();
40338 this.allCountries = [];
40339 this.dialCodeMapping = [];
40341 for (var i = 0; i < data.length; i++) {
40343 this.allCountries[i] = {
40347 priority: c[3] || 0,
40348 areaCodes: c[4] || null
40350 this.dialCodeMapping[c[2]] = {
40353 priority: c[3] || 0,
40354 areaCodes: c[4] || null
40366 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40367 maxlength: this.max_length,
40368 cls : 'form-control tel-input',
40369 autocomplete: 'new-password'
40372 var hiddenInput = {
40375 cls: 'hidden-tel-input'
40379 hiddenInput.name = this.name;
40382 if (this.disabled) {
40383 input.disabled = true;
40386 var flag_container = {
40403 cls: this.hasFeedback ? 'has-feedback' : '',
40409 cls: 'dial-code-holder',
40416 cls: 'roo-select2-container input-group',
40423 if (this.fieldLabel.length) {
40426 tooltip: 'This field is required'
40432 cls: 'control-label',
40438 html: this.fieldLabel
40441 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40447 if(this.indicatorpos == 'right') {
40448 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40455 if(align == 'left') {
40463 if(this.labelWidth > 12){
40464 label.style = "width: " + this.labelWidth + 'px';
40466 if(this.labelWidth < 13 && this.labelmd == 0){
40467 this.labelmd = this.labelWidth;
40469 if(this.labellg > 0){
40470 label.cls += ' col-lg-' + this.labellg;
40471 input.cls += ' col-lg-' + (12 - this.labellg);
40473 if(this.labelmd > 0){
40474 label.cls += ' col-md-' + this.labelmd;
40475 container.cls += ' col-md-' + (12 - this.labelmd);
40477 if(this.labelsm > 0){
40478 label.cls += ' col-sm-' + this.labelsm;
40479 container.cls += ' col-sm-' + (12 - this.labelsm);
40481 if(this.labelxs > 0){
40482 label.cls += ' col-xs-' + this.labelxs;
40483 container.cls += ' col-xs-' + (12 - this.labelxs);
40493 var settings = this;
40495 ['xs','sm','md','lg'].map(function(size){
40496 if (settings[size]) {
40497 cfg.cls += ' col-' + size + '-' + settings[size];
40501 this.store = new Roo.data.Store({
40502 proxy : new Roo.data.MemoryProxy({}),
40503 reader : new Roo.data.JsonReader({
40514 'name' : 'dialCode',
40518 'name' : 'priority',
40522 'name' : 'areaCodes',
40529 if(!this.preferedCountries) {
40530 this.preferedCountries = [
40537 var p = this.preferedCountries.reverse();
40540 for (var i = 0; i < p.length; i++) {
40541 for (var j = 0; j < this.allCountries.length; j++) {
40542 if(this.allCountries[j].iso2 == p[i]) {
40543 var t = this.allCountries[j];
40544 this.allCountries.splice(j,1);
40545 this.allCountries.unshift(t);
40551 this.store.proxy.data = {
40553 data: this.allCountries
40559 initEvents : function()
40562 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40564 this.indicator = this.indicatorEl();
40565 this.flag = this.flagEl();
40566 this.dialCodeHolder = this.dialCodeHolderEl();
40568 this.trigger = this.el.select('div.flag-box',true).first();
40569 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40574 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40575 _this.list.setWidth(lw);
40578 this.list.on('mouseover', this.onViewOver, this);
40579 this.list.on('mousemove', this.onViewMove, this);
40580 this.inputEl().on("keyup", this.onKeyUp, this);
40581 this.inputEl().on("keypress", this.onKeyPress, this);
40583 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40585 this.view = new Roo.View(this.list, this.tpl, {
40586 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40589 this.view.on('click', this.onViewClick, this);
40590 this.setValue(this.defaultDialCode);
40593 onTriggerClick : function(e)
40595 Roo.log('trigger click');
40600 if(this.isExpanded()){
40602 this.hasFocus = false;
40604 this.store.load({});
40605 this.hasFocus = true;
40610 isExpanded : function()
40612 return this.list.isVisible();
40615 collapse : function()
40617 if(!this.isExpanded()){
40621 Roo.get(document).un('mousedown', this.collapseIf, this);
40622 Roo.get(document).un('mousewheel', this.collapseIf, this);
40623 this.fireEvent('collapse', this);
40627 expand : function()
40631 if(this.isExpanded() || !this.hasFocus){
40635 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40636 this.list.setWidth(lw);
40639 this.restrictHeight();
40641 Roo.get(document).on('mousedown', this.collapseIf, this);
40642 Roo.get(document).on('mousewheel', this.collapseIf, this);
40644 this.fireEvent('expand', this);
40647 restrictHeight : function()
40649 this.list.alignTo(this.inputEl(), this.listAlign);
40650 this.list.alignTo(this.inputEl(), this.listAlign);
40653 onViewOver : function(e, t)
40655 if(this.inKeyMode){
40658 var item = this.view.findItemFromChild(t);
40661 var index = this.view.indexOf(item);
40662 this.select(index, false);
40667 onViewClick : function(view, doFocus, el, e)
40669 var index = this.view.getSelectedIndexes()[0];
40671 var r = this.store.getAt(index);
40674 this.onSelect(r, index);
40676 if(doFocus !== false && !this.blockFocus){
40677 this.inputEl().focus();
40681 onViewMove : function(e, t)
40683 this.inKeyMode = false;
40686 select : function(index, scrollIntoView)
40688 this.selectedIndex = index;
40689 this.view.select(index);
40690 if(scrollIntoView !== false){
40691 var el = this.view.getNode(index);
40693 this.list.scrollChildIntoView(el, false);
40698 createList : function()
40700 this.list = Roo.get(document.body).createChild({
40702 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40703 style: 'display:none'
40706 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40709 collapseIf : function(e)
40711 var in_combo = e.within(this.el);
40712 var in_list = e.within(this.list);
40713 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40715 if (in_combo || in_list || is_list) {
40721 onSelect : function(record, index)
40723 if(this.fireEvent('beforeselect', this, record, index) !== false){
40725 this.setFlagClass(record.data.iso2);
40726 this.setDialCode(record.data.dialCode);
40727 this.hasFocus = false;
40729 this.fireEvent('select', this, record, index);
40733 flagEl : function()
40735 var flag = this.el.select('div.flag',true).first();
40742 dialCodeHolderEl : function()
40744 var d = this.el.select('input.dial-code-holder',true).first();
40751 setDialCode : function(v)
40753 this.dialCodeHolder.dom.value = '+'+v;
40756 setFlagClass : function(n)
40758 this.flag.dom.className = 'flag '+n;
40761 getValue : function()
40763 var v = this.inputEl().getValue();
40764 if(this.dialCodeHolder) {
40765 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40770 setValue : function(v)
40772 var d = this.getDialCode(v);
40774 //invalid dial code
40775 if(v.length == 0 || !d || d.length == 0) {
40777 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40778 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40784 this.setFlagClass(this.dialCodeMapping[d].iso2);
40785 this.setDialCode(d);
40786 this.inputEl().dom.value = v.replace('+'+d,'');
40787 this.hiddenEl().dom.value = this.getValue();
40792 getDialCode : function(v)
40796 if (v.length == 0) {
40797 return this.dialCodeHolder.dom.value;
40801 if (v.charAt(0) != "+") {
40804 var numericChars = "";
40805 for (var i = 1; i < v.length; i++) {
40806 var c = v.charAt(i);
40809 if (this.dialCodeMapping[numericChars]) {
40810 dialCode = v.substr(1, i);
40812 if (numericChars.length == 4) {
40822 this.setValue(this.defaultDialCode);
40826 hiddenEl : function()
40828 return this.el.select('input.hidden-tel-input',true).first();
40831 // after setting val
40832 onKeyUp : function(e){
40833 this.setValue(this.getValue());
40836 onKeyPress : function(e){
40837 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40844 * @class Roo.bootstrap.MoneyField
40845 * @extends Roo.bootstrap.ComboBox
40846 * Bootstrap MoneyField class
40849 * Create a new MoneyField.
40850 * @param {Object} config Configuration options
40853 Roo.bootstrap.MoneyField = function(config) {
40855 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40859 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40862 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40864 allowDecimals : true,
40866 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40868 decimalSeparator : ".",
40870 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40872 decimalPrecision : 0,
40874 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40876 allowNegative : true,
40878 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40882 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40884 minValue : Number.NEGATIVE_INFINITY,
40886 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40888 maxValue : Number.MAX_VALUE,
40890 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40892 minText : "The minimum value for this field is {0}",
40894 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40896 maxText : "The maximum value for this field is {0}",
40898 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40899 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40901 nanText : "{0} is not a valid number",
40903 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40907 * @cfg {String} defaults currency of the MoneyField
40908 * value should be in lkey
40910 defaultCurrency : false,
40912 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40914 thousandsDelimiter : false,
40916 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40927 getAutoCreate : function()
40929 var align = this.labelAlign || this.parentLabelAlign();
40941 cls : 'form-control roo-money-amount-input',
40942 autocomplete: 'new-password'
40945 var hiddenInput = {
40949 cls: 'hidden-number-input'
40952 if(this.max_length) {
40953 input.maxlength = this.max_length;
40957 hiddenInput.name = this.name;
40960 if (this.disabled) {
40961 input.disabled = true;
40964 var clg = 12 - this.inputlg;
40965 var cmd = 12 - this.inputmd;
40966 var csm = 12 - this.inputsm;
40967 var cxs = 12 - this.inputxs;
40971 cls : 'row roo-money-field',
40975 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40979 cls: 'roo-select2-container input-group',
40983 cls : 'form-control roo-money-currency-input',
40984 autocomplete: 'new-password',
40986 name : this.currencyName
40990 cls : 'input-group-addon',
41004 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
41008 cls: this.hasFeedback ? 'has-feedback' : '',
41019 if (this.fieldLabel.length) {
41022 tooltip: 'This field is required'
41028 cls: 'control-label',
41034 html: this.fieldLabel
41037 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
41043 if(this.indicatorpos == 'right') {
41044 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41051 if(align == 'left') {
41059 if(this.labelWidth > 12){
41060 label.style = "width: " + this.labelWidth + 'px';
41062 if(this.labelWidth < 13 && this.labelmd == 0){
41063 this.labelmd = this.labelWidth;
41065 if(this.labellg > 0){
41066 label.cls += ' col-lg-' + this.labellg;
41067 input.cls += ' col-lg-' + (12 - this.labellg);
41069 if(this.labelmd > 0){
41070 label.cls += ' col-md-' + this.labelmd;
41071 container.cls += ' col-md-' + (12 - this.labelmd);
41073 if(this.labelsm > 0){
41074 label.cls += ' col-sm-' + this.labelsm;
41075 container.cls += ' col-sm-' + (12 - this.labelsm);
41077 if(this.labelxs > 0){
41078 label.cls += ' col-xs-' + this.labelxs;
41079 container.cls += ' col-xs-' + (12 - this.labelxs);
41090 var settings = this;
41092 ['xs','sm','md','lg'].map(function(size){
41093 if (settings[size]) {
41094 cfg.cls += ' col-' + size + '-' + settings[size];
41101 initEvents : function()
41103 this.indicator = this.indicatorEl();
41105 this.initCurrencyEvent();
41107 this.initNumberEvent();
41110 initCurrencyEvent : function()
41113 throw "can not find store for combo";
41116 this.store = Roo.factory(this.store, Roo.data);
41117 this.store.parent = this;
41121 this.triggerEl = this.el.select('.input-group-addon', true).first();
41123 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41128 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41129 _this.list.setWidth(lw);
41132 this.list.on('mouseover', this.onViewOver, this);
41133 this.list.on('mousemove', this.onViewMove, this);
41134 this.list.on('scroll', this.onViewScroll, this);
41137 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41140 this.view = new Roo.View(this.list, this.tpl, {
41141 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41144 this.view.on('click', this.onViewClick, this);
41146 this.store.on('beforeload', this.onBeforeLoad, this);
41147 this.store.on('load', this.onLoad, this);
41148 this.store.on('loadexception', this.onLoadException, this);
41150 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41151 "up" : function(e){
41152 this.inKeyMode = true;
41156 "down" : function(e){
41157 if(!this.isExpanded()){
41158 this.onTriggerClick();
41160 this.inKeyMode = true;
41165 "enter" : function(e){
41168 if(this.fireEvent("specialkey", this, e)){
41169 this.onViewClick(false);
41175 "esc" : function(e){
41179 "tab" : function(e){
41182 if(this.fireEvent("specialkey", this, e)){
41183 this.onViewClick(false);
41191 doRelay : function(foo, bar, hname){
41192 if(hname == 'down' || this.scope.isExpanded()){
41193 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41201 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41205 initNumberEvent : function(e)
41207 this.inputEl().on("keydown" , this.fireKey, this);
41208 this.inputEl().on("focus", this.onFocus, this);
41209 this.inputEl().on("blur", this.onBlur, this);
41211 this.inputEl().relayEvent('keyup', this);
41213 if(this.indicator){
41214 this.indicator.addClass('invisible');
41217 this.originalValue = this.getValue();
41219 if(this.validationEvent == 'keyup'){
41220 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41221 this.inputEl().on('keyup', this.filterValidation, this);
41223 else if(this.validationEvent !== false){
41224 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41227 if(this.selectOnFocus){
41228 this.on("focus", this.preFocus, this);
41231 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41232 this.inputEl().on("keypress", this.filterKeys, this);
41234 this.inputEl().relayEvent('keypress', this);
41237 var allowed = "0123456789";
41239 if(this.allowDecimals){
41240 allowed += this.decimalSeparator;
41243 if(this.allowNegative){
41247 if(this.thousandsDelimiter) {
41251 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41253 var keyPress = function(e){
41255 var k = e.getKey();
41257 var c = e.getCharCode();
41260 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41261 allowed.indexOf(String.fromCharCode(c)) === -1
41267 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41271 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41276 this.inputEl().on("keypress", keyPress, this);
41280 onTriggerClick : function(e)
41287 this.loadNext = false;
41289 if(this.isExpanded()){
41294 this.hasFocus = true;
41296 if(this.triggerAction == 'all') {
41297 this.doQuery(this.allQuery, true);
41301 this.doQuery(this.getRawValue());
41304 getCurrency : function()
41306 var v = this.currencyEl().getValue();
41311 restrictHeight : function()
41313 this.list.alignTo(this.currencyEl(), this.listAlign);
41314 this.list.alignTo(this.currencyEl(), this.listAlign);
41317 onViewClick : function(view, doFocus, el, e)
41319 var index = this.view.getSelectedIndexes()[0];
41321 var r = this.store.getAt(index);
41324 this.onSelect(r, index);
41328 onSelect : function(record, index){
41330 if(this.fireEvent('beforeselect', this, record, index) !== false){
41332 this.setFromCurrencyData(index > -1 ? record.data : false);
41336 this.fireEvent('select', this, record, index);
41340 setFromCurrencyData : function(o)
41344 this.lastCurrency = o;
41346 if (this.currencyField) {
41347 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41349 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41352 this.lastSelectionText = currency;
41354 //setting default currency
41355 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41356 this.setCurrency(this.defaultCurrency);
41360 this.setCurrency(currency);
41363 setFromData : function(o)
41367 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41369 this.setFromCurrencyData(c);
41374 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41376 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41379 this.setValue(value);
41383 setCurrency : function(v)
41385 this.currencyValue = v;
41388 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41393 setValue : function(v)
41395 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41401 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41403 this.inputEl().dom.value = (v == '') ? '' :
41404 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41406 if(!this.allowZero && v === '0') {
41407 this.hiddenEl().dom.value = '';
41408 this.inputEl().dom.value = '';
41415 getRawValue : function()
41417 var v = this.inputEl().getValue();
41422 getValue : function()
41424 return this.fixPrecision(this.parseValue(this.getRawValue()));
41427 parseValue : function(value)
41429 if(this.thousandsDelimiter) {
41431 r = new RegExp(",", "g");
41432 value = value.replace(r, "");
41435 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41436 return isNaN(value) ? '' : value;
41440 fixPrecision : function(value)
41442 if(this.thousandsDelimiter) {
41444 r = new RegExp(",", "g");
41445 value = value.replace(r, "");
41448 var nan = isNaN(value);
41450 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41451 return nan ? '' : value;
41453 return parseFloat(value).toFixed(this.decimalPrecision);
41456 decimalPrecisionFcn : function(v)
41458 return Math.floor(v);
41461 validateValue : function(value)
41463 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41467 var num = this.parseValue(value);
41470 this.markInvalid(String.format(this.nanText, value));
41474 if(num < this.minValue){
41475 this.markInvalid(String.format(this.minText, this.minValue));
41479 if(num > this.maxValue){
41480 this.markInvalid(String.format(this.maxText, this.maxValue));
41487 validate : function()
41489 if(this.disabled || this.allowBlank){
41494 var currency = this.getCurrency();
41496 if(this.validateValue(this.getRawValue()) && currency.length){
41501 this.markInvalid();
41505 getName: function()
41510 beforeBlur : function()
41516 var v = this.parseValue(this.getRawValue());
41523 onBlur : function()
41527 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41528 //this.el.removeClass(this.focusClass);
41531 this.hasFocus = false;
41533 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41537 var v = this.getValue();
41539 if(String(v) !== String(this.startValue)){
41540 this.fireEvent('change', this, v, this.startValue);
41543 this.fireEvent("blur", this);
41546 inputEl : function()
41548 return this.el.select('.roo-money-amount-input', true).first();
41551 currencyEl : function()
41553 return this.el.select('.roo-money-currency-input', true).first();
41556 hiddenEl : function()
41558 return this.el.select('input.hidden-number-input',true).first();
41562 * @class Roo.bootstrap.BezierSignature
41563 * @extends Roo.bootstrap.Component
41564 * Bootstrap BezierSignature class
41565 * This script refer to:
41566 * Title: Signature Pad
41568 * Availability: https://github.com/szimek/signature_pad
41571 * Create a new BezierSignature
41572 * @param {Object} config The config object
41575 Roo.bootstrap.BezierSignature = function(config){
41576 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41582 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
41589 mouse_btn_down: true,
41592 * @cfg {int} canvas height
41594 canvas_height: '200px',
41597 * @cfg {float|function} Radius of a single dot.
41602 * @cfg {float} Minimum width of a line. Defaults to 0.5.
41607 * @cfg {float} Maximum width of a line. Defaults to 2.5.
41612 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41617 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41622 * @cfg {string} Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images.
41624 bg_color: 'rgba(0, 0, 0, 0)',
41627 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41629 dot_color: 'black',
41632 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41634 velocity_filter_weight: 0.7,
41637 * @cfg {function} Callback when stroke begin.
41642 * @cfg {function} Callback when stroke end.
41646 getAutoCreate : function()
41648 var cls = 'roo-signature column';
41651 cls += ' ' + this.cls;
41661 for(var i = 0; i < col_sizes.length; i++) {
41662 if(this[col_sizes[i]]) {
41663 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41673 cls: 'roo-signature-body',
41677 cls: 'roo-signature-body-canvas',
41678 height: this.canvas_height,
41679 width: this.canvas_width
41686 style: 'display: none'
41694 initEvents: function()
41696 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41698 var canvas = this.canvasEl();
41700 // mouse && touch event swapping...
41701 canvas.dom.style.touchAction = 'none';
41702 canvas.dom.style.msTouchAction = 'none';
41704 this.mouse_btn_down = false;
41705 canvas.on('mousedown', this._handleMouseDown, this);
41706 canvas.on('mousemove', this._handleMouseMove, this);
41707 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41709 if (window.PointerEvent) {
41710 canvas.on('pointerdown', this._handleMouseDown, this);
41711 canvas.on('pointermove', this._handleMouseMove, this);
41712 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41715 if ('ontouchstart' in window) {
41716 canvas.on('touchstart', this._handleTouchStart, this);
41717 canvas.on('touchmove', this._handleTouchMove, this);
41718 canvas.on('touchend', this._handleTouchEnd, this);
41721 Roo.EventManager.onWindowResize(this.resize, this, true);
41723 // file input event
41724 this.fileEl().on('change', this.uploadImage, this);
41731 resize: function(){
41733 var canvas = this.canvasEl().dom;
41734 var ctx = this.canvasElCtx();
41735 var img_data = false;
41737 if(canvas.width > 0) {
41738 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41740 // setting canvas width will clean img data
41743 var style = window.getComputedStyle ?
41744 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41746 var padding_left = parseInt(style.paddingLeft) || 0;
41747 var padding_right = parseInt(style.paddingRight) || 0;
41749 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41752 ctx.putImageData(img_data, 0, 0);
41756 _handleMouseDown: function(e)
41758 if (e.browserEvent.which === 1) {
41759 this.mouse_btn_down = true;
41760 this.strokeBegin(e);
41764 _handleMouseMove: function (e)
41766 if (this.mouse_btn_down) {
41767 this.strokeMoveUpdate(e);
41771 _handleMouseUp: function (e)
41773 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41774 this.mouse_btn_down = false;
41779 _handleTouchStart: function (e) {
41781 e.preventDefault();
41782 if (e.browserEvent.targetTouches.length === 1) {
41783 // var touch = e.browserEvent.changedTouches[0];
41784 // this.strokeBegin(touch);
41786 this.strokeBegin(e); // assume e catching the correct xy...
41790 _handleTouchMove: function (e) {
41791 e.preventDefault();
41792 // var touch = event.targetTouches[0];
41793 // _this._strokeMoveUpdate(touch);
41794 this.strokeMoveUpdate(e);
41797 _handleTouchEnd: function (e) {
41798 var wasCanvasTouched = e.target === this.canvasEl().dom;
41799 if (wasCanvasTouched) {
41800 e.preventDefault();
41801 // var touch = event.changedTouches[0];
41802 // _this._strokeEnd(touch);
41807 reset: function () {
41808 this._lastPoints = [];
41809 this._lastVelocity = 0;
41810 this._lastWidth = (this.min_width + this.max_width) / 2;
41811 this.canvasElCtx().fillStyle = this.dot_color;
41814 strokeMoveUpdate: function(e)
41816 this.strokeUpdate(e);
41818 if (this.throttle) {
41819 this.throttleStroke(this.strokeUpdate, this.throttle);
41822 this.strokeUpdate(e);
41826 strokeBegin: function(e)
41828 var newPointGroup = {
41829 color: this.dot_color,
41833 if (typeof this.onBegin === 'function') {
41837 this.curve_data.push(newPointGroup);
41839 this.strokeUpdate(e);
41842 strokeUpdate: function(e)
41844 var rect = this.canvasEl().dom.getBoundingClientRect();
41845 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41846 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41847 var lastPoints = lastPointGroup.points;
41848 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41849 var isLastPointTooClose = lastPoint
41850 ? point.distanceTo(lastPoint) <= this.min_distance
41852 var color = lastPointGroup.color;
41853 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41854 var curve = this.addPoint(point);
41856 this.drawDot({color: color, point: point});
41859 this.drawCurve({color: color, curve: curve});
41869 strokeEnd: function(e)
41871 this.strokeUpdate(e);
41872 if (typeof this.onEnd === 'function') {
41877 addPoint: function (point) {
41878 var _lastPoints = this._lastPoints;
41879 _lastPoints.push(point);
41880 if (_lastPoints.length > 2) {
41881 if (_lastPoints.length === 3) {
41882 _lastPoints.unshift(_lastPoints[0]);
41884 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41885 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41886 _lastPoints.shift();
41892 calculateCurveWidths: function (startPoint, endPoint) {
41893 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41894 (1 - this.velocity_filter_weight) * this._lastVelocity;
41896 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41899 start: this._lastWidth
41902 this._lastVelocity = velocity;
41903 this._lastWidth = newWidth;
41907 drawDot: function (_a) {
41908 var color = _a.color, point = _a.point;
41909 var ctx = this.canvasElCtx();
41910 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41912 this.drawCurveSegment(point.x, point.y, width);
41914 ctx.fillStyle = color;
41918 drawCurve: function (_a) {
41919 var color = _a.color, curve = _a.curve;
41920 var ctx = this.canvasElCtx();
41921 var widthDelta = curve.endWidth - curve.startWidth;
41922 var drawSteps = Math.floor(curve.length()) * 2;
41924 ctx.fillStyle = color;
41925 for (var i = 0; i < drawSteps; i += 1) {
41926 var t = i / drawSteps;
41932 var x = uuu * curve.startPoint.x;
41933 x += 3 * uu * t * curve.control1.x;
41934 x += 3 * u * tt * curve.control2.x;
41935 x += ttt * curve.endPoint.x;
41936 var y = uuu * curve.startPoint.y;
41937 y += 3 * uu * t * curve.control1.y;
41938 y += 3 * u * tt * curve.control2.y;
41939 y += ttt * curve.endPoint.y;
41940 var width = curve.startWidth + ttt * widthDelta;
41941 this.drawCurveSegment(x, y, width);
41947 drawCurveSegment: function (x, y, width) {
41948 var ctx = this.canvasElCtx();
41950 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41951 this.is_empty = false;
41956 var ctx = this.canvasElCtx();
41957 var canvas = this.canvasEl().dom;
41958 ctx.fillStyle = this.bg_color;
41959 ctx.clearRect(0, 0, canvas.width, canvas.height);
41960 ctx.fillRect(0, 0, canvas.width, canvas.height);
41961 this.curve_data = [];
41963 this.is_empty = true;
41968 return this.el.select('input',true).first();
41971 canvasEl: function()
41973 return this.el.select('canvas',true).first();
41976 canvasElCtx: function()
41978 return this.el.select('canvas',true).first().dom.getContext('2d');
41981 getImage: function(type)
41983 if(this.is_empty) {
41988 return this.canvasEl().dom.toDataURL('image/'+type, 1);
41991 drawFromImage: function(img_src)
41993 var img = new Image();
41995 img.onload = function(){
41996 this.canvasElCtx().drawImage(img, 0, 0);
42001 this.is_empty = false;
42004 selectImage: function()
42006 this.fileEl().dom.click();
42009 uploadImage: function(e)
42011 var reader = new FileReader();
42013 reader.onload = function(e){
42014 var img = new Image();
42015 img.onload = function(){
42017 this.canvasElCtx().drawImage(img, 0, 0);
42019 img.src = e.target.result;
42022 reader.readAsDataURL(e.target.files[0]);
42025 // Bezier Point Constructor
42026 Point: (function () {
42027 function Point(x, y, time) {
42030 this.time = time || Date.now();
42032 Point.prototype.distanceTo = function (start) {
42033 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
42035 Point.prototype.equals = function (other) {
42036 return this.x === other.x && this.y === other.y && this.time === other.time;
42038 Point.prototype.velocityFrom = function (start) {
42039 return this.time !== start.time
42040 ? this.distanceTo(start) / (this.time - start.time)
42047 // Bezier Constructor
42048 Bezier: (function () {
42049 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
42050 this.startPoint = startPoint;
42051 this.control2 = control2;
42052 this.control1 = control1;
42053 this.endPoint = endPoint;
42054 this.startWidth = startWidth;
42055 this.endWidth = endWidth;
42057 Bezier.fromPoints = function (points, widths, scope) {
42058 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42059 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42060 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42062 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42063 var dx1 = s1.x - s2.x;
42064 var dy1 = s1.y - s2.y;
42065 var dx2 = s2.x - s3.x;
42066 var dy2 = s2.y - s3.y;
42067 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42068 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42069 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42070 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42071 var dxm = m1.x - m2.x;
42072 var dym = m1.y - m2.y;
42073 var k = l2 / (l1 + l2);
42074 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42075 var tx = s2.x - cm.x;
42076 var ty = s2.y - cm.y;
42078 c1: new scope.Point(m1.x + tx, m1.y + ty),
42079 c2: new scope.Point(m2.x + tx, m2.y + ty)
42082 Bezier.prototype.length = function () {
42087 for (var i = 0; i <= steps; i += 1) {
42089 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42090 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42092 var xdiff = cx - px;
42093 var ydiff = cy - py;
42094 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42101 Bezier.prototype.point = function (t, start, c1, c2, end) {
42102 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42103 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42104 + (3.0 * c2 * (1.0 - t) * t * t)
42105 + (end * t * t * t);
42110 throttleStroke: function(fn, wait) {
42111 if (wait === void 0) { wait = 250; }
42113 var timeout = null;
42117 var later = function () {
42118 previous = Date.now();
42120 result = fn.apply(storedContext, storedArgs);
42122 storedContext = null;
42126 return function wrapper() {
42128 for (var _i = 0; _i < arguments.length; _i++) {
42129 args[_i] = arguments[_i];
42131 var now = Date.now();
42132 var remaining = wait - (now - previous);
42133 storedContext = this;
42135 if (remaining <= 0 || remaining > wait) {
42137 clearTimeout(timeout);
42141 result = fn.apply(storedContext, storedArgs);
42143 storedContext = null;
42147 else if (!timeout) {
42148 timeout = window.setTimeout(later, remaining);