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;
1078 cfg.cls += ' col-' + size + '-' + settings[size];
1083 cfg.cls += ' hidden';
1086 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1087 cfg.cls +=' alert alert-' + this.alert;
1091 if (this.html.length) {
1092 cfg.html = this.html;
1096 if (this.fasize > 1) {
1097 fasize = ' fa-' + this.fasize + 'x';
1099 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1104 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1123 * @class Roo.bootstrap.Container
1124 * @extends Roo.bootstrap.Component
1125 * Bootstrap Container class
1126 * @cfg {Boolean} jumbotron is it a jumbotron element
1127 * @cfg {String} html content of element
1128 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1129 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1130 * @cfg {String} header content of header (for panel)
1131 * @cfg {String} footer content of footer (for panel)
1132 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1133 * @cfg {String} tag (header|aside|section) type of HTML tag.
1134 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1135 * @cfg {String} fa font awesome icon
1136 * @cfg {String} icon (info-sign|check|...) glyphicon name
1137 * @cfg {Boolean} hidden (true|false) hide the element
1138 * @cfg {Boolean} expandable (true|false) default false
1139 * @cfg {Boolean} expanded (true|false) default true
1140 * @cfg {String} rheader contet on the right of header
1141 * @cfg {Boolean} clickable (true|false) default false
1145 * Create a new Container
1146 * @param {Object} config The config object
1149 Roo.bootstrap.Container = function(config){
1150 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1156 * After the panel has been expand
1158 * @param {Roo.bootstrap.Container} this
1163 * After the panel has been collapsed
1165 * @param {Roo.bootstrap.Container} this
1170 * When a element is chick
1171 * @param {Roo.bootstrap.Container} this
1172 * @param {Roo.EventObject} e
1178 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1196 getChildContainer : function() {
1202 if (this.panel.length) {
1203 return this.el.select('.panel-body',true).first();
1210 getAutoCreate : function(){
1213 tag : this.tag || 'div',
1217 if (this.jumbotron) {
1218 cfg.cls = 'jumbotron';
1223 // - this is applied by the parent..
1225 // cfg.cls = this.cls + '';
1228 if (this.sticky.length) {
1230 var bd = Roo.get(document.body);
1231 if (!bd.hasClass('bootstrap-sticky')) {
1232 bd.addClass('bootstrap-sticky');
1233 Roo.select('html',true).setStyle('height', '100%');
1236 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1240 if (this.well.length) {
1241 switch (this.well) {
1244 cfg.cls +=' well well-' +this.well;
1253 cfg.cls += ' hidden';
1257 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1258 cfg.cls +=' alert alert-' + this.alert;
1263 if (this.panel.length) {
1264 cfg.cls += ' panel panel-' + this.panel;
1266 if (this.header.length) {
1270 if(this.expandable){
1272 cfg.cls = cfg.cls + ' expandable';
1276 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1284 cls : 'panel-title',
1285 html : (this.expandable ? ' ' : '') + this.header
1289 cls: 'panel-header-right',
1295 cls : 'panel-heading',
1296 style : this.expandable ? 'cursor: pointer' : '',
1304 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1309 if (this.footer.length) {
1311 cls : 'panel-footer',
1320 body.html = this.html || cfg.html;
1321 // prefix with the icons..
1323 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1326 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1331 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1332 cfg.cls = 'container';
1338 initEvents: function()
1340 if(this.expandable){
1341 var headerEl = this.headerEl();
1344 headerEl.on('click', this.onToggleClick, this);
1349 this.el.on('click', this.onClick, this);
1354 onToggleClick : function()
1356 var headerEl = this.headerEl();
1372 if(this.fireEvent('expand', this)) {
1374 this.expanded = true;
1376 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1378 this.el.select('.panel-body',true).first().removeClass('hide');
1380 var toggleEl = this.toggleEl();
1386 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1391 collapse : function()
1393 if(this.fireEvent('collapse', this)) {
1395 this.expanded = false;
1397 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1398 this.el.select('.panel-body',true).first().addClass('hide');
1400 var toggleEl = this.toggleEl();
1406 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1410 toggleEl : function()
1412 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1416 return this.el.select('.panel-heading .fa',true).first();
1419 headerEl : function()
1421 if(!this.el || !this.panel.length || !this.header.length){
1425 return this.el.select('.panel-heading',true).first()
1430 if(!this.el || !this.panel.length){
1434 return this.el.select('.panel-body',true).first()
1437 titleEl : function()
1439 if(!this.el || !this.panel.length || !this.header.length){
1443 return this.el.select('.panel-title',true).first();
1446 setTitle : function(v)
1448 var titleEl = this.titleEl();
1454 titleEl.dom.innerHTML = v;
1457 getTitle : function()
1460 var titleEl = this.titleEl();
1466 return titleEl.dom.innerHTML;
1469 setRightTitle : function(v)
1471 var t = this.el.select('.panel-header-right',true).first();
1477 t.dom.innerHTML = v;
1480 onClick : function(e)
1484 this.fireEvent('click', this, e);
1497 * @class Roo.bootstrap.Img
1498 * @extends Roo.bootstrap.Component
1499 * Bootstrap Img class
1500 * @cfg {Boolean} imgResponsive false | true
1501 * @cfg {String} border rounded | circle | thumbnail
1502 * @cfg {String} src image source
1503 * @cfg {String} alt image alternative text
1504 * @cfg {String} href a tag href
1505 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1506 * @cfg {String} xsUrl xs image source
1507 * @cfg {String} smUrl sm image source
1508 * @cfg {String} mdUrl md image source
1509 * @cfg {String} lgUrl lg image source
1512 * Create a new Input
1513 * @param {Object} config The config object
1516 Roo.bootstrap.Img = function(config){
1517 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1523 * The img click event for the img.
1524 * @param {Roo.EventObject} e
1530 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1532 imgResponsive: true,
1542 getAutoCreate : function()
1544 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1545 return this.createSingleImg();
1550 cls: 'roo-image-responsive-group',
1555 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1557 if(!_this[size + 'Url']){
1563 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1564 html: _this.html || cfg.html,
1565 src: _this[size + 'Url']
1568 img.cls += ' roo-image-responsive-' + size;
1570 var s = ['xs', 'sm', 'md', 'lg'];
1572 s.splice(s.indexOf(size), 1);
1574 Roo.each(s, function(ss){
1575 img.cls += ' hidden-' + ss;
1578 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1579 cfg.cls += ' img-' + _this.border;
1583 cfg.alt = _this.alt;
1596 a.target = _this.target;
1600 cfg.cn.push((_this.href) ? a : img);
1607 createSingleImg : function()
1611 cls: (this.imgResponsive) ? 'img-responsive' : '',
1613 src : 'about:blank' // just incase src get's set to undefined?!?
1616 cfg.html = this.html || cfg.html;
1618 cfg.src = this.src || cfg.src;
1620 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1621 cfg.cls += ' img-' + this.border;
1638 a.target = this.target;
1643 return (this.href) ? a : cfg;
1646 initEvents: function()
1649 this.el.on('click', this.onClick, this);
1654 onClick : function(e)
1656 Roo.log('img onclick');
1657 this.fireEvent('click', this, e);
1660 * Sets the url of the image - used to update it
1661 * @param {String} url the url of the image
1664 setSrc : function(url)
1668 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1669 this.el.dom.src = url;
1673 this.el.select('img', true).first().dom.src = url;
1689 * @class Roo.bootstrap.Link
1690 * @extends Roo.bootstrap.Component
1691 * Bootstrap Link Class
1692 * @cfg {String} alt image alternative text
1693 * @cfg {String} href a tag href
1694 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1695 * @cfg {String} html the content of the link.
1696 * @cfg {String} anchor name for the anchor link
1697 * @cfg {String} fa - favicon
1699 * @cfg {Boolean} preventDefault (true | false) default false
1703 * Create a new Input
1704 * @param {Object} config The config object
1707 Roo.bootstrap.Link = function(config){
1708 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1714 * The img click event for the img.
1715 * @param {Roo.EventObject} e
1721 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1725 preventDefault: false,
1731 getAutoCreate : function()
1733 var html = this.html || '';
1735 if (this.fa !== false) {
1736 html = '<i class="fa fa-' + this.fa + '"></i>';
1741 // anchor's do not require html/href...
1742 if (this.anchor === false) {
1744 cfg.href = this.href || '#';
1746 cfg.name = this.anchor;
1747 if (this.html !== false || this.fa !== false) {
1750 if (this.href !== false) {
1751 cfg.href = this.href;
1755 if(this.alt !== false){
1760 if(this.target !== false) {
1761 cfg.target = this.target;
1767 initEvents: function() {
1769 if(!this.href || this.preventDefault){
1770 this.el.on('click', this.onClick, this);
1774 onClick : function(e)
1776 if(this.preventDefault){
1779 //Roo.log('img onclick');
1780 this.fireEvent('click', this, e);
1793 * @class Roo.bootstrap.Header
1794 * @extends Roo.bootstrap.Component
1795 * Bootstrap Header class
1796 * @cfg {String} html content of header
1797 * @cfg {Number} level (1|2|3|4|5|6) default 1
1800 * Create a new Header
1801 * @param {Object} config The config object
1805 Roo.bootstrap.Header = function(config){
1806 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1809 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1817 getAutoCreate : function(){
1822 tag: 'h' + (1 *this.level),
1823 html: this.html || ''
1835 * Ext JS Library 1.1.1
1836 * Copyright(c) 2006-2007, Ext JS, LLC.
1838 * Originally Released Under LGPL - original licence link has changed is not relivant.
1841 * <script type="text/javascript">
1845 * @class Roo.bootstrap.MenuMgr
1846 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1849 Roo.bootstrap.MenuMgr = function(){
1850 var menus, active, groups = {}, attached = false, lastShow = new Date();
1852 // private - called when first menu is created
1855 active = new Roo.util.MixedCollection();
1856 Roo.get(document).addKeyListener(27, function(){
1857 if(active.length > 0){
1865 if(active && active.length > 0){
1866 var c = active.clone();
1876 if(active.length < 1){
1877 Roo.get(document).un("mouseup", onMouseDown);
1885 var last = active.last();
1886 lastShow = new Date();
1889 Roo.get(document).on("mouseup", onMouseDown);
1894 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1895 m.parentMenu.activeChild = m;
1896 }else if(last && last.isVisible()){
1897 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1902 function onBeforeHide(m){
1904 m.activeChild.hide();
1906 if(m.autoHideTimer){
1907 clearTimeout(m.autoHideTimer);
1908 delete m.autoHideTimer;
1913 function onBeforeShow(m){
1914 var pm = m.parentMenu;
1915 if(!pm && !m.allowOtherMenus){
1917 }else if(pm && pm.activeChild && active != m){
1918 pm.activeChild.hide();
1922 // private this should really trigger on mouseup..
1923 function onMouseDown(e){
1924 Roo.log("on Mouse Up");
1926 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1927 Roo.log("MenuManager hideAll");
1936 function onBeforeCheck(mi, state){
1938 var g = groups[mi.group];
1939 for(var i = 0, l = g.length; i < l; i++){
1941 g[i].setChecked(false);
1950 * Hides all menus that are currently visible
1952 hideAll : function(){
1957 register : function(menu){
1961 menus[menu.id] = menu;
1962 menu.on("beforehide", onBeforeHide);
1963 menu.on("hide", onHide);
1964 menu.on("beforeshow", onBeforeShow);
1965 menu.on("show", onShow);
1967 if(g && menu.events["checkchange"]){
1971 groups[g].push(menu);
1972 menu.on("checkchange", onCheck);
1977 * Returns a {@link Roo.menu.Menu} object
1978 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1979 * be used to generate and return a new Menu instance.
1981 get : function(menu){
1982 if(typeof menu == "string"){ // menu id
1984 }else if(menu.events){ // menu instance
1987 /*else if(typeof menu.length == 'number'){ // array of menu items?
1988 return new Roo.bootstrap.Menu({items:menu});
1989 }else{ // otherwise, must be a config
1990 return new Roo.bootstrap.Menu(menu);
1997 unregister : function(menu){
1998 delete menus[menu.id];
1999 menu.un("beforehide", onBeforeHide);
2000 menu.un("hide", onHide);
2001 menu.un("beforeshow", onBeforeShow);
2002 menu.un("show", onShow);
2004 if(g && menu.events["checkchange"]){
2005 groups[g].remove(menu);
2006 menu.un("checkchange", onCheck);
2011 registerCheckable : function(menuItem){
2012 var g = menuItem.group;
2017 groups[g].push(menuItem);
2018 menuItem.on("beforecheckchange", onBeforeCheck);
2023 unregisterCheckable : function(menuItem){
2024 var g = menuItem.group;
2026 groups[g].remove(menuItem);
2027 menuItem.un("beforecheckchange", onBeforeCheck);
2039 * @class Roo.bootstrap.Menu
2040 * @extends Roo.bootstrap.Component
2041 * Bootstrap Menu class - container for MenuItems
2042 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2043 * @cfg {bool} hidden if the menu should be hidden when rendered.
2044 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2045 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2049 * @param {Object} config The config object
2053 Roo.bootstrap.Menu = function(config){
2054 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2055 if (this.registerMenu && this.type != 'treeview') {
2056 Roo.bootstrap.MenuMgr.register(this);
2063 * Fires before this menu is displayed (return false to block)
2064 * @param {Roo.menu.Menu} this
2069 * Fires before this menu is hidden (return false to block)
2070 * @param {Roo.menu.Menu} this
2075 * Fires after this menu is displayed
2076 * @param {Roo.menu.Menu} this
2081 * Fires after this menu is hidden
2082 * @param {Roo.menu.Menu} this
2087 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2088 * @param {Roo.menu.Menu} this
2089 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2090 * @param {Roo.EventObject} e
2095 * Fires when the mouse is hovering over this menu
2096 * @param {Roo.menu.Menu} this
2097 * @param {Roo.EventObject} e
2098 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2103 * Fires when the mouse exits this menu
2104 * @param {Roo.menu.Menu} this
2105 * @param {Roo.EventObject} e
2106 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2111 * Fires when a menu item contained in this menu is clicked
2112 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2113 * @param {Roo.EventObject} e
2117 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2120 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2124 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2127 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2129 registerMenu : true,
2131 menuItems :false, // stores the menu items..
2141 getChildContainer : function() {
2145 getAutoCreate : function(){
2147 //if (['right'].indexOf(this.align)!==-1) {
2148 // cfg.cn[1].cls += ' pull-right'
2154 cls : 'dropdown-menu' ,
2155 style : 'z-index:1000'
2159 if (this.type === 'submenu') {
2160 cfg.cls = 'submenu active';
2162 if (this.type === 'treeview') {
2163 cfg.cls = 'treeview-menu';
2168 initEvents : function() {
2170 // Roo.log("ADD event");
2171 // Roo.log(this.triggerEl.dom);
2173 this.triggerEl.on('click', this.onTriggerClick, this);
2175 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2178 if (this.triggerEl.hasClass('nav-item')) {
2179 // dropdown toggle on the 'a' in BS4?
2180 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2182 this.triggerEl.addClass('dropdown-toggle');
2185 this.el.on('touchstart' , this.onTouch, this);
2187 this.el.on('click' , this.onClick, this);
2189 this.el.on("mouseover", this.onMouseOver, this);
2190 this.el.on("mouseout", this.onMouseOut, this);
2194 findTargetItem : function(e)
2196 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2200 //Roo.log(t); Roo.log(t.id);
2202 //Roo.log(this.menuitems);
2203 return this.menuitems.get(t.id);
2205 //return this.items.get(t.menuItemId);
2211 onTouch : function(e)
2213 Roo.log("menu.onTouch");
2214 //e.stopEvent(); this make the user popdown broken
2218 onClick : function(e)
2220 Roo.log("menu.onClick");
2222 var t = this.findTargetItem(e);
2223 if(!t || t.isContainer){
2228 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2229 if(t == this.activeItem && t.shouldDeactivate(e)){
2230 this.activeItem.deactivate();
2231 delete this.activeItem;
2235 this.setActiveItem(t, true);
2243 Roo.log('pass click event');
2247 this.fireEvent("click", this, t, e);
2251 if(!t.href.length || t.href == '#'){
2252 (function() { _this.hide(); }).defer(100);
2257 onMouseOver : function(e){
2258 var t = this.findTargetItem(e);
2261 // if(t.canActivate && !t.disabled){
2262 // this.setActiveItem(t, true);
2266 this.fireEvent("mouseover", this, e, t);
2268 isVisible : function(){
2269 return !this.hidden;
2271 onMouseOut : function(e){
2272 var t = this.findTargetItem(e);
2275 // if(t == this.activeItem && t.shouldDeactivate(e)){
2276 // this.activeItem.deactivate();
2277 // delete this.activeItem;
2280 this.fireEvent("mouseout", this, e, t);
2285 * Displays this menu relative to another element
2286 * @param {String/HTMLElement/Roo.Element} element The element to align to
2287 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2288 * the element (defaults to this.defaultAlign)
2289 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2291 show : function(el, pos, parentMenu)
2293 if (false === this.fireEvent("beforeshow", this)) {
2294 Roo.log("show canceled");
2297 this.parentMenu = parentMenu;
2302 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2305 * Displays this menu at a specific xy position
2306 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2307 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2309 showAt : function(xy, parentMenu, /* private: */_e){
2310 this.parentMenu = parentMenu;
2315 this.fireEvent("beforeshow", this);
2316 //xy = this.el.adjustForConstraints(xy);
2320 this.hideMenuItems();
2321 this.hidden = false;
2322 this.triggerEl.addClass('open');
2323 this.el.addClass('show');
2325 // reassign x when hitting right
2326 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2327 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2330 // reassign y when hitting bottom
2331 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2332 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2335 // but the list may align on trigger left or trigger top... should it be a properity?
2337 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2342 this.fireEvent("show", this);
2348 this.doFocus.defer(50, this);
2352 doFocus : function(){
2354 this.focusEl.focus();
2359 * Hides this menu and optionally all parent menus
2360 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2362 hide : function(deep)
2364 if (false === this.fireEvent("beforehide", this)) {
2365 Roo.log("hide canceled");
2368 this.hideMenuItems();
2369 if(this.el && this.isVisible()){
2371 if(this.activeItem){
2372 this.activeItem.deactivate();
2373 this.activeItem = null;
2375 this.triggerEl.removeClass('open');;
2376 this.el.removeClass('show');
2378 this.fireEvent("hide", this);
2380 if(deep === true && this.parentMenu){
2381 this.parentMenu.hide(true);
2385 onTriggerClick : function(e)
2387 Roo.log('trigger click');
2389 var target = e.getTarget();
2391 Roo.log(target.nodeName.toLowerCase());
2393 if(target.nodeName.toLowerCase() === 'i'){
2399 onTriggerPress : function(e)
2401 Roo.log('trigger press');
2402 //Roo.log(e.getTarget());
2403 // Roo.log(this.triggerEl.dom);
2405 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2406 var pel = Roo.get(e.getTarget());
2407 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2408 Roo.log('is treeview or dropdown?');
2412 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2416 if (this.isVisible()) {
2421 this.show(this.triggerEl, '?', false);
2424 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2431 hideMenuItems : function()
2433 Roo.log("hide Menu Items");
2438 this.el.select('.open',true).each(function(aa) {
2440 aa.removeClass('open');
2444 addxtypeChild : function (tree, cntr) {
2445 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2447 this.menuitems.add(comp);
2459 this.getEl().dom.innerHTML = '';
2460 this.menuitems.clear();
2474 * @class Roo.bootstrap.MenuItem
2475 * @extends Roo.bootstrap.Component
2476 * Bootstrap MenuItem class
2477 * @cfg {String} html the menu label
2478 * @cfg {String} href the link
2479 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2480 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2481 * @cfg {Boolean} active used on sidebars to highlight active itesm
2482 * @cfg {String} fa favicon to show on left of menu item.
2483 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2487 * Create a new MenuItem
2488 * @param {Object} config The config object
2492 Roo.bootstrap.MenuItem = function(config){
2493 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2498 * The raw click event for the entire grid.
2499 * @param {Roo.bootstrap.MenuItem} this
2500 * @param {Roo.EventObject} e
2506 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2510 preventDefault: false,
2511 isContainer : false,
2515 getAutoCreate : function(){
2517 if(this.isContainer){
2520 cls: 'dropdown-menu-item '
2530 cls : 'dropdown-item',
2535 if (this.fa !== false) {
2538 cls : 'fa fa-' + this.fa
2547 cls: 'dropdown-menu-item',
2550 if (this.parent().type == 'treeview') {
2551 cfg.cls = 'treeview-menu';
2554 cfg.cls += ' active';
2559 anc.href = this.href || cfg.cn[0].href ;
2560 ctag.html = this.html || cfg.cn[0].html ;
2564 initEvents: function()
2566 if (this.parent().type == 'treeview') {
2567 this.el.select('a').on('click', this.onClick, this);
2571 this.menu.parentType = this.xtype;
2572 this.menu.triggerEl = this.el;
2573 this.menu = this.addxtype(Roo.apply({}, this.menu));
2577 onClick : function(e)
2579 Roo.log('item on click ');
2581 if(this.preventDefault){
2584 //this.parent().hideMenuItems();
2586 this.fireEvent('click', this, e);
2605 * @class Roo.bootstrap.MenuSeparator
2606 * @extends Roo.bootstrap.Component
2607 * Bootstrap MenuSeparator class
2610 * Create a new MenuItem
2611 * @param {Object} config The config object
2615 Roo.bootstrap.MenuSeparator = function(config){
2616 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2619 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2621 getAutoCreate : function(){
2640 * @class Roo.bootstrap.Modal
2641 * @extends Roo.bootstrap.Component
2642 * Bootstrap Modal class
2643 * @cfg {String} title Title of dialog
2644 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2645 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2646 * @cfg {Boolean} specificTitle default false
2647 * @cfg {Array} buttons Array of buttons or standard button set..
2648 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2649 * @cfg {Boolean} animate default true
2650 * @cfg {Boolean} allow_close default true
2651 * @cfg {Boolean} fitwindow default false
2652 * @cfg {String} size (sm|lg) default empty
2653 * @cfg {Number} max_width set the max width of modal
2657 * Create a new Modal Dialog
2658 * @param {Object} config The config object
2661 Roo.bootstrap.Modal = function(config){
2662 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2667 * The raw btnclick event for the button
2668 * @param {Roo.EventObject} e
2673 * Fire when dialog resize
2674 * @param {Roo.bootstrap.Modal} this
2675 * @param {Roo.EventObject} e
2679 this.buttons = this.buttons || [];
2682 this.tmpl = Roo.factory(this.tmpl);
2687 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2689 title : 'test dialog',
2699 specificTitle: false,
2701 buttonPosition: 'right',
2724 onRender : function(ct, position)
2726 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2729 var cfg = Roo.apply({}, this.getAutoCreate());
2732 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2734 //if (!cfg.name.length) {
2738 cfg.cls += ' ' + this.cls;
2741 cfg.style = this.style;
2743 this.el = Roo.get(document.body).createChild(cfg, position);
2745 //var type = this.el.dom.type;
2748 if(this.tabIndex !== undefined){
2749 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2752 this.dialogEl = this.el.select('.modal-dialog',true).first();
2753 this.bodyEl = this.el.select('.modal-body',true).first();
2754 this.closeEl = this.el.select('.modal-header .close', true).first();
2755 this.headerEl = this.el.select('.modal-header',true).first();
2756 this.titleEl = this.el.select('.modal-title',true).first();
2757 this.footerEl = this.el.select('.modal-footer',true).first();
2759 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2761 //this.el.addClass("x-dlg-modal");
2763 if (this.buttons.length) {
2764 Roo.each(this.buttons, function(bb) {
2765 var b = Roo.apply({}, bb);
2766 b.xns = b.xns || Roo.bootstrap;
2767 b.xtype = b.xtype || 'Button';
2768 if (typeof(b.listeners) == 'undefined') {
2769 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2772 var btn = Roo.factory(b);
2774 btn.render(this.getButtonContainer());
2778 // render the children.
2781 if(typeof(this.items) != 'undefined'){
2782 var items = this.items;
2785 for(var i =0;i < items.length;i++) {
2786 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2790 this.items = nitems;
2792 // where are these used - they used to be body/close/footer
2796 //this.el.addClass([this.fieldClass, this.cls]);
2800 getAutoCreate : function()
2804 html : this.html || ''
2809 cls : 'modal-title',
2813 if(this.specificTitle){
2819 if (this.allow_close && Roo.bootstrap.version == 3) {
2829 if (this.allow_close && Roo.bootstrap.version == 4) {
2839 if(this.size.length){
2840 size = 'modal-' + this.size;
2843 var footer = Roo.bootstrap.version == 3 ?
2845 cls : 'modal-footer',
2849 cls: 'btn-' + this.buttonPosition
2854 { // BS4 uses mr-auto on left buttons....
2855 cls : 'modal-footer'
2866 cls: "modal-dialog " + size,
2869 cls : "modal-content",
2872 cls : 'modal-header',
2887 modal.cls += ' fade';
2893 getChildContainer : function() {
2898 getButtonContainer : function() {
2900 return Roo.bootstrap.version == 4 ?
2901 this.el.select('.modal-footer',true).first()
2902 : this.el.select('.modal-footer div',true).first();
2905 initEvents : function()
2907 if (this.allow_close) {
2908 this.closeEl.on('click', this.hide, this);
2910 Roo.EventManager.onWindowResize(this.resize, this, true);
2918 this.maskEl.setSize(
2919 Roo.lib.Dom.getViewWidth(true),
2920 Roo.lib.Dom.getViewHeight(true)
2923 if (this.fitwindow) {
2927 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2928 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2933 if(this.max_width !== 0) {
2935 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2938 this.setSize(w, this.height);
2942 if(this.max_height) {
2943 this.setSize(w,Math.min(
2945 Roo.lib.Dom.getViewportHeight(true) - 60
2951 if(!this.fit_content) {
2952 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2956 this.setSize(w, Math.min(
2958 this.headerEl.getHeight() +
2959 this.footerEl.getHeight() +
2960 this.getChildHeight(this.bodyEl.dom.childNodes),
2961 Roo.lib.Dom.getViewportHeight(true) - 60)
2967 setSize : function(w,h)
2978 if (!this.rendered) {
2982 //this.el.setStyle('display', 'block');
2983 this.el.removeClass('hideing');
2984 this.el.dom.style.display='block';
2986 Roo.get(document.body).addClass('modal-open');
2988 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2991 this.el.addClass('show');
2992 this.el.addClass('in');
2995 this.el.addClass('show');
2996 this.el.addClass('in');
2999 // not sure how we can show data in here..
3001 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3004 Roo.get(document.body).addClass("x-body-masked");
3006 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3007 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3008 this.maskEl.dom.style.display = 'block';
3009 this.maskEl.addClass('show');
3014 this.fireEvent('show', this);
3016 // set zindex here - otherwise it appears to be ignored...
3017 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3020 this.items.forEach( function(e) {
3021 e.layout ? e.layout() : false;
3029 if(this.fireEvent("beforehide", this) !== false){
3031 this.maskEl.removeClass('show');
3033 this.maskEl.dom.style.display = '';
3034 Roo.get(document.body).removeClass("x-body-masked");
3035 this.el.removeClass('in');
3036 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3038 if(this.animate){ // why
3039 this.el.addClass('hideing');
3040 this.el.removeClass('show');
3042 if (!this.el.hasClass('hideing')) {
3043 return; // it's been shown again...
3046 this.el.dom.style.display='';
3048 Roo.get(document.body).removeClass('modal-open');
3049 this.el.removeClass('hideing');
3053 this.el.removeClass('show');
3054 this.el.dom.style.display='';
3055 Roo.get(document.body).removeClass('modal-open');
3058 this.fireEvent('hide', this);
3061 isVisible : function()
3064 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3068 addButton : function(str, cb)
3072 var b = Roo.apply({}, { html : str } );
3073 b.xns = b.xns || Roo.bootstrap;
3074 b.xtype = b.xtype || 'Button';
3075 if (typeof(b.listeners) == 'undefined') {
3076 b.listeners = { click : cb.createDelegate(this) };
3079 var btn = Roo.factory(b);
3081 btn.render(this.getButtonContainer());
3087 setDefaultButton : function(btn)
3089 //this.el.select('.modal-footer').()
3092 resizeTo: function(w,h)
3094 this.dialogEl.setWidth(w);
3096 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3098 this.bodyEl.setHeight(h - diff);
3100 this.fireEvent('resize', this);
3103 setContentSize : function(w, h)
3107 onButtonClick: function(btn,e)
3110 this.fireEvent('btnclick', btn.name, e);
3113 * Set the title of the Dialog
3114 * @param {String} str new Title
3116 setTitle: function(str) {
3117 this.titleEl.dom.innerHTML = str;
3120 * Set the body of the Dialog
3121 * @param {String} str new Title
3123 setBody: function(str) {
3124 this.bodyEl.dom.innerHTML = str;
3127 * Set the body of the Dialog using the template
3128 * @param {Obj} data - apply this data to the template and replace the body contents.
3130 applyBody: function(obj)
3133 Roo.log("Error - using apply Body without a template");
3136 this.tmpl.overwrite(this.bodyEl, obj);
3139 getChildHeight : function(child_nodes)
3143 child_nodes.length == 0
3148 var child_height = 0;
3150 for(var i = 0; i < child_nodes.length; i++) {
3153 * for modal with tabs...
3154 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3156 var layout_childs = child_nodes[i].childNodes;
3158 for(var j = 0; j < layout_childs.length; j++) {
3160 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3162 var layout_body_childs = layout_childs[j].childNodes;
3164 for(var k = 0; k < layout_body_childs.length; k++) {
3166 if(layout_body_childs[k].classList.contains('navbar')) {
3167 child_height += layout_body_childs[k].offsetHeight;
3171 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3173 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3175 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3177 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3178 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3193 child_height += child_nodes[i].offsetHeight;
3194 // Roo.log(child_nodes[i].offsetHeight);
3197 return child_height;
3203 Roo.apply(Roo.bootstrap.Modal, {
3205 * Button config that displays a single OK button
3214 * Button config that displays Yes and No buttons
3230 * Button config that displays OK and Cancel buttons
3245 * Button config that displays Yes, No and Cancel buttons
3269 * messagebox - can be used as a replace
3273 * @class Roo.MessageBox
3274 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3278 Roo.Msg.alert('Status', 'Changes saved successfully.');
3280 // Prompt for user data:
3281 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3283 // process text value...
3287 // Show a dialog using config options:
3289 title:'Save Changes?',
3290 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3291 buttons: Roo.Msg.YESNOCANCEL,
3298 Roo.bootstrap.MessageBox = function(){
3299 var dlg, opt, mask, waitTimer;
3300 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3301 var buttons, activeTextEl, bwidth;
3305 var handleButton = function(button){
3307 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3311 var handleHide = function(){
3313 dlg.el.removeClass(opt.cls);
3316 // Roo.TaskMgr.stop(waitTimer);
3317 // waitTimer = null;
3322 var updateButtons = function(b){
3325 buttons["ok"].hide();
3326 buttons["cancel"].hide();
3327 buttons["yes"].hide();
3328 buttons["no"].hide();
3329 dlg.footerEl.hide();
3333 dlg.footerEl.show();
3334 for(var k in buttons){
3335 if(typeof buttons[k] != "function"){
3338 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3339 width += buttons[k].el.getWidth()+15;
3349 var handleEsc = function(d, k, e){
3350 if(opt && opt.closable !== false){
3360 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3361 * @return {Roo.BasicDialog} The BasicDialog element
3363 getDialog : function(){
3365 dlg = new Roo.bootstrap.Modal( {
3368 //constraintoviewport:false,
3370 //collapsible : false,
3375 //buttonAlign:"center",
3376 closeClick : function(){
3377 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3380 handleButton("cancel");
3385 dlg.on("hide", handleHide);
3387 //dlg.addKeyListener(27, handleEsc);
3389 this.buttons = buttons;
3390 var bt = this.buttonText;
3391 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3392 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3393 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3394 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3396 bodyEl = dlg.bodyEl.createChild({
3398 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3399 '<textarea class="roo-mb-textarea"></textarea>' +
3400 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3402 msgEl = bodyEl.dom.firstChild;
3403 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3404 textboxEl.enableDisplayMode();
3405 textboxEl.addKeyListener([10,13], function(){
3406 if(dlg.isVisible() && opt && opt.buttons){
3409 }else if(opt.buttons.yes){
3410 handleButton("yes");
3414 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3415 textareaEl.enableDisplayMode();
3416 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3417 progressEl.enableDisplayMode();
3419 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3420 var pf = progressEl.dom.firstChild;
3422 pp = Roo.get(pf.firstChild);
3423 pp.setHeight(pf.offsetHeight);
3431 * Updates the message box body text
3432 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3433 * the XHTML-compliant non-breaking space character '&#160;')
3434 * @return {Roo.MessageBox} This message box
3436 updateText : function(text)
3438 if(!dlg.isVisible() && !opt.width){
3439 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3440 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3442 msgEl.innerHTML = text || ' ';
3444 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3445 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3447 Math.min(opt.width || cw , this.maxWidth),
3448 Math.max(opt.minWidth || this.minWidth, bwidth)
3451 activeTextEl.setWidth(w);
3453 if(dlg.isVisible()){
3454 dlg.fixedcenter = false;
3456 // to big, make it scroll. = But as usual stupid IE does not support
3459 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3460 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3461 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3463 bodyEl.dom.style.height = '';
3464 bodyEl.dom.style.overflowY = '';
3467 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3469 bodyEl.dom.style.overflowX = '';
3472 dlg.setContentSize(w, bodyEl.getHeight());
3473 if(dlg.isVisible()){
3474 dlg.fixedcenter = true;
3480 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3481 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3482 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3483 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3484 * @return {Roo.MessageBox} This message box
3486 updateProgress : function(value, text){
3488 this.updateText(text);
3491 if (pp) { // weird bug on my firefox - for some reason this is not defined
3492 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3493 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3499 * Returns true if the message box is currently displayed
3500 * @return {Boolean} True if the message box is visible, else false
3502 isVisible : function(){
3503 return dlg && dlg.isVisible();
3507 * Hides the message box if it is displayed
3510 if(this.isVisible()){
3516 * Displays a new message box, or reinitializes an existing message box, based on the config options
3517 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3518 * The following config object properties are supported:
3520 Property Type Description
3521 ---------- --------------- ------------------------------------------------------------------------------------
3522 animEl String/Element An id or Element from which the message box should animate as it opens and
3523 closes (defaults to undefined)
3524 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3525 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3526 closable Boolean False to hide the top-right close button (defaults to true). Note that
3527 progress and wait dialogs will ignore this property and always hide the
3528 close button as they can only be closed programmatically.
3529 cls String A custom CSS class to apply to the message box element
3530 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3531 displayed (defaults to 75)
3532 fn Function A callback function to execute after closing the dialog. The arguments to the
3533 function will be btn (the name of the button that was clicked, if applicable,
3534 e.g. "ok"), and text (the value of the active text field, if applicable).
3535 Progress and wait dialogs will ignore this option since they do not respond to
3536 user actions and can only be closed programmatically, so any required function
3537 should be called by the same code after it closes the dialog.
3538 icon String A CSS class that provides a background image to be used as an icon for
3539 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3540 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3541 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3542 modal Boolean False to allow user interaction with the page while the message box is
3543 displayed (defaults to true)
3544 msg String A string that will replace the existing message box body text (defaults
3545 to the XHTML-compliant non-breaking space character ' ')
3546 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3547 progress Boolean True to display a progress bar (defaults to false)
3548 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3549 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3550 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3551 title String The title text
3552 value String The string value to set into the active textbox element if displayed
3553 wait Boolean True to display a progress bar (defaults to false)
3554 width Number The width of the dialog in pixels
3561 msg: 'Please enter your address:',
3563 buttons: Roo.MessageBox.OKCANCEL,
3566 animEl: 'addAddressBtn'
3569 * @param {Object} config Configuration options
3570 * @return {Roo.MessageBox} This message box
3572 show : function(options)
3575 // this causes nightmares if you show one dialog after another
3576 // especially on callbacks..
3578 if(this.isVisible()){
3581 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3582 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3583 Roo.log("New Dialog Message:" + options.msg )
3584 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3585 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3588 var d = this.getDialog();
3590 d.setTitle(opt.title || " ");
3591 d.closeEl.setDisplayed(opt.closable !== false);
3592 activeTextEl = textboxEl;
3593 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3598 textareaEl.setHeight(typeof opt.multiline == "number" ?
3599 opt.multiline : this.defaultTextHeight);
3600 activeTextEl = textareaEl;
3609 progressEl.setDisplayed(opt.progress === true);
3611 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3613 this.updateProgress(0);
3614 activeTextEl.dom.value = opt.value || "";
3616 dlg.setDefaultButton(activeTextEl);
3618 var bs = opt.buttons;
3622 }else if(bs && bs.yes){
3623 db = buttons["yes"];
3625 dlg.setDefaultButton(db);
3627 bwidth = updateButtons(opt.buttons);
3628 this.updateText(opt.msg);
3630 d.el.addClass(opt.cls);
3632 d.proxyDrag = opt.proxyDrag === true;
3633 d.modal = opt.modal !== false;
3634 d.mask = opt.modal !== false ? mask : false;
3636 // force it to the end of the z-index stack so it gets a cursor in FF
3637 document.body.appendChild(dlg.el.dom);
3638 d.animateTarget = null;
3639 d.show(options.animEl);
3645 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3646 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3647 * and closing the message box when the process is complete.
3648 * @param {String} title The title bar text
3649 * @param {String} msg The message box body text
3650 * @return {Roo.MessageBox} This message box
3652 progress : function(title, msg){
3659 minWidth: this.minProgressWidth,
3666 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3667 * If a callback function is passed it will be called after the user clicks the button, and the
3668 * id of the button that was clicked will be passed as the only parameter to the callback
3669 * (could also be the top-right close button).
3670 * @param {String} title The title bar text
3671 * @param {String} msg The message box body text
3672 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3673 * @param {Object} scope (optional) The scope of the callback function
3674 * @return {Roo.MessageBox} This message box
3676 alert : function(title, msg, fn, scope)
3691 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3692 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3693 * You are responsible for closing the message box when the process is complete.
3694 * @param {String} msg The message box body text
3695 * @param {String} title (optional) The title bar text
3696 * @return {Roo.MessageBox} This message box
3698 wait : function(msg, title){
3709 waitTimer = Roo.TaskMgr.start({
3711 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3719 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3720 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3721 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3722 * @param {String} title The title bar text
3723 * @param {String} msg The message box body text
3724 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3725 * @param {Object} scope (optional) The scope of the callback function
3726 * @return {Roo.MessageBox} This message box
3728 confirm : function(title, msg, fn, scope){
3732 buttons: this.YESNO,
3741 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3742 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3743 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3744 * (could also be the top-right close button) and the text that was entered will be passed as the two
3745 * parameters to the callback.
3746 * @param {String} title The title bar text
3747 * @param {String} msg The message box body text
3748 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3749 * @param {Object} scope (optional) The scope of the callback function
3750 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3751 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3752 * @return {Roo.MessageBox} This message box
3754 prompt : function(title, msg, fn, scope, multiline){
3758 buttons: this.OKCANCEL,
3763 multiline: multiline,
3770 * Button config that displays a single OK button
3775 * Button config that displays Yes and No buttons
3778 YESNO : {yes:true, no:true},
3780 * Button config that displays OK and Cancel buttons
3783 OKCANCEL : {ok:true, cancel:true},
3785 * Button config that displays Yes, No and Cancel buttons
3788 YESNOCANCEL : {yes:true, no:true, cancel:true},
3791 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3794 defaultTextHeight : 75,
3796 * The maximum width in pixels of the message box (defaults to 600)
3801 * The minimum width in pixels of the message box (defaults to 100)
3806 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3807 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3810 minProgressWidth : 250,
3812 * An object containing the default button text strings that can be overriden for localized language support.
3813 * Supported properties are: ok, cancel, yes and no.
3814 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3827 * Shorthand for {@link Roo.MessageBox}
3829 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3830 Roo.Msg = Roo.Msg || Roo.MessageBox;
3839 * @class Roo.bootstrap.Navbar
3840 * @extends Roo.bootstrap.Component
3841 * Bootstrap Navbar class
3844 * Create a new Navbar
3845 * @param {Object} config The config object
3849 Roo.bootstrap.Navbar = function(config){
3850 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3854 * @event beforetoggle
3855 * Fire before toggle the menu
3856 * @param {Roo.EventObject} e
3858 "beforetoggle" : true
3862 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3871 getAutoCreate : function(){
3874 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3878 initEvents :function ()
3880 //Roo.log(this.el.select('.navbar-toggle',true));
3881 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
3888 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3890 var size = this.el.getSize();
3891 this.maskEl.setSize(size.width, size.height);
3892 this.maskEl.enableDisplayMode("block");
3901 getChildContainer : function()
3903 if (this.el && this.el.select('.collapse').getCount()) {
3904 return this.el.select('.collapse',true).first();
3919 onToggle : function()
3922 if(this.fireEvent('beforetoggle', this) === false){
3925 var ce = this.el.select('.navbar-collapse',true).first();
3927 if (!ce.hasClass('show')) {
3937 * Expand the navbar pulldown
3939 expand : function ()
3942 var ce = this.el.select('.navbar-collapse',true).first();
3943 if (ce.hasClass('collapsing')) {
3946 ce.dom.style.height = '';
3948 ce.addClass('in'); // old...
3949 ce.removeClass('collapse');
3950 ce.addClass('show');
3951 var h = ce.getHeight();
3953 ce.removeClass('show');
3954 // at this point we should be able to see it..
3955 ce.addClass('collapsing');
3957 ce.setHeight(0); // resize it ...
3958 ce.on('transitionend', function() {
3959 //Roo.log('done transition');
3960 ce.removeClass('collapsing');
3961 ce.addClass('show');
3962 ce.removeClass('collapse');
3964 ce.dom.style.height = '';
3965 }, this, { single: true} );
3967 ce.dom.scrollTop = 0;
3970 * Collapse the navbar pulldown
3972 collapse : function()
3974 var ce = this.el.select('.navbar-collapse',true).first();
3976 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
3977 // it's collapsed or collapsing..
3980 ce.removeClass('in'); // old...
3981 ce.setHeight(ce.getHeight());
3982 ce.removeClass('show');
3983 ce.addClass('collapsing');
3985 ce.on('transitionend', function() {
3986 ce.dom.style.height = '';
3987 ce.removeClass('collapsing');
3988 ce.addClass('collapse');
3989 }, this, { single: true} );
4009 * @class Roo.bootstrap.NavSimplebar
4010 * @extends Roo.bootstrap.Navbar
4011 * Bootstrap Sidebar class
4013 * @cfg {Boolean} inverse is inverted color
4015 * @cfg {String} type (nav | pills | tabs)
4016 * @cfg {Boolean} arrangement stacked | justified
4017 * @cfg {String} align (left | right) alignment
4019 * @cfg {Boolean} main (true|false) main nav bar? default false
4020 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
4022 * @cfg {String} tag (header|footer|nav|div) default is nav
4024 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
4028 * Create a new Sidebar
4029 * @param {Object} config The config object
4033 Roo.bootstrap.NavSimplebar = function(config){
4034 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4037 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4053 getAutoCreate : function(){
4057 tag : this.tag || 'div',
4058 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4060 if (['light','white'].indexOf(this.weight) > -1) {
4061 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4063 cfg.cls += ' bg-' + this.weight;
4066 cfg.cls += ' navbar-inverse';
4070 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4072 //if (Roo.bootstrap.version == 4) {
4084 this.type = this.type || 'nav';
4085 if (['tabs','pills'].indexOf(this.type) != -1) {
4086 cfg.cn[0].cls += ' nav-' + this.type
4090 if (this.type!=='nav') {
4091 Roo.log('nav type must be nav/tabs/pills')
4093 cfg.cn[0].cls += ' navbar-nav'
4099 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4100 cfg.cn[0].cls += ' nav-' + this.arrangement;
4104 if (this.align === 'right') {
4105 cfg.cn[0].cls += ' navbar-right';
4130 * navbar-expand-md fixed-top
4134 * @class Roo.bootstrap.NavHeaderbar
4135 * @extends Roo.bootstrap.NavSimplebar
4136 * Bootstrap Sidebar class
4138 * @cfg {String} brand what is brand
4139 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4140 * @cfg {String} brand_href href of the brand
4141 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4142 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4143 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4144 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4147 * Create a new Sidebar
4148 * @param {Object} config The config object
4152 Roo.bootstrap.NavHeaderbar = function(config){
4153 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4157 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4164 desktopCenter : false,
4167 getAutoCreate : function(){
4170 tag: this.nav || 'nav',
4171 cls: 'navbar navbar-expand-md',
4177 if (this.desktopCenter) {
4178 cn.push({cls : 'container', cn : []});
4186 cls: 'navbar-toggle navbar-toggler',
4187 'data-toggle': 'collapse',
4192 html: 'Toggle navigation'
4196 cls: 'icon-bar navbar-toggler-icon'
4209 cn.push( Roo.bootstrap.version == 4 ? btn : {
4211 cls: 'navbar-header',
4220 cls: 'collapse navbar-collapse',
4224 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4226 if (['light','white'].indexOf(this.weight) > -1) {
4227 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4229 cfg.cls += ' bg-' + this.weight;
4232 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4233 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4235 // tag can override this..
4237 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4240 if (this.brand !== '') {
4241 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4242 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4244 href: this.brand_href ? this.brand_href : '#',
4245 cls: 'navbar-brand',
4253 cfg.cls += ' main-nav';
4261 getHeaderChildContainer : function()
4263 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4264 return this.el.select('.navbar-header',true).first();
4267 return this.getChildContainer();
4271 initEvents : function()
4273 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4275 if (this.autohide) {
4280 Roo.get(document).on('scroll',function(e) {
4281 var ns = Roo.get(document).getScroll().top;
4282 var os = prevScroll;
4286 ft.removeClass('slideDown');
4287 ft.addClass('slideUp');
4290 ft.removeClass('slideUp');
4291 ft.addClass('slideDown');
4312 * @class Roo.bootstrap.NavSidebar
4313 * @extends Roo.bootstrap.Navbar
4314 * Bootstrap Sidebar class
4317 * Create a new Sidebar
4318 * @param {Object} config The config object
4322 Roo.bootstrap.NavSidebar = function(config){
4323 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4326 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4328 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4330 getAutoCreate : function(){
4335 cls: 'sidebar sidebar-nav'
4357 * @class Roo.bootstrap.NavGroup
4358 * @extends Roo.bootstrap.Component
4359 * Bootstrap NavGroup class
4360 * @cfg {String} align (left|right)
4361 * @cfg {Boolean} inverse
4362 * @cfg {String} type (nav|pills|tab) default nav
4363 * @cfg {String} navId - reference Id for navbar.
4367 * Create a new nav group
4368 * @param {Object} config The config object
4371 Roo.bootstrap.NavGroup = function(config){
4372 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4375 Roo.bootstrap.NavGroup.register(this);
4379 * Fires when the active item changes
4380 * @param {Roo.bootstrap.NavGroup} this
4381 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4382 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4389 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4400 getAutoCreate : function()
4402 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4408 if (Roo.bootstrap.version == 4) {
4409 if (['tabs','pills'].indexOf(this.type) != -1) {
4410 cfg.cls += ' nav-' + this.type;
4412 cfg.cls += ' navbar-nav';
4415 if (['tabs','pills'].indexOf(this.type) != -1) {
4416 cfg.cls += ' nav-' + this.type
4418 if (this.type !== 'nav') {
4419 Roo.log('nav type must be nav/tabs/pills')
4421 cfg.cls += ' navbar-nav'
4425 if (this.parent() && this.parent().sidebar) {
4428 cls: 'dashboard-menu sidebar-menu'
4434 if (this.form === true) {
4437 cls: 'navbar-form form-inline'
4440 if (this.align === 'right') {
4441 cfg.cls += ' navbar-right ml-md-auto';
4443 cfg.cls += ' navbar-left';
4447 if (this.align === 'right') {
4448 cfg.cls += ' navbar-right ml-md-auto';
4450 cfg.cls += ' mr-auto';
4454 cfg.cls += ' navbar-inverse';
4462 * sets the active Navigation item
4463 * @param {Roo.bootstrap.NavItem} the new current navitem
4465 setActiveItem : function(item)
4468 Roo.each(this.navItems, function(v){
4473 v.setActive(false, true);
4480 item.setActive(true, true);
4481 this.fireEvent('changed', this, item, prev);
4486 * gets the active Navigation item
4487 * @return {Roo.bootstrap.NavItem} the current navitem
4489 getActive : function()
4493 Roo.each(this.navItems, function(v){
4504 indexOfNav : function()
4508 Roo.each(this.navItems, function(v,i){
4519 * adds a Navigation item
4520 * @param {Roo.bootstrap.NavItem} the navitem to add
4522 addItem : function(cfg)
4524 if (this.form && Roo.bootstrap.version == 4) {
4527 var cn = new Roo.bootstrap.NavItem(cfg);
4529 cn.parentId = this.id;
4530 cn.onRender(this.el, null);
4534 * register a Navigation item
4535 * @param {Roo.bootstrap.NavItem} the navitem to add
4537 register : function(item)
4539 this.navItems.push( item);
4540 item.navId = this.navId;
4545 * clear all the Navigation item
4548 clearAll : function()
4551 this.el.dom.innerHTML = '';
4554 getNavItem: function(tabId)
4557 Roo.each(this.navItems, function(e) {
4558 if (e.tabId == tabId) {
4568 setActiveNext : function()
4570 var i = this.indexOfNav(this.getActive());
4571 if (i > this.navItems.length) {
4574 this.setActiveItem(this.navItems[i+1]);
4576 setActivePrev : function()
4578 var i = this.indexOfNav(this.getActive());
4582 this.setActiveItem(this.navItems[i-1]);
4584 clearWasActive : function(except) {
4585 Roo.each(this.navItems, function(e) {
4586 if (e.tabId != except.tabId && e.was_active) {
4587 e.was_active = false;
4594 getWasActive : function ()
4597 Roo.each(this.navItems, function(e) {
4612 Roo.apply(Roo.bootstrap.NavGroup, {
4616 * register a Navigation Group
4617 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4619 register : function(navgrp)
4621 this.groups[navgrp.navId] = navgrp;
4625 * fetch a Navigation Group based on the navigation ID
4626 * @param {string} the navgroup to add
4627 * @returns {Roo.bootstrap.NavGroup} the navgroup
4629 get: function(navId) {
4630 if (typeof(this.groups[navId]) == 'undefined') {
4632 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4634 return this.groups[navId] ;
4649 * @class Roo.bootstrap.NavItem
4650 * @extends Roo.bootstrap.Component
4651 * Bootstrap Navbar.NavItem class
4652 * @cfg {String} href link to
4653 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4655 * @cfg {String} html content of button
4656 * @cfg {String} badge text inside badge
4657 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4658 * @cfg {String} glyphicon DEPRICATED - use fa
4659 * @cfg {String} icon DEPRICATED - use fa
4660 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4661 * @cfg {Boolean} active Is item active
4662 * @cfg {Boolean} disabled Is item disabled
4664 * @cfg {Boolean} preventDefault (true | false) default false
4665 * @cfg {String} tabId the tab that this item activates.
4666 * @cfg {String} tagtype (a|span) render as a href or span?
4667 * @cfg {Boolean} animateRef (true|false) link to element default false
4670 * Create a new Navbar Item
4671 * @param {Object} config The config object
4673 Roo.bootstrap.NavItem = function(config){
4674 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4679 * The raw click event for the entire grid.
4680 * @param {Roo.EventObject} e
4685 * Fires when the active item active state changes
4686 * @param {Roo.bootstrap.NavItem} this
4687 * @param {boolean} state the new state
4693 * Fires when scroll to element
4694 * @param {Roo.bootstrap.NavItem} this
4695 * @param {Object} options
4696 * @param {Roo.EventObject} e
4704 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4713 preventDefault : false,
4721 button_outline : false,
4725 getAutoCreate : function(){
4733 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4735 if (this.disabled) {
4736 cfg.cls += ' disabled';
4740 if (this.button_weight.length) {
4741 cfg.tag = this.href ? 'a' : 'button';
4742 cfg.html = this.html || '';
4743 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4745 cfg.href = this.href;
4748 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4751 // menu .. should add dropdown-menu class - so no need for carat..
4753 if (this.badge !== '') {
4755 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4760 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4764 href : this.href || "#",
4765 html: this.html || ''
4768 if (this.tagtype == 'a') {
4769 cfg.cn[0].cls = 'nav-link';
4772 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4775 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4777 if(this.glyphicon) {
4778 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4783 cfg.cn[0].html += " <span class='caret'></span>";
4787 if (this.badge !== '') {
4789 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4797 onRender : function(ct, position)
4799 // Roo.log("Call onRender: " + this.xtype);
4800 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4804 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4805 this.navLink = this.el.select('.nav-link',true).first();
4810 initEvents: function()
4812 if (typeof (this.menu) != 'undefined') {
4813 this.menu.parentType = this.xtype;
4814 this.menu.triggerEl = this.el;
4815 this.menu = this.addxtype(Roo.apply({}, this.menu));
4818 this.el.select('a',true).on('click', this.onClick, this);
4820 if(this.tagtype == 'span'){
4821 this.el.select('span',true).on('click', this.onClick, this);
4824 // at this point parent should be available..
4825 this.parent().register(this);
4828 onClick : function(e)
4830 if (e.getTarget('.dropdown-menu-item')) {
4831 // did you click on a menu itemm.... - then don't trigger onclick..
4836 this.preventDefault ||
4839 Roo.log("NavItem - prevent Default?");
4843 if (this.disabled) {
4847 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4848 if (tg && tg.transition) {
4849 Roo.log("waiting for the transitionend");
4855 //Roo.log("fire event clicked");
4856 if(this.fireEvent('click', this, e) === false){
4860 if(this.tagtype == 'span'){
4864 //Roo.log(this.href);
4865 var ael = this.el.select('a',true).first();
4868 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4869 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4870 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4871 return; // ignore... - it's a 'hash' to another page.
4873 Roo.log("NavItem - prevent Default?");
4875 this.scrollToElement(e);
4879 var p = this.parent();
4881 if (['tabs','pills'].indexOf(p.type)!==-1) {
4882 if (typeof(p.setActiveItem) !== 'undefined') {
4883 p.setActiveItem(this);
4887 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4888 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4889 // remove the collapsed menu expand...
4890 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4894 isActive: function () {
4897 setActive : function(state, fire, is_was_active)
4899 if (this.active && !state && this.navId) {
4900 this.was_active = true;
4901 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4903 nv.clearWasActive(this);
4907 this.active = state;
4910 this.el.removeClass('active');
4911 this.navLink ? this.navLink.removeClass('active') : false;
4912 } else if (!this.el.hasClass('active')) {
4914 this.el.addClass('active');
4915 if (Roo.bootstrap.version == 4 && this.navLink ) {
4916 this.navLink.addClass('active');
4921 this.fireEvent('changed', this, state);
4924 // show a panel if it's registered and related..
4926 if (!this.navId || !this.tabId || !state || is_was_active) {
4930 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4934 var pan = tg.getPanelByName(this.tabId);
4938 // if we can not flip to new panel - go back to old nav highlight..
4939 if (false == tg.showPanel(pan)) {
4940 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4942 var onav = nv.getWasActive();
4944 onav.setActive(true, false, true);
4953 // this should not be here...
4954 setDisabled : function(state)
4956 this.disabled = state;
4958 this.el.removeClass('disabled');
4959 } else if (!this.el.hasClass('disabled')) {
4960 this.el.addClass('disabled');
4966 * Fetch the element to display the tooltip on.
4967 * @return {Roo.Element} defaults to this.el
4969 tooltipEl : function()
4971 return this.el.select('' + this.tagtype + '', true).first();
4974 scrollToElement : function(e)
4976 var c = document.body;
4979 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4981 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4982 c = document.documentElement;
4985 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4991 var o = target.calcOffsetsTo(c);
4998 this.fireEvent('scrollto', this, options, e);
5000 Roo.get(c).scrollTo('top', options.value, true);
5013 * <span> icon </span>
5014 * <span> text </span>
5015 * <span>badge </span>
5019 * @class Roo.bootstrap.NavSidebarItem
5020 * @extends Roo.bootstrap.NavItem
5021 * Bootstrap Navbar.NavSidebarItem class
5022 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
5023 * {Boolean} open is the menu open
5024 * {Boolean} buttonView use button as the tigger el rather that a (default false)
5025 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
5026 * {String} buttonSize (sm|md|lg)the extra classes for the button
5027 * {Boolean} showArrow show arrow next to the text (default true)
5029 * Create a new Navbar Button
5030 * @param {Object} config The config object
5032 Roo.bootstrap.NavSidebarItem = function(config){
5033 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5038 * The raw click event for the entire grid.
5039 * @param {Roo.EventObject} e
5044 * Fires when the active item active state changes
5045 * @param {Roo.bootstrap.NavSidebarItem} this
5046 * @param {boolean} state the new state
5054 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5056 badgeWeight : 'default',
5062 buttonWeight : 'default',
5068 getAutoCreate : function(){
5073 href : this.href || '#',
5079 if(this.buttonView){
5082 href : this.href || '#',
5083 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5096 cfg.cls += ' active';
5099 if (this.disabled) {
5100 cfg.cls += ' disabled';
5103 cfg.cls += ' open x-open';
5106 if (this.glyphicon || this.icon) {
5107 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5108 a.cn.push({ tag : 'i', cls : c }) ;
5111 if(!this.buttonView){
5114 html : this.html || ''
5121 if (this.badge !== '') {
5122 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5128 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5131 a.cls += ' dropdown-toggle treeview' ;
5137 initEvents : function()
5139 if (typeof (this.menu) != 'undefined') {
5140 this.menu.parentType = this.xtype;
5141 this.menu.triggerEl = this.el;
5142 this.menu = this.addxtype(Roo.apply({}, this.menu));
5145 this.el.on('click', this.onClick, this);
5147 if(this.badge !== ''){
5148 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5153 onClick : function(e)
5160 if(this.preventDefault){
5164 this.fireEvent('click', this, e);
5167 disable : function()
5169 this.setDisabled(true);
5174 this.setDisabled(false);
5177 setDisabled : function(state)
5179 if(this.disabled == state){
5183 this.disabled = state;
5186 this.el.addClass('disabled');
5190 this.el.removeClass('disabled');
5195 setActive : function(state)
5197 if(this.active == state){
5201 this.active = state;
5204 this.el.addClass('active');
5208 this.el.removeClass('active');
5213 isActive: function ()
5218 setBadge : function(str)
5224 this.badgeEl.dom.innerHTML = str;
5241 * @class Roo.bootstrap.Row
5242 * @extends Roo.bootstrap.Component
5243 * Bootstrap Row class (contains columns...)
5247 * @param {Object} config The config object
5250 Roo.bootstrap.Row = function(config){
5251 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5254 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5256 getAutoCreate : function(){
5275 * @class Roo.bootstrap.Element
5276 * @extends Roo.bootstrap.Component
5277 * Bootstrap Element class
5278 * @cfg {String} html contents of the element
5279 * @cfg {String} tag tag of the element
5280 * @cfg {String} cls class of the element
5281 * @cfg {Boolean} preventDefault (true|false) default false
5282 * @cfg {Boolean} clickable (true|false) default false
5285 * Create a new Element
5286 * @param {Object} config The config object
5289 Roo.bootstrap.Element = function(config){
5290 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5296 * When a element is chick
5297 * @param {Roo.bootstrap.Element} this
5298 * @param {Roo.EventObject} e
5304 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5309 preventDefault: false,
5312 getAutoCreate : function(){
5316 // cls: this.cls, double assign in parent class Component.js :: onRender
5323 initEvents: function()
5325 Roo.bootstrap.Element.superclass.initEvents.call(this);
5328 this.el.on('click', this.onClick, this);
5333 onClick : function(e)
5335 if(this.preventDefault){
5339 this.fireEvent('click', this, e);
5342 getValue : function()
5344 return this.el.dom.innerHTML;
5347 setValue : function(value)
5349 this.el.dom.innerHTML = value;
5364 * @class Roo.bootstrap.Pagination
5365 * @extends Roo.bootstrap.Component
5366 * Bootstrap Pagination class
5367 * @cfg {String} size xs | sm | md | lg
5368 * @cfg {Boolean} inverse false | true
5371 * Create a new Pagination
5372 * @param {Object} config The config object
5375 Roo.bootstrap.Pagination = function(config){
5376 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5379 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5385 getAutoCreate : function(){
5391 cfg.cls += ' inverse';
5397 cfg.cls += " " + this.cls;
5415 * @class Roo.bootstrap.PaginationItem
5416 * @extends Roo.bootstrap.Component
5417 * Bootstrap PaginationItem class
5418 * @cfg {String} html text
5419 * @cfg {String} href the link
5420 * @cfg {Boolean} preventDefault (true | false) default true
5421 * @cfg {Boolean} active (true | false) default false
5422 * @cfg {Boolean} disabled default false
5426 * Create a new PaginationItem
5427 * @param {Object} config The config object
5431 Roo.bootstrap.PaginationItem = function(config){
5432 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5437 * The raw click event for the entire grid.
5438 * @param {Roo.EventObject} e
5444 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5448 preventDefault: true,
5453 getAutoCreate : function(){
5459 href : this.href ? this.href : '#',
5460 html : this.html ? this.html : ''
5470 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5474 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5480 initEvents: function() {
5482 this.el.on('click', this.onClick, this);
5485 onClick : function(e)
5487 Roo.log('PaginationItem on click ');
5488 if(this.preventDefault){
5496 this.fireEvent('click', this, e);
5512 * @class Roo.bootstrap.Slider
5513 * @extends Roo.bootstrap.Component
5514 * Bootstrap Slider class
5517 * Create a new Slider
5518 * @param {Object} config The config object
5521 Roo.bootstrap.Slider = function(config){
5522 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5525 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5527 getAutoCreate : function(){
5531 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5535 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5547 * Ext JS Library 1.1.1
5548 * Copyright(c) 2006-2007, Ext JS, LLC.
5550 * Originally Released Under LGPL - original licence link has changed is not relivant.
5553 * <script type="text/javascript">
5558 * @class Roo.grid.ColumnModel
5559 * @extends Roo.util.Observable
5560 * This is the default implementation of a ColumnModel used by the Grid. It defines
5561 * the columns in the grid.
5564 var colModel = new Roo.grid.ColumnModel([
5565 {header: "Ticker", width: 60, sortable: true, locked: true},
5566 {header: "Company Name", width: 150, sortable: true},
5567 {header: "Market Cap.", width: 100, sortable: true},
5568 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5569 {header: "Employees", width: 100, sortable: true, resizable: false}
5574 * The config options listed for this class are options which may appear in each
5575 * individual column definition.
5576 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5578 * @param {Object} config An Array of column config objects. See this class's
5579 * config objects for details.
5581 Roo.grid.ColumnModel = function(config){
5583 * The config passed into the constructor
5585 this.config = config;
5588 // if no id, create one
5589 // if the column does not have a dataIndex mapping,
5590 // map it to the order it is in the config
5591 for(var i = 0, len = config.length; i < len; i++){
5593 if(typeof c.dataIndex == "undefined"){
5596 if(typeof c.renderer == "string"){
5597 c.renderer = Roo.util.Format[c.renderer];
5599 if(typeof c.id == "undefined"){
5602 if(c.editor && c.editor.xtype){
5603 c.editor = Roo.factory(c.editor, Roo.grid);
5605 if(c.editor && c.editor.isFormField){
5606 c.editor = new Roo.grid.GridEditor(c.editor);
5608 this.lookup[c.id] = c;
5612 * The width of columns which have no width specified (defaults to 100)
5615 this.defaultWidth = 100;
5618 * Default sortable of columns which have no sortable specified (defaults to false)
5621 this.defaultSortable = false;
5625 * @event widthchange
5626 * Fires when the width of a column changes.
5627 * @param {ColumnModel} this
5628 * @param {Number} columnIndex The column index
5629 * @param {Number} newWidth The new width
5631 "widthchange": true,
5633 * @event headerchange
5634 * Fires when the text of a header changes.
5635 * @param {ColumnModel} this
5636 * @param {Number} columnIndex The column index
5637 * @param {Number} newText The new header text
5639 "headerchange": true,
5641 * @event hiddenchange
5642 * Fires when a column is hidden or "unhidden".
5643 * @param {ColumnModel} this
5644 * @param {Number} columnIndex The column index
5645 * @param {Boolean} hidden true if hidden, false otherwise
5647 "hiddenchange": true,
5649 * @event columnmoved
5650 * Fires when a column is moved.
5651 * @param {ColumnModel} this
5652 * @param {Number} oldIndex
5653 * @param {Number} newIndex
5655 "columnmoved" : true,
5657 * @event columlockchange
5658 * Fires when a column's locked state is changed
5659 * @param {ColumnModel} this
5660 * @param {Number} colIndex
5661 * @param {Boolean} locked true if locked
5663 "columnlockchange" : true
5665 Roo.grid.ColumnModel.superclass.constructor.call(this);
5667 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5669 * @cfg {String} header The header text to display in the Grid view.
5672 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5673 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5674 * specified, the column's index is used as an index into the Record's data Array.
5677 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5678 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5681 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5682 * Defaults to the value of the {@link #defaultSortable} property.
5683 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5686 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5689 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5692 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5695 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5698 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5699 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5700 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5701 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5704 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5707 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5710 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5713 * @cfg {String} cursor (Optional)
5716 * @cfg {String} tooltip (Optional)
5719 * @cfg {Number} xs (Optional)
5722 * @cfg {Number} sm (Optional)
5725 * @cfg {Number} md (Optional)
5728 * @cfg {Number} lg (Optional)
5731 * Returns the id of the column at the specified index.
5732 * @param {Number} index The column index
5733 * @return {String} the id
5735 getColumnId : function(index){
5736 return this.config[index].id;
5740 * Returns the column for a specified id.
5741 * @param {String} id The column id
5742 * @return {Object} the column
5744 getColumnById : function(id){
5745 return this.lookup[id];
5750 * Returns the column for a specified dataIndex.
5751 * @param {String} dataIndex The column dataIndex
5752 * @return {Object|Boolean} the column or false if not found
5754 getColumnByDataIndex: function(dataIndex){
5755 var index = this.findColumnIndex(dataIndex);
5756 return index > -1 ? this.config[index] : false;
5760 * Returns the index for a specified column id.
5761 * @param {String} id The column id
5762 * @return {Number} the index, or -1 if not found
5764 getIndexById : function(id){
5765 for(var i = 0, len = this.config.length; i < len; i++){
5766 if(this.config[i].id == id){
5774 * Returns the index for a specified column dataIndex.
5775 * @param {String} dataIndex The column dataIndex
5776 * @return {Number} the index, or -1 if not found
5779 findColumnIndex : function(dataIndex){
5780 for(var i = 0, len = this.config.length; i < len; i++){
5781 if(this.config[i].dataIndex == dataIndex){
5789 moveColumn : function(oldIndex, newIndex){
5790 var c = this.config[oldIndex];
5791 this.config.splice(oldIndex, 1);
5792 this.config.splice(newIndex, 0, c);
5793 this.dataMap = null;
5794 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5797 isLocked : function(colIndex){
5798 return this.config[colIndex].locked === true;
5801 setLocked : function(colIndex, value, suppressEvent){
5802 if(this.isLocked(colIndex) == value){
5805 this.config[colIndex].locked = value;
5807 this.fireEvent("columnlockchange", this, colIndex, value);
5811 getTotalLockedWidth : function(){
5813 for(var i = 0; i < this.config.length; i++){
5814 if(this.isLocked(i) && !this.isHidden(i)){
5815 this.totalWidth += this.getColumnWidth(i);
5821 getLockedCount : function(){
5822 for(var i = 0, len = this.config.length; i < len; i++){
5823 if(!this.isLocked(i)){
5828 return this.config.length;
5832 * Returns the number of columns.
5835 getColumnCount : function(visibleOnly){
5836 if(visibleOnly === true){
5838 for(var i = 0, len = this.config.length; i < len; i++){
5839 if(!this.isHidden(i)){
5845 return this.config.length;
5849 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5850 * @param {Function} fn
5851 * @param {Object} scope (optional)
5852 * @return {Array} result
5854 getColumnsBy : function(fn, scope){
5856 for(var i = 0, len = this.config.length; i < len; i++){
5857 var c = this.config[i];
5858 if(fn.call(scope||this, c, i) === true){
5866 * Returns true if the specified column is sortable.
5867 * @param {Number} col The column index
5870 isSortable : function(col){
5871 if(typeof this.config[col].sortable == "undefined"){
5872 return this.defaultSortable;
5874 return this.config[col].sortable;
5878 * Returns the rendering (formatting) function defined for the column.
5879 * @param {Number} col The column index.
5880 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5882 getRenderer : function(col){
5883 if(!this.config[col].renderer){
5884 return Roo.grid.ColumnModel.defaultRenderer;
5886 return this.config[col].renderer;
5890 * Sets the rendering (formatting) function for a column.
5891 * @param {Number} col The column index
5892 * @param {Function} fn The function to use to process the cell's raw data
5893 * to return HTML markup for the grid view. The render function is called with
5894 * the following parameters:<ul>
5895 * <li>Data value.</li>
5896 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5897 * <li>css A CSS style string to apply to the table cell.</li>
5898 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5899 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5900 * <li>Row index</li>
5901 * <li>Column index</li>
5902 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5904 setRenderer : function(col, fn){
5905 this.config[col].renderer = fn;
5909 * Returns the width for the specified column.
5910 * @param {Number} col The column index
5913 getColumnWidth : function(col){
5914 return this.config[col].width * 1 || this.defaultWidth;
5918 * Sets the width for a column.
5919 * @param {Number} col The column index
5920 * @param {Number} width The new width
5922 setColumnWidth : function(col, width, suppressEvent){
5923 this.config[col].width = width;
5924 this.totalWidth = null;
5926 this.fireEvent("widthchange", this, col, width);
5931 * Returns the total width of all columns.
5932 * @param {Boolean} includeHidden True to include hidden column widths
5935 getTotalWidth : function(includeHidden){
5936 if(!this.totalWidth){
5937 this.totalWidth = 0;
5938 for(var i = 0, len = this.config.length; i < len; i++){
5939 if(includeHidden || !this.isHidden(i)){
5940 this.totalWidth += this.getColumnWidth(i);
5944 return this.totalWidth;
5948 * Returns the header for the specified column.
5949 * @param {Number} col The column index
5952 getColumnHeader : function(col){
5953 return this.config[col].header;
5957 * Sets the header for a column.
5958 * @param {Number} col The column index
5959 * @param {String} header The new header
5961 setColumnHeader : function(col, header){
5962 this.config[col].header = header;
5963 this.fireEvent("headerchange", this, col, header);
5967 * Returns the tooltip for the specified column.
5968 * @param {Number} col The column index
5971 getColumnTooltip : function(col){
5972 return this.config[col].tooltip;
5975 * Sets the tooltip for a column.
5976 * @param {Number} col The column index
5977 * @param {String} tooltip The new tooltip
5979 setColumnTooltip : function(col, tooltip){
5980 this.config[col].tooltip = tooltip;
5984 * Returns the dataIndex for the specified column.
5985 * @param {Number} col The column index
5988 getDataIndex : function(col){
5989 return this.config[col].dataIndex;
5993 * Sets the dataIndex for a column.
5994 * @param {Number} col The column index
5995 * @param {Number} dataIndex The new dataIndex
5997 setDataIndex : function(col, dataIndex){
5998 this.config[col].dataIndex = dataIndex;
6004 * Returns true if the cell is editable.
6005 * @param {Number} colIndex The column index
6006 * @param {Number} rowIndex The row index - this is nto actually used..?
6009 isCellEditable : function(colIndex, rowIndex){
6010 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
6014 * Returns the editor defined for the cell/column.
6015 * return false or null to disable editing.
6016 * @param {Number} colIndex The column index
6017 * @param {Number} rowIndex The row index
6020 getCellEditor : function(colIndex, rowIndex){
6021 return this.config[colIndex].editor;
6025 * Sets if a column is editable.
6026 * @param {Number} col The column index
6027 * @param {Boolean} editable True if the column is editable
6029 setEditable : function(col, editable){
6030 this.config[col].editable = editable;
6035 * Returns true if the column is hidden.
6036 * @param {Number} colIndex The column index
6039 isHidden : function(colIndex){
6040 return this.config[colIndex].hidden;
6045 * Returns true if the column width cannot be changed
6047 isFixed : function(colIndex){
6048 return this.config[colIndex].fixed;
6052 * Returns true if the column can be resized
6055 isResizable : function(colIndex){
6056 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6059 * Sets if a column is hidden.
6060 * @param {Number} colIndex The column index
6061 * @param {Boolean} hidden True if the column is hidden
6063 setHidden : function(colIndex, hidden){
6064 this.config[colIndex].hidden = hidden;
6065 this.totalWidth = null;
6066 this.fireEvent("hiddenchange", this, colIndex, hidden);
6070 * Sets the editor for a column.
6071 * @param {Number} col The column index
6072 * @param {Object} editor The editor object
6074 setEditor : function(col, editor){
6075 this.config[col].editor = editor;
6079 Roo.grid.ColumnModel.defaultRenderer = function(value)
6081 if(typeof value == "object") {
6084 if(typeof value == "string" && value.length < 1){
6088 return String.format("{0}", value);
6091 // Alias for backwards compatibility
6092 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6095 * Ext JS Library 1.1.1
6096 * Copyright(c) 2006-2007, Ext JS, LLC.
6098 * Originally Released Under LGPL - original licence link has changed is not relivant.
6101 * <script type="text/javascript">
6105 * @class Roo.LoadMask
6106 * A simple utility class for generically masking elements while loading data. If the element being masked has
6107 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6108 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6109 * element's UpdateManager load indicator and will be destroyed after the initial load.
6111 * Create a new LoadMask
6112 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6113 * @param {Object} config The config object
6115 Roo.LoadMask = function(el, config){
6116 this.el = Roo.get(el);
6117 Roo.apply(this, config);
6119 this.store.on('beforeload', this.onBeforeLoad, this);
6120 this.store.on('load', this.onLoad, this);
6121 this.store.on('loadexception', this.onLoadException, this);
6122 this.removeMask = false;
6124 var um = this.el.getUpdateManager();
6125 um.showLoadIndicator = false; // disable the default indicator
6126 um.on('beforeupdate', this.onBeforeLoad, this);
6127 um.on('update', this.onLoad, this);
6128 um.on('failure', this.onLoad, this);
6129 this.removeMask = true;
6133 Roo.LoadMask.prototype = {
6135 * @cfg {Boolean} removeMask
6136 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6137 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6141 * The text to display in a centered loading message box (defaults to 'Loading...')
6145 * @cfg {String} msgCls
6146 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6148 msgCls : 'x-mask-loading',
6151 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6157 * Disables the mask to prevent it from being displayed
6159 disable : function(){
6160 this.disabled = true;
6164 * Enables the mask so that it can be displayed
6166 enable : function(){
6167 this.disabled = false;
6170 onLoadException : function()
6174 if (typeof(arguments[3]) != 'undefined') {
6175 Roo.MessageBox.alert("Error loading",arguments[3]);
6179 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6180 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6187 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6192 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6196 onBeforeLoad : function(){
6198 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6203 destroy : function(){
6205 this.store.un('beforeload', this.onBeforeLoad, this);
6206 this.store.un('load', this.onLoad, this);
6207 this.store.un('loadexception', this.onLoadException, this);
6209 var um = this.el.getUpdateManager();
6210 um.un('beforeupdate', this.onBeforeLoad, this);
6211 um.un('update', this.onLoad, this);
6212 um.un('failure', this.onLoad, this);
6223 * @class Roo.bootstrap.Table
6224 * @extends Roo.bootstrap.Component
6225 * Bootstrap Table class
6226 * @cfg {String} cls table class
6227 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6228 * @cfg {String} bgcolor Specifies the background color for a table
6229 * @cfg {Number} border Specifies whether the table cells should have borders or not
6230 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6231 * @cfg {Number} cellspacing Specifies the space between cells
6232 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6233 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6234 * @cfg {String} sortable Specifies that the table should be sortable
6235 * @cfg {String} summary Specifies a summary of the content of a table
6236 * @cfg {Number} width Specifies the width of a table
6237 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6239 * @cfg {boolean} striped Should the rows be alternative striped
6240 * @cfg {boolean} bordered Add borders to the table
6241 * @cfg {boolean} hover Add hover highlighting
6242 * @cfg {boolean} condensed Format condensed
6243 * @cfg {boolean} responsive Format condensed
6244 * @cfg {Boolean} loadMask (true|false) default false
6245 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6246 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6247 * @cfg {Boolean} rowSelection (true|false) default false
6248 * @cfg {Boolean} cellSelection (true|false) default false
6249 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6250 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6251 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6252 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6256 * Create a new Table
6257 * @param {Object} config The config object
6260 Roo.bootstrap.Table = function(config){
6261 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6266 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6267 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6268 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6269 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6271 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6273 this.sm.grid = this;
6274 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6275 this.sm = this.selModel;
6276 this.sm.xmodule = this.xmodule || false;
6279 if (this.cm && typeof(this.cm.config) == 'undefined') {
6280 this.colModel = new Roo.grid.ColumnModel(this.cm);
6281 this.cm = this.colModel;
6282 this.cm.xmodule = this.xmodule || false;
6285 this.store= Roo.factory(this.store, Roo.data);
6286 this.ds = this.store;
6287 this.ds.xmodule = this.xmodule || false;
6290 if (this.footer && this.store) {
6291 this.footer.dataSource = this.ds;
6292 this.footer = Roo.factory(this.footer);
6299 * Fires when a cell is clicked
6300 * @param {Roo.bootstrap.Table} this
6301 * @param {Roo.Element} el
6302 * @param {Number} rowIndex
6303 * @param {Number} columnIndex
6304 * @param {Roo.EventObject} e
6308 * @event celldblclick
6309 * Fires when a cell is double clicked
6310 * @param {Roo.bootstrap.Table} this
6311 * @param {Roo.Element} el
6312 * @param {Number} rowIndex
6313 * @param {Number} columnIndex
6314 * @param {Roo.EventObject} e
6316 "celldblclick" : true,
6319 * Fires when a row is clicked
6320 * @param {Roo.bootstrap.Table} this
6321 * @param {Roo.Element} el
6322 * @param {Number} rowIndex
6323 * @param {Roo.EventObject} e
6327 * @event rowdblclick
6328 * Fires when a row is double clicked
6329 * @param {Roo.bootstrap.Table} this
6330 * @param {Roo.Element} el
6331 * @param {Number} rowIndex
6332 * @param {Roo.EventObject} e
6334 "rowdblclick" : true,
6337 * Fires when a mouseover occur
6338 * @param {Roo.bootstrap.Table} this
6339 * @param {Roo.Element} el
6340 * @param {Number} rowIndex
6341 * @param {Number} columnIndex
6342 * @param {Roo.EventObject} e
6347 * Fires when a mouseout occur
6348 * @param {Roo.bootstrap.Table} this
6349 * @param {Roo.Element} el
6350 * @param {Number} rowIndex
6351 * @param {Number} columnIndex
6352 * @param {Roo.EventObject} e
6357 * Fires when a row is rendered, so you can change add a style to it.
6358 * @param {Roo.bootstrap.Table} this
6359 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6363 * @event rowsrendered
6364 * Fires when all the rows have been rendered
6365 * @param {Roo.bootstrap.Table} this
6367 'rowsrendered' : true,
6369 * @event contextmenu
6370 * The raw contextmenu event for the entire grid.
6371 * @param {Roo.EventObject} e
6373 "contextmenu" : true,
6375 * @event rowcontextmenu
6376 * Fires when a row is right clicked
6377 * @param {Roo.bootstrap.Table} this
6378 * @param {Number} rowIndex
6379 * @param {Roo.EventObject} e
6381 "rowcontextmenu" : true,
6383 * @event cellcontextmenu
6384 * Fires when a cell is right clicked
6385 * @param {Roo.bootstrap.Table} this
6386 * @param {Number} rowIndex
6387 * @param {Number} cellIndex
6388 * @param {Roo.EventObject} e
6390 "cellcontextmenu" : true,
6392 * @event headercontextmenu
6393 * Fires when a header is right clicked
6394 * @param {Roo.bootstrap.Table} this
6395 * @param {Number} columnIndex
6396 * @param {Roo.EventObject} e
6398 "headercontextmenu" : true
6402 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6428 rowSelection : false,
6429 cellSelection : false,
6432 // Roo.Element - the tbody
6434 // Roo.Element - thead element
6437 container: false, // used by gridpanel...
6443 auto_hide_footer : false,
6445 getAutoCreate : function()
6447 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6454 if (this.scrollBody) {
6455 cfg.cls += ' table-body-fixed';
6458 cfg.cls += ' table-striped';
6462 cfg.cls += ' table-hover';
6464 if (this.bordered) {
6465 cfg.cls += ' table-bordered';
6467 if (this.condensed) {
6468 cfg.cls += ' table-condensed';
6470 if (this.responsive) {
6471 cfg.cls += ' table-responsive';
6475 cfg.cls+= ' ' +this.cls;
6478 // this lot should be simplifed...
6491 ].forEach(function(k) {
6499 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6502 if(this.store || this.cm){
6503 if(this.headerShow){
6504 cfg.cn.push(this.renderHeader());
6507 cfg.cn.push(this.renderBody());
6509 if(this.footerShow){
6510 cfg.cn.push(this.renderFooter());
6512 // where does this come from?
6513 //cfg.cls+= ' TableGrid';
6516 return { cn : [ cfg ] };
6519 initEvents : function()
6521 if(!this.store || !this.cm){
6524 if (this.selModel) {
6525 this.selModel.initEvents();
6529 //Roo.log('initEvents with ds!!!!');
6531 this.mainBody = this.el.select('tbody', true).first();
6532 this.mainHead = this.el.select('thead', true).first();
6533 this.mainFoot = this.el.select('tfoot', true).first();
6539 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6540 e.on('click', _this.sort, _this);
6543 this.mainBody.on("click", this.onClick, this);
6544 this.mainBody.on("dblclick", this.onDblClick, this);
6546 // why is this done????? = it breaks dialogs??
6547 //this.parent().el.setStyle('position', 'relative');
6551 this.footer.parentId = this.id;
6552 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6555 this.el.select('tfoot tr td').first().addClass('hide');
6560 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6563 this.store.on('load', this.onLoad, this);
6564 this.store.on('beforeload', this.onBeforeLoad, this);
6565 this.store.on('update', this.onUpdate, this);
6566 this.store.on('add', this.onAdd, this);
6567 this.store.on("clear", this.clear, this);
6569 this.el.on("contextmenu", this.onContextMenu, this);
6571 this.mainBody.on('scroll', this.onBodyScroll, this);
6573 this.cm.on("headerchange", this.onHeaderChange, this);
6575 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6579 onContextMenu : function(e, t)
6581 this.processEvent("contextmenu", e);
6584 processEvent : function(name, e)
6586 if (name != 'touchstart' ) {
6587 this.fireEvent(name, e);
6590 var t = e.getTarget();
6592 var cell = Roo.get(t);
6598 if(cell.findParent('tfoot', false, true)){
6602 if(cell.findParent('thead', false, true)){
6604 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6605 cell = Roo.get(t).findParent('th', false, true);
6607 Roo.log("failed to find th in thead?");
6608 Roo.log(e.getTarget());
6613 var cellIndex = cell.dom.cellIndex;
6615 var ename = name == 'touchstart' ? 'click' : name;
6616 this.fireEvent("header" + ename, this, cellIndex, e);
6621 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6622 cell = Roo.get(t).findParent('td', false, true);
6624 Roo.log("failed to find th in tbody?");
6625 Roo.log(e.getTarget());
6630 var row = cell.findParent('tr', false, true);
6631 var cellIndex = cell.dom.cellIndex;
6632 var rowIndex = row.dom.rowIndex - 1;
6636 this.fireEvent("row" + name, this, rowIndex, e);
6640 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6646 onMouseover : function(e, el)
6648 var cell = Roo.get(el);
6654 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6655 cell = cell.findParent('td', false, true);
6658 var row = cell.findParent('tr', false, true);
6659 var cellIndex = cell.dom.cellIndex;
6660 var rowIndex = row.dom.rowIndex - 1; // start from 0
6662 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6666 onMouseout : function(e, el)
6668 var cell = Roo.get(el);
6674 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6675 cell = cell.findParent('td', false, true);
6678 var row = cell.findParent('tr', false, true);
6679 var cellIndex = cell.dom.cellIndex;
6680 var rowIndex = row.dom.rowIndex - 1; // start from 0
6682 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6686 onClick : function(e, el)
6688 var cell = Roo.get(el);
6690 if(!cell || (!this.cellSelection && !this.rowSelection)){
6694 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6695 cell = cell.findParent('td', false, true);
6698 if(!cell || typeof(cell) == 'undefined'){
6702 var row = cell.findParent('tr', false, true);
6704 if(!row || typeof(row) == 'undefined'){
6708 var cellIndex = cell.dom.cellIndex;
6709 var rowIndex = this.getRowIndex(row);
6711 // why??? - should these not be based on SelectionModel?
6712 if(this.cellSelection){
6713 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6716 if(this.rowSelection){
6717 this.fireEvent('rowclick', this, row, rowIndex, e);
6723 onDblClick : function(e,el)
6725 var cell = Roo.get(el);
6727 if(!cell || (!this.cellSelection && !this.rowSelection)){
6731 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6732 cell = cell.findParent('td', false, true);
6735 if(!cell || typeof(cell) == 'undefined'){
6739 var row = cell.findParent('tr', false, true);
6741 if(!row || typeof(row) == 'undefined'){
6745 var cellIndex = cell.dom.cellIndex;
6746 var rowIndex = this.getRowIndex(row);
6748 if(this.cellSelection){
6749 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6752 if(this.rowSelection){
6753 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6757 sort : function(e,el)
6759 var col = Roo.get(el);
6761 if(!col.hasClass('sortable')){
6765 var sort = col.attr('sort');
6768 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6772 this.store.sortInfo = {field : sort, direction : dir};
6775 Roo.log("calling footer first");
6776 this.footer.onClick('first');
6779 this.store.load({ params : { start : 0 } });
6783 renderHeader : function()
6791 this.totalWidth = 0;
6793 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6795 var config = cm.config[i];
6799 cls : 'x-hcol-' + i,
6801 html: cm.getColumnHeader(i)
6806 if(typeof(config.sortable) != 'undefined' && config.sortable){
6808 c.html = '<i class="glyphicon"></i>' + c.html;
6811 // could use BS4 hidden-..-down
6813 if(typeof(config.lgHeader) != 'undefined'){
6814 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
6817 if(typeof(config.mdHeader) != 'undefined'){
6818 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6821 if(typeof(config.smHeader) != 'undefined'){
6822 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6825 if(typeof(config.xsHeader) != 'undefined'){
6826 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6833 if(typeof(config.tooltip) != 'undefined'){
6834 c.tooltip = config.tooltip;
6837 if(typeof(config.colspan) != 'undefined'){
6838 c.colspan = config.colspan;
6841 if(typeof(config.hidden) != 'undefined' && config.hidden){
6842 c.style += ' display:none;';
6845 if(typeof(config.dataIndex) != 'undefined'){
6846 c.sort = config.dataIndex;
6851 if(typeof(config.align) != 'undefined' && config.align.length){
6852 c.style += ' text-align:' + config.align + ';';
6855 if(typeof(config.width) != 'undefined'){
6856 c.style += ' width:' + config.width + 'px;';
6857 this.totalWidth += config.width;
6859 this.totalWidth += 100; // assume minimum of 100 per column?
6862 if(typeof(config.cls) != 'undefined'){
6863 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6866 ['xs','sm','md','lg'].map(function(size){
6868 if(typeof(config[size]) == 'undefined'){
6872 if (!config[size]) { // 0 = hidden
6873 // BS 4 '0' is treated as hide that column and below.
6874 c.cls += ' hidden-' + size + ' hidden' + size + 'down';
6878 c.cls += ' col-' + size + '-' + config[size] + (
6879 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
6891 renderBody : function()
6901 colspan : this.cm.getColumnCount()
6911 renderFooter : function()
6921 colspan : this.cm.getColumnCount()
6935 // Roo.log('ds onload');
6940 var ds = this.store;
6942 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6943 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6944 if (_this.store.sortInfo) {
6946 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6947 e.select('i', true).addClass(['glyphicon-arrow-up']);
6950 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6951 e.select('i', true).addClass(['glyphicon-arrow-down']);
6956 var tbody = this.mainBody;
6958 if(ds.getCount() > 0){
6959 ds.data.each(function(d,rowIndex){
6960 var row = this.renderRow(cm, ds, rowIndex);
6962 tbody.createChild(row);
6966 if(row.cellObjects.length){
6967 Roo.each(row.cellObjects, function(r){
6968 _this.renderCellObject(r);
6975 var tfoot = this.el.select('tfoot', true).first();
6977 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6979 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6981 var total = this.ds.getTotalCount();
6983 if(this.footer.pageSize < total){
6984 this.mainFoot.show();
6988 Roo.each(this.el.select('tbody td', true).elements, function(e){
6989 e.on('mouseover', _this.onMouseover, _this);
6992 Roo.each(this.el.select('tbody td', true).elements, function(e){
6993 e.on('mouseout', _this.onMouseout, _this);
6995 this.fireEvent('rowsrendered', this);
7001 onUpdate : function(ds,record)
7003 this.refreshRow(record);
7007 onRemove : function(ds, record, index, isUpdate){
7008 if(isUpdate !== true){
7009 this.fireEvent("beforerowremoved", this, index, record);
7011 var bt = this.mainBody.dom;
7013 var rows = this.el.select('tbody > tr', true).elements;
7015 if(typeof(rows[index]) != 'undefined'){
7016 bt.removeChild(rows[index].dom);
7019 // if(bt.rows[index]){
7020 // bt.removeChild(bt.rows[index]);
7023 if(isUpdate !== true){
7024 //this.stripeRows(index);
7025 //this.syncRowHeights(index, index);
7027 this.fireEvent("rowremoved", this, index, record);
7031 onAdd : function(ds, records, rowIndex)
7033 //Roo.log('on Add called');
7034 // - note this does not handle multiple adding very well..
7035 var bt = this.mainBody.dom;
7036 for (var i =0 ; i < records.length;i++) {
7037 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7038 //Roo.log(records[i]);
7039 //Roo.log(this.store.getAt(rowIndex+i));
7040 this.insertRow(this.store, rowIndex + i, false);
7047 refreshRow : function(record){
7048 var ds = this.store, index;
7049 if(typeof record == 'number'){
7051 record = ds.getAt(index);
7053 index = ds.indexOf(record);
7055 this.insertRow(ds, index, true);
7057 this.onRemove(ds, record, index+1, true);
7059 //this.syncRowHeights(index, index);
7061 this.fireEvent("rowupdated", this, index, record);
7064 insertRow : function(dm, rowIndex, isUpdate){
7067 this.fireEvent("beforerowsinserted", this, rowIndex);
7069 //var s = this.getScrollState();
7070 var row = this.renderRow(this.cm, this.store, rowIndex);
7071 // insert before rowIndex..
7072 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7076 if(row.cellObjects.length){
7077 Roo.each(row.cellObjects, function(r){
7078 _this.renderCellObject(r);
7083 this.fireEvent("rowsinserted", this, rowIndex);
7084 //this.syncRowHeights(firstRow, lastRow);
7085 //this.stripeRows(firstRow);
7092 getRowDom : function(rowIndex)
7094 var rows = this.el.select('tbody > tr', true).elements;
7096 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7099 // returns the object tree for a tr..
7102 renderRow : function(cm, ds, rowIndex)
7104 var d = ds.getAt(rowIndex);
7108 cls : 'x-row-' + rowIndex,
7112 var cellObjects = [];
7114 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7115 var config = cm.config[i];
7117 var renderer = cm.getRenderer(i);
7121 if(typeof(renderer) !== 'undefined'){
7122 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7124 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7125 // and are rendered into the cells after the row is rendered - using the id for the element.
7127 if(typeof(value) === 'object'){
7137 rowIndex : rowIndex,
7142 this.fireEvent('rowclass', this, rowcfg);
7146 cls : rowcfg.rowClass + ' x-col-' + i,
7148 html: (typeof(value) === 'object') ? '' : value
7155 if(typeof(config.colspan) != 'undefined'){
7156 td.colspan = config.colspan;
7159 if(typeof(config.hidden) != 'undefined' && config.hidden){
7160 td.style += ' display:none;';
7163 if(typeof(config.align) != 'undefined' && config.align.length){
7164 td.style += ' text-align:' + config.align + ';';
7166 if(typeof(config.valign) != 'undefined' && config.valign.length){
7167 td.style += ' vertical-align:' + config.valign + ';';
7170 if(typeof(config.width) != 'undefined'){
7171 td.style += ' width:' + config.width + 'px;';
7174 if(typeof(config.cursor) != 'undefined'){
7175 td.style += ' cursor:' + config.cursor + ';';
7178 if(typeof(config.cls) != 'undefined'){
7179 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7182 ['xs','sm','md','lg'].map(function(size){
7184 if(typeof(config[size]) == 'undefined'){
7190 if (!config[size]) { // 0 = hidden
7191 // BS 4 '0' is treated as hide that column and below.
7192 td.cls += ' hidden-' + size + ' hidden' + size + 'down';
7196 td.cls += ' col-' + size + '-' + config[size] + (
7197 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
7207 row.cellObjects = cellObjects;
7215 onBeforeLoad : function()
7224 this.el.select('tbody', true).first().dom.innerHTML = '';
7227 * Show or hide a row.
7228 * @param {Number} rowIndex to show or hide
7229 * @param {Boolean} state hide
7231 setRowVisibility : function(rowIndex, state)
7233 var bt = this.mainBody.dom;
7235 var rows = this.el.select('tbody > tr', true).elements;
7237 if(typeof(rows[rowIndex]) == 'undefined'){
7240 rows[rowIndex].dom.style.display = state ? '' : 'none';
7244 getSelectionModel : function(){
7246 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7248 return this.selModel;
7251 * Render the Roo.bootstrap object from renderder
7253 renderCellObject : function(r)
7257 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7259 var t = r.cfg.render(r.container);
7262 Roo.each(r.cfg.cn, function(c){
7264 container: t.getChildContainer(),
7267 _this.renderCellObject(child);
7272 getRowIndex : function(row)
7276 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7287 * Returns the grid's underlying element = used by panel.Grid
7288 * @return {Element} The element
7290 getGridEl : function(){
7294 * Forces a resize - used by panel.Grid
7295 * @return {Element} The element
7297 autoSize : function()
7299 //var ctr = Roo.get(this.container.dom.parentElement);
7300 var ctr = Roo.get(this.el.dom);
7302 var thd = this.getGridEl().select('thead',true).first();
7303 var tbd = this.getGridEl().select('tbody', true).first();
7304 var tfd = this.getGridEl().select('tfoot', true).first();
7306 var cw = ctr.getWidth();
7310 tbd.setSize(ctr.getWidth(),
7311 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7313 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7316 cw = Math.max(cw, this.totalWidth);
7317 this.getGridEl().select('tr',true).setWidth(cw);
7318 // resize 'expandable coloumn?
7320 return; // we doe not have a view in this design..
7323 onBodyScroll: function()
7325 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7327 this.mainHead.setStyle({
7328 'position' : 'relative',
7329 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7335 var scrollHeight = this.mainBody.dom.scrollHeight;
7337 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7339 var height = this.mainBody.getHeight();
7341 if(scrollHeight - height == scrollTop) {
7343 var total = this.ds.getTotalCount();
7345 if(this.footer.cursor + this.footer.pageSize < total){
7347 this.footer.ds.load({
7349 start : this.footer.cursor + this.footer.pageSize,
7350 limit : this.footer.pageSize
7360 onHeaderChange : function()
7362 var header = this.renderHeader();
7363 var table = this.el.select('table', true).first();
7365 this.mainHead.remove();
7366 this.mainHead = table.createChild(header, this.mainBody, false);
7369 onHiddenChange : function(colModel, colIndex, hidden)
7371 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7372 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7374 this.CSS.updateRule(thSelector, "display", "");
7375 this.CSS.updateRule(tdSelector, "display", "");
7378 this.CSS.updateRule(thSelector, "display", "none");
7379 this.CSS.updateRule(tdSelector, "display", "none");
7382 this.onHeaderChange();
7386 setColumnWidth: function(col_index, width)
7388 // width = "md-2 xs-2..."
7389 if(!this.colModel.config[col_index]) {
7393 var w = width.split(" ");
7395 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7397 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7400 for(var j = 0; j < w.length; j++) {
7406 var size_cls = w[j].split("-");
7408 if(!Number.isInteger(size_cls[1] * 1)) {
7412 if(!this.colModel.config[col_index][size_cls[0]]) {
7416 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7420 h_row[0].classList.replace(
7421 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7422 "col-"+size_cls[0]+"-"+size_cls[1]
7425 for(var i = 0; i < rows.length; i++) {
7427 var size_cls = w[j].split("-");
7429 if(!Number.isInteger(size_cls[1] * 1)) {
7433 if(!this.colModel.config[col_index][size_cls[0]]) {
7437 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7441 rows[i].classList.replace(
7442 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7443 "col-"+size_cls[0]+"-"+size_cls[1]
7447 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7462 * @class Roo.bootstrap.TableCell
7463 * @extends Roo.bootstrap.Component
7464 * Bootstrap TableCell class
7465 * @cfg {String} html cell contain text
7466 * @cfg {String} cls cell class
7467 * @cfg {String} tag cell tag (td|th) default td
7468 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7469 * @cfg {String} align Aligns the content in a cell
7470 * @cfg {String} axis Categorizes cells
7471 * @cfg {String} bgcolor Specifies the background color of a cell
7472 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7473 * @cfg {Number} colspan Specifies the number of columns a cell should span
7474 * @cfg {String} headers Specifies one or more header cells a cell is related to
7475 * @cfg {Number} height Sets the height of a cell
7476 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7477 * @cfg {Number} rowspan Sets the number of rows a cell should span
7478 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7479 * @cfg {String} valign Vertical aligns the content in a cell
7480 * @cfg {Number} width Specifies the width of a cell
7483 * Create a new TableCell
7484 * @param {Object} config The config object
7487 Roo.bootstrap.TableCell = function(config){
7488 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7491 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7511 getAutoCreate : function(){
7512 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7532 cfg.align=this.align
7538 cfg.bgcolor=this.bgcolor
7541 cfg.charoff=this.charoff
7544 cfg.colspan=this.colspan
7547 cfg.headers=this.headers
7550 cfg.height=this.height
7553 cfg.nowrap=this.nowrap
7556 cfg.rowspan=this.rowspan
7559 cfg.scope=this.scope
7562 cfg.valign=this.valign
7565 cfg.width=this.width
7584 * @class Roo.bootstrap.TableRow
7585 * @extends Roo.bootstrap.Component
7586 * Bootstrap TableRow class
7587 * @cfg {String} cls row class
7588 * @cfg {String} align Aligns the content in a table row
7589 * @cfg {String} bgcolor Specifies a background color for a table row
7590 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7591 * @cfg {String} valign Vertical aligns the content in a table row
7594 * Create a new TableRow
7595 * @param {Object} config The config object
7598 Roo.bootstrap.TableRow = function(config){
7599 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7602 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7610 getAutoCreate : function(){
7611 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7621 cfg.align = this.align;
7624 cfg.bgcolor = this.bgcolor;
7627 cfg.charoff = this.charoff;
7630 cfg.valign = this.valign;
7648 * @class Roo.bootstrap.TableBody
7649 * @extends Roo.bootstrap.Component
7650 * Bootstrap TableBody class
7651 * @cfg {String} cls element class
7652 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7653 * @cfg {String} align Aligns the content inside the element
7654 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7655 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7658 * Create a new TableBody
7659 * @param {Object} config The config object
7662 Roo.bootstrap.TableBody = function(config){
7663 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7666 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7674 getAutoCreate : function(){
7675 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7689 cfg.align = this.align;
7692 cfg.charoff = this.charoff;
7695 cfg.valign = this.valign;
7702 // initEvents : function()
7709 // this.store = Roo.factory(this.store, Roo.data);
7710 // this.store.on('load', this.onLoad, this);
7712 // this.store.load();
7716 // onLoad: function ()
7718 // this.fireEvent('load', this);
7728 * Ext JS Library 1.1.1
7729 * Copyright(c) 2006-2007, Ext JS, LLC.
7731 * Originally Released Under LGPL - original licence link has changed is not relivant.
7734 * <script type="text/javascript">
7737 // as we use this in bootstrap.
7738 Roo.namespace('Roo.form');
7740 * @class Roo.form.Action
7741 * Internal Class used to handle form actions
7743 * @param {Roo.form.BasicForm} el The form element or its id
7744 * @param {Object} config Configuration options
7749 // define the action interface
7750 Roo.form.Action = function(form, options){
7752 this.options = options || {};
7755 * Client Validation Failed
7758 Roo.form.Action.CLIENT_INVALID = 'client';
7760 * Server Validation Failed
7763 Roo.form.Action.SERVER_INVALID = 'server';
7765 * Connect to Server Failed
7768 Roo.form.Action.CONNECT_FAILURE = 'connect';
7770 * Reading Data from Server Failed
7773 Roo.form.Action.LOAD_FAILURE = 'load';
7775 Roo.form.Action.prototype = {
7777 failureType : undefined,
7778 response : undefined,
7782 run : function(options){
7787 success : function(response){
7792 handleResponse : function(response){
7796 // default connection failure
7797 failure : function(response){
7799 this.response = response;
7800 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7801 this.form.afterAction(this, false);
7804 processResponse : function(response){
7805 this.response = response;
7806 if(!response.responseText){
7809 this.result = this.handleResponse(response);
7813 // utility functions used internally
7814 getUrl : function(appendParams){
7815 var url = this.options.url || this.form.url || this.form.el.dom.action;
7817 var p = this.getParams();
7819 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7825 getMethod : function(){
7826 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7829 getParams : function(){
7830 var bp = this.form.baseParams;
7831 var p = this.options.params;
7833 if(typeof p == "object"){
7834 p = Roo.urlEncode(Roo.applyIf(p, bp));
7835 }else if(typeof p == 'string' && bp){
7836 p += '&' + Roo.urlEncode(bp);
7839 p = Roo.urlEncode(bp);
7844 createCallback : function(){
7846 success: this.success,
7847 failure: this.failure,
7849 timeout: (this.form.timeout*1000),
7850 upload: this.form.fileUpload ? this.success : undefined
7855 Roo.form.Action.Submit = function(form, options){
7856 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7859 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7862 haveProgress : false,
7863 uploadComplete : false,
7865 // uploadProgress indicator.
7866 uploadProgress : function()
7868 if (!this.form.progressUrl) {
7872 if (!this.haveProgress) {
7873 Roo.MessageBox.progress("Uploading", "Uploading");
7875 if (this.uploadComplete) {
7876 Roo.MessageBox.hide();
7880 this.haveProgress = true;
7882 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7884 var c = new Roo.data.Connection();
7886 url : this.form.progressUrl,
7891 success : function(req){
7892 //console.log(data);
7896 rdata = Roo.decode(req.responseText)
7898 Roo.log("Invalid data from server..");
7902 if (!rdata || !rdata.success) {
7904 Roo.MessageBox.alert(Roo.encode(rdata));
7907 var data = rdata.data;
7909 if (this.uploadComplete) {
7910 Roo.MessageBox.hide();
7915 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7916 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7919 this.uploadProgress.defer(2000,this);
7922 failure: function(data) {
7923 Roo.log('progress url failed ');
7934 // run get Values on the form, so it syncs any secondary forms.
7935 this.form.getValues();
7937 var o = this.options;
7938 var method = this.getMethod();
7939 var isPost = method == 'POST';
7940 if(o.clientValidation === false || this.form.isValid()){
7942 if (this.form.progressUrl) {
7943 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7944 (new Date() * 1) + '' + Math.random());
7949 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7950 form:this.form.el.dom,
7951 url:this.getUrl(!isPost),
7953 params:isPost ? this.getParams() : null,
7954 isUpload: this.form.fileUpload,
7955 formData : this.form.formData
7958 this.uploadProgress();
7960 }else if (o.clientValidation !== false){ // client validation failed
7961 this.failureType = Roo.form.Action.CLIENT_INVALID;
7962 this.form.afterAction(this, false);
7966 success : function(response)
7968 this.uploadComplete= true;
7969 if (this.haveProgress) {
7970 Roo.MessageBox.hide();
7974 var result = this.processResponse(response);
7975 if(result === true || result.success){
7976 this.form.afterAction(this, true);
7980 this.form.markInvalid(result.errors);
7981 this.failureType = Roo.form.Action.SERVER_INVALID;
7983 this.form.afterAction(this, false);
7985 failure : function(response)
7987 this.uploadComplete= true;
7988 if (this.haveProgress) {
7989 Roo.MessageBox.hide();
7992 this.response = response;
7993 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7994 this.form.afterAction(this, false);
7997 handleResponse : function(response){
7998 if(this.form.errorReader){
7999 var rs = this.form.errorReader.read(response);
8002 for(var i = 0, len = rs.records.length; i < len; i++) {
8003 var r = rs.records[i];
8007 if(errors.length < 1){
8011 success : rs.success,
8017 ret = Roo.decode(response.responseText);
8021 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
8031 Roo.form.Action.Load = function(form, options){
8032 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
8033 this.reader = this.form.reader;
8036 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8041 Roo.Ajax.request(Roo.apply(
8042 this.createCallback(), {
8043 method:this.getMethod(),
8044 url:this.getUrl(false),
8045 params:this.getParams()
8049 success : function(response){
8051 var result = this.processResponse(response);
8052 if(result === true || !result.success || !result.data){
8053 this.failureType = Roo.form.Action.LOAD_FAILURE;
8054 this.form.afterAction(this, false);
8057 this.form.clearInvalid();
8058 this.form.setValues(result.data);
8059 this.form.afterAction(this, true);
8062 handleResponse : function(response){
8063 if(this.form.reader){
8064 var rs = this.form.reader.read(response);
8065 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8067 success : rs.success,
8071 return Roo.decode(response.responseText);
8075 Roo.form.Action.ACTION_TYPES = {
8076 'load' : Roo.form.Action.Load,
8077 'submit' : Roo.form.Action.Submit
8086 * @class Roo.bootstrap.Form
8087 * @extends Roo.bootstrap.Component
8088 * Bootstrap Form class
8089 * @cfg {String} method GET | POST (default POST)
8090 * @cfg {String} labelAlign top | left (default top)
8091 * @cfg {String} align left | right - for navbars
8092 * @cfg {Boolean} loadMask load mask when submit (default true)
8097 * @param {Object} config The config object
8101 Roo.bootstrap.Form = function(config){
8103 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8105 Roo.bootstrap.Form.popover.apply();
8109 * @event clientvalidation
8110 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8111 * @param {Form} this
8112 * @param {Boolean} valid true if the form has passed client-side validation
8114 clientvalidation: true,
8116 * @event beforeaction
8117 * Fires before any action is performed. Return false to cancel the action.
8118 * @param {Form} this
8119 * @param {Action} action The action to be performed
8123 * @event actionfailed
8124 * Fires when an action fails.
8125 * @param {Form} this
8126 * @param {Action} action The action that failed
8128 actionfailed : true,
8130 * @event actioncomplete
8131 * Fires when an action is completed.
8132 * @param {Form} this
8133 * @param {Action} action The action that completed
8135 actioncomplete : true
8139 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8142 * @cfg {String} method
8143 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8148 * The URL to use for form actions if one isn't supplied in the action options.
8151 * @cfg {Boolean} fileUpload
8152 * Set to true if this form is a file upload.
8156 * @cfg {Object} baseParams
8157 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8161 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8165 * @cfg {Sting} align (left|right) for navbar forms
8170 activeAction : null,
8173 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8174 * element by passing it or its id or mask the form itself by passing in true.
8177 waitMsgTarget : false,
8182 * @cfg {Boolean} errorMask (true|false) default false
8187 * @cfg {Number} maskOffset Default 100
8192 * @cfg {Boolean} maskBody
8196 getAutoCreate : function(){
8200 method : this.method || 'POST',
8201 id : this.id || Roo.id(),
8204 if (this.parent().xtype.match(/^Nav/)) {
8205 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8209 if (this.labelAlign == 'left' ) {
8210 cfg.cls += ' form-horizontal';
8216 initEvents : function()
8218 this.el.on('submit', this.onSubmit, this);
8219 // this was added as random key presses on the form where triggering form submit.
8220 this.el.on('keypress', function(e) {
8221 if (e.getCharCode() != 13) {
8224 // we might need to allow it for textareas.. and some other items.
8225 // check e.getTarget().
8227 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8231 Roo.log("keypress blocked");
8239 onSubmit : function(e){
8244 * Returns true if client-side validation on the form is successful.
8247 isValid : function(){
8248 var items = this.getItems();
8252 items.each(function(f){
8258 Roo.log('invalid field: ' + f.name);
8262 if(!target && f.el.isVisible(true)){
8268 if(this.errorMask && !valid){
8269 Roo.bootstrap.Form.popover.mask(this, target);
8276 * Returns true if any fields in this form have changed since their original load.
8279 isDirty : function(){
8281 var items = this.getItems();
8282 items.each(function(f){
8292 * Performs a predefined action (submit or load) or custom actions you define on this form.
8293 * @param {String} actionName The name of the action type
8294 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8295 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8296 * accept other config options):
8298 Property Type Description
8299 ---------------- --------------- ----------------------------------------------------------------------------------
8300 url String The url for the action (defaults to the form's url)
8301 method String The form method to use (defaults to the form's method, or POST if not defined)
8302 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8303 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8304 validate the form on the client (defaults to false)
8306 * @return {BasicForm} this
8308 doAction : function(action, options){
8309 if(typeof action == 'string'){
8310 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8312 if(this.fireEvent('beforeaction', this, action) !== false){
8313 this.beforeAction(action);
8314 action.run.defer(100, action);
8320 beforeAction : function(action){
8321 var o = action.options;
8326 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8328 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8331 // not really supported yet.. ??
8333 //if(this.waitMsgTarget === true){
8334 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8335 //}else if(this.waitMsgTarget){
8336 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8337 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8339 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8345 afterAction : function(action, success){
8346 this.activeAction = null;
8347 var o = action.options;
8352 Roo.get(document.body).unmask();
8358 //if(this.waitMsgTarget === true){
8359 // this.el.unmask();
8360 //}else if(this.waitMsgTarget){
8361 // this.waitMsgTarget.unmask();
8363 // Roo.MessageBox.updateProgress(1);
8364 // Roo.MessageBox.hide();
8371 Roo.callback(o.success, o.scope, [this, action]);
8372 this.fireEvent('actioncomplete', this, action);
8376 // failure condition..
8377 // we have a scenario where updates need confirming.
8378 // eg. if a locking scenario exists..
8379 // we look for { errors : { needs_confirm : true }} in the response.
8381 (typeof(action.result) != 'undefined') &&
8382 (typeof(action.result.errors) != 'undefined') &&
8383 (typeof(action.result.errors.needs_confirm) != 'undefined')
8386 Roo.log("not supported yet");
8389 Roo.MessageBox.confirm(
8390 "Change requires confirmation",
8391 action.result.errorMsg,
8396 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8406 Roo.callback(o.failure, o.scope, [this, action]);
8407 // show an error message if no failed handler is set..
8408 if (!this.hasListener('actionfailed')) {
8409 Roo.log("need to add dialog support");
8411 Roo.MessageBox.alert("Error",
8412 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8413 action.result.errorMsg :
8414 "Saving Failed, please check your entries or try again"
8419 this.fireEvent('actionfailed', this, action);
8424 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8425 * @param {String} id The value to search for
8428 findField : function(id){
8429 var items = this.getItems();
8430 var field = items.get(id);
8432 items.each(function(f){
8433 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8440 return field || null;
8443 * Mark fields in this form invalid in bulk.
8444 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8445 * @return {BasicForm} this
8447 markInvalid : function(errors){
8448 if(errors instanceof Array){
8449 for(var i = 0, len = errors.length; i < len; i++){
8450 var fieldError = errors[i];
8451 var f = this.findField(fieldError.id);
8453 f.markInvalid(fieldError.msg);
8459 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8460 field.markInvalid(errors[id]);
8464 //Roo.each(this.childForms || [], function (f) {
8465 // f.markInvalid(errors);
8472 * Set values for fields in this form in bulk.
8473 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8474 * @return {BasicForm} this
8476 setValues : function(values){
8477 if(values instanceof Array){ // array of objects
8478 for(var i = 0, len = values.length; i < len; i++){
8480 var f = this.findField(v.id);
8482 f.setValue(v.value);
8483 if(this.trackResetOnLoad){
8484 f.originalValue = f.getValue();
8488 }else{ // object hash
8491 if(typeof values[id] != 'function' && (field = this.findField(id))){
8493 if (field.setFromData &&
8495 field.displayField &&
8496 // combos' with local stores can
8497 // be queried via setValue()
8498 // to set their value..
8499 (field.store && !field.store.isLocal)
8503 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8504 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8505 field.setFromData(sd);
8507 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8509 field.setFromData(values);
8512 field.setValue(values[id]);
8516 if(this.trackResetOnLoad){
8517 field.originalValue = field.getValue();
8523 //Roo.each(this.childForms || [], function (f) {
8524 // f.setValues(values);
8531 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8532 * they are returned as an array.
8533 * @param {Boolean} asString
8536 getValues : function(asString){
8537 //if (this.childForms) {
8538 // copy values from the child forms
8539 // Roo.each(this.childForms, function (f) {
8540 // this.setValues(f.getValues());
8546 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8547 if(asString === true){
8550 return Roo.urlDecode(fs);
8554 * Returns the fields in this form as an object with key/value pairs.
8555 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8558 getFieldValues : function(with_hidden)
8560 var items = this.getItems();
8562 items.each(function(f){
8568 var v = f.getValue();
8570 if (f.inputType =='radio') {
8571 if (typeof(ret[f.getName()]) == 'undefined') {
8572 ret[f.getName()] = ''; // empty..
8575 if (!f.el.dom.checked) {
8583 if(f.xtype == 'MoneyField'){
8584 ret[f.currencyName] = f.getCurrency();
8587 // not sure if this supported any more..
8588 if ((typeof(v) == 'object') && f.getRawValue) {
8589 v = f.getRawValue() ; // dates..
8591 // combo boxes where name != hiddenName...
8592 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8593 ret[f.name] = f.getRawValue();
8595 ret[f.getName()] = v;
8602 * Clears all invalid messages in this form.
8603 * @return {BasicForm} this
8605 clearInvalid : function(){
8606 var items = this.getItems();
8608 items.each(function(f){
8617 * @return {BasicForm} this
8620 var items = this.getItems();
8621 items.each(function(f){
8625 Roo.each(this.childForms || [], function (f) {
8633 getItems : function()
8635 var r=new Roo.util.MixedCollection(false, function(o){
8636 return o.id || (o.id = Roo.id());
8638 var iter = function(el) {
8645 Roo.each(el.items,function(e) {
8654 hideFields : function(items)
8656 Roo.each(items, function(i){
8658 var f = this.findField(i);
8669 showFields : function(items)
8671 Roo.each(items, function(i){
8673 var f = this.findField(i);
8686 Roo.apply(Roo.bootstrap.Form, {
8713 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8714 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8715 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8716 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8719 this.maskEl.top.enableDisplayMode("block");
8720 this.maskEl.left.enableDisplayMode("block");
8721 this.maskEl.bottom.enableDisplayMode("block");
8722 this.maskEl.right.enableDisplayMode("block");
8724 this.toolTip = new Roo.bootstrap.Tooltip({
8725 cls : 'roo-form-error-popover',
8727 'left' : ['r-l', [-2,0], 'right'],
8728 'right' : ['l-r', [2,0], 'left'],
8729 'bottom' : ['tl-bl', [0,2], 'top'],
8730 'top' : [ 'bl-tl', [0,-2], 'bottom']
8734 this.toolTip.render(Roo.get(document.body));
8736 this.toolTip.el.enableDisplayMode("block");
8738 Roo.get(document.body).on('click', function(){
8742 Roo.get(document.body).on('touchstart', function(){
8746 this.isApplied = true
8749 mask : function(form, target)
8753 this.target = target;
8755 if(!this.form.errorMask || !target.el){
8759 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8761 Roo.log(scrollable);
8763 var ot = this.target.el.calcOffsetsTo(scrollable);
8765 var scrollTo = ot[1] - this.form.maskOffset;
8767 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8769 scrollable.scrollTo('top', scrollTo);
8771 var box = this.target.el.getBox();
8773 var zIndex = Roo.bootstrap.Modal.zIndex++;
8776 this.maskEl.top.setStyle('position', 'absolute');
8777 this.maskEl.top.setStyle('z-index', zIndex);
8778 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8779 this.maskEl.top.setLeft(0);
8780 this.maskEl.top.setTop(0);
8781 this.maskEl.top.show();
8783 this.maskEl.left.setStyle('position', 'absolute');
8784 this.maskEl.left.setStyle('z-index', zIndex);
8785 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8786 this.maskEl.left.setLeft(0);
8787 this.maskEl.left.setTop(box.y - this.padding);
8788 this.maskEl.left.show();
8790 this.maskEl.bottom.setStyle('position', 'absolute');
8791 this.maskEl.bottom.setStyle('z-index', zIndex);
8792 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8793 this.maskEl.bottom.setLeft(0);
8794 this.maskEl.bottom.setTop(box.bottom + this.padding);
8795 this.maskEl.bottom.show();
8797 this.maskEl.right.setStyle('position', 'absolute');
8798 this.maskEl.right.setStyle('z-index', zIndex);
8799 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8800 this.maskEl.right.setLeft(box.right + this.padding);
8801 this.maskEl.right.setTop(box.y - this.padding);
8802 this.maskEl.right.show();
8804 this.toolTip.bindEl = this.target.el;
8806 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8808 var tip = this.target.blankText;
8810 if(this.target.getValue() !== '' ) {
8812 if (this.target.invalidText.length) {
8813 tip = this.target.invalidText;
8814 } else if (this.target.regexText.length){
8815 tip = this.target.regexText;
8819 this.toolTip.show(tip);
8821 this.intervalID = window.setInterval(function() {
8822 Roo.bootstrap.Form.popover.unmask();
8825 window.onwheel = function(){ return false;};
8827 (function(){ this.isMasked = true; }).defer(500, this);
8833 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8837 this.maskEl.top.setStyle('position', 'absolute');
8838 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8839 this.maskEl.top.hide();
8841 this.maskEl.left.setStyle('position', 'absolute');
8842 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8843 this.maskEl.left.hide();
8845 this.maskEl.bottom.setStyle('position', 'absolute');
8846 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8847 this.maskEl.bottom.hide();
8849 this.maskEl.right.setStyle('position', 'absolute');
8850 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8851 this.maskEl.right.hide();
8853 this.toolTip.hide();
8855 this.toolTip.el.hide();
8857 window.onwheel = function(){ return true;};
8859 if(this.intervalID){
8860 window.clearInterval(this.intervalID);
8861 this.intervalID = false;
8864 this.isMasked = false;
8874 * Ext JS Library 1.1.1
8875 * Copyright(c) 2006-2007, Ext JS, LLC.
8877 * Originally Released Under LGPL - original licence link has changed is not relivant.
8880 * <script type="text/javascript">
8883 * @class Roo.form.VTypes
8884 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8887 Roo.form.VTypes = function(){
8888 // closure these in so they are only created once.
8889 var alpha = /^[a-zA-Z_]+$/;
8890 var alphanum = /^[a-zA-Z0-9_]+$/;
8891 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8892 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8894 // All these messages and functions are configurable
8897 * The function used to validate email addresses
8898 * @param {String} value The email address
8900 'email' : function(v){
8901 return email.test(v);
8904 * The error text to display when the email validation function returns false
8907 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8909 * The keystroke filter mask to be applied on email input
8912 'emailMask' : /[a-z0-9_\.\-@]/i,
8915 * The function used to validate URLs
8916 * @param {String} value The URL
8918 'url' : function(v){
8922 * The error text to display when the url validation function returns false
8925 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8928 * The function used to validate alpha values
8929 * @param {String} value The value
8931 'alpha' : function(v){
8932 return alpha.test(v);
8935 * The error text to display when the alpha validation function returns false
8938 'alphaText' : 'This field should only contain letters and _',
8940 * The keystroke filter mask to be applied on alpha input
8943 'alphaMask' : /[a-z_]/i,
8946 * The function used to validate alphanumeric values
8947 * @param {String} value The value
8949 'alphanum' : function(v){
8950 return alphanum.test(v);
8953 * The error text to display when the alphanumeric validation function returns false
8956 'alphanumText' : 'This field should only contain letters, numbers and _',
8958 * The keystroke filter mask to be applied on alphanumeric input
8961 'alphanumMask' : /[a-z0-9_]/i
8971 * @class Roo.bootstrap.Input
8972 * @extends Roo.bootstrap.Component
8973 * Bootstrap Input class
8974 * @cfg {Boolean} disabled is it disabled
8975 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8976 * @cfg {String} name name of the input
8977 * @cfg {string} fieldLabel - the label associated
8978 * @cfg {string} placeholder - placeholder to put in text.
8979 * @cfg {string} before - input group add on before
8980 * @cfg {string} after - input group add on after
8981 * @cfg {string} size - (lg|sm) or leave empty..
8982 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8983 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8984 * @cfg {Number} md colspan out of 12 for computer-sized screens
8985 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8986 * @cfg {string} value default value of the input
8987 * @cfg {Number} labelWidth set the width of label
8988 * @cfg {Number} labellg set the width of label (1-12)
8989 * @cfg {Number} labelmd set the width of label (1-12)
8990 * @cfg {Number} labelsm set the width of label (1-12)
8991 * @cfg {Number} labelxs set the width of label (1-12)
8992 * @cfg {String} labelAlign (top|left)
8993 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8994 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8995 * @cfg {String} indicatorpos (left|right) default left
8996 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8997 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8999 * @cfg {String} align (left|center|right) Default left
9000 * @cfg {Boolean} forceFeedback (true|false) Default false
9003 * Create a new Input
9004 * @param {Object} config The config object
9007 Roo.bootstrap.Input = function(config){
9009 Roo.bootstrap.Input.superclass.constructor.call(this, config);
9014 * Fires when this field receives input focus.
9015 * @param {Roo.form.Field} this
9020 * Fires when this field loses input focus.
9021 * @param {Roo.form.Field} this
9026 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
9027 * {@link Roo.EventObject#getKey} to determine which key was pressed.
9028 * @param {Roo.form.Field} this
9029 * @param {Roo.EventObject} e The event object
9034 * Fires just before the field blurs if the field value has changed.
9035 * @param {Roo.form.Field} this
9036 * @param {Mixed} newValue The new value
9037 * @param {Mixed} oldValue The original value
9042 * Fires after the field has been marked as invalid.
9043 * @param {Roo.form.Field} this
9044 * @param {String} msg The validation message
9049 * Fires after the field has been validated with no errors.
9050 * @param {Roo.form.Field} this
9055 * Fires after the key up
9056 * @param {Roo.form.Field} this
9057 * @param {Roo.EventObject} e The event Object
9063 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9065 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9066 automatic validation (defaults to "keyup").
9068 validationEvent : "keyup",
9070 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9072 validateOnBlur : true,
9074 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9076 validationDelay : 250,
9078 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9080 focusClass : "x-form-focus", // not needed???
9084 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9086 invalidClass : "has-warning",
9089 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9091 validClass : "has-success",
9094 * @cfg {Boolean} hasFeedback (true|false) default true
9099 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9101 invalidFeedbackClass : "glyphicon-warning-sign",
9104 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9106 validFeedbackClass : "glyphicon-ok",
9109 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9111 selectOnFocus : false,
9114 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9118 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9123 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9125 disableKeyFilter : false,
9128 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9132 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9136 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9138 blankText : "Please complete this mandatory field",
9141 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9145 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9147 maxLength : Number.MAX_VALUE,
9149 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9151 minLengthText : "The minimum length for this field is {0}",
9153 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9155 maxLengthText : "The maximum length for this field is {0}",
9159 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9160 * If available, this function will be called only after the basic validators all return true, and will be passed the
9161 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9165 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9166 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9167 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9171 * @cfg {String} regexText -- Depricated - use Invalid Text
9176 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9182 autocomplete: false,
9201 formatedValue : false,
9202 forceFeedback : false,
9204 indicatorpos : 'left',
9214 parentLabelAlign : function()
9217 while (parent.parent()) {
9218 parent = parent.parent();
9219 if (typeof(parent.labelAlign) !='undefined') {
9220 return parent.labelAlign;
9227 getAutoCreate : function()
9229 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9235 if(this.inputType != 'hidden'){
9236 cfg.cls = 'form-group' //input-group
9242 type : this.inputType,
9244 cls : 'form-control',
9245 placeholder : this.placeholder || '',
9246 autocomplete : this.autocomplete || 'new-password'
9249 if(this.capture.length){
9250 input.capture = this.capture;
9253 if(this.accept.length){
9254 input.accept = this.accept + "/*";
9258 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9261 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9262 input.maxLength = this.maxLength;
9265 if (this.disabled) {
9266 input.disabled=true;
9269 if (this.readOnly) {
9270 input.readonly=true;
9274 input.name = this.name;
9278 input.cls += ' input-' + this.size;
9282 ['xs','sm','md','lg'].map(function(size){
9283 if (settings[size]) {
9284 cfg.cls += ' col-' + size + '-' + settings[size];
9288 var inputblock = input;
9292 cls: 'glyphicon form-control-feedback'
9295 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9298 cls : 'has-feedback',
9306 if (this.before || this.after) {
9309 cls : 'input-group',
9313 if (this.before && typeof(this.before) == 'string') {
9315 inputblock.cn.push({
9317 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9321 if (this.before && typeof(this.before) == 'object') {
9322 this.before = Roo.factory(this.before);
9324 inputblock.cn.push({
9326 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9327 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9331 inputblock.cn.push(input);
9333 if (this.after && typeof(this.after) == 'string') {
9334 inputblock.cn.push({
9336 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9340 if (this.after && typeof(this.after) == 'object') {
9341 this.after = Roo.factory(this.after);
9343 inputblock.cn.push({
9345 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9346 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9350 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9351 inputblock.cls += ' has-feedback';
9352 inputblock.cn.push(feedback);
9357 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9358 tooltip : 'This field is required'
9360 if (Roo.bootstrap.version == 4) {
9363 style : 'display-none'
9366 if (align ==='left' && this.fieldLabel.length) {
9368 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9375 cls : 'control-label col-form-label',
9376 html : this.fieldLabel
9387 var labelCfg = cfg.cn[1];
9388 var contentCfg = cfg.cn[2];
9390 if(this.indicatorpos == 'right'){
9395 cls : 'control-label col-form-label',
9399 html : this.fieldLabel
9413 labelCfg = cfg.cn[0];
9414 contentCfg = cfg.cn[1];
9418 if(this.labelWidth > 12){
9419 labelCfg.style = "width: " + this.labelWidth + 'px';
9422 if(this.labelWidth < 13 && this.labelmd == 0){
9423 this.labelmd = this.labelWidth;
9426 if(this.labellg > 0){
9427 labelCfg.cls += ' col-lg-' + this.labellg;
9428 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9431 if(this.labelmd > 0){
9432 labelCfg.cls += ' col-md-' + this.labelmd;
9433 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9436 if(this.labelsm > 0){
9437 labelCfg.cls += ' col-sm-' + this.labelsm;
9438 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9441 if(this.labelxs > 0){
9442 labelCfg.cls += ' col-xs-' + this.labelxs;
9443 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9447 } else if ( this.fieldLabel.length) {
9452 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9453 tooltip : 'This field is required'
9457 //cls : 'input-group-addon',
9458 html : this.fieldLabel
9466 if(this.indicatorpos == 'right'){
9471 //cls : 'input-group-addon',
9472 html : this.fieldLabel
9477 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9478 tooltip : 'This field is required'
9498 if (this.parentType === 'Navbar' && this.parent().bar) {
9499 cfg.cls += ' navbar-form';
9502 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9503 // on BS4 we do this only if not form
9504 cfg.cls += ' navbar-form';
9512 * return the real input element.
9514 inputEl: function ()
9516 return this.el.select('input.form-control',true).first();
9519 tooltipEl : function()
9521 return this.inputEl();
9524 indicatorEl : function()
9526 if (Roo.bootstrap.version == 4) {
9527 return false; // not enabled in v4 yet.
9530 var indicator = this.el.select('i.roo-required-indicator',true).first();
9540 setDisabled : function(v)
9542 var i = this.inputEl().dom;
9544 i.removeAttribute('disabled');
9548 i.setAttribute('disabled','true');
9550 initEvents : function()
9553 this.inputEl().on("keydown" , this.fireKey, this);
9554 this.inputEl().on("focus", this.onFocus, this);
9555 this.inputEl().on("blur", this.onBlur, this);
9557 this.inputEl().relayEvent('keyup', this);
9559 this.indicator = this.indicatorEl();
9562 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9565 // reference to original value for reset
9566 this.originalValue = this.getValue();
9567 //Roo.form.TextField.superclass.initEvents.call(this);
9568 if(this.validationEvent == 'keyup'){
9569 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9570 this.inputEl().on('keyup', this.filterValidation, this);
9572 else if(this.validationEvent !== false){
9573 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9576 if(this.selectOnFocus){
9577 this.on("focus", this.preFocus, this);
9580 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9581 this.inputEl().on("keypress", this.filterKeys, this);
9583 this.inputEl().relayEvent('keypress', this);
9586 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9587 this.el.on("click", this.autoSize, this);
9590 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9591 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9594 if (typeof(this.before) == 'object') {
9595 this.before.render(this.el.select('.roo-input-before',true).first());
9597 if (typeof(this.after) == 'object') {
9598 this.after.render(this.el.select('.roo-input-after',true).first());
9601 this.inputEl().on('change', this.onChange, this);
9604 filterValidation : function(e){
9605 if(!e.isNavKeyPress()){
9606 this.validationTask.delay(this.validationDelay);
9610 * Validates the field value
9611 * @return {Boolean} True if the value is valid, else false
9613 validate : function(){
9614 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9615 if(this.disabled || this.validateValue(this.getRawValue())){
9626 * Validates a value according to the field's validation rules and marks the field as invalid
9627 * if the validation fails
9628 * @param {Mixed} value The value to validate
9629 * @return {Boolean} True if the value is valid, else false
9631 validateValue : function(value)
9633 if(this.getVisibilityEl().hasClass('hidden')){
9637 if(value.length < 1) { // if it's blank
9638 if(this.allowBlank){
9644 if(value.length < this.minLength){
9647 if(value.length > this.maxLength){
9651 var vt = Roo.form.VTypes;
9652 if(!vt[this.vtype](value, this)){
9656 if(typeof this.validator == "function"){
9657 var msg = this.validator(value);
9661 if (typeof(msg) == 'string') {
9662 this.invalidText = msg;
9666 if(this.regex && !this.regex.test(value)){
9674 fireKey : function(e){
9675 //Roo.log('field ' + e.getKey());
9676 if(e.isNavKeyPress()){
9677 this.fireEvent("specialkey", this, e);
9680 focus : function (selectText){
9682 this.inputEl().focus();
9683 if(selectText === true){
9684 this.inputEl().dom.select();
9690 onFocus : function(){
9691 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9692 // this.el.addClass(this.focusClass);
9695 this.hasFocus = true;
9696 this.startValue = this.getValue();
9697 this.fireEvent("focus", this);
9701 beforeBlur : Roo.emptyFn,
9705 onBlur : function(){
9707 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9708 //this.el.removeClass(this.focusClass);
9710 this.hasFocus = false;
9711 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9714 var v = this.getValue();
9715 if(String(v) !== String(this.startValue)){
9716 this.fireEvent('change', this, v, this.startValue);
9718 this.fireEvent("blur", this);
9721 onChange : function(e)
9723 var v = this.getValue();
9724 if(String(v) !== String(this.startValue)){
9725 this.fireEvent('change', this, v, this.startValue);
9731 * Resets the current field value to the originally loaded value and clears any validation messages
9734 this.setValue(this.originalValue);
9738 * Returns the name of the field
9739 * @return {Mixed} name The name field
9741 getName: function(){
9745 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9746 * @return {Mixed} value The field value
9748 getValue : function(){
9750 var v = this.inputEl().getValue();
9755 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9756 * @return {Mixed} value The field value
9758 getRawValue : function(){
9759 var v = this.inputEl().getValue();
9765 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9766 * @param {Mixed} value The value to set
9768 setRawValue : function(v){
9769 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9772 selectText : function(start, end){
9773 var v = this.getRawValue();
9775 start = start === undefined ? 0 : start;
9776 end = end === undefined ? v.length : end;
9777 var d = this.inputEl().dom;
9778 if(d.setSelectionRange){
9779 d.setSelectionRange(start, end);
9780 }else if(d.createTextRange){
9781 var range = d.createTextRange();
9782 range.moveStart("character", start);
9783 range.moveEnd("character", v.length-end);
9790 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9791 * @param {Mixed} value The value to set
9793 setValue : function(v){
9796 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9802 processValue : function(value){
9803 if(this.stripCharsRe){
9804 var newValue = value.replace(this.stripCharsRe, '');
9805 if(newValue !== value){
9806 this.setRawValue(newValue);
9813 preFocus : function(){
9815 if(this.selectOnFocus){
9816 this.inputEl().dom.select();
9819 filterKeys : function(e){
9821 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9824 var c = e.getCharCode(), cc = String.fromCharCode(c);
9825 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9828 if(!this.maskRe.test(cc)){
9833 * Clear any invalid styles/messages for this field
9835 clearInvalid : function(){
9837 if(!this.el || this.preventMark){ // not rendered
9842 this.el.removeClass([this.invalidClass, 'is-invalid']);
9844 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9846 var feedback = this.el.select('.form-control-feedback', true).first();
9849 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9855 this.indicator.removeClass('visible');
9856 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9859 this.fireEvent('valid', this);
9863 * Mark this field as valid
9865 markValid : function()
9867 if(!this.el || this.preventMark){ // not rendered...
9871 this.el.removeClass([this.invalidClass, this.validClass]);
9872 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9874 var feedback = this.el.select('.form-control-feedback', true).first();
9877 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9881 this.indicator.removeClass('visible');
9882 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9889 if(this.allowBlank && !this.getRawValue().length){
9892 if (Roo.bootstrap.version == 3) {
9893 this.el.addClass(this.validClass);
9895 this.inputEl().addClass('is-valid');
9898 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9900 var feedback = this.el.select('.form-control-feedback', true).first();
9903 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9904 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9909 this.fireEvent('valid', this);
9913 * Mark this field as invalid
9914 * @param {String} msg The validation message
9916 markInvalid : function(msg)
9918 if(!this.el || this.preventMark){ // not rendered
9922 this.el.removeClass([this.invalidClass, this.validClass]);
9923 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9925 var feedback = this.el.select('.form-control-feedback', true).first();
9928 this.el.select('.form-control-feedback', true).first().removeClass(
9929 [this.invalidFeedbackClass, this.validFeedbackClass]);
9936 if(this.allowBlank && !this.getRawValue().length){
9941 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9942 this.indicator.addClass('visible');
9944 if (Roo.bootstrap.version == 3) {
9945 this.el.addClass(this.invalidClass);
9947 this.inputEl().addClass('is-invalid');
9952 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9954 var feedback = this.el.select('.form-control-feedback', true).first();
9957 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9959 if(this.getValue().length || this.forceFeedback){
9960 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9967 this.fireEvent('invalid', this, msg);
9970 SafariOnKeyDown : function(event)
9972 // this is a workaround for a password hang bug on chrome/ webkit.
9973 if (this.inputEl().dom.type != 'password') {
9977 var isSelectAll = false;
9979 if(this.inputEl().dom.selectionEnd > 0){
9980 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9982 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9983 event.preventDefault();
9988 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9990 event.preventDefault();
9991 // this is very hacky as keydown always get's upper case.
9993 var cc = String.fromCharCode(event.getCharCode());
9994 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9998 adjustWidth : function(tag, w){
9999 tag = tag.toLowerCase();
10000 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
10001 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
10002 if(tag == 'input'){
10005 if(tag == 'textarea'){
10008 }else if(Roo.isOpera){
10009 if(tag == 'input'){
10012 if(tag == 'textarea'){
10020 setFieldLabel : function(v)
10022 if(!this.rendered){
10026 if(this.indicatorEl()){
10027 var ar = this.el.select('label > span',true);
10029 if (ar.elements.length) {
10030 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10031 this.fieldLabel = v;
10035 var br = this.el.select('label',true);
10037 if(br.elements.length) {
10038 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10039 this.fieldLabel = v;
10043 Roo.log('Cannot Found any of label > span || label in input');
10047 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10048 this.fieldLabel = v;
10063 * @class Roo.bootstrap.TextArea
10064 * @extends Roo.bootstrap.Input
10065 * Bootstrap TextArea class
10066 * @cfg {Number} cols Specifies the visible width of a text area
10067 * @cfg {Number} rows Specifies the visible number of lines in a text area
10068 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10069 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10070 * @cfg {string} html text
10073 * Create a new TextArea
10074 * @param {Object} config The config object
10077 Roo.bootstrap.TextArea = function(config){
10078 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10082 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10092 getAutoCreate : function(){
10094 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10100 if(this.inputType != 'hidden'){
10101 cfg.cls = 'form-group' //input-group
10109 value : this.value || '',
10110 html: this.html || '',
10111 cls : 'form-control',
10112 placeholder : this.placeholder || ''
10116 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10117 input.maxLength = this.maxLength;
10121 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10125 input.cols = this.cols;
10128 if (this.readOnly) {
10129 input.readonly = true;
10133 input.name = this.name;
10137 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10141 ['xs','sm','md','lg'].map(function(size){
10142 if (settings[size]) {
10143 cfg.cls += ' col-' + size + '-' + settings[size];
10147 var inputblock = input;
10149 if(this.hasFeedback && !this.allowBlank){
10153 cls: 'glyphicon form-control-feedback'
10157 cls : 'has-feedback',
10166 if (this.before || this.after) {
10169 cls : 'input-group',
10173 inputblock.cn.push({
10175 cls : 'input-group-addon',
10180 inputblock.cn.push(input);
10182 if(this.hasFeedback && !this.allowBlank){
10183 inputblock.cls += ' has-feedback';
10184 inputblock.cn.push(feedback);
10188 inputblock.cn.push({
10190 cls : 'input-group-addon',
10197 if (align ==='left' && this.fieldLabel.length) {
10202 cls : 'control-label',
10203 html : this.fieldLabel
10214 if(this.labelWidth > 12){
10215 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10218 if(this.labelWidth < 13 && this.labelmd == 0){
10219 this.labelmd = this.labelWidth;
10222 if(this.labellg > 0){
10223 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10224 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10227 if(this.labelmd > 0){
10228 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10229 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10232 if(this.labelsm > 0){
10233 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10234 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10237 if(this.labelxs > 0){
10238 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10239 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10242 } else if ( this.fieldLabel.length) {
10247 //cls : 'input-group-addon',
10248 html : this.fieldLabel
10266 if (this.disabled) {
10267 input.disabled=true;
10274 * return the real textarea element.
10276 inputEl: function ()
10278 return this.el.select('textarea.form-control',true).first();
10282 * Clear any invalid styles/messages for this field
10284 clearInvalid : function()
10287 if(!this.el || this.preventMark){ // not rendered
10291 var label = this.el.select('label', true).first();
10292 var icon = this.el.select('i.fa-star', true).first();
10297 this.el.removeClass( this.validClass);
10298 this.inputEl().removeClass('is-invalid');
10300 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10302 var feedback = this.el.select('.form-control-feedback', true).first();
10305 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10310 this.fireEvent('valid', this);
10314 * Mark this field as valid
10316 markValid : function()
10318 if(!this.el || this.preventMark){ // not rendered
10322 this.el.removeClass([this.invalidClass, this.validClass]);
10323 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10325 var feedback = this.el.select('.form-control-feedback', true).first();
10328 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10331 if(this.disabled || this.allowBlank){
10335 var label = this.el.select('label', true).first();
10336 var icon = this.el.select('i.fa-star', true).first();
10341 if (Roo.bootstrap.version == 3) {
10342 this.el.addClass(this.validClass);
10344 this.inputEl().addClass('is-valid');
10348 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10350 var feedback = this.el.select('.form-control-feedback', true).first();
10353 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10354 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10359 this.fireEvent('valid', this);
10363 * Mark this field as invalid
10364 * @param {String} msg The validation message
10366 markInvalid : function(msg)
10368 if(!this.el || this.preventMark){ // not rendered
10372 this.el.removeClass([this.invalidClass, this.validClass]);
10373 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10375 var feedback = this.el.select('.form-control-feedback', true).first();
10378 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10381 if(this.disabled || this.allowBlank){
10385 var label = this.el.select('label', true).first();
10386 var icon = this.el.select('i.fa-star', true).first();
10388 if(!this.getValue().length && label && !icon){
10389 this.el.createChild({
10391 cls : 'text-danger fa fa-lg fa-star',
10392 tooltip : 'This field is required',
10393 style : 'margin-right:5px;'
10397 if (Roo.bootstrap.version == 3) {
10398 this.el.addClass(this.invalidClass);
10400 this.inputEl().addClass('is-invalid');
10403 // fixme ... this may be depricated need to test..
10404 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10406 var feedback = this.el.select('.form-control-feedback', true).first();
10409 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10411 if(this.getValue().length || this.forceFeedback){
10412 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10419 this.fireEvent('invalid', this, msg);
10427 * trigger field - base class for combo..
10432 * @class Roo.bootstrap.TriggerField
10433 * @extends Roo.bootstrap.Input
10434 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10435 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10436 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10437 * for which you can provide a custom implementation. For example:
10439 var trigger = new Roo.bootstrap.TriggerField();
10440 trigger.onTriggerClick = myTriggerFn;
10441 trigger.applyTo('my-field');
10444 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10445 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10446 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10447 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10448 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10451 * Create a new TriggerField.
10452 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10453 * to the base TextField)
10455 Roo.bootstrap.TriggerField = function(config){
10456 this.mimicing = false;
10457 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10460 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10462 * @cfg {String} triggerClass A CSS class to apply to the trigger
10465 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10470 * @cfg {Boolean} removable (true|false) special filter default false
10474 /** @cfg {Boolean} grow @hide */
10475 /** @cfg {Number} growMin @hide */
10476 /** @cfg {Number} growMax @hide */
10482 autoSize: Roo.emptyFn,
10486 deferHeight : true,
10489 actionMode : 'wrap',
10494 getAutoCreate : function(){
10496 var align = this.labelAlign || this.parentLabelAlign();
10501 cls: 'form-group' //input-group
10508 type : this.inputType,
10509 cls : 'form-control',
10510 autocomplete: 'new-password',
10511 placeholder : this.placeholder || ''
10515 input.name = this.name;
10518 input.cls += ' input-' + this.size;
10521 if (this.disabled) {
10522 input.disabled=true;
10525 var inputblock = input;
10527 if(this.hasFeedback && !this.allowBlank){
10531 cls: 'glyphicon form-control-feedback'
10534 if(this.removable && !this.editable && !this.tickable){
10536 cls : 'has-feedback',
10542 cls : 'roo-combo-removable-btn close'
10549 cls : 'has-feedback',
10558 if(this.removable && !this.editable && !this.tickable){
10560 cls : 'roo-removable',
10566 cls : 'roo-combo-removable-btn close'
10573 if (this.before || this.after) {
10576 cls : 'input-group',
10580 inputblock.cn.push({
10582 cls : 'input-group-addon input-group-prepend input-group-text',
10587 inputblock.cn.push(input);
10589 if(this.hasFeedback && !this.allowBlank){
10590 inputblock.cls += ' has-feedback';
10591 inputblock.cn.push(feedback);
10595 inputblock.cn.push({
10597 cls : 'input-group-addon input-group-append input-group-text',
10606 var ibwrap = inputblock;
10611 cls: 'roo-select2-choices',
10615 cls: 'roo-select2-search-field',
10627 cls: 'roo-select2-container input-group',
10632 cls: 'form-hidden-field'
10638 if(!this.multiple && this.showToggleBtn){
10644 if (this.caret != false) {
10647 cls: 'fa fa-' + this.caret
10654 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10659 cls: 'combobox-clear',
10673 combobox.cls += ' roo-select2-container-multi';
10677 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10678 tooltip : 'This field is required'
10680 if (Roo.bootstrap.version == 4) {
10683 style : 'display:none'
10688 if (align ==='left' && this.fieldLabel.length) {
10690 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10697 cls : 'control-label',
10698 html : this.fieldLabel
10710 var labelCfg = cfg.cn[1];
10711 var contentCfg = cfg.cn[2];
10713 if(this.indicatorpos == 'right'){
10718 cls : 'control-label',
10722 html : this.fieldLabel
10736 labelCfg = cfg.cn[0];
10737 contentCfg = cfg.cn[1];
10740 if(this.labelWidth > 12){
10741 labelCfg.style = "width: " + this.labelWidth + 'px';
10744 if(this.labelWidth < 13 && this.labelmd == 0){
10745 this.labelmd = this.labelWidth;
10748 if(this.labellg > 0){
10749 labelCfg.cls += ' col-lg-' + this.labellg;
10750 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10753 if(this.labelmd > 0){
10754 labelCfg.cls += ' col-md-' + this.labelmd;
10755 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10758 if(this.labelsm > 0){
10759 labelCfg.cls += ' col-sm-' + this.labelsm;
10760 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10763 if(this.labelxs > 0){
10764 labelCfg.cls += ' col-xs-' + this.labelxs;
10765 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10768 } else if ( this.fieldLabel.length) {
10769 // Roo.log(" label");
10774 //cls : 'input-group-addon',
10775 html : this.fieldLabel
10783 if(this.indicatorpos == 'right'){
10791 html : this.fieldLabel
10805 // Roo.log(" no label && no align");
10812 ['xs','sm','md','lg'].map(function(size){
10813 if (settings[size]) {
10814 cfg.cls += ' col-' + size + '-' + settings[size];
10825 onResize : function(w, h){
10826 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10827 // if(typeof w == 'number'){
10828 // var x = w - this.trigger.getWidth();
10829 // this.inputEl().setWidth(this.adjustWidth('input', x));
10830 // this.trigger.setStyle('left', x+'px');
10835 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10838 getResizeEl : function(){
10839 return this.inputEl();
10843 getPositionEl : function(){
10844 return this.inputEl();
10848 alignErrorIcon : function(){
10849 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10853 initEvents : function(){
10857 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10858 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10859 if(!this.multiple && this.showToggleBtn){
10860 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10861 if(this.hideTrigger){
10862 this.trigger.setDisplayed(false);
10864 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10868 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10871 if(this.removable && !this.editable && !this.tickable){
10872 var close = this.closeTriggerEl();
10875 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10876 close.on('click', this.removeBtnClick, this, close);
10880 //this.trigger.addClassOnOver('x-form-trigger-over');
10881 //this.trigger.addClassOnClick('x-form-trigger-click');
10884 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10888 closeTriggerEl : function()
10890 var close = this.el.select('.roo-combo-removable-btn', true).first();
10891 return close ? close : false;
10894 removeBtnClick : function(e, h, el)
10896 e.preventDefault();
10898 if(this.fireEvent("remove", this) !== false){
10900 this.fireEvent("afterremove", this)
10904 createList : function()
10906 this.list = Roo.get(document.body).createChild({
10907 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10908 cls: 'typeahead typeahead-long dropdown-menu',
10909 style: 'display:none'
10912 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10917 initTrigger : function(){
10922 onDestroy : function(){
10924 this.trigger.removeAllListeners();
10925 // this.trigger.remove();
10928 // this.wrap.remove();
10930 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10934 onFocus : function(){
10935 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10937 if(!this.mimicing){
10938 this.wrap.addClass('x-trigger-wrap-focus');
10939 this.mimicing = true;
10940 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10941 if(this.monitorTab){
10942 this.el.on("keydown", this.checkTab, this);
10949 checkTab : function(e){
10950 if(e.getKey() == e.TAB){
10951 this.triggerBlur();
10956 onBlur : function(){
10961 mimicBlur : function(e, t){
10963 if(!this.wrap.contains(t) && this.validateBlur()){
10964 this.triggerBlur();
10970 triggerBlur : function(){
10971 this.mimicing = false;
10972 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10973 if(this.monitorTab){
10974 this.el.un("keydown", this.checkTab, this);
10976 //this.wrap.removeClass('x-trigger-wrap-focus');
10977 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10981 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10982 validateBlur : function(e, t){
10987 onDisable : function(){
10988 this.inputEl().dom.disabled = true;
10989 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10991 // this.wrap.addClass('x-item-disabled');
10996 onEnable : function(){
10997 this.inputEl().dom.disabled = false;
10998 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
11000 // this.el.removeClass('x-item-disabled');
11005 onShow : function(){
11006 var ae = this.getActionEl();
11009 ae.dom.style.display = '';
11010 ae.dom.style.visibility = 'visible';
11016 onHide : function(){
11017 var ae = this.getActionEl();
11018 ae.dom.style.display = 'none';
11022 * The function that should handle the trigger's click event. This method does nothing by default until overridden
11023 * by an implementing function.
11025 * @param {EventObject} e
11027 onTriggerClick : Roo.emptyFn
11031 * Ext JS Library 1.1.1
11032 * Copyright(c) 2006-2007, Ext JS, LLC.
11034 * Originally Released Under LGPL - original licence link has changed is not relivant.
11037 * <script type="text/javascript">
11042 * @class Roo.data.SortTypes
11044 * Defines the default sorting (casting?) comparison functions used when sorting data.
11046 Roo.data.SortTypes = {
11048 * Default sort that does nothing
11049 * @param {Mixed} s The value being converted
11050 * @return {Mixed} The comparison value
11052 none : function(s){
11057 * The regular expression used to strip tags
11061 stripTagsRE : /<\/?[^>]+>/gi,
11064 * Strips all HTML tags to sort on text only
11065 * @param {Mixed} s The value being converted
11066 * @return {String} The comparison value
11068 asText : function(s){
11069 return String(s).replace(this.stripTagsRE, "");
11073 * Strips all HTML tags to sort on text only - Case insensitive
11074 * @param {Mixed} s The value being converted
11075 * @return {String} The comparison value
11077 asUCText : function(s){
11078 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11082 * Case insensitive string
11083 * @param {Mixed} s The value being converted
11084 * @return {String} The comparison value
11086 asUCString : function(s) {
11087 return String(s).toUpperCase();
11092 * @param {Mixed} s The value being converted
11093 * @return {Number} The comparison value
11095 asDate : function(s) {
11099 if(s instanceof Date){
11100 return s.getTime();
11102 return Date.parse(String(s));
11107 * @param {Mixed} s The value being converted
11108 * @return {Float} The comparison value
11110 asFloat : function(s) {
11111 var val = parseFloat(String(s).replace(/,/g, ""));
11120 * @param {Mixed} s The value being converted
11121 * @return {Number} The comparison value
11123 asInt : function(s) {
11124 var val = parseInt(String(s).replace(/,/g, ""));
11132 * Ext JS Library 1.1.1
11133 * Copyright(c) 2006-2007, Ext JS, LLC.
11135 * Originally Released Under LGPL - original licence link has changed is not relivant.
11138 * <script type="text/javascript">
11142 * @class Roo.data.Record
11143 * Instances of this class encapsulate both record <em>definition</em> information, and record
11144 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11145 * to access Records cached in an {@link Roo.data.Store} object.<br>
11147 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11148 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11151 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11153 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11154 * {@link #create}. The parameters are the same.
11155 * @param {Array} data An associative Array of data values keyed by the field name.
11156 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11157 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11158 * not specified an integer id is generated.
11160 Roo.data.Record = function(data, id){
11161 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11166 * Generate a constructor for a specific record layout.
11167 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11168 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11169 * Each field definition object may contain the following properties: <ul>
11170 * <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,
11171 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11172 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11173 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11174 * is being used, then this is a string containing the javascript expression to reference the data relative to
11175 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11176 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11177 * this may be omitted.</p></li>
11178 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11179 * <ul><li>auto (Default, implies no conversion)</li>
11184 * <li>date</li></ul></p></li>
11185 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11186 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11187 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11188 * by the Reader into an object that will be stored in the Record. It is passed the
11189 * following parameters:<ul>
11190 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11192 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11194 * <br>usage:<br><pre><code>
11195 var TopicRecord = Roo.data.Record.create(
11196 {name: 'title', mapping: 'topic_title'},
11197 {name: 'author', mapping: 'username'},
11198 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11199 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11200 {name: 'lastPoster', mapping: 'user2'},
11201 {name: 'excerpt', mapping: 'post_text'}
11204 var myNewRecord = new TopicRecord({
11205 title: 'Do my job please',
11208 lastPost: new Date(),
11209 lastPoster: 'Animal',
11210 excerpt: 'No way dude!'
11212 myStore.add(myNewRecord);
11217 Roo.data.Record.create = function(o){
11218 var f = function(){
11219 f.superclass.constructor.apply(this, arguments);
11221 Roo.extend(f, Roo.data.Record);
11222 var p = f.prototype;
11223 p.fields = new Roo.util.MixedCollection(false, function(field){
11226 for(var i = 0, len = o.length; i < len; i++){
11227 p.fields.add(new Roo.data.Field(o[i]));
11229 f.getField = function(name){
11230 return p.fields.get(name);
11235 Roo.data.Record.AUTO_ID = 1000;
11236 Roo.data.Record.EDIT = 'edit';
11237 Roo.data.Record.REJECT = 'reject';
11238 Roo.data.Record.COMMIT = 'commit';
11240 Roo.data.Record.prototype = {
11242 * Readonly flag - true if this record has been modified.
11251 join : function(store){
11252 this.store = store;
11256 * Set the named field to the specified value.
11257 * @param {String} name The name of the field to set.
11258 * @param {Object} value The value to set the field to.
11260 set : function(name, value){
11261 if(this.data[name] == value){
11265 if(!this.modified){
11266 this.modified = {};
11268 if(typeof this.modified[name] == 'undefined'){
11269 this.modified[name] = this.data[name];
11271 this.data[name] = value;
11272 if(!this.editing && this.store){
11273 this.store.afterEdit(this);
11278 * Get the value of the named field.
11279 * @param {String} name The name of the field to get the value of.
11280 * @return {Object} The value of the field.
11282 get : function(name){
11283 return this.data[name];
11287 beginEdit : function(){
11288 this.editing = true;
11289 this.modified = {};
11293 cancelEdit : function(){
11294 this.editing = false;
11295 delete this.modified;
11299 endEdit : function(){
11300 this.editing = false;
11301 if(this.dirty && this.store){
11302 this.store.afterEdit(this);
11307 * Usually called by the {@link Roo.data.Store} which owns the Record.
11308 * Rejects all changes made to the Record since either creation, or the last commit operation.
11309 * Modified fields are reverted to their original values.
11311 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11312 * of reject operations.
11314 reject : function(){
11315 var m = this.modified;
11317 if(typeof m[n] != "function"){
11318 this.data[n] = m[n];
11321 this.dirty = false;
11322 delete this.modified;
11323 this.editing = false;
11325 this.store.afterReject(this);
11330 * Usually called by the {@link Roo.data.Store} which owns the Record.
11331 * Commits all changes made to the Record since either creation, or the last commit operation.
11333 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11334 * of commit operations.
11336 commit : function(){
11337 this.dirty = false;
11338 delete this.modified;
11339 this.editing = false;
11341 this.store.afterCommit(this);
11346 hasError : function(){
11347 return this.error != null;
11351 clearError : function(){
11356 * Creates a copy of this record.
11357 * @param {String} id (optional) A new record id if you don't want to use this record's id
11360 copy : function(newId) {
11361 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11365 * Ext JS Library 1.1.1
11366 * Copyright(c) 2006-2007, Ext JS, LLC.
11368 * Originally Released Under LGPL - original licence link has changed is not relivant.
11371 * <script type="text/javascript">
11377 * @class Roo.data.Store
11378 * @extends Roo.util.Observable
11379 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11380 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11382 * 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
11383 * has no knowledge of the format of the data returned by the Proxy.<br>
11385 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11386 * instances from the data object. These records are cached and made available through accessor functions.
11388 * Creates a new Store.
11389 * @param {Object} config A config object containing the objects needed for the Store to access data,
11390 * and read the data into Records.
11392 Roo.data.Store = function(config){
11393 this.data = new Roo.util.MixedCollection(false);
11394 this.data.getKey = function(o){
11397 this.baseParams = {};
11399 this.paramNames = {
11404 "multisort" : "_multisort"
11407 if(config && config.data){
11408 this.inlineData = config.data;
11409 delete config.data;
11412 Roo.apply(this, config);
11414 if(this.reader){ // reader passed
11415 this.reader = Roo.factory(this.reader, Roo.data);
11416 this.reader.xmodule = this.xmodule || false;
11417 if(!this.recordType){
11418 this.recordType = this.reader.recordType;
11420 if(this.reader.onMetaChange){
11421 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11425 if(this.recordType){
11426 this.fields = this.recordType.prototype.fields;
11428 this.modified = [];
11432 * @event datachanged
11433 * Fires when the data cache has changed, and a widget which is using this Store
11434 * as a Record cache should refresh its view.
11435 * @param {Store} this
11437 datachanged : true,
11439 * @event metachange
11440 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11441 * @param {Store} this
11442 * @param {Object} meta The JSON metadata
11447 * Fires when Records have been added to the Store
11448 * @param {Store} this
11449 * @param {Roo.data.Record[]} records The array of Records added
11450 * @param {Number} index The index at which the record(s) were added
11455 * Fires when a Record has been removed from the Store
11456 * @param {Store} this
11457 * @param {Roo.data.Record} record The Record that was removed
11458 * @param {Number} index The index at which the record was removed
11463 * Fires when a Record has been updated
11464 * @param {Store} this
11465 * @param {Roo.data.Record} record The Record that was updated
11466 * @param {String} operation The update operation being performed. Value may be one of:
11468 Roo.data.Record.EDIT
11469 Roo.data.Record.REJECT
11470 Roo.data.Record.COMMIT
11476 * Fires when the data cache has been cleared.
11477 * @param {Store} this
11481 * @event beforeload
11482 * Fires before a request is made for a new data object. If the beforeload handler returns false
11483 * the load action will be canceled.
11484 * @param {Store} this
11485 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11489 * @event beforeloadadd
11490 * Fires after a new set of Records has been loaded.
11491 * @param {Store} this
11492 * @param {Roo.data.Record[]} records The Records that were loaded
11493 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11495 beforeloadadd : true,
11498 * Fires after a new set of Records has been loaded, before they are added to the store.
11499 * @param {Store} this
11500 * @param {Roo.data.Record[]} records The Records that were loaded
11501 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11502 * @params {Object} return from reader
11506 * @event loadexception
11507 * Fires if an exception occurs in the Proxy during loading.
11508 * Called with the signature of the Proxy's "loadexception" event.
11509 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11512 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11513 * @param {Object} load options
11514 * @param {Object} jsonData from your request (normally this contains the Exception)
11516 loadexception : true
11520 this.proxy = Roo.factory(this.proxy, Roo.data);
11521 this.proxy.xmodule = this.xmodule || false;
11522 this.relayEvents(this.proxy, ["loadexception"]);
11524 this.sortToggle = {};
11525 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11527 Roo.data.Store.superclass.constructor.call(this);
11529 if(this.inlineData){
11530 this.loadData(this.inlineData);
11531 delete this.inlineData;
11535 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11537 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11538 * without a remote query - used by combo/forms at present.
11542 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11545 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11548 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11549 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11552 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11553 * on any HTTP request
11556 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11559 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11563 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11564 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11566 remoteSort : false,
11569 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11570 * loaded or when a record is removed. (defaults to false).
11572 pruneModifiedRecords : false,
11575 lastOptions : null,
11578 * Add Records to the Store and fires the add event.
11579 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11581 add : function(records){
11582 records = [].concat(records);
11583 for(var i = 0, len = records.length; i < len; i++){
11584 records[i].join(this);
11586 var index = this.data.length;
11587 this.data.addAll(records);
11588 this.fireEvent("add", this, records, index);
11592 * Remove a Record from the Store and fires the remove event.
11593 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11595 remove : function(record){
11596 var index = this.data.indexOf(record);
11597 this.data.removeAt(index);
11599 if(this.pruneModifiedRecords){
11600 this.modified.remove(record);
11602 this.fireEvent("remove", this, record, index);
11606 * Remove all Records from the Store and fires the clear event.
11608 removeAll : function(){
11610 if(this.pruneModifiedRecords){
11611 this.modified = [];
11613 this.fireEvent("clear", this);
11617 * Inserts Records to the Store at the given index and fires the add event.
11618 * @param {Number} index The start index at which to insert the passed Records.
11619 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11621 insert : function(index, records){
11622 records = [].concat(records);
11623 for(var i = 0, len = records.length; i < len; i++){
11624 this.data.insert(index, records[i]);
11625 records[i].join(this);
11627 this.fireEvent("add", this, records, index);
11631 * Get the index within the cache of the passed Record.
11632 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11633 * @return {Number} The index of the passed Record. Returns -1 if not found.
11635 indexOf : function(record){
11636 return this.data.indexOf(record);
11640 * Get the index within the cache of the Record with the passed id.
11641 * @param {String} id The id of the Record to find.
11642 * @return {Number} The index of the Record. Returns -1 if not found.
11644 indexOfId : function(id){
11645 return this.data.indexOfKey(id);
11649 * Get the Record with the specified id.
11650 * @param {String} id The id of the Record to find.
11651 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11653 getById : function(id){
11654 return this.data.key(id);
11658 * Get the Record at the specified index.
11659 * @param {Number} index The index of the Record to find.
11660 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11662 getAt : function(index){
11663 return this.data.itemAt(index);
11667 * Returns a range of Records between specified indices.
11668 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11669 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11670 * @return {Roo.data.Record[]} An array of Records
11672 getRange : function(start, end){
11673 return this.data.getRange(start, end);
11677 storeOptions : function(o){
11678 o = Roo.apply({}, o);
11681 this.lastOptions = o;
11685 * Loads the Record cache from the configured Proxy using the configured Reader.
11687 * If using remote paging, then the first load call must specify the <em>start</em>
11688 * and <em>limit</em> properties in the options.params property to establish the initial
11689 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11691 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11692 * and this call will return before the new data has been loaded. Perform any post-processing
11693 * in a callback function, or in a "load" event handler.</strong>
11695 * @param {Object} options An object containing properties which control loading options:<ul>
11696 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11697 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11698 * passed the following arguments:<ul>
11699 * <li>r : Roo.data.Record[]</li>
11700 * <li>options: Options object from the load call</li>
11701 * <li>success: Boolean success indicator</li></ul></li>
11702 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11703 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11706 load : function(options){
11707 options = options || {};
11708 if(this.fireEvent("beforeload", this, options) !== false){
11709 this.storeOptions(options);
11710 var p = Roo.apply(options.params || {}, this.baseParams);
11711 // if meta was not loaded from remote source.. try requesting it.
11712 if (!this.reader.metaFromRemote) {
11713 p._requestMeta = 1;
11715 if(this.sortInfo && this.remoteSort){
11716 var pn = this.paramNames;
11717 p[pn["sort"]] = this.sortInfo.field;
11718 p[pn["dir"]] = this.sortInfo.direction;
11720 if (this.multiSort) {
11721 var pn = this.paramNames;
11722 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11725 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11730 * Reloads the Record cache from the configured Proxy using the configured Reader and
11731 * the options from the last load operation performed.
11732 * @param {Object} options (optional) An object containing properties which may override the options
11733 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11734 * the most recently used options are reused).
11736 reload : function(options){
11737 this.load(Roo.applyIf(options||{}, this.lastOptions));
11741 // Called as a callback by the Reader during a load operation.
11742 loadRecords : function(o, options, success){
11743 if(!o || success === false){
11744 if(success !== false){
11745 this.fireEvent("load", this, [], options, o);
11747 if(options.callback){
11748 options.callback.call(options.scope || this, [], options, false);
11752 // if data returned failure - throw an exception.
11753 if (o.success === false) {
11754 // show a message if no listener is registered.
11755 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11756 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11758 // loadmask wil be hooked into this..
11759 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11762 var r = o.records, t = o.totalRecords || r.length;
11764 this.fireEvent("beforeloadadd", this, r, options, o);
11766 if(!options || options.add !== true){
11767 if(this.pruneModifiedRecords){
11768 this.modified = [];
11770 for(var i = 0, len = r.length; i < len; i++){
11774 this.data = this.snapshot;
11775 delete this.snapshot;
11778 this.data.addAll(r);
11779 this.totalLength = t;
11781 this.fireEvent("datachanged", this);
11783 this.totalLength = Math.max(t, this.data.length+r.length);
11787 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11789 var e = new Roo.data.Record({});
11791 e.set(this.parent.displayField, this.parent.emptyTitle);
11792 e.set(this.parent.valueField, '');
11797 this.fireEvent("load", this, r, options, o);
11798 if(options.callback){
11799 options.callback.call(options.scope || this, r, options, true);
11805 * Loads data from a passed data block. A Reader which understands the format of the data
11806 * must have been configured in the constructor.
11807 * @param {Object} data The data block from which to read the Records. The format of the data expected
11808 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11809 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11811 loadData : function(o, append){
11812 var r = this.reader.readRecords(o);
11813 this.loadRecords(r, {add: append}, true);
11817 * Gets the number of cached records.
11819 * <em>If using paging, this may not be the total size of the dataset. If the data object
11820 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11821 * the data set size</em>
11823 getCount : function(){
11824 return this.data.length || 0;
11828 * Gets the total number of records in the dataset as returned by the server.
11830 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11831 * the dataset size</em>
11833 getTotalCount : function(){
11834 return this.totalLength || 0;
11838 * Returns the sort state of the Store as an object with two properties:
11840 field {String} The name of the field by which the Records are sorted
11841 direction {String} The sort order, "ASC" or "DESC"
11844 getSortState : function(){
11845 return this.sortInfo;
11849 applySort : function(){
11850 if(this.sortInfo && !this.remoteSort){
11851 var s = this.sortInfo, f = s.field;
11852 var st = this.fields.get(f).sortType;
11853 var fn = function(r1, r2){
11854 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11855 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11857 this.data.sort(s.direction, fn);
11858 if(this.snapshot && this.snapshot != this.data){
11859 this.snapshot.sort(s.direction, fn);
11865 * Sets the default sort column and order to be used by the next load operation.
11866 * @param {String} fieldName The name of the field to sort by.
11867 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11869 setDefaultSort : function(field, dir){
11870 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11874 * Sort the Records.
11875 * If remote sorting is used, the sort is performed on the server, and the cache is
11876 * reloaded. If local sorting is used, the cache is sorted internally.
11877 * @param {String} fieldName The name of the field to sort by.
11878 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11880 sort : function(fieldName, dir){
11881 var f = this.fields.get(fieldName);
11883 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11885 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11886 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11891 this.sortToggle[f.name] = dir;
11892 this.sortInfo = {field: f.name, direction: dir};
11893 if(!this.remoteSort){
11895 this.fireEvent("datachanged", this);
11897 this.load(this.lastOptions);
11902 * Calls the specified function for each of the Records in the cache.
11903 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11904 * Returning <em>false</em> aborts and exits the iteration.
11905 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11907 each : function(fn, scope){
11908 this.data.each(fn, scope);
11912 * Gets all records modified since the last commit. Modified records are persisted across load operations
11913 * (e.g., during paging).
11914 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11916 getModifiedRecords : function(){
11917 return this.modified;
11921 createFilterFn : function(property, value, anyMatch){
11922 if(!value.exec){ // not a regex
11923 value = String(value);
11924 if(value.length == 0){
11927 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11929 return function(r){
11930 return value.test(r.data[property]);
11935 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11936 * @param {String} property A field on your records
11937 * @param {Number} start The record index to start at (defaults to 0)
11938 * @param {Number} end The last record index to include (defaults to length - 1)
11939 * @return {Number} The sum
11941 sum : function(property, start, end){
11942 var rs = this.data.items, v = 0;
11943 start = start || 0;
11944 end = (end || end === 0) ? end : rs.length-1;
11946 for(var i = start; i <= end; i++){
11947 v += (rs[i].data[property] || 0);
11953 * Filter the records by a specified property.
11954 * @param {String} field A field on your records
11955 * @param {String/RegExp} value Either a string that the field
11956 * should start with or a RegExp to test against the field
11957 * @param {Boolean} anyMatch True to match any part not just the beginning
11959 filter : function(property, value, anyMatch){
11960 var fn = this.createFilterFn(property, value, anyMatch);
11961 return fn ? this.filterBy(fn) : this.clearFilter();
11965 * Filter by a function. The specified function will be called with each
11966 * record in this data source. If the function returns true the record is included,
11967 * otherwise it is filtered.
11968 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11969 * @param {Object} scope (optional) The scope of the function (defaults to this)
11971 filterBy : function(fn, scope){
11972 this.snapshot = this.snapshot || this.data;
11973 this.data = this.queryBy(fn, scope||this);
11974 this.fireEvent("datachanged", this);
11978 * Query the records by a specified property.
11979 * @param {String} field A field on your records
11980 * @param {String/RegExp} value Either a string that the field
11981 * should start with or a RegExp to test against the field
11982 * @param {Boolean} anyMatch True to match any part not just the beginning
11983 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11985 query : function(property, value, anyMatch){
11986 var fn = this.createFilterFn(property, value, anyMatch);
11987 return fn ? this.queryBy(fn) : this.data.clone();
11991 * Query by a function. The specified function will be called with each
11992 * record in this data source. If the function returns true the record is included
11994 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11995 * @param {Object} scope (optional) The scope of the function (defaults to this)
11996 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11998 queryBy : function(fn, scope){
11999 var data = this.snapshot || this.data;
12000 return data.filterBy(fn, scope||this);
12004 * Collects unique values for a particular dataIndex from this store.
12005 * @param {String} dataIndex The property to collect
12006 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
12007 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
12008 * @return {Array} An array of the unique values
12010 collect : function(dataIndex, allowNull, bypassFilter){
12011 var d = (bypassFilter === true && this.snapshot) ?
12012 this.snapshot.items : this.data.items;
12013 var v, sv, r = [], l = {};
12014 for(var i = 0, len = d.length; i < len; i++){
12015 v = d[i].data[dataIndex];
12017 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
12026 * Revert to a view of the Record cache with no filtering applied.
12027 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
12029 clearFilter : function(suppressEvent){
12030 if(this.snapshot && this.snapshot != this.data){
12031 this.data = this.snapshot;
12032 delete this.snapshot;
12033 if(suppressEvent !== true){
12034 this.fireEvent("datachanged", this);
12040 afterEdit : function(record){
12041 if(this.modified.indexOf(record) == -1){
12042 this.modified.push(record);
12044 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12048 afterReject : function(record){
12049 this.modified.remove(record);
12050 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12054 afterCommit : function(record){
12055 this.modified.remove(record);
12056 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12060 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12061 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12063 commitChanges : function(){
12064 var m = this.modified.slice(0);
12065 this.modified = [];
12066 for(var i = 0, len = m.length; i < len; i++){
12072 * Cancel outstanding changes on all changed records.
12074 rejectChanges : function(){
12075 var m = this.modified.slice(0);
12076 this.modified = [];
12077 for(var i = 0, len = m.length; i < len; i++){
12082 onMetaChange : function(meta, rtype, o){
12083 this.recordType = rtype;
12084 this.fields = rtype.prototype.fields;
12085 delete this.snapshot;
12086 this.sortInfo = meta.sortInfo || this.sortInfo;
12087 this.modified = [];
12088 this.fireEvent('metachange', this, this.reader.meta);
12091 moveIndex : function(data, type)
12093 var index = this.indexOf(data);
12095 var newIndex = index + type;
12099 this.insert(newIndex, data);
12104 * Ext JS Library 1.1.1
12105 * Copyright(c) 2006-2007, Ext JS, LLC.
12107 * Originally Released Under LGPL - original licence link has changed is not relivant.
12110 * <script type="text/javascript">
12114 * @class Roo.data.SimpleStore
12115 * @extends Roo.data.Store
12116 * Small helper class to make creating Stores from Array data easier.
12117 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12118 * @cfg {Array} fields An array of field definition objects, or field name strings.
12119 * @cfg {Array} data The multi-dimensional array of data
12121 * @param {Object} config
12123 Roo.data.SimpleStore = function(config){
12124 Roo.data.SimpleStore.superclass.constructor.call(this, {
12126 reader: new Roo.data.ArrayReader({
12129 Roo.data.Record.create(config.fields)
12131 proxy : new Roo.data.MemoryProxy(config.data)
12135 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12137 * Ext JS Library 1.1.1
12138 * Copyright(c) 2006-2007, Ext JS, LLC.
12140 * Originally Released Under LGPL - original licence link has changed is not relivant.
12143 * <script type="text/javascript">
12148 * @extends Roo.data.Store
12149 * @class Roo.data.JsonStore
12150 * Small helper class to make creating Stores for JSON data easier. <br/>
12152 var store = new Roo.data.JsonStore({
12153 url: 'get-images.php',
12155 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12158 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12159 * JsonReader and HttpProxy (unless inline data is provided).</b>
12160 * @cfg {Array} fields An array of field definition objects, or field name strings.
12162 * @param {Object} config
12164 Roo.data.JsonStore = function(c){
12165 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12166 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12167 reader: new Roo.data.JsonReader(c, c.fields)
12170 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12172 * Ext JS Library 1.1.1
12173 * Copyright(c) 2006-2007, Ext JS, LLC.
12175 * Originally Released Under LGPL - original licence link has changed is not relivant.
12178 * <script type="text/javascript">
12182 Roo.data.Field = function(config){
12183 if(typeof config == "string"){
12184 config = {name: config};
12186 Roo.apply(this, config);
12189 this.type = "auto";
12192 var st = Roo.data.SortTypes;
12193 // named sortTypes are supported, here we look them up
12194 if(typeof this.sortType == "string"){
12195 this.sortType = st[this.sortType];
12198 // set default sortType for strings and dates
12199 if(!this.sortType){
12202 this.sortType = st.asUCString;
12205 this.sortType = st.asDate;
12208 this.sortType = st.none;
12213 var stripRe = /[\$,%]/g;
12215 // prebuilt conversion function for this field, instead of
12216 // switching every time we're reading a value
12218 var cv, dateFormat = this.dateFormat;
12223 cv = function(v){ return v; };
12226 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12230 return v !== undefined && v !== null && v !== '' ?
12231 parseInt(String(v).replace(stripRe, ""), 10) : '';
12236 return v !== undefined && v !== null && v !== '' ?
12237 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12242 cv = function(v){ return v === true || v === "true" || v == 1; };
12249 if(v instanceof Date){
12253 if(dateFormat == "timestamp"){
12254 return new Date(v*1000);
12256 return Date.parseDate(v, dateFormat);
12258 var parsed = Date.parse(v);
12259 return parsed ? new Date(parsed) : null;
12268 Roo.data.Field.prototype = {
12276 * Ext JS Library 1.1.1
12277 * Copyright(c) 2006-2007, Ext JS, LLC.
12279 * Originally Released Under LGPL - original licence link has changed is not relivant.
12282 * <script type="text/javascript">
12285 // Base class for reading structured data from a data source. This class is intended to be
12286 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12289 * @class Roo.data.DataReader
12290 * Base class for reading structured data from a data source. This class is intended to be
12291 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12294 Roo.data.DataReader = function(meta, recordType){
12298 this.recordType = recordType instanceof Array ?
12299 Roo.data.Record.create(recordType) : recordType;
12302 Roo.data.DataReader.prototype = {
12304 * Create an empty record
12305 * @param {Object} data (optional) - overlay some values
12306 * @return {Roo.data.Record} record created.
12308 newRow : function(d) {
12310 this.recordType.prototype.fields.each(function(c) {
12312 case 'int' : da[c.name] = 0; break;
12313 case 'date' : da[c.name] = new Date(); break;
12314 case 'float' : da[c.name] = 0.0; break;
12315 case 'boolean' : da[c.name] = false; break;
12316 default : da[c.name] = ""; break;
12320 return new this.recordType(Roo.apply(da, d));
12325 * Ext JS Library 1.1.1
12326 * Copyright(c) 2006-2007, Ext JS, LLC.
12328 * Originally Released Under LGPL - original licence link has changed is not relivant.
12331 * <script type="text/javascript">
12335 * @class Roo.data.DataProxy
12336 * @extends Roo.data.Observable
12337 * This class is an abstract base class for implementations which provide retrieval of
12338 * unformatted data objects.<br>
12340 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12341 * (of the appropriate type which knows how to parse the data object) to provide a block of
12342 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12344 * Custom implementations must implement the load method as described in
12345 * {@link Roo.data.HttpProxy#load}.
12347 Roo.data.DataProxy = function(){
12350 * @event beforeload
12351 * Fires before a network request is made to retrieve a data object.
12352 * @param {Object} This DataProxy object.
12353 * @param {Object} params The params parameter to the load function.
12358 * Fires before the load method's callback is called.
12359 * @param {Object} This DataProxy object.
12360 * @param {Object} o The data object.
12361 * @param {Object} arg The callback argument object passed to the load function.
12365 * @event loadexception
12366 * Fires if an Exception occurs during data retrieval.
12367 * @param {Object} This DataProxy object.
12368 * @param {Object} o The data object.
12369 * @param {Object} arg The callback argument object passed to the load function.
12370 * @param {Object} e The Exception.
12372 loadexception : true
12374 Roo.data.DataProxy.superclass.constructor.call(this);
12377 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12380 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12384 * Ext JS Library 1.1.1
12385 * Copyright(c) 2006-2007, Ext JS, LLC.
12387 * Originally Released Under LGPL - original licence link has changed is not relivant.
12390 * <script type="text/javascript">
12393 * @class Roo.data.MemoryProxy
12394 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12395 * to the Reader when its load method is called.
12397 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12399 Roo.data.MemoryProxy = function(data){
12403 Roo.data.MemoryProxy.superclass.constructor.call(this);
12407 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12410 * Load data from the requested source (in this case an in-memory
12411 * data object passed to the constructor), read the data object into
12412 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12413 * process that block using the passed callback.
12414 * @param {Object} params This parameter is not used by the MemoryProxy class.
12415 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12416 * object into a block of Roo.data.Records.
12417 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12418 * The function must be passed <ul>
12419 * <li>The Record block object</li>
12420 * <li>The "arg" argument from the load function</li>
12421 * <li>A boolean success indicator</li>
12423 * @param {Object} scope The scope in which to call the callback
12424 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12426 load : function(params, reader, callback, scope, arg){
12427 params = params || {};
12430 result = reader.readRecords(params.data ? params.data :this.data);
12432 this.fireEvent("loadexception", this, arg, null, e);
12433 callback.call(scope, null, arg, false);
12436 callback.call(scope, result, arg, true);
12440 update : function(params, records){
12445 * Ext JS Library 1.1.1
12446 * Copyright(c) 2006-2007, Ext JS, LLC.
12448 * Originally Released Under LGPL - original licence link has changed is not relivant.
12451 * <script type="text/javascript">
12454 * @class Roo.data.HttpProxy
12455 * @extends Roo.data.DataProxy
12456 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12457 * configured to reference a certain URL.<br><br>
12459 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12460 * from which the running page was served.<br><br>
12462 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12464 * Be aware that to enable the browser to parse an XML document, the server must set
12465 * the Content-Type header in the HTTP response to "text/xml".
12467 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12468 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12469 * will be used to make the request.
12471 Roo.data.HttpProxy = function(conn){
12472 Roo.data.HttpProxy.superclass.constructor.call(this);
12473 // is conn a conn config or a real conn?
12475 this.useAjax = !conn || !conn.events;
12479 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12480 // thse are take from connection...
12483 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12486 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12487 * extra parameters to each request made by this object. (defaults to undefined)
12490 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12491 * to each request made by this object. (defaults to undefined)
12494 * @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)
12497 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12500 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12506 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12510 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12511 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12512 * a finer-grained basis than the DataProxy events.
12514 getConnection : function(){
12515 return this.useAjax ? Roo.Ajax : this.conn;
12519 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12520 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12521 * process that block using the passed callback.
12522 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12523 * for the request to the remote server.
12524 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12525 * object into a block of Roo.data.Records.
12526 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12527 * The function must be passed <ul>
12528 * <li>The Record block object</li>
12529 * <li>The "arg" argument from the load function</li>
12530 * <li>A boolean success indicator</li>
12532 * @param {Object} scope The scope in which to call the callback
12533 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12535 load : function(params, reader, callback, scope, arg){
12536 if(this.fireEvent("beforeload", this, params) !== false){
12538 params : params || {},
12540 callback : callback,
12545 callback : this.loadResponse,
12549 Roo.applyIf(o, this.conn);
12550 if(this.activeRequest){
12551 Roo.Ajax.abort(this.activeRequest);
12553 this.activeRequest = Roo.Ajax.request(o);
12555 this.conn.request(o);
12558 callback.call(scope||this, null, arg, false);
12563 loadResponse : function(o, success, response){
12564 delete this.activeRequest;
12566 this.fireEvent("loadexception", this, o, response);
12567 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12572 result = o.reader.read(response);
12574 this.fireEvent("loadexception", this, o, response, e);
12575 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12579 this.fireEvent("load", this, o, o.request.arg);
12580 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12584 update : function(dataSet){
12589 updateResponse : function(dataSet){
12594 * Ext JS Library 1.1.1
12595 * Copyright(c) 2006-2007, Ext JS, LLC.
12597 * Originally Released Under LGPL - original licence link has changed is not relivant.
12600 * <script type="text/javascript">
12604 * @class Roo.data.ScriptTagProxy
12605 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12606 * other than the originating domain of the running page.<br><br>
12608 * <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
12609 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12611 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12612 * source code that is used as the source inside a <script> tag.<br><br>
12614 * In order for the browser to process the returned data, the server must wrap the data object
12615 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12616 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12617 * depending on whether the callback name was passed:
12620 boolean scriptTag = false;
12621 String cb = request.getParameter("callback");
12624 response.setContentType("text/javascript");
12626 response.setContentType("application/x-json");
12628 Writer out = response.getWriter();
12630 out.write(cb + "(");
12632 out.print(dataBlock.toJsonString());
12639 * @param {Object} config A configuration object.
12641 Roo.data.ScriptTagProxy = function(config){
12642 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12643 Roo.apply(this, config);
12644 this.head = document.getElementsByTagName("head")[0];
12647 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12649 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12651 * @cfg {String} url The URL from which to request the data object.
12654 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12658 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12659 * the server the name of the callback function set up by the load call to process the returned data object.
12660 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12661 * javascript output which calls this named function passing the data object as its only parameter.
12663 callbackParam : "callback",
12665 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12666 * name to the request.
12671 * Load data from the configured URL, read the data object into
12672 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12673 * process that block using the passed callback.
12674 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12675 * for the request to the remote server.
12676 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12677 * object into a block of Roo.data.Records.
12678 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12679 * The function must be passed <ul>
12680 * <li>The Record block object</li>
12681 * <li>The "arg" argument from the load function</li>
12682 * <li>A boolean success indicator</li>
12684 * @param {Object} scope The scope in which to call the callback
12685 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12687 load : function(params, reader, callback, scope, arg){
12688 if(this.fireEvent("beforeload", this, params) !== false){
12690 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12692 var url = this.url;
12693 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12695 url += "&_dc=" + (new Date().getTime());
12697 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12700 cb : "stcCallback"+transId,
12701 scriptId : "stcScript"+transId,
12705 callback : callback,
12711 window[trans.cb] = function(o){
12712 conn.handleResponse(o, trans);
12715 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12717 if(this.autoAbort !== false){
12721 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12723 var script = document.createElement("script");
12724 script.setAttribute("src", url);
12725 script.setAttribute("type", "text/javascript");
12726 script.setAttribute("id", trans.scriptId);
12727 this.head.appendChild(script);
12729 this.trans = trans;
12731 callback.call(scope||this, null, arg, false);
12736 isLoading : function(){
12737 return this.trans ? true : false;
12741 * Abort the current server request.
12743 abort : function(){
12744 if(this.isLoading()){
12745 this.destroyTrans(this.trans);
12750 destroyTrans : function(trans, isLoaded){
12751 this.head.removeChild(document.getElementById(trans.scriptId));
12752 clearTimeout(trans.timeoutId);
12754 window[trans.cb] = undefined;
12756 delete window[trans.cb];
12759 // if hasn't been loaded, wait for load to remove it to prevent script error
12760 window[trans.cb] = function(){
12761 window[trans.cb] = undefined;
12763 delete window[trans.cb];
12770 handleResponse : function(o, trans){
12771 this.trans = false;
12772 this.destroyTrans(trans, true);
12775 result = trans.reader.readRecords(o);
12777 this.fireEvent("loadexception", this, o, trans.arg, e);
12778 trans.callback.call(trans.scope||window, null, trans.arg, false);
12781 this.fireEvent("load", this, o, trans.arg);
12782 trans.callback.call(trans.scope||window, result, trans.arg, true);
12786 handleFailure : function(trans){
12787 this.trans = false;
12788 this.destroyTrans(trans, false);
12789 this.fireEvent("loadexception", this, null, trans.arg);
12790 trans.callback.call(trans.scope||window, null, trans.arg, false);
12794 * Ext JS Library 1.1.1
12795 * Copyright(c) 2006-2007, Ext JS, LLC.
12797 * Originally Released Under LGPL - original licence link has changed is not relivant.
12800 * <script type="text/javascript">
12804 * @class Roo.data.JsonReader
12805 * @extends Roo.data.DataReader
12806 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12807 * based on mappings in a provided Roo.data.Record constructor.
12809 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12810 * in the reply previously.
12815 var RecordDef = Roo.data.Record.create([
12816 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12817 {name: 'occupation'} // This field will use "occupation" as the mapping.
12819 var myReader = new Roo.data.JsonReader({
12820 totalProperty: "results", // The property which contains the total dataset size (optional)
12821 root: "rows", // The property which contains an Array of row objects
12822 id: "id" // The property within each row object that provides an ID for the record (optional)
12826 * This would consume a JSON file like this:
12828 { 'results': 2, 'rows': [
12829 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12830 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12833 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12834 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12835 * paged from the remote server.
12836 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12837 * @cfg {String} root name of the property which contains the Array of row objects.
12838 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12839 * @cfg {Array} fields Array of field definition objects
12841 * Create a new JsonReader
12842 * @param {Object} meta Metadata configuration options
12843 * @param {Object} recordType Either an Array of field definition objects,
12844 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12846 Roo.data.JsonReader = function(meta, recordType){
12849 // set some defaults:
12850 Roo.applyIf(meta, {
12851 totalProperty: 'total',
12852 successProperty : 'success',
12857 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12859 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12862 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12863 * Used by Store query builder to append _requestMeta to params.
12866 metaFromRemote : false,
12868 * This method is only used by a DataProxy which has retrieved data from a remote server.
12869 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12870 * @return {Object} data A data block which is used by an Roo.data.Store object as
12871 * a cache of Roo.data.Records.
12873 read : function(response){
12874 var json = response.responseText;
12876 var o = /* eval:var:o */ eval("("+json+")");
12878 throw {message: "JsonReader.read: Json object not found"};
12884 this.metaFromRemote = true;
12885 this.meta = o.metaData;
12886 this.recordType = Roo.data.Record.create(o.metaData.fields);
12887 this.onMetaChange(this.meta, this.recordType, o);
12889 return this.readRecords(o);
12892 // private function a store will implement
12893 onMetaChange : function(meta, recordType, o){
12900 simpleAccess: function(obj, subsc) {
12907 getJsonAccessor: function(){
12909 return function(expr) {
12911 return(re.test(expr))
12912 ? new Function("obj", "return obj." + expr)
12917 return Roo.emptyFn;
12922 * Create a data block containing Roo.data.Records from an XML document.
12923 * @param {Object} o An object which contains an Array of row objects in the property specified
12924 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12925 * which contains the total size of the dataset.
12926 * @return {Object} data A data block which is used by an Roo.data.Store object as
12927 * a cache of Roo.data.Records.
12929 readRecords : function(o){
12931 * After any data loads, the raw JSON data is available for further custom processing.
12935 var s = this.meta, Record = this.recordType,
12936 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12938 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12940 if(s.totalProperty) {
12941 this.getTotal = this.getJsonAccessor(s.totalProperty);
12943 if(s.successProperty) {
12944 this.getSuccess = this.getJsonAccessor(s.successProperty);
12946 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12948 var g = this.getJsonAccessor(s.id);
12949 this.getId = function(rec) {
12951 return (r === undefined || r === "") ? null : r;
12954 this.getId = function(){return null;};
12957 for(var jj = 0; jj < fl; jj++){
12959 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12960 this.ef[jj] = this.getJsonAccessor(map);
12964 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12965 if(s.totalProperty){
12966 var vt = parseInt(this.getTotal(o), 10);
12971 if(s.successProperty){
12972 var vs = this.getSuccess(o);
12973 if(vs === false || vs === 'false'){
12978 for(var i = 0; i < c; i++){
12981 var id = this.getId(n);
12982 for(var j = 0; j < fl; j++){
12984 var v = this.ef[j](n);
12986 Roo.log('missing convert for ' + f.name);
12990 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12992 var record = new Record(values, id);
12994 records[i] = record;
13000 totalRecords : totalRecords
13005 * Ext JS Library 1.1.1
13006 * Copyright(c) 2006-2007, Ext JS, LLC.
13008 * Originally Released Under LGPL - original licence link has changed is not relivant.
13011 * <script type="text/javascript">
13015 * @class Roo.data.ArrayReader
13016 * @extends Roo.data.DataReader
13017 * Data reader class to create an Array of Roo.data.Record objects from an Array.
13018 * Each element of that Array represents a row of data fields. The
13019 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
13020 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
13024 var RecordDef = Roo.data.Record.create([
13025 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
13026 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
13028 var myReader = new Roo.data.ArrayReader({
13029 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
13033 * This would consume an Array like this:
13035 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13039 * Create a new JsonReader
13040 * @param {Object} meta Metadata configuration options.
13041 * @param {Object|Array} recordType Either an Array of field definition objects
13043 * @cfg {Array} fields Array of field definition objects
13044 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
13045 * as specified to {@link Roo.data.Record#create},
13046 * or an {@link Roo.data.Record} object
13049 * created using {@link Roo.data.Record#create}.
13051 Roo.data.ArrayReader = function(meta, recordType){
13054 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13057 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13059 * Create a data block containing Roo.data.Records from an XML document.
13060 * @param {Object} o An Array of row objects which represents the dataset.
13061 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
13062 * a cache of Roo.data.Records.
13064 readRecords : function(o){
13065 var sid = this.meta ? this.meta.id : null;
13066 var recordType = this.recordType, fields = recordType.prototype.fields;
13069 for(var i = 0; i < root.length; i++){
13072 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13073 for(var j = 0, jlen = fields.length; j < jlen; j++){
13074 var f = fields.items[j];
13075 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13076 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13078 values[f.name] = v;
13080 var record = new recordType(values, id);
13082 records[records.length] = record;
13086 totalRecords : records.length
13095 * @class Roo.bootstrap.ComboBox
13096 * @extends Roo.bootstrap.TriggerField
13097 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13098 * @cfg {Boolean} append (true|false) default false
13099 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13100 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13101 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13102 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13103 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13104 * @cfg {Boolean} animate default true
13105 * @cfg {Boolean} emptyResultText only for touch device
13106 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13107 * @cfg {String} emptyTitle default ''
13109 * Create a new ComboBox.
13110 * @param {Object} config Configuration options
13112 Roo.bootstrap.ComboBox = function(config){
13113 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13117 * Fires when the dropdown list is expanded
13118 * @param {Roo.bootstrap.ComboBox} combo This combo box
13123 * Fires when the dropdown list is collapsed
13124 * @param {Roo.bootstrap.ComboBox} combo This combo box
13128 * @event beforeselect
13129 * Fires before a list item is selected. Return false to cancel the selection.
13130 * @param {Roo.bootstrap.ComboBox} combo This combo box
13131 * @param {Roo.data.Record} record The data record returned from the underlying store
13132 * @param {Number} index The index of the selected item in the dropdown list
13134 'beforeselect' : true,
13137 * Fires when a list item is selected
13138 * @param {Roo.bootstrap.ComboBox} combo This combo box
13139 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13140 * @param {Number} index The index of the selected item in the dropdown list
13144 * @event beforequery
13145 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13146 * The event object passed has these properties:
13147 * @param {Roo.bootstrap.ComboBox} combo This combo box
13148 * @param {String} query The query
13149 * @param {Boolean} forceAll true to force "all" query
13150 * @param {Boolean} cancel true to cancel the query
13151 * @param {Object} e The query event object
13153 'beforequery': true,
13156 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13157 * @param {Roo.bootstrap.ComboBox} combo This combo box
13162 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13163 * @param {Roo.bootstrap.ComboBox} combo This combo box
13164 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13169 * Fires when the remove value from the combobox array
13170 * @param {Roo.bootstrap.ComboBox} combo This combo box
13174 * @event afterremove
13175 * Fires when the remove value from the combobox array
13176 * @param {Roo.bootstrap.ComboBox} combo This combo box
13178 'afterremove' : true,
13180 * @event specialfilter
13181 * Fires when specialfilter
13182 * @param {Roo.bootstrap.ComboBox} combo This combo box
13184 'specialfilter' : true,
13187 * Fires when tick the element
13188 * @param {Roo.bootstrap.ComboBox} combo This combo box
13192 * @event touchviewdisplay
13193 * Fires when touch view require special display (default is using displayField)
13194 * @param {Roo.bootstrap.ComboBox} combo This combo box
13195 * @param {Object} cfg set html .
13197 'touchviewdisplay' : true
13202 this.tickItems = [];
13204 this.selectedIndex = -1;
13205 if(this.mode == 'local'){
13206 if(config.queryDelay === undefined){
13207 this.queryDelay = 10;
13209 if(config.minChars === undefined){
13215 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13218 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13219 * rendering into an Roo.Editor, defaults to false)
13222 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13223 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13226 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13229 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13230 * the dropdown list (defaults to undefined, with no header element)
13234 * @cfg {String/Roo.Template} tpl The template to use to render the output
13238 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13240 listWidth: undefined,
13242 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13243 * mode = 'remote' or 'text' if mode = 'local')
13245 displayField: undefined,
13248 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13249 * mode = 'remote' or 'value' if mode = 'local').
13250 * Note: use of a valueField requires the user make a selection
13251 * in order for a value to be mapped.
13253 valueField: undefined,
13255 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13260 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13261 * field's data value (defaults to the underlying DOM element's name)
13263 hiddenName: undefined,
13265 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13269 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13271 selectedClass: 'active',
13274 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13278 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13279 * anchor positions (defaults to 'tl-bl')
13281 listAlign: 'tl-bl?',
13283 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13287 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13288 * query specified by the allQuery config option (defaults to 'query')
13290 triggerAction: 'query',
13292 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13293 * (defaults to 4, does not apply if editable = false)
13297 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13298 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13302 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13303 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13307 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13308 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13312 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13313 * when editable = true (defaults to false)
13315 selectOnFocus:false,
13317 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13319 queryParam: 'query',
13321 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13322 * when mode = 'remote' (defaults to 'Loading...')
13324 loadingText: 'Loading...',
13326 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13330 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13334 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13335 * traditional select (defaults to true)
13339 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13343 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13347 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13348 * listWidth has a higher value)
13352 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13353 * allow the user to set arbitrary text into the field (defaults to false)
13355 forceSelection:false,
13357 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13358 * if typeAhead = true (defaults to 250)
13360 typeAheadDelay : 250,
13362 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13363 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13365 valueNotFoundText : undefined,
13367 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13369 blockFocus : false,
13372 * @cfg {Boolean} disableClear Disable showing of clear button.
13374 disableClear : false,
13376 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13378 alwaysQuery : false,
13381 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13386 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13388 invalidClass : "has-warning",
13391 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13393 validClass : "has-success",
13396 * @cfg {Boolean} specialFilter (true|false) special filter default false
13398 specialFilter : false,
13401 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13403 mobileTouchView : true,
13406 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13408 useNativeIOS : false,
13411 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13413 mobile_restrict_height : false,
13415 ios_options : false,
13427 btnPosition : 'right',
13428 triggerList : true,
13429 showToggleBtn : true,
13431 emptyResultText: 'Empty',
13432 triggerText : 'Select',
13435 // element that contains real text value.. (when hidden is used..)
13437 getAutoCreate : function()
13442 * Render classic select for iso
13445 if(Roo.isIOS && this.useNativeIOS){
13446 cfg = this.getAutoCreateNativeIOS();
13454 if(Roo.isTouch && this.mobileTouchView){
13455 cfg = this.getAutoCreateTouchView();
13462 if(!this.tickable){
13463 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13468 * ComboBox with tickable selections
13471 var align = this.labelAlign || this.parentLabelAlign();
13474 cls : 'form-group roo-combobox-tickable' //input-group
13477 var btn_text_select = '';
13478 var btn_text_done = '';
13479 var btn_text_cancel = '';
13481 if (this.btn_text_show) {
13482 btn_text_select = 'Select';
13483 btn_text_done = 'Done';
13484 btn_text_cancel = 'Cancel';
13489 cls : 'tickable-buttons',
13494 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13495 //html : this.triggerText
13496 html: btn_text_select
13502 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13504 html: btn_text_done
13510 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13512 html: btn_text_cancel
13518 buttons.cn.unshift({
13520 cls: 'roo-select2-search-field-input'
13526 Roo.each(buttons.cn, function(c){
13528 c.cls += ' btn-' + _this.size;
13531 if (_this.disabled) {
13538 style : 'display: contents',
13543 cls: 'form-hidden-field'
13547 cls: 'roo-select2-choices',
13551 cls: 'roo-select2-search-field',
13562 cls: 'roo-select2-container input-group roo-select2-container-multi',
13568 // cls: 'typeahead typeahead-long dropdown-menu',
13569 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13574 if(this.hasFeedback && !this.allowBlank){
13578 cls: 'glyphicon form-control-feedback'
13581 combobox.cn.push(feedback);
13586 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13587 tooltip : 'This field is required'
13589 if (Roo.bootstrap.version == 4) {
13592 style : 'display:none'
13595 if (align ==='left' && this.fieldLabel.length) {
13597 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13604 cls : 'control-label col-form-label',
13605 html : this.fieldLabel
13617 var labelCfg = cfg.cn[1];
13618 var contentCfg = cfg.cn[2];
13621 if(this.indicatorpos == 'right'){
13627 cls : 'control-label col-form-label',
13631 html : this.fieldLabel
13647 labelCfg = cfg.cn[0];
13648 contentCfg = cfg.cn[1];
13652 if(this.labelWidth > 12){
13653 labelCfg.style = "width: " + this.labelWidth + 'px';
13656 if(this.labelWidth < 13 && this.labelmd == 0){
13657 this.labelmd = this.labelWidth;
13660 if(this.labellg > 0){
13661 labelCfg.cls += ' col-lg-' + this.labellg;
13662 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13665 if(this.labelmd > 0){
13666 labelCfg.cls += ' col-md-' + this.labelmd;
13667 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13670 if(this.labelsm > 0){
13671 labelCfg.cls += ' col-sm-' + this.labelsm;
13672 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13675 if(this.labelxs > 0){
13676 labelCfg.cls += ' col-xs-' + this.labelxs;
13677 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13681 } else if ( this.fieldLabel.length) {
13682 // Roo.log(" label");
13687 //cls : 'input-group-addon',
13688 html : this.fieldLabel
13693 if(this.indicatorpos == 'right'){
13697 //cls : 'input-group-addon',
13698 html : this.fieldLabel
13708 // Roo.log(" no label && no align");
13715 ['xs','sm','md','lg'].map(function(size){
13716 if (settings[size]) {
13717 cfg.cls += ' col-' + size + '-' + settings[size];
13725 _initEventsCalled : false,
13728 initEvents: function()
13730 if (this._initEventsCalled) { // as we call render... prevent looping...
13733 this._initEventsCalled = true;
13736 throw "can not find store for combo";
13739 this.indicator = this.indicatorEl();
13741 this.store = Roo.factory(this.store, Roo.data);
13742 this.store.parent = this;
13744 // if we are building from html. then this element is so complex, that we can not really
13745 // use the rendered HTML.
13746 // so we have to trash and replace the previous code.
13747 if (Roo.XComponent.build_from_html) {
13748 // remove this element....
13749 var e = this.el.dom, k=0;
13750 while (e ) { e = e.previousSibling; ++k;}
13755 this.rendered = false;
13757 this.render(this.parent().getChildContainer(true), k);
13760 if(Roo.isIOS && this.useNativeIOS){
13761 this.initIOSView();
13769 if(Roo.isTouch && this.mobileTouchView){
13770 this.initTouchView();
13775 this.initTickableEvents();
13779 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13781 if(this.hiddenName){
13783 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13785 this.hiddenField.dom.value =
13786 this.hiddenValue !== undefined ? this.hiddenValue :
13787 this.value !== undefined ? this.value : '';
13789 // prevent input submission
13790 this.el.dom.removeAttribute('name');
13791 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13796 // this.el.dom.setAttribute('autocomplete', 'off');
13799 var cls = 'x-combo-list';
13801 //this.list = new Roo.Layer({
13802 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13808 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13809 _this.list.setWidth(lw);
13812 this.list.on('mouseover', this.onViewOver, this);
13813 this.list.on('mousemove', this.onViewMove, this);
13814 this.list.on('scroll', this.onViewScroll, this);
13817 this.list.swallowEvent('mousewheel');
13818 this.assetHeight = 0;
13821 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13822 this.assetHeight += this.header.getHeight();
13825 this.innerList = this.list.createChild({cls:cls+'-inner'});
13826 this.innerList.on('mouseover', this.onViewOver, this);
13827 this.innerList.on('mousemove', this.onViewMove, this);
13828 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13830 if(this.allowBlank && !this.pageSize && !this.disableClear){
13831 this.footer = this.list.createChild({cls:cls+'-ft'});
13832 this.pageTb = new Roo.Toolbar(this.footer);
13836 this.footer = this.list.createChild({cls:cls+'-ft'});
13837 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13838 {pageSize: this.pageSize});
13842 if (this.pageTb && this.allowBlank && !this.disableClear) {
13844 this.pageTb.add(new Roo.Toolbar.Fill(), {
13845 cls: 'x-btn-icon x-btn-clear',
13847 handler: function()
13850 _this.clearValue();
13851 _this.onSelect(false, -1);
13856 this.assetHeight += this.footer.getHeight();
13861 this.tpl = Roo.bootstrap.version == 4 ?
13862 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13863 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13866 this.view = new Roo.View(this.list, this.tpl, {
13867 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13869 //this.view.wrapEl.setDisplayed(false);
13870 this.view.on('click', this.onViewClick, this);
13873 this.store.on('beforeload', this.onBeforeLoad, this);
13874 this.store.on('load', this.onLoad, this);
13875 this.store.on('loadexception', this.onLoadException, this);
13877 if(this.resizable){
13878 this.resizer = new Roo.Resizable(this.list, {
13879 pinned:true, handles:'se'
13881 this.resizer.on('resize', function(r, w, h){
13882 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13883 this.listWidth = w;
13884 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13885 this.restrictHeight();
13887 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13890 if(!this.editable){
13891 this.editable = true;
13892 this.setEditable(false);
13897 if (typeof(this.events.add.listeners) != 'undefined') {
13899 this.addicon = this.wrap.createChild(
13900 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13902 this.addicon.on('click', function(e) {
13903 this.fireEvent('add', this);
13906 if (typeof(this.events.edit.listeners) != 'undefined') {
13908 this.editicon = this.wrap.createChild(
13909 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13910 if (this.addicon) {
13911 this.editicon.setStyle('margin-left', '40px');
13913 this.editicon.on('click', function(e) {
13915 // we fire even if inothing is selected..
13916 this.fireEvent('edit', this, this.lastData );
13922 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13923 "up" : function(e){
13924 this.inKeyMode = true;
13928 "down" : function(e){
13929 if(!this.isExpanded()){
13930 this.onTriggerClick();
13932 this.inKeyMode = true;
13937 "enter" : function(e){
13938 // this.onViewClick();
13942 if(this.fireEvent("specialkey", this, e)){
13943 this.onViewClick(false);
13949 "esc" : function(e){
13953 "tab" : function(e){
13956 if(this.fireEvent("specialkey", this, e)){
13957 this.onViewClick(false);
13965 doRelay : function(foo, bar, hname){
13966 if(hname == 'down' || this.scope.isExpanded()){
13967 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13976 this.queryDelay = Math.max(this.queryDelay || 10,
13977 this.mode == 'local' ? 10 : 250);
13980 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13982 if(this.typeAhead){
13983 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13985 if(this.editable !== false){
13986 this.inputEl().on("keyup", this.onKeyUp, this);
13988 if(this.forceSelection){
13989 this.inputEl().on('blur', this.doForce, this);
13993 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13994 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13998 initTickableEvents: function()
14002 if(this.hiddenName){
14004 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14006 this.hiddenField.dom.value =
14007 this.hiddenValue !== undefined ? this.hiddenValue :
14008 this.value !== undefined ? this.value : '';
14010 // prevent input submission
14011 this.el.dom.removeAttribute('name');
14012 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14017 // this.list = this.el.select('ul.dropdown-menu',true).first();
14019 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14020 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14021 if(this.triggerList){
14022 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
14025 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
14026 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
14028 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
14029 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
14031 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
14032 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
14034 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
14035 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
14036 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
14039 this.cancelBtn.hide();
14044 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14045 _this.list.setWidth(lw);
14048 this.list.on('mouseover', this.onViewOver, this);
14049 this.list.on('mousemove', this.onViewMove, this);
14051 this.list.on('scroll', this.onViewScroll, this);
14054 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14055 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14058 this.view = new Roo.View(this.list, this.tpl, {
14063 selectedClass: this.selectedClass
14066 //this.view.wrapEl.setDisplayed(false);
14067 this.view.on('click', this.onViewClick, this);
14071 this.store.on('beforeload', this.onBeforeLoad, this);
14072 this.store.on('load', this.onLoad, this);
14073 this.store.on('loadexception', this.onLoadException, this);
14076 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14077 "up" : function(e){
14078 this.inKeyMode = true;
14082 "down" : function(e){
14083 this.inKeyMode = true;
14087 "enter" : function(e){
14088 if(this.fireEvent("specialkey", this, e)){
14089 this.onViewClick(false);
14095 "esc" : function(e){
14096 this.onTickableFooterButtonClick(e, false, false);
14099 "tab" : function(e){
14100 this.fireEvent("specialkey", this, e);
14102 this.onTickableFooterButtonClick(e, false, false);
14109 doRelay : function(e, fn, key){
14110 if(this.scope.isExpanded()){
14111 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14120 this.queryDelay = Math.max(this.queryDelay || 10,
14121 this.mode == 'local' ? 10 : 250);
14124 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14126 if(this.typeAhead){
14127 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14130 if(this.editable !== false){
14131 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14134 this.indicator = this.indicatorEl();
14136 if(this.indicator){
14137 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14138 this.indicator.hide();
14143 onDestroy : function(){
14145 this.view.setStore(null);
14146 this.view.el.removeAllListeners();
14147 this.view.el.remove();
14148 this.view.purgeListeners();
14151 this.list.dom.innerHTML = '';
14155 this.store.un('beforeload', this.onBeforeLoad, this);
14156 this.store.un('load', this.onLoad, this);
14157 this.store.un('loadexception', this.onLoadException, this);
14159 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14163 fireKey : function(e){
14164 if(e.isNavKeyPress() && !this.list.isVisible()){
14165 this.fireEvent("specialkey", this, e);
14170 onResize: function(w, h){
14171 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14173 // if(typeof w != 'number'){
14174 // // we do not handle it!?!?
14177 // var tw = this.trigger.getWidth();
14178 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14179 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14181 // this.inputEl().setWidth( this.adjustWidth('input', x));
14183 // //this.trigger.setStyle('left', x+'px');
14185 // if(this.list && this.listWidth === undefined){
14186 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14187 // this.list.setWidth(lw);
14188 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14196 * Allow or prevent the user from directly editing the field text. If false is passed,
14197 * the user will only be able to select from the items defined in the dropdown list. This method
14198 * is the runtime equivalent of setting the 'editable' config option at config time.
14199 * @param {Boolean} value True to allow the user to directly edit the field text
14201 setEditable : function(value){
14202 if(value == this.editable){
14205 this.editable = value;
14207 this.inputEl().dom.setAttribute('readOnly', true);
14208 this.inputEl().on('mousedown', this.onTriggerClick, this);
14209 this.inputEl().addClass('x-combo-noedit');
14211 this.inputEl().dom.setAttribute('readOnly', false);
14212 this.inputEl().un('mousedown', this.onTriggerClick, this);
14213 this.inputEl().removeClass('x-combo-noedit');
14219 onBeforeLoad : function(combo,opts){
14220 if(!this.hasFocus){
14224 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14226 this.restrictHeight();
14227 this.selectedIndex = -1;
14231 onLoad : function(){
14233 this.hasQuery = false;
14235 if(!this.hasFocus){
14239 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14240 this.loading.hide();
14243 if(this.store.getCount() > 0){
14246 this.restrictHeight();
14247 if(this.lastQuery == this.allQuery){
14248 if(this.editable && !this.tickable){
14249 this.inputEl().dom.select();
14253 !this.selectByValue(this.value, true) &&
14256 !this.store.lastOptions ||
14257 typeof(this.store.lastOptions.add) == 'undefined' ||
14258 this.store.lastOptions.add != true
14261 this.select(0, true);
14264 if(this.autoFocus){
14267 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14268 this.taTask.delay(this.typeAheadDelay);
14272 this.onEmptyResults();
14278 onLoadException : function()
14280 this.hasQuery = false;
14282 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14283 this.loading.hide();
14286 if(this.tickable && this.editable){
14291 // only causes errors at present
14292 //Roo.log(this.store.reader.jsonData);
14293 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14295 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14301 onTypeAhead : function(){
14302 if(this.store.getCount() > 0){
14303 var r = this.store.getAt(0);
14304 var newValue = r.data[this.displayField];
14305 var len = newValue.length;
14306 var selStart = this.getRawValue().length;
14308 if(selStart != len){
14309 this.setRawValue(newValue);
14310 this.selectText(selStart, newValue.length);
14316 onSelect : function(record, index){
14318 if(this.fireEvent('beforeselect', this, record, index) !== false){
14320 this.setFromData(index > -1 ? record.data : false);
14323 this.fireEvent('select', this, record, index);
14328 * Returns the currently selected field value or empty string if no value is set.
14329 * @return {String} value The selected value
14331 getValue : function()
14333 if(Roo.isIOS && this.useNativeIOS){
14334 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14338 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14341 if(this.valueField){
14342 return typeof this.value != 'undefined' ? this.value : '';
14344 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14348 getRawValue : function()
14350 if(Roo.isIOS && this.useNativeIOS){
14351 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14354 var v = this.inputEl().getValue();
14360 * Clears any text/value currently set in the field
14362 clearValue : function(){
14364 if(this.hiddenField){
14365 this.hiddenField.dom.value = '';
14368 this.setRawValue('');
14369 this.lastSelectionText = '';
14370 this.lastData = false;
14372 var close = this.closeTriggerEl();
14383 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14384 * will be displayed in the field. If the value does not match the data value of an existing item,
14385 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14386 * Otherwise the field will be blank (although the value will still be set).
14387 * @param {String} value The value to match
14389 setValue : function(v)
14391 if(Roo.isIOS && this.useNativeIOS){
14392 this.setIOSValue(v);
14402 if(this.valueField){
14403 var r = this.findRecord(this.valueField, v);
14405 text = r.data[this.displayField];
14406 }else if(this.valueNotFoundText !== undefined){
14407 text = this.valueNotFoundText;
14410 this.lastSelectionText = text;
14411 if(this.hiddenField){
14412 this.hiddenField.dom.value = v;
14414 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14417 var close = this.closeTriggerEl();
14420 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14426 * @property {Object} the last set data for the element
14431 * Sets the value of the field based on a object which is related to the record format for the store.
14432 * @param {Object} value the value to set as. or false on reset?
14434 setFromData : function(o){
14441 var dv = ''; // display value
14442 var vv = ''; // value value..
14444 if (this.displayField) {
14445 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14447 // this is an error condition!!!
14448 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14451 if(this.valueField){
14452 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14455 var close = this.closeTriggerEl();
14458 if(dv.length || vv * 1 > 0){
14460 this.blockFocus=true;
14466 if(this.hiddenField){
14467 this.hiddenField.dom.value = vv;
14469 this.lastSelectionText = dv;
14470 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14474 // no hidden field.. - we store the value in 'value', but still display
14475 // display field!!!!
14476 this.lastSelectionText = dv;
14477 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14484 reset : function(){
14485 // overridden so that last data is reset..
14492 this.setValue(this.originalValue);
14493 //this.clearInvalid();
14494 this.lastData = false;
14496 this.view.clearSelections();
14502 findRecord : function(prop, value){
14504 if(this.store.getCount() > 0){
14505 this.store.each(function(r){
14506 if(r.data[prop] == value){
14516 getName: function()
14518 // returns hidden if it's set..
14519 if (!this.rendered) {return ''};
14520 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14524 onViewMove : function(e, t){
14525 this.inKeyMode = false;
14529 onViewOver : function(e, t){
14530 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14533 var item = this.view.findItemFromChild(t);
14536 var index = this.view.indexOf(item);
14537 this.select(index, false);
14542 onViewClick : function(view, doFocus, el, e)
14544 var index = this.view.getSelectedIndexes()[0];
14546 var r = this.store.getAt(index);
14550 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14557 Roo.each(this.tickItems, function(v,k){
14559 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14561 _this.tickItems.splice(k, 1);
14563 if(typeof(e) == 'undefined' && view == false){
14564 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14576 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14577 this.tickItems.push(r.data);
14580 if(typeof(e) == 'undefined' && view == false){
14581 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14588 this.onSelect(r, index);
14590 if(doFocus !== false && !this.blockFocus){
14591 this.inputEl().focus();
14596 restrictHeight : function(){
14597 //this.innerList.dom.style.height = '';
14598 //var inner = this.innerList.dom;
14599 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14600 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14601 //this.list.beginUpdate();
14602 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14603 this.list.alignTo(this.inputEl(), this.listAlign);
14604 this.list.alignTo(this.inputEl(), this.listAlign);
14605 //this.list.endUpdate();
14609 onEmptyResults : function(){
14611 if(this.tickable && this.editable){
14612 this.hasFocus = false;
14613 this.restrictHeight();
14621 * Returns true if the dropdown list is expanded, else false.
14623 isExpanded : function(){
14624 return this.list.isVisible();
14628 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14629 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14630 * @param {String} value The data value of the item to select
14631 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14632 * selected item if it is not currently in view (defaults to true)
14633 * @return {Boolean} True if the value matched an item in the list, else false
14635 selectByValue : function(v, scrollIntoView){
14636 if(v !== undefined && v !== null){
14637 var r = this.findRecord(this.valueField || this.displayField, v);
14639 this.select(this.store.indexOf(r), scrollIntoView);
14647 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14648 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14649 * @param {Number} index The zero-based index of the list item to select
14650 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14651 * selected item if it is not currently in view (defaults to true)
14653 select : function(index, scrollIntoView){
14654 this.selectedIndex = index;
14655 this.view.select(index);
14656 if(scrollIntoView !== false){
14657 var el = this.view.getNode(index);
14659 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14662 this.list.scrollChildIntoView(el, false);
14668 selectNext : function(){
14669 var ct = this.store.getCount();
14671 if(this.selectedIndex == -1){
14673 }else if(this.selectedIndex < ct-1){
14674 this.select(this.selectedIndex+1);
14680 selectPrev : function(){
14681 var ct = this.store.getCount();
14683 if(this.selectedIndex == -1){
14685 }else if(this.selectedIndex != 0){
14686 this.select(this.selectedIndex-1);
14692 onKeyUp : function(e){
14693 if(this.editable !== false && !e.isSpecialKey()){
14694 this.lastKey = e.getKey();
14695 this.dqTask.delay(this.queryDelay);
14700 validateBlur : function(){
14701 return !this.list || !this.list.isVisible();
14705 initQuery : function(){
14707 var v = this.getRawValue();
14709 if(this.tickable && this.editable){
14710 v = this.tickableInputEl().getValue();
14717 doForce : function(){
14718 if(this.inputEl().dom.value.length > 0){
14719 this.inputEl().dom.value =
14720 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14726 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14727 * query allowing the query action to be canceled if needed.
14728 * @param {String} query The SQL query to execute
14729 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14730 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14731 * saved in the current store (defaults to false)
14733 doQuery : function(q, forceAll){
14735 if(q === undefined || q === null){
14740 forceAll: forceAll,
14744 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14749 forceAll = qe.forceAll;
14750 if(forceAll === true || (q.length >= this.minChars)){
14752 this.hasQuery = true;
14754 if(this.lastQuery != q || this.alwaysQuery){
14755 this.lastQuery = q;
14756 if(this.mode == 'local'){
14757 this.selectedIndex = -1;
14759 this.store.clearFilter();
14762 if(this.specialFilter){
14763 this.fireEvent('specialfilter', this);
14768 this.store.filter(this.displayField, q);
14771 this.store.fireEvent("datachanged", this.store);
14778 this.store.baseParams[this.queryParam] = q;
14780 var options = {params : this.getParams(q)};
14783 options.add = true;
14784 options.params.start = this.page * this.pageSize;
14787 this.store.load(options);
14790 * this code will make the page width larger, at the beginning, the list not align correctly,
14791 * we should expand the list on onLoad
14792 * so command out it
14797 this.selectedIndex = -1;
14802 this.loadNext = false;
14806 getParams : function(q){
14808 //p[this.queryParam] = q;
14812 p.limit = this.pageSize;
14818 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14820 collapse : function(){
14821 if(!this.isExpanded()){
14827 this.hasFocus = false;
14831 this.cancelBtn.hide();
14832 this.trigger.show();
14835 this.tickableInputEl().dom.value = '';
14836 this.tickableInputEl().blur();
14841 Roo.get(document).un('mousedown', this.collapseIf, this);
14842 Roo.get(document).un('mousewheel', this.collapseIf, this);
14843 if (!this.editable) {
14844 Roo.get(document).un('keydown', this.listKeyPress, this);
14846 this.fireEvent('collapse', this);
14852 collapseIf : function(e){
14853 var in_combo = e.within(this.el);
14854 var in_list = e.within(this.list);
14855 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14857 if (in_combo || in_list || is_list) {
14858 //e.stopPropagation();
14863 this.onTickableFooterButtonClick(e, false, false);
14871 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14873 expand : function(){
14875 if(this.isExpanded() || !this.hasFocus){
14879 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14880 this.list.setWidth(lw);
14886 this.restrictHeight();
14890 this.tickItems = Roo.apply([], this.item);
14893 this.cancelBtn.show();
14894 this.trigger.hide();
14897 this.tickableInputEl().focus();
14902 Roo.get(document).on('mousedown', this.collapseIf, this);
14903 Roo.get(document).on('mousewheel', this.collapseIf, this);
14904 if (!this.editable) {
14905 Roo.get(document).on('keydown', this.listKeyPress, this);
14908 this.fireEvent('expand', this);
14912 // Implements the default empty TriggerField.onTriggerClick function
14913 onTriggerClick : function(e)
14915 Roo.log('trigger click');
14917 if(this.disabled || !this.triggerList){
14922 this.loadNext = false;
14924 if(this.isExpanded()){
14926 if (!this.blockFocus) {
14927 this.inputEl().focus();
14931 this.hasFocus = true;
14932 if(this.triggerAction == 'all') {
14933 this.doQuery(this.allQuery, true);
14935 this.doQuery(this.getRawValue());
14937 if (!this.blockFocus) {
14938 this.inputEl().focus();
14943 onTickableTriggerClick : function(e)
14950 this.loadNext = false;
14951 this.hasFocus = true;
14953 if(this.triggerAction == 'all') {
14954 this.doQuery(this.allQuery, true);
14956 this.doQuery(this.getRawValue());
14960 onSearchFieldClick : function(e)
14962 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14963 this.onTickableFooterButtonClick(e, false, false);
14967 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14972 this.loadNext = false;
14973 this.hasFocus = true;
14975 if(this.triggerAction == 'all') {
14976 this.doQuery(this.allQuery, true);
14978 this.doQuery(this.getRawValue());
14982 listKeyPress : function(e)
14984 //Roo.log('listkeypress');
14985 // scroll to first matching element based on key pres..
14986 if (e.isSpecialKey()) {
14989 var k = String.fromCharCode(e.getKey()).toUpperCase();
14992 var csel = this.view.getSelectedNodes();
14993 var cselitem = false;
14995 var ix = this.view.indexOf(csel[0]);
14996 cselitem = this.store.getAt(ix);
14997 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
15003 this.store.each(function(v) {
15005 // start at existing selection.
15006 if (cselitem.id == v.id) {
15012 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
15013 match = this.store.indexOf(v);
15019 if (match === false) {
15020 return true; // no more action?
15023 this.view.select(match);
15024 var sn = Roo.get(this.view.getSelectedNodes()[0]);
15025 sn.scrollIntoView(sn.dom.parentNode, false);
15028 onViewScroll : function(e, t){
15030 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){
15034 this.hasQuery = true;
15036 this.loading = this.list.select('.loading', true).first();
15038 if(this.loading === null){
15039 this.list.createChild({
15041 cls: 'loading roo-select2-more-results roo-select2-active',
15042 html: 'Loading more results...'
15045 this.loading = this.list.select('.loading', true).first();
15047 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15049 this.loading.hide();
15052 this.loading.show();
15057 this.loadNext = true;
15059 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15064 addItem : function(o)
15066 var dv = ''; // display value
15068 if (this.displayField) {
15069 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15071 // this is an error condition!!!
15072 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15079 var choice = this.choices.createChild({
15081 cls: 'roo-select2-search-choice',
15090 cls: 'roo-select2-search-choice-close fa fa-times',
15095 }, this.searchField);
15097 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15099 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15107 this.inputEl().dom.value = '';
15112 onRemoveItem : function(e, _self, o)
15114 e.preventDefault();
15116 this.lastItem = Roo.apply([], this.item);
15118 var index = this.item.indexOf(o.data) * 1;
15121 Roo.log('not this item?!');
15125 this.item.splice(index, 1);
15130 this.fireEvent('remove', this, e);
15136 syncValue : function()
15138 if(!this.item.length){
15145 Roo.each(this.item, function(i){
15146 if(_this.valueField){
15147 value.push(i[_this.valueField]);
15154 this.value = value.join(',');
15156 if(this.hiddenField){
15157 this.hiddenField.dom.value = this.value;
15160 this.store.fireEvent("datachanged", this.store);
15165 clearItem : function()
15167 if(!this.multiple){
15173 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15181 if(this.tickable && !Roo.isTouch){
15182 this.view.refresh();
15186 inputEl: function ()
15188 if(Roo.isIOS && this.useNativeIOS){
15189 return this.el.select('select.roo-ios-select', true).first();
15192 if(Roo.isTouch && this.mobileTouchView){
15193 return this.el.select('input.form-control',true).first();
15197 return this.searchField;
15200 return this.el.select('input.form-control',true).first();
15203 onTickableFooterButtonClick : function(e, btn, el)
15205 e.preventDefault();
15207 this.lastItem = Roo.apply([], this.item);
15209 if(btn && btn.name == 'cancel'){
15210 this.tickItems = Roo.apply([], this.item);
15219 Roo.each(this.tickItems, function(o){
15227 validate : function()
15229 if(this.getVisibilityEl().hasClass('hidden')){
15233 var v = this.getRawValue();
15236 v = this.getValue();
15239 if(this.disabled || this.allowBlank || v.length){
15244 this.markInvalid();
15248 tickableInputEl : function()
15250 if(!this.tickable || !this.editable){
15251 return this.inputEl();
15254 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15258 getAutoCreateTouchView : function()
15263 cls: 'form-group' //input-group
15269 type : this.inputType,
15270 cls : 'form-control x-combo-noedit',
15271 autocomplete: 'new-password',
15272 placeholder : this.placeholder || '',
15277 input.name = this.name;
15281 input.cls += ' input-' + this.size;
15284 if (this.disabled) {
15285 input.disabled = true;
15296 inputblock.cls += ' input-group';
15298 inputblock.cn.unshift({
15300 cls : 'input-group-addon input-group-prepend input-group-text',
15305 if(this.removable && !this.multiple){
15306 inputblock.cls += ' roo-removable';
15308 inputblock.cn.push({
15311 cls : 'roo-combo-removable-btn close'
15315 if(this.hasFeedback && !this.allowBlank){
15317 inputblock.cls += ' has-feedback';
15319 inputblock.cn.push({
15321 cls: 'glyphicon form-control-feedback'
15328 inputblock.cls += (this.before) ? '' : ' input-group';
15330 inputblock.cn.push({
15332 cls : 'input-group-addon input-group-append input-group-text',
15338 var ibwrap = inputblock;
15343 cls: 'roo-select2-choices',
15347 cls: 'roo-select2-search-field',
15360 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15365 cls: 'form-hidden-field'
15371 if(!this.multiple && this.showToggleBtn){
15378 if (this.caret != false) {
15381 cls: 'fa fa-' + this.caret
15388 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15393 cls: 'combobox-clear',
15407 combobox.cls += ' roo-select2-container-multi';
15410 var align = this.labelAlign || this.parentLabelAlign();
15412 if (align ==='left' && this.fieldLabel.length) {
15417 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15418 tooltip : 'This field is required'
15422 cls : 'control-label col-form-label',
15423 html : this.fieldLabel
15434 var labelCfg = cfg.cn[1];
15435 var contentCfg = cfg.cn[2];
15438 if(this.indicatorpos == 'right'){
15443 cls : 'control-label col-form-label',
15447 html : this.fieldLabel
15451 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15452 tooltip : 'This field is required'
15465 labelCfg = cfg.cn[0];
15466 contentCfg = cfg.cn[1];
15471 if(this.labelWidth > 12){
15472 labelCfg.style = "width: " + this.labelWidth + 'px';
15475 if(this.labelWidth < 13 && this.labelmd == 0){
15476 this.labelmd = this.labelWidth;
15479 if(this.labellg > 0){
15480 labelCfg.cls += ' col-lg-' + this.labellg;
15481 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15484 if(this.labelmd > 0){
15485 labelCfg.cls += ' col-md-' + this.labelmd;
15486 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15489 if(this.labelsm > 0){
15490 labelCfg.cls += ' col-sm-' + this.labelsm;
15491 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15494 if(this.labelxs > 0){
15495 labelCfg.cls += ' col-xs-' + this.labelxs;
15496 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15500 } else if ( this.fieldLabel.length) {
15504 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15505 tooltip : 'This field is required'
15509 cls : 'control-label',
15510 html : this.fieldLabel
15521 if(this.indicatorpos == 'right'){
15525 cls : 'control-label',
15526 html : this.fieldLabel,
15530 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15531 tooltip : 'This field is required'
15548 var settings = this;
15550 ['xs','sm','md','lg'].map(function(size){
15551 if (settings[size]) {
15552 cfg.cls += ' col-' + size + '-' + settings[size];
15559 initTouchView : function()
15561 this.renderTouchView();
15563 this.touchViewEl.on('scroll', function(){
15564 this.el.dom.scrollTop = 0;
15567 this.originalValue = this.getValue();
15569 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15571 this.inputEl().on("click", this.showTouchView, this);
15572 if (this.triggerEl) {
15573 this.triggerEl.on("click", this.showTouchView, this);
15577 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15578 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15580 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15582 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15583 this.store.on('load', this.onTouchViewLoad, this);
15584 this.store.on('loadexception', this.onTouchViewLoadException, this);
15586 if(this.hiddenName){
15588 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15590 this.hiddenField.dom.value =
15591 this.hiddenValue !== undefined ? this.hiddenValue :
15592 this.value !== undefined ? this.value : '';
15594 this.el.dom.removeAttribute('name');
15595 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15599 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15600 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15603 if(this.removable && !this.multiple){
15604 var close = this.closeTriggerEl();
15606 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15607 close.on('click', this.removeBtnClick, this, close);
15611 * fix the bug in Safari iOS8
15613 this.inputEl().on("focus", function(e){
15614 document.activeElement.blur();
15617 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15624 renderTouchView : function()
15626 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15627 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15629 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15630 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15632 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15633 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15634 this.touchViewBodyEl.setStyle('overflow', 'auto');
15636 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15637 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15639 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15640 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15644 showTouchView : function()
15650 this.touchViewHeaderEl.hide();
15652 if(this.modalTitle.length){
15653 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15654 this.touchViewHeaderEl.show();
15657 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15658 this.touchViewEl.show();
15660 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15662 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15663 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15665 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15667 if(this.modalTitle.length){
15668 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15671 this.touchViewBodyEl.setHeight(bodyHeight);
15675 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15677 this.touchViewEl.addClass('in');
15680 if(this._touchViewMask){
15681 Roo.get(document.body).addClass("x-body-masked");
15682 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15683 this._touchViewMask.setStyle('z-index', 10000);
15684 this._touchViewMask.addClass('show');
15687 this.doTouchViewQuery();
15691 hideTouchView : function()
15693 this.touchViewEl.removeClass('in');
15697 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15699 this.touchViewEl.setStyle('display', 'none');
15702 if(this._touchViewMask){
15703 this._touchViewMask.removeClass('show');
15704 Roo.get(document.body).removeClass("x-body-masked");
15708 setTouchViewValue : function()
15715 Roo.each(this.tickItems, function(o){
15720 this.hideTouchView();
15723 doTouchViewQuery : function()
15732 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15736 if(!this.alwaysQuery || this.mode == 'local'){
15737 this.onTouchViewLoad();
15744 onTouchViewBeforeLoad : function(combo,opts)
15750 onTouchViewLoad : function()
15752 if(this.store.getCount() < 1){
15753 this.onTouchViewEmptyResults();
15757 this.clearTouchView();
15759 var rawValue = this.getRawValue();
15761 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15763 this.tickItems = [];
15765 this.store.data.each(function(d, rowIndex){
15766 var row = this.touchViewListGroup.createChild(template);
15768 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15769 row.addClass(d.data.cls);
15772 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15775 html : d.data[this.displayField]
15778 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15779 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15782 row.removeClass('selected');
15783 if(!this.multiple && this.valueField &&
15784 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15787 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15788 row.addClass('selected');
15791 if(this.multiple && this.valueField &&
15792 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15796 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15797 this.tickItems.push(d.data);
15800 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15804 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15806 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15808 if(this.modalTitle.length){
15809 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15812 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15814 if(this.mobile_restrict_height && listHeight < bodyHeight){
15815 this.touchViewBodyEl.setHeight(listHeight);
15820 if(firstChecked && listHeight > bodyHeight){
15821 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15826 onTouchViewLoadException : function()
15828 this.hideTouchView();
15831 onTouchViewEmptyResults : function()
15833 this.clearTouchView();
15835 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15837 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15841 clearTouchView : function()
15843 this.touchViewListGroup.dom.innerHTML = '';
15846 onTouchViewClick : function(e, el, o)
15848 e.preventDefault();
15851 var rowIndex = o.rowIndex;
15853 var r = this.store.getAt(rowIndex);
15855 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15857 if(!this.multiple){
15858 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15859 c.dom.removeAttribute('checked');
15862 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15864 this.setFromData(r.data);
15866 var close = this.closeTriggerEl();
15872 this.hideTouchView();
15874 this.fireEvent('select', this, r, rowIndex);
15879 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15880 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15881 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15885 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15886 this.addItem(r.data);
15887 this.tickItems.push(r.data);
15891 getAutoCreateNativeIOS : function()
15894 cls: 'form-group' //input-group,
15899 cls : 'roo-ios-select'
15903 combobox.name = this.name;
15906 if (this.disabled) {
15907 combobox.disabled = true;
15910 var settings = this;
15912 ['xs','sm','md','lg'].map(function(size){
15913 if (settings[size]) {
15914 cfg.cls += ' col-' + size + '-' + settings[size];
15924 initIOSView : function()
15926 this.store.on('load', this.onIOSViewLoad, this);
15931 onIOSViewLoad : function()
15933 if(this.store.getCount() < 1){
15937 this.clearIOSView();
15939 if(this.allowBlank) {
15941 var default_text = '-- SELECT --';
15943 if(this.placeholder.length){
15944 default_text = this.placeholder;
15947 if(this.emptyTitle.length){
15948 default_text += ' - ' + this.emptyTitle + ' -';
15951 var opt = this.inputEl().createChild({
15954 html : default_text
15958 o[this.valueField] = 0;
15959 o[this.displayField] = default_text;
15961 this.ios_options.push({
15968 this.store.data.each(function(d, rowIndex){
15972 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15973 html = d.data[this.displayField];
15978 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15979 value = d.data[this.valueField];
15988 if(this.value == d.data[this.valueField]){
15989 option['selected'] = true;
15992 var opt = this.inputEl().createChild(option);
15994 this.ios_options.push({
16001 this.inputEl().on('change', function(){
16002 this.fireEvent('select', this);
16007 clearIOSView: function()
16009 this.inputEl().dom.innerHTML = '';
16011 this.ios_options = [];
16014 setIOSValue: function(v)
16018 if(!this.ios_options){
16022 Roo.each(this.ios_options, function(opts){
16024 opts.el.dom.removeAttribute('selected');
16026 if(opts.data[this.valueField] != v){
16030 opts.el.dom.setAttribute('selected', true);
16036 * @cfg {Boolean} grow
16040 * @cfg {Number} growMin
16044 * @cfg {Number} growMax
16053 Roo.apply(Roo.bootstrap.ComboBox, {
16057 cls: 'modal-header',
16079 cls: 'list-group-item',
16083 cls: 'roo-combobox-list-group-item-value'
16087 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16101 listItemCheckbox : {
16103 cls: 'list-group-item',
16107 cls: 'roo-combobox-list-group-item-value'
16111 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16127 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16132 cls: 'modal-footer',
16140 cls: 'col-xs-6 text-left',
16143 cls: 'btn btn-danger roo-touch-view-cancel',
16149 cls: 'col-xs-6 text-right',
16152 cls: 'btn btn-success roo-touch-view-ok',
16163 Roo.apply(Roo.bootstrap.ComboBox, {
16165 touchViewTemplate : {
16167 cls: 'modal fade roo-combobox-touch-view',
16171 cls: 'modal-dialog',
16172 style : 'position:fixed', // we have to fix position....
16176 cls: 'modal-content',
16178 Roo.bootstrap.ComboBox.header,
16179 Roo.bootstrap.ComboBox.body,
16180 Roo.bootstrap.ComboBox.footer
16189 * Ext JS Library 1.1.1
16190 * Copyright(c) 2006-2007, Ext JS, LLC.
16192 * Originally Released Under LGPL - original licence link has changed is not relivant.
16195 * <script type="text/javascript">
16200 * @extends Roo.util.Observable
16201 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16202 * This class also supports single and multi selection modes. <br>
16203 * Create a data model bound view:
16205 var store = new Roo.data.Store(...);
16207 var view = new Roo.View({
16209 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16211 singleSelect: true,
16212 selectedClass: "ydataview-selected",
16216 // listen for node click?
16217 view.on("click", function(vw, index, node, e){
16218 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16222 dataModel.load("foobar.xml");
16224 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16226 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16227 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16229 * Note: old style constructor is still suported (container, template, config)
16232 * Create a new View
16233 * @param {Object} config The config object
16236 Roo.View = function(config, depreciated_tpl, depreciated_config){
16238 this.parent = false;
16240 if (typeof(depreciated_tpl) == 'undefined') {
16241 // new way.. - universal constructor.
16242 Roo.apply(this, config);
16243 this.el = Roo.get(this.el);
16246 this.el = Roo.get(config);
16247 this.tpl = depreciated_tpl;
16248 Roo.apply(this, depreciated_config);
16250 this.wrapEl = this.el.wrap().wrap();
16251 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16254 if(typeof(this.tpl) == "string"){
16255 this.tpl = new Roo.Template(this.tpl);
16257 // support xtype ctors..
16258 this.tpl = new Roo.factory(this.tpl, Roo);
16262 this.tpl.compile();
16267 * @event beforeclick
16268 * Fires before a click is processed. Returns false to cancel the default action.
16269 * @param {Roo.View} this
16270 * @param {Number} index The index of the target node
16271 * @param {HTMLElement} node The target node
16272 * @param {Roo.EventObject} e The raw event object
16274 "beforeclick" : true,
16277 * Fires when a template node is clicked.
16278 * @param {Roo.View} this
16279 * @param {Number} index The index of the target node
16280 * @param {HTMLElement} node The target node
16281 * @param {Roo.EventObject} e The raw event object
16286 * Fires when a template node is double clicked.
16287 * @param {Roo.View} this
16288 * @param {Number} index The index of the target node
16289 * @param {HTMLElement} node The target node
16290 * @param {Roo.EventObject} e The raw event object
16294 * @event contextmenu
16295 * Fires when a template node is right clicked.
16296 * @param {Roo.View} this
16297 * @param {Number} index The index of the target node
16298 * @param {HTMLElement} node The target node
16299 * @param {Roo.EventObject} e The raw event object
16301 "contextmenu" : true,
16303 * @event selectionchange
16304 * Fires when the selected nodes change.
16305 * @param {Roo.View} this
16306 * @param {Array} selections Array of the selected nodes
16308 "selectionchange" : true,
16311 * @event beforeselect
16312 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16313 * @param {Roo.View} this
16314 * @param {HTMLElement} node The node to be selected
16315 * @param {Array} selections Array of currently selected nodes
16317 "beforeselect" : true,
16319 * @event preparedata
16320 * Fires on every row to render, to allow you to change the data.
16321 * @param {Roo.View} this
16322 * @param {Object} data to be rendered (change this)
16324 "preparedata" : true
16332 "click": this.onClick,
16333 "dblclick": this.onDblClick,
16334 "contextmenu": this.onContextMenu,
16338 this.selections = [];
16340 this.cmp = new Roo.CompositeElementLite([]);
16342 this.store = Roo.factory(this.store, Roo.data);
16343 this.setStore(this.store, true);
16346 if ( this.footer && this.footer.xtype) {
16348 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16350 this.footer.dataSource = this.store;
16351 this.footer.container = fctr;
16352 this.footer = Roo.factory(this.footer, Roo);
16353 fctr.insertFirst(this.el);
16355 // this is a bit insane - as the paging toolbar seems to detach the el..
16356 // dom.parentNode.parentNode.parentNode
16357 // they get detached?
16361 Roo.View.superclass.constructor.call(this);
16366 Roo.extend(Roo.View, Roo.util.Observable, {
16369 * @cfg {Roo.data.Store} store Data store to load data from.
16374 * @cfg {String|Roo.Element} el The container element.
16379 * @cfg {String|Roo.Template} tpl The template used by this View
16383 * @cfg {String} dataName the named area of the template to use as the data area
16384 * Works with domtemplates roo-name="name"
16388 * @cfg {String} selectedClass The css class to add to selected nodes
16390 selectedClass : "x-view-selected",
16392 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16397 * @cfg {String} text to display on mask (default Loading)
16401 * @cfg {Boolean} multiSelect Allow multiple selection
16403 multiSelect : false,
16405 * @cfg {Boolean} singleSelect Allow single selection
16407 singleSelect: false,
16410 * @cfg {Boolean} toggleSelect - selecting
16412 toggleSelect : false,
16415 * @cfg {Boolean} tickable - selecting
16420 * Returns the element this view is bound to.
16421 * @return {Roo.Element}
16423 getEl : function(){
16424 return this.wrapEl;
16430 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16432 refresh : function(){
16433 //Roo.log('refresh');
16436 // if we are using something like 'domtemplate', then
16437 // the what gets used is:
16438 // t.applySubtemplate(NAME, data, wrapping data..)
16439 // the outer template then get' applied with
16440 // the store 'extra data'
16441 // and the body get's added to the
16442 // roo-name="data" node?
16443 // <span class='roo-tpl-{name}'></span> ?????
16447 this.clearSelections();
16448 this.el.update("");
16450 var records = this.store.getRange();
16451 if(records.length < 1) {
16453 // is this valid?? = should it render a template??
16455 this.el.update(this.emptyText);
16459 if (this.dataName) {
16460 this.el.update(t.apply(this.store.meta)); //????
16461 el = this.el.child('.roo-tpl-' + this.dataName);
16464 for(var i = 0, len = records.length; i < len; i++){
16465 var data = this.prepareData(records[i].data, i, records[i]);
16466 this.fireEvent("preparedata", this, data, i, records[i]);
16468 var d = Roo.apply({}, data);
16471 Roo.apply(d, {'roo-id' : Roo.id()});
16475 Roo.each(this.parent.item, function(item){
16476 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16479 Roo.apply(d, {'roo-data-checked' : 'checked'});
16483 html[html.length] = Roo.util.Format.trim(
16485 t.applySubtemplate(this.dataName, d, this.store.meta) :
16492 el.update(html.join(""));
16493 this.nodes = el.dom.childNodes;
16494 this.updateIndexes(0);
16499 * Function to override to reformat the data that is sent to
16500 * the template for each node.
16501 * DEPRICATED - use the preparedata event handler.
16502 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16503 * a JSON object for an UpdateManager bound view).
16505 prepareData : function(data, index, record)
16507 this.fireEvent("preparedata", this, data, index, record);
16511 onUpdate : function(ds, record){
16512 // Roo.log('on update');
16513 this.clearSelections();
16514 var index = this.store.indexOf(record);
16515 var n = this.nodes[index];
16516 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16517 n.parentNode.removeChild(n);
16518 this.updateIndexes(index, index);
16524 onAdd : function(ds, records, index)
16526 //Roo.log(['on Add', ds, records, index] );
16527 this.clearSelections();
16528 if(this.nodes.length == 0){
16532 var n = this.nodes[index];
16533 for(var i = 0, len = records.length; i < len; i++){
16534 var d = this.prepareData(records[i].data, i, records[i]);
16536 this.tpl.insertBefore(n, d);
16539 this.tpl.append(this.el, d);
16542 this.updateIndexes(index);
16545 onRemove : function(ds, record, index){
16546 // Roo.log('onRemove');
16547 this.clearSelections();
16548 var el = this.dataName ?
16549 this.el.child('.roo-tpl-' + this.dataName) :
16552 el.dom.removeChild(this.nodes[index]);
16553 this.updateIndexes(index);
16557 * Refresh an individual node.
16558 * @param {Number} index
16560 refreshNode : function(index){
16561 this.onUpdate(this.store, this.store.getAt(index));
16564 updateIndexes : function(startIndex, endIndex){
16565 var ns = this.nodes;
16566 startIndex = startIndex || 0;
16567 endIndex = endIndex || ns.length - 1;
16568 for(var i = startIndex; i <= endIndex; i++){
16569 ns[i].nodeIndex = i;
16574 * Changes the data store this view uses and refresh the view.
16575 * @param {Store} store
16577 setStore : function(store, initial){
16578 if(!initial && this.store){
16579 this.store.un("datachanged", this.refresh);
16580 this.store.un("add", this.onAdd);
16581 this.store.un("remove", this.onRemove);
16582 this.store.un("update", this.onUpdate);
16583 this.store.un("clear", this.refresh);
16584 this.store.un("beforeload", this.onBeforeLoad);
16585 this.store.un("load", this.onLoad);
16586 this.store.un("loadexception", this.onLoad);
16590 store.on("datachanged", this.refresh, this);
16591 store.on("add", this.onAdd, this);
16592 store.on("remove", this.onRemove, this);
16593 store.on("update", this.onUpdate, this);
16594 store.on("clear", this.refresh, this);
16595 store.on("beforeload", this.onBeforeLoad, this);
16596 store.on("load", this.onLoad, this);
16597 store.on("loadexception", this.onLoad, this);
16605 * onbeforeLoad - masks the loading area.
16608 onBeforeLoad : function(store,opts)
16610 //Roo.log('onBeforeLoad');
16612 this.el.update("");
16614 this.el.mask(this.mask ? this.mask : "Loading" );
16616 onLoad : function ()
16623 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16624 * @param {HTMLElement} node
16625 * @return {HTMLElement} The template node
16627 findItemFromChild : function(node){
16628 var el = this.dataName ?
16629 this.el.child('.roo-tpl-' + this.dataName,true) :
16632 if(!node || node.parentNode == el){
16635 var p = node.parentNode;
16636 while(p && p != el){
16637 if(p.parentNode == el){
16646 onClick : function(e){
16647 var item = this.findItemFromChild(e.getTarget());
16649 var index = this.indexOf(item);
16650 if(this.onItemClick(item, index, e) !== false){
16651 this.fireEvent("click", this, index, item, e);
16654 this.clearSelections();
16659 onContextMenu : function(e){
16660 var item = this.findItemFromChild(e.getTarget());
16662 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16667 onDblClick : function(e){
16668 var item = this.findItemFromChild(e.getTarget());
16670 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16674 onItemClick : function(item, index, e)
16676 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16679 if (this.toggleSelect) {
16680 var m = this.isSelected(item) ? 'unselect' : 'select';
16683 _t[m](item, true, false);
16686 if(this.multiSelect || this.singleSelect){
16687 if(this.multiSelect && e.shiftKey && this.lastSelection){
16688 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16690 this.select(item, this.multiSelect && e.ctrlKey);
16691 this.lastSelection = item;
16694 if(!this.tickable){
16695 e.preventDefault();
16703 * Get the number of selected nodes.
16706 getSelectionCount : function(){
16707 return this.selections.length;
16711 * Get the currently selected nodes.
16712 * @return {Array} An array of HTMLElements
16714 getSelectedNodes : function(){
16715 return this.selections;
16719 * Get the indexes of the selected nodes.
16722 getSelectedIndexes : function(){
16723 var indexes = [], s = this.selections;
16724 for(var i = 0, len = s.length; i < len; i++){
16725 indexes.push(s[i].nodeIndex);
16731 * Clear all selections
16732 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16734 clearSelections : function(suppressEvent){
16735 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16736 this.cmp.elements = this.selections;
16737 this.cmp.removeClass(this.selectedClass);
16738 this.selections = [];
16739 if(!suppressEvent){
16740 this.fireEvent("selectionchange", this, this.selections);
16746 * Returns true if the passed node is selected
16747 * @param {HTMLElement/Number} node The node or node index
16748 * @return {Boolean}
16750 isSelected : function(node){
16751 var s = this.selections;
16755 node = this.getNode(node);
16756 return s.indexOf(node) !== -1;
16761 * @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
16762 * @param {Boolean} keepExisting (optional) true to keep existing selections
16763 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16765 select : function(nodeInfo, keepExisting, suppressEvent){
16766 if(nodeInfo instanceof Array){
16768 this.clearSelections(true);
16770 for(var i = 0, len = nodeInfo.length; i < len; i++){
16771 this.select(nodeInfo[i], true, true);
16775 var node = this.getNode(nodeInfo);
16776 if(!node || this.isSelected(node)){
16777 return; // already selected.
16780 this.clearSelections(true);
16783 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16784 Roo.fly(node).addClass(this.selectedClass);
16785 this.selections.push(node);
16786 if(!suppressEvent){
16787 this.fireEvent("selectionchange", this, this.selections);
16795 * @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
16796 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16797 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16799 unselect : function(nodeInfo, keepExisting, suppressEvent)
16801 if(nodeInfo instanceof Array){
16802 Roo.each(this.selections, function(s) {
16803 this.unselect(s, nodeInfo);
16807 var node = this.getNode(nodeInfo);
16808 if(!node || !this.isSelected(node)){
16809 //Roo.log("not selected");
16810 return; // not selected.
16814 Roo.each(this.selections, function(s) {
16816 Roo.fly(node).removeClass(this.selectedClass);
16823 this.selections= ns;
16824 this.fireEvent("selectionchange", this, this.selections);
16828 * Gets a template node.
16829 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16830 * @return {HTMLElement} The node or null if it wasn't found
16832 getNode : function(nodeInfo){
16833 if(typeof nodeInfo == "string"){
16834 return document.getElementById(nodeInfo);
16835 }else if(typeof nodeInfo == "number"){
16836 return this.nodes[nodeInfo];
16842 * Gets a range template nodes.
16843 * @param {Number} startIndex
16844 * @param {Number} endIndex
16845 * @return {Array} An array of nodes
16847 getNodes : function(start, end){
16848 var ns = this.nodes;
16849 start = start || 0;
16850 end = typeof end == "undefined" ? ns.length - 1 : end;
16853 for(var i = start; i <= end; i++){
16857 for(var i = start; i >= end; i--){
16865 * Finds the index of the passed node
16866 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16867 * @return {Number} The index of the node or -1
16869 indexOf : function(node){
16870 node = this.getNode(node);
16871 if(typeof node.nodeIndex == "number"){
16872 return node.nodeIndex;
16874 var ns = this.nodes;
16875 for(var i = 0, len = ns.length; i < len; i++){
16886 * based on jquery fullcalendar
16890 Roo.bootstrap = Roo.bootstrap || {};
16892 * @class Roo.bootstrap.Calendar
16893 * @extends Roo.bootstrap.Component
16894 * Bootstrap Calendar class
16895 * @cfg {Boolean} loadMask (true|false) default false
16896 * @cfg {Object} header generate the user specific header of the calendar, default false
16899 * Create a new Container
16900 * @param {Object} config The config object
16905 Roo.bootstrap.Calendar = function(config){
16906 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16910 * Fires when a date is selected
16911 * @param {DatePicker} this
16912 * @param {Date} date The selected date
16916 * @event monthchange
16917 * Fires when the displayed month changes
16918 * @param {DatePicker} this
16919 * @param {Date} date The selected month
16921 'monthchange': true,
16923 * @event evententer
16924 * Fires when mouse over an event
16925 * @param {Calendar} this
16926 * @param {event} Event
16928 'evententer': true,
16930 * @event eventleave
16931 * Fires when the mouse leaves an
16932 * @param {Calendar} this
16935 'eventleave': true,
16937 * @event eventclick
16938 * Fires when the mouse click an
16939 * @param {Calendar} this
16948 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16951 * @cfg {Number} startDay
16952 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16960 getAutoCreate : function(){
16963 var fc_button = function(name, corner, style, content ) {
16964 return Roo.apply({},{
16966 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16968 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16971 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16982 style : 'width:100%',
16989 cls : 'fc-header-left',
16991 fc_button('prev', 'left', 'arrow', '‹' ),
16992 fc_button('next', 'right', 'arrow', '›' ),
16993 { tag: 'span', cls: 'fc-header-space' },
16994 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
17002 cls : 'fc-header-center',
17006 cls: 'fc-header-title',
17009 html : 'month / year'
17017 cls : 'fc-header-right',
17019 /* fc_button('month', 'left', '', 'month' ),
17020 fc_button('week', '', '', 'week' ),
17021 fc_button('day', 'right', '', 'day' )
17033 header = this.header;
17036 var cal_heads = function() {
17038 // fixme - handle this.
17040 for (var i =0; i < Date.dayNames.length; i++) {
17041 var d = Date.dayNames[i];
17044 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17045 html : d.substring(0,3)
17049 ret[0].cls += ' fc-first';
17050 ret[6].cls += ' fc-last';
17053 var cal_cell = function(n) {
17056 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17061 cls: 'fc-day-number',
17065 cls: 'fc-day-content',
17069 style: 'position: relative;' // height: 17px;
17081 var cal_rows = function() {
17084 for (var r = 0; r < 6; r++) {
17091 for (var i =0; i < Date.dayNames.length; i++) {
17092 var d = Date.dayNames[i];
17093 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17096 row.cn[0].cls+=' fc-first';
17097 row.cn[0].cn[0].style = 'min-height:90px';
17098 row.cn[6].cls+=' fc-last';
17102 ret[0].cls += ' fc-first';
17103 ret[4].cls += ' fc-prev-last';
17104 ret[5].cls += ' fc-last';
17111 cls: 'fc-border-separate',
17112 style : 'width:100%',
17120 cls : 'fc-first fc-last',
17138 cls : 'fc-content',
17139 style : "position: relative;",
17142 cls : 'fc-view fc-view-month fc-grid',
17143 style : 'position: relative',
17144 unselectable : 'on',
17147 cls : 'fc-event-container',
17148 style : 'position:absolute;z-index:8;top:0;left:0;'
17166 initEvents : function()
17169 throw "can not find store for calendar";
17175 style: "text-align:center",
17179 style: "background-color:white;width:50%;margin:250 auto",
17183 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17194 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17196 var size = this.el.select('.fc-content', true).first().getSize();
17197 this.maskEl.setSize(size.width, size.height);
17198 this.maskEl.enableDisplayMode("block");
17199 if(!this.loadMask){
17200 this.maskEl.hide();
17203 this.store = Roo.factory(this.store, Roo.data);
17204 this.store.on('load', this.onLoad, this);
17205 this.store.on('beforeload', this.onBeforeLoad, this);
17209 this.cells = this.el.select('.fc-day',true);
17210 //Roo.log(this.cells);
17211 this.textNodes = this.el.query('.fc-day-number');
17212 this.cells.addClassOnOver('fc-state-hover');
17214 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17215 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17216 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17217 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17219 this.on('monthchange', this.onMonthChange, this);
17221 this.update(new Date().clearTime());
17224 resize : function() {
17225 var sz = this.el.getSize();
17227 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17228 this.el.select('.fc-day-content div',true).setHeight(34);
17233 showPrevMonth : function(e){
17234 this.update(this.activeDate.add("mo", -1));
17236 showToday : function(e){
17237 this.update(new Date().clearTime());
17240 showNextMonth : function(e){
17241 this.update(this.activeDate.add("mo", 1));
17245 showPrevYear : function(){
17246 this.update(this.activeDate.add("y", -1));
17250 showNextYear : function(){
17251 this.update(this.activeDate.add("y", 1));
17256 update : function(date)
17258 var vd = this.activeDate;
17259 this.activeDate = date;
17260 // if(vd && this.el){
17261 // var t = date.getTime();
17262 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17263 // Roo.log('using add remove');
17265 // this.fireEvent('monthchange', this, date);
17267 // this.cells.removeClass("fc-state-highlight");
17268 // this.cells.each(function(c){
17269 // if(c.dateValue == t){
17270 // c.addClass("fc-state-highlight");
17271 // setTimeout(function(){
17272 // try{c.dom.firstChild.focus();}catch(e){}
17282 var days = date.getDaysInMonth();
17284 var firstOfMonth = date.getFirstDateOfMonth();
17285 var startingPos = firstOfMonth.getDay()-this.startDay;
17287 if(startingPos < this.startDay){
17291 var pm = date.add(Date.MONTH, -1);
17292 var prevStart = pm.getDaysInMonth()-startingPos;
17294 this.cells = this.el.select('.fc-day',true);
17295 this.textNodes = this.el.query('.fc-day-number');
17296 this.cells.addClassOnOver('fc-state-hover');
17298 var cells = this.cells.elements;
17299 var textEls = this.textNodes;
17301 Roo.each(cells, function(cell){
17302 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17305 days += startingPos;
17307 // convert everything to numbers so it's fast
17308 var day = 86400000;
17309 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17312 //Roo.log(prevStart);
17314 var today = new Date().clearTime().getTime();
17315 var sel = date.clearTime().getTime();
17316 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17317 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17318 var ddMatch = this.disabledDatesRE;
17319 var ddText = this.disabledDatesText;
17320 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17321 var ddaysText = this.disabledDaysText;
17322 var format = this.format;
17324 var setCellClass = function(cal, cell){
17328 //Roo.log('set Cell Class');
17330 var t = d.getTime();
17334 cell.dateValue = t;
17336 cell.className += " fc-today";
17337 cell.className += " fc-state-highlight";
17338 cell.title = cal.todayText;
17341 // disable highlight in other month..
17342 //cell.className += " fc-state-highlight";
17347 cell.className = " fc-state-disabled";
17348 cell.title = cal.minText;
17352 cell.className = " fc-state-disabled";
17353 cell.title = cal.maxText;
17357 if(ddays.indexOf(d.getDay()) != -1){
17358 cell.title = ddaysText;
17359 cell.className = " fc-state-disabled";
17362 if(ddMatch && format){
17363 var fvalue = d.dateFormat(format);
17364 if(ddMatch.test(fvalue)){
17365 cell.title = ddText.replace("%0", fvalue);
17366 cell.className = " fc-state-disabled";
17370 if (!cell.initialClassName) {
17371 cell.initialClassName = cell.dom.className;
17374 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17379 for(; i < startingPos; i++) {
17380 textEls[i].innerHTML = (++prevStart);
17381 d.setDate(d.getDate()+1);
17383 cells[i].className = "fc-past fc-other-month";
17384 setCellClass(this, cells[i]);
17389 for(; i < days; i++){
17390 intDay = i - startingPos + 1;
17391 textEls[i].innerHTML = (intDay);
17392 d.setDate(d.getDate()+1);
17394 cells[i].className = ''; // "x-date-active";
17395 setCellClass(this, cells[i]);
17399 for(; i < 42; i++) {
17400 textEls[i].innerHTML = (++extraDays);
17401 d.setDate(d.getDate()+1);
17403 cells[i].className = "fc-future fc-other-month";
17404 setCellClass(this, cells[i]);
17407 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17409 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17411 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17412 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17414 if(totalRows != 6){
17415 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17416 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17419 this.fireEvent('monthchange', this, date);
17423 if(!this.internalRender){
17424 var main = this.el.dom.firstChild;
17425 var w = main.offsetWidth;
17426 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17427 Roo.fly(main).setWidth(w);
17428 this.internalRender = true;
17429 // opera does not respect the auto grow header center column
17430 // then, after it gets a width opera refuses to recalculate
17431 // without a second pass
17432 if(Roo.isOpera && !this.secondPass){
17433 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17434 this.secondPass = true;
17435 this.update.defer(10, this, [date]);
17442 findCell : function(dt) {
17443 dt = dt.clearTime().getTime();
17445 this.cells.each(function(c){
17446 //Roo.log("check " +c.dateValue + '?=' + dt);
17447 if(c.dateValue == dt){
17457 findCells : function(ev) {
17458 var s = ev.start.clone().clearTime().getTime();
17460 var e= ev.end.clone().clearTime().getTime();
17463 this.cells.each(function(c){
17464 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17466 if(c.dateValue > e){
17469 if(c.dateValue < s){
17478 // findBestRow: function(cells)
17482 // for (var i =0 ; i < cells.length;i++) {
17483 // ret = Math.max(cells[i].rows || 0,ret);
17490 addItem : function(ev)
17492 // look for vertical location slot in
17493 var cells = this.findCells(ev);
17495 // ev.row = this.findBestRow(cells);
17497 // work out the location.
17501 for(var i =0; i < cells.length; i++) {
17503 cells[i].row = cells[0].row;
17506 cells[i].row = cells[i].row + 1;
17516 if (crow.start.getY() == cells[i].getY()) {
17518 crow.end = cells[i];
17535 cells[0].events.push(ev);
17537 this.calevents.push(ev);
17540 clearEvents: function() {
17542 if(!this.calevents){
17546 Roo.each(this.cells.elements, function(c){
17552 Roo.each(this.calevents, function(e) {
17553 Roo.each(e.els, function(el) {
17554 el.un('mouseenter' ,this.onEventEnter, this);
17555 el.un('mouseleave' ,this.onEventLeave, this);
17560 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17566 renderEvents: function()
17570 this.cells.each(function(c) {
17579 if(c.row != c.events.length){
17580 r = 4 - (4 - (c.row - c.events.length));
17583 c.events = ev.slice(0, r);
17584 c.more = ev.slice(r);
17586 if(c.more.length && c.more.length == 1){
17587 c.events.push(c.more.pop());
17590 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17594 this.cells.each(function(c) {
17596 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17599 for (var e = 0; e < c.events.length; e++){
17600 var ev = c.events[e];
17601 var rows = ev.rows;
17603 for(var i = 0; i < rows.length; i++) {
17605 // how many rows should it span..
17608 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17609 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17611 unselectable : "on",
17614 cls: 'fc-event-inner',
17618 // cls: 'fc-event-time',
17619 // html : cells.length > 1 ? '' : ev.time
17623 cls: 'fc-event-title',
17624 html : String.format('{0}', ev.title)
17631 cls: 'ui-resizable-handle ui-resizable-e',
17632 html : '  '
17639 cfg.cls += ' fc-event-start';
17641 if ((i+1) == rows.length) {
17642 cfg.cls += ' fc-event-end';
17645 var ctr = _this.el.select('.fc-event-container',true).first();
17646 var cg = ctr.createChild(cfg);
17648 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17649 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17651 var r = (c.more.length) ? 1 : 0;
17652 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17653 cg.setWidth(ebox.right - sbox.x -2);
17655 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17656 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17657 cg.on('click', _this.onEventClick, _this, ev);
17668 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17669 style : 'position: absolute',
17670 unselectable : "on",
17673 cls: 'fc-event-inner',
17677 cls: 'fc-event-title',
17685 cls: 'ui-resizable-handle ui-resizable-e',
17686 html : '  '
17692 var ctr = _this.el.select('.fc-event-container',true).first();
17693 var cg = ctr.createChild(cfg);
17695 var sbox = c.select('.fc-day-content',true).first().getBox();
17696 var ebox = c.select('.fc-day-content',true).first().getBox();
17698 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17699 cg.setWidth(ebox.right - sbox.x -2);
17701 cg.on('click', _this.onMoreEventClick, _this, c.more);
17711 onEventEnter: function (e, el,event,d) {
17712 this.fireEvent('evententer', this, el, event);
17715 onEventLeave: function (e, el,event,d) {
17716 this.fireEvent('eventleave', this, el, event);
17719 onEventClick: function (e, el,event,d) {
17720 this.fireEvent('eventclick', this, el, event);
17723 onMonthChange: function () {
17727 onMoreEventClick: function(e, el, more)
17731 this.calpopover.placement = 'right';
17732 this.calpopover.setTitle('More');
17734 this.calpopover.setContent('');
17736 var ctr = this.calpopover.el.select('.popover-content', true).first();
17738 Roo.each(more, function(m){
17740 cls : 'fc-event-hori fc-event-draggable',
17743 var cg = ctr.createChild(cfg);
17745 cg.on('click', _this.onEventClick, _this, m);
17748 this.calpopover.show(el);
17753 onLoad: function ()
17755 this.calevents = [];
17758 if(this.store.getCount() > 0){
17759 this.store.data.each(function(d){
17762 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17763 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17764 time : d.data.start_time,
17765 title : d.data.title,
17766 description : d.data.description,
17767 venue : d.data.venue
17772 this.renderEvents();
17774 if(this.calevents.length && this.loadMask){
17775 this.maskEl.hide();
17779 onBeforeLoad: function()
17781 this.clearEvents();
17783 this.maskEl.show();
17797 * @class Roo.bootstrap.Popover
17798 * @extends Roo.bootstrap.Component
17799 * Bootstrap Popover class
17800 * @cfg {String} html contents of the popover (or false to use children..)
17801 * @cfg {String} title of popover (or false to hide)
17802 * @cfg {String} placement how it is placed
17803 * @cfg {String} trigger click || hover (or false to trigger manually)
17804 * @cfg {String} over what (parent or false to trigger manually.)
17805 * @cfg {Number} delay - delay before showing
17808 * Create a new Popover
17809 * @param {Object} config The config object
17812 Roo.bootstrap.Popover = function(config){
17813 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17819 * After the popover show
17821 * @param {Roo.bootstrap.Popover} this
17826 * After the popover hide
17828 * @param {Roo.bootstrap.Popover} this
17834 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17836 title: 'Fill in a title',
17839 placement : 'right',
17840 trigger : 'hover', // hover
17846 can_build_overlaid : false,
17848 getChildContainer : function()
17850 return this.el.select('.popover-content',true).first();
17853 getAutoCreate : function(){
17856 cls : 'popover roo-dynamic',
17857 style: 'display:block',
17863 cls : 'popover-inner',
17867 cls: 'popover-title popover-header',
17871 cls : 'popover-content popover-body',
17882 setTitle: function(str)
17885 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17887 setContent: function(str)
17890 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17892 // as it get's added to the bottom of the page.
17893 onRender : function(ct, position)
17895 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17897 var cfg = Roo.apply({}, this.getAutoCreate());
17901 cfg.cls += ' ' + this.cls;
17904 cfg.style = this.style;
17906 //Roo.log("adding to ");
17907 this.el = Roo.get(document.body).createChild(cfg, position);
17908 // Roo.log(this.el);
17913 initEvents : function()
17915 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17916 this.el.enableDisplayMode('block');
17918 if (this.over === false) {
17921 if (this.triggers === false) {
17924 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17925 var triggers = this.trigger ? this.trigger.split(' ') : [];
17926 Roo.each(triggers, function(trigger) {
17928 if (trigger == 'click') {
17929 on_el.on('click', this.toggle, this);
17930 } else if (trigger != 'manual') {
17931 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17932 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17934 on_el.on(eventIn ,this.enter, this);
17935 on_el.on(eventOut, this.leave, this);
17946 toggle : function () {
17947 this.hoverState == 'in' ? this.leave() : this.enter();
17950 enter : function () {
17952 clearTimeout(this.timeout);
17954 this.hoverState = 'in';
17956 if (!this.delay || !this.delay.show) {
17961 this.timeout = setTimeout(function () {
17962 if (_t.hoverState == 'in') {
17965 }, this.delay.show)
17968 leave : function() {
17969 clearTimeout(this.timeout);
17971 this.hoverState = 'out';
17973 if (!this.delay || !this.delay.hide) {
17978 this.timeout = setTimeout(function () {
17979 if (_t.hoverState == 'out') {
17982 }, this.delay.hide)
17985 show : function (on_el)
17988 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17992 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17993 if (this.html !== false) {
17994 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17996 this.el.removeClass([
17997 'fade','top','bottom', 'left', 'right','in',
17998 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
18000 if (!this.title.length) {
18001 this.el.select('.popover-title',true).hide();
18004 var placement = typeof this.placement == 'function' ?
18005 this.placement.call(this, this.el, on_el) :
18008 var autoToken = /\s?auto?\s?/i;
18009 var autoPlace = autoToken.test(placement);
18011 placement = placement.replace(autoToken, '') || 'top';
18015 //this.el.setXY([0,0]);
18017 this.el.dom.style.display='block';
18018 this.el.addClass(placement);
18020 //this.el.appendTo(on_el);
18022 var p = this.getPosition();
18023 var box = this.el.getBox();
18028 var align = Roo.bootstrap.Popover.alignment[placement];
18031 this.el.alignTo(on_el, align[0],align[1]);
18032 //var arrow = this.el.select('.arrow',true).first();
18033 //arrow.set(align[2],
18035 this.el.addClass('in');
18038 if (this.el.hasClass('fade')) {
18042 this.hoverState = 'in';
18044 this.fireEvent('show', this);
18049 this.el.setXY([0,0]);
18050 this.el.removeClass('in');
18052 this.hoverState = null;
18054 this.fireEvent('hide', this);
18059 Roo.bootstrap.Popover.alignment = {
18060 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18061 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18062 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18063 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18074 * @class Roo.bootstrap.Progress
18075 * @extends Roo.bootstrap.Component
18076 * Bootstrap Progress class
18077 * @cfg {Boolean} striped striped of the progress bar
18078 * @cfg {Boolean} active animated of the progress bar
18082 * Create a new Progress
18083 * @param {Object} config The config object
18086 Roo.bootstrap.Progress = function(config){
18087 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18090 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18095 getAutoCreate : function(){
18103 cfg.cls += ' progress-striped';
18107 cfg.cls += ' active';
18126 * @class Roo.bootstrap.ProgressBar
18127 * @extends Roo.bootstrap.Component
18128 * Bootstrap ProgressBar class
18129 * @cfg {Number} aria_valuenow aria-value now
18130 * @cfg {Number} aria_valuemin aria-value min
18131 * @cfg {Number} aria_valuemax aria-value max
18132 * @cfg {String} label label for the progress bar
18133 * @cfg {String} panel (success | info | warning | danger )
18134 * @cfg {String} role role of the progress bar
18135 * @cfg {String} sr_only text
18139 * Create a new ProgressBar
18140 * @param {Object} config The config object
18143 Roo.bootstrap.ProgressBar = function(config){
18144 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18147 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18151 aria_valuemax : 100,
18157 getAutoCreate : function()
18162 cls: 'progress-bar',
18163 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18175 cfg.role = this.role;
18178 if(this.aria_valuenow){
18179 cfg['aria-valuenow'] = this.aria_valuenow;
18182 if(this.aria_valuemin){
18183 cfg['aria-valuemin'] = this.aria_valuemin;
18186 if(this.aria_valuemax){
18187 cfg['aria-valuemax'] = this.aria_valuemax;
18190 if(this.label && !this.sr_only){
18191 cfg.html = this.label;
18195 cfg.cls += ' progress-bar-' + this.panel;
18201 update : function(aria_valuenow)
18203 this.aria_valuenow = aria_valuenow;
18205 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18220 * @class Roo.bootstrap.TabGroup
18221 * @extends Roo.bootstrap.Column
18222 * Bootstrap Column class
18223 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18224 * @cfg {Boolean} carousel true to make the group behave like a carousel
18225 * @cfg {Boolean} bullets show bullets for the panels
18226 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18227 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18228 * @cfg {Boolean} showarrow (true|false) show arrow default true
18231 * Create a new TabGroup
18232 * @param {Object} config The config object
18235 Roo.bootstrap.TabGroup = function(config){
18236 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18238 this.navId = Roo.id();
18241 Roo.bootstrap.TabGroup.register(this);
18245 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18248 transition : false,
18253 slideOnTouch : false,
18256 getAutoCreate : function()
18258 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18260 cfg.cls += ' tab-content';
18262 if (this.carousel) {
18263 cfg.cls += ' carousel slide';
18266 cls : 'carousel-inner',
18270 if(this.bullets && !Roo.isTouch){
18273 cls : 'carousel-bullets',
18277 if(this.bullets_cls){
18278 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18285 cfg.cn[0].cn.push(bullets);
18288 if(this.showarrow){
18289 cfg.cn[0].cn.push({
18291 class : 'carousel-arrow',
18295 class : 'carousel-prev',
18299 class : 'fa fa-chevron-left'
18305 class : 'carousel-next',
18309 class : 'fa fa-chevron-right'
18322 initEvents: function()
18324 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18325 // this.el.on("touchstart", this.onTouchStart, this);
18328 if(this.autoslide){
18331 this.slideFn = window.setInterval(function() {
18332 _this.showPanelNext();
18336 if(this.showarrow){
18337 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18338 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18344 // onTouchStart : function(e, el, o)
18346 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18350 // this.showPanelNext();
18354 getChildContainer : function()
18356 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18360 * register a Navigation item
18361 * @param {Roo.bootstrap.NavItem} the navitem to add
18363 register : function(item)
18365 this.tabs.push( item);
18366 item.navId = this.navId; // not really needed..
18371 getActivePanel : function()
18374 Roo.each(this.tabs, function(t) {
18384 getPanelByName : function(n)
18387 Roo.each(this.tabs, function(t) {
18388 if (t.tabId == n) {
18396 indexOfPanel : function(p)
18399 Roo.each(this.tabs, function(t,i) {
18400 if (t.tabId == p.tabId) {
18409 * show a specific panel
18410 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18411 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18413 showPanel : function (pan)
18415 if(this.transition || typeof(pan) == 'undefined'){
18416 Roo.log("waiting for the transitionend");
18420 if (typeof(pan) == 'number') {
18421 pan = this.tabs[pan];
18424 if (typeof(pan) == 'string') {
18425 pan = this.getPanelByName(pan);
18428 var cur = this.getActivePanel();
18431 Roo.log('pan or acitve pan is undefined');
18435 if (pan.tabId == this.getActivePanel().tabId) {
18439 if (false === cur.fireEvent('beforedeactivate')) {
18443 if(this.bullets > 0 && !Roo.isTouch){
18444 this.setActiveBullet(this.indexOfPanel(pan));
18447 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18449 //class="carousel-item carousel-item-next carousel-item-left"
18451 this.transition = true;
18452 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18453 var lr = dir == 'next' ? 'left' : 'right';
18454 pan.el.addClass(dir); // or prev
18455 pan.el.addClass('carousel-item-' + dir); // or prev
18456 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18457 cur.el.addClass(lr); // or right
18458 pan.el.addClass(lr);
18459 cur.el.addClass('carousel-item-' +lr); // or right
18460 pan.el.addClass('carousel-item-' +lr);
18464 cur.el.on('transitionend', function() {
18465 Roo.log("trans end?");
18467 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18468 pan.setActive(true);
18470 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18471 cur.setActive(false);
18473 _this.transition = false;
18475 }, this, { single: true } );
18480 cur.setActive(false);
18481 pan.setActive(true);
18486 showPanelNext : function()
18488 var i = this.indexOfPanel(this.getActivePanel());
18490 if (i >= this.tabs.length - 1 && !this.autoslide) {
18494 if (i >= this.tabs.length - 1 && this.autoslide) {
18498 this.showPanel(this.tabs[i+1]);
18501 showPanelPrev : function()
18503 var i = this.indexOfPanel(this.getActivePanel());
18505 if (i < 1 && !this.autoslide) {
18509 if (i < 1 && this.autoslide) {
18510 i = this.tabs.length;
18513 this.showPanel(this.tabs[i-1]);
18517 addBullet: function()
18519 if(!this.bullets || Roo.isTouch){
18522 var ctr = this.el.select('.carousel-bullets',true).first();
18523 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18524 var bullet = ctr.createChild({
18525 cls : 'bullet bullet-' + i
18526 },ctr.dom.lastChild);
18531 bullet.on('click', (function(e, el, o, ii, t){
18533 e.preventDefault();
18535 this.showPanel(ii);
18537 if(this.autoslide && this.slideFn){
18538 clearInterval(this.slideFn);
18539 this.slideFn = window.setInterval(function() {
18540 _this.showPanelNext();
18544 }).createDelegate(this, [i, bullet], true));
18549 setActiveBullet : function(i)
18555 Roo.each(this.el.select('.bullet', true).elements, function(el){
18556 el.removeClass('selected');
18559 var bullet = this.el.select('.bullet-' + i, true).first();
18565 bullet.addClass('selected');
18576 Roo.apply(Roo.bootstrap.TabGroup, {
18580 * register a Navigation Group
18581 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18583 register : function(navgrp)
18585 this.groups[navgrp.navId] = navgrp;
18589 * fetch a Navigation Group based on the navigation ID
18590 * if one does not exist , it will get created.
18591 * @param {string} the navgroup to add
18592 * @returns {Roo.bootstrap.NavGroup} the navgroup
18594 get: function(navId) {
18595 if (typeof(this.groups[navId]) == 'undefined') {
18596 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18598 return this.groups[navId] ;
18613 * @class Roo.bootstrap.TabPanel
18614 * @extends Roo.bootstrap.Component
18615 * Bootstrap TabPanel class
18616 * @cfg {Boolean} active panel active
18617 * @cfg {String} html panel content
18618 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18619 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18620 * @cfg {String} href click to link..
18624 * Create a new TabPanel
18625 * @param {Object} config The config object
18628 Roo.bootstrap.TabPanel = function(config){
18629 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18633 * Fires when the active status changes
18634 * @param {Roo.bootstrap.TabPanel} this
18635 * @param {Boolean} state the new state
18640 * @event beforedeactivate
18641 * Fires before a tab is de-activated - can be used to do validation on a form.
18642 * @param {Roo.bootstrap.TabPanel} this
18643 * @return {Boolean} false if there is an error
18646 'beforedeactivate': true
18649 this.tabId = this.tabId || Roo.id();
18653 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18661 getAutoCreate : function(){
18666 // item is needed for carousel - not sure if it has any effect otherwise
18667 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18668 html: this.html || ''
18672 cfg.cls += ' active';
18676 cfg.tabId = this.tabId;
18684 initEvents: function()
18686 var p = this.parent();
18688 this.navId = this.navId || p.navId;
18690 if (typeof(this.navId) != 'undefined') {
18691 // not really needed.. but just in case.. parent should be a NavGroup.
18692 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18696 var i = tg.tabs.length - 1;
18698 if(this.active && tg.bullets > 0 && i < tg.bullets){
18699 tg.setActiveBullet(i);
18703 this.el.on('click', this.onClick, this);
18706 this.el.on("touchstart", this.onTouchStart, this);
18707 this.el.on("touchmove", this.onTouchMove, this);
18708 this.el.on("touchend", this.onTouchEnd, this);
18713 onRender : function(ct, position)
18715 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18718 setActive : function(state)
18720 Roo.log("panel - set active " + this.tabId + "=" + state);
18722 this.active = state;
18724 this.el.removeClass('active');
18726 } else if (!this.el.hasClass('active')) {
18727 this.el.addClass('active');
18730 this.fireEvent('changed', this, state);
18733 onClick : function(e)
18735 e.preventDefault();
18737 if(!this.href.length){
18741 window.location.href = this.href;
18750 onTouchStart : function(e)
18752 this.swiping = false;
18754 this.startX = e.browserEvent.touches[0].clientX;
18755 this.startY = e.browserEvent.touches[0].clientY;
18758 onTouchMove : function(e)
18760 this.swiping = true;
18762 this.endX = e.browserEvent.touches[0].clientX;
18763 this.endY = e.browserEvent.touches[0].clientY;
18766 onTouchEnd : function(e)
18773 var tabGroup = this.parent();
18775 if(this.endX > this.startX){ // swiping right
18776 tabGroup.showPanelPrev();
18780 if(this.startX > this.endX){ // swiping left
18781 tabGroup.showPanelNext();
18800 * @class Roo.bootstrap.DateField
18801 * @extends Roo.bootstrap.Input
18802 * Bootstrap DateField class
18803 * @cfg {Number} weekStart default 0
18804 * @cfg {String} viewMode default empty, (months|years)
18805 * @cfg {String} minViewMode default empty, (months|years)
18806 * @cfg {Number} startDate default -Infinity
18807 * @cfg {Number} endDate default Infinity
18808 * @cfg {Boolean} todayHighlight default false
18809 * @cfg {Boolean} todayBtn default false
18810 * @cfg {Boolean} calendarWeeks default false
18811 * @cfg {Object} daysOfWeekDisabled default empty
18812 * @cfg {Boolean} singleMode default false (true | false)
18814 * @cfg {Boolean} keyboardNavigation default true
18815 * @cfg {String} language default en
18818 * Create a new DateField
18819 * @param {Object} config The config object
18822 Roo.bootstrap.DateField = function(config){
18823 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18827 * Fires when this field show.
18828 * @param {Roo.bootstrap.DateField} this
18829 * @param {Mixed} date The date value
18834 * Fires when this field hide.
18835 * @param {Roo.bootstrap.DateField} this
18836 * @param {Mixed} date The date value
18841 * Fires when select a date.
18842 * @param {Roo.bootstrap.DateField} this
18843 * @param {Mixed} date The date value
18847 * @event beforeselect
18848 * Fires when before select a date.
18849 * @param {Roo.bootstrap.DateField} this
18850 * @param {Mixed} date The date value
18852 beforeselect : true
18856 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18859 * @cfg {String} format
18860 * The default date format string which can be overriden for localization support. The format must be
18861 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18865 * @cfg {String} altFormats
18866 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18867 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18869 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18877 todayHighlight : false,
18883 keyboardNavigation: true,
18885 calendarWeeks: false,
18887 startDate: -Infinity,
18891 daysOfWeekDisabled: [],
18895 singleMode : false,
18897 UTCDate: function()
18899 return new Date(Date.UTC.apply(Date, arguments));
18902 UTCToday: function()
18904 var today = new Date();
18905 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18908 getDate: function() {
18909 var d = this.getUTCDate();
18910 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18913 getUTCDate: function() {
18917 setDate: function(d) {
18918 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18921 setUTCDate: function(d) {
18923 this.setValue(this.formatDate(this.date));
18926 onRender: function(ct, position)
18929 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18931 this.language = this.language || 'en';
18932 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18933 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18935 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18936 this.format = this.format || 'm/d/y';
18937 this.isInline = false;
18938 this.isInput = true;
18939 this.component = this.el.select('.add-on', true).first() || false;
18940 this.component = (this.component && this.component.length === 0) ? false : this.component;
18941 this.hasInput = this.component && this.inputEl().length;
18943 if (typeof(this.minViewMode === 'string')) {
18944 switch (this.minViewMode) {
18946 this.minViewMode = 1;
18949 this.minViewMode = 2;
18952 this.minViewMode = 0;
18957 if (typeof(this.viewMode === 'string')) {
18958 switch (this.viewMode) {
18971 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18973 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18975 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18977 this.picker().on('mousedown', this.onMousedown, this);
18978 this.picker().on('click', this.onClick, this);
18980 this.picker().addClass('datepicker-dropdown');
18982 this.startViewMode = this.viewMode;
18984 if(this.singleMode){
18985 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18986 v.setVisibilityMode(Roo.Element.DISPLAY);
18990 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18991 v.setStyle('width', '189px');
18995 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18996 if(!this.calendarWeeks){
19001 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19002 v.attr('colspan', function(i, val){
19003 return parseInt(val) + 1;
19008 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
19010 this.setStartDate(this.startDate);
19011 this.setEndDate(this.endDate);
19013 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
19020 if(this.isInline) {
19025 picker : function()
19027 return this.pickerEl;
19028 // return this.el.select('.datepicker', true).first();
19031 fillDow: function()
19033 var dowCnt = this.weekStart;
19042 if(this.calendarWeeks){
19050 while (dowCnt < this.weekStart + 7) {
19054 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19058 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19061 fillMonths: function()
19064 var months = this.picker().select('>.datepicker-months td', true).first();
19066 months.dom.innerHTML = '';
19072 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19075 months.createChild(month);
19082 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;
19084 if (this.date < this.startDate) {
19085 this.viewDate = new Date(this.startDate);
19086 } else if (this.date > this.endDate) {
19087 this.viewDate = new Date(this.endDate);
19089 this.viewDate = new Date(this.date);
19097 var d = new Date(this.viewDate),
19098 year = d.getUTCFullYear(),
19099 month = d.getUTCMonth(),
19100 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19101 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19102 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19103 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19104 currentDate = this.date && this.date.valueOf(),
19105 today = this.UTCToday();
19107 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19109 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19111 // this.picker.select('>tfoot th.today').
19112 // .text(dates[this.language].today)
19113 // .toggle(this.todayBtn !== false);
19115 this.updateNavArrows();
19118 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19120 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19122 prevMonth.setUTCDate(day);
19124 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19126 var nextMonth = new Date(prevMonth);
19128 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19130 nextMonth = nextMonth.valueOf();
19132 var fillMonths = false;
19134 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19136 while(prevMonth.valueOf() <= nextMonth) {
19139 if (prevMonth.getUTCDay() === this.weekStart) {
19141 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19149 if(this.calendarWeeks){
19150 // ISO 8601: First week contains first thursday.
19151 // ISO also states week starts on Monday, but we can be more abstract here.
19153 // Start of current week: based on weekstart/current date
19154 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19155 // Thursday of this week
19156 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19157 // First Thursday of year, year from thursday
19158 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19159 // Calendar week: ms between thursdays, div ms per day, div 7 days
19160 calWeek = (th - yth) / 864e5 / 7 + 1;
19162 fillMonths.cn.push({
19170 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19172 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19175 if (this.todayHighlight &&
19176 prevMonth.getUTCFullYear() == today.getFullYear() &&
19177 prevMonth.getUTCMonth() == today.getMonth() &&
19178 prevMonth.getUTCDate() == today.getDate()) {
19179 clsName += ' today';
19182 if (currentDate && prevMonth.valueOf() === currentDate) {
19183 clsName += ' active';
19186 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19187 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19188 clsName += ' disabled';
19191 fillMonths.cn.push({
19193 cls: 'day ' + clsName,
19194 html: prevMonth.getDate()
19197 prevMonth.setDate(prevMonth.getDate()+1);
19200 var currentYear = this.date && this.date.getUTCFullYear();
19201 var currentMonth = this.date && this.date.getUTCMonth();
19203 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19205 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19206 v.removeClass('active');
19208 if(currentYear === year && k === currentMonth){
19209 v.addClass('active');
19212 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19213 v.addClass('disabled');
19219 year = parseInt(year/10, 10) * 10;
19221 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19223 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19226 for (var i = -1; i < 11; i++) {
19227 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19229 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19237 showMode: function(dir)
19240 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19243 Roo.each(this.picker().select('>div',true).elements, function(v){
19244 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19247 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19252 if(this.isInline) {
19256 this.picker().removeClass(['bottom', 'top']);
19258 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19260 * place to the top of element!
19264 this.picker().addClass('top');
19265 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19270 this.picker().addClass('bottom');
19272 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19275 parseDate : function(value)
19277 if(!value || value instanceof Date){
19280 var v = Date.parseDate(value, this.format);
19281 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19282 v = Date.parseDate(value, 'Y-m-d');
19284 if(!v && this.altFormats){
19285 if(!this.altFormatsArray){
19286 this.altFormatsArray = this.altFormats.split("|");
19288 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19289 v = Date.parseDate(value, this.altFormatsArray[i]);
19295 formatDate : function(date, fmt)
19297 return (!date || !(date instanceof Date)) ?
19298 date : date.dateFormat(fmt || this.format);
19301 onFocus : function()
19303 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19307 onBlur : function()
19309 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19311 var d = this.inputEl().getValue();
19318 showPopup : function()
19320 this.picker().show();
19324 this.fireEvent('showpopup', this, this.date);
19327 hidePopup : function()
19329 if(this.isInline) {
19332 this.picker().hide();
19333 this.viewMode = this.startViewMode;
19336 this.fireEvent('hidepopup', this, this.date);
19340 onMousedown: function(e)
19342 e.stopPropagation();
19343 e.preventDefault();
19348 Roo.bootstrap.DateField.superclass.keyup.call(this);
19352 setValue: function(v)
19354 if(this.fireEvent('beforeselect', this, v) !== false){
19355 var d = new Date(this.parseDate(v) ).clearTime();
19357 if(isNaN(d.getTime())){
19358 this.date = this.viewDate = '';
19359 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19363 v = this.formatDate(d);
19365 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19367 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19371 this.fireEvent('select', this, this.date);
19375 getValue: function()
19377 return this.formatDate(this.date);
19380 fireKey: function(e)
19382 if (!this.picker().isVisible()){
19383 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19389 var dateChanged = false,
19391 newDate, newViewDate;
19396 e.preventDefault();
19400 if (!this.keyboardNavigation) {
19403 dir = e.keyCode == 37 ? -1 : 1;
19406 newDate = this.moveYear(this.date, dir);
19407 newViewDate = this.moveYear(this.viewDate, dir);
19408 } else if (e.shiftKey){
19409 newDate = this.moveMonth(this.date, dir);
19410 newViewDate = this.moveMonth(this.viewDate, dir);
19412 newDate = new Date(this.date);
19413 newDate.setUTCDate(this.date.getUTCDate() + dir);
19414 newViewDate = new Date(this.viewDate);
19415 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19417 if (this.dateWithinRange(newDate)){
19418 this.date = newDate;
19419 this.viewDate = newViewDate;
19420 this.setValue(this.formatDate(this.date));
19422 e.preventDefault();
19423 dateChanged = true;
19428 if (!this.keyboardNavigation) {
19431 dir = e.keyCode == 38 ? -1 : 1;
19433 newDate = this.moveYear(this.date, dir);
19434 newViewDate = this.moveYear(this.viewDate, dir);
19435 } else if (e.shiftKey){
19436 newDate = this.moveMonth(this.date, dir);
19437 newViewDate = this.moveMonth(this.viewDate, dir);
19439 newDate = new Date(this.date);
19440 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19441 newViewDate = new Date(this.viewDate);
19442 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19444 if (this.dateWithinRange(newDate)){
19445 this.date = newDate;
19446 this.viewDate = newViewDate;
19447 this.setValue(this.formatDate(this.date));
19449 e.preventDefault();
19450 dateChanged = true;
19454 this.setValue(this.formatDate(this.date));
19456 e.preventDefault();
19459 this.setValue(this.formatDate(this.date));
19473 onClick: function(e)
19475 e.stopPropagation();
19476 e.preventDefault();
19478 var target = e.getTarget();
19480 if(target.nodeName.toLowerCase() === 'i'){
19481 target = Roo.get(target).dom.parentNode;
19484 var nodeName = target.nodeName;
19485 var className = target.className;
19486 var html = target.innerHTML;
19487 //Roo.log(nodeName);
19489 switch(nodeName.toLowerCase()) {
19491 switch(className) {
19497 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19498 switch(this.viewMode){
19500 this.viewDate = this.moveMonth(this.viewDate, dir);
19504 this.viewDate = this.moveYear(this.viewDate, dir);
19510 var date = new Date();
19511 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19513 this.setValue(this.formatDate(this.date));
19520 if (className.indexOf('disabled') < 0) {
19521 this.viewDate.setUTCDate(1);
19522 if (className.indexOf('month') > -1) {
19523 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19525 var year = parseInt(html, 10) || 0;
19526 this.viewDate.setUTCFullYear(year);
19530 if(this.singleMode){
19531 this.setValue(this.formatDate(this.viewDate));
19542 //Roo.log(className);
19543 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19544 var day = parseInt(html, 10) || 1;
19545 var year = this.viewDate.getUTCFullYear(),
19546 month = this.viewDate.getUTCMonth();
19548 if (className.indexOf('old') > -1) {
19555 } else if (className.indexOf('new') > -1) {
19563 //Roo.log([year,month,day]);
19564 this.date = this.UTCDate(year, month, day,0,0,0,0);
19565 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19567 //Roo.log(this.formatDate(this.date));
19568 this.setValue(this.formatDate(this.date));
19575 setStartDate: function(startDate)
19577 this.startDate = startDate || -Infinity;
19578 if (this.startDate !== -Infinity) {
19579 this.startDate = this.parseDate(this.startDate);
19582 this.updateNavArrows();
19585 setEndDate: function(endDate)
19587 this.endDate = endDate || Infinity;
19588 if (this.endDate !== Infinity) {
19589 this.endDate = this.parseDate(this.endDate);
19592 this.updateNavArrows();
19595 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19597 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19598 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19599 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19601 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19602 return parseInt(d, 10);
19605 this.updateNavArrows();
19608 updateNavArrows: function()
19610 if(this.singleMode){
19614 var d = new Date(this.viewDate),
19615 year = d.getUTCFullYear(),
19616 month = d.getUTCMonth();
19618 Roo.each(this.picker().select('.prev', true).elements, function(v){
19620 switch (this.viewMode) {
19623 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19629 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19636 Roo.each(this.picker().select('.next', true).elements, function(v){
19638 switch (this.viewMode) {
19641 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19647 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19655 moveMonth: function(date, dir)
19660 var new_date = new Date(date.valueOf()),
19661 day = new_date.getUTCDate(),
19662 month = new_date.getUTCMonth(),
19663 mag = Math.abs(dir),
19665 dir = dir > 0 ? 1 : -1;
19668 // If going back one month, make sure month is not current month
19669 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19671 return new_date.getUTCMonth() == month;
19673 // If going forward one month, make sure month is as expected
19674 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19676 return new_date.getUTCMonth() != new_month;
19678 new_month = month + dir;
19679 new_date.setUTCMonth(new_month);
19680 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19681 if (new_month < 0 || new_month > 11) {
19682 new_month = (new_month + 12) % 12;
19685 // For magnitudes >1, move one month at a time...
19686 for (var i=0; i<mag; i++) {
19687 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19688 new_date = this.moveMonth(new_date, dir);
19690 // ...then reset the day, keeping it in the new month
19691 new_month = new_date.getUTCMonth();
19692 new_date.setUTCDate(day);
19694 return new_month != new_date.getUTCMonth();
19697 // Common date-resetting loop -- if date is beyond end of month, make it
19700 new_date.setUTCDate(--day);
19701 new_date.setUTCMonth(new_month);
19706 moveYear: function(date, dir)
19708 return this.moveMonth(date, dir*12);
19711 dateWithinRange: function(date)
19713 return date >= this.startDate && date <= this.endDate;
19719 this.picker().remove();
19722 validateValue : function(value)
19724 if(this.getVisibilityEl().hasClass('hidden')){
19728 if(value.length < 1) {
19729 if(this.allowBlank){
19735 if(value.length < this.minLength){
19738 if(value.length > this.maxLength){
19742 var vt = Roo.form.VTypes;
19743 if(!vt[this.vtype](value, this)){
19747 if(typeof this.validator == "function"){
19748 var msg = this.validator(value);
19754 if(this.regex && !this.regex.test(value)){
19758 if(typeof(this.parseDate(value)) == 'undefined'){
19762 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19766 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19776 this.date = this.viewDate = '';
19778 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19783 Roo.apply(Roo.bootstrap.DateField, {
19794 html: '<i class="fa fa-arrow-left"/>'
19804 html: '<i class="fa fa-arrow-right"/>'
19846 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19847 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19848 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19849 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19850 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19863 navFnc: 'FullYear',
19868 navFnc: 'FullYear',
19873 Roo.apply(Roo.bootstrap.DateField, {
19877 cls: 'datepicker dropdown-menu roo-dynamic',
19881 cls: 'datepicker-days',
19885 cls: 'table-condensed',
19887 Roo.bootstrap.DateField.head,
19891 Roo.bootstrap.DateField.footer
19898 cls: 'datepicker-months',
19902 cls: 'table-condensed',
19904 Roo.bootstrap.DateField.head,
19905 Roo.bootstrap.DateField.content,
19906 Roo.bootstrap.DateField.footer
19913 cls: 'datepicker-years',
19917 cls: 'table-condensed',
19919 Roo.bootstrap.DateField.head,
19920 Roo.bootstrap.DateField.content,
19921 Roo.bootstrap.DateField.footer
19940 * @class Roo.bootstrap.TimeField
19941 * @extends Roo.bootstrap.Input
19942 * Bootstrap DateField class
19946 * Create a new TimeField
19947 * @param {Object} config The config object
19950 Roo.bootstrap.TimeField = function(config){
19951 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19955 * Fires when this field show.
19956 * @param {Roo.bootstrap.DateField} thisthis
19957 * @param {Mixed} date The date value
19962 * Fires when this field hide.
19963 * @param {Roo.bootstrap.DateField} this
19964 * @param {Mixed} date The date value
19969 * Fires when select a date.
19970 * @param {Roo.bootstrap.DateField} this
19971 * @param {Mixed} date The date value
19977 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19980 * @cfg {String} format
19981 * The default time format string which can be overriden for localization support. The format must be
19982 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19986 onRender: function(ct, position)
19989 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19991 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19993 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19995 this.pop = this.picker().select('>.datepicker-time',true).first();
19996 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19998 this.picker().on('mousedown', this.onMousedown, this);
19999 this.picker().on('click', this.onClick, this);
20001 this.picker().addClass('datepicker-dropdown');
20006 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
20007 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
20008 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
20009 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
20010 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
20011 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
20015 fireKey: function(e){
20016 if (!this.picker().isVisible()){
20017 if (e.keyCode == 27) { // allow escape to hide and re-show picker
20023 e.preventDefault();
20031 this.onTogglePeriod();
20034 this.onIncrementMinutes();
20037 this.onDecrementMinutes();
20046 onClick: function(e) {
20047 e.stopPropagation();
20048 e.preventDefault();
20051 picker : function()
20053 return this.el.select('.datepicker', true).first();
20056 fillTime: function()
20058 var time = this.pop.select('tbody', true).first();
20060 time.dom.innerHTML = '';
20075 cls: 'hours-up glyphicon glyphicon-chevron-up'
20095 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20116 cls: 'timepicker-hour',
20131 cls: 'timepicker-minute',
20146 cls: 'btn btn-primary period',
20168 cls: 'hours-down glyphicon glyphicon-chevron-down'
20188 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20206 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20213 var hours = this.time.getHours();
20214 var minutes = this.time.getMinutes();
20227 hours = hours - 12;
20231 hours = '0' + hours;
20235 minutes = '0' + minutes;
20238 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20239 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20240 this.pop.select('button', true).first().dom.innerHTML = period;
20246 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20248 var cls = ['bottom'];
20250 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20257 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20262 this.picker().addClass(cls.join('-'));
20266 Roo.each(cls, function(c){
20268 _this.picker().setTop(_this.inputEl().getHeight());
20272 _this.picker().setTop(0 - _this.picker().getHeight());
20277 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20281 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20288 onFocus : function()
20290 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20294 onBlur : function()
20296 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20302 this.picker().show();
20307 this.fireEvent('show', this, this.date);
20312 this.picker().hide();
20315 this.fireEvent('hide', this, this.date);
20318 setTime : function()
20321 this.setValue(this.time.format(this.format));
20323 this.fireEvent('select', this, this.date);
20328 onMousedown: function(e){
20329 e.stopPropagation();
20330 e.preventDefault();
20333 onIncrementHours: function()
20335 Roo.log('onIncrementHours');
20336 this.time = this.time.add(Date.HOUR, 1);
20341 onDecrementHours: function()
20343 Roo.log('onDecrementHours');
20344 this.time = this.time.add(Date.HOUR, -1);
20348 onIncrementMinutes: function()
20350 Roo.log('onIncrementMinutes');
20351 this.time = this.time.add(Date.MINUTE, 1);
20355 onDecrementMinutes: function()
20357 Roo.log('onDecrementMinutes');
20358 this.time = this.time.add(Date.MINUTE, -1);
20362 onTogglePeriod: function()
20364 Roo.log('onTogglePeriod');
20365 this.time = this.time.add(Date.HOUR, 12);
20372 Roo.apply(Roo.bootstrap.TimeField, {
20402 cls: 'btn btn-info ok',
20414 Roo.apply(Roo.bootstrap.TimeField, {
20418 cls: 'datepicker dropdown-menu',
20422 cls: 'datepicker-time',
20426 cls: 'table-condensed',
20428 Roo.bootstrap.TimeField.content,
20429 Roo.bootstrap.TimeField.footer
20448 * @class Roo.bootstrap.MonthField
20449 * @extends Roo.bootstrap.Input
20450 * Bootstrap MonthField class
20452 * @cfg {String} language default en
20455 * Create a new MonthField
20456 * @param {Object} config The config object
20459 Roo.bootstrap.MonthField = function(config){
20460 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20465 * Fires when this field show.
20466 * @param {Roo.bootstrap.MonthField} this
20467 * @param {Mixed} date The date value
20472 * Fires when this field hide.
20473 * @param {Roo.bootstrap.MonthField} this
20474 * @param {Mixed} date The date value
20479 * Fires when select a date.
20480 * @param {Roo.bootstrap.MonthField} this
20481 * @param {String} oldvalue The old value
20482 * @param {String} newvalue The new value
20488 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20490 onRender: function(ct, position)
20493 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20495 this.language = this.language || 'en';
20496 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20497 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20499 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20500 this.isInline = false;
20501 this.isInput = true;
20502 this.component = this.el.select('.add-on', true).first() || false;
20503 this.component = (this.component && this.component.length === 0) ? false : this.component;
20504 this.hasInput = this.component && this.inputEL().length;
20506 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20508 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20510 this.picker().on('mousedown', this.onMousedown, this);
20511 this.picker().on('click', this.onClick, this);
20513 this.picker().addClass('datepicker-dropdown');
20515 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20516 v.setStyle('width', '189px');
20523 if(this.isInline) {
20529 setValue: function(v, suppressEvent)
20531 var o = this.getValue();
20533 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20537 if(suppressEvent !== true){
20538 this.fireEvent('select', this, o, v);
20543 getValue: function()
20548 onClick: function(e)
20550 e.stopPropagation();
20551 e.preventDefault();
20553 var target = e.getTarget();
20555 if(target.nodeName.toLowerCase() === 'i'){
20556 target = Roo.get(target).dom.parentNode;
20559 var nodeName = target.nodeName;
20560 var className = target.className;
20561 var html = target.innerHTML;
20563 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20567 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20569 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20575 picker : function()
20577 return this.pickerEl;
20580 fillMonths: function()
20583 var months = this.picker().select('>.datepicker-months td', true).first();
20585 months.dom.innerHTML = '';
20591 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20594 months.createChild(month);
20603 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20604 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20607 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20608 e.removeClass('active');
20610 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20611 e.addClass('active');
20618 if(this.isInline) {
20622 this.picker().removeClass(['bottom', 'top']);
20624 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20626 * place to the top of element!
20630 this.picker().addClass('top');
20631 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20636 this.picker().addClass('bottom');
20638 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20641 onFocus : function()
20643 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20647 onBlur : function()
20649 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20651 var d = this.inputEl().getValue();
20660 this.picker().show();
20661 this.picker().select('>.datepicker-months', true).first().show();
20665 this.fireEvent('show', this, this.date);
20670 if(this.isInline) {
20673 this.picker().hide();
20674 this.fireEvent('hide', this, this.date);
20678 onMousedown: function(e)
20680 e.stopPropagation();
20681 e.preventDefault();
20686 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20690 fireKey: function(e)
20692 if (!this.picker().isVisible()){
20693 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20704 e.preventDefault();
20708 dir = e.keyCode == 37 ? -1 : 1;
20710 this.vIndex = this.vIndex + dir;
20712 if(this.vIndex < 0){
20716 if(this.vIndex > 11){
20720 if(isNaN(this.vIndex)){
20724 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20730 dir = e.keyCode == 38 ? -1 : 1;
20732 this.vIndex = this.vIndex + dir * 4;
20734 if(this.vIndex < 0){
20738 if(this.vIndex > 11){
20742 if(isNaN(this.vIndex)){
20746 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20751 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20752 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20756 e.preventDefault();
20759 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20760 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20776 this.picker().remove();
20781 Roo.apply(Roo.bootstrap.MonthField, {
20800 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20801 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20806 Roo.apply(Roo.bootstrap.MonthField, {
20810 cls: 'datepicker dropdown-menu roo-dynamic',
20814 cls: 'datepicker-months',
20818 cls: 'table-condensed',
20820 Roo.bootstrap.DateField.content
20840 * @class Roo.bootstrap.CheckBox
20841 * @extends Roo.bootstrap.Input
20842 * Bootstrap CheckBox class
20844 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20845 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20846 * @cfg {String} boxLabel The text that appears beside the checkbox
20847 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20848 * @cfg {Boolean} checked initnal the element
20849 * @cfg {Boolean} inline inline the element (default false)
20850 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20851 * @cfg {String} tooltip label tooltip
20854 * Create a new CheckBox
20855 * @param {Object} config The config object
20858 Roo.bootstrap.CheckBox = function(config){
20859 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20864 * Fires when the element is checked or unchecked.
20865 * @param {Roo.bootstrap.CheckBox} this This input
20866 * @param {Boolean} checked The new checked value
20871 * Fires when the element is click.
20872 * @param {Roo.bootstrap.CheckBox} this This input
20879 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20881 inputType: 'checkbox',
20890 getAutoCreate : function()
20892 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20898 cfg.cls = 'form-group ' + this.inputType; //input-group
20901 cfg.cls += ' ' + this.inputType + '-inline';
20907 type : this.inputType,
20908 value : this.inputValue,
20909 cls : 'roo-' + this.inputType, //'form-box',
20910 placeholder : this.placeholder || ''
20914 if(this.inputType != 'radio'){
20918 cls : 'roo-hidden-value',
20919 value : this.checked ? this.inputValue : this.valueOff
20924 if (this.weight) { // Validity check?
20925 cfg.cls += " " + this.inputType + "-" + this.weight;
20928 if (this.disabled) {
20929 input.disabled=true;
20933 input.checked = this.checked;
20938 input.name = this.name;
20940 if(this.inputType != 'radio'){
20941 hidden.name = this.name;
20942 input.name = '_hidden_' + this.name;
20947 input.cls += ' input-' + this.size;
20952 ['xs','sm','md','lg'].map(function(size){
20953 if (settings[size]) {
20954 cfg.cls += ' col-' + size + '-' + settings[size];
20958 var inputblock = input;
20960 if (this.before || this.after) {
20963 cls : 'input-group',
20968 inputblock.cn.push({
20970 cls : 'input-group-addon',
20975 inputblock.cn.push(input);
20977 if(this.inputType != 'radio'){
20978 inputblock.cn.push(hidden);
20982 inputblock.cn.push({
20984 cls : 'input-group-addon',
20991 if (align ==='left' && this.fieldLabel.length) {
20992 // Roo.log("left and has label");
20997 cls : 'control-label',
20998 html : this.fieldLabel
21008 if(this.labelWidth > 12){
21009 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
21012 if(this.labelWidth < 13 && this.labelmd == 0){
21013 this.labelmd = this.labelWidth;
21016 if(this.labellg > 0){
21017 cfg.cn[0].cls += ' col-lg-' + this.labellg;
21018 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
21021 if(this.labelmd > 0){
21022 cfg.cn[0].cls += ' col-md-' + this.labelmd;
21023 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
21026 if(this.labelsm > 0){
21027 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
21028 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
21031 if(this.labelxs > 0){
21032 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
21033 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
21036 } else if ( this.fieldLabel.length) {
21037 // Roo.log(" label");
21041 tag: this.boxLabel ? 'span' : 'label',
21043 cls: 'control-label box-input-label',
21044 //cls : 'input-group-addon',
21045 html : this.fieldLabel
21054 // Roo.log(" no label && no align");
21055 cfg.cn = [ inputblock ] ;
21061 var boxLabelCfg = {
21063 //'for': id, // box label is handled by onclick - so no for...
21065 html: this.boxLabel
21069 boxLabelCfg.tooltip = this.tooltip;
21072 cfg.cn.push(boxLabelCfg);
21075 if(this.inputType != 'radio'){
21076 cfg.cn.push(hidden);
21084 * return the real input element.
21086 inputEl: function ()
21088 return this.el.select('input.roo-' + this.inputType,true).first();
21090 hiddenEl: function ()
21092 return this.el.select('input.roo-hidden-value',true).first();
21095 labelEl: function()
21097 return this.el.select('label.control-label',true).first();
21099 /* depricated... */
21103 return this.labelEl();
21106 boxLabelEl: function()
21108 return this.el.select('label.box-label',true).first();
21111 initEvents : function()
21113 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21115 this.inputEl().on('click', this.onClick, this);
21117 if (this.boxLabel) {
21118 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21121 this.startValue = this.getValue();
21124 Roo.bootstrap.CheckBox.register(this);
21128 onClick : function(e)
21130 if(this.fireEvent('click', this, e) !== false){
21131 this.setChecked(!this.checked);
21136 setChecked : function(state,suppressEvent)
21138 this.startValue = this.getValue();
21140 if(this.inputType == 'radio'){
21142 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21143 e.dom.checked = false;
21146 this.inputEl().dom.checked = true;
21148 this.inputEl().dom.value = this.inputValue;
21150 if(suppressEvent !== true){
21151 this.fireEvent('check', this, true);
21159 this.checked = state;
21161 this.inputEl().dom.checked = state;
21164 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21166 if(suppressEvent !== true){
21167 this.fireEvent('check', this, state);
21173 getValue : function()
21175 if(this.inputType == 'radio'){
21176 return this.getGroupValue();
21179 return this.hiddenEl().dom.value;
21183 getGroupValue : function()
21185 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21189 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21192 setValue : function(v,suppressEvent)
21194 if(this.inputType == 'radio'){
21195 this.setGroupValue(v, suppressEvent);
21199 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21204 setGroupValue : function(v, suppressEvent)
21206 this.startValue = this.getValue();
21208 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21209 e.dom.checked = false;
21211 if(e.dom.value == v){
21212 e.dom.checked = true;
21216 if(suppressEvent !== true){
21217 this.fireEvent('check', this, true);
21225 validate : function()
21227 if(this.getVisibilityEl().hasClass('hidden')){
21233 (this.inputType == 'radio' && this.validateRadio()) ||
21234 (this.inputType == 'checkbox' && this.validateCheckbox())
21240 this.markInvalid();
21244 validateRadio : function()
21246 if(this.getVisibilityEl().hasClass('hidden')){
21250 if(this.allowBlank){
21256 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21257 if(!e.dom.checked){
21269 validateCheckbox : function()
21272 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21273 //return (this.getValue() == this.inputValue) ? true : false;
21276 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21284 for(var i in group){
21285 if(group[i].el.isVisible(true)){
21293 for(var i in group){
21298 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21305 * Mark this field as valid
21307 markValid : function()
21311 this.fireEvent('valid', this);
21313 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21316 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21323 if(this.inputType == 'radio'){
21324 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21325 var fg = e.findParent('.form-group', false, true);
21326 if (Roo.bootstrap.version == 3) {
21327 fg.removeClass([_this.invalidClass, _this.validClass]);
21328 fg.addClass(_this.validClass);
21330 fg.removeClass(['is-valid', 'is-invalid']);
21331 fg.addClass('is-valid');
21339 var fg = this.el.findParent('.form-group', false, true);
21340 if (Roo.bootstrap.version == 3) {
21341 fg.removeClass([this.invalidClass, this.validClass]);
21342 fg.addClass(this.validClass);
21344 fg.removeClass(['is-valid', 'is-invalid']);
21345 fg.addClass('is-valid');
21350 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21356 for(var i in group){
21357 var fg = group[i].el.findParent('.form-group', false, true);
21358 if (Roo.bootstrap.version == 3) {
21359 fg.removeClass([this.invalidClass, this.validClass]);
21360 fg.addClass(this.validClass);
21362 fg.removeClass(['is-valid', 'is-invalid']);
21363 fg.addClass('is-valid');
21369 * Mark this field as invalid
21370 * @param {String} msg The validation message
21372 markInvalid : function(msg)
21374 if(this.allowBlank){
21380 this.fireEvent('invalid', this, msg);
21382 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21385 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21389 label.markInvalid();
21392 if(this.inputType == 'radio'){
21394 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21395 var fg = e.findParent('.form-group', false, true);
21396 if (Roo.bootstrap.version == 3) {
21397 fg.removeClass([_this.invalidClass, _this.validClass]);
21398 fg.addClass(_this.invalidClass);
21400 fg.removeClass(['is-invalid', 'is-valid']);
21401 fg.addClass('is-invalid');
21409 var fg = this.el.findParent('.form-group', false, true);
21410 if (Roo.bootstrap.version == 3) {
21411 fg.removeClass([_this.invalidClass, _this.validClass]);
21412 fg.addClass(_this.invalidClass);
21414 fg.removeClass(['is-invalid', 'is-valid']);
21415 fg.addClass('is-invalid');
21420 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21426 for(var i in group){
21427 var fg = group[i].el.findParent('.form-group', false, true);
21428 if (Roo.bootstrap.version == 3) {
21429 fg.removeClass([_this.invalidClass, _this.validClass]);
21430 fg.addClass(_this.invalidClass);
21432 fg.removeClass(['is-invalid', 'is-valid']);
21433 fg.addClass('is-invalid');
21439 clearInvalid : function()
21441 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21443 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21445 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21447 if (label && label.iconEl) {
21448 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21449 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21453 disable : function()
21455 if(this.inputType != 'radio'){
21456 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21463 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21464 _this.getActionEl().addClass(this.disabledClass);
21465 e.dom.disabled = true;
21469 this.disabled = true;
21470 this.fireEvent("disable", this);
21474 enable : function()
21476 if(this.inputType != 'radio'){
21477 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21484 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21485 _this.getActionEl().removeClass(this.disabledClass);
21486 e.dom.disabled = false;
21490 this.disabled = false;
21491 this.fireEvent("enable", this);
21495 setBoxLabel : function(v)
21500 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21506 Roo.apply(Roo.bootstrap.CheckBox, {
21511 * register a CheckBox Group
21512 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21514 register : function(checkbox)
21516 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21517 this.groups[checkbox.groupId] = {};
21520 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21524 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21528 * fetch a CheckBox Group based on the group ID
21529 * @param {string} the group ID
21530 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21532 get: function(groupId) {
21533 if (typeof(this.groups[groupId]) == 'undefined') {
21537 return this.groups[groupId] ;
21550 * @class Roo.bootstrap.Radio
21551 * @extends Roo.bootstrap.Component
21552 * Bootstrap Radio class
21553 * @cfg {String} boxLabel - the label associated
21554 * @cfg {String} value - the value of radio
21557 * Create a new Radio
21558 * @param {Object} config The config object
21560 Roo.bootstrap.Radio = function(config){
21561 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21565 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21571 getAutoCreate : function()
21575 cls : 'form-group radio',
21580 html : this.boxLabel
21588 initEvents : function()
21590 this.parent().register(this);
21592 this.el.on('click', this.onClick, this);
21596 onClick : function(e)
21598 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21599 this.setChecked(true);
21603 setChecked : function(state, suppressEvent)
21605 this.parent().setValue(this.value, suppressEvent);
21609 setBoxLabel : function(v)
21614 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21629 * @class Roo.bootstrap.SecurePass
21630 * @extends Roo.bootstrap.Input
21631 * Bootstrap SecurePass class
21635 * Create a new SecurePass
21636 * @param {Object} config The config object
21639 Roo.bootstrap.SecurePass = function (config) {
21640 // these go here, so the translation tool can replace them..
21642 PwdEmpty: "Please type a password, and then retype it to confirm.",
21643 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21644 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21645 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21646 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21647 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21648 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21649 TooWeak: "Your password is Too Weak."
21651 this.meterLabel = "Password strength:";
21652 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21653 this.meterClass = [
21654 "roo-password-meter-tooweak",
21655 "roo-password-meter-weak",
21656 "roo-password-meter-medium",
21657 "roo-password-meter-strong",
21658 "roo-password-meter-grey"
21663 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21666 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21668 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21670 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21671 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21672 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21673 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21674 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21675 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21676 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21686 * @cfg {String/Object} Label for the strength meter (defaults to
21687 * 'Password strength:')
21692 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21693 * ['Weak', 'Medium', 'Strong'])
21696 pwdStrengths: false,
21709 initEvents: function ()
21711 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21713 if (this.el.is('input[type=password]') && Roo.isSafari) {
21714 this.el.on('keydown', this.SafariOnKeyDown, this);
21717 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21720 onRender: function (ct, position)
21722 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21723 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21724 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21726 this.trigger.createChild({
21731 cls: 'roo-password-meter-grey col-xs-12',
21734 //width: this.meterWidth + 'px'
21738 cls: 'roo-password-meter-text'
21744 if (this.hideTrigger) {
21745 this.trigger.setDisplayed(false);
21747 this.setSize(this.width || '', this.height || '');
21750 onDestroy: function ()
21752 if (this.trigger) {
21753 this.trigger.removeAllListeners();
21754 this.trigger.remove();
21757 this.wrap.remove();
21759 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21762 checkStrength: function ()
21764 var pwd = this.inputEl().getValue();
21765 if (pwd == this._lastPwd) {
21770 if (this.ClientSideStrongPassword(pwd)) {
21772 } else if (this.ClientSideMediumPassword(pwd)) {
21774 } else if (this.ClientSideWeakPassword(pwd)) {
21780 Roo.log('strength1: ' + strength);
21782 //var pm = this.trigger.child('div/div/div').dom;
21783 var pm = this.trigger.child('div/div');
21784 pm.removeClass(this.meterClass);
21785 pm.addClass(this.meterClass[strength]);
21788 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21790 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21792 this._lastPwd = pwd;
21796 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21798 this._lastPwd = '';
21800 var pm = this.trigger.child('div/div');
21801 pm.removeClass(this.meterClass);
21802 pm.addClass('roo-password-meter-grey');
21805 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21808 this.inputEl().dom.type='password';
21811 validateValue: function (value)
21814 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21817 if (value.length == 0) {
21818 if (this.allowBlank) {
21819 this.clearInvalid();
21823 this.markInvalid(this.errors.PwdEmpty);
21824 this.errorMsg = this.errors.PwdEmpty;
21832 if ('[\x21-\x7e]*'.match(value)) {
21833 this.markInvalid(this.errors.PwdBadChar);
21834 this.errorMsg = this.errors.PwdBadChar;
21837 if (value.length < 6) {
21838 this.markInvalid(this.errors.PwdShort);
21839 this.errorMsg = this.errors.PwdShort;
21842 if (value.length > 16) {
21843 this.markInvalid(this.errors.PwdLong);
21844 this.errorMsg = this.errors.PwdLong;
21848 if (this.ClientSideStrongPassword(value)) {
21850 } else if (this.ClientSideMediumPassword(value)) {
21852 } else if (this.ClientSideWeakPassword(value)) {
21859 if (strength < 2) {
21860 //this.markInvalid(this.errors.TooWeak);
21861 this.errorMsg = this.errors.TooWeak;
21866 console.log('strength2: ' + strength);
21868 //var pm = this.trigger.child('div/div/div').dom;
21870 var pm = this.trigger.child('div/div');
21871 pm.removeClass(this.meterClass);
21872 pm.addClass(this.meterClass[strength]);
21874 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21876 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21878 this.errorMsg = '';
21882 CharacterSetChecks: function (type)
21885 this.fResult = false;
21888 isctype: function (character, type)
21891 case this.kCapitalLetter:
21892 if (character >= 'A' && character <= 'Z') {
21897 case this.kSmallLetter:
21898 if (character >= 'a' && character <= 'z') {
21904 if (character >= '0' && character <= '9') {
21909 case this.kPunctuation:
21910 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21921 IsLongEnough: function (pwd, size)
21923 return !(pwd == null || isNaN(size) || pwd.length < size);
21926 SpansEnoughCharacterSets: function (word, nb)
21928 if (!this.IsLongEnough(word, nb))
21933 var characterSetChecks = new Array(
21934 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21935 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21938 for (var index = 0; index < word.length; ++index) {
21939 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21940 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21941 characterSetChecks[nCharSet].fResult = true;
21948 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21949 if (characterSetChecks[nCharSet].fResult) {
21954 if (nCharSets < nb) {
21960 ClientSideStrongPassword: function (pwd)
21962 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21965 ClientSideMediumPassword: function (pwd)
21967 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21970 ClientSideWeakPassword: function (pwd)
21972 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21975 })//<script type="text/javascript">
21978 * Based Ext JS Library 1.1.1
21979 * Copyright(c) 2006-2007, Ext JS, LLC.
21985 * @class Roo.HtmlEditorCore
21986 * @extends Roo.Component
21987 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21989 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21992 Roo.HtmlEditorCore = function(config){
21995 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
22000 * @event initialize
22001 * Fires when the editor is fully initialized (including the iframe)
22002 * @param {Roo.HtmlEditorCore} this
22007 * Fires when the editor is first receives the focus. Any insertion must wait
22008 * until after this event.
22009 * @param {Roo.HtmlEditorCore} this
22013 * @event beforesync
22014 * Fires before the textarea is updated with content from the editor iframe. Return false
22015 * to cancel the sync.
22016 * @param {Roo.HtmlEditorCore} this
22017 * @param {String} html
22021 * @event beforepush
22022 * Fires before the iframe editor is updated with content from the textarea. Return false
22023 * to cancel the push.
22024 * @param {Roo.HtmlEditorCore} this
22025 * @param {String} html
22030 * Fires when the textarea is updated with content from the editor iframe.
22031 * @param {Roo.HtmlEditorCore} this
22032 * @param {String} html
22037 * Fires when the iframe editor is updated with content from the textarea.
22038 * @param {Roo.HtmlEditorCore} this
22039 * @param {String} html
22044 * @event editorevent
22045 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22046 * @param {Roo.HtmlEditorCore} this
22052 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22054 // defaults : white / black...
22055 this.applyBlacklists();
22062 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22066 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22072 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22077 * @cfg {Number} height (in pixels)
22081 * @cfg {Number} width (in pixels)
22086 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22089 stylesheets: false,
22094 // private properties
22095 validationEvent : false,
22097 initialized : false,
22099 sourceEditMode : false,
22100 onFocus : Roo.emptyFn,
22102 hideMode:'offsets',
22106 // blacklist + whitelisted elements..
22113 * Protected method that will not generally be called directly. It
22114 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22115 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22117 getDocMarkup : function(){
22121 // inherit styels from page...??
22122 if (this.stylesheets === false) {
22124 Roo.get(document.head).select('style').each(function(node) {
22125 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22128 Roo.get(document.head).select('link').each(function(node) {
22129 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22132 } else if (!this.stylesheets.length) {
22134 st = '<style type="text/css">' +
22135 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22138 st = '<style type="text/css">' +
22143 st += '<style type="text/css">' +
22144 'IMG { cursor: pointer } ' +
22147 var cls = 'roo-htmleditor-body';
22149 if(this.bodyCls.length){
22150 cls += ' ' + this.bodyCls;
22153 return '<html><head>' + st +
22154 //<style type="text/css">' +
22155 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22157 ' </head><body class="' + cls + '"></body></html>';
22161 onRender : function(ct, position)
22164 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22165 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22168 this.el.dom.style.border = '0 none';
22169 this.el.dom.setAttribute('tabIndex', -1);
22170 this.el.addClass('x-hidden hide');
22174 if(Roo.isIE){ // fix IE 1px bogus margin
22175 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22179 this.frameId = Roo.id();
22183 var iframe = this.owner.wrap.createChild({
22185 cls: 'form-control', // bootstrap..
22187 name: this.frameId,
22188 frameBorder : 'no',
22189 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22194 this.iframe = iframe.dom;
22196 this.assignDocWin();
22198 this.doc.designMode = 'on';
22201 this.doc.write(this.getDocMarkup());
22205 var task = { // must defer to wait for browser to be ready
22207 //console.log("run task?" + this.doc.readyState);
22208 this.assignDocWin();
22209 if(this.doc.body || this.doc.readyState == 'complete'){
22211 this.doc.designMode="on";
22215 Roo.TaskMgr.stop(task);
22216 this.initEditor.defer(10, this);
22223 Roo.TaskMgr.start(task);
22228 onResize : function(w, h)
22230 Roo.log('resize: ' +w + ',' + h );
22231 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22235 if(typeof w == 'number'){
22237 this.iframe.style.width = w + 'px';
22239 if(typeof h == 'number'){
22241 this.iframe.style.height = h + 'px';
22243 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22250 * Toggles the editor between standard and source edit mode.
22251 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22253 toggleSourceEdit : function(sourceEditMode){
22255 this.sourceEditMode = sourceEditMode === true;
22257 if(this.sourceEditMode){
22259 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22262 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22263 //this.iframe.className = '';
22266 //this.setSize(this.owner.wrap.getSize());
22267 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22274 * Protected method that will not generally be called directly. If you need/want
22275 * custom HTML cleanup, this is the method you should override.
22276 * @param {String} html The HTML to be cleaned
22277 * return {String} The cleaned HTML
22279 cleanHtml : function(html){
22280 html = String(html);
22281 if(html.length > 5){
22282 if(Roo.isSafari){ // strip safari nonsense
22283 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22286 if(html == ' '){
22293 * HTML Editor -> Textarea
22294 * Protected method that will not generally be called directly. Syncs the contents
22295 * of the editor iframe with the textarea.
22297 syncValue : function(){
22298 if(this.initialized){
22299 var bd = (this.doc.body || this.doc.documentElement);
22300 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22301 var html = bd.innerHTML;
22303 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22304 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22306 html = '<div style="'+m[0]+'">' + html + '</div>';
22309 html = this.cleanHtml(html);
22310 // fix up the special chars.. normaly like back quotes in word...
22311 // however we do not want to do this with chinese..
22312 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22313 var cc = b.charCodeAt();
22315 (cc >= 0x4E00 && cc < 0xA000 ) ||
22316 (cc >= 0x3400 && cc < 0x4E00 ) ||
22317 (cc >= 0xf900 && cc < 0xfb00 )
22323 if(this.owner.fireEvent('beforesync', this, html) !== false){
22324 this.el.dom.value = html;
22325 this.owner.fireEvent('sync', this, html);
22331 * Protected method that will not generally be called directly. Pushes the value of the textarea
22332 * into the iframe editor.
22334 pushValue : function(){
22335 if(this.initialized){
22336 var v = this.el.dom.value.trim();
22338 // if(v.length < 1){
22342 if(this.owner.fireEvent('beforepush', this, v) !== false){
22343 var d = (this.doc.body || this.doc.documentElement);
22345 this.cleanUpPaste();
22346 this.el.dom.value = d.innerHTML;
22347 this.owner.fireEvent('push', this, v);
22353 deferFocus : function(){
22354 this.focus.defer(10, this);
22358 focus : function(){
22359 if(this.win && !this.sourceEditMode){
22366 assignDocWin: function()
22368 var iframe = this.iframe;
22371 this.doc = iframe.contentWindow.document;
22372 this.win = iframe.contentWindow;
22374 // if (!Roo.get(this.frameId)) {
22377 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22378 // this.win = Roo.get(this.frameId).dom.contentWindow;
22380 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22384 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22385 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22390 initEditor : function(){
22391 //console.log("INIT EDITOR");
22392 this.assignDocWin();
22396 this.doc.designMode="on";
22398 this.doc.write(this.getDocMarkup());
22401 var dbody = (this.doc.body || this.doc.documentElement);
22402 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22403 // this copies styles from the containing element into thsi one..
22404 // not sure why we need all of this..
22405 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22407 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22408 //ss['background-attachment'] = 'fixed'; // w3c
22409 dbody.bgProperties = 'fixed'; // ie
22410 //Roo.DomHelper.applyStyles(dbody, ss);
22411 Roo.EventManager.on(this.doc, {
22412 //'mousedown': this.onEditorEvent,
22413 'mouseup': this.onEditorEvent,
22414 'dblclick': this.onEditorEvent,
22415 'click': this.onEditorEvent,
22416 'keyup': this.onEditorEvent,
22421 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22423 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22424 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22426 this.initialized = true;
22428 this.owner.fireEvent('initialize', this);
22433 onDestroy : function(){
22439 //for (var i =0; i < this.toolbars.length;i++) {
22440 // // fixme - ask toolbars for heights?
22441 // this.toolbars[i].onDestroy();
22444 //this.wrap.dom.innerHTML = '';
22445 //this.wrap.remove();
22450 onFirstFocus : function(){
22452 this.assignDocWin();
22455 this.activated = true;
22458 if(Roo.isGecko){ // prevent silly gecko errors
22460 var s = this.win.getSelection();
22461 if(!s.focusNode || s.focusNode.nodeType != 3){
22462 var r = s.getRangeAt(0);
22463 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22468 this.execCmd('useCSS', true);
22469 this.execCmd('styleWithCSS', false);
22472 this.owner.fireEvent('activate', this);
22476 adjustFont: function(btn){
22477 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22478 //if(Roo.isSafari){ // safari
22481 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22482 if(Roo.isSafari){ // safari
22483 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22484 v = (v < 10) ? 10 : v;
22485 v = (v > 48) ? 48 : v;
22486 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22491 v = Math.max(1, v+adjust);
22493 this.execCmd('FontSize', v );
22496 onEditorEvent : function(e)
22498 this.owner.fireEvent('editorevent', this, e);
22499 // this.updateToolbar();
22500 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22503 insertTag : function(tg)
22505 // could be a bit smarter... -> wrap the current selected tRoo..
22506 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22508 range = this.createRange(this.getSelection());
22509 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22510 wrappingNode.appendChild(range.extractContents());
22511 range.insertNode(wrappingNode);
22518 this.execCmd("formatblock", tg);
22522 insertText : function(txt)
22526 var range = this.createRange();
22527 range.deleteContents();
22528 //alert(Sender.getAttribute('label'));
22530 range.insertNode(this.doc.createTextNode(txt));
22536 * Executes a Midas editor command on the editor document and performs necessary focus and
22537 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22538 * @param {String} cmd The Midas command
22539 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22541 relayCmd : function(cmd, value){
22543 this.execCmd(cmd, value);
22544 this.owner.fireEvent('editorevent', this);
22545 //this.updateToolbar();
22546 this.owner.deferFocus();
22550 * Executes a Midas editor command directly on the editor document.
22551 * For visual commands, you should use {@link #relayCmd} instead.
22552 * <b>This should only be called after the editor is initialized.</b>
22553 * @param {String} cmd The Midas command
22554 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22556 execCmd : function(cmd, value){
22557 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22564 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22566 * @param {String} text | dom node..
22568 insertAtCursor : function(text)
22571 if(!this.activated){
22577 var r = this.doc.selection.createRange();
22588 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22592 // from jquery ui (MIT licenced)
22594 var win = this.win;
22596 if (win.getSelection && win.getSelection().getRangeAt) {
22597 range = win.getSelection().getRangeAt(0);
22598 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22599 range.insertNode(node);
22600 } else if (win.document.selection && win.document.selection.createRange) {
22601 // no firefox support
22602 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22603 win.document.selection.createRange().pasteHTML(txt);
22605 // no firefox support
22606 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22607 this.execCmd('InsertHTML', txt);
22616 mozKeyPress : function(e){
22618 var c = e.getCharCode(), cmd;
22621 c = String.fromCharCode(c).toLowerCase();
22635 this.cleanUpPaste.defer(100, this);
22643 e.preventDefault();
22651 fixKeys : function(){ // load time branching for fastest keydown performance
22653 return function(e){
22654 var k = e.getKey(), r;
22657 r = this.doc.selection.createRange();
22660 r.pasteHTML('    ');
22667 r = this.doc.selection.createRange();
22669 var target = r.parentElement();
22670 if(!target || target.tagName.toLowerCase() != 'li'){
22672 r.pasteHTML('<br />');
22678 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22679 this.cleanUpPaste.defer(100, this);
22685 }else if(Roo.isOpera){
22686 return function(e){
22687 var k = e.getKey();
22691 this.execCmd('InsertHTML','    ');
22694 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22695 this.cleanUpPaste.defer(100, this);
22700 }else if(Roo.isSafari){
22701 return function(e){
22702 var k = e.getKey();
22706 this.execCmd('InsertText','\t');
22710 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22711 this.cleanUpPaste.defer(100, this);
22719 getAllAncestors: function()
22721 var p = this.getSelectedNode();
22724 a.push(p); // push blank onto stack..
22725 p = this.getParentElement();
22729 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22733 a.push(this.doc.body);
22737 lastSelNode : false,
22740 getSelection : function()
22742 this.assignDocWin();
22743 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22746 getSelectedNode: function()
22748 // this may only work on Gecko!!!
22750 // should we cache this!!!!
22755 var range = this.createRange(this.getSelection()).cloneRange();
22758 var parent = range.parentElement();
22760 var testRange = range.duplicate();
22761 testRange.moveToElementText(parent);
22762 if (testRange.inRange(range)) {
22765 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22768 parent = parent.parentElement;
22773 // is ancestor a text element.
22774 var ac = range.commonAncestorContainer;
22775 if (ac.nodeType == 3) {
22776 ac = ac.parentNode;
22779 var ar = ac.childNodes;
22782 var other_nodes = [];
22783 var has_other_nodes = false;
22784 for (var i=0;i<ar.length;i++) {
22785 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22788 // fullly contained node.
22790 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22795 // probably selected..
22796 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22797 other_nodes.push(ar[i]);
22801 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22806 has_other_nodes = true;
22808 if (!nodes.length && other_nodes.length) {
22809 nodes= other_nodes;
22811 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22817 createRange: function(sel)
22819 // this has strange effects when using with
22820 // top toolbar - not sure if it's a great idea.
22821 //this.editor.contentWindow.focus();
22822 if (typeof sel != "undefined") {
22824 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22826 return this.doc.createRange();
22829 return this.doc.createRange();
22832 getParentElement: function()
22835 this.assignDocWin();
22836 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22838 var range = this.createRange(sel);
22841 var p = range.commonAncestorContainer;
22842 while (p.nodeType == 3) { // text node
22853 * Range intersection.. the hard stuff...
22857 * [ -- selected range --- ]
22861 * if end is before start or hits it. fail.
22862 * if start is after end or hits it fail.
22864 * if either hits (but other is outside. - then it's not
22870 // @see http://www.thismuchiknow.co.uk/?p=64.
22871 rangeIntersectsNode : function(range, node)
22873 var nodeRange = node.ownerDocument.createRange();
22875 nodeRange.selectNode(node);
22877 nodeRange.selectNodeContents(node);
22880 var rangeStartRange = range.cloneRange();
22881 rangeStartRange.collapse(true);
22883 var rangeEndRange = range.cloneRange();
22884 rangeEndRange.collapse(false);
22886 var nodeStartRange = nodeRange.cloneRange();
22887 nodeStartRange.collapse(true);
22889 var nodeEndRange = nodeRange.cloneRange();
22890 nodeEndRange.collapse(false);
22892 return rangeStartRange.compareBoundaryPoints(
22893 Range.START_TO_START, nodeEndRange) == -1 &&
22894 rangeEndRange.compareBoundaryPoints(
22895 Range.START_TO_START, nodeStartRange) == 1;
22899 rangeCompareNode : function(range, node)
22901 var nodeRange = node.ownerDocument.createRange();
22903 nodeRange.selectNode(node);
22905 nodeRange.selectNodeContents(node);
22909 range.collapse(true);
22911 nodeRange.collapse(true);
22913 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22914 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22916 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22918 var nodeIsBefore = ss == 1;
22919 var nodeIsAfter = ee == -1;
22921 if (nodeIsBefore && nodeIsAfter) {
22924 if (!nodeIsBefore && nodeIsAfter) {
22925 return 1; //right trailed.
22928 if (nodeIsBefore && !nodeIsAfter) {
22929 return 2; // left trailed.
22935 // private? - in a new class?
22936 cleanUpPaste : function()
22938 // cleans up the whole document..
22939 Roo.log('cleanuppaste');
22941 this.cleanUpChildren(this.doc.body);
22942 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22943 if (clean != this.doc.body.innerHTML) {
22944 this.doc.body.innerHTML = clean;
22949 cleanWordChars : function(input) {// change the chars to hex code
22950 var he = Roo.HtmlEditorCore;
22952 var output = input;
22953 Roo.each(he.swapCodes, function(sw) {
22954 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22956 output = output.replace(swapper, sw[1]);
22963 cleanUpChildren : function (n)
22965 if (!n.childNodes.length) {
22968 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22969 this.cleanUpChild(n.childNodes[i]);
22976 cleanUpChild : function (node)
22979 //console.log(node);
22980 if (node.nodeName == "#text") {
22981 // clean up silly Windows -- stuff?
22984 if (node.nodeName == "#comment") {
22985 node.parentNode.removeChild(node);
22986 // clean up silly Windows -- stuff?
22989 var lcname = node.tagName.toLowerCase();
22990 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22991 // whitelist of tags..
22993 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22995 node.parentNode.removeChild(node);
23000 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
23002 // remove <a name=....> as rendering on yahoo mailer is borked with this.
23003 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
23005 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
23006 // remove_keep_children = true;
23009 if (remove_keep_children) {
23010 this.cleanUpChildren(node);
23011 // inserts everything just before this node...
23012 while (node.childNodes.length) {
23013 var cn = node.childNodes[0];
23014 node.removeChild(cn);
23015 node.parentNode.insertBefore(cn, node);
23017 node.parentNode.removeChild(node);
23021 if (!node.attributes || !node.attributes.length) {
23022 this.cleanUpChildren(node);
23026 function cleanAttr(n,v)
23029 if (v.match(/^\./) || v.match(/^\//)) {
23032 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
23035 if (v.match(/^#/)) {
23038 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
23039 node.removeAttribute(n);
23043 var cwhite = this.cwhite;
23044 var cblack = this.cblack;
23046 function cleanStyle(n,v)
23048 if (v.match(/expression/)) { //XSS?? should we even bother..
23049 node.removeAttribute(n);
23053 var parts = v.split(/;/);
23056 Roo.each(parts, function(p) {
23057 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23061 var l = p.split(':').shift().replace(/\s+/g,'');
23062 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23064 if ( cwhite.length && cblack.indexOf(l) > -1) {
23065 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23066 //node.removeAttribute(n);
23070 // only allow 'c whitelisted system attributes'
23071 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23072 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23073 //node.removeAttribute(n);
23083 if (clean.length) {
23084 node.setAttribute(n, clean.join(';'));
23086 node.removeAttribute(n);
23092 for (var i = node.attributes.length-1; i > -1 ; i--) {
23093 var a = node.attributes[i];
23096 if (a.name.toLowerCase().substr(0,2)=='on') {
23097 node.removeAttribute(a.name);
23100 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23101 node.removeAttribute(a.name);
23104 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23105 cleanAttr(a.name,a.value); // fixme..
23108 if (a.name == 'style') {
23109 cleanStyle(a.name,a.value);
23112 /// clean up MS crap..
23113 // tecnically this should be a list of valid class'es..
23116 if (a.name == 'class') {
23117 if (a.value.match(/^Mso/)) {
23118 node.className = '';
23121 if (a.value.match(/^body$/)) {
23122 node.className = '';
23133 this.cleanUpChildren(node);
23139 * Clean up MS wordisms...
23141 cleanWord : function(node)
23146 this.cleanWord(this.doc.body);
23149 if (node.nodeName == "#text") {
23150 // clean up silly Windows -- stuff?
23153 if (node.nodeName == "#comment") {
23154 node.parentNode.removeChild(node);
23155 // clean up silly Windows -- stuff?
23159 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23160 node.parentNode.removeChild(node);
23164 // remove - but keep children..
23165 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23166 while (node.childNodes.length) {
23167 var cn = node.childNodes[0];
23168 node.removeChild(cn);
23169 node.parentNode.insertBefore(cn, node);
23171 node.parentNode.removeChild(node);
23172 this.iterateChildren(node, this.cleanWord);
23176 if (node.className.length) {
23178 var cn = node.className.split(/\W+/);
23180 Roo.each(cn, function(cls) {
23181 if (cls.match(/Mso[a-zA-Z]+/)) {
23186 node.className = cna.length ? cna.join(' ') : '';
23188 node.removeAttribute("class");
23192 if (node.hasAttribute("lang")) {
23193 node.removeAttribute("lang");
23196 if (node.hasAttribute("style")) {
23198 var styles = node.getAttribute("style").split(";");
23200 Roo.each(styles, function(s) {
23201 if (!s.match(/:/)) {
23204 var kv = s.split(":");
23205 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23208 // what ever is left... we allow.
23211 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23212 if (!nstyle.length) {
23213 node.removeAttribute('style');
23216 this.iterateChildren(node, this.cleanWord);
23222 * iterateChildren of a Node, calling fn each time, using this as the scole..
23223 * @param {DomNode} node node to iterate children of.
23224 * @param {Function} fn method of this class to call on each item.
23226 iterateChildren : function(node, fn)
23228 if (!node.childNodes.length) {
23231 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23232 fn.call(this, node.childNodes[i])
23238 * cleanTableWidths.
23240 * Quite often pasting from word etc.. results in tables with column and widths.
23241 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23244 cleanTableWidths : function(node)
23249 this.cleanTableWidths(this.doc.body);
23254 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23257 Roo.log(node.tagName);
23258 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23259 this.iterateChildren(node, this.cleanTableWidths);
23262 if (node.hasAttribute('width')) {
23263 node.removeAttribute('width');
23267 if (node.hasAttribute("style")) {
23270 var styles = node.getAttribute("style").split(";");
23272 Roo.each(styles, function(s) {
23273 if (!s.match(/:/)) {
23276 var kv = s.split(":");
23277 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23280 // what ever is left... we allow.
23283 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23284 if (!nstyle.length) {
23285 node.removeAttribute('style');
23289 this.iterateChildren(node, this.cleanTableWidths);
23297 domToHTML : function(currentElement, depth, nopadtext) {
23299 depth = depth || 0;
23300 nopadtext = nopadtext || false;
23302 if (!currentElement) {
23303 return this.domToHTML(this.doc.body);
23306 //Roo.log(currentElement);
23308 var allText = false;
23309 var nodeName = currentElement.nodeName;
23310 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23312 if (nodeName == '#text') {
23314 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23319 if (nodeName != 'BODY') {
23322 // Prints the node tagName, such as <A>, <IMG>, etc
23325 for(i = 0; i < currentElement.attributes.length;i++) {
23327 var aname = currentElement.attributes.item(i).name;
23328 if (!currentElement.attributes.item(i).value.length) {
23331 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23334 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23343 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23346 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23351 // Traverse the tree
23353 var currentElementChild = currentElement.childNodes.item(i);
23354 var allText = true;
23355 var innerHTML = '';
23357 while (currentElementChild) {
23358 // Formatting code (indent the tree so it looks nice on the screen)
23359 var nopad = nopadtext;
23360 if (lastnode == 'SPAN') {
23364 if (currentElementChild.nodeName == '#text') {
23365 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23366 toadd = nopadtext ? toadd : toadd.trim();
23367 if (!nopad && toadd.length > 80) {
23368 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23370 innerHTML += toadd;
23373 currentElementChild = currentElement.childNodes.item(i);
23379 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23381 // Recursively traverse the tree structure of the child node
23382 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23383 lastnode = currentElementChild.nodeName;
23385 currentElementChild=currentElement.childNodes.item(i);
23391 // The remaining code is mostly for formatting the tree
23392 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23397 ret+= "</"+tagName+">";
23403 applyBlacklists : function()
23405 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23406 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23410 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23411 if (b.indexOf(tag) > -1) {
23414 this.white.push(tag);
23418 Roo.each(w, function(tag) {
23419 if (b.indexOf(tag) > -1) {
23422 if (this.white.indexOf(tag) > -1) {
23425 this.white.push(tag);
23430 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23431 if (w.indexOf(tag) > -1) {
23434 this.black.push(tag);
23438 Roo.each(b, function(tag) {
23439 if (w.indexOf(tag) > -1) {
23442 if (this.black.indexOf(tag) > -1) {
23445 this.black.push(tag);
23450 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23451 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23455 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23456 if (b.indexOf(tag) > -1) {
23459 this.cwhite.push(tag);
23463 Roo.each(w, function(tag) {
23464 if (b.indexOf(tag) > -1) {
23467 if (this.cwhite.indexOf(tag) > -1) {
23470 this.cwhite.push(tag);
23475 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23476 if (w.indexOf(tag) > -1) {
23479 this.cblack.push(tag);
23483 Roo.each(b, function(tag) {
23484 if (w.indexOf(tag) > -1) {
23487 if (this.cblack.indexOf(tag) > -1) {
23490 this.cblack.push(tag);
23495 setStylesheets : function(stylesheets)
23497 if(typeof(stylesheets) == 'string'){
23498 Roo.get(this.iframe.contentDocument.head).createChild({
23500 rel : 'stylesheet',
23509 Roo.each(stylesheets, function(s) {
23514 Roo.get(_this.iframe.contentDocument.head).createChild({
23516 rel : 'stylesheet',
23525 removeStylesheets : function()
23529 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23534 setStyle : function(style)
23536 Roo.get(this.iframe.contentDocument.head).createChild({
23545 // hide stuff that is not compatible
23559 * @event specialkey
23563 * @cfg {String} fieldClass @hide
23566 * @cfg {String} focusClass @hide
23569 * @cfg {String} autoCreate @hide
23572 * @cfg {String} inputType @hide
23575 * @cfg {String} invalidClass @hide
23578 * @cfg {String} invalidText @hide
23581 * @cfg {String} msgFx @hide
23584 * @cfg {String} validateOnBlur @hide
23588 Roo.HtmlEditorCore.white = [
23589 'area', 'br', 'img', 'input', 'hr', 'wbr',
23591 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23592 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23593 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23594 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23595 'table', 'ul', 'xmp',
23597 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23600 'dir', 'menu', 'ol', 'ul', 'dl',
23606 Roo.HtmlEditorCore.black = [
23607 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23609 'base', 'basefont', 'bgsound', 'blink', 'body',
23610 'frame', 'frameset', 'head', 'html', 'ilayer',
23611 'iframe', 'layer', 'link', 'meta', 'object',
23612 'script', 'style' ,'title', 'xml' // clean later..
23614 Roo.HtmlEditorCore.clean = [
23615 'script', 'style', 'title', 'xml'
23617 Roo.HtmlEditorCore.remove = [
23622 Roo.HtmlEditorCore.ablack = [
23626 Roo.HtmlEditorCore.aclean = [
23627 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23631 Roo.HtmlEditorCore.pwhite= [
23632 'http', 'https', 'mailto'
23635 // white listed style attributes.
23636 Roo.HtmlEditorCore.cwhite= [
23637 // 'text-align', /// default is to allow most things..
23643 // black listed style attributes.
23644 Roo.HtmlEditorCore.cblack= [
23645 // 'font-size' -- this can be set by the project
23649 Roo.HtmlEditorCore.swapCodes =[
23668 * @class Roo.bootstrap.HtmlEditor
23669 * @extends Roo.bootstrap.TextArea
23670 * Bootstrap HtmlEditor class
23673 * Create a new HtmlEditor
23674 * @param {Object} config The config object
23677 Roo.bootstrap.HtmlEditor = function(config){
23678 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23679 if (!this.toolbars) {
23680 this.toolbars = [];
23683 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23686 * @event initialize
23687 * Fires when the editor is fully initialized (including the iframe)
23688 * @param {HtmlEditor} this
23693 * Fires when the editor is first receives the focus. Any insertion must wait
23694 * until after this event.
23695 * @param {HtmlEditor} this
23699 * @event beforesync
23700 * Fires before the textarea is updated with content from the editor iframe. Return false
23701 * to cancel the sync.
23702 * @param {HtmlEditor} this
23703 * @param {String} html
23707 * @event beforepush
23708 * Fires before the iframe editor is updated with content from the textarea. Return false
23709 * to cancel the push.
23710 * @param {HtmlEditor} this
23711 * @param {String} html
23716 * Fires when the textarea is updated with content from the editor iframe.
23717 * @param {HtmlEditor} this
23718 * @param {String} html
23723 * Fires when the iframe editor is updated with content from the textarea.
23724 * @param {HtmlEditor} this
23725 * @param {String} html
23729 * @event editmodechange
23730 * Fires when the editor switches edit modes
23731 * @param {HtmlEditor} this
23732 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23734 editmodechange: true,
23736 * @event editorevent
23737 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23738 * @param {HtmlEditor} this
23742 * @event firstfocus
23743 * Fires when on first focus - needed by toolbars..
23744 * @param {HtmlEditor} this
23749 * Auto save the htmlEditor value as a file into Events
23750 * @param {HtmlEditor} this
23754 * @event savedpreview
23755 * preview the saved version of htmlEditor
23756 * @param {HtmlEditor} this
23763 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23767 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23772 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23777 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23782 * @cfg {Number} height (in pixels)
23786 * @cfg {Number} width (in pixels)
23791 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23794 stylesheets: false,
23799 // private properties
23800 validationEvent : false,
23802 initialized : false,
23805 onFocus : Roo.emptyFn,
23807 hideMode:'offsets',
23809 tbContainer : false,
23813 toolbarContainer :function() {
23814 return this.wrap.select('.x-html-editor-tb',true).first();
23818 * Protected method that will not generally be called directly. It
23819 * is called when the editor creates its toolbar. Override this method if you need to
23820 * add custom toolbar buttons.
23821 * @param {HtmlEditor} editor
23823 createToolbar : function(){
23824 Roo.log('renewing');
23825 Roo.log("create toolbars");
23827 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23828 this.toolbars[0].render(this.toolbarContainer());
23832 // if (!editor.toolbars || !editor.toolbars.length) {
23833 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23836 // for (var i =0 ; i < editor.toolbars.length;i++) {
23837 // editor.toolbars[i] = Roo.factory(
23838 // typeof(editor.toolbars[i]) == 'string' ?
23839 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23840 // Roo.bootstrap.HtmlEditor);
23841 // editor.toolbars[i].init(editor);
23847 onRender : function(ct, position)
23849 // Roo.log("Call onRender: " + this.xtype);
23851 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23853 this.wrap = this.inputEl().wrap({
23854 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23857 this.editorcore.onRender(ct, position);
23859 if (this.resizable) {
23860 this.resizeEl = new Roo.Resizable(this.wrap, {
23864 minHeight : this.height,
23865 height: this.height,
23866 handles : this.resizable,
23869 resize : function(r, w, h) {
23870 _t.onResize(w,h); // -something
23876 this.createToolbar(this);
23879 if(!this.width && this.resizable){
23880 this.setSize(this.wrap.getSize());
23882 if (this.resizeEl) {
23883 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23884 // should trigger onReize..
23890 onResize : function(w, h)
23892 Roo.log('resize: ' +w + ',' + h );
23893 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23897 if(this.inputEl() ){
23898 if(typeof w == 'number'){
23899 var aw = w - this.wrap.getFrameWidth('lr');
23900 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23903 if(typeof h == 'number'){
23904 var tbh = -11; // fixme it needs to tool bar size!
23905 for (var i =0; i < this.toolbars.length;i++) {
23906 // fixme - ask toolbars for heights?
23907 tbh += this.toolbars[i].el.getHeight();
23908 //if (this.toolbars[i].footer) {
23909 // tbh += this.toolbars[i].footer.el.getHeight();
23917 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23918 ah -= 5; // knock a few pixes off for look..
23919 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23923 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23924 this.editorcore.onResize(ew,eh);
23929 * Toggles the editor between standard and source edit mode.
23930 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23932 toggleSourceEdit : function(sourceEditMode)
23934 this.editorcore.toggleSourceEdit(sourceEditMode);
23936 if(this.editorcore.sourceEditMode){
23937 Roo.log('editor - showing textarea');
23940 // Roo.log(this.syncValue());
23942 this.inputEl().removeClass(['hide', 'x-hidden']);
23943 this.inputEl().dom.removeAttribute('tabIndex');
23944 this.inputEl().focus();
23946 Roo.log('editor - hiding textarea');
23948 // Roo.log(this.pushValue());
23951 this.inputEl().addClass(['hide', 'x-hidden']);
23952 this.inputEl().dom.setAttribute('tabIndex', -1);
23953 //this.deferFocus();
23956 if(this.resizable){
23957 this.setSize(this.wrap.getSize());
23960 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23963 // private (for BoxComponent)
23964 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23966 // private (for BoxComponent)
23967 getResizeEl : function(){
23971 // private (for BoxComponent)
23972 getPositionEl : function(){
23977 initEvents : function(){
23978 this.originalValue = this.getValue();
23982 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23985 // markInvalid : Roo.emptyFn,
23987 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23990 // clearInvalid : Roo.emptyFn,
23992 setValue : function(v){
23993 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23994 this.editorcore.pushValue();
23999 deferFocus : function(){
24000 this.focus.defer(10, this);
24004 focus : function(){
24005 this.editorcore.focus();
24011 onDestroy : function(){
24017 for (var i =0; i < this.toolbars.length;i++) {
24018 // fixme - ask toolbars for heights?
24019 this.toolbars[i].onDestroy();
24022 this.wrap.dom.innerHTML = '';
24023 this.wrap.remove();
24028 onFirstFocus : function(){
24029 //Roo.log("onFirstFocus");
24030 this.editorcore.onFirstFocus();
24031 for (var i =0; i < this.toolbars.length;i++) {
24032 this.toolbars[i].onFirstFocus();
24038 syncValue : function()
24040 this.editorcore.syncValue();
24043 pushValue : function()
24045 this.editorcore.pushValue();
24049 // hide stuff that is not compatible
24063 * @event specialkey
24067 * @cfg {String} fieldClass @hide
24070 * @cfg {String} focusClass @hide
24073 * @cfg {String} autoCreate @hide
24076 * @cfg {String} inputType @hide
24080 * @cfg {String} invalidText @hide
24083 * @cfg {String} msgFx @hide
24086 * @cfg {String} validateOnBlur @hide
24095 Roo.namespace('Roo.bootstrap.htmleditor');
24097 * @class Roo.bootstrap.HtmlEditorToolbar1
24103 new Roo.bootstrap.HtmlEditor({
24106 new Roo.bootstrap.HtmlEditorToolbar1({
24107 disable : { fonts: 1 , format: 1, ..., ... , ...],
24113 * @cfg {Object} disable List of elements to disable..
24114 * @cfg {Array} btns List of additional buttons.
24118 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24121 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24124 Roo.apply(this, config);
24126 // default disabled, based on 'good practice'..
24127 this.disable = this.disable || {};
24128 Roo.applyIf(this.disable, {
24131 specialElements : true
24133 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24135 this.editor = config.editor;
24136 this.editorcore = config.editor.editorcore;
24138 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24140 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24141 // dont call parent... till later.
24143 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24148 editorcore : false,
24153 "h1","h2","h3","h4","h5","h6",
24155 "abbr", "acronym", "address", "cite", "samp", "var",
24159 onRender : function(ct, position)
24161 // Roo.log("Call onRender: " + this.xtype);
24163 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24165 this.el.dom.style.marginBottom = '0';
24167 var editorcore = this.editorcore;
24168 var editor= this.editor;
24171 var btn = function(id,cmd , toggle, handler, html){
24173 var event = toggle ? 'toggle' : 'click';
24178 xns: Roo.bootstrap,
24182 enableToggle:toggle !== false,
24184 pressed : toggle ? false : null,
24187 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24188 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24194 // var cb_box = function...
24199 xns: Roo.bootstrap,
24204 xns: Roo.bootstrap,
24208 Roo.each(this.formats, function(f) {
24209 style.menu.items.push({
24211 xns: Roo.bootstrap,
24212 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24217 editorcore.insertTag(this.tagname);
24224 children.push(style);
24226 btn('bold',false,true);
24227 btn('italic',false,true);
24228 btn('align-left', 'justifyleft',true);
24229 btn('align-center', 'justifycenter',true);
24230 btn('align-right' , 'justifyright',true);
24231 btn('link', false, false, function(btn) {
24232 //Roo.log("create link?");
24233 var url = prompt(this.createLinkText, this.defaultLinkValue);
24234 if(url && url != 'http:/'+'/'){
24235 this.editorcore.relayCmd('createlink', url);
24238 btn('list','insertunorderedlist',true);
24239 btn('pencil', false,true, function(btn){
24241 this.toggleSourceEdit(btn.pressed);
24244 if (this.editor.btns.length > 0) {
24245 for (var i = 0; i<this.editor.btns.length; i++) {
24246 children.push(this.editor.btns[i]);
24254 xns: Roo.bootstrap,
24259 xns: Roo.bootstrap,
24264 cog.menu.items.push({
24266 xns: Roo.bootstrap,
24267 html : Clean styles,
24272 editorcore.insertTag(this.tagname);
24281 this.xtype = 'NavSimplebar';
24283 for(var i=0;i< children.length;i++) {
24285 this.buttons.add(this.addxtypeChild(children[i]));
24289 editor.on('editorevent', this.updateToolbar, this);
24291 onBtnClick : function(id)
24293 this.editorcore.relayCmd(id);
24294 this.editorcore.focus();
24298 * Protected method that will not generally be called directly. It triggers
24299 * a toolbar update by reading the markup state of the current selection in the editor.
24301 updateToolbar: function(){
24303 if(!this.editorcore.activated){
24304 this.editor.onFirstFocus(); // is this neeed?
24308 var btns = this.buttons;
24309 var doc = this.editorcore.doc;
24310 btns.get('bold').setActive(doc.queryCommandState('bold'));
24311 btns.get('italic').setActive(doc.queryCommandState('italic'));
24312 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24314 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24315 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24316 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24318 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24319 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24322 var ans = this.editorcore.getAllAncestors();
24323 if (this.formatCombo) {
24326 var store = this.formatCombo.store;
24327 this.formatCombo.setValue("");
24328 for (var i =0; i < ans.length;i++) {
24329 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24331 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24339 // hides menus... - so this cant be on a menu...
24340 Roo.bootstrap.MenuMgr.hideAll();
24342 Roo.bootstrap.MenuMgr.hideAll();
24343 //this.editorsyncValue();
24345 onFirstFocus: function() {
24346 this.buttons.each(function(item){
24350 toggleSourceEdit : function(sourceEditMode){
24353 if(sourceEditMode){
24354 Roo.log("disabling buttons");
24355 this.buttons.each( function(item){
24356 if(item.cmd != 'pencil'){
24362 Roo.log("enabling buttons");
24363 if(this.editorcore.initialized){
24364 this.buttons.each( function(item){
24370 Roo.log("calling toggole on editor");
24371 // tell the editor that it's been pressed..
24372 this.editor.toggleSourceEdit(sourceEditMode);
24382 * @class Roo.bootstrap.Table.AbstractSelectionModel
24383 * @extends Roo.util.Observable
24384 * Abstract base class for grid SelectionModels. It provides the interface that should be
24385 * implemented by descendant classes. This class should not be directly instantiated.
24388 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24389 this.locked = false;
24390 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24394 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24395 /** @ignore Called by the grid automatically. Do not call directly. */
24396 init : function(grid){
24402 * Locks the selections.
24405 this.locked = true;
24409 * Unlocks the selections.
24411 unlock : function(){
24412 this.locked = false;
24416 * Returns true if the selections are locked.
24417 * @return {Boolean}
24419 isLocked : function(){
24420 return this.locked;
24424 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24425 * @class Roo.bootstrap.Table.RowSelectionModel
24426 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24427 * It supports multiple selections and keyboard selection/navigation.
24429 * @param {Object} config
24432 Roo.bootstrap.Table.RowSelectionModel = function(config){
24433 Roo.apply(this, config);
24434 this.selections = new Roo.util.MixedCollection(false, function(o){
24439 this.lastActive = false;
24443 * @event selectionchange
24444 * Fires when the selection changes
24445 * @param {SelectionModel} this
24447 "selectionchange" : true,
24449 * @event afterselectionchange
24450 * Fires after the selection changes (eg. by key press or clicking)
24451 * @param {SelectionModel} this
24453 "afterselectionchange" : true,
24455 * @event beforerowselect
24456 * Fires when a row is selected being selected, return false to cancel.
24457 * @param {SelectionModel} this
24458 * @param {Number} rowIndex The selected index
24459 * @param {Boolean} keepExisting False if other selections will be cleared
24461 "beforerowselect" : true,
24464 * Fires when a row is selected.
24465 * @param {SelectionModel} this
24466 * @param {Number} rowIndex The selected index
24467 * @param {Roo.data.Record} r The record
24469 "rowselect" : true,
24471 * @event rowdeselect
24472 * Fires when a row is deselected.
24473 * @param {SelectionModel} this
24474 * @param {Number} rowIndex The selected index
24476 "rowdeselect" : true
24478 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24479 this.locked = false;
24482 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24484 * @cfg {Boolean} singleSelect
24485 * True to allow selection of only one row at a time (defaults to false)
24487 singleSelect : false,
24490 initEvents : function()
24493 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24494 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24495 //}else{ // allow click to work like normal
24496 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24498 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24499 this.grid.on("rowclick", this.handleMouseDown, this);
24501 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24502 "up" : function(e){
24504 this.selectPrevious(e.shiftKey);
24505 }else if(this.last !== false && this.lastActive !== false){
24506 var last = this.last;
24507 this.selectRange(this.last, this.lastActive-1);
24508 this.grid.getView().focusRow(this.lastActive);
24509 if(last !== false){
24513 this.selectFirstRow();
24515 this.fireEvent("afterselectionchange", this);
24517 "down" : function(e){
24519 this.selectNext(e.shiftKey);
24520 }else if(this.last !== false && this.lastActive !== false){
24521 var last = this.last;
24522 this.selectRange(this.last, this.lastActive+1);
24523 this.grid.getView().focusRow(this.lastActive);
24524 if(last !== false){
24528 this.selectFirstRow();
24530 this.fireEvent("afterselectionchange", this);
24534 this.grid.store.on('load', function(){
24535 this.selections.clear();
24538 var view = this.grid.view;
24539 view.on("refresh", this.onRefresh, this);
24540 view.on("rowupdated", this.onRowUpdated, this);
24541 view.on("rowremoved", this.onRemove, this);
24546 onRefresh : function()
24548 var ds = this.grid.store, i, v = this.grid.view;
24549 var s = this.selections;
24550 s.each(function(r){
24551 if((i = ds.indexOfId(r.id)) != -1){
24560 onRemove : function(v, index, r){
24561 this.selections.remove(r);
24565 onRowUpdated : function(v, index, r){
24566 if(this.isSelected(r)){
24567 v.onRowSelect(index);
24573 * @param {Array} records The records to select
24574 * @param {Boolean} keepExisting (optional) True to keep existing selections
24576 selectRecords : function(records, keepExisting)
24579 this.clearSelections();
24581 var ds = this.grid.store;
24582 for(var i = 0, len = records.length; i < len; i++){
24583 this.selectRow(ds.indexOf(records[i]), true);
24588 * Gets the number of selected rows.
24591 getCount : function(){
24592 return this.selections.length;
24596 * Selects the first row in the grid.
24598 selectFirstRow : function(){
24603 * Select the last row.
24604 * @param {Boolean} keepExisting (optional) True to keep existing selections
24606 selectLastRow : function(keepExisting){
24607 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24608 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24612 * Selects the row immediately following the last selected row.
24613 * @param {Boolean} keepExisting (optional) True to keep existing selections
24615 selectNext : function(keepExisting)
24617 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24618 this.selectRow(this.last+1, keepExisting);
24619 this.grid.getView().focusRow(this.last);
24624 * Selects the row that precedes the last selected row.
24625 * @param {Boolean} keepExisting (optional) True to keep existing selections
24627 selectPrevious : function(keepExisting){
24629 this.selectRow(this.last-1, keepExisting);
24630 this.grid.getView().focusRow(this.last);
24635 * Returns the selected records
24636 * @return {Array} Array of selected records
24638 getSelections : function(){
24639 return [].concat(this.selections.items);
24643 * Returns the first selected record.
24646 getSelected : function(){
24647 return this.selections.itemAt(0);
24652 * Clears all selections.
24654 clearSelections : function(fast)
24660 var ds = this.grid.store;
24661 var s = this.selections;
24662 s.each(function(r){
24663 this.deselectRow(ds.indexOfId(r.id));
24667 this.selections.clear();
24674 * Selects all rows.
24676 selectAll : function(){
24680 this.selections.clear();
24681 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24682 this.selectRow(i, true);
24687 * Returns True if there is a selection.
24688 * @return {Boolean}
24690 hasSelection : function(){
24691 return this.selections.length > 0;
24695 * Returns True if the specified row is selected.
24696 * @param {Number/Record} record The record or index of the record to check
24697 * @return {Boolean}
24699 isSelected : function(index){
24700 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24701 return (r && this.selections.key(r.id) ? true : false);
24705 * Returns True if the specified record id is selected.
24706 * @param {String} id The id of record to check
24707 * @return {Boolean}
24709 isIdSelected : function(id){
24710 return (this.selections.key(id) ? true : false);
24715 handleMouseDBClick : function(e, t){
24719 handleMouseDown : function(e, t)
24721 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24722 if(this.isLocked() || rowIndex < 0 ){
24725 if(e.shiftKey && this.last !== false){
24726 var last = this.last;
24727 this.selectRange(last, rowIndex, e.ctrlKey);
24728 this.last = last; // reset the last
24732 var isSelected = this.isSelected(rowIndex);
24733 //Roo.log("select row:" + rowIndex);
24735 this.deselectRow(rowIndex);
24737 this.selectRow(rowIndex, true);
24741 if(e.button !== 0 && isSelected){
24742 alert('rowIndex 2: ' + rowIndex);
24743 view.focusRow(rowIndex);
24744 }else if(e.ctrlKey && isSelected){
24745 this.deselectRow(rowIndex);
24746 }else if(!isSelected){
24747 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24748 view.focusRow(rowIndex);
24752 this.fireEvent("afterselectionchange", this);
24755 handleDragableRowClick : function(grid, rowIndex, e)
24757 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24758 this.selectRow(rowIndex, false);
24759 grid.view.focusRow(rowIndex);
24760 this.fireEvent("afterselectionchange", this);
24765 * Selects multiple rows.
24766 * @param {Array} rows Array of the indexes of the row to select
24767 * @param {Boolean} keepExisting (optional) True to keep existing selections
24769 selectRows : function(rows, keepExisting){
24771 this.clearSelections();
24773 for(var i = 0, len = rows.length; i < len; i++){
24774 this.selectRow(rows[i], true);
24779 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24780 * @param {Number} startRow The index of the first row in the range
24781 * @param {Number} endRow The index of the last row in the range
24782 * @param {Boolean} keepExisting (optional) True to retain existing selections
24784 selectRange : function(startRow, endRow, keepExisting){
24789 this.clearSelections();
24791 if(startRow <= endRow){
24792 for(var i = startRow; i <= endRow; i++){
24793 this.selectRow(i, true);
24796 for(var i = startRow; i >= endRow; i--){
24797 this.selectRow(i, true);
24803 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24804 * @param {Number} startRow The index of the first row in the range
24805 * @param {Number} endRow The index of the last row in the range
24807 deselectRange : function(startRow, endRow, preventViewNotify){
24811 for(var i = startRow; i <= endRow; i++){
24812 this.deselectRow(i, preventViewNotify);
24818 * @param {Number} row The index of the row to select
24819 * @param {Boolean} keepExisting (optional) True to keep existing selections
24821 selectRow : function(index, keepExisting, preventViewNotify)
24823 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24826 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24827 if(!keepExisting || this.singleSelect){
24828 this.clearSelections();
24831 var r = this.grid.store.getAt(index);
24832 //console.log('selectRow - record id :' + r.id);
24834 this.selections.add(r);
24835 this.last = this.lastActive = index;
24836 if(!preventViewNotify){
24837 var proxy = new Roo.Element(
24838 this.grid.getRowDom(index)
24840 proxy.addClass('bg-info info');
24842 this.fireEvent("rowselect", this, index, r);
24843 this.fireEvent("selectionchange", this);
24849 * @param {Number} row The index of the row to deselect
24851 deselectRow : function(index, preventViewNotify)
24856 if(this.last == index){
24859 if(this.lastActive == index){
24860 this.lastActive = false;
24863 var r = this.grid.store.getAt(index);
24868 this.selections.remove(r);
24869 //.console.log('deselectRow - record id :' + r.id);
24870 if(!preventViewNotify){
24872 var proxy = new Roo.Element(
24873 this.grid.getRowDom(index)
24875 proxy.removeClass('bg-info info');
24877 this.fireEvent("rowdeselect", this, index);
24878 this.fireEvent("selectionchange", this);
24882 restoreLast : function(){
24884 this.last = this._last;
24889 acceptsNav : function(row, col, cm){
24890 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24894 onEditorKey : function(field, e){
24895 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24900 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24902 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24904 }else if(k == e.ENTER && !e.ctrlKey){
24908 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24910 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24912 }else if(k == e.ESC){
24916 g.startEditing(newCell[0], newCell[1]);
24922 * Ext JS Library 1.1.1
24923 * Copyright(c) 2006-2007, Ext JS, LLC.
24925 * Originally Released Under LGPL - original licence link has changed is not relivant.
24928 * <script type="text/javascript">
24932 * @class Roo.bootstrap.PagingToolbar
24933 * @extends Roo.bootstrap.NavSimplebar
24934 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24936 * Create a new PagingToolbar
24937 * @param {Object} config The config object
24938 * @param {Roo.data.Store} store
24940 Roo.bootstrap.PagingToolbar = function(config)
24942 // old args format still supported... - xtype is prefered..
24943 // created from xtype...
24945 this.ds = config.dataSource;
24947 if (config.store && !this.ds) {
24948 this.store= Roo.factory(config.store, Roo.data);
24949 this.ds = this.store;
24950 this.ds.xmodule = this.xmodule || false;
24953 this.toolbarItems = [];
24954 if (config.items) {
24955 this.toolbarItems = config.items;
24958 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24963 this.bind(this.ds);
24966 if (Roo.bootstrap.version == 4) {
24967 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24969 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24974 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24976 * @cfg {Roo.data.Store} dataSource
24977 * The underlying data store providing the paged data
24980 * @cfg {String/HTMLElement/Element} container
24981 * container The id or element that will contain the toolbar
24984 * @cfg {Boolean} displayInfo
24985 * True to display the displayMsg (defaults to false)
24988 * @cfg {Number} pageSize
24989 * The number of records to display per page (defaults to 20)
24993 * @cfg {String} displayMsg
24994 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24996 displayMsg : 'Displaying {0} - {1} of {2}',
24998 * @cfg {String} emptyMsg
24999 * The message to display when no records are found (defaults to "No data to display")
25001 emptyMsg : 'No data to display',
25003 * Customizable piece of the default paging text (defaults to "Page")
25006 beforePageText : "Page",
25008 * Customizable piece of the default paging text (defaults to "of %0")
25011 afterPageText : "of {0}",
25013 * Customizable piece of the default paging text (defaults to "First Page")
25016 firstText : "First Page",
25018 * Customizable piece of the default paging text (defaults to "Previous Page")
25021 prevText : "Previous Page",
25023 * Customizable piece of the default paging text (defaults to "Next Page")
25026 nextText : "Next Page",
25028 * Customizable piece of the default paging text (defaults to "Last Page")
25031 lastText : "Last Page",
25033 * Customizable piece of the default paging text (defaults to "Refresh")
25036 refreshText : "Refresh",
25040 onRender : function(ct, position)
25042 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
25043 this.navgroup.parentId = this.id;
25044 this.navgroup.onRender(this.el, null);
25045 // add the buttons to the navgroup
25047 if(this.displayInfo){
25048 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25049 this.displayEl = this.el.select('.x-paging-info', true).first();
25050 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25051 // this.displayEl = navel.el.select('span',true).first();
25057 Roo.each(_this.buttons, function(e){ // this might need to use render????
25058 Roo.factory(e).render(_this.el);
25062 Roo.each(_this.toolbarItems, function(e) {
25063 _this.navgroup.addItem(e);
25067 this.first = this.navgroup.addItem({
25068 tooltip: this.firstText,
25069 cls: "prev btn-outline-secondary",
25070 html : ' <i class="fa fa-step-backward"></i>',
25072 preventDefault: true,
25073 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25076 this.prev = this.navgroup.addItem({
25077 tooltip: this.prevText,
25078 cls: "prev btn-outline-secondary",
25079 html : ' <i class="fa fa-backward"></i>',
25081 preventDefault: true,
25082 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25084 //this.addSeparator();
25087 var field = this.navgroup.addItem( {
25089 cls : 'x-paging-position btn-outline-secondary',
25091 html : this.beforePageText +
25092 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25093 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25096 this.field = field.el.select('input', true).first();
25097 this.field.on("keydown", this.onPagingKeydown, this);
25098 this.field.on("focus", function(){this.dom.select();});
25101 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25102 //this.field.setHeight(18);
25103 //this.addSeparator();
25104 this.next = this.navgroup.addItem({
25105 tooltip: this.nextText,
25106 cls: "next btn-outline-secondary",
25107 html : ' <i class="fa fa-forward"></i>',
25109 preventDefault: true,
25110 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25112 this.last = this.navgroup.addItem({
25113 tooltip: this.lastText,
25114 html : ' <i class="fa fa-step-forward"></i>',
25115 cls: "next btn-outline-secondary",
25117 preventDefault: true,
25118 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25120 //this.addSeparator();
25121 this.loading = this.navgroup.addItem({
25122 tooltip: this.refreshText,
25123 cls: "btn-outline-secondary",
25124 html : ' <i class="fa fa-refresh"></i>',
25125 preventDefault: true,
25126 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25132 updateInfo : function(){
25133 if(this.displayEl){
25134 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25135 var msg = count == 0 ?
25139 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25141 this.displayEl.update(msg);
25146 onLoad : function(ds, r, o)
25148 this.cursor = o.params.start ? o.params.start : 0;
25150 var d = this.getPageData(),
25155 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25156 this.field.dom.value = ap;
25157 this.first.setDisabled(ap == 1);
25158 this.prev.setDisabled(ap == 1);
25159 this.next.setDisabled(ap == ps);
25160 this.last.setDisabled(ap == ps);
25161 this.loading.enable();
25166 getPageData : function(){
25167 var total = this.ds.getTotalCount();
25170 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25171 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25176 onLoadError : function(){
25177 this.loading.enable();
25181 onPagingKeydown : function(e){
25182 var k = e.getKey();
25183 var d = this.getPageData();
25185 var v = this.field.dom.value, pageNum;
25186 if(!v || isNaN(pageNum = parseInt(v, 10))){
25187 this.field.dom.value = d.activePage;
25190 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25191 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25194 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))
25196 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25197 this.field.dom.value = pageNum;
25198 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25201 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25203 var v = this.field.dom.value, pageNum;
25204 var increment = (e.shiftKey) ? 10 : 1;
25205 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25208 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25209 this.field.dom.value = d.activePage;
25212 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25214 this.field.dom.value = parseInt(v, 10) + increment;
25215 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25216 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25223 beforeLoad : function(){
25225 this.loading.disable();
25230 onClick : function(which){
25239 ds.load({params:{start: 0, limit: this.pageSize}});
25242 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25245 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25248 var total = ds.getTotalCount();
25249 var extra = total % this.pageSize;
25250 var lastStart = extra ? (total - extra) : total-this.pageSize;
25251 ds.load({params:{start: lastStart, limit: this.pageSize}});
25254 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25260 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25261 * @param {Roo.data.Store} store The data store to unbind
25263 unbind : function(ds){
25264 ds.un("beforeload", this.beforeLoad, this);
25265 ds.un("load", this.onLoad, this);
25266 ds.un("loadexception", this.onLoadError, this);
25267 ds.un("remove", this.updateInfo, this);
25268 ds.un("add", this.updateInfo, this);
25269 this.ds = undefined;
25273 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25274 * @param {Roo.data.Store} store The data store to bind
25276 bind : function(ds){
25277 ds.on("beforeload", this.beforeLoad, this);
25278 ds.on("load", this.onLoad, this);
25279 ds.on("loadexception", this.onLoadError, this);
25280 ds.on("remove", this.updateInfo, this);
25281 ds.on("add", this.updateInfo, this);
25292 * @class Roo.bootstrap.MessageBar
25293 * @extends Roo.bootstrap.Component
25294 * Bootstrap MessageBar class
25295 * @cfg {String} html contents of the MessageBar
25296 * @cfg {String} weight (info | success | warning | danger) default info
25297 * @cfg {String} beforeClass insert the bar before the given class
25298 * @cfg {Boolean} closable (true | false) default false
25299 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25302 * Create a new Element
25303 * @param {Object} config The config object
25306 Roo.bootstrap.MessageBar = function(config){
25307 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25310 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25316 beforeClass: 'bootstrap-sticky-wrap',
25318 getAutoCreate : function(){
25322 cls: 'alert alert-dismissable alert-' + this.weight,
25327 html: this.html || ''
25333 cfg.cls += ' alert-messages-fixed';
25347 onRender : function(ct, position)
25349 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25352 var cfg = Roo.apply({}, this.getAutoCreate());
25356 cfg.cls += ' ' + this.cls;
25359 cfg.style = this.style;
25361 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25363 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25366 this.el.select('>button.close').on('click', this.hide, this);
25372 if (!this.rendered) {
25378 this.fireEvent('show', this);
25384 if (!this.rendered) {
25390 this.fireEvent('hide', this);
25393 update : function()
25395 // var e = this.el.dom.firstChild;
25397 // if(this.closable){
25398 // e = e.nextSibling;
25401 // e.data = this.html || '';
25403 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25419 * @class Roo.bootstrap.Graph
25420 * @extends Roo.bootstrap.Component
25421 * Bootstrap Graph class
25425 @cfg {String} graphtype bar | vbar | pie
25426 @cfg {number} g_x coodinator | centre x (pie)
25427 @cfg {number} g_y coodinator | centre y (pie)
25428 @cfg {number} g_r radius (pie)
25429 @cfg {number} g_height height of the chart (respected by all elements in the set)
25430 @cfg {number} g_width width of the chart (respected by all elements in the set)
25431 @cfg {Object} title The title of the chart
25434 -opts (object) options for the chart
25436 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25437 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25439 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.
25440 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25442 o stretch (boolean)
25444 -opts (object) options for the pie
25447 o startAngle (number)
25448 o endAngle (number)
25452 * Create a new Input
25453 * @param {Object} config The config object
25456 Roo.bootstrap.Graph = function(config){
25457 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25463 * The img click event for the img.
25464 * @param {Roo.EventObject} e
25470 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25481 //g_colors: this.colors,
25488 getAutoCreate : function(){
25499 onRender : function(ct,position){
25502 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25504 if (typeof(Raphael) == 'undefined') {
25505 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25509 this.raphael = Raphael(this.el.dom);
25511 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25512 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25513 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25514 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25516 r.text(160, 10, "Single Series Chart").attr(txtattr);
25517 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25518 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25519 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25521 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25522 r.barchart(330, 10, 300, 220, data1);
25523 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25524 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25527 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25528 // r.barchart(30, 30, 560, 250, xdata, {
25529 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25530 // axis : "0 0 1 1",
25531 // axisxlabels : xdata
25532 // //yvalues : cols,
25535 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25537 // this.load(null,xdata,{
25538 // axis : "0 0 1 1",
25539 // axisxlabels : xdata
25544 load : function(graphtype,xdata,opts)
25546 this.raphael.clear();
25548 graphtype = this.graphtype;
25553 var r = this.raphael,
25554 fin = function () {
25555 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25557 fout = function () {
25558 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25560 pfin = function() {
25561 this.sector.stop();
25562 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25565 this.label[0].stop();
25566 this.label[0].attr({ r: 7.5 });
25567 this.label[1].attr({ "font-weight": 800 });
25570 pfout = function() {
25571 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25574 this.label[0].animate({ r: 5 }, 500, "bounce");
25575 this.label[1].attr({ "font-weight": 400 });
25581 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25584 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25587 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25588 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25590 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25597 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25602 setTitle: function(o)
25607 initEvents: function() {
25610 this.el.on('click', this.onClick, this);
25614 onClick : function(e)
25616 Roo.log('img onclick');
25617 this.fireEvent('click', this, e);
25629 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25632 * @class Roo.bootstrap.dash.NumberBox
25633 * @extends Roo.bootstrap.Component
25634 * Bootstrap NumberBox class
25635 * @cfg {String} headline Box headline
25636 * @cfg {String} content Box content
25637 * @cfg {String} icon Box icon
25638 * @cfg {String} footer Footer text
25639 * @cfg {String} fhref Footer href
25642 * Create a new NumberBox
25643 * @param {Object} config The config object
25647 Roo.bootstrap.dash.NumberBox = function(config){
25648 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25652 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25661 getAutoCreate : function(){
25665 cls : 'small-box ',
25673 cls : 'roo-headline',
25674 html : this.headline
25678 cls : 'roo-content',
25679 html : this.content
25693 cls : 'ion ' + this.icon
25702 cls : 'small-box-footer',
25703 href : this.fhref || '#',
25707 cfg.cn.push(footer);
25714 onRender : function(ct,position){
25715 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25722 setHeadline: function (value)
25724 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25727 setFooter: function (value, href)
25729 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25732 this.el.select('a.small-box-footer',true).first().attr('href', href);
25737 setContent: function (value)
25739 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25742 initEvents: function()
25756 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25759 * @class Roo.bootstrap.dash.TabBox
25760 * @extends Roo.bootstrap.Component
25761 * Bootstrap TabBox class
25762 * @cfg {String} title Title of the TabBox
25763 * @cfg {String} icon Icon of the TabBox
25764 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25765 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25768 * Create a new TabBox
25769 * @param {Object} config The config object
25773 Roo.bootstrap.dash.TabBox = function(config){
25774 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25779 * When a pane is added
25780 * @param {Roo.bootstrap.dash.TabPane} pane
25784 * @event activatepane
25785 * When a pane is activated
25786 * @param {Roo.bootstrap.dash.TabPane} pane
25788 "activatepane" : true
25796 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25801 tabScrollable : false,
25803 getChildContainer : function()
25805 return this.el.select('.tab-content', true).first();
25808 getAutoCreate : function(){
25812 cls: 'pull-left header',
25820 cls: 'fa ' + this.icon
25826 cls: 'nav nav-tabs pull-right',
25832 if(this.tabScrollable){
25839 cls: 'nav nav-tabs pull-right',
25850 cls: 'nav-tabs-custom',
25855 cls: 'tab-content no-padding',
25863 initEvents : function()
25865 //Roo.log('add add pane handler');
25866 this.on('addpane', this.onAddPane, this);
25869 * Updates the box title
25870 * @param {String} html to set the title to.
25872 setTitle : function(value)
25874 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25876 onAddPane : function(pane)
25878 this.panes.push(pane);
25879 //Roo.log('addpane');
25881 // tabs are rendere left to right..
25882 if(!this.showtabs){
25886 var ctr = this.el.select('.nav-tabs', true).first();
25889 var existing = ctr.select('.nav-tab',true);
25890 var qty = existing.getCount();;
25893 var tab = ctr.createChild({
25895 cls : 'nav-tab' + (qty ? '' : ' active'),
25903 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25906 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25908 pane.el.addClass('active');
25913 onTabClick : function(ev,un,ob,pane)
25915 //Roo.log('tab - prev default');
25916 ev.preventDefault();
25919 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25920 pane.tab.addClass('active');
25921 //Roo.log(pane.title);
25922 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25923 // technically we should have a deactivate event.. but maybe add later.
25924 // and it should not de-activate the selected tab...
25925 this.fireEvent('activatepane', pane);
25926 pane.el.addClass('active');
25927 pane.fireEvent('activate');
25932 getActivePane : function()
25935 Roo.each(this.panes, function(p) {
25936 if(p.el.hasClass('active')){
25957 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25959 * @class Roo.bootstrap.TabPane
25960 * @extends Roo.bootstrap.Component
25961 * Bootstrap TabPane class
25962 * @cfg {Boolean} active (false | true) Default false
25963 * @cfg {String} title title of panel
25967 * Create a new TabPane
25968 * @param {Object} config The config object
25971 Roo.bootstrap.dash.TabPane = function(config){
25972 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25978 * When a pane is activated
25979 * @param {Roo.bootstrap.dash.TabPane} pane
25986 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25991 // the tabBox that this is attached to.
25994 getAutoCreate : function()
26002 cfg.cls += ' active';
26007 initEvents : function()
26009 //Roo.log('trigger add pane handler');
26010 this.parent().fireEvent('addpane', this)
26014 * Updates the tab title
26015 * @param {String} html to set the title to.
26017 setTitle: function(str)
26023 this.tab.select('a', true).first().dom.innerHTML = str;
26040 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26043 * @class Roo.bootstrap.menu.Menu
26044 * @extends Roo.bootstrap.Component
26045 * Bootstrap Menu class - container for Menu
26046 * @cfg {String} html Text of the menu
26047 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26048 * @cfg {String} icon Font awesome icon
26049 * @cfg {String} pos Menu align to (top | bottom) default bottom
26053 * Create a new Menu
26054 * @param {Object} config The config object
26058 Roo.bootstrap.menu.Menu = function(config){
26059 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26063 * @event beforeshow
26064 * Fires before this menu is displayed
26065 * @param {Roo.bootstrap.menu.Menu} this
26069 * @event beforehide
26070 * Fires before this menu is hidden
26071 * @param {Roo.bootstrap.menu.Menu} this
26076 * Fires after this menu is displayed
26077 * @param {Roo.bootstrap.menu.Menu} this
26082 * Fires after this menu is hidden
26083 * @param {Roo.bootstrap.menu.Menu} this
26088 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26089 * @param {Roo.bootstrap.menu.Menu} this
26090 * @param {Roo.EventObject} e
26097 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26101 weight : 'default',
26106 getChildContainer : function() {
26107 if(this.isSubMenu){
26111 return this.el.select('ul.dropdown-menu', true).first();
26114 getAutoCreate : function()
26119 cls : 'roo-menu-text',
26127 cls : 'fa ' + this.icon
26138 cls : 'dropdown-button btn btn-' + this.weight,
26143 cls : 'dropdown-toggle btn btn-' + this.weight,
26153 cls : 'dropdown-menu'
26159 if(this.pos == 'top'){
26160 cfg.cls += ' dropup';
26163 if(this.isSubMenu){
26166 cls : 'dropdown-menu'
26173 onRender : function(ct, position)
26175 this.isSubMenu = ct.hasClass('dropdown-submenu');
26177 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26180 initEvents : function()
26182 if(this.isSubMenu){
26186 this.hidden = true;
26188 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26189 this.triggerEl.on('click', this.onTriggerPress, this);
26191 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26192 this.buttonEl.on('click', this.onClick, this);
26198 if(this.isSubMenu){
26202 return this.el.select('ul.dropdown-menu', true).first();
26205 onClick : function(e)
26207 this.fireEvent("click", this, e);
26210 onTriggerPress : function(e)
26212 if (this.isVisible()) {
26219 isVisible : function(){
26220 return !this.hidden;
26225 this.fireEvent("beforeshow", this);
26227 this.hidden = false;
26228 this.el.addClass('open');
26230 Roo.get(document).on("mouseup", this.onMouseUp, this);
26232 this.fireEvent("show", this);
26239 this.fireEvent("beforehide", this);
26241 this.hidden = true;
26242 this.el.removeClass('open');
26244 Roo.get(document).un("mouseup", this.onMouseUp);
26246 this.fireEvent("hide", this);
26249 onMouseUp : function()
26263 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26266 * @class Roo.bootstrap.menu.Item
26267 * @extends Roo.bootstrap.Component
26268 * Bootstrap MenuItem class
26269 * @cfg {Boolean} submenu (true | false) default false
26270 * @cfg {String} html text of the item
26271 * @cfg {String} href the link
26272 * @cfg {Boolean} disable (true | false) default false
26273 * @cfg {Boolean} preventDefault (true | false) default true
26274 * @cfg {String} icon Font awesome icon
26275 * @cfg {String} pos Submenu align to (left | right) default right
26279 * Create a new Item
26280 * @param {Object} config The config object
26284 Roo.bootstrap.menu.Item = function(config){
26285 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26289 * Fires when the mouse is hovering over this menu
26290 * @param {Roo.bootstrap.menu.Item} this
26291 * @param {Roo.EventObject} e
26296 * Fires when the mouse exits this menu
26297 * @param {Roo.bootstrap.menu.Item} this
26298 * @param {Roo.EventObject} e
26304 * The raw click event for the entire grid.
26305 * @param {Roo.EventObject} e
26311 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26316 preventDefault: true,
26321 getAutoCreate : function()
26326 cls : 'roo-menu-item-text',
26334 cls : 'fa ' + this.icon
26343 href : this.href || '#',
26350 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26354 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26356 if(this.pos == 'left'){
26357 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26364 initEvents : function()
26366 this.el.on('mouseover', this.onMouseOver, this);
26367 this.el.on('mouseout', this.onMouseOut, this);
26369 this.el.select('a', true).first().on('click', this.onClick, this);
26373 onClick : function(e)
26375 if(this.preventDefault){
26376 e.preventDefault();
26379 this.fireEvent("click", this, e);
26382 onMouseOver : function(e)
26384 if(this.submenu && this.pos == 'left'){
26385 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26388 this.fireEvent("mouseover", this, e);
26391 onMouseOut : function(e)
26393 this.fireEvent("mouseout", this, e);
26405 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26408 * @class Roo.bootstrap.menu.Separator
26409 * @extends Roo.bootstrap.Component
26410 * Bootstrap Separator class
26413 * Create a new Separator
26414 * @param {Object} config The config object
26418 Roo.bootstrap.menu.Separator = function(config){
26419 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26422 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26424 getAutoCreate : function(){
26445 * @class Roo.bootstrap.Tooltip
26446 * Bootstrap Tooltip class
26447 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26448 * to determine which dom element triggers the tooltip.
26450 * It needs to add support for additional attributes like tooltip-position
26453 * Create a new Toolti
26454 * @param {Object} config The config object
26457 Roo.bootstrap.Tooltip = function(config){
26458 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26460 this.alignment = Roo.bootstrap.Tooltip.alignment;
26462 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26463 this.alignment = config.alignment;
26468 Roo.apply(Roo.bootstrap.Tooltip, {
26470 * @function init initialize tooltip monitoring.
26474 currentTip : false,
26475 currentRegion : false,
26481 Roo.get(document).on('mouseover', this.enter ,this);
26482 Roo.get(document).on('mouseout', this.leave, this);
26485 this.currentTip = new Roo.bootstrap.Tooltip();
26488 enter : function(ev)
26490 var dom = ev.getTarget();
26492 //Roo.log(['enter',dom]);
26493 var el = Roo.fly(dom);
26494 if (this.currentEl) {
26496 //Roo.log(this.currentEl);
26497 //Roo.log(this.currentEl.contains(dom));
26498 if (this.currentEl == el) {
26501 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26507 if (this.currentTip.el) {
26508 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26512 if(!el || el.dom == document){
26518 // you can not look for children, as if el is the body.. then everythign is the child..
26519 if (!el.attr('tooltip')) { //
26520 if (!el.select("[tooltip]").elements.length) {
26523 // is the mouse over this child...?
26524 bindEl = el.select("[tooltip]").first();
26525 var xy = ev.getXY();
26526 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26527 //Roo.log("not in region.");
26530 //Roo.log("child element over..");
26533 this.currentEl = bindEl;
26534 this.currentTip.bind(bindEl);
26535 this.currentRegion = Roo.lib.Region.getRegion(dom);
26536 this.currentTip.enter();
26539 leave : function(ev)
26541 var dom = ev.getTarget();
26542 //Roo.log(['leave',dom]);
26543 if (!this.currentEl) {
26548 if (dom != this.currentEl.dom) {
26551 var xy = ev.getXY();
26552 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26555 // only activate leave if mouse cursor is outside... bounding box..
26560 if (this.currentTip) {
26561 this.currentTip.leave();
26563 //Roo.log('clear currentEl');
26564 this.currentEl = false;
26569 'left' : ['r-l', [-2,0], 'right'],
26570 'right' : ['l-r', [2,0], 'left'],
26571 'bottom' : ['t-b', [0,2], 'top'],
26572 'top' : [ 'b-t', [0,-2], 'bottom']
26578 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26583 delay : null, // can be { show : 300 , hide: 500}
26587 hoverState : null, //???
26589 placement : 'bottom',
26593 getAutoCreate : function(){
26600 cls : 'tooltip-arrow'
26603 cls : 'tooltip-inner'
26610 bind : function(el)
26616 enter : function () {
26618 if (this.timeout != null) {
26619 clearTimeout(this.timeout);
26622 this.hoverState = 'in';
26623 //Roo.log("enter - show");
26624 if (!this.delay || !this.delay.show) {
26629 this.timeout = setTimeout(function () {
26630 if (_t.hoverState == 'in') {
26633 }, this.delay.show);
26637 clearTimeout(this.timeout);
26639 this.hoverState = 'out';
26640 if (!this.delay || !this.delay.hide) {
26646 this.timeout = setTimeout(function () {
26647 //Roo.log("leave - timeout");
26649 if (_t.hoverState == 'out') {
26651 Roo.bootstrap.Tooltip.currentEl = false;
26656 show : function (msg)
26659 this.render(document.body);
26662 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26664 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26666 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26668 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26670 var placement = typeof this.placement == 'function' ?
26671 this.placement.call(this, this.el, on_el) :
26674 var autoToken = /\s?auto?\s?/i;
26675 var autoPlace = autoToken.test(placement);
26677 placement = placement.replace(autoToken, '') || 'top';
26681 //this.el.setXY([0,0]);
26683 //this.el.dom.style.display='block';
26685 //this.el.appendTo(on_el);
26687 var p = this.getPosition();
26688 var box = this.el.getBox();
26694 var align = this.alignment[placement];
26696 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26698 if(placement == 'top' || placement == 'bottom'){
26700 placement = 'right';
26703 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26704 placement = 'left';
26707 var scroll = Roo.select('body', true).first().getScroll();
26709 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26713 align = this.alignment[placement];
26716 this.el.alignTo(this.bindEl, align[0],align[1]);
26717 //var arrow = this.el.select('.arrow',true).first();
26718 //arrow.set(align[2],
26720 this.el.addClass(placement);
26722 this.el.addClass('in fade');
26724 this.hoverState = null;
26726 if (this.el.hasClass('fade')) {
26737 //this.el.setXY([0,0]);
26738 this.el.removeClass('in');
26754 * @class Roo.bootstrap.LocationPicker
26755 * @extends Roo.bootstrap.Component
26756 * Bootstrap LocationPicker class
26757 * @cfg {Number} latitude Position when init default 0
26758 * @cfg {Number} longitude Position when init default 0
26759 * @cfg {Number} zoom default 15
26760 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26761 * @cfg {Boolean} mapTypeControl default false
26762 * @cfg {Boolean} disableDoubleClickZoom default false
26763 * @cfg {Boolean} scrollwheel default true
26764 * @cfg {Boolean} streetViewControl default false
26765 * @cfg {Number} radius default 0
26766 * @cfg {String} locationName
26767 * @cfg {Boolean} draggable default true
26768 * @cfg {Boolean} enableAutocomplete default false
26769 * @cfg {Boolean} enableReverseGeocode default true
26770 * @cfg {String} markerTitle
26773 * Create a new LocationPicker
26774 * @param {Object} config The config object
26778 Roo.bootstrap.LocationPicker = function(config){
26780 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26785 * Fires when the picker initialized.
26786 * @param {Roo.bootstrap.LocationPicker} this
26787 * @param {Google Location} location
26791 * @event positionchanged
26792 * Fires when the picker position changed.
26793 * @param {Roo.bootstrap.LocationPicker} this
26794 * @param {Google Location} location
26796 positionchanged : true,
26799 * Fires when the map resize.
26800 * @param {Roo.bootstrap.LocationPicker} this
26805 * Fires when the map show.
26806 * @param {Roo.bootstrap.LocationPicker} this
26811 * Fires when the map hide.
26812 * @param {Roo.bootstrap.LocationPicker} this
26817 * Fires when click the map.
26818 * @param {Roo.bootstrap.LocationPicker} this
26819 * @param {Map event} e
26823 * @event mapRightClick
26824 * Fires when right click the map.
26825 * @param {Roo.bootstrap.LocationPicker} this
26826 * @param {Map event} e
26828 mapRightClick : true,
26830 * @event markerClick
26831 * Fires when click the marker.
26832 * @param {Roo.bootstrap.LocationPicker} this
26833 * @param {Map event} e
26835 markerClick : true,
26837 * @event markerRightClick
26838 * Fires when right click the marker.
26839 * @param {Roo.bootstrap.LocationPicker} this
26840 * @param {Map event} e
26842 markerRightClick : true,
26844 * @event OverlayViewDraw
26845 * Fires when OverlayView Draw
26846 * @param {Roo.bootstrap.LocationPicker} this
26848 OverlayViewDraw : true,
26850 * @event OverlayViewOnAdd
26851 * Fires when OverlayView Draw
26852 * @param {Roo.bootstrap.LocationPicker} this
26854 OverlayViewOnAdd : true,
26856 * @event OverlayViewOnRemove
26857 * Fires when OverlayView Draw
26858 * @param {Roo.bootstrap.LocationPicker} this
26860 OverlayViewOnRemove : true,
26862 * @event OverlayViewShow
26863 * Fires when OverlayView Draw
26864 * @param {Roo.bootstrap.LocationPicker} this
26865 * @param {Pixel} cpx
26867 OverlayViewShow : true,
26869 * @event OverlayViewHide
26870 * Fires when OverlayView Draw
26871 * @param {Roo.bootstrap.LocationPicker} this
26873 OverlayViewHide : true,
26875 * @event loadexception
26876 * Fires when load google lib failed.
26877 * @param {Roo.bootstrap.LocationPicker} this
26879 loadexception : true
26884 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26886 gMapContext: false,
26892 mapTypeControl: false,
26893 disableDoubleClickZoom: false,
26895 streetViewControl: false,
26899 enableAutocomplete: false,
26900 enableReverseGeocode: true,
26903 getAutoCreate: function()
26908 cls: 'roo-location-picker'
26914 initEvents: function(ct, position)
26916 if(!this.el.getWidth() || this.isApplied()){
26920 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26925 initial: function()
26927 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26928 this.fireEvent('loadexception', this);
26932 if(!this.mapTypeId){
26933 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26936 this.gMapContext = this.GMapContext();
26938 this.initOverlayView();
26940 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26944 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26945 _this.setPosition(_this.gMapContext.marker.position);
26948 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26949 _this.fireEvent('mapClick', this, event);
26953 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26954 _this.fireEvent('mapRightClick', this, event);
26958 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26959 _this.fireEvent('markerClick', this, event);
26963 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26964 _this.fireEvent('markerRightClick', this, event);
26968 this.setPosition(this.gMapContext.location);
26970 this.fireEvent('initial', this, this.gMapContext.location);
26973 initOverlayView: function()
26977 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26981 _this.fireEvent('OverlayViewDraw', _this);
26986 _this.fireEvent('OverlayViewOnAdd', _this);
26989 onRemove: function()
26991 _this.fireEvent('OverlayViewOnRemove', _this);
26994 show: function(cpx)
26996 _this.fireEvent('OverlayViewShow', _this, cpx);
27001 _this.fireEvent('OverlayViewHide', _this);
27007 fromLatLngToContainerPixel: function(event)
27009 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
27012 isApplied: function()
27014 return this.getGmapContext() == false ? false : true;
27017 getGmapContext: function()
27019 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
27022 GMapContext: function()
27024 var position = new google.maps.LatLng(this.latitude, this.longitude);
27026 var _map = new google.maps.Map(this.el.dom, {
27029 mapTypeId: this.mapTypeId,
27030 mapTypeControl: this.mapTypeControl,
27031 disableDoubleClickZoom: this.disableDoubleClickZoom,
27032 scrollwheel: this.scrollwheel,
27033 streetViewControl: this.streetViewControl,
27034 locationName: this.locationName,
27035 draggable: this.draggable,
27036 enableAutocomplete: this.enableAutocomplete,
27037 enableReverseGeocode: this.enableReverseGeocode
27040 var _marker = new google.maps.Marker({
27041 position: position,
27043 title: this.markerTitle,
27044 draggable: this.draggable
27051 location: position,
27052 radius: this.radius,
27053 locationName: this.locationName,
27054 addressComponents: {
27055 formatted_address: null,
27056 addressLine1: null,
27057 addressLine2: null,
27059 streetNumber: null,
27063 stateOrProvince: null
27066 domContainer: this.el.dom,
27067 geodecoder: new google.maps.Geocoder()
27071 drawCircle: function(center, radius, options)
27073 if (this.gMapContext.circle != null) {
27074 this.gMapContext.circle.setMap(null);
27078 options = Roo.apply({}, options, {
27079 strokeColor: "#0000FF",
27080 strokeOpacity: .35,
27082 fillColor: "#0000FF",
27086 options.map = this.gMapContext.map;
27087 options.radius = radius;
27088 options.center = center;
27089 this.gMapContext.circle = new google.maps.Circle(options);
27090 return this.gMapContext.circle;
27096 setPosition: function(location)
27098 this.gMapContext.location = location;
27099 this.gMapContext.marker.setPosition(location);
27100 this.gMapContext.map.panTo(location);
27101 this.drawCircle(location, this.gMapContext.radius, {});
27105 if (this.gMapContext.settings.enableReverseGeocode) {
27106 this.gMapContext.geodecoder.geocode({
27107 latLng: this.gMapContext.location
27108 }, function(results, status) {
27110 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27111 _this.gMapContext.locationName = results[0].formatted_address;
27112 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27114 _this.fireEvent('positionchanged', this, location);
27121 this.fireEvent('positionchanged', this, location);
27126 google.maps.event.trigger(this.gMapContext.map, "resize");
27128 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27130 this.fireEvent('resize', this);
27133 setPositionByLatLng: function(latitude, longitude)
27135 this.setPosition(new google.maps.LatLng(latitude, longitude));
27138 getCurrentPosition: function()
27141 latitude: this.gMapContext.location.lat(),
27142 longitude: this.gMapContext.location.lng()
27146 getAddressName: function()
27148 return this.gMapContext.locationName;
27151 getAddressComponents: function()
27153 return this.gMapContext.addressComponents;
27156 address_component_from_google_geocode: function(address_components)
27160 for (var i = 0; i < address_components.length; i++) {
27161 var component = address_components[i];
27162 if (component.types.indexOf("postal_code") >= 0) {
27163 result.postalCode = component.short_name;
27164 } else if (component.types.indexOf("street_number") >= 0) {
27165 result.streetNumber = component.short_name;
27166 } else if (component.types.indexOf("route") >= 0) {
27167 result.streetName = component.short_name;
27168 } else if (component.types.indexOf("neighborhood") >= 0) {
27169 result.city = component.short_name;
27170 } else if (component.types.indexOf("locality") >= 0) {
27171 result.city = component.short_name;
27172 } else if (component.types.indexOf("sublocality") >= 0) {
27173 result.district = component.short_name;
27174 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27175 result.stateOrProvince = component.short_name;
27176 } else if (component.types.indexOf("country") >= 0) {
27177 result.country = component.short_name;
27181 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27182 result.addressLine2 = "";
27186 setZoomLevel: function(zoom)
27188 this.gMapContext.map.setZoom(zoom);
27201 this.fireEvent('show', this);
27212 this.fireEvent('hide', this);
27217 Roo.apply(Roo.bootstrap.LocationPicker, {
27219 OverlayView : function(map, options)
27221 options = options || {};
27228 * @class Roo.bootstrap.Alert
27229 * @extends Roo.bootstrap.Component
27230 * Bootstrap Alert class - shows an alert area box
27232 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
27233 Enter a valid email address
27236 * @cfg {String} title The title of alert
27237 * @cfg {String} html The content of alert
27238 * @cfg {String} weight ( success | info | warning | danger )
27239 * @cfg {String} faicon font-awesomeicon
27242 * Create a new alert
27243 * @param {Object} config The config object
27247 Roo.bootstrap.Alert = function(config){
27248 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27252 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27259 getAutoCreate : function()
27268 cls : 'roo-alert-icon'
27273 cls : 'roo-alert-title',
27278 cls : 'roo-alert-text',
27285 cfg.cn[0].cls += ' fa ' + this.faicon;
27289 cfg.cls += ' alert-' + this.weight;
27295 initEvents: function()
27297 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27300 setTitle : function(str)
27302 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27305 setText : function(str)
27307 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27310 setWeight : function(weight)
27313 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27316 this.weight = weight;
27318 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27321 setIcon : function(icon)
27324 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27327 this.faicon = icon;
27329 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27350 * @class Roo.bootstrap.UploadCropbox
27351 * @extends Roo.bootstrap.Component
27352 * Bootstrap UploadCropbox class
27353 * @cfg {String} emptyText show when image has been loaded
27354 * @cfg {String} rotateNotify show when image too small to rotate
27355 * @cfg {Number} errorTimeout default 3000
27356 * @cfg {Number} minWidth default 300
27357 * @cfg {Number} minHeight default 300
27358 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27359 * @cfg {Boolean} isDocument (true|false) default false
27360 * @cfg {String} url action url
27361 * @cfg {String} paramName default 'imageUpload'
27362 * @cfg {String} method default POST
27363 * @cfg {Boolean} loadMask (true|false) default true
27364 * @cfg {Boolean} loadingText default 'Loading...'
27367 * Create a new UploadCropbox
27368 * @param {Object} config The config object
27371 Roo.bootstrap.UploadCropbox = function(config){
27372 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27376 * @event beforeselectfile
27377 * Fire before select file
27378 * @param {Roo.bootstrap.UploadCropbox} this
27380 "beforeselectfile" : true,
27383 * Fire after initEvent
27384 * @param {Roo.bootstrap.UploadCropbox} this
27389 * Fire after initEvent
27390 * @param {Roo.bootstrap.UploadCropbox} this
27391 * @param {String} data
27396 * Fire when preparing the file data
27397 * @param {Roo.bootstrap.UploadCropbox} this
27398 * @param {Object} file
27403 * Fire when get exception
27404 * @param {Roo.bootstrap.UploadCropbox} this
27405 * @param {XMLHttpRequest} xhr
27407 "exception" : true,
27409 * @event beforeloadcanvas
27410 * Fire before load the canvas
27411 * @param {Roo.bootstrap.UploadCropbox} this
27412 * @param {String} src
27414 "beforeloadcanvas" : true,
27417 * Fire when trash image
27418 * @param {Roo.bootstrap.UploadCropbox} this
27423 * Fire when download the image
27424 * @param {Roo.bootstrap.UploadCropbox} this
27428 * @event footerbuttonclick
27429 * Fire when footerbuttonclick
27430 * @param {Roo.bootstrap.UploadCropbox} this
27431 * @param {String} type
27433 "footerbuttonclick" : true,
27437 * @param {Roo.bootstrap.UploadCropbox} this
27442 * Fire when rotate the image
27443 * @param {Roo.bootstrap.UploadCropbox} this
27444 * @param {String} pos
27449 * Fire when inspect the file
27450 * @param {Roo.bootstrap.UploadCropbox} this
27451 * @param {Object} file
27456 * Fire when xhr upload the file
27457 * @param {Roo.bootstrap.UploadCropbox} this
27458 * @param {Object} data
27463 * Fire when arrange the file data
27464 * @param {Roo.bootstrap.UploadCropbox} this
27465 * @param {Object} formData
27470 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27473 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27475 emptyText : 'Click to upload image',
27476 rotateNotify : 'Image is too small to rotate',
27477 errorTimeout : 3000,
27491 cropType : 'image/jpeg',
27493 canvasLoaded : false,
27494 isDocument : false,
27496 paramName : 'imageUpload',
27498 loadingText : 'Loading...',
27501 getAutoCreate : function()
27505 cls : 'roo-upload-cropbox',
27509 cls : 'roo-upload-cropbox-selector',
27514 cls : 'roo-upload-cropbox-body',
27515 style : 'cursor:pointer',
27519 cls : 'roo-upload-cropbox-preview'
27523 cls : 'roo-upload-cropbox-thumb'
27527 cls : 'roo-upload-cropbox-empty-notify',
27528 html : this.emptyText
27532 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27533 html : this.rotateNotify
27539 cls : 'roo-upload-cropbox-footer',
27542 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27552 onRender : function(ct, position)
27554 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27556 if (this.buttons.length) {
27558 Roo.each(this.buttons, function(bb) {
27560 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27562 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27568 this.maskEl = this.el;
27572 initEvents : function()
27574 this.urlAPI = (window.createObjectURL && window) ||
27575 (window.URL && URL.revokeObjectURL && URL) ||
27576 (window.webkitURL && webkitURL);
27578 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27579 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27581 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27582 this.selectorEl.hide();
27584 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27585 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27587 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27588 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27589 this.thumbEl.hide();
27591 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27592 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27594 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27595 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27596 this.errorEl.hide();
27598 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27599 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27600 this.footerEl.hide();
27602 this.setThumbBoxSize();
27608 this.fireEvent('initial', this);
27615 window.addEventListener("resize", function() { _this.resize(); } );
27617 this.bodyEl.on('click', this.beforeSelectFile, this);
27620 this.bodyEl.on('touchstart', this.onTouchStart, this);
27621 this.bodyEl.on('touchmove', this.onTouchMove, this);
27622 this.bodyEl.on('touchend', this.onTouchEnd, this);
27626 this.bodyEl.on('mousedown', this.onMouseDown, this);
27627 this.bodyEl.on('mousemove', this.onMouseMove, this);
27628 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27629 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27630 Roo.get(document).on('mouseup', this.onMouseUp, this);
27633 this.selectorEl.on('change', this.onFileSelected, this);
27639 this.baseScale = 1;
27641 this.baseRotate = 1;
27642 this.dragable = false;
27643 this.pinching = false;
27646 this.cropData = false;
27647 this.notifyEl.dom.innerHTML = this.emptyText;
27649 this.selectorEl.dom.value = '';
27653 resize : function()
27655 if(this.fireEvent('resize', this) != false){
27656 this.setThumbBoxPosition();
27657 this.setCanvasPosition();
27661 onFooterButtonClick : function(e, el, o, type)
27664 case 'rotate-left' :
27665 this.onRotateLeft(e);
27667 case 'rotate-right' :
27668 this.onRotateRight(e);
27671 this.beforeSelectFile(e);
27686 this.fireEvent('footerbuttonclick', this, type);
27689 beforeSelectFile : function(e)
27691 e.preventDefault();
27693 if(this.fireEvent('beforeselectfile', this) != false){
27694 this.selectorEl.dom.click();
27698 onFileSelected : function(e)
27700 e.preventDefault();
27702 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27706 var file = this.selectorEl.dom.files[0];
27708 if(this.fireEvent('inspect', this, file) != false){
27709 this.prepare(file);
27714 trash : function(e)
27716 this.fireEvent('trash', this);
27719 download : function(e)
27721 this.fireEvent('download', this);
27724 loadCanvas : function(src)
27726 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27730 this.imageEl = document.createElement('img');
27734 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27736 this.imageEl.src = src;
27740 onLoadCanvas : function()
27742 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27743 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27745 this.bodyEl.un('click', this.beforeSelectFile, this);
27747 this.notifyEl.hide();
27748 this.thumbEl.show();
27749 this.footerEl.show();
27751 this.baseRotateLevel();
27753 if(this.isDocument){
27754 this.setThumbBoxSize();
27757 this.setThumbBoxPosition();
27759 this.baseScaleLevel();
27765 this.canvasLoaded = true;
27768 this.maskEl.unmask();
27773 setCanvasPosition : function()
27775 if(!this.canvasEl){
27779 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27780 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27782 this.previewEl.setLeft(pw);
27783 this.previewEl.setTop(ph);
27787 onMouseDown : function(e)
27791 this.dragable = true;
27792 this.pinching = false;
27794 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27795 this.dragable = false;
27799 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27800 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27804 onMouseMove : function(e)
27808 if(!this.canvasLoaded){
27812 if (!this.dragable){
27816 var minX = Math.ceil(this.thumbEl.getLeft(true));
27817 var minY = Math.ceil(this.thumbEl.getTop(true));
27819 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27820 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27822 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27823 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27825 x = x - this.mouseX;
27826 y = y - this.mouseY;
27828 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27829 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27831 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27832 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27834 this.previewEl.setLeft(bgX);
27835 this.previewEl.setTop(bgY);
27837 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27838 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27841 onMouseUp : function(e)
27845 this.dragable = false;
27848 onMouseWheel : function(e)
27852 this.startScale = this.scale;
27854 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27856 if(!this.zoomable()){
27857 this.scale = this.startScale;
27866 zoomable : function()
27868 var minScale = this.thumbEl.getWidth() / this.minWidth;
27870 if(this.minWidth < this.minHeight){
27871 minScale = this.thumbEl.getHeight() / this.minHeight;
27874 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27875 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27879 (this.rotate == 0 || this.rotate == 180) &&
27881 width > this.imageEl.OriginWidth ||
27882 height > this.imageEl.OriginHeight ||
27883 (width < this.minWidth && height < this.minHeight)
27891 (this.rotate == 90 || this.rotate == 270) &&
27893 width > this.imageEl.OriginWidth ||
27894 height > this.imageEl.OriginHeight ||
27895 (width < this.minHeight && height < this.minWidth)
27902 !this.isDocument &&
27903 (this.rotate == 0 || this.rotate == 180) &&
27905 width < this.minWidth ||
27906 width > this.imageEl.OriginWidth ||
27907 height < this.minHeight ||
27908 height > this.imageEl.OriginHeight
27915 !this.isDocument &&
27916 (this.rotate == 90 || this.rotate == 270) &&
27918 width < this.minHeight ||
27919 width > this.imageEl.OriginWidth ||
27920 height < this.minWidth ||
27921 height > this.imageEl.OriginHeight
27931 onRotateLeft : function(e)
27933 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27935 var minScale = this.thumbEl.getWidth() / this.minWidth;
27937 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27938 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27940 this.startScale = this.scale;
27942 while (this.getScaleLevel() < minScale){
27944 this.scale = this.scale + 1;
27946 if(!this.zoomable()){
27951 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27952 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27957 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27964 this.scale = this.startScale;
27966 this.onRotateFail();
27971 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27973 if(this.isDocument){
27974 this.setThumbBoxSize();
27975 this.setThumbBoxPosition();
27976 this.setCanvasPosition();
27981 this.fireEvent('rotate', this, 'left');
27985 onRotateRight : function(e)
27987 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27989 var minScale = this.thumbEl.getWidth() / this.minWidth;
27991 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27992 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27994 this.startScale = this.scale;
27996 while (this.getScaleLevel() < minScale){
27998 this.scale = this.scale + 1;
28000 if(!this.zoomable()){
28005 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
28006 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
28011 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28018 this.scale = this.startScale;
28020 this.onRotateFail();
28025 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28027 if(this.isDocument){
28028 this.setThumbBoxSize();
28029 this.setThumbBoxPosition();
28030 this.setCanvasPosition();
28035 this.fireEvent('rotate', this, 'right');
28038 onRotateFail : function()
28040 this.errorEl.show(true);
28044 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28049 this.previewEl.dom.innerHTML = '';
28051 var canvasEl = document.createElement("canvas");
28053 var contextEl = canvasEl.getContext("2d");
28055 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28056 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28057 var center = this.imageEl.OriginWidth / 2;
28059 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28060 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28061 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28062 center = this.imageEl.OriginHeight / 2;
28065 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28067 contextEl.translate(center, center);
28068 contextEl.rotate(this.rotate * Math.PI / 180);
28070 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28072 this.canvasEl = document.createElement("canvas");
28074 this.contextEl = this.canvasEl.getContext("2d");
28076 switch (this.rotate) {
28079 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28080 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28082 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28087 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28088 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28090 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28091 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);
28095 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28100 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28101 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28103 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28104 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);
28108 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);
28113 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28114 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28116 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28117 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28121 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);
28128 this.previewEl.appendChild(this.canvasEl);
28130 this.setCanvasPosition();
28135 if(!this.canvasLoaded){
28139 var imageCanvas = document.createElement("canvas");
28141 var imageContext = imageCanvas.getContext("2d");
28143 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28144 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28146 var center = imageCanvas.width / 2;
28148 imageContext.translate(center, center);
28150 imageContext.rotate(this.rotate * Math.PI / 180);
28152 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28154 var canvas = document.createElement("canvas");
28156 var context = canvas.getContext("2d");
28158 canvas.width = this.minWidth;
28159 canvas.height = this.minHeight;
28161 switch (this.rotate) {
28164 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28165 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28167 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28168 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28170 var targetWidth = this.minWidth - 2 * x;
28171 var targetHeight = this.minHeight - 2 * y;
28175 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28176 scale = targetWidth / width;
28179 if(x > 0 && y == 0){
28180 scale = targetHeight / height;
28183 if(x > 0 && y > 0){
28184 scale = targetWidth / width;
28186 if(width < height){
28187 scale = targetHeight / height;
28191 context.scale(scale, scale);
28193 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28194 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28196 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28197 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28199 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28204 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28205 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28207 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28208 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28210 var targetWidth = this.minWidth - 2 * x;
28211 var targetHeight = this.minHeight - 2 * y;
28215 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28216 scale = targetWidth / width;
28219 if(x > 0 && y == 0){
28220 scale = targetHeight / height;
28223 if(x > 0 && y > 0){
28224 scale = targetWidth / width;
28226 if(width < height){
28227 scale = targetHeight / height;
28231 context.scale(scale, scale);
28233 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28234 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28236 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28237 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28239 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28241 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28246 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28247 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28249 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28250 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28252 var targetWidth = this.minWidth - 2 * x;
28253 var targetHeight = this.minHeight - 2 * y;
28257 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28258 scale = targetWidth / width;
28261 if(x > 0 && y == 0){
28262 scale = targetHeight / height;
28265 if(x > 0 && y > 0){
28266 scale = targetWidth / width;
28268 if(width < height){
28269 scale = targetHeight / height;
28273 context.scale(scale, scale);
28275 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28276 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28278 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28279 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28281 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28282 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28284 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28289 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28290 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28292 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28293 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28295 var targetWidth = this.minWidth - 2 * x;
28296 var targetHeight = this.minHeight - 2 * y;
28300 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28301 scale = targetWidth / width;
28304 if(x > 0 && y == 0){
28305 scale = targetHeight / height;
28308 if(x > 0 && y > 0){
28309 scale = targetWidth / width;
28311 if(width < height){
28312 scale = targetHeight / height;
28316 context.scale(scale, scale);
28318 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28319 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28321 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28322 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28324 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28326 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28333 this.cropData = canvas.toDataURL(this.cropType);
28335 if(this.fireEvent('crop', this, this.cropData) !== false){
28336 this.process(this.file, this.cropData);
28343 setThumbBoxSize : function()
28347 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28348 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28349 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28351 this.minWidth = width;
28352 this.minHeight = height;
28354 if(this.rotate == 90 || this.rotate == 270){
28355 this.minWidth = height;
28356 this.minHeight = width;
28361 width = Math.ceil(this.minWidth * height / this.minHeight);
28363 if(this.minWidth > this.minHeight){
28365 height = Math.ceil(this.minHeight * width / this.minWidth);
28368 this.thumbEl.setStyle({
28369 width : width + 'px',
28370 height : height + 'px'
28377 setThumbBoxPosition : function()
28379 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28380 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28382 this.thumbEl.setLeft(x);
28383 this.thumbEl.setTop(y);
28387 baseRotateLevel : function()
28389 this.baseRotate = 1;
28392 typeof(this.exif) != 'undefined' &&
28393 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28394 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28396 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28399 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28403 baseScaleLevel : function()
28407 if(this.isDocument){
28409 if(this.baseRotate == 6 || this.baseRotate == 8){
28411 height = this.thumbEl.getHeight();
28412 this.baseScale = height / this.imageEl.OriginWidth;
28414 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28415 width = this.thumbEl.getWidth();
28416 this.baseScale = width / this.imageEl.OriginHeight;
28422 height = this.thumbEl.getHeight();
28423 this.baseScale = height / this.imageEl.OriginHeight;
28425 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28426 width = this.thumbEl.getWidth();
28427 this.baseScale = width / this.imageEl.OriginWidth;
28433 if(this.baseRotate == 6 || this.baseRotate == 8){
28435 width = this.thumbEl.getHeight();
28436 this.baseScale = width / this.imageEl.OriginHeight;
28438 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28439 height = this.thumbEl.getWidth();
28440 this.baseScale = height / this.imageEl.OriginHeight;
28443 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28444 height = this.thumbEl.getWidth();
28445 this.baseScale = height / this.imageEl.OriginHeight;
28447 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28448 width = this.thumbEl.getHeight();
28449 this.baseScale = width / this.imageEl.OriginWidth;
28456 width = this.thumbEl.getWidth();
28457 this.baseScale = width / this.imageEl.OriginWidth;
28459 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28460 height = this.thumbEl.getHeight();
28461 this.baseScale = height / this.imageEl.OriginHeight;
28464 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28466 height = this.thumbEl.getHeight();
28467 this.baseScale = height / this.imageEl.OriginHeight;
28469 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28470 width = this.thumbEl.getWidth();
28471 this.baseScale = width / this.imageEl.OriginWidth;
28479 getScaleLevel : function()
28481 return this.baseScale * Math.pow(1.1, this.scale);
28484 onTouchStart : function(e)
28486 if(!this.canvasLoaded){
28487 this.beforeSelectFile(e);
28491 var touches = e.browserEvent.touches;
28497 if(touches.length == 1){
28498 this.onMouseDown(e);
28502 if(touches.length != 2){
28508 for(var i = 0, finger; finger = touches[i]; i++){
28509 coords.push(finger.pageX, finger.pageY);
28512 var x = Math.pow(coords[0] - coords[2], 2);
28513 var y = Math.pow(coords[1] - coords[3], 2);
28515 this.startDistance = Math.sqrt(x + y);
28517 this.startScale = this.scale;
28519 this.pinching = true;
28520 this.dragable = false;
28524 onTouchMove : function(e)
28526 if(!this.pinching && !this.dragable){
28530 var touches = e.browserEvent.touches;
28537 this.onMouseMove(e);
28543 for(var i = 0, finger; finger = touches[i]; i++){
28544 coords.push(finger.pageX, finger.pageY);
28547 var x = Math.pow(coords[0] - coords[2], 2);
28548 var y = Math.pow(coords[1] - coords[3], 2);
28550 this.endDistance = Math.sqrt(x + y);
28552 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28554 if(!this.zoomable()){
28555 this.scale = this.startScale;
28563 onTouchEnd : function(e)
28565 this.pinching = false;
28566 this.dragable = false;
28570 process : function(file, crop)
28573 this.maskEl.mask(this.loadingText);
28576 this.xhr = new XMLHttpRequest();
28578 file.xhr = this.xhr;
28580 this.xhr.open(this.method, this.url, true);
28583 "Accept": "application/json",
28584 "Cache-Control": "no-cache",
28585 "X-Requested-With": "XMLHttpRequest"
28588 for (var headerName in headers) {
28589 var headerValue = headers[headerName];
28591 this.xhr.setRequestHeader(headerName, headerValue);
28597 this.xhr.onload = function()
28599 _this.xhrOnLoad(_this.xhr);
28602 this.xhr.onerror = function()
28604 _this.xhrOnError(_this.xhr);
28607 var formData = new FormData();
28609 formData.append('returnHTML', 'NO');
28612 formData.append('crop', crop);
28615 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28616 formData.append(this.paramName, file, file.name);
28619 if(typeof(file.filename) != 'undefined'){
28620 formData.append('filename', file.filename);
28623 if(typeof(file.mimetype) != 'undefined'){
28624 formData.append('mimetype', file.mimetype);
28627 if(this.fireEvent('arrange', this, formData) != false){
28628 this.xhr.send(formData);
28632 xhrOnLoad : function(xhr)
28635 this.maskEl.unmask();
28638 if (xhr.readyState !== 4) {
28639 this.fireEvent('exception', this, xhr);
28643 var response = Roo.decode(xhr.responseText);
28645 if(!response.success){
28646 this.fireEvent('exception', this, xhr);
28650 var response = Roo.decode(xhr.responseText);
28652 this.fireEvent('upload', this, response);
28656 xhrOnError : function()
28659 this.maskEl.unmask();
28662 Roo.log('xhr on error');
28664 var response = Roo.decode(xhr.responseText);
28670 prepare : function(file)
28673 this.maskEl.mask(this.loadingText);
28679 if(typeof(file) === 'string'){
28680 this.loadCanvas(file);
28684 if(!file || !this.urlAPI){
28689 this.cropType = file.type;
28693 if(this.fireEvent('prepare', this, this.file) != false){
28695 var reader = new FileReader();
28697 reader.onload = function (e) {
28698 if (e.target.error) {
28699 Roo.log(e.target.error);
28703 var buffer = e.target.result,
28704 dataView = new DataView(buffer),
28706 maxOffset = dataView.byteLength - 4,
28710 if (dataView.getUint16(0) === 0xffd8) {
28711 while (offset < maxOffset) {
28712 markerBytes = dataView.getUint16(offset);
28714 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28715 markerLength = dataView.getUint16(offset + 2) + 2;
28716 if (offset + markerLength > dataView.byteLength) {
28717 Roo.log('Invalid meta data: Invalid segment size.');
28721 if(markerBytes == 0xffe1){
28722 _this.parseExifData(
28729 offset += markerLength;
28739 var url = _this.urlAPI.createObjectURL(_this.file);
28741 _this.loadCanvas(url);
28746 reader.readAsArrayBuffer(this.file);
28752 parseExifData : function(dataView, offset, length)
28754 var tiffOffset = offset + 10,
28758 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28759 // No Exif data, might be XMP data instead
28763 // Check for the ASCII code for "Exif" (0x45786966):
28764 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28765 // No Exif data, might be XMP data instead
28768 if (tiffOffset + 8 > dataView.byteLength) {
28769 Roo.log('Invalid Exif data: Invalid segment size.');
28772 // Check for the two null bytes:
28773 if (dataView.getUint16(offset + 8) !== 0x0000) {
28774 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28777 // Check the byte alignment:
28778 switch (dataView.getUint16(tiffOffset)) {
28780 littleEndian = true;
28783 littleEndian = false;
28786 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28789 // Check for the TIFF tag marker (0x002A):
28790 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28791 Roo.log('Invalid Exif data: Missing TIFF marker.');
28794 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28795 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28797 this.parseExifTags(
28800 tiffOffset + dirOffset,
28805 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28810 if (dirOffset + 6 > dataView.byteLength) {
28811 Roo.log('Invalid Exif data: Invalid directory offset.');
28814 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28815 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28816 if (dirEndOffset + 4 > dataView.byteLength) {
28817 Roo.log('Invalid Exif data: Invalid directory size.');
28820 for (i = 0; i < tagsNumber; i += 1) {
28824 dirOffset + 2 + 12 * i, // tag offset
28828 // Return the offset to the next directory:
28829 return dataView.getUint32(dirEndOffset, littleEndian);
28832 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28834 var tag = dataView.getUint16(offset, littleEndian);
28836 this.exif[tag] = this.getExifValue(
28840 dataView.getUint16(offset + 2, littleEndian), // tag type
28841 dataView.getUint32(offset + 4, littleEndian), // tag length
28846 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28848 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28857 Roo.log('Invalid Exif data: Invalid tag type.');
28861 tagSize = tagType.size * length;
28862 // Determine if the value is contained in the dataOffset bytes,
28863 // or if the value at the dataOffset is a pointer to the actual data:
28864 dataOffset = tagSize > 4 ?
28865 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28866 if (dataOffset + tagSize > dataView.byteLength) {
28867 Roo.log('Invalid Exif data: Invalid data offset.');
28870 if (length === 1) {
28871 return tagType.getValue(dataView, dataOffset, littleEndian);
28874 for (i = 0; i < length; i += 1) {
28875 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28878 if (tagType.ascii) {
28880 // Concatenate the chars:
28881 for (i = 0; i < values.length; i += 1) {
28883 // Ignore the terminating NULL byte(s):
28884 if (c === '\u0000') {
28896 Roo.apply(Roo.bootstrap.UploadCropbox, {
28898 'Orientation': 0x0112
28902 1: 0, //'top-left',
28904 3: 180, //'bottom-right',
28905 // 4: 'bottom-left',
28907 6: 90, //'right-top',
28908 // 7: 'right-bottom',
28909 8: 270 //'left-bottom'
28913 // byte, 8-bit unsigned int:
28915 getValue: function (dataView, dataOffset) {
28916 return dataView.getUint8(dataOffset);
28920 // ascii, 8-bit byte:
28922 getValue: function (dataView, dataOffset) {
28923 return String.fromCharCode(dataView.getUint8(dataOffset));
28928 // short, 16 bit int:
28930 getValue: function (dataView, dataOffset, littleEndian) {
28931 return dataView.getUint16(dataOffset, littleEndian);
28935 // long, 32 bit int:
28937 getValue: function (dataView, dataOffset, littleEndian) {
28938 return dataView.getUint32(dataOffset, littleEndian);
28942 // rational = two long values, first is numerator, second is denominator:
28944 getValue: function (dataView, dataOffset, littleEndian) {
28945 return dataView.getUint32(dataOffset, littleEndian) /
28946 dataView.getUint32(dataOffset + 4, littleEndian);
28950 // slong, 32 bit signed int:
28952 getValue: function (dataView, dataOffset, littleEndian) {
28953 return dataView.getInt32(dataOffset, littleEndian);
28957 // srational, two slongs, first is numerator, second is denominator:
28959 getValue: function (dataView, dataOffset, littleEndian) {
28960 return dataView.getInt32(dataOffset, littleEndian) /
28961 dataView.getInt32(dataOffset + 4, littleEndian);
28971 cls : 'btn-group roo-upload-cropbox-rotate-left',
28972 action : 'rotate-left',
28976 cls : 'btn btn-default',
28977 html : '<i class="fa fa-undo"></i>'
28983 cls : 'btn-group roo-upload-cropbox-picture',
28984 action : 'picture',
28988 cls : 'btn btn-default',
28989 html : '<i class="fa fa-picture-o"></i>'
28995 cls : 'btn-group roo-upload-cropbox-rotate-right',
28996 action : 'rotate-right',
29000 cls : 'btn btn-default',
29001 html : '<i class="fa fa-repeat"></i>'
29009 cls : 'btn-group roo-upload-cropbox-rotate-left',
29010 action : 'rotate-left',
29014 cls : 'btn btn-default',
29015 html : '<i class="fa fa-undo"></i>'
29021 cls : 'btn-group roo-upload-cropbox-download',
29022 action : 'download',
29026 cls : 'btn btn-default',
29027 html : '<i class="fa fa-download"></i>'
29033 cls : 'btn-group roo-upload-cropbox-crop',
29038 cls : 'btn btn-default',
29039 html : '<i class="fa fa-crop"></i>'
29045 cls : 'btn-group roo-upload-cropbox-trash',
29050 cls : 'btn btn-default',
29051 html : '<i class="fa fa-trash"></i>'
29057 cls : 'btn-group roo-upload-cropbox-rotate-right',
29058 action : 'rotate-right',
29062 cls : 'btn btn-default',
29063 html : '<i class="fa fa-repeat"></i>'
29071 cls : 'btn-group roo-upload-cropbox-rotate-left',
29072 action : 'rotate-left',
29076 cls : 'btn btn-default',
29077 html : '<i class="fa fa-undo"></i>'
29083 cls : 'btn-group roo-upload-cropbox-rotate-right',
29084 action : 'rotate-right',
29088 cls : 'btn btn-default',
29089 html : '<i class="fa fa-repeat"></i>'
29102 * @class Roo.bootstrap.DocumentManager
29103 * @extends Roo.bootstrap.Component
29104 * Bootstrap DocumentManager class
29105 * @cfg {String} paramName default 'imageUpload'
29106 * @cfg {String} toolTipName default 'filename'
29107 * @cfg {String} method default POST
29108 * @cfg {String} url action url
29109 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29110 * @cfg {Boolean} multiple multiple upload default true
29111 * @cfg {Number} thumbSize default 300
29112 * @cfg {String} fieldLabel
29113 * @cfg {Number} labelWidth default 4
29114 * @cfg {String} labelAlign (left|top) default left
29115 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29116 * @cfg {Number} labellg set the width of label (1-12)
29117 * @cfg {Number} labelmd set the width of label (1-12)
29118 * @cfg {Number} labelsm set the width of label (1-12)
29119 * @cfg {Number} labelxs set the width of label (1-12)
29122 * Create a new DocumentManager
29123 * @param {Object} config The config object
29126 Roo.bootstrap.DocumentManager = function(config){
29127 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29130 this.delegates = [];
29135 * Fire when initial the DocumentManager
29136 * @param {Roo.bootstrap.DocumentManager} this
29141 * inspect selected file
29142 * @param {Roo.bootstrap.DocumentManager} this
29143 * @param {File} file
29148 * Fire when xhr load exception
29149 * @param {Roo.bootstrap.DocumentManager} this
29150 * @param {XMLHttpRequest} xhr
29152 "exception" : true,
29154 * @event afterupload
29155 * Fire when xhr load exception
29156 * @param {Roo.bootstrap.DocumentManager} this
29157 * @param {XMLHttpRequest} xhr
29159 "afterupload" : true,
29162 * prepare the form data
29163 * @param {Roo.bootstrap.DocumentManager} this
29164 * @param {Object} formData
29169 * Fire when remove the file
29170 * @param {Roo.bootstrap.DocumentManager} this
29171 * @param {Object} file
29176 * Fire after refresh the file
29177 * @param {Roo.bootstrap.DocumentManager} this
29182 * Fire after click the image
29183 * @param {Roo.bootstrap.DocumentManager} this
29184 * @param {Object} file
29189 * Fire when upload a image and editable set to true
29190 * @param {Roo.bootstrap.DocumentManager} this
29191 * @param {Object} file
29195 * @event beforeselectfile
29196 * Fire before select file
29197 * @param {Roo.bootstrap.DocumentManager} this
29199 "beforeselectfile" : true,
29202 * Fire before process file
29203 * @param {Roo.bootstrap.DocumentManager} this
29204 * @param {Object} file
29208 * @event previewrendered
29209 * Fire when preview rendered
29210 * @param {Roo.bootstrap.DocumentManager} this
29211 * @param {Object} file
29213 "previewrendered" : true,
29216 "previewResize" : true
29221 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29230 paramName : 'imageUpload',
29231 toolTipName : 'filename',
29234 labelAlign : 'left',
29244 getAutoCreate : function()
29246 var managerWidget = {
29248 cls : 'roo-document-manager',
29252 cls : 'roo-document-manager-selector',
29257 cls : 'roo-document-manager-uploader',
29261 cls : 'roo-document-manager-upload-btn',
29262 html : '<i class="fa fa-plus"></i>'
29273 cls : 'column col-md-12',
29278 if(this.fieldLabel.length){
29283 cls : 'column col-md-12',
29284 html : this.fieldLabel
29288 cls : 'column col-md-12',
29293 if(this.labelAlign == 'left'){
29298 html : this.fieldLabel
29307 if(this.labelWidth > 12){
29308 content[0].style = "width: " + this.labelWidth + 'px';
29311 if(this.labelWidth < 13 && this.labelmd == 0){
29312 this.labelmd = this.labelWidth;
29315 if(this.labellg > 0){
29316 content[0].cls += ' col-lg-' + this.labellg;
29317 content[1].cls += ' col-lg-' + (12 - this.labellg);
29320 if(this.labelmd > 0){
29321 content[0].cls += ' col-md-' + this.labelmd;
29322 content[1].cls += ' col-md-' + (12 - this.labelmd);
29325 if(this.labelsm > 0){
29326 content[0].cls += ' col-sm-' + this.labelsm;
29327 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29330 if(this.labelxs > 0){
29331 content[0].cls += ' col-xs-' + this.labelxs;
29332 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29340 cls : 'row clearfix',
29348 initEvents : function()
29350 this.managerEl = this.el.select('.roo-document-manager', true).first();
29351 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29353 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29354 this.selectorEl.hide();
29357 this.selectorEl.attr('multiple', 'multiple');
29360 this.selectorEl.on('change', this.onFileSelected, this);
29362 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29363 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29365 this.uploader.on('click', this.onUploaderClick, this);
29367 this.renderProgressDialog();
29371 window.addEventListener("resize", function() { _this.refresh(); } );
29373 this.fireEvent('initial', this);
29376 renderProgressDialog : function()
29380 this.progressDialog = new Roo.bootstrap.Modal({
29381 cls : 'roo-document-manager-progress-dialog',
29382 allow_close : false,
29393 btnclick : function() {
29394 _this.uploadCancel();
29400 this.progressDialog.render(Roo.get(document.body));
29402 this.progress = new Roo.bootstrap.Progress({
29403 cls : 'roo-document-manager-progress',
29408 this.progress.render(this.progressDialog.getChildContainer());
29410 this.progressBar = new Roo.bootstrap.ProgressBar({
29411 cls : 'roo-document-manager-progress-bar',
29414 aria_valuemax : 12,
29418 this.progressBar.render(this.progress.getChildContainer());
29421 onUploaderClick : function(e)
29423 e.preventDefault();
29425 if(this.fireEvent('beforeselectfile', this) != false){
29426 this.selectorEl.dom.click();
29431 onFileSelected : function(e)
29433 e.preventDefault();
29435 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29439 Roo.each(this.selectorEl.dom.files, function(file){
29440 if(this.fireEvent('inspect', this, file) != false){
29441 this.files.push(file);
29451 this.selectorEl.dom.value = '';
29453 if(!this.files || !this.files.length){
29457 if(this.boxes > 0 && this.files.length > this.boxes){
29458 this.files = this.files.slice(0, this.boxes);
29461 this.uploader.show();
29463 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29464 this.uploader.hide();
29473 Roo.each(this.files, function(file){
29475 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29476 var f = this.renderPreview(file);
29481 if(file.type.indexOf('image') != -1){
29482 this.delegates.push(
29484 _this.process(file);
29485 }).createDelegate(this)
29493 _this.process(file);
29494 }).createDelegate(this)
29499 this.files = files;
29501 this.delegates = this.delegates.concat(docs);
29503 if(!this.delegates.length){
29508 this.progressBar.aria_valuemax = this.delegates.length;
29515 arrange : function()
29517 if(!this.delegates.length){
29518 this.progressDialog.hide();
29523 var delegate = this.delegates.shift();
29525 this.progressDialog.show();
29527 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29529 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29534 refresh : function()
29536 this.uploader.show();
29538 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29539 this.uploader.hide();
29542 Roo.isTouch ? this.closable(false) : this.closable(true);
29544 this.fireEvent('refresh', this);
29547 onRemove : function(e, el, o)
29549 e.preventDefault();
29551 this.fireEvent('remove', this, o);
29555 remove : function(o)
29559 Roo.each(this.files, function(file){
29560 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29569 this.files = files;
29576 Roo.each(this.files, function(file){
29581 file.target.remove();
29590 onClick : function(e, el, o)
29592 e.preventDefault();
29594 this.fireEvent('click', this, o);
29598 closable : function(closable)
29600 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29602 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29614 xhrOnLoad : function(xhr)
29616 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29620 if (xhr.readyState !== 4) {
29622 this.fireEvent('exception', this, xhr);
29626 var response = Roo.decode(xhr.responseText);
29628 if(!response.success){
29630 this.fireEvent('exception', this, xhr);
29634 var file = this.renderPreview(response.data);
29636 this.files.push(file);
29640 this.fireEvent('afterupload', this, xhr);
29644 xhrOnError : function(xhr)
29646 Roo.log('xhr on error');
29648 var response = Roo.decode(xhr.responseText);
29655 process : function(file)
29657 if(this.fireEvent('process', this, file) !== false){
29658 if(this.editable && file.type.indexOf('image') != -1){
29659 this.fireEvent('edit', this, file);
29663 this.uploadStart(file, false);
29670 uploadStart : function(file, crop)
29672 this.xhr = new XMLHttpRequest();
29674 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29679 file.xhr = this.xhr;
29681 this.managerEl.createChild({
29683 cls : 'roo-document-manager-loading',
29687 tooltip : file.name,
29688 cls : 'roo-document-manager-thumb',
29689 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29695 this.xhr.open(this.method, this.url, true);
29698 "Accept": "application/json",
29699 "Cache-Control": "no-cache",
29700 "X-Requested-With": "XMLHttpRequest"
29703 for (var headerName in headers) {
29704 var headerValue = headers[headerName];
29706 this.xhr.setRequestHeader(headerName, headerValue);
29712 this.xhr.onload = function()
29714 _this.xhrOnLoad(_this.xhr);
29717 this.xhr.onerror = function()
29719 _this.xhrOnError(_this.xhr);
29722 var formData = new FormData();
29724 formData.append('returnHTML', 'NO');
29727 formData.append('crop', crop);
29730 formData.append(this.paramName, file, file.name);
29737 if(this.fireEvent('prepare', this, formData, options) != false){
29739 if(options.manually){
29743 this.xhr.send(formData);
29747 this.uploadCancel();
29750 uploadCancel : function()
29756 this.delegates = [];
29758 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29765 renderPreview : function(file)
29767 if(typeof(file.target) != 'undefined' && file.target){
29771 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29773 var previewEl = this.managerEl.createChild({
29775 cls : 'roo-document-manager-preview',
29779 tooltip : file[this.toolTipName],
29780 cls : 'roo-document-manager-thumb',
29781 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29786 html : '<i class="fa fa-times-circle"></i>'
29791 var close = previewEl.select('button.close', true).first();
29793 close.on('click', this.onRemove, this, file);
29795 file.target = previewEl;
29797 var image = previewEl.select('img', true).first();
29801 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29803 image.on('click', this.onClick, this, file);
29805 this.fireEvent('previewrendered', this, file);
29811 onPreviewLoad : function(file, image)
29813 if(typeof(file.target) == 'undefined' || !file.target){
29817 var width = image.dom.naturalWidth || image.dom.width;
29818 var height = image.dom.naturalHeight || image.dom.height;
29820 if(!this.previewResize) {
29824 if(width > height){
29825 file.target.addClass('wide');
29829 file.target.addClass('tall');
29834 uploadFromSource : function(file, crop)
29836 this.xhr = new XMLHttpRequest();
29838 this.managerEl.createChild({
29840 cls : 'roo-document-manager-loading',
29844 tooltip : file.name,
29845 cls : 'roo-document-manager-thumb',
29846 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29852 this.xhr.open(this.method, this.url, true);
29855 "Accept": "application/json",
29856 "Cache-Control": "no-cache",
29857 "X-Requested-With": "XMLHttpRequest"
29860 for (var headerName in headers) {
29861 var headerValue = headers[headerName];
29863 this.xhr.setRequestHeader(headerName, headerValue);
29869 this.xhr.onload = function()
29871 _this.xhrOnLoad(_this.xhr);
29874 this.xhr.onerror = function()
29876 _this.xhrOnError(_this.xhr);
29879 var formData = new FormData();
29881 formData.append('returnHTML', 'NO');
29883 formData.append('crop', crop);
29885 if(typeof(file.filename) != 'undefined'){
29886 formData.append('filename', file.filename);
29889 if(typeof(file.mimetype) != 'undefined'){
29890 formData.append('mimetype', file.mimetype);
29895 if(this.fireEvent('prepare', this, formData) != false){
29896 this.xhr.send(formData);
29906 * @class Roo.bootstrap.DocumentViewer
29907 * @extends Roo.bootstrap.Component
29908 * Bootstrap DocumentViewer class
29909 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29910 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29913 * Create a new DocumentViewer
29914 * @param {Object} config The config object
29917 Roo.bootstrap.DocumentViewer = function(config){
29918 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29923 * Fire after initEvent
29924 * @param {Roo.bootstrap.DocumentViewer} this
29930 * @param {Roo.bootstrap.DocumentViewer} this
29935 * Fire after download button
29936 * @param {Roo.bootstrap.DocumentViewer} this
29941 * Fire after trash button
29942 * @param {Roo.bootstrap.DocumentViewer} this
29949 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29951 showDownload : true,
29955 getAutoCreate : function()
29959 cls : 'roo-document-viewer',
29963 cls : 'roo-document-viewer-body',
29967 cls : 'roo-document-viewer-thumb',
29971 cls : 'roo-document-viewer-image'
29979 cls : 'roo-document-viewer-footer',
29982 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29986 cls : 'btn-group roo-document-viewer-download',
29990 cls : 'btn btn-default',
29991 html : '<i class="fa fa-download"></i>'
29997 cls : 'btn-group roo-document-viewer-trash',
30001 cls : 'btn btn-default',
30002 html : '<i class="fa fa-trash"></i>'
30015 initEvents : function()
30017 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
30018 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
30020 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
30021 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
30023 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
30024 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
30026 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
30027 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
30029 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
30030 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
30032 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
30033 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
30035 this.bodyEl.on('click', this.onClick, this);
30036 this.downloadBtn.on('click', this.onDownload, this);
30037 this.trashBtn.on('click', this.onTrash, this);
30039 this.downloadBtn.hide();
30040 this.trashBtn.hide();
30042 if(this.showDownload){
30043 this.downloadBtn.show();
30046 if(this.showTrash){
30047 this.trashBtn.show();
30050 if(!this.showDownload && !this.showTrash) {
30051 this.footerEl.hide();
30056 initial : function()
30058 this.fireEvent('initial', this);
30062 onClick : function(e)
30064 e.preventDefault();
30066 this.fireEvent('click', this);
30069 onDownload : function(e)
30071 e.preventDefault();
30073 this.fireEvent('download', this);
30076 onTrash : function(e)
30078 e.preventDefault();
30080 this.fireEvent('trash', this);
30092 * @class Roo.bootstrap.NavProgressBar
30093 * @extends Roo.bootstrap.Component
30094 * Bootstrap NavProgressBar class
30097 * Create a new nav progress bar
30098 * @param {Object} config The config object
30101 Roo.bootstrap.NavProgressBar = function(config){
30102 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30104 this.bullets = this.bullets || [];
30106 // Roo.bootstrap.NavProgressBar.register(this);
30110 * Fires when the active item changes
30111 * @param {Roo.bootstrap.NavProgressBar} this
30112 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30113 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30120 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30125 getAutoCreate : function()
30127 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30131 cls : 'roo-navigation-bar-group',
30135 cls : 'roo-navigation-top-bar'
30139 cls : 'roo-navigation-bullets-bar',
30143 cls : 'roo-navigation-bar'
30150 cls : 'roo-navigation-bottom-bar'
30160 initEvents: function()
30165 onRender : function(ct, position)
30167 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30169 if(this.bullets.length){
30170 Roo.each(this.bullets, function(b){
30179 addItem : function(cfg)
30181 var item = new Roo.bootstrap.NavProgressItem(cfg);
30183 item.parentId = this.id;
30184 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30187 var top = new Roo.bootstrap.Element({
30189 cls : 'roo-navigation-bar-text'
30192 var bottom = new Roo.bootstrap.Element({
30194 cls : 'roo-navigation-bar-text'
30197 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30198 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30200 var topText = new Roo.bootstrap.Element({
30202 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30205 var bottomText = new Roo.bootstrap.Element({
30207 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30210 topText.onRender(top.el, null);
30211 bottomText.onRender(bottom.el, null);
30214 item.bottomEl = bottom;
30217 this.barItems.push(item);
30222 getActive : function()
30224 var active = false;
30226 Roo.each(this.barItems, function(v){
30228 if (!v.isActive()) {
30240 setActiveItem : function(item)
30244 Roo.each(this.barItems, function(v){
30245 if (v.rid == item.rid) {
30249 if (v.isActive()) {
30250 v.setActive(false);
30255 item.setActive(true);
30257 this.fireEvent('changed', this, item, prev);
30260 getBarItem: function(rid)
30264 Roo.each(this.barItems, function(e) {
30265 if (e.rid != rid) {
30276 indexOfItem : function(item)
30280 Roo.each(this.barItems, function(v, i){
30282 if (v.rid != item.rid) {
30293 setActiveNext : function()
30295 var i = this.indexOfItem(this.getActive());
30297 if (i > this.barItems.length) {
30301 this.setActiveItem(this.barItems[i+1]);
30304 setActivePrev : function()
30306 var i = this.indexOfItem(this.getActive());
30312 this.setActiveItem(this.barItems[i-1]);
30315 format : function()
30317 if(!this.barItems.length){
30321 var width = 100 / this.barItems.length;
30323 Roo.each(this.barItems, function(i){
30324 i.el.setStyle('width', width + '%');
30325 i.topEl.el.setStyle('width', width + '%');
30326 i.bottomEl.el.setStyle('width', width + '%');
30335 * Nav Progress Item
30340 * @class Roo.bootstrap.NavProgressItem
30341 * @extends Roo.bootstrap.Component
30342 * Bootstrap NavProgressItem class
30343 * @cfg {String} rid the reference id
30344 * @cfg {Boolean} active (true|false) Is item active default false
30345 * @cfg {Boolean} disabled (true|false) Is item active default false
30346 * @cfg {String} html
30347 * @cfg {String} position (top|bottom) text position default bottom
30348 * @cfg {String} icon show icon instead of number
30351 * Create a new NavProgressItem
30352 * @param {Object} config The config object
30354 Roo.bootstrap.NavProgressItem = function(config){
30355 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30360 * The raw click event for the entire grid.
30361 * @param {Roo.bootstrap.NavProgressItem} this
30362 * @param {Roo.EventObject} e
30369 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30375 position : 'bottom',
30378 getAutoCreate : function()
30380 var iconCls = 'roo-navigation-bar-item-icon';
30382 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30386 cls: 'roo-navigation-bar-item',
30396 cfg.cls += ' active';
30399 cfg.cls += ' disabled';
30405 disable : function()
30407 this.setDisabled(true);
30410 enable : function()
30412 this.setDisabled(false);
30415 initEvents: function()
30417 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30419 this.iconEl.on('click', this.onClick, this);
30422 onClick : function(e)
30424 e.preventDefault();
30430 if(this.fireEvent('click', this, e) === false){
30434 this.parent().setActiveItem(this);
30437 isActive: function ()
30439 return this.active;
30442 setActive : function(state)
30444 if(this.active == state){
30448 this.active = state;
30451 this.el.addClass('active');
30455 this.el.removeClass('active');
30460 setDisabled : function(state)
30462 if(this.disabled == state){
30466 this.disabled = state;
30469 this.el.addClass('disabled');
30473 this.el.removeClass('disabled');
30476 tooltipEl : function()
30478 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30491 * @class Roo.bootstrap.FieldLabel
30492 * @extends Roo.bootstrap.Component
30493 * Bootstrap FieldLabel class
30494 * @cfg {String} html contents of the element
30495 * @cfg {String} tag tag of the element default label
30496 * @cfg {String} cls class of the element
30497 * @cfg {String} target label target
30498 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30499 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30500 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30501 * @cfg {String} iconTooltip default "This field is required"
30502 * @cfg {String} indicatorpos (left|right) default left
30505 * Create a new FieldLabel
30506 * @param {Object} config The config object
30509 Roo.bootstrap.FieldLabel = function(config){
30510 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30515 * Fires after the field has been marked as invalid.
30516 * @param {Roo.form.FieldLabel} this
30517 * @param {String} msg The validation message
30522 * Fires after the field has been validated with no errors.
30523 * @param {Roo.form.FieldLabel} this
30529 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30536 invalidClass : 'has-warning',
30537 validClass : 'has-success',
30538 iconTooltip : 'This field is required',
30539 indicatorpos : 'left',
30541 getAutoCreate : function(){
30544 if (!this.allowBlank) {
30550 cls : 'roo-bootstrap-field-label ' + this.cls,
30555 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30556 tooltip : this.iconTooltip
30565 if(this.indicatorpos == 'right'){
30568 cls : 'roo-bootstrap-field-label ' + this.cls,
30577 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30578 tooltip : this.iconTooltip
30587 initEvents: function()
30589 Roo.bootstrap.Element.superclass.initEvents.call(this);
30591 this.indicator = this.indicatorEl();
30593 if(this.indicator){
30594 this.indicator.removeClass('visible');
30595 this.indicator.addClass('invisible');
30598 Roo.bootstrap.FieldLabel.register(this);
30601 indicatorEl : function()
30603 var indicator = this.el.select('i.roo-required-indicator',true).first();
30614 * Mark this field as valid
30616 markValid : function()
30618 if(this.indicator){
30619 this.indicator.removeClass('visible');
30620 this.indicator.addClass('invisible');
30622 if (Roo.bootstrap.version == 3) {
30623 this.el.removeClass(this.invalidClass);
30624 this.el.addClass(this.validClass);
30626 this.el.removeClass('is-invalid');
30627 this.el.addClass('is-valid');
30631 this.fireEvent('valid', this);
30635 * Mark this field as invalid
30636 * @param {String} msg The validation message
30638 markInvalid : function(msg)
30640 if(this.indicator){
30641 this.indicator.removeClass('invisible');
30642 this.indicator.addClass('visible');
30644 if (Roo.bootstrap.version == 3) {
30645 this.el.removeClass(this.validClass);
30646 this.el.addClass(this.invalidClass);
30648 this.el.removeClass('is-valid');
30649 this.el.addClass('is-invalid');
30653 this.fireEvent('invalid', this, msg);
30659 Roo.apply(Roo.bootstrap.FieldLabel, {
30664 * register a FieldLabel Group
30665 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30667 register : function(label)
30669 if(this.groups.hasOwnProperty(label.target)){
30673 this.groups[label.target] = label;
30677 * fetch a FieldLabel Group based on the target
30678 * @param {string} target
30679 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30681 get: function(target) {
30682 if (typeof(this.groups[target]) == 'undefined') {
30686 return this.groups[target] ;
30695 * page DateSplitField.
30701 * @class Roo.bootstrap.DateSplitField
30702 * @extends Roo.bootstrap.Component
30703 * Bootstrap DateSplitField class
30704 * @cfg {string} fieldLabel - the label associated
30705 * @cfg {Number} labelWidth set the width of label (0-12)
30706 * @cfg {String} labelAlign (top|left)
30707 * @cfg {Boolean} dayAllowBlank (true|false) default false
30708 * @cfg {Boolean} monthAllowBlank (true|false) default false
30709 * @cfg {Boolean} yearAllowBlank (true|false) default false
30710 * @cfg {string} dayPlaceholder
30711 * @cfg {string} monthPlaceholder
30712 * @cfg {string} yearPlaceholder
30713 * @cfg {string} dayFormat default 'd'
30714 * @cfg {string} monthFormat default 'm'
30715 * @cfg {string} yearFormat default 'Y'
30716 * @cfg {Number} labellg set the width of label (1-12)
30717 * @cfg {Number} labelmd set the width of label (1-12)
30718 * @cfg {Number} labelsm set the width of label (1-12)
30719 * @cfg {Number} labelxs set the width of label (1-12)
30723 * Create a new DateSplitField
30724 * @param {Object} config The config object
30727 Roo.bootstrap.DateSplitField = function(config){
30728 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30734 * getting the data of years
30735 * @param {Roo.bootstrap.DateSplitField} this
30736 * @param {Object} years
30741 * getting the data of days
30742 * @param {Roo.bootstrap.DateSplitField} this
30743 * @param {Object} days
30748 * Fires after the field has been marked as invalid.
30749 * @param {Roo.form.Field} this
30750 * @param {String} msg The validation message
30755 * Fires after the field has been validated with no errors.
30756 * @param {Roo.form.Field} this
30762 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30765 labelAlign : 'top',
30767 dayAllowBlank : false,
30768 monthAllowBlank : false,
30769 yearAllowBlank : false,
30770 dayPlaceholder : '',
30771 monthPlaceholder : '',
30772 yearPlaceholder : '',
30776 isFormField : true,
30782 getAutoCreate : function()
30786 cls : 'row roo-date-split-field-group',
30791 cls : 'form-hidden-field roo-date-split-field-group-value',
30797 var labelCls = 'col-md-12';
30798 var contentCls = 'col-md-4';
30800 if(this.fieldLabel){
30804 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30808 html : this.fieldLabel
30813 if(this.labelAlign == 'left'){
30815 if(this.labelWidth > 12){
30816 label.style = "width: " + this.labelWidth + 'px';
30819 if(this.labelWidth < 13 && this.labelmd == 0){
30820 this.labelmd = this.labelWidth;
30823 if(this.labellg > 0){
30824 labelCls = ' col-lg-' + this.labellg;
30825 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30828 if(this.labelmd > 0){
30829 labelCls = ' col-md-' + this.labelmd;
30830 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30833 if(this.labelsm > 0){
30834 labelCls = ' col-sm-' + this.labelsm;
30835 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30838 if(this.labelxs > 0){
30839 labelCls = ' col-xs-' + this.labelxs;
30840 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30844 label.cls += ' ' + labelCls;
30846 cfg.cn.push(label);
30849 Roo.each(['day', 'month', 'year'], function(t){
30852 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30859 inputEl: function ()
30861 return this.el.select('.roo-date-split-field-group-value', true).first();
30864 onRender : function(ct, position)
30868 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30870 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30872 this.dayField = new Roo.bootstrap.ComboBox({
30873 allowBlank : this.dayAllowBlank,
30874 alwaysQuery : true,
30875 displayField : 'value',
30878 forceSelection : true,
30880 placeholder : this.dayPlaceholder,
30881 selectOnFocus : true,
30882 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30883 triggerAction : 'all',
30885 valueField : 'value',
30886 store : new Roo.data.SimpleStore({
30887 data : (function() {
30889 _this.fireEvent('days', _this, days);
30892 fields : [ 'value' ]
30895 select : function (_self, record, index)
30897 _this.setValue(_this.getValue());
30902 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30904 this.monthField = new Roo.bootstrap.MonthField({
30905 after : '<i class=\"fa fa-calendar\"></i>',
30906 allowBlank : this.monthAllowBlank,
30907 placeholder : this.monthPlaceholder,
30910 render : function (_self)
30912 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30913 e.preventDefault();
30917 select : function (_self, oldvalue, newvalue)
30919 _this.setValue(_this.getValue());
30924 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30926 this.yearField = new Roo.bootstrap.ComboBox({
30927 allowBlank : this.yearAllowBlank,
30928 alwaysQuery : true,
30929 displayField : 'value',
30932 forceSelection : true,
30934 placeholder : this.yearPlaceholder,
30935 selectOnFocus : true,
30936 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30937 triggerAction : 'all',
30939 valueField : 'value',
30940 store : new Roo.data.SimpleStore({
30941 data : (function() {
30943 _this.fireEvent('years', _this, years);
30946 fields : [ 'value' ]
30949 select : function (_self, record, index)
30951 _this.setValue(_this.getValue());
30956 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30959 setValue : function(v, format)
30961 this.inputEl.dom.value = v;
30963 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30965 var d = Date.parseDate(v, f);
30972 this.setDay(d.format(this.dayFormat));
30973 this.setMonth(d.format(this.monthFormat));
30974 this.setYear(d.format(this.yearFormat));
30981 setDay : function(v)
30983 this.dayField.setValue(v);
30984 this.inputEl.dom.value = this.getValue();
30989 setMonth : function(v)
30991 this.monthField.setValue(v, true);
30992 this.inputEl.dom.value = this.getValue();
30997 setYear : function(v)
30999 this.yearField.setValue(v);
31000 this.inputEl.dom.value = this.getValue();
31005 getDay : function()
31007 return this.dayField.getValue();
31010 getMonth : function()
31012 return this.monthField.getValue();
31015 getYear : function()
31017 return this.yearField.getValue();
31020 getValue : function()
31022 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
31024 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
31034 this.inputEl.dom.value = '';
31039 validate : function()
31041 var d = this.dayField.validate();
31042 var m = this.monthField.validate();
31043 var y = this.yearField.validate();
31048 (!this.dayAllowBlank && !d) ||
31049 (!this.monthAllowBlank && !m) ||
31050 (!this.yearAllowBlank && !y)
31055 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31064 this.markInvalid();
31069 markValid : function()
31072 var label = this.el.select('label', true).first();
31073 var icon = this.el.select('i.fa-star', true).first();
31079 this.fireEvent('valid', this);
31083 * Mark this field as invalid
31084 * @param {String} msg The validation message
31086 markInvalid : function(msg)
31089 var label = this.el.select('label', true).first();
31090 var icon = this.el.select('i.fa-star', true).first();
31092 if(label && !icon){
31093 this.el.select('.roo-date-split-field-label', true).createChild({
31095 cls : 'text-danger fa fa-lg fa-star',
31096 tooltip : 'This field is required',
31097 style : 'margin-right:5px;'
31101 this.fireEvent('invalid', this, msg);
31104 clearInvalid : function()
31106 var label = this.el.select('label', true).first();
31107 var icon = this.el.select('i.fa-star', true).first();
31113 this.fireEvent('valid', this);
31116 getName: function()
31126 * http://masonry.desandro.com
31128 * The idea is to render all the bricks based on vertical width...
31130 * The original code extends 'outlayer' - we might need to use that....
31136 * @class Roo.bootstrap.LayoutMasonry
31137 * @extends Roo.bootstrap.Component
31138 * Bootstrap Layout Masonry class
31141 * Create a new Element
31142 * @param {Object} config The config object
31145 Roo.bootstrap.LayoutMasonry = function(config){
31147 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31151 Roo.bootstrap.LayoutMasonry.register(this);
31157 * Fire after layout the items
31158 * @param {Roo.bootstrap.LayoutMasonry} this
31159 * @param {Roo.EventObject} e
31166 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31169 * @cfg {Boolean} isLayoutInstant = no animation?
31171 isLayoutInstant : false, // needed?
31174 * @cfg {Number} boxWidth width of the columns
31179 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31184 * @cfg {Number} padWidth padding below box..
31189 * @cfg {Number} gutter gutter width..
31194 * @cfg {Number} maxCols maximum number of columns
31200 * @cfg {Boolean} isAutoInitial defalut true
31202 isAutoInitial : true,
31207 * @cfg {Boolean} isHorizontal defalut false
31209 isHorizontal : false,
31211 currentSize : null,
31217 bricks: null, //CompositeElement
31221 _isLayoutInited : false,
31223 // isAlternative : false, // only use for vertical layout...
31226 * @cfg {Number} alternativePadWidth padding below box..
31228 alternativePadWidth : 50,
31230 selectedBrick : [],
31232 getAutoCreate : function(){
31234 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31238 cls: 'blog-masonary-wrapper ' + this.cls,
31240 cls : 'mas-boxes masonary'
31247 getChildContainer: function( )
31249 if (this.boxesEl) {
31250 return this.boxesEl;
31253 this.boxesEl = this.el.select('.mas-boxes').first();
31255 return this.boxesEl;
31259 initEvents : function()
31263 if(this.isAutoInitial){
31264 Roo.log('hook children rendered');
31265 this.on('childrenrendered', function() {
31266 Roo.log('children rendered');
31272 initial : function()
31274 this.selectedBrick = [];
31276 this.currentSize = this.el.getBox(true);
31278 Roo.EventManager.onWindowResize(this.resize, this);
31280 if(!this.isAutoInitial){
31288 //this.layout.defer(500,this);
31292 resize : function()
31294 var cs = this.el.getBox(true);
31297 this.currentSize.width == cs.width &&
31298 this.currentSize.x == cs.x &&
31299 this.currentSize.height == cs.height &&
31300 this.currentSize.y == cs.y
31302 Roo.log("no change in with or X or Y");
31306 this.currentSize = cs;
31312 layout : function()
31314 this._resetLayout();
31316 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31318 this.layoutItems( isInstant );
31320 this._isLayoutInited = true;
31322 this.fireEvent('layout', this);
31326 _resetLayout : function()
31328 if(this.isHorizontal){
31329 this.horizontalMeasureColumns();
31333 this.verticalMeasureColumns();
31337 verticalMeasureColumns : function()
31339 this.getContainerWidth();
31341 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31342 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31346 var boxWidth = this.boxWidth + this.padWidth;
31348 if(this.containerWidth < this.boxWidth){
31349 boxWidth = this.containerWidth
31352 var containerWidth = this.containerWidth;
31354 var cols = Math.floor(containerWidth / boxWidth);
31356 this.cols = Math.max( cols, 1 );
31358 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31360 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31362 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31364 this.colWidth = boxWidth + avail - this.padWidth;
31366 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31367 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31370 horizontalMeasureColumns : function()
31372 this.getContainerWidth();
31374 var boxWidth = this.boxWidth;
31376 if(this.containerWidth < boxWidth){
31377 boxWidth = this.containerWidth;
31380 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31382 this.el.setHeight(boxWidth);
31386 getContainerWidth : function()
31388 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31391 layoutItems : function( isInstant )
31393 Roo.log(this.bricks);
31395 var items = Roo.apply([], this.bricks);
31397 if(this.isHorizontal){
31398 this._horizontalLayoutItems( items , isInstant );
31402 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31403 // this._verticalAlternativeLayoutItems( items , isInstant );
31407 this._verticalLayoutItems( items , isInstant );
31411 _verticalLayoutItems : function ( items , isInstant)
31413 if ( !items || !items.length ) {
31418 ['xs', 'xs', 'xs', 'tall'],
31419 ['xs', 'xs', 'tall'],
31420 ['xs', 'xs', 'sm'],
31421 ['xs', 'xs', 'xs'],
31427 ['sm', 'xs', 'xs'],
31431 ['tall', 'xs', 'xs', 'xs'],
31432 ['tall', 'xs', 'xs'],
31444 Roo.each(items, function(item, k){
31446 switch (item.size) {
31447 // these layouts take up a full box,
31458 boxes.push([item]);
31481 var filterPattern = function(box, length)
31489 var pattern = box.slice(0, length);
31493 Roo.each(pattern, function(i){
31494 format.push(i.size);
31497 Roo.each(standard, function(s){
31499 if(String(s) != String(format)){
31508 if(!match && length == 1){
31513 filterPattern(box, length - 1);
31517 queue.push(pattern);
31519 box = box.slice(length, box.length);
31521 filterPattern(box, 4);
31527 Roo.each(boxes, function(box, k){
31533 if(box.length == 1){
31538 filterPattern(box, 4);
31542 this._processVerticalLayoutQueue( queue, isInstant );
31546 // _verticalAlternativeLayoutItems : function( items , isInstant )
31548 // if ( !items || !items.length ) {
31552 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31556 _horizontalLayoutItems : function ( items , isInstant)
31558 if ( !items || !items.length || items.length < 3) {
31564 var eItems = items.slice(0, 3);
31566 items = items.slice(3, items.length);
31569 ['xs', 'xs', 'xs', 'wide'],
31570 ['xs', 'xs', 'wide'],
31571 ['xs', 'xs', 'sm'],
31572 ['xs', 'xs', 'xs'],
31578 ['sm', 'xs', 'xs'],
31582 ['wide', 'xs', 'xs', 'xs'],
31583 ['wide', 'xs', 'xs'],
31596 Roo.each(items, function(item, k){
31598 switch (item.size) {
31609 boxes.push([item]);
31633 var filterPattern = function(box, length)
31641 var pattern = box.slice(0, length);
31645 Roo.each(pattern, function(i){
31646 format.push(i.size);
31649 Roo.each(standard, function(s){
31651 if(String(s) != String(format)){
31660 if(!match && length == 1){
31665 filterPattern(box, length - 1);
31669 queue.push(pattern);
31671 box = box.slice(length, box.length);
31673 filterPattern(box, 4);
31679 Roo.each(boxes, function(box, k){
31685 if(box.length == 1){
31690 filterPattern(box, 4);
31697 var pos = this.el.getBox(true);
31701 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31703 var hit_end = false;
31705 Roo.each(queue, function(box){
31709 Roo.each(box, function(b){
31711 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31721 Roo.each(box, function(b){
31723 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31726 mx = Math.max(mx, b.x);
31730 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31734 Roo.each(box, function(b){
31736 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31750 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31753 /** Sets position of item in DOM
31754 * @param {Element} item
31755 * @param {Number} x - horizontal position
31756 * @param {Number} y - vertical position
31757 * @param {Boolean} isInstant - disables transitions
31759 _processVerticalLayoutQueue : function( queue, isInstant )
31761 var pos = this.el.getBox(true);
31766 for (var i = 0; i < this.cols; i++){
31770 Roo.each(queue, function(box, k){
31772 var col = k % this.cols;
31774 Roo.each(box, function(b,kk){
31776 b.el.position('absolute');
31778 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31779 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31781 if(b.size == 'md-left' || b.size == 'md-right'){
31782 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31783 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31786 b.el.setWidth(width);
31787 b.el.setHeight(height);
31789 b.el.select('iframe',true).setSize(width,height);
31793 for (var i = 0; i < this.cols; i++){
31795 if(maxY[i] < maxY[col]){
31800 col = Math.min(col, i);
31804 x = pos.x + col * (this.colWidth + this.padWidth);
31808 var positions = [];
31810 switch (box.length){
31812 positions = this.getVerticalOneBoxColPositions(x, y, box);
31815 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31818 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31821 positions = this.getVerticalFourBoxColPositions(x, y, box);
31827 Roo.each(box, function(b,kk){
31829 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31831 var sz = b.el.getSize();
31833 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31841 for (var i = 0; i < this.cols; i++){
31842 mY = Math.max(mY, maxY[i]);
31845 this.el.setHeight(mY - pos.y);
31849 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31851 // var pos = this.el.getBox(true);
31854 // var maxX = pos.right;
31856 // var maxHeight = 0;
31858 // Roo.each(items, function(item, k){
31862 // item.el.position('absolute');
31864 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31866 // item.el.setWidth(width);
31868 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31870 // item.el.setHeight(height);
31873 // item.el.setXY([x, y], isInstant ? false : true);
31875 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31878 // y = y + height + this.alternativePadWidth;
31880 // maxHeight = maxHeight + height + this.alternativePadWidth;
31884 // this.el.setHeight(maxHeight);
31888 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31890 var pos = this.el.getBox(true);
31895 var maxX = pos.right;
31897 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31899 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31901 Roo.each(queue, function(box, k){
31903 Roo.each(box, function(b, kk){
31905 b.el.position('absolute');
31907 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31908 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31910 if(b.size == 'md-left' || b.size == 'md-right'){
31911 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31912 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31915 b.el.setWidth(width);
31916 b.el.setHeight(height);
31924 var positions = [];
31926 switch (box.length){
31928 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31931 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31934 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31937 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31943 Roo.each(box, function(b,kk){
31945 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31947 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31955 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31957 Roo.each(eItems, function(b,k){
31959 b.size = (k == 0) ? 'sm' : 'xs';
31960 b.x = (k == 0) ? 2 : 1;
31961 b.y = (k == 0) ? 2 : 1;
31963 b.el.position('absolute');
31965 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31967 b.el.setWidth(width);
31969 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31971 b.el.setHeight(height);
31975 var positions = [];
31978 x : maxX - this.unitWidth * 2 - this.gutter,
31983 x : maxX - this.unitWidth,
31984 y : minY + (this.unitWidth + this.gutter) * 2
31988 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31992 Roo.each(eItems, function(b,k){
31994 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
32000 getVerticalOneBoxColPositions : function(x, y, box)
32004 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
32006 if(box[0].size == 'md-left'){
32010 if(box[0].size == 'md-right'){
32015 x : x + (this.unitWidth + this.gutter) * rand,
32022 getVerticalTwoBoxColPositions : function(x, y, box)
32026 if(box[0].size == 'xs'){
32030 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
32034 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32048 x : x + (this.unitWidth + this.gutter) * 2,
32049 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32056 getVerticalThreeBoxColPositions : function(x, y, box)
32060 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32068 x : x + (this.unitWidth + this.gutter) * 1,
32073 x : x + (this.unitWidth + this.gutter) * 2,
32081 if(box[0].size == 'xs' && box[1].size == 'xs'){
32090 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32094 x : x + (this.unitWidth + this.gutter) * 1,
32108 x : x + (this.unitWidth + this.gutter) * 2,
32113 x : x + (this.unitWidth + this.gutter) * 2,
32114 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32121 getVerticalFourBoxColPositions : function(x, y, box)
32125 if(box[0].size == 'xs'){
32134 y : y + (this.unitHeight + this.gutter) * 1
32139 y : y + (this.unitHeight + this.gutter) * 2
32143 x : x + (this.unitWidth + this.gutter) * 1,
32157 x : x + (this.unitWidth + this.gutter) * 2,
32162 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32163 y : y + (this.unitHeight + this.gutter) * 1
32167 x : x + (this.unitWidth + this.gutter) * 2,
32168 y : y + (this.unitWidth + this.gutter) * 2
32175 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32179 if(box[0].size == 'md-left'){
32181 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32188 if(box[0].size == 'md-right'){
32190 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32191 y : minY + (this.unitWidth + this.gutter) * 1
32197 var rand = Math.floor(Math.random() * (4 - box[0].y));
32200 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32201 y : minY + (this.unitWidth + this.gutter) * rand
32208 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32212 if(box[0].size == 'xs'){
32215 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32220 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32221 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32229 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32234 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32235 y : minY + (this.unitWidth + this.gutter) * 2
32242 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32246 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32249 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32254 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32255 y : minY + (this.unitWidth + this.gutter) * 1
32259 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32260 y : minY + (this.unitWidth + this.gutter) * 2
32267 if(box[0].size == 'xs' && box[1].size == 'xs'){
32270 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32275 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32280 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32281 y : minY + (this.unitWidth + this.gutter) * 1
32289 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32294 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32295 y : minY + (this.unitWidth + this.gutter) * 2
32299 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32300 y : minY + (this.unitWidth + this.gutter) * 2
32307 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32311 if(box[0].size == 'xs'){
32314 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32319 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32324 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),
32329 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32330 y : minY + (this.unitWidth + this.gutter) * 1
32338 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32343 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32344 y : minY + (this.unitWidth + this.gutter) * 2
32348 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32349 y : minY + (this.unitWidth + this.gutter) * 2
32353 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),
32354 y : minY + (this.unitWidth + this.gutter) * 2
32362 * remove a Masonry Brick
32363 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32365 removeBrick : function(brick_id)
32371 for (var i = 0; i<this.bricks.length; i++) {
32372 if (this.bricks[i].id == brick_id) {
32373 this.bricks.splice(i,1);
32374 this.el.dom.removeChild(Roo.get(brick_id).dom);
32381 * adds a Masonry Brick
32382 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32384 addBrick : function(cfg)
32386 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32387 //this.register(cn);
32388 cn.parentId = this.id;
32389 cn.render(this.el);
32394 * register a Masonry Brick
32395 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32398 register : function(brick)
32400 this.bricks.push(brick);
32401 brick.masonryId = this.id;
32405 * clear all the Masonry Brick
32407 clearAll : function()
32410 //this.getChildContainer().dom.innerHTML = "";
32411 this.el.dom.innerHTML = '';
32414 getSelected : function()
32416 if (!this.selectedBrick) {
32420 return this.selectedBrick;
32424 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32428 * register a Masonry Layout
32429 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32432 register : function(layout)
32434 this.groups[layout.id] = layout;
32437 * fetch a Masonry Layout based on the masonry layout ID
32438 * @param {string} the masonry layout to add
32439 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32442 get: function(layout_id) {
32443 if (typeof(this.groups[layout_id]) == 'undefined') {
32446 return this.groups[layout_id] ;
32458 * http://masonry.desandro.com
32460 * The idea is to render all the bricks based on vertical width...
32462 * The original code extends 'outlayer' - we might need to use that....
32468 * @class Roo.bootstrap.LayoutMasonryAuto
32469 * @extends Roo.bootstrap.Component
32470 * Bootstrap Layout Masonry class
32473 * Create a new Element
32474 * @param {Object} config The config object
32477 Roo.bootstrap.LayoutMasonryAuto = function(config){
32478 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32481 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32484 * @cfg {Boolean} isFitWidth - resize the width..
32486 isFitWidth : false, // options..
32488 * @cfg {Boolean} isOriginLeft = left align?
32490 isOriginLeft : true,
32492 * @cfg {Boolean} isOriginTop = top align?
32494 isOriginTop : false,
32496 * @cfg {Boolean} isLayoutInstant = no animation?
32498 isLayoutInstant : false, // needed?
32500 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32502 isResizingContainer : true,
32504 * @cfg {Number} columnWidth width of the columns
32510 * @cfg {Number} maxCols maximum number of columns
32515 * @cfg {Number} padHeight padding below box..
32521 * @cfg {Boolean} isAutoInitial defalut true
32524 isAutoInitial : true,
32530 initialColumnWidth : 0,
32531 currentSize : null,
32533 colYs : null, // array.
32540 bricks: null, //CompositeElement
32541 cols : 0, // array?
32542 // element : null, // wrapped now this.el
32543 _isLayoutInited : null,
32546 getAutoCreate : function(){
32550 cls: 'blog-masonary-wrapper ' + this.cls,
32552 cls : 'mas-boxes masonary'
32559 getChildContainer: function( )
32561 if (this.boxesEl) {
32562 return this.boxesEl;
32565 this.boxesEl = this.el.select('.mas-boxes').first();
32567 return this.boxesEl;
32571 initEvents : function()
32575 if(this.isAutoInitial){
32576 Roo.log('hook children rendered');
32577 this.on('childrenrendered', function() {
32578 Roo.log('children rendered');
32585 initial : function()
32587 this.reloadItems();
32589 this.currentSize = this.el.getBox(true);
32591 /// was window resize... - let's see if this works..
32592 Roo.EventManager.onWindowResize(this.resize, this);
32594 if(!this.isAutoInitial){
32599 this.layout.defer(500,this);
32602 reloadItems: function()
32604 this.bricks = this.el.select('.masonry-brick', true);
32606 this.bricks.each(function(b) {
32607 //Roo.log(b.getSize());
32608 if (!b.attr('originalwidth')) {
32609 b.attr('originalwidth', b.getSize().width);
32614 Roo.log(this.bricks.elements.length);
32617 resize : function()
32620 var cs = this.el.getBox(true);
32622 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32623 Roo.log("no change in with or X");
32626 this.currentSize = cs;
32630 layout : function()
32633 this._resetLayout();
32634 //this._manageStamps();
32636 // don't animate first layout
32637 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32638 this.layoutItems( isInstant );
32640 // flag for initalized
32641 this._isLayoutInited = true;
32644 layoutItems : function( isInstant )
32646 //var items = this._getItemsForLayout( this.items );
32647 // original code supports filtering layout items.. we just ignore it..
32649 this._layoutItems( this.bricks , isInstant );
32651 this._postLayout();
32653 _layoutItems : function ( items , isInstant)
32655 //this.fireEvent( 'layout', this, items );
32658 if ( !items || !items.elements.length ) {
32659 // no items, emit event with empty array
32664 items.each(function(item) {
32665 Roo.log("layout item");
32667 // get x/y object from method
32668 var position = this._getItemLayoutPosition( item );
32670 position.item = item;
32671 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32672 queue.push( position );
32675 this._processLayoutQueue( queue );
32677 /** Sets position of item in DOM
32678 * @param {Element} item
32679 * @param {Number} x - horizontal position
32680 * @param {Number} y - vertical position
32681 * @param {Boolean} isInstant - disables transitions
32683 _processLayoutQueue : function( queue )
32685 for ( var i=0, len = queue.length; i < len; i++ ) {
32686 var obj = queue[i];
32687 obj.item.position('absolute');
32688 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32694 * Any logic you want to do after each layout,
32695 * i.e. size the container
32697 _postLayout : function()
32699 this.resizeContainer();
32702 resizeContainer : function()
32704 if ( !this.isResizingContainer ) {
32707 var size = this._getContainerSize();
32709 this.el.setSize(size.width,size.height);
32710 this.boxesEl.setSize(size.width,size.height);
32716 _resetLayout : function()
32718 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32719 this.colWidth = this.el.getWidth();
32720 //this.gutter = this.el.getWidth();
32722 this.measureColumns();
32728 this.colYs.push( 0 );
32734 measureColumns : function()
32736 this.getContainerWidth();
32737 // if columnWidth is 0, default to outerWidth of first item
32738 if ( !this.columnWidth ) {
32739 var firstItem = this.bricks.first();
32740 Roo.log(firstItem);
32741 this.columnWidth = this.containerWidth;
32742 if (firstItem && firstItem.attr('originalwidth') ) {
32743 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32745 // columnWidth fall back to item of first element
32746 Roo.log("set column width?");
32747 this.initialColumnWidth = this.columnWidth ;
32749 // if first elem has no width, default to size of container
32754 if (this.initialColumnWidth) {
32755 this.columnWidth = this.initialColumnWidth;
32760 // column width is fixed at the top - however if container width get's smaller we should
32763 // this bit calcs how man columns..
32765 var columnWidth = this.columnWidth += this.gutter;
32767 // calculate columns
32768 var containerWidth = this.containerWidth + this.gutter;
32770 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32771 // fix rounding errors, typically with gutters
32772 var excess = columnWidth - containerWidth % columnWidth;
32775 // if overshoot is less than a pixel, round up, otherwise floor it
32776 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32777 cols = Math[ mathMethod ]( cols );
32778 this.cols = Math.max( cols, 1 );
32779 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32781 // padding positioning..
32782 var totalColWidth = this.cols * this.columnWidth;
32783 var padavail = this.containerWidth - totalColWidth;
32784 // so for 2 columns - we need 3 'pads'
32786 var padNeeded = (1+this.cols) * this.padWidth;
32788 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32790 this.columnWidth += padExtra
32791 //this.padWidth = Math.floor(padavail / ( this.cols));
32793 // adjust colum width so that padding is fixed??
32795 // we have 3 columns ... total = width * 3
32796 // we have X left over... that should be used by
32798 //if (this.expandC) {
32806 getContainerWidth : function()
32808 /* // container is parent if fit width
32809 var container = this.isFitWidth ? this.element.parentNode : this.element;
32810 // check that this.size and size are there
32811 // IE8 triggers resize on body size change, so they might not be
32813 var size = getSize( container ); //FIXME
32814 this.containerWidth = size && size.innerWidth; //FIXME
32817 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32821 _getItemLayoutPosition : function( item ) // what is item?
32823 // we resize the item to our columnWidth..
32825 item.setWidth(this.columnWidth);
32826 item.autoBoxAdjust = false;
32828 var sz = item.getSize();
32830 // how many columns does this brick span
32831 var remainder = this.containerWidth % this.columnWidth;
32833 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32834 // round if off by 1 pixel, otherwise use ceil
32835 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32836 colSpan = Math.min( colSpan, this.cols );
32838 // normally this should be '1' as we dont' currently allow multi width columns..
32840 var colGroup = this._getColGroup( colSpan );
32841 // get the minimum Y value from the columns
32842 var minimumY = Math.min.apply( Math, colGroup );
32843 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32845 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32847 // position the brick
32849 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32850 y: this.currentSize.y + minimumY + this.padHeight
32854 // apply setHeight to necessary columns
32855 var setHeight = minimumY + sz.height + this.padHeight;
32856 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32858 var setSpan = this.cols + 1 - colGroup.length;
32859 for ( var i = 0; i < setSpan; i++ ) {
32860 this.colYs[ shortColIndex + i ] = setHeight ;
32867 * @param {Number} colSpan - number of columns the element spans
32868 * @returns {Array} colGroup
32870 _getColGroup : function( colSpan )
32872 if ( colSpan < 2 ) {
32873 // if brick spans only one column, use all the column Ys
32878 // how many different places could this brick fit horizontally
32879 var groupCount = this.cols + 1 - colSpan;
32880 // for each group potential horizontal position
32881 for ( var i = 0; i < groupCount; i++ ) {
32882 // make an array of colY values for that one group
32883 var groupColYs = this.colYs.slice( i, i + colSpan );
32884 // and get the max value of the array
32885 colGroup[i] = Math.max.apply( Math, groupColYs );
32890 _manageStamp : function( stamp )
32892 var stampSize = stamp.getSize();
32893 var offset = stamp.getBox();
32894 // get the columns that this stamp affects
32895 var firstX = this.isOriginLeft ? offset.x : offset.right;
32896 var lastX = firstX + stampSize.width;
32897 var firstCol = Math.floor( firstX / this.columnWidth );
32898 firstCol = Math.max( 0, firstCol );
32900 var lastCol = Math.floor( lastX / this.columnWidth );
32901 // lastCol should not go over if multiple of columnWidth #425
32902 lastCol -= lastX % this.columnWidth ? 0 : 1;
32903 lastCol = Math.min( this.cols - 1, lastCol );
32905 // set colYs to bottom of the stamp
32906 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32909 for ( var i = firstCol; i <= lastCol; i++ ) {
32910 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32915 _getContainerSize : function()
32917 this.maxY = Math.max.apply( Math, this.colYs );
32922 if ( this.isFitWidth ) {
32923 size.width = this._getContainerFitWidth();
32929 _getContainerFitWidth : function()
32931 var unusedCols = 0;
32932 // count unused columns
32935 if ( this.colYs[i] !== 0 ) {
32940 // fit container to columns that have been used
32941 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32944 needsResizeLayout : function()
32946 var previousWidth = this.containerWidth;
32947 this.getContainerWidth();
32948 return previousWidth !== this.containerWidth;
32963 * @class Roo.bootstrap.MasonryBrick
32964 * @extends Roo.bootstrap.Component
32965 * Bootstrap MasonryBrick class
32968 * Create a new MasonryBrick
32969 * @param {Object} config The config object
32972 Roo.bootstrap.MasonryBrick = function(config){
32974 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32976 Roo.bootstrap.MasonryBrick.register(this);
32982 * When a MasonryBrick is clcik
32983 * @param {Roo.bootstrap.MasonryBrick} this
32984 * @param {Roo.EventObject} e
32990 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32993 * @cfg {String} title
32997 * @cfg {String} html
33001 * @cfg {String} bgimage
33005 * @cfg {String} videourl
33009 * @cfg {String} cls
33013 * @cfg {String} href
33017 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
33022 * @cfg {String} placetitle (center|bottom)
33027 * @cfg {Boolean} isFitContainer defalut true
33029 isFitContainer : true,
33032 * @cfg {Boolean} preventDefault defalut false
33034 preventDefault : false,
33037 * @cfg {Boolean} inverse defalut false
33039 maskInverse : false,
33041 getAutoCreate : function()
33043 if(!this.isFitContainer){
33044 return this.getSplitAutoCreate();
33047 var cls = 'masonry-brick masonry-brick-full';
33049 if(this.href.length){
33050 cls += ' masonry-brick-link';
33053 if(this.bgimage.length){
33054 cls += ' masonry-brick-image';
33057 if(this.maskInverse){
33058 cls += ' mask-inverse';
33061 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33062 cls += ' enable-mask';
33066 cls += ' masonry-' + this.size + '-brick';
33069 if(this.placetitle.length){
33071 switch (this.placetitle) {
33073 cls += ' masonry-center-title';
33076 cls += ' masonry-bottom-title';
33083 if(!this.html.length && !this.bgimage.length){
33084 cls += ' masonry-center-title';
33087 if(!this.html.length && this.bgimage.length){
33088 cls += ' masonry-bottom-title';
33093 cls += ' ' + this.cls;
33097 tag: (this.href.length) ? 'a' : 'div',
33102 cls: 'masonry-brick-mask'
33106 cls: 'masonry-brick-paragraph',
33112 if(this.href.length){
33113 cfg.href = this.href;
33116 var cn = cfg.cn[1].cn;
33118 if(this.title.length){
33121 cls: 'masonry-brick-title',
33126 if(this.html.length){
33129 cls: 'masonry-brick-text',
33134 if (!this.title.length && !this.html.length) {
33135 cfg.cn[1].cls += ' hide';
33138 if(this.bgimage.length){
33141 cls: 'masonry-brick-image-view',
33146 if(this.videourl.length){
33147 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33148 // youtube support only?
33151 cls: 'masonry-brick-image-view',
33154 allowfullscreen : true
33162 getSplitAutoCreate : function()
33164 var cls = 'masonry-brick masonry-brick-split';
33166 if(this.href.length){
33167 cls += ' masonry-brick-link';
33170 if(this.bgimage.length){
33171 cls += ' masonry-brick-image';
33175 cls += ' masonry-' + this.size + '-brick';
33178 switch (this.placetitle) {
33180 cls += ' masonry-center-title';
33183 cls += ' masonry-bottom-title';
33186 if(!this.bgimage.length){
33187 cls += ' masonry-center-title';
33190 if(this.bgimage.length){
33191 cls += ' masonry-bottom-title';
33197 cls += ' ' + this.cls;
33201 tag: (this.href.length) ? 'a' : 'div',
33206 cls: 'masonry-brick-split-head',
33210 cls: 'masonry-brick-paragraph',
33217 cls: 'masonry-brick-split-body',
33223 if(this.href.length){
33224 cfg.href = this.href;
33227 if(this.title.length){
33228 cfg.cn[0].cn[0].cn.push({
33230 cls: 'masonry-brick-title',
33235 if(this.html.length){
33236 cfg.cn[1].cn.push({
33238 cls: 'masonry-brick-text',
33243 if(this.bgimage.length){
33244 cfg.cn[0].cn.push({
33246 cls: 'masonry-brick-image-view',
33251 if(this.videourl.length){
33252 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33253 // youtube support only?
33254 cfg.cn[0].cn.cn.push({
33256 cls: 'masonry-brick-image-view',
33259 allowfullscreen : true
33266 initEvents: function()
33268 switch (this.size) {
33301 this.el.on('touchstart', this.onTouchStart, this);
33302 this.el.on('touchmove', this.onTouchMove, this);
33303 this.el.on('touchend', this.onTouchEnd, this);
33304 this.el.on('contextmenu', this.onContextMenu, this);
33306 this.el.on('mouseenter' ,this.enter, this);
33307 this.el.on('mouseleave', this.leave, this);
33308 this.el.on('click', this.onClick, this);
33311 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33312 this.parent().bricks.push(this);
33317 onClick: function(e, el)
33319 var time = this.endTimer - this.startTimer;
33320 // Roo.log(e.preventDefault());
33323 e.preventDefault();
33328 if(!this.preventDefault){
33332 e.preventDefault();
33334 if (this.activeClass != '') {
33335 this.selectBrick();
33338 this.fireEvent('click', this, e);
33341 enter: function(e, el)
33343 e.preventDefault();
33345 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33349 if(this.bgimage.length && this.html.length){
33350 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33354 leave: function(e, el)
33356 e.preventDefault();
33358 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33362 if(this.bgimage.length && this.html.length){
33363 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33367 onTouchStart: function(e, el)
33369 // e.preventDefault();
33371 this.touchmoved = false;
33373 if(!this.isFitContainer){
33377 if(!this.bgimage.length || !this.html.length){
33381 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33383 this.timer = new Date().getTime();
33387 onTouchMove: function(e, el)
33389 this.touchmoved = true;
33392 onContextMenu : function(e,el)
33394 e.preventDefault();
33395 e.stopPropagation();
33399 onTouchEnd: function(e, el)
33401 // e.preventDefault();
33403 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33410 if(!this.bgimage.length || !this.html.length){
33412 if(this.href.length){
33413 window.location.href = this.href;
33419 if(!this.isFitContainer){
33423 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33425 window.location.href = this.href;
33428 //selection on single brick only
33429 selectBrick : function() {
33431 if (!this.parentId) {
33435 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33436 var index = m.selectedBrick.indexOf(this.id);
33439 m.selectedBrick.splice(index,1);
33440 this.el.removeClass(this.activeClass);
33444 for(var i = 0; i < m.selectedBrick.length; i++) {
33445 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33446 b.el.removeClass(b.activeClass);
33449 m.selectedBrick = [];
33451 m.selectedBrick.push(this.id);
33452 this.el.addClass(this.activeClass);
33456 isSelected : function(){
33457 return this.el.hasClass(this.activeClass);
33462 Roo.apply(Roo.bootstrap.MasonryBrick, {
33465 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33467 * register a Masonry Brick
33468 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33471 register : function(brick)
33473 //this.groups[brick.id] = brick;
33474 this.groups.add(brick.id, brick);
33477 * fetch a masonry brick based on the masonry brick ID
33478 * @param {string} the masonry brick to add
33479 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33482 get: function(brick_id)
33484 // if (typeof(this.groups[brick_id]) == 'undefined') {
33487 // return this.groups[brick_id] ;
33489 if(this.groups.key(brick_id)) {
33490 return this.groups.key(brick_id);
33508 * @class Roo.bootstrap.Brick
33509 * @extends Roo.bootstrap.Component
33510 * Bootstrap Brick class
33513 * Create a new Brick
33514 * @param {Object} config The config object
33517 Roo.bootstrap.Brick = function(config){
33518 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33524 * When a Brick is click
33525 * @param {Roo.bootstrap.Brick} this
33526 * @param {Roo.EventObject} e
33532 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33535 * @cfg {String} title
33539 * @cfg {String} html
33543 * @cfg {String} bgimage
33547 * @cfg {String} cls
33551 * @cfg {String} href
33555 * @cfg {String} video
33559 * @cfg {Boolean} square
33563 getAutoCreate : function()
33565 var cls = 'roo-brick';
33567 if(this.href.length){
33568 cls += ' roo-brick-link';
33571 if(this.bgimage.length){
33572 cls += ' roo-brick-image';
33575 if(!this.html.length && !this.bgimage.length){
33576 cls += ' roo-brick-center-title';
33579 if(!this.html.length && this.bgimage.length){
33580 cls += ' roo-brick-bottom-title';
33584 cls += ' ' + this.cls;
33588 tag: (this.href.length) ? 'a' : 'div',
33593 cls: 'roo-brick-paragraph',
33599 if(this.href.length){
33600 cfg.href = this.href;
33603 var cn = cfg.cn[0].cn;
33605 if(this.title.length){
33608 cls: 'roo-brick-title',
33613 if(this.html.length){
33616 cls: 'roo-brick-text',
33623 if(this.bgimage.length){
33626 cls: 'roo-brick-image-view',
33634 initEvents: function()
33636 if(this.title.length || this.html.length){
33637 this.el.on('mouseenter' ,this.enter, this);
33638 this.el.on('mouseleave', this.leave, this);
33641 Roo.EventManager.onWindowResize(this.resize, this);
33643 if(this.bgimage.length){
33644 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33645 this.imageEl.on('load', this.onImageLoad, this);
33652 onImageLoad : function()
33657 resize : function()
33659 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33661 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33663 if(this.bgimage.length){
33664 var image = this.el.select('.roo-brick-image-view', true).first();
33666 image.setWidth(paragraph.getWidth());
33669 image.setHeight(paragraph.getWidth());
33672 this.el.setHeight(image.getHeight());
33673 paragraph.setHeight(image.getHeight());
33679 enter: function(e, el)
33681 e.preventDefault();
33683 if(this.bgimage.length){
33684 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33685 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33689 leave: function(e, el)
33691 e.preventDefault();
33693 if(this.bgimage.length){
33694 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33695 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33710 * @class Roo.bootstrap.NumberField
33711 * @extends Roo.bootstrap.Input
33712 * Bootstrap NumberField class
33718 * Create a new NumberField
33719 * @param {Object} config The config object
33722 Roo.bootstrap.NumberField = function(config){
33723 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33726 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33729 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33731 allowDecimals : true,
33733 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33735 decimalSeparator : ".",
33737 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33739 decimalPrecision : 2,
33741 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33743 allowNegative : true,
33746 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33750 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33752 minValue : Number.NEGATIVE_INFINITY,
33754 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33756 maxValue : Number.MAX_VALUE,
33758 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33760 minText : "The minimum value for this field is {0}",
33762 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33764 maxText : "The maximum value for this field is {0}",
33766 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33767 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33769 nanText : "{0} is not a valid number",
33771 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33773 thousandsDelimiter : false,
33775 * @cfg {String} valueAlign alignment of value
33777 valueAlign : "left",
33779 getAutoCreate : function()
33781 var hiddenInput = {
33785 cls: 'hidden-number-input'
33789 hiddenInput.name = this.name;
33794 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33796 this.name = hiddenInput.name;
33798 if(cfg.cn.length > 0) {
33799 cfg.cn.push(hiddenInput);
33806 initEvents : function()
33808 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33810 var allowed = "0123456789";
33812 if(this.allowDecimals){
33813 allowed += this.decimalSeparator;
33816 if(this.allowNegative){
33820 if(this.thousandsDelimiter) {
33824 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33826 var keyPress = function(e){
33828 var k = e.getKey();
33830 var c = e.getCharCode();
33833 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33834 allowed.indexOf(String.fromCharCode(c)) === -1
33840 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33844 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33849 this.el.on("keypress", keyPress, this);
33852 validateValue : function(value)
33855 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33859 var num = this.parseValue(value);
33862 this.markInvalid(String.format(this.nanText, value));
33866 if(num < this.minValue){
33867 this.markInvalid(String.format(this.minText, this.minValue));
33871 if(num > this.maxValue){
33872 this.markInvalid(String.format(this.maxText, this.maxValue));
33879 getValue : function()
33881 var v = this.hiddenEl().getValue();
33883 return this.fixPrecision(this.parseValue(v));
33886 parseValue : function(value)
33888 if(this.thousandsDelimiter) {
33890 r = new RegExp(",", "g");
33891 value = value.replace(r, "");
33894 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33895 return isNaN(value) ? '' : value;
33898 fixPrecision : function(value)
33900 if(this.thousandsDelimiter) {
33902 r = new RegExp(",", "g");
33903 value = value.replace(r, "");
33906 var nan = isNaN(value);
33908 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33909 return nan ? '' : value;
33911 return parseFloat(value).toFixed(this.decimalPrecision);
33914 setValue : function(v)
33916 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33922 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33924 this.inputEl().dom.value = (v == '') ? '' :
33925 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33927 if(!this.allowZero && v === '0') {
33928 this.hiddenEl().dom.value = '';
33929 this.inputEl().dom.value = '';
33936 decimalPrecisionFcn : function(v)
33938 return Math.floor(v);
33941 beforeBlur : function()
33943 var v = this.parseValue(this.getRawValue());
33945 if(v || v === 0 || v === ''){
33950 hiddenEl : function()
33952 return this.el.select('input.hidden-number-input',true).first();
33964 * @class Roo.bootstrap.DocumentSlider
33965 * @extends Roo.bootstrap.Component
33966 * Bootstrap DocumentSlider class
33969 * Create a new DocumentViewer
33970 * @param {Object} config The config object
33973 Roo.bootstrap.DocumentSlider = function(config){
33974 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33981 * Fire after initEvent
33982 * @param {Roo.bootstrap.DocumentSlider} this
33987 * Fire after update
33988 * @param {Roo.bootstrap.DocumentSlider} this
33994 * @param {Roo.bootstrap.DocumentSlider} this
34000 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
34006 getAutoCreate : function()
34010 cls : 'roo-document-slider',
34014 cls : 'roo-document-slider-header',
34018 cls : 'roo-document-slider-header-title'
34024 cls : 'roo-document-slider-body',
34028 cls : 'roo-document-slider-prev',
34032 cls : 'fa fa-chevron-left'
34038 cls : 'roo-document-slider-thumb',
34042 cls : 'roo-document-slider-image'
34048 cls : 'roo-document-slider-next',
34052 cls : 'fa fa-chevron-right'
34064 initEvents : function()
34066 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34067 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34069 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34070 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34072 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34073 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34075 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34076 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34078 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34079 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34081 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34082 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34084 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34085 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34087 this.thumbEl.on('click', this.onClick, this);
34089 this.prevIndicator.on('click', this.prev, this);
34091 this.nextIndicator.on('click', this.next, this);
34095 initial : function()
34097 if(this.files.length){
34098 this.indicator = 1;
34102 this.fireEvent('initial', this);
34105 update : function()
34107 this.imageEl.attr('src', this.files[this.indicator - 1]);
34109 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34111 this.prevIndicator.show();
34113 if(this.indicator == 1){
34114 this.prevIndicator.hide();
34117 this.nextIndicator.show();
34119 if(this.indicator == this.files.length){
34120 this.nextIndicator.hide();
34123 this.thumbEl.scrollTo('top');
34125 this.fireEvent('update', this);
34128 onClick : function(e)
34130 e.preventDefault();
34132 this.fireEvent('click', this);
34137 e.preventDefault();
34139 this.indicator = Math.max(1, this.indicator - 1);
34146 e.preventDefault();
34148 this.indicator = Math.min(this.files.length, this.indicator + 1);
34162 * @class Roo.bootstrap.RadioSet
34163 * @extends Roo.bootstrap.Input
34164 * Bootstrap RadioSet class
34165 * @cfg {String} indicatorpos (left|right) default left
34166 * @cfg {Boolean} inline (true|false) inline the element (default true)
34167 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34169 * Create a new RadioSet
34170 * @param {Object} config The config object
34173 Roo.bootstrap.RadioSet = function(config){
34175 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34179 Roo.bootstrap.RadioSet.register(this);
34184 * Fires when the element is checked or unchecked.
34185 * @param {Roo.bootstrap.RadioSet} this This radio
34186 * @param {Roo.bootstrap.Radio} item The checked item
34191 * Fires when the element is click.
34192 * @param {Roo.bootstrap.RadioSet} this This radio set
34193 * @param {Roo.bootstrap.Radio} item The checked item
34194 * @param {Roo.EventObject} e The event object
34201 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34209 indicatorpos : 'left',
34211 getAutoCreate : function()
34215 cls : 'roo-radio-set-label',
34219 html : this.fieldLabel
34223 if (Roo.bootstrap.version == 3) {
34226 if(this.indicatorpos == 'left'){
34229 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34230 tooltip : 'This field is required'
34235 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34236 tooltip : 'This field is required'
34242 cls : 'roo-radio-set-items'
34245 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34247 if (align === 'left' && this.fieldLabel.length) {
34250 cls : "roo-radio-set-right",
34256 if(this.labelWidth > 12){
34257 label.style = "width: " + this.labelWidth + 'px';
34260 if(this.labelWidth < 13 && this.labelmd == 0){
34261 this.labelmd = this.labelWidth;
34264 if(this.labellg > 0){
34265 label.cls += ' col-lg-' + this.labellg;
34266 items.cls += ' col-lg-' + (12 - this.labellg);
34269 if(this.labelmd > 0){
34270 label.cls += ' col-md-' + this.labelmd;
34271 items.cls += ' col-md-' + (12 - this.labelmd);
34274 if(this.labelsm > 0){
34275 label.cls += ' col-sm-' + this.labelsm;
34276 items.cls += ' col-sm-' + (12 - this.labelsm);
34279 if(this.labelxs > 0){
34280 label.cls += ' col-xs-' + this.labelxs;
34281 items.cls += ' col-xs-' + (12 - this.labelxs);
34287 cls : 'roo-radio-set',
34291 cls : 'roo-radio-set-input',
34294 value : this.value ? this.value : ''
34301 if(this.weight.length){
34302 cfg.cls += ' roo-radio-' + this.weight;
34306 cfg.cls += ' roo-radio-set-inline';
34310 ['xs','sm','md','lg'].map(function(size){
34311 if (settings[size]) {
34312 cfg.cls += ' col-' + size + '-' + settings[size];
34320 initEvents : function()
34322 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34323 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34325 if(!this.fieldLabel.length){
34326 this.labelEl.hide();
34329 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34330 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34332 this.indicator = this.indicatorEl();
34334 if(this.indicator){
34335 this.indicator.addClass('invisible');
34338 this.originalValue = this.getValue();
34342 inputEl: function ()
34344 return this.el.select('.roo-radio-set-input', true).first();
34347 getChildContainer : function()
34349 return this.itemsEl;
34352 register : function(item)
34354 this.radioes.push(item);
34358 validate : function()
34360 if(this.getVisibilityEl().hasClass('hidden')){
34366 Roo.each(this.radioes, function(i){
34375 if(this.allowBlank) {
34379 if(this.disabled || valid){
34384 this.markInvalid();
34389 markValid : function()
34391 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34392 this.indicatorEl().removeClass('visible');
34393 this.indicatorEl().addClass('invisible');
34397 if (Roo.bootstrap.version == 3) {
34398 this.el.removeClass([this.invalidClass, this.validClass]);
34399 this.el.addClass(this.validClass);
34401 this.el.removeClass(['is-invalid','is-valid']);
34402 this.el.addClass(['is-valid']);
34404 this.fireEvent('valid', this);
34407 markInvalid : function(msg)
34409 if(this.allowBlank || this.disabled){
34413 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34414 this.indicatorEl().removeClass('invisible');
34415 this.indicatorEl().addClass('visible');
34417 if (Roo.bootstrap.version == 3) {
34418 this.el.removeClass([this.invalidClass, this.validClass]);
34419 this.el.addClass(this.invalidClass);
34421 this.el.removeClass(['is-invalid','is-valid']);
34422 this.el.addClass(['is-invalid']);
34425 this.fireEvent('invalid', this, msg);
34429 setValue : function(v, suppressEvent)
34431 if(this.value === v){
34438 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34441 Roo.each(this.radioes, function(i){
34443 i.el.removeClass('checked');
34446 Roo.each(this.radioes, function(i){
34448 if(i.value === v || i.value.toString() === v.toString()){
34450 i.el.addClass('checked');
34452 if(suppressEvent !== true){
34453 this.fireEvent('check', this, i);
34464 clearInvalid : function(){
34466 if(!this.el || this.preventMark){
34470 this.el.removeClass([this.invalidClass]);
34472 this.fireEvent('valid', this);
34477 Roo.apply(Roo.bootstrap.RadioSet, {
34481 register : function(set)
34483 this.groups[set.name] = set;
34486 get: function(name)
34488 if (typeof(this.groups[name]) == 'undefined') {
34492 return this.groups[name] ;
34498 * Ext JS Library 1.1.1
34499 * Copyright(c) 2006-2007, Ext JS, LLC.
34501 * Originally Released Under LGPL - original licence link has changed is not relivant.
34504 * <script type="text/javascript">
34509 * @class Roo.bootstrap.SplitBar
34510 * @extends Roo.util.Observable
34511 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34515 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34516 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34517 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34518 split.minSize = 100;
34519 split.maxSize = 600;
34520 split.animate = true;
34521 split.on('moved', splitterMoved);
34524 * Create a new SplitBar
34525 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34526 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34527 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34528 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34529 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34530 position of the SplitBar).
34532 Roo.bootstrap.SplitBar = function(cfg){
34537 // dragElement : elm
34538 // resizingElement: el,
34540 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34541 // placement : Roo.bootstrap.SplitBar.LEFT ,
34542 // existingProxy ???
34545 this.el = Roo.get(cfg.dragElement, true);
34546 this.el.dom.unselectable = "on";
34548 this.resizingEl = Roo.get(cfg.resizingElement, true);
34552 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34553 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34556 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34559 * The minimum size of the resizing element. (Defaults to 0)
34565 * The maximum size of the resizing element. (Defaults to 2000)
34568 this.maxSize = 2000;
34571 * Whether to animate the transition to the new size
34574 this.animate = false;
34577 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34580 this.useShim = false;
34585 if(!cfg.existingProxy){
34587 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34589 this.proxy = Roo.get(cfg.existingProxy).dom;
34592 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34595 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34598 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34601 this.dragSpecs = {};
34604 * @private The adapter to use to positon and resize elements
34606 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34607 this.adapter.init(this);
34609 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34611 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34612 this.el.addClass("roo-splitbar-h");
34615 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34616 this.el.addClass("roo-splitbar-v");
34622 * Fires when the splitter is moved (alias for {@link #event-moved})
34623 * @param {Roo.bootstrap.SplitBar} this
34624 * @param {Number} newSize the new width or height
34629 * Fires when the splitter is moved
34630 * @param {Roo.bootstrap.SplitBar} this
34631 * @param {Number} newSize the new width or height
34635 * @event beforeresize
34636 * Fires before the splitter is dragged
34637 * @param {Roo.bootstrap.SplitBar} this
34639 "beforeresize" : true,
34641 "beforeapply" : true
34644 Roo.util.Observable.call(this);
34647 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34648 onStartProxyDrag : function(x, y){
34649 this.fireEvent("beforeresize", this);
34651 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34653 o.enableDisplayMode("block");
34654 // all splitbars share the same overlay
34655 Roo.bootstrap.SplitBar.prototype.overlay = o;
34657 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34658 this.overlay.show();
34659 Roo.get(this.proxy).setDisplayed("block");
34660 var size = this.adapter.getElementSize(this);
34661 this.activeMinSize = this.getMinimumSize();;
34662 this.activeMaxSize = this.getMaximumSize();;
34663 var c1 = size - this.activeMinSize;
34664 var c2 = Math.max(this.activeMaxSize - size, 0);
34665 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34666 this.dd.resetConstraints();
34667 this.dd.setXConstraint(
34668 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34669 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34671 this.dd.setYConstraint(0, 0);
34673 this.dd.resetConstraints();
34674 this.dd.setXConstraint(0, 0);
34675 this.dd.setYConstraint(
34676 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34677 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34680 this.dragSpecs.startSize = size;
34681 this.dragSpecs.startPoint = [x, y];
34682 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34686 * @private Called after the drag operation by the DDProxy
34688 onEndProxyDrag : function(e){
34689 Roo.get(this.proxy).setDisplayed(false);
34690 var endPoint = Roo.lib.Event.getXY(e);
34692 this.overlay.hide();
34695 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34696 newSize = this.dragSpecs.startSize +
34697 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34698 endPoint[0] - this.dragSpecs.startPoint[0] :
34699 this.dragSpecs.startPoint[0] - endPoint[0]
34702 newSize = this.dragSpecs.startSize +
34703 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34704 endPoint[1] - this.dragSpecs.startPoint[1] :
34705 this.dragSpecs.startPoint[1] - endPoint[1]
34708 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34709 if(newSize != this.dragSpecs.startSize){
34710 if(this.fireEvent('beforeapply', this, newSize) !== false){
34711 this.adapter.setElementSize(this, newSize);
34712 this.fireEvent("moved", this, newSize);
34713 this.fireEvent("resize", this, newSize);
34719 * Get the adapter this SplitBar uses
34720 * @return The adapter object
34722 getAdapter : function(){
34723 return this.adapter;
34727 * Set the adapter this SplitBar uses
34728 * @param {Object} adapter A SplitBar adapter object
34730 setAdapter : function(adapter){
34731 this.adapter = adapter;
34732 this.adapter.init(this);
34736 * Gets the minimum size for the resizing element
34737 * @return {Number} The minimum size
34739 getMinimumSize : function(){
34740 return this.minSize;
34744 * Sets the minimum size for the resizing element
34745 * @param {Number} minSize The minimum size
34747 setMinimumSize : function(minSize){
34748 this.minSize = minSize;
34752 * Gets the maximum size for the resizing element
34753 * @return {Number} The maximum size
34755 getMaximumSize : function(){
34756 return this.maxSize;
34760 * Sets the maximum size for the resizing element
34761 * @param {Number} maxSize The maximum size
34763 setMaximumSize : function(maxSize){
34764 this.maxSize = maxSize;
34768 * Sets the initialize size for the resizing element
34769 * @param {Number} size The initial size
34771 setCurrentSize : function(size){
34772 var oldAnimate = this.animate;
34773 this.animate = false;
34774 this.adapter.setElementSize(this, size);
34775 this.animate = oldAnimate;
34779 * Destroy this splitbar.
34780 * @param {Boolean} removeEl True to remove the element
34782 destroy : function(removeEl){
34784 this.shim.remove();
34787 this.proxy.parentNode.removeChild(this.proxy);
34795 * @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.
34797 Roo.bootstrap.SplitBar.createProxy = function(dir){
34798 var proxy = new Roo.Element(document.createElement("div"));
34799 proxy.unselectable();
34800 var cls = 'roo-splitbar-proxy';
34801 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34802 document.body.appendChild(proxy.dom);
34807 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34808 * Default Adapter. It assumes the splitter and resizing element are not positioned
34809 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34811 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34814 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34815 // do nothing for now
34816 init : function(s){
34820 * Called before drag operations to get the current size of the resizing element.
34821 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34823 getElementSize : function(s){
34824 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34825 return s.resizingEl.getWidth();
34827 return s.resizingEl.getHeight();
34832 * Called after drag operations to set the size of the resizing element.
34833 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34834 * @param {Number} newSize The new size to set
34835 * @param {Function} onComplete A function to be invoked when resizing is complete
34837 setElementSize : function(s, newSize, onComplete){
34838 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34840 s.resizingEl.setWidth(newSize);
34842 onComplete(s, newSize);
34845 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34850 s.resizingEl.setHeight(newSize);
34852 onComplete(s, newSize);
34855 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34862 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34863 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34864 * Adapter that moves the splitter element to align with the resized sizing element.
34865 * Used with an absolute positioned SplitBar.
34866 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34867 * document.body, make sure you assign an id to the body element.
34869 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34870 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34871 this.container = Roo.get(container);
34874 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34875 init : function(s){
34876 this.basic.init(s);
34879 getElementSize : function(s){
34880 return this.basic.getElementSize(s);
34883 setElementSize : function(s, newSize, onComplete){
34884 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34887 moveSplitter : function(s){
34888 var yes = Roo.bootstrap.SplitBar;
34889 switch(s.placement){
34891 s.el.setX(s.resizingEl.getRight());
34894 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34897 s.el.setY(s.resizingEl.getBottom());
34900 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34907 * Orientation constant - Create a vertical SplitBar
34911 Roo.bootstrap.SplitBar.VERTICAL = 1;
34914 * Orientation constant - Create a horizontal SplitBar
34918 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34921 * Placement constant - The resizing element is to the left of the splitter element
34925 Roo.bootstrap.SplitBar.LEFT = 1;
34928 * Placement constant - The resizing element is to the right of the splitter element
34932 Roo.bootstrap.SplitBar.RIGHT = 2;
34935 * Placement constant - The resizing element is positioned above the splitter element
34939 Roo.bootstrap.SplitBar.TOP = 3;
34942 * Placement constant - The resizing element is positioned under splitter element
34946 Roo.bootstrap.SplitBar.BOTTOM = 4;
34947 Roo.namespace("Roo.bootstrap.layout");/*
34949 * Ext JS Library 1.1.1
34950 * Copyright(c) 2006-2007, Ext JS, LLC.
34952 * Originally Released Under LGPL - original licence link has changed is not relivant.
34955 * <script type="text/javascript">
34959 * @class Roo.bootstrap.layout.Manager
34960 * @extends Roo.bootstrap.Component
34961 * Base class for layout managers.
34963 Roo.bootstrap.layout.Manager = function(config)
34965 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34971 /** false to disable window resize monitoring @type Boolean */
34972 this.monitorWindowResize = true;
34977 * Fires when a layout is performed.
34978 * @param {Roo.LayoutManager} this
34982 * @event regionresized
34983 * Fires when the user resizes a region.
34984 * @param {Roo.LayoutRegion} region The resized region
34985 * @param {Number} newSize The new size (width for east/west, height for north/south)
34987 "regionresized" : true,
34989 * @event regioncollapsed
34990 * Fires when a region is collapsed.
34991 * @param {Roo.LayoutRegion} region The collapsed region
34993 "regioncollapsed" : true,
34995 * @event regionexpanded
34996 * Fires when a region is expanded.
34997 * @param {Roo.LayoutRegion} region The expanded region
34999 "regionexpanded" : true
35001 this.updating = false;
35004 this.el = Roo.get(config.el);
35010 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
35015 monitorWindowResize : true,
35021 onRender : function(ct, position)
35024 this.el = Roo.get(ct);
35027 //this.fireEvent('render',this);
35031 initEvents: function()
35035 // ie scrollbar fix
35036 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
35037 document.body.scroll = "no";
35038 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
35039 this.el.position('relative');
35041 this.id = this.el.id;
35042 this.el.addClass("roo-layout-container");
35043 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35044 if(this.el.dom != document.body ) {
35045 this.el.on('resize', this.layout,this);
35046 this.el.on('show', this.layout,this);
35052 * Returns true if this layout is currently being updated
35053 * @return {Boolean}
35055 isUpdating : function(){
35056 return this.updating;
35060 * Suspend the LayoutManager from doing auto-layouts while
35061 * making multiple add or remove calls
35063 beginUpdate : function(){
35064 this.updating = true;
35068 * Restore auto-layouts and optionally disable the manager from performing a layout
35069 * @param {Boolean} noLayout true to disable a layout update
35071 endUpdate : function(noLayout){
35072 this.updating = false;
35078 layout: function(){
35082 onRegionResized : function(region, newSize){
35083 this.fireEvent("regionresized", region, newSize);
35087 onRegionCollapsed : function(region){
35088 this.fireEvent("regioncollapsed", region);
35091 onRegionExpanded : function(region){
35092 this.fireEvent("regionexpanded", region);
35096 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35097 * performs box-model adjustments.
35098 * @return {Object} The size as an object {width: (the width), height: (the height)}
35100 getViewSize : function()
35103 if(this.el.dom != document.body){
35104 size = this.el.getSize();
35106 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35108 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35109 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35114 * Returns the Element this layout is bound to.
35115 * @return {Roo.Element}
35117 getEl : function(){
35122 * Returns the specified region.
35123 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35124 * @return {Roo.LayoutRegion}
35126 getRegion : function(target){
35127 return this.regions[target.toLowerCase()];
35130 onWindowResize : function(){
35131 if(this.monitorWindowResize){
35138 * Ext JS Library 1.1.1
35139 * Copyright(c) 2006-2007, Ext JS, LLC.
35141 * Originally Released Under LGPL - original licence link has changed is not relivant.
35144 * <script type="text/javascript">
35147 * @class Roo.bootstrap.layout.Border
35148 * @extends Roo.bootstrap.layout.Manager
35149 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35150 * please see: examples/bootstrap/nested.html<br><br>
35152 <b>The container the layout is rendered into can be either the body element or any other element.
35153 If it is not the body element, the container needs to either be an absolute positioned element,
35154 or you will need to add "position:relative" to the css of the container. You will also need to specify
35155 the container size if it is not the body element.</b>
35158 * Create a new Border
35159 * @param {Object} config Configuration options
35161 Roo.bootstrap.layout.Border = function(config){
35162 config = config || {};
35163 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35167 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35168 if(config[region]){
35169 config[region].region = region;
35170 this.addRegion(config[region]);
35176 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35178 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35180 parent : false, // this might point to a 'nest' or a ???
35183 * Creates and adds a new region if it doesn't already exist.
35184 * @param {String} target The target region key (north, south, east, west or center).
35185 * @param {Object} config The regions config object
35186 * @return {BorderLayoutRegion} The new region
35188 addRegion : function(config)
35190 if(!this.regions[config.region]){
35191 var r = this.factory(config);
35192 this.bindRegion(r);
35194 return this.regions[config.region];
35198 bindRegion : function(r){
35199 this.regions[r.config.region] = r;
35201 r.on("visibilitychange", this.layout, this);
35202 r.on("paneladded", this.layout, this);
35203 r.on("panelremoved", this.layout, this);
35204 r.on("invalidated", this.layout, this);
35205 r.on("resized", this.onRegionResized, this);
35206 r.on("collapsed", this.onRegionCollapsed, this);
35207 r.on("expanded", this.onRegionExpanded, this);
35211 * Performs a layout update.
35213 layout : function()
35215 if(this.updating) {
35219 // render all the rebions if they have not been done alreayd?
35220 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35221 if(this.regions[region] && !this.regions[region].bodyEl){
35222 this.regions[region].onRender(this.el)
35226 var size = this.getViewSize();
35227 var w = size.width;
35228 var h = size.height;
35233 //var x = 0, y = 0;
35235 var rs = this.regions;
35236 var north = rs["north"];
35237 var south = rs["south"];
35238 var west = rs["west"];
35239 var east = rs["east"];
35240 var center = rs["center"];
35241 //if(this.hideOnLayout){ // not supported anymore
35242 //c.el.setStyle("display", "none");
35244 if(north && north.isVisible()){
35245 var b = north.getBox();
35246 var m = north.getMargins();
35247 b.width = w - (m.left+m.right);
35250 centerY = b.height + b.y + m.bottom;
35251 centerH -= centerY;
35252 north.updateBox(this.safeBox(b));
35254 if(south && south.isVisible()){
35255 var b = south.getBox();
35256 var m = south.getMargins();
35257 b.width = w - (m.left+m.right);
35259 var totalHeight = (b.height + m.top + m.bottom);
35260 b.y = h - totalHeight + m.top;
35261 centerH -= totalHeight;
35262 south.updateBox(this.safeBox(b));
35264 if(west && west.isVisible()){
35265 var b = west.getBox();
35266 var m = west.getMargins();
35267 b.height = centerH - (m.top+m.bottom);
35269 b.y = centerY + m.top;
35270 var totalWidth = (b.width + m.left + m.right);
35271 centerX += totalWidth;
35272 centerW -= totalWidth;
35273 west.updateBox(this.safeBox(b));
35275 if(east && east.isVisible()){
35276 var b = east.getBox();
35277 var m = east.getMargins();
35278 b.height = centerH - (m.top+m.bottom);
35279 var totalWidth = (b.width + m.left + m.right);
35280 b.x = w - totalWidth + m.left;
35281 b.y = centerY + m.top;
35282 centerW -= totalWidth;
35283 east.updateBox(this.safeBox(b));
35286 var m = center.getMargins();
35288 x: centerX + m.left,
35289 y: centerY + m.top,
35290 width: centerW - (m.left+m.right),
35291 height: centerH - (m.top+m.bottom)
35293 //if(this.hideOnLayout){
35294 //center.el.setStyle("display", "block");
35296 center.updateBox(this.safeBox(centerBox));
35299 this.fireEvent("layout", this);
35303 safeBox : function(box){
35304 box.width = Math.max(0, box.width);
35305 box.height = Math.max(0, box.height);
35310 * Adds a ContentPanel (or subclass) to this layout.
35311 * @param {String} target The target region key (north, south, east, west or center).
35312 * @param {Roo.ContentPanel} panel The panel to add
35313 * @return {Roo.ContentPanel} The added panel
35315 add : function(target, panel){
35317 target = target.toLowerCase();
35318 return this.regions[target].add(panel);
35322 * Remove a ContentPanel (or subclass) to this layout.
35323 * @param {String} target The target region key (north, south, east, west or center).
35324 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35325 * @return {Roo.ContentPanel} The removed panel
35327 remove : function(target, panel){
35328 target = target.toLowerCase();
35329 return this.regions[target].remove(panel);
35333 * Searches all regions for a panel with the specified id
35334 * @param {String} panelId
35335 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35337 findPanel : function(panelId){
35338 var rs = this.regions;
35339 for(var target in rs){
35340 if(typeof rs[target] != "function"){
35341 var p = rs[target].getPanel(panelId);
35351 * Searches all regions for a panel with the specified id and activates (shows) it.
35352 * @param {String/ContentPanel} panelId The panels id or the panel itself
35353 * @return {Roo.ContentPanel} The shown panel or null
35355 showPanel : function(panelId) {
35356 var rs = this.regions;
35357 for(var target in rs){
35358 var r = rs[target];
35359 if(typeof r != "function"){
35360 if(r.hasPanel(panelId)){
35361 return r.showPanel(panelId);
35369 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35370 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35373 restoreState : function(provider){
35375 provider = Roo.state.Manager;
35377 var sm = new Roo.LayoutStateManager();
35378 sm.init(this, provider);
35384 * Adds a xtype elements to the layout.
35388 xtype : 'ContentPanel',
35395 xtype : 'NestedLayoutPanel',
35401 items : [ ... list of content panels or nested layout panels.. ]
35405 * @param {Object} cfg Xtype definition of item to add.
35407 addxtype : function(cfg)
35409 // basically accepts a pannel...
35410 // can accept a layout region..!?!?
35411 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35414 // theory? children can only be panels??
35416 //if (!cfg.xtype.match(/Panel$/)) {
35421 if (typeof(cfg.region) == 'undefined') {
35422 Roo.log("Failed to add Panel, region was not set");
35426 var region = cfg.region;
35432 xitems = cfg.items;
35437 if ( region == 'center') {
35438 Roo.log("Center: " + cfg.title);
35444 case 'Content': // ContentPanel (el, cfg)
35445 case 'Scroll': // ContentPanel (el, cfg)
35447 cfg.autoCreate = cfg.autoCreate || true;
35448 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35450 // var el = this.el.createChild();
35451 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35454 this.add(region, ret);
35458 case 'TreePanel': // our new panel!
35459 cfg.el = this.el.createChild();
35460 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35461 this.add(region, ret);
35466 // create a new Layout (which is a Border Layout...
35468 var clayout = cfg.layout;
35469 clayout.el = this.el.createChild();
35470 clayout.items = clayout.items || [];
35474 // replace this exitems with the clayout ones..
35475 xitems = clayout.items;
35477 // force background off if it's in center...
35478 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35479 cfg.background = false;
35481 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35484 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35485 //console.log('adding nested layout panel ' + cfg.toSource());
35486 this.add(region, ret);
35487 nb = {}; /// find first...
35492 // needs grid and region
35494 //var el = this.getRegion(region).el.createChild();
35496 *var el = this.el.createChild();
35497 // create the grid first...
35498 cfg.grid.container = el;
35499 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35502 if (region == 'center' && this.active ) {
35503 cfg.background = false;
35506 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35508 this.add(region, ret);
35510 if (cfg.background) {
35511 // render grid on panel activation (if panel background)
35512 ret.on('activate', function(gp) {
35513 if (!gp.grid.rendered) {
35514 // gp.grid.render(el);
35518 // cfg.grid.render(el);
35524 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35525 // it was the old xcomponent building that caused this before.
35526 // espeically if border is the top element in the tree.
35536 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35538 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35539 this.add(region, ret);
35543 throw "Can not add '" + cfg.xtype + "' to Border";
35549 this.beginUpdate();
35553 Roo.each(xitems, function(i) {
35554 region = nb && i.region ? i.region : false;
35556 var add = ret.addxtype(i);
35559 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35560 if (!i.background) {
35561 abn[region] = nb[region] ;
35568 // make the last non-background panel active..
35569 //if (nb) { Roo.log(abn); }
35572 for(var r in abn) {
35573 region = this.getRegion(r);
35575 // tried using nb[r], but it does not work..
35577 region.showPanel(abn[r]);
35588 factory : function(cfg)
35591 var validRegions = Roo.bootstrap.layout.Border.regions;
35593 var target = cfg.region;
35596 var r = Roo.bootstrap.layout;
35600 return new r.North(cfg);
35602 return new r.South(cfg);
35604 return new r.East(cfg);
35606 return new r.West(cfg);
35608 return new r.Center(cfg);
35610 throw 'Layout region "'+target+'" not supported.';
35617 * Ext JS Library 1.1.1
35618 * Copyright(c) 2006-2007, Ext JS, LLC.
35620 * Originally Released Under LGPL - original licence link has changed is not relivant.
35623 * <script type="text/javascript">
35627 * @class Roo.bootstrap.layout.Basic
35628 * @extends Roo.util.Observable
35629 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35630 * and does not have a titlebar, tabs or any other features. All it does is size and position
35631 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35632 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35633 * @cfg {string} region the region that it inhabits..
35634 * @cfg {bool} skipConfig skip config?
35638 Roo.bootstrap.layout.Basic = function(config){
35640 this.mgr = config.mgr;
35642 this.position = config.region;
35644 var skipConfig = config.skipConfig;
35648 * @scope Roo.BasicLayoutRegion
35652 * @event beforeremove
35653 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35654 * @param {Roo.LayoutRegion} this
35655 * @param {Roo.ContentPanel} panel The panel
35656 * @param {Object} e The cancel event object
35658 "beforeremove" : true,
35660 * @event invalidated
35661 * Fires when the layout for this region is changed.
35662 * @param {Roo.LayoutRegion} this
35664 "invalidated" : true,
35666 * @event visibilitychange
35667 * Fires when this region is shown or hidden
35668 * @param {Roo.LayoutRegion} this
35669 * @param {Boolean} visibility true or false
35671 "visibilitychange" : true,
35673 * @event paneladded
35674 * Fires when a panel is added.
35675 * @param {Roo.LayoutRegion} this
35676 * @param {Roo.ContentPanel} panel The panel
35678 "paneladded" : true,
35680 * @event panelremoved
35681 * Fires when a panel is removed.
35682 * @param {Roo.LayoutRegion} this
35683 * @param {Roo.ContentPanel} panel The panel
35685 "panelremoved" : true,
35687 * @event beforecollapse
35688 * Fires when this region before collapse.
35689 * @param {Roo.LayoutRegion} this
35691 "beforecollapse" : true,
35694 * Fires when this region is collapsed.
35695 * @param {Roo.LayoutRegion} this
35697 "collapsed" : true,
35700 * Fires when this region is expanded.
35701 * @param {Roo.LayoutRegion} this
35706 * Fires when this region is slid into view.
35707 * @param {Roo.LayoutRegion} this
35709 "slideshow" : true,
35712 * Fires when this region slides out of view.
35713 * @param {Roo.LayoutRegion} this
35715 "slidehide" : true,
35717 * @event panelactivated
35718 * Fires when a panel is activated.
35719 * @param {Roo.LayoutRegion} this
35720 * @param {Roo.ContentPanel} panel The activated panel
35722 "panelactivated" : true,
35725 * Fires when the user resizes this region.
35726 * @param {Roo.LayoutRegion} this
35727 * @param {Number} newSize The new size (width for east/west, height for north/south)
35731 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35732 this.panels = new Roo.util.MixedCollection();
35733 this.panels.getKey = this.getPanelId.createDelegate(this);
35735 this.activePanel = null;
35736 // ensure listeners are added...
35738 if (config.listeners || config.events) {
35739 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35740 listeners : config.listeners || {},
35741 events : config.events || {}
35745 if(skipConfig !== true){
35746 this.applyConfig(config);
35750 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35752 getPanelId : function(p){
35756 applyConfig : function(config){
35757 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35758 this.config = config;
35763 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35764 * the width, for horizontal (north, south) the height.
35765 * @param {Number} newSize The new width or height
35767 resizeTo : function(newSize){
35768 var el = this.el ? this.el :
35769 (this.activePanel ? this.activePanel.getEl() : null);
35771 switch(this.position){
35774 el.setWidth(newSize);
35775 this.fireEvent("resized", this, newSize);
35779 el.setHeight(newSize);
35780 this.fireEvent("resized", this, newSize);
35786 getBox : function(){
35787 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35790 getMargins : function(){
35791 return this.margins;
35794 updateBox : function(box){
35796 var el = this.activePanel.getEl();
35797 el.dom.style.left = box.x + "px";
35798 el.dom.style.top = box.y + "px";
35799 this.activePanel.setSize(box.width, box.height);
35803 * Returns the container element for this region.
35804 * @return {Roo.Element}
35806 getEl : function(){
35807 return this.activePanel;
35811 * Returns true if this region is currently visible.
35812 * @return {Boolean}
35814 isVisible : function(){
35815 return this.activePanel ? true : false;
35818 setActivePanel : function(panel){
35819 panel = this.getPanel(panel);
35820 if(this.activePanel && this.activePanel != panel){
35821 this.activePanel.setActiveState(false);
35822 this.activePanel.getEl().setLeftTop(-10000,-10000);
35824 this.activePanel = panel;
35825 panel.setActiveState(true);
35827 panel.setSize(this.box.width, this.box.height);
35829 this.fireEvent("panelactivated", this, panel);
35830 this.fireEvent("invalidated");
35834 * Show the specified panel.
35835 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35836 * @return {Roo.ContentPanel} The shown panel or null
35838 showPanel : function(panel){
35839 panel = this.getPanel(panel);
35841 this.setActivePanel(panel);
35847 * Get the active panel for this region.
35848 * @return {Roo.ContentPanel} The active panel or null
35850 getActivePanel : function(){
35851 return this.activePanel;
35855 * Add the passed ContentPanel(s)
35856 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35857 * @return {Roo.ContentPanel} The panel added (if only one was added)
35859 add : function(panel){
35860 if(arguments.length > 1){
35861 for(var i = 0, len = arguments.length; i < len; i++) {
35862 this.add(arguments[i]);
35866 if(this.hasPanel(panel)){
35867 this.showPanel(panel);
35870 var el = panel.getEl();
35871 if(el.dom.parentNode != this.mgr.el.dom){
35872 this.mgr.el.dom.appendChild(el.dom);
35874 if(panel.setRegion){
35875 panel.setRegion(this);
35877 this.panels.add(panel);
35878 el.setStyle("position", "absolute");
35879 if(!panel.background){
35880 this.setActivePanel(panel);
35881 if(this.config.initialSize && this.panels.getCount()==1){
35882 this.resizeTo(this.config.initialSize);
35885 this.fireEvent("paneladded", this, panel);
35890 * Returns true if the panel is in this region.
35891 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35892 * @return {Boolean}
35894 hasPanel : function(panel){
35895 if(typeof panel == "object"){ // must be panel obj
35896 panel = panel.getId();
35898 return this.getPanel(panel) ? true : false;
35902 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35903 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35904 * @param {Boolean} preservePanel Overrides the config preservePanel option
35905 * @return {Roo.ContentPanel} The panel that was removed
35907 remove : function(panel, preservePanel){
35908 panel = this.getPanel(panel);
35913 this.fireEvent("beforeremove", this, panel, e);
35914 if(e.cancel === true){
35917 var panelId = panel.getId();
35918 this.panels.removeKey(panelId);
35923 * Returns the panel specified or null if it's not in this region.
35924 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35925 * @return {Roo.ContentPanel}
35927 getPanel : function(id){
35928 if(typeof id == "object"){ // must be panel obj
35931 return this.panels.get(id);
35935 * Returns this regions position (north/south/east/west/center).
35938 getPosition: function(){
35939 return this.position;
35943 * Ext JS Library 1.1.1
35944 * Copyright(c) 2006-2007, Ext JS, LLC.
35946 * Originally Released Under LGPL - original licence link has changed is not relivant.
35949 * <script type="text/javascript">
35953 * @class Roo.bootstrap.layout.Region
35954 * @extends Roo.bootstrap.layout.Basic
35955 * This class represents a region in a layout manager.
35957 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35958 * @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})
35959 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35960 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35961 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35962 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35963 * @cfg {String} title The title for the region (overrides panel titles)
35964 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35965 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35966 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35967 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35968 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35969 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35970 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35971 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35972 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35973 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35975 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35976 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35977 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35978 * @cfg {Number} width For East/West panels
35979 * @cfg {Number} height For North/South panels
35980 * @cfg {Boolean} split To show the splitter
35981 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35983 * @cfg {string} cls Extra CSS classes to add to region
35985 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35986 * @cfg {string} region the region that it inhabits..
35989 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35990 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35992 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35993 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35994 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35996 Roo.bootstrap.layout.Region = function(config)
35998 this.applyConfig(config);
36000 var mgr = config.mgr;
36001 var pos = config.region;
36002 config.skipConfig = true;
36003 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
36006 this.onRender(mgr.el);
36009 this.visible = true;
36010 this.collapsed = false;
36011 this.unrendered_panels = [];
36014 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
36016 position: '', // set by wrapper (eg. north/south etc..)
36017 unrendered_panels : null, // unrendered panels.
36019 tabPosition : false,
36021 mgr: false, // points to 'Border'
36024 createBody : function(){
36025 /** This region's body element
36026 * @type Roo.Element */
36027 this.bodyEl = this.el.createChild({
36029 cls: "roo-layout-panel-body tab-content" // bootstrap added...
36033 onRender: function(ctr, pos)
36035 var dh = Roo.DomHelper;
36036 /** This region's container element
36037 * @type Roo.Element */
36038 this.el = dh.append(ctr.dom, {
36040 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
36042 /** This region's title element
36043 * @type Roo.Element */
36045 this.titleEl = dh.append(this.el.dom, {
36047 unselectable: "on",
36048 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36050 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36051 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36055 this.titleEl.enableDisplayMode();
36056 /** This region's title text element
36057 * @type HTMLElement */
36058 this.titleTextEl = this.titleEl.dom.firstChild;
36059 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36061 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36062 this.closeBtn.enableDisplayMode();
36063 this.closeBtn.on("click", this.closeClicked, this);
36064 this.closeBtn.hide();
36066 this.createBody(this.config);
36067 if(this.config.hideWhenEmpty){
36069 this.on("paneladded", this.validateVisibility, this);
36070 this.on("panelremoved", this.validateVisibility, this);
36072 if(this.autoScroll){
36073 this.bodyEl.setStyle("overflow", "auto");
36075 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36077 //if(c.titlebar !== false){
36078 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36079 this.titleEl.hide();
36081 this.titleEl.show();
36082 if(this.config.title){
36083 this.titleTextEl.innerHTML = this.config.title;
36087 if(this.config.collapsed){
36088 this.collapse(true);
36090 if(this.config.hidden){
36094 if (this.unrendered_panels && this.unrendered_panels.length) {
36095 for (var i =0;i< this.unrendered_panels.length; i++) {
36096 this.add(this.unrendered_panels[i]);
36098 this.unrendered_panels = null;
36104 applyConfig : function(c)
36107 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36108 var dh = Roo.DomHelper;
36109 if(c.titlebar !== false){
36110 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36111 this.collapseBtn.on("click", this.collapse, this);
36112 this.collapseBtn.enableDisplayMode();
36114 if(c.showPin === true || this.showPin){
36115 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36116 this.stickBtn.enableDisplayMode();
36117 this.stickBtn.on("click", this.expand, this);
36118 this.stickBtn.hide();
36123 /** This region's collapsed element
36124 * @type Roo.Element */
36127 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36128 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36131 if(c.floatable !== false){
36132 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36133 this.collapsedEl.on("click", this.collapseClick, this);
36136 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36137 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36138 id: "message", unselectable: "on", style:{"float":"left"}});
36139 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36141 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36142 this.expandBtn.on("click", this.expand, this);
36146 if(this.collapseBtn){
36147 this.collapseBtn.setVisible(c.collapsible == true);
36150 this.cmargins = c.cmargins || this.cmargins ||
36151 (this.position == "west" || this.position == "east" ?
36152 {top: 0, left: 2, right:2, bottom: 0} :
36153 {top: 2, left: 0, right:0, bottom: 2});
36155 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36158 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36160 this.autoScroll = c.autoScroll || false;
36165 this.duration = c.duration || .30;
36166 this.slideDuration = c.slideDuration || .45;
36171 * Returns true if this region is currently visible.
36172 * @return {Boolean}
36174 isVisible : function(){
36175 return this.visible;
36179 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36180 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36182 //setCollapsedTitle : function(title){
36183 // title = title || " ";
36184 // if(this.collapsedTitleTextEl){
36185 // this.collapsedTitleTextEl.innerHTML = title;
36189 getBox : function(){
36191 // if(!this.collapsed){
36192 b = this.el.getBox(false, true);
36194 // b = this.collapsedEl.getBox(false, true);
36199 getMargins : function(){
36200 return this.margins;
36201 //return this.collapsed ? this.cmargins : this.margins;
36204 highlight : function(){
36205 this.el.addClass("x-layout-panel-dragover");
36208 unhighlight : function(){
36209 this.el.removeClass("x-layout-panel-dragover");
36212 updateBox : function(box)
36214 if (!this.bodyEl) {
36215 return; // not rendered yet..
36219 if(!this.collapsed){
36220 this.el.dom.style.left = box.x + "px";
36221 this.el.dom.style.top = box.y + "px";
36222 this.updateBody(box.width, box.height);
36224 this.collapsedEl.dom.style.left = box.x + "px";
36225 this.collapsedEl.dom.style.top = box.y + "px";
36226 this.collapsedEl.setSize(box.width, box.height);
36229 this.tabs.autoSizeTabs();
36233 updateBody : function(w, h)
36236 this.el.setWidth(w);
36237 w -= this.el.getBorderWidth("rl");
36238 if(this.config.adjustments){
36239 w += this.config.adjustments[0];
36242 if(h !== null && h > 0){
36243 this.el.setHeight(h);
36244 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36245 h -= this.el.getBorderWidth("tb");
36246 if(this.config.adjustments){
36247 h += this.config.adjustments[1];
36249 this.bodyEl.setHeight(h);
36251 h = this.tabs.syncHeight(h);
36254 if(this.panelSize){
36255 w = w !== null ? w : this.panelSize.width;
36256 h = h !== null ? h : this.panelSize.height;
36258 if(this.activePanel){
36259 var el = this.activePanel.getEl();
36260 w = w !== null ? w : el.getWidth();
36261 h = h !== null ? h : el.getHeight();
36262 this.panelSize = {width: w, height: h};
36263 this.activePanel.setSize(w, h);
36265 if(Roo.isIE && this.tabs){
36266 this.tabs.el.repaint();
36271 * Returns the container element for this region.
36272 * @return {Roo.Element}
36274 getEl : function(){
36279 * Hides this region.
36282 //if(!this.collapsed){
36283 this.el.dom.style.left = "-2000px";
36286 // this.collapsedEl.dom.style.left = "-2000px";
36287 // this.collapsedEl.hide();
36289 this.visible = false;
36290 this.fireEvent("visibilitychange", this, false);
36294 * Shows this region if it was previously hidden.
36297 //if(!this.collapsed){
36300 // this.collapsedEl.show();
36302 this.visible = true;
36303 this.fireEvent("visibilitychange", this, true);
36306 closeClicked : function(){
36307 if(this.activePanel){
36308 this.remove(this.activePanel);
36312 collapseClick : function(e){
36314 e.stopPropagation();
36317 e.stopPropagation();
36323 * Collapses this region.
36324 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36327 collapse : function(skipAnim, skipCheck = false){
36328 if(this.collapsed) {
36332 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36334 this.collapsed = true;
36336 this.split.el.hide();
36338 if(this.config.animate && skipAnim !== true){
36339 this.fireEvent("invalidated", this);
36340 this.animateCollapse();
36342 this.el.setLocation(-20000,-20000);
36344 this.collapsedEl.show();
36345 this.fireEvent("collapsed", this);
36346 this.fireEvent("invalidated", this);
36352 animateCollapse : function(){
36357 * Expands this region if it was previously collapsed.
36358 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36359 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36362 expand : function(e, skipAnim){
36364 e.stopPropagation();
36366 if(!this.collapsed || this.el.hasActiveFx()) {
36370 this.afterSlideIn();
36373 this.collapsed = false;
36374 if(this.config.animate && skipAnim !== true){
36375 this.animateExpand();
36379 this.split.el.show();
36381 this.collapsedEl.setLocation(-2000,-2000);
36382 this.collapsedEl.hide();
36383 this.fireEvent("invalidated", this);
36384 this.fireEvent("expanded", this);
36388 animateExpand : function(){
36392 initTabs : function()
36394 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36396 var ts = new Roo.bootstrap.panel.Tabs({
36397 el: this.bodyEl.dom,
36399 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36400 disableTooltips: this.config.disableTabTips,
36401 toolbar : this.config.toolbar
36404 if(this.config.hideTabs){
36405 ts.stripWrap.setDisplayed(false);
36408 ts.resizeTabs = this.config.resizeTabs === true;
36409 ts.minTabWidth = this.config.minTabWidth || 40;
36410 ts.maxTabWidth = this.config.maxTabWidth || 250;
36411 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36412 ts.monitorResize = false;
36413 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36414 ts.bodyEl.addClass('roo-layout-tabs-body');
36415 this.panels.each(this.initPanelAsTab, this);
36418 initPanelAsTab : function(panel){
36419 var ti = this.tabs.addTab(
36423 this.config.closeOnTab && panel.isClosable(),
36426 if(panel.tabTip !== undefined){
36427 ti.setTooltip(panel.tabTip);
36429 ti.on("activate", function(){
36430 this.setActivePanel(panel);
36433 if(this.config.closeOnTab){
36434 ti.on("beforeclose", function(t, e){
36436 this.remove(panel);
36440 panel.tabItem = ti;
36445 updatePanelTitle : function(panel, title)
36447 if(this.activePanel == panel){
36448 this.updateTitle(title);
36451 var ti = this.tabs.getTab(panel.getEl().id);
36453 if(panel.tabTip !== undefined){
36454 ti.setTooltip(panel.tabTip);
36459 updateTitle : function(title){
36460 if(this.titleTextEl && !this.config.title){
36461 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36465 setActivePanel : function(panel)
36467 panel = this.getPanel(panel);
36468 if(this.activePanel && this.activePanel != panel){
36469 if(this.activePanel.setActiveState(false) === false){
36473 this.activePanel = panel;
36474 panel.setActiveState(true);
36475 if(this.panelSize){
36476 panel.setSize(this.panelSize.width, this.panelSize.height);
36479 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36481 this.updateTitle(panel.getTitle());
36483 this.fireEvent("invalidated", this);
36485 this.fireEvent("panelactivated", this, panel);
36489 * Shows the specified panel.
36490 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36491 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36493 showPanel : function(panel)
36495 panel = this.getPanel(panel);
36498 var tab = this.tabs.getTab(panel.getEl().id);
36499 if(tab.isHidden()){
36500 this.tabs.unhideTab(tab.id);
36504 this.setActivePanel(panel);
36511 * Get the active panel for this region.
36512 * @return {Roo.ContentPanel} The active panel or null
36514 getActivePanel : function(){
36515 return this.activePanel;
36518 validateVisibility : function(){
36519 if(this.panels.getCount() < 1){
36520 this.updateTitle(" ");
36521 this.closeBtn.hide();
36524 if(!this.isVisible()){
36531 * Adds the passed ContentPanel(s) to this region.
36532 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36533 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36535 add : function(panel)
36537 if(arguments.length > 1){
36538 for(var i = 0, len = arguments.length; i < len; i++) {
36539 this.add(arguments[i]);
36544 // if we have not been rendered yet, then we can not really do much of this..
36545 if (!this.bodyEl) {
36546 this.unrendered_panels.push(panel);
36553 if(this.hasPanel(panel)){
36554 this.showPanel(panel);
36557 panel.setRegion(this);
36558 this.panels.add(panel);
36559 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36560 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36561 // and hide them... ???
36562 this.bodyEl.dom.appendChild(panel.getEl().dom);
36563 if(panel.background !== true){
36564 this.setActivePanel(panel);
36566 this.fireEvent("paneladded", this, panel);
36573 this.initPanelAsTab(panel);
36577 if(panel.background !== true){
36578 this.tabs.activate(panel.getEl().id);
36580 this.fireEvent("paneladded", this, panel);
36585 * Hides the tab for the specified panel.
36586 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36588 hidePanel : function(panel){
36589 if(this.tabs && (panel = this.getPanel(panel))){
36590 this.tabs.hideTab(panel.getEl().id);
36595 * Unhides the tab for a previously hidden panel.
36596 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36598 unhidePanel : function(panel){
36599 if(this.tabs && (panel = this.getPanel(panel))){
36600 this.tabs.unhideTab(panel.getEl().id);
36604 clearPanels : function(){
36605 while(this.panels.getCount() > 0){
36606 this.remove(this.panels.first());
36611 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36612 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36613 * @param {Boolean} preservePanel Overrides the config preservePanel option
36614 * @return {Roo.ContentPanel} The panel that was removed
36616 remove : function(panel, preservePanel)
36618 panel = this.getPanel(panel);
36623 this.fireEvent("beforeremove", this, panel, e);
36624 if(e.cancel === true){
36627 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36628 var panelId = panel.getId();
36629 this.panels.removeKey(panelId);
36631 document.body.appendChild(panel.getEl().dom);
36634 this.tabs.removeTab(panel.getEl().id);
36635 }else if (!preservePanel){
36636 this.bodyEl.dom.removeChild(panel.getEl().dom);
36638 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36639 var p = this.panels.first();
36640 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36641 tempEl.appendChild(p.getEl().dom);
36642 this.bodyEl.update("");
36643 this.bodyEl.dom.appendChild(p.getEl().dom);
36645 this.updateTitle(p.getTitle());
36647 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36648 this.setActivePanel(p);
36650 panel.setRegion(null);
36651 if(this.activePanel == panel){
36652 this.activePanel = null;
36654 if(this.config.autoDestroy !== false && preservePanel !== true){
36655 try{panel.destroy();}catch(e){}
36657 this.fireEvent("panelremoved", this, panel);
36662 * Returns the TabPanel component used by this region
36663 * @return {Roo.TabPanel}
36665 getTabs : function(){
36669 createTool : function(parentEl, className){
36670 var btn = Roo.DomHelper.append(parentEl, {
36672 cls: "x-layout-tools-button",
36675 cls: "roo-layout-tools-button-inner " + className,
36679 btn.addClassOnOver("roo-layout-tools-button-over");
36684 * Ext JS Library 1.1.1
36685 * Copyright(c) 2006-2007, Ext JS, LLC.
36687 * Originally Released Under LGPL - original licence link has changed is not relivant.
36690 * <script type="text/javascript">
36696 * @class Roo.SplitLayoutRegion
36697 * @extends Roo.LayoutRegion
36698 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36700 Roo.bootstrap.layout.Split = function(config){
36701 this.cursor = config.cursor;
36702 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36705 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36707 splitTip : "Drag to resize.",
36708 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36709 useSplitTips : false,
36711 applyConfig : function(config){
36712 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36715 onRender : function(ctr,pos) {
36717 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36718 if(!this.config.split){
36723 var splitEl = Roo.DomHelper.append(ctr.dom, {
36725 id: this.el.id + "-split",
36726 cls: "roo-layout-split roo-layout-split-"+this.position,
36729 /** The SplitBar for this region
36730 * @type Roo.SplitBar */
36731 // does not exist yet...
36732 Roo.log([this.position, this.orientation]);
36734 this.split = new Roo.bootstrap.SplitBar({
36735 dragElement : splitEl,
36736 resizingElement: this.el,
36737 orientation : this.orientation
36740 this.split.on("moved", this.onSplitMove, this);
36741 this.split.useShim = this.config.useShim === true;
36742 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36743 if(this.useSplitTips){
36744 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36746 //if(config.collapsible){
36747 // this.split.el.on("dblclick", this.collapse, this);
36750 if(typeof this.config.minSize != "undefined"){
36751 this.split.minSize = this.config.minSize;
36753 if(typeof this.config.maxSize != "undefined"){
36754 this.split.maxSize = this.config.maxSize;
36756 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36757 this.hideSplitter();
36762 getHMaxSize : function(){
36763 var cmax = this.config.maxSize || 10000;
36764 var center = this.mgr.getRegion("center");
36765 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36768 getVMaxSize : function(){
36769 var cmax = this.config.maxSize || 10000;
36770 var center = this.mgr.getRegion("center");
36771 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36774 onSplitMove : function(split, newSize){
36775 this.fireEvent("resized", this, newSize);
36779 * Returns the {@link Roo.SplitBar} for this region.
36780 * @return {Roo.SplitBar}
36782 getSplitBar : function(){
36787 this.hideSplitter();
36788 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36791 hideSplitter : function(){
36793 this.split.el.setLocation(-2000,-2000);
36794 this.split.el.hide();
36800 this.split.el.show();
36802 Roo.bootstrap.layout.Split.superclass.show.call(this);
36805 beforeSlide: function(){
36806 if(Roo.isGecko){// firefox overflow auto bug workaround
36807 this.bodyEl.clip();
36809 this.tabs.bodyEl.clip();
36811 if(this.activePanel){
36812 this.activePanel.getEl().clip();
36814 if(this.activePanel.beforeSlide){
36815 this.activePanel.beforeSlide();
36821 afterSlide : function(){
36822 if(Roo.isGecko){// firefox overflow auto bug workaround
36823 this.bodyEl.unclip();
36825 this.tabs.bodyEl.unclip();
36827 if(this.activePanel){
36828 this.activePanel.getEl().unclip();
36829 if(this.activePanel.afterSlide){
36830 this.activePanel.afterSlide();
36836 initAutoHide : function(){
36837 if(this.autoHide !== false){
36838 if(!this.autoHideHd){
36839 var st = new Roo.util.DelayedTask(this.slideIn, this);
36840 this.autoHideHd = {
36841 "mouseout": function(e){
36842 if(!e.within(this.el, true)){
36846 "mouseover" : function(e){
36852 this.el.on(this.autoHideHd);
36856 clearAutoHide : function(){
36857 if(this.autoHide !== false){
36858 this.el.un("mouseout", this.autoHideHd.mouseout);
36859 this.el.un("mouseover", this.autoHideHd.mouseover);
36863 clearMonitor : function(){
36864 Roo.get(document).un("click", this.slideInIf, this);
36867 // these names are backwards but not changed for compat
36868 slideOut : function(){
36869 if(this.isSlid || this.el.hasActiveFx()){
36872 this.isSlid = true;
36873 if(this.collapseBtn){
36874 this.collapseBtn.hide();
36876 this.closeBtnState = this.closeBtn.getStyle('display');
36877 this.closeBtn.hide();
36879 this.stickBtn.show();
36882 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36883 this.beforeSlide();
36884 this.el.setStyle("z-index", 10001);
36885 this.el.slideIn(this.getSlideAnchor(), {
36886 callback: function(){
36888 this.initAutoHide();
36889 Roo.get(document).on("click", this.slideInIf, this);
36890 this.fireEvent("slideshow", this);
36897 afterSlideIn : function(){
36898 this.clearAutoHide();
36899 this.isSlid = false;
36900 this.clearMonitor();
36901 this.el.setStyle("z-index", "");
36902 if(this.collapseBtn){
36903 this.collapseBtn.show();
36905 this.closeBtn.setStyle('display', this.closeBtnState);
36907 this.stickBtn.hide();
36909 this.fireEvent("slidehide", this);
36912 slideIn : function(cb){
36913 if(!this.isSlid || this.el.hasActiveFx()){
36917 this.isSlid = false;
36918 this.beforeSlide();
36919 this.el.slideOut(this.getSlideAnchor(), {
36920 callback: function(){
36921 this.el.setLeftTop(-10000, -10000);
36923 this.afterSlideIn();
36931 slideInIf : function(e){
36932 if(!e.within(this.el)){
36937 animateCollapse : function(){
36938 this.beforeSlide();
36939 this.el.setStyle("z-index", 20000);
36940 var anchor = this.getSlideAnchor();
36941 this.el.slideOut(anchor, {
36942 callback : function(){
36943 this.el.setStyle("z-index", "");
36944 this.collapsedEl.slideIn(anchor, {duration:.3});
36946 this.el.setLocation(-10000,-10000);
36948 this.fireEvent("collapsed", this);
36955 animateExpand : function(){
36956 this.beforeSlide();
36957 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36958 this.el.setStyle("z-index", 20000);
36959 this.collapsedEl.hide({
36962 this.el.slideIn(this.getSlideAnchor(), {
36963 callback : function(){
36964 this.el.setStyle("z-index", "");
36967 this.split.el.show();
36969 this.fireEvent("invalidated", this);
36970 this.fireEvent("expanded", this);
36998 getAnchor : function(){
36999 return this.anchors[this.position];
37002 getCollapseAnchor : function(){
37003 return this.canchors[this.position];
37006 getSlideAnchor : function(){
37007 return this.sanchors[this.position];
37010 getAlignAdj : function(){
37011 var cm = this.cmargins;
37012 switch(this.position){
37028 getExpandAdj : function(){
37029 var c = this.collapsedEl, cm = this.cmargins;
37030 switch(this.position){
37032 return [-(cm.right+c.getWidth()+cm.left), 0];
37035 return [cm.right+c.getWidth()+cm.left, 0];
37038 return [0, -(cm.top+cm.bottom+c.getHeight())];
37041 return [0, cm.top+cm.bottom+c.getHeight()];
37047 * Ext JS Library 1.1.1
37048 * Copyright(c) 2006-2007, Ext JS, LLC.
37050 * Originally Released Under LGPL - original licence link has changed is not relivant.
37053 * <script type="text/javascript">
37056 * These classes are private internal classes
37058 Roo.bootstrap.layout.Center = function(config){
37059 config.region = "center";
37060 Roo.bootstrap.layout.Region.call(this, config);
37061 this.visible = true;
37062 this.minWidth = config.minWidth || 20;
37063 this.minHeight = config.minHeight || 20;
37066 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37068 // center panel can't be hidden
37072 // center panel can't be hidden
37075 getMinWidth: function(){
37076 return this.minWidth;
37079 getMinHeight: function(){
37080 return this.minHeight;
37094 Roo.bootstrap.layout.North = function(config)
37096 config.region = 'north';
37097 config.cursor = 'n-resize';
37099 Roo.bootstrap.layout.Split.call(this, config);
37103 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37104 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37105 this.split.el.addClass("roo-layout-split-v");
37107 var size = config.initialSize || config.height;
37108 if(typeof size != "undefined"){
37109 this.el.setHeight(size);
37112 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37114 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37118 getBox : function(){
37119 if(this.collapsed){
37120 return this.collapsedEl.getBox();
37122 var box = this.el.getBox();
37124 box.height += this.split.el.getHeight();
37129 updateBox : function(box){
37130 if(this.split && !this.collapsed){
37131 box.height -= this.split.el.getHeight();
37132 this.split.el.setLeft(box.x);
37133 this.split.el.setTop(box.y+box.height);
37134 this.split.el.setWidth(box.width);
37136 if(this.collapsed){
37137 this.updateBody(box.width, null);
37139 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37147 Roo.bootstrap.layout.South = function(config){
37148 config.region = 'south';
37149 config.cursor = 's-resize';
37150 Roo.bootstrap.layout.Split.call(this, config);
37152 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37153 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37154 this.split.el.addClass("roo-layout-split-v");
37156 var size = config.initialSize || config.height;
37157 if(typeof size != "undefined"){
37158 this.el.setHeight(size);
37162 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37163 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37164 getBox : function(){
37165 if(this.collapsed){
37166 return this.collapsedEl.getBox();
37168 var box = this.el.getBox();
37170 var sh = this.split.el.getHeight();
37177 updateBox : function(box){
37178 if(this.split && !this.collapsed){
37179 var sh = this.split.el.getHeight();
37182 this.split.el.setLeft(box.x);
37183 this.split.el.setTop(box.y-sh);
37184 this.split.el.setWidth(box.width);
37186 if(this.collapsed){
37187 this.updateBody(box.width, null);
37189 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37193 Roo.bootstrap.layout.East = function(config){
37194 config.region = "east";
37195 config.cursor = "e-resize";
37196 Roo.bootstrap.layout.Split.call(this, config);
37198 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37199 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37200 this.split.el.addClass("roo-layout-split-h");
37202 var size = config.initialSize || config.width;
37203 if(typeof size != "undefined"){
37204 this.el.setWidth(size);
37207 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37208 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37209 getBox : function(){
37210 if(this.collapsed){
37211 return this.collapsedEl.getBox();
37213 var box = this.el.getBox();
37215 var sw = this.split.el.getWidth();
37222 updateBox : function(box){
37223 if(this.split && !this.collapsed){
37224 var sw = this.split.el.getWidth();
37226 this.split.el.setLeft(box.x);
37227 this.split.el.setTop(box.y);
37228 this.split.el.setHeight(box.height);
37231 if(this.collapsed){
37232 this.updateBody(null, box.height);
37234 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37238 Roo.bootstrap.layout.West = function(config){
37239 config.region = "west";
37240 config.cursor = "w-resize";
37242 Roo.bootstrap.layout.Split.call(this, config);
37244 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37245 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37246 this.split.el.addClass("roo-layout-split-h");
37250 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37251 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37253 onRender: function(ctr, pos)
37255 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37256 var size = this.config.initialSize || this.config.width;
37257 if(typeof size != "undefined"){
37258 this.el.setWidth(size);
37262 getBox : function(){
37263 if(this.collapsed){
37264 return this.collapsedEl.getBox();
37266 var box = this.el.getBox();
37268 box.width += this.split.el.getWidth();
37273 updateBox : function(box){
37274 if(this.split && !this.collapsed){
37275 var sw = this.split.el.getWidth();
37277 this.split.el.setLeft(box.x+box.width);
37278 this.split.el.setTop(box.y);
37279 this.split.el.setHeight(box.height);
37281 if(this.collapsed){
37282 this.updateBody(null, box.height);
37284 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37286 });Roo.namespace("Roo.bootstrap.panel");/*
37288 * Ext JS Library 1.1.1
37289 * Copyright(c) 2006-2007, Ext JS, LLC.
37291 * Originally Released Under LGPL - original licence link has changed is not relivant.
37294 * <script type="text/javascript">
37297 * @class Roo.ContentPanel
37298 * @extends Roo.util.Observable
37299 * A basic ContentPanel element.
37300 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37301 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37302 * @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
37303 * @cfg {Boolean} closable True if the panel can be closed/removed
37304 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37305 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37306 * @cfg {Toolbar} toolbar A toolbar for this panel
37307 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37308 * @cfg {String} title The title for this panel
37309 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37310 * @cfg {String} url Calls {@link #setUrl} with this value
37311 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37312 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37313 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37314 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37315 * @cfg {Boolean} badges render the badges
37318 * Create a new ContentPanel.
37319 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37320 * @param {String/Object} config A string to set only the title or a config object
37321 * @param {String} content (optional) Set the HTML content for this panel
37322 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37324 Roo.bootstrap.panel.Content = function( config){
37326 this.tpl = config.tpl || false;
37328 var el = config.el;
37329 var content = config.content;
37331 if(config.autoCreate){ // xtype is available if this is called from factory
37334 this.el = Roo.get(el);
37335 if(!this.el && config && config.autoCreate){
37336 if(typeof config.autoCreate == "object"){
37337 if(!config.autoCreate.id){
37338 config.autoCreate.id = config.id||el;
37340 this.el = Roo.DomHelper.append(document.body,
37341 config.autoCreate, true);
37343 var elcfg = { tag: "div",
37344 cls: "roo-layout-inactive-content",
37348 elcfg.html = config.html;
37352 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37355 this.closable = false;
37356 this.loaded = false;
37357 this.active = false;
37360 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37362 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37364 this.wrapEl = this.el; //this.el.wrap();
37366 if (config.toolbar.items) {
37367 ti = config.toolbar.items ;
37368 delete config.toolbar.items ;
37372 this.toolbar.render(this.wrapEl, 'before');
37373 for(var i =0;i < ti.length;i++) {
37374 // Roo.log(['add child', items[i]]);
37375 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37377 this.toolbar.items = nitems;
37378 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37379 delete config.toolbar;
37383 // xtype created footer. - not sure if will work as we normally have to render first..
37384 if (this.footer && !this.footer.el && this.footer.xtype) {
37385 if (!this.wrapEl) {
37386 this.wrapEl = this.el.wrap();
37389 this.footer.container = this.wrapEl.createChild();
37391 this.footer = Roo.factory(this.footer, Roo);
37396 if(typeof config == "string"){
37397 this.title = config;
37399 Roo.apply(this, config);
37403 this.resizeEl = Roo.get(this.resizeEl, true);
37405 this.resizeEl = this.el;
37407 // handle view.xtype
37415 * Fires when this panel is activated.
37416 * @param {Roo.ContentPanel} this
37420 * @event deactivate
37421 * Fires when this panel is activated.
37422 * @param {Roo.ContentPanel} this
37424 "deactivate" : true,
37428 * Fires when this panel is resized if fitToFrame is true.
37429 * @param {Roo.ContentPanel} this
37430 * @param {Number} width The width after any component adjustments
37431 * @param {Number} height The height after any component adjustments
37437 * Fires when this tab is created
37438 * @param {Roo.ContentPanel} this
37449 if(this.autoScroll){
37450 this.resizeEl.setStyle("overflow", "auto");
37452 // fix randome scrolling
37453 //this.el.on('scroll', function() {
37454 // Roo.log('fix random scolling');
37455 // this.scrollTo('top',0);
37458 content = content || this.content;
37460 this.setContent(content);
37462 if(config && config.url){
37463 this.setUrl(this.url, this.params, this.loadOnce);
37468 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37470 if (this.view && typeof(this.view.xtype) != 'undefined') {
37471 this.view.el = this.el.appendChild(document.createElement("div"));
37472 this.view = Roo.factory(this.view);
37473 this.view.render && this.view.render(false, '');
37477 this.fireEvent('render', this);
37480 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37484 setRegion : function(region){
37485 this.region = region;
37486 this.setActiveClass(region && !this.background);
37490 setActiveClass: function(state)
37493 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37494 this.el.setStyle('position','relative');
37496 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37497 this.el.setStyle('position', 'absolute');
37502 * Returns the toolbar for this Panel if one was configured.
37503 * @return {Roo.Toolbar}
37505 getToolbar : function(){
37506 return this.toolbar;
37509 setActiveState : function(active)
37511 this.active = active;
37512 this.setActiveClass(active);
37514 if(this.fireEvent("deactivate", this) === false){
37519 this.fireEvent("activate", this);
37523 * Updates this panel's element
37524 * @param {String} content The new content
37525 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37527 setContent : function(content, loadScripts){
37528 this.el.update(content, loadScripts);
37531 ignoreResize : function(w, h){
37532 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37535 this.lastSize = {width: w, height: h};
37540 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37541 * @return {Roo.UpdateManager} The UpdateManager
37543 getUpdateManager : function(){
37544 return this.el.getUpdateManager();
37547 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37548 * @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:
37551 url: "your-url.php",
37552 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37553 callback: yourFunction,
37554 scope: yourObject, //(optional scope)
37557 text: "Loading...",
37562 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37563 * 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.
37564 * @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}
37565 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37566 * @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.
37567 * @return {Roo.ContentPanel} this
37570 var um = this.el.getUpdateManager();
37571 um.update.apply(um, arguments);
37577 * 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.
37578 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37579 * @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)
37580 * @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)
37581 * @return {Roo.UpdateManager} The UpdateManager
37583 setUrl : function(url, params, loadOnce){
37584 if(this.refreshDelegate){
37585 this.removeListener("activate", this.refreshDelegate);
37587 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37588 this.on("activate", this.refreshDelegate);
37589 return this.el.getUpdateManager();
37592 _handleRefresh : function(url, params, loadOnce){
37593 if(!loadOnce || !this.loaded){
37594 var updater = this.el.getUpdateManager();
37595 updater.update(url, params, this._setLoaded.createDelegate(this));
37599 _setLoaded : function(){
37600 this.loaded = true;
37604 * Returns this panel's id
37607 getId : function(){
37612 * Returns this panel's element - used by regiosn to add.
37613 * @return {Roo.Element}
37615 getEl : function(){
37616 return this.wrapEl || this.el;
37621 adjustForComponents : function(width, height)
37623 //Roo.log('adjustForComponents ');
37624 if(this.resizeEl != this.el){
37625 width -= this.el.getFrameWidth('lr');
37626 height -= this.el.getFrameWidth('tb');
37629 var te = this.toolbar.getEl();
37630 te.setWidth(width);
37631 height -= te.getHeight();
37634 var te = this.footer.getEl();
37635 te.setWidth(width);
37636 height -= te.getHeight();
37640 if(this.adjustments){
37641 width += this.adjustments[0];
37642 height += this.adjustments[1];
37644 return {"width": width, "height": height};
37647 setSize : function(width, height){
37648 if(this.fitToFrame && !this.ignoreResize(width, height)){
37649 if(this.fitContainer && this.resizeEl != this.el){
37650 this.el.setSize(width, height);
37652 var size = this.adjustForComponents(width, height);
37653 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37654 this.fireEvent('resize', this, size.width, size.height);
37659 * Returns this panel's title
37662 getTitle : function(){
37664 if (typeof(this.title) != 'object') {
37669 for (var k in this.title) {
37670 if (!this.title.hasOwnProperty(k)) {
37674 if (k.indexOf('-') >= 0) {
37675 var s = k.split('-');
37676 for (var i = 0; i<s.length; i++) {
37677 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37680 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37687 * Set this panel's title
37688 * @param {String} title
37690 setTitle : function(title){
37691 this.title = title;
37693 this.region.updatePanelTitle(this, title);
37698 * Returns true is this panel was configured to be closable
37699 * @return {Boolean}
37701 isClosable : function(){
37702 return this.closable;
37705 beforeSlide : function(){
37707 this.resizeEl.clip();
37710 afterSlide : function(){
37712 this.resizeEl.unclip();
37716 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37717 * Will fail silently if the {@link #setUrl} method has not been called.
37718 * This does not activate the panel, just updates its content.
37720 refresh : function(){
37721 if(this.refreshDelegate){
37722 this.loaded = false;
37723 this.refreshDelegate();
37728 * Destroys this panel
37730 destroy : function(){
37731 this.el.removeAllListeners();
37732 var tempEl = document.createElement("span");
37733 tempEl.appendChild(this.el.dom);
37734 tempEl.innerHTML = "";
37740 * form - if the content panel contains a form - this is a reference to it.
37741 * @type {Roo.form.Form}
37745 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37746 * This contains a reference to it.
37752 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37762 * @param {Object} cfg Xtype definition of item to add.
37766 getChildContainer: function () {
37767 return this.getEl();
37772 var ret = new Roo.factory(cfg);
37777 if (cfg.xtype.match(/^Form$/)) {
37780 //if (this.footer) {
37781 // el = this.footer.container.insertSibling(false, 'before');
37783 el = this.el.createChild();
37786 this.form = new Roo.form.Form(cfg);
37789 if ( this.form.allItems.length) {
37790 this.form.render(el.dom);
37794 // should only have one of theses..
37795 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37796 // views.. should not be just added - used named prop 'view''
37798 cfg.el = this.el.appendChild(document.createElement("div"));
37801 var ret = new Roo.factory(cfg);
37803 ret.render && ret.render(false, ''); // render blank..
37813 * @class Roo.bootstrap.panel.Grid
37814 * @extends Roo.bootstrap.panel.Content
37816 * Create a new GridPanel.
37817 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37818 * @param {Object} config A the config object
37824 Roo.bootstrap.panel.Grid = function(config)
37828 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37829 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37831 config.el = this.wrapper;
37832 //this.el = this.wrapper;
37834 if (config.container) {
37835 // ctor'ed from a Border/panel.grid
37838 this.wrapper.setStyle("overflow", "hidden");
37839 this.wrapper.addClass('roo-grid-container');
37844 if(config.toolbar){
37845 var tool_el = this.wrapper.createChild();
37846 this.toolbar = Roo.factory(config.toolbar);
37848 if (config.toolbar.items) {
37849 ti = config.toolbar.items ;
37850 delete config.toolbar.items ;
37854 this.toolbar.render(tool_el);
37855 for(var i =0;i < ti.length;i++) {
37856 // Roo.log(['add child', items[i]]);
37857 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37859 this.toolbar.items = nitems;
37861 delete config.toolbar;
37864 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37865 config.grid.scrollBody = true;;
37866 config.grid.monitorWindowResize = false; // turn off autosizing
37867 config.grid.autoHeight = false;
37868 config.grid.autoWidth = false;
37870 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37872 if (config.background) {
37873 // render grid on panel activation (if panel background)
37874 this.on('activate', function(gp) {
37875 if (!gp.grid.rendered) {
37876 gp.grid.render(this.wrapper);
37877 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37882 this.grid.render(this.wrapper);
37883 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37886 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37887 // ??? needed ??? config.el = this.wrapper;
37892 // xtype created footer. - not sure if will work as we normally have to render first..
37893 if (this.footer && !this.footer.el && this.footer.xtype) {
37895 var ctr = this.grid.getView().getFooterPanel(true);
37896 this.footer.dataSource = this.grid.dataSource;
37897 this.footer = Roo.factory(this.footer, Roo);
37898 this.footer.render(ctr);
37908 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37909 getId : function(){
37910 return this.grid.id;
37914 * Returns the grid for this panel
37915 * @return {Roo.bootstrap.Table}
37917 getGrid : function(){
37921 setSize : function(width, height){
37922 if(!this.ignoreResize(width, height)){
37923 var grid = this.grid;
37924 var size = this.adjustForComponents(width, height);
37925 var gridel = grid.getGridEl();
37926 gridel.setSize(size.width, size.height);
37928 var thd = grid.getGridEl().select('thead',true).first();
37929 var tbd = grid.getGridEl().select('tbody', true).first();
37931 tbd.setSize(width, height - thd.getHeight());
37940 beforeSlide : function(){
37941 this.grid.getView().scroller.clip();
37944 afterSlide : function(){
37945 this.grid.getView().scroller.unclip();
37948 destroy : function(){
37949 this.grid.destroy();
37951 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37956 * @class Roo.bootstrap.panel.Nest
37957 * @extends Roo.bootstrap.panel.Content
37959 * Create a new Panel, that can contain a layout.Border.
37962 * @param {Roo.BorderLayout} layout The layout for this panel
37963 * @param {String/Object} config A string to set only the title or a config object
37965 Roo.bootstrap.panel.Nest = function(config)
37967 // construct with only one argument..
37968 /* FIXME - implement nicer consturctors
37969 if (layout.layout) {
37971 layout = config.layout;
37972 delete config.layout;
37974 if (layout.xtype && !layout.getEl) {
37975 // then layout needs constructing..
37976 layout = Roo.factory(layout, Roo);
37980 config.el = config.layout.getEl();
37982 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37984 config.layout.monitorWindowResize = false; // turn off autosizing
37985 this.layout = config.layout;
37986 this.layout.getEl().addClass("roo-layout-nested-layout");
37987 this.layout.parent = this;
37994 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37996 setSize : function(width, height){
37997 if(!this.ignoreResize(width, height)){
37998 var size = this.adjustForComponents(width, height);
37999 var el = this.layout.getEl();
38000 if (size.height < 1) {
38001 el.setWidth(size.width);
38003 el.setSize(size.width, size.height);
38005 var touch = el.dom.offsetWidth;
38006 this.layout.layout();
38007 // ie requires a double layout on the first pass
38008 if(Roo.isIE && !this.initialized){
38009 this.initialized = true;
38010 this.layout.layout();
38015 // activate all subpanels if not currently active..
38017 setActiveState : function(active){
38018 this.active = active;
38019 this.setActiveClass(active);
38022 this.fireEvent("deactivate", this);
38026 this.fireEvent("activate", this);
38027 // not sure if this should happen before or after..
38028 if (!this.layout) {
38029 return; // should not happen..
38032 for (var r in this.layout.regions) {
38033 reg = this.layout.getRegion(r);
38034 if (reg.getActivePanel()) {
38035 //reg.showPanel(reg.getActivePanel()); // force it to activate..
38036 reg.setActivePanel(reg.getActivePanel());
38039 if (!reg.panels.length) {
38042 reg.showPanel(reg.getPanel(0));
38051 * Returns the nested BorderLayout for this panel
38052 * @return {Roo.BorderLayout}
38054 getLayout : function(){
38055 return this.layout;
38059 * Adds a xtype elements to the layout of the nested panel
38063 xtype : 'ContentPanel',
38070 xtype : 'NestedLayoutPanel',
38076 items : [ ... list of content panels or nested layout panels.. ]
38080 * @param {Object} cfg Xtype definition of item to add.
38082 addxtype : function(cfg) {
38083 return this.layout.addxtype(cfg);
38088 * Ext JS Library 1.1.1
38089 * Copyright(c) 2006-2007, Ext JS, LLC.
38091 * Originally Released Under LGPL - original licence link has changed is not relivant.
38094 * <script type="text/javascript">
38097 * @class Roo.TabPanel
38098 * @extends Roo.util.Observable
38099 * A lightweight tab container.
38103 // basic tabs 1, built from existing content
38104 var tabs = new Roo.TabPanel("tabs1");
38105 tabs.addTab("script", "View Script");
38106 tabs.addTab("markup", "View Markup");
38107 tabs.activate("script");
38109 // more advanced tabs, built from javascript
38110 var jtabs = new Roo.TabPanel("jtabs");
38111 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38113 // set up the UpdateManager
38114 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38115 var updater = tab2.getUpdateManager();
38116 updater.setDefaultUrl("ajax1.htm");
38117 tab2.on('activate', updater.refresh, updater, true);
38119 // Use setUrl for Ajax loading
38120 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38121 tab3.setUrl("ajax2.htm", null, true);
38124 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38127 jtabs.activate("jtabs-1");
38130 * Create a new TabPanel.
38131 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38132 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38134 Roo.bootstrap.panel.Tabs = function(config){
38136 * The container element for this TabPanel.
38137 * @type Roo.Element
38139 this.el = Roo.get(config.el);
38142 if(typeof config == "boolean"){
38143 this.tabPosition = config ? "bottom" : "top";
38145 Roo.apply(this, config);
38149 if(this.tabPosition == "bottom"){
38150 // if tabs are at the bottom = create the body first.
38151 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38152 this.el.addClass("roo-tabs-bottom");
38154 // next create the tabs holders
38156 if (this.tabPosition == "west"){
38158 var reg = this.region; // fake it..
38160 if (!reg.mgr.parent) {
38163 reg = reg.mgr.parent.region;
38165 Roo.log("got nest?");
38167 if (reg.mgr.getRegion('west')) {
38168 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38169 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38170 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38171 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38172 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38180 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38181 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38182 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38183 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38188 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38191 // finally - if tabs are at the top, then create the body last..
38192 if(this.tabPosition != "bottom"){
38193 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38194 * @type Roo.Element
38196 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38197 this.el.addClass("roo-tabs-top");
38201 this.bodyEl.setStyle("position", "relative");
38203 this.active = null;
38204 this.activateDelegate = this.activate.createDelegate(this);
38209 * Fires when the active tab changes
38210 * @param {Roo.TabPanel} this
38211 * @param {Roo.TabPanelItem} activePanel The new active tab
38215 * @event beforetabchange
38216 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38217 * @param {Roo.TabPanel} this
38218 * @param {Object} e Set cancel to true on this object to cancel the tab change
38219 * @param {Roo.TabPanelItem} tab The tab being changed to
38221 "beforetabchange" : true
38224 Roo.EventManager.onWindowResize(this.onResize, this);
38225 this.cpad = this.el.getPadding("lr");
38226 this.hiddenCount = 0;
38229 // toolbar on the tabbar support...
38230 if (this.toolbar) {
38231 alert("no toolbar support yet");
38232 this.toolbar = false;
38234 var tcfg = this.toolbar;
38235 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38236 this.toolbar = new Roo.Toolbar(tcfg);
38237 if (Roo.isSafari) {
38238 var tbl = tcfg.container.child('table', true);
38239 tbl.setAttribute('width', '100%');
38247 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38250 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38252 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38254 tabPosition : "top",
38256 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38258 currentTabWidth : 0,
38260 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38264 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38268 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38270 preferredTabWidth : 175,
38272 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38274 resizeTabs : false,
38276 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38278 monitorResize : true,
38280 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38282 toolbar : false, // set by caller..
38284 region : false, /// set by caller
38286 disableTooltips : true, // not used yet...
38289 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38290 * @param {String} id The id of the div to use <b>or create</b>
38291 * @param {String} text The text for the tab
38292 * @param {String} content (optional) Content to put in the TabPanelItem body
38293 * @param {Boolean} closable (optional) True to create a close icon on the tab
38294 * @return {Roo.TabPanelItem} The created TabPanelItem
38296 addTab : function(id, text, content, closable, tpl)
38298 var item = new Roo.bootstrap.panel.TabItem({
38302 closable : closable,
38305 this.addTabItem(item);
38307 item.setContent(content);
38313 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38314 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38315 * @return {Roo.TabPanelItem}
38317 getTab : function(id){
38318 return this.items[id];
38322 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38323 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38325 hideTab : function(id){
38326 var t = this.items[id];
38329 this.hiddenCount++;
38330 this.autoSizeTabs();
38335 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38336 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38338 unhideTab : function(id){
38339 var t = this.items[id];
38341 t.setHidden(false);
38342 this.hiddenCount--;
38343 this.autoSizeTabs();
38348 * Adds an existing {@link Roo.TabPanelItem}.
38349 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38351 addTabItem : function(item)
38353 this.items[item.id] = item;
38354 this.items.push(item);
38355 this.autoSizeTabs();
38356 // if(this.resizeTabs){
38357 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38358 // this.autoSizeTabs();
38360 // item.autoSize();
38365 * Removes a {@link Roo.TabPanelItem}.
38366 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38368 removeTab : function(id){
38369 var items = this.items;
38370 var tab = items[id];
38371 if(!tab) { return; }
38372 var index = items.indexOf(tab);
38373 if(this.active == tab && items.length > 1){
38374 var newTab = this.getNextAvailable(index);
38379 this.stripEl.dom.removeChild(tab.pnode.dom);
38380 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38381 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38383 items.splice(index, 1);
38384 delete this.items[tab.id];
38385 tab.fireEvent("close", tab);
38386 tab.purgeListeners();
38387 this.autoSizeTabs();
38390 getNextAvailable : function(start){
38391 var items = this.items;
38393 // look for a next tab that will slide over to
38394 // replace the one being removed
38395 while(index < items.length){
38396 var item = items[++index];
38397 if(item && !item.isHidden()){
38401 // if one isn't found select the previous tab (on the left)
38404 var item = items[--index];
38405 if(item && !item.isHidden()){
38413 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38414 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38416 disableTab : function(id){
38417 var tab = this.items[id];
38418 if(tab && this.active != tab){
38424 * Enables a {@link Roo.TabPanelItem} that is disabled.
38425 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38427 enableTab : function(id){
38428 var tab = this.items[id];
38433 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38434 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38435 * @return {Roo.TabPanelItem} The TabPanelItem.
38437 activate : function(id)
38439 //Roo.log('activite:' + id);
38441 var tab = this.items[id];
38445 if(tab == this.active || tab.disabled){
38449 this.fireEvent("beforetabchange", this, e, tab);
38450 if(e.cancel !== true && !tab.disabled){
38452 this.active.hide();
38454 this.active = this.items[id];
38455 this.active.show();
38456 this.fireEvent("tabchange", this, this.active);
38462 * Gets the active {@link Roo.TabPanelItem}.
38463 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38465 getActiveTab : function(){
38466 return this.active;
38470 * Updates the tab body element to fit the height of the container element
38471 * for overflow scrolling
38472 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38474 syncHeight : function(targetHeight){
38475 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38476 var bm = this.bodyEl.getMargins();
38477 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38478 this.bodyEl.setHeight(newHeight);
38482 onResize : function(){
38483 if(this.monitorResize){
38484 this.autoSizeTabs();
38489 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38491 beginUpdate : function(){
38492 this.updating = true;
38496 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38498 endUpdate : function(){
38499 this.updating = false;
38500 this.autoSizeTabs();
38504 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38506 autoSizeTabs : function()
38508 var count = this.items.length;
38509 var vcount = count - this.hiddenCount;
38512 this.stripEl.hide();
38514 this.stripEl.show();
38517 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38522 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38523 var availWidth = Math.floor(w / vcount);
38524 var b = this.stripBody;
38525 if(b.getWidth() > w){
38526 var tabs = this.items;
38527 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38528 if(availWidth < this.minTabWidth){
38529 /*if(!this.sleft){ // incomplete scrolling code
38530 this.createScrollButtons();
38533 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38536 if(this.currentTabWidth < this.preferredTabWidth){
38537 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38543 * Returns the number of tabs in this TabPanel.
38546 getCount : function(){
38547 return this.items.length;
38551 * Resizes all the tabs to the passed width
38552 * @param {Number} The new width
38554 setTabWidth : function(width){
38555 this.currentTabWidth = width;
38556 for(var i = 0, len = this.items.length; i < len; i++) {
38557 if(!this.items[i].isHidden()) {
38558 this.items[i].setWidth(width);
38564 * Destroys this TabPanel
38565 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38567 destroy : function(removeEl){
38568 Roo.EventManager.removeResizeListener(this.onResize, this);
38569 for(var i = 0, len = this.items.length; i < len; i++){
38570 this.items[i].purgeListeners();
38572 if(removeEl === true){
38573 this.el.update("");
38578 createStrip : function(container)
38580 var strip = document.createElement("nav");
38581 strip.className = Roo.bootstrap.version == 4 ?
38582 "navbar-light bg-light" :
38583 "navbar navbar-default"; //"x-tabs-wrap";
38584 container.appendChild(strip);
38588 createStripList : function(strip)
38590 // div wrapper for retard IE
38591 // returns the "tr" element.
38592 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38593 //'<div class="x-tabs-strip-wrap">'+
38594 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38595 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38596 return strip.firstChild; //.firstChild.firstChild.firstChild;
38598 createBody : function(container)
38600 var body = document.createElement("div");
38601 Roo.id(body, "tab-body");
38602 //Roo.fly(body).addClass("x-tabs-body");
38603 Roo.fly(body).addClass("tab-content");
38604 container.appendChild(body);
38607 createItemBody :function(bodyEl, id){
38608 var body = Roo.getDom(id);
38610 body = document.createElement("div");
38613 //Roo.fly(body).addClass("x-tabs-item-body");
38614 Roo.fly(body).addClass("tab-pane");
38615 bodyEl.insertBefore(body, bodyEl.firstChild);
38619 createStripElements : function(stripEl, text, closable, tpl)
38621 var td = document.createElement("li"); // was td..
38622 td.className = 'nav-item';
38624 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38627 stripEl.appendChild(td);
38629 td.className = "x-tabs-closable";
38630 if(!this.closeTpl){
38631 this.closeTpl = new Roo.Template(
38632 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38633 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38634 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38637 var el = this.closeTpl.overwrite(td, {"text": text});
38638 var close = el.getElementsByTagName("div")[0];
38639 var inner = el.getElementsByTagName("em")[0];
38640 return {"el": el, "close": close, "inner": inner};
38643 // not sure what this is..
38644 // if(!this.tabTpl){
38645 //this.tabTpl = new Roo.Template(
38646 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38647 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38649 // this.tabTpl = new Roo.Template(
38650 // '<a href="#">' +
38651 // '<span unselectable="on"' +
38652 // (this.disableTooltips ? '' : ' title="{text}"') +
38653 // ' >{text}</span></a>'
38659 var template = tpl || this.tabTpl || false;
38662 template = new Roo.Template(
38663 Roo.bootstrap.version == 4 ?
38665 '<a class="nav-link" href="#" unselectable="on"' +
38666 (this.disableTooltips ? '' : ' title="{text}"') +
38669 '<a class="nav-link" href="#">' +
38670 '<span unselectable="on"' +
38671 (this.disableTooltips ? '' : ' title="{text}"') +
38672 ' >{text}</span></a>'
38677 switch (typeof(template)) {
38681 template = new Roo.Template(template);
38687 var el = template.overwrite(td, {"text": text});
38689 var inner = el.getElementsByTagName("span")[0];
38691 return {"el": el, "inner": inner};
38699 * @class Roo.TabPanelItem
38700 * @extends Roo.util.Observable
38701 * Represents an individual item (tab plus body) in a TabPanel.
38702 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38703 * @param {String} id The id of this TabPanelItem
38704 * @param {String} text The text for the tab of this TabPanelItem
38705 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38707 Roo.bootstrap.panel.TabItem = function(config){
38709 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38710 * @type Roo.TabPanel
38712 this.tabPanel = config.panel;
38714 * The id for this TabPanelItem
38717 this.id = config.id;
38719 this.disabled = false;
38721 this.text = config.text;
38723 this.loaded = false;
38724 this.closable = config.closable;
38727 * The body element for this TabPanelItem.
38728 * @type Roo.Element
38730 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38731 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38732 this.bodyEl.setStyle("display", "block");
38733 this.bodyEl.setStyle("zoom", "1");
38734 //this.hideAction();
38736 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38738 this.el = Roo.get(els.el);
38739 this.inner = Roo.get(els.inner, true);
38740 this.textEl = Roo.bootstrap.version == 4 ?
38741 this.el : Roo.get(this.el.dom.firstChild, true);
38743 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38744 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38747 // this.el.on("mousedown", this.onTabMouseDown, this);
38748 this.el.on("click", this.onTabClick, this);
38750 if(config.closable){
38751 var c = Roo.get(els.close, true);
38752 c.dom.title = this.closeText;
38753 c.addClassOnOver("close-over");
38754 c.on("click", this.closeClick, this);
38760 * Fires when this tab becomes the active tab.
38761 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38762 * @param {Roo.TabPanelItem} this
38766 * @event beforeclose
38767 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38768 * @param {Roo.TabPanelItem} this
38769 * @param {Object} e Set cancel to true on this object to cancel the close.
38771 "beforeclose": true,
38774 * Fires when this tab is closed.
38775 * @param {Roo.TabPanelItem} this
38779 * @event deactivate
38780 * Fires when this tab is no longer the active tab.
38781 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38782 * @param {Roo.TabPanelItem} this
38784 "deactivate" : true
38786 this.hidden = false;
38788 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38791 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38793 purgeListeners : function(){
38794 Roo.util.Observable.prototype.purgeListeners.call(this);
38795 this.el.removeAllListeners();
38798 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38801 this.status_node.addClass("active");
38804 this.tabPanel.stripWrap.repaint();
38806 this.fireEvent("activate", this.tabPanel, this);
38810 * Returns true if this tab is the active tab.
38811 * @return {Boolean}
38813 isActive : function(){
38814 return this.tabPanel.getActiveTab() == this;
38818 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38821 this.status_node.removeClass("active");
38823 this.fireEvent("deactivate", this.tabPanel, this);
38826 hideAction : function(){
38827 this.bodyEl.hide();
38828 this.bodyEl.setStyle("position", "absolute");
38829 this.bodyEl.setLeft("-20000px");
38830 this.bodyEl.setTop("-20000px");
38833 showAction : function(){
38834 this.bodyEl.setStyle("position", "relative");
38835 this.bodyEl.setTop("");
38836 this.bodyEl.setLeft("");
38837 this.bodyEl.show();
38841 * Set the tooltip for the tab.
38842 * @param {String} tooltip The tab's tooltip
38844 setTooltip : function(text){
38845 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38846 this.textEl.dom.qtip = text;
38847 this.textEl.dom.removeAttribute('title');
38849 this.textEl.dom.title = text;
38853 onTabClick : function(e){
38854 e.preventDefault();
38855 this.tabPanel.activate(this.id);
38858 onTabMouseDown : function(e){
38859 e.preventDefault();
38860 this.tabPanel.activate(this.id);
38863 getWidth : function(){
38864 return this.inner.getWidth();
38867 setWidth : function(width){
38868 var iwidth = width - this.linode.getPadding("lr");
38869 this.inner.setWidth(iwidth);
38870 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38871 this.linode.setWidth(width);
38875 * Show or hide the tab
38876 * @param {Boolean} hidden True to hide or false to show.
38878 setHidden : function(hidden){
38879 this.hidden = hidden;
38880 this.linode.setStyle("display", hidden ? "none" : "");
38884 * Returns true if this tab is "hidden"
38885 * @return {Boolean}
38887 isHidden : function(){
38888 return this.hidden;
38892 * Returns the text for this tab
38895 getText : function(){
38899 autoSize : function(){
38900 //this.el.beginMeasure();
38901 this.textEl.setWidth(1);
38903 * #2804 [new] Tabs in Roojs
38904 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38906 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38907 //this.el.endMeasure();
38911 * Sets the text for the tab (Note: this also sets the tooltip text)
38912 * @param {String} text The tab's text and tooltip
38914 setText : function(text){
38916 this.textEl.update(text);
38917 this.setTooltip(text);
38918 //if(!this.tabPanel.resizeTabs){
38919 // this.autoSize();
38923 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38925 activate : function(){
38926 this.tabPanel.activate(this.id);
38930 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38932 disable : function(){
38933 if(this.tabPanel.active != this){
38934 this.disabled = true;
38935 this.status_node.addClass("disabled");
38940 * Enables this TabPanelItem if it was previously disabled.
38942 enable : function(){
38943 this.disabled = false;
38944 this.status_node.removeClass("disabled");
38948 * Sets the content for this TabPanelItem.
38949 * @param {String} content The content
38950 * @param {Boolean} loadScripts true to look for and load scripts
38952 setContent : function(content, loadScripts){
38953 this.bodyEl.update(content, loadScripts);
38957 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38958 * @return {Roo.UpdateManager} The UpdateManager
38960 getUpdateManager : function(){
38961 return this.bodyEl.getUpdateManager();
38965 * Set a URL to be used to load the content for this TabPanelItem.
38966 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38967 * @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)
38968 * @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)
38969 * @return {Roo.UpdateManager} The UpdateManager
38971 setUrl : function(url, params, loadOnce){
38972 if(this.refreshDelegate){
38973 this.un('activate', this.refreshDelegate);
38975 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38976 this.on("activate", this.refreshDelegate);
38977 return this.bodyEl.getUpdateManager();
38981 _handleRefresh : function(url, params, loadOnce){
38982 if(!loadOnce || !this.loaded){
38983 var updater = this.bodyEl.getUpdateManager();
38984 updater.update(url, params, this._setLoaded.createDelegate(this));
38989 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38990 * Will fail silently if the setUrl method has not been called.
38991 * This does not activate the panel, just updates its content.
38993 refresh : function(){
38994 if(this.refreshDelegate){
38995 this.loaded = false;
38996 this.refreshDelegate();
39001 _setLoaded : function(){
39002 this.loaded = true;
39006 closeClick : function(e){
39009 this.fireEvent("beforeclose", this, o);
39010 if(o.cancel !== true){
39011 this.tabPanel.removeTab(this.id);
39015 * The text displayed in the tooltip for the close icon.
39018 closeText : "Close this tab"
39021 * This script refer to:
39022 * Title: International Telephone Input
39023 * Author: Jack O'Connor
39024 * Code version: v12.1.12
39025 * Availability: https://github.com/jackocnr/intl-tel-input.git
39028 Roo.bootstrap.PhoneInputData = function() {
39031 "Afghanistan (افغانستان)",
39036 "Albania (Shqipëri)",
39041 "Algeria (الجزائر)",
39066 "Antigua and Barbuda",
39076 "Armenia (Հայաստան)",
39092 "Austria (Österreich)",
39097 "Azerbaijan (Azərbaycan)",
39107 "Bahrain (البحرين)",
39112 "Bangladesh (বাংলাদেশ)",
39122 "Belarus (Беларусь)",
39127 "Belgium (België)",
39157 "Bosnia and Herzegovina (Босна и Херцеговина)",
39172 "British Indian Ocean Territory",
39177 "British Virgin Islands",
39187 "Bulgaria (България)",
39197 "Burundi (Uburundi)",
39202 "Cambodia (កម្ពុជា)",
39207 "Cameroon (Cameroun)",
39216 ["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"]
39219 "Cape Verde (Kabu Verdi)",
39224 "Caribbean Netherlands",
39235 "Central African Republic (République centrafricaine)",
39255 "Christmas Island",
39261 "Cocos (Keeling) Islands",
39272 "Comoros (جزر القمر)",
39277 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39282 "Congo (Republic) (Congo-Brazzaville)",
39302 "Croatia (Hrvatska)",
39323 "Czech Republic (Česká republika)",
39328 "Denmark (Danmark)",
39343 "Dominican Republic (República Dominicana)",
39347 ["809", "829", "849"]
39365 "Equatorial Guinea (Guinea Ecuatorial)",
39385 "Falkland Islands (Islas Malvinas)",
39390 "Faroe Islands (Føroyar)",
39411 "French Guiana (Guyane française)",
39416 "French Polynesia (Polynésie française)",
39431 "Georgia (საქართველო)",
39436 "Germany (Deutschland)",
39456 "Greenland (Kalaallit Nunaat)",
39493 "Guinea-Bissau (Guiné Bissau)",
39518 "Hungary (Magyarország)",
39523 "Iceland (Ísland)",
39543 "Iraq (العراق)",
39559 "Israel (ישראל)",
39586 "Jordan (الأردن)",
39591 "Kazakhstan (Казахстан)",
39612 "Kuwait (الكويت)",
39617 "Kyrgyzstan (Кыргызстан)",
39627 "Latvia (Latvija)",
39632 "Lebanon (لبنان)",
39647 "Libya (ليبيا)",
39657 "Lithuania (Lietuva)",
39672 "Macedonia (FYROM) (Македонија)",
39677 "Madagascar (Madagasikara)",
39707 "Marshall Islands",
39717 "Mauritania (موريتانيا)",
39722 "Mauritius (Moris)",
39743 "Moldova (Republica Moldova)",
39753 "Mongolia (Монгол)",
39758 "Montenegro (Crna Gora)",
39768 "Morocco (المغرب)",
39774 "Mozambique (Moçambique)",
39779 "Myanmar (Burma) (မြန်မာ)",
39784 "Namibia (Namibië)",
39799 "Netherlands (Nederland)",
39804 "New Caledonia (Nouvelle-Calédonie)",
39839 "North Korea (조선 민주주의 인민 공화국)",
39844 "Northern Mariana Islands",
39860 "Pakistan (پاکستان)",
39870 "Palestine (فلسطين)",
39880 "Papua New Guinea",
39922 "Réunion (La Réunion)",
39928 "Romania (România)",
39944 "Saint Barthélemy",
39955 "Saint Kitts and Nevis",
39965 "Saint Martin (Saint-Martin (partie française))",
39971 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39976 "Saint Vincent and the Grenadines",
39991 "São Tomé and Príncipe (São Tomé e Príncipe)",
39996 "Saudi Arabia (المملكة العربية السعودية)",
40001 "Senegal (Sénégal)",
40031 "Slovakia (Slovensko)",
40036 "Slovenia (Slovenija)",
40046 "Somalia (Soomaaliya)",
40056 "South Korea (대한민국)",
40061 "South Sudan (جنوب السودان)",
40071 "Sri Lanka (ශ්රී ලංකාව)",
40076 "Sudan (السودان)",
40086 "Svalbard and Jan Mayen",
40097 "Sweden (Sverige)",
40102 "Switzerland (Schweiz)",
40107 "Syria (سوريا)",
40152 "Trinidad and Tobago",
40157 "Tunisia (تونس)",
40162 "Turkey (Türkiye)",
40172 "Turks and Caicos Islands",
40182 "U.S. Virgin Islands",
40192 "Ukraine (Україна)",
40197 "United Arab Emirates (الإمارات العربية المتحدة)",
40219 "Uzbekistan (Oʻzbekiston)",
40229 "Vatican City (Città del Vaticano)",
40240 "Vietnam (Việt Nam)",
40245 "Wallis and Futuna (Wallis-et-Futuna)",
40250 "Western Sahara (الصحراء الغربية)",
40256 "Yemen (اليمن)",
40280 * This script refer to:
40281 * Title: International Telephone Input
40282 * Author: Jack O'Connor
40283 * Code version: v12.1.12
40284 * Availability: https://github.com/jackocnr/intl-tel-input.git
40288 * @class Roo.bootstrap.PhoneInput
40289 * @extends Roo.bootstrap.TriggerField
40290 * An input with International dial-code selection
40292 * @cfg {String} defaultDialCode default '+852'
40293 * @cfg {Array} preferedCountries default []
40296 * Create a new PhoneInput.
40297 * @param {Object} config Configuration options
40300 Roo.bootstrap.PhoneInput = function(config) {
40301 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40304 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40306 listWidth: undefined,
40308 selectedClass: 'active',
40310 invalidClass : "has-warning",
40312 validClass: 'has-success',
40314 allowed: '0123456789',
40319 * @cfg {String} defaultDialCode The default dial code when initializing the input
40321 defaultDialCode: '+852',
40324 * @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
40326 preferedCountries: false,
40328 getAutoCreate : function()
40330 var data = Roo.bootstrap.PhoneInputData();
40331 var align = this.labelAlign || this.parentLabelAlign();
40334 this.allCountries = [];
40335 this.dialCodeMapping = [];
40337 for (var i = 0; i < data.length; i++) {
40339 this.allCountries[i] = {
40343 priority: c[3] || 0,
40344 areaCodes: c[4] || null
40346 this.dialCodeMapping[c[2]] = {
40349 priority: c[3] || 0,
40350 areaCodes: c[4] || null
40362 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40363 maxlength: this.max_length,
40364 cls : 'form-control tel-input',
40365 autocomplete: 'new-password'
40368 var hiddenInput = {
40371 cls: 'hidden-tel-input'
40375 hiddenInput.name = this.name;
40378 if (this.disabled) {
40379 input.disabled = true;
40382 var flag_container = {
40399 cls: this.hasFeedback ? 'has-feedback' : '',
40405 cls: 'dial-code-holder',
40412 cls: 'roo-select2-container input-group',
40419 if (this.fieldLabel.length) {
40422 tooltip: 'This field is required'
40428 cls: 'control-label',
40434 html: this.fieldLabel
40437 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40443 if(this.indicatorpos == 'right') {
40444 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40451 if(align == 'left') {
40459 if(this.labelWidth > 12){
40460 label.style = "width: " + this.labelWidth + 'px';
40462 if(this.labelWidth < 13 && this.labelmd == 0){
40463 this.labelmd = this.labelWidth;
40465 if(this.labellg > 0){
40466 label.cls += ' col-lg-' + this.labellg;
40467 input.cls += ' col-lg-' + (12 - this.labellg);
40469 if(this.labelmd > 0){
40470 label.cls += ' col-md-' + this.labelmd;
40471 container.cls += ' col-md-' + (12 - this.labelmd);
40473 if(this.labelsm > 0){
40474 label.cls += ' col-sm-' + this.labelsm;
40475 container.cls += ' col-sm-' + (12 - this.labelsm);
40477 if(this.labelxs > 0){
40478 label.cls += ' col-xs-' + this.labelxs;
40479 container.cls += ' col-xs-' + (12 - this.labelxs);
40489 var settings = this;
40491 ['xs','sm','md','lg'].map(function(size){
40492 if (settings[size]) {
40493 cfg.cls += ' col-' + size + '-' + settings[size];
40497 this.store = new Roo.data.Store({
40498 proxy : new Roo.data.MemoryProxy({}),
40499 reader : new Roo.data.JsonReader({
40510 'name' : 'dialCode',
40514 'name' : 'priority',
40518 'name' : 'areaCodes',
40525 if(!this.preferedCountries) {
40526 this.preferedCountries = [
40533 var p = this.preferedCountries.reverse();
40536 for (var i = 0; i < p.length; i++) {
40537 for (var j = 0; j < this.allCountries.length; j++) {
40538 if(this.allCountries[j].iso2 == p[i]) {
40539 var t = this.allCountries[j];
40540 this.allCountries.splice(j,1);
40541 this.allCountries.unshift(t);
40547 this.store.proxy.data = {
40549 data: this.allCountries
40555 initEvents : function()
40558 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40560 this.indicator = this.indicatorEl();
40561 this.flag = this.flagEl();
40562 this.dialCodeHolder = this.dialCodeHolderEl();
40564 this.trigger = this.el.select('div.flag-box',true).first();
40565 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40570 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40571 _this.list.setWidth(lw);
40574 this.list.on('mouseover', this.onViewOver, this);
40575 this.list.on('mousemove', this.onViewMove, this);
40576 this.inputEl().on("keyup", this.onKeyUp, this);
40577 this.inputEl().on("keypress", this.onKeyPress, this);
40579 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40581 this.view = new Roo.View(this.list, this.tpl, {
40582 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40585 this.view.on('click', this.onViewClick, this);
40586 this.setValue(this.defaultDialCode);
40589 onTriggerClick : function(e)
40591 Roo.log('trigger click');
40596 if(this.isExpanded()){
40598 this.hasFocus = false;
40600 this.store.load({});
40601 this.hasFocus = true;
40606 isExpanded : function()
40608 return this.list.isVisible();
40611 collapse : function()
40613 if(!this.isExpanded()){
40617 Roo.get(document).un('mousedown', this.collapseIf, this);
40618 Roo.get(document).un('mousewheel', this.collapseIf, this);
40619 this.fireEvent('collapse', this);
40623 expand : function()
40627 if(this.isExpanded() || !this.hasFocus){
40631 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40632 this.list.setWidth(lw);
40635 this.restrictHeight();
40637 Roo.get(document).on('mousedown', this.collapseIf, this);
40638 Roo.get(document).on('mousewheel', this.collapseIf, this);
40640 this.fireEvent('expand', this);
40643 restrictHeight : function()
40645 this.list.alignTo(this.inputEl(), this.listAlign);
40646 this.list.alignTo(this.inputEl(), this.listAlign);
40649 onViewOver : function(e, t)
40651 if(this.inKeyMode){
40654 var item = this.view.findItemFromChild(t);
40657 var index = this.view.indexOf(item);
40658 this.select(index, false);
40663 onViewClick : function(view, doFocus, el, e)
40665 var index = this.view.getSelectedIndexes()[0];
40667 var r = this.store.getAt(index);
40670 this.onSelect(r, index);
40672 if(doFocus !== false && !this.blockFocus){
40673 this.inputEl().focus();
40677 onViewMove : function(e, t)
40679 this.inKeyMode = false;
40682 select : function(index, scrollIntoView)
40684 this.selectedIndex = index;
40685 this.view.select(index);
40686 if(scrollIntoView !== false){
40687 var el = this.view.getNode(index);
40689 this.list.scrollChildIntoView(el, false);
40694 createList : function()
40696 this.list = Roo.get(document.body).createChild({
40698 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40699 style: 'display:none'
40702 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40705 collapseIf : function(e)
40707 var in_combo = e.within(this.el);
40708 var in_list = e.within(this.list);
40709 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40711 if (in_combo || in_list || is_list) {
40717 onSelect : function(record, index)
40719 if(this.fireEvent('beforeselect', this, record, index) !== false){
40721 this.setFlagClass(record.data.iso2);
40722 this.setDialCode(record.data.dialCode);
40723 this.hasFocus = false;
40725 this.fireEvent('select', this, record, index);
40729 flagEl : function()
40731 var flag = this.el.select('div.flag',true).first();
40738 dialCodeHolderEl : function()
40740 var d = this.el.select('input.dial-code-holder',true).first();
40747 setDialCode : function(v)
40749 this.dialCodeHolder.dom.value = '+'+v;
40752 setFlagClass : function(n)
40754 this.flag.dom.className = 'flag '+n;
40757 getValue : function()
40759 var v = this.inputEl().getValue();
40760 if(this.dialCodeHolder) {
40761 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40766 setValue : function(v)
40768 var d = this.getDialCode(v);
40770 //invalid dial code
40771 if(v.length == 0 || !d || d.length == 0) {
40773 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40774 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40780 this.setFlagClass(this.dialCodeMapping[d].iso2);
40781 this.setDialCode(d);
40782 this.inputEl().dom.value = v.replace('+'+d,'');
40783 this.hiddenEl().dom.value = this.getValue();
40788 getDialCode : function(v)
40792 if (v.length == 0) {
40793 return this.dialCodeHolder.dom.value;
40797 if (v.charAt(0) != "+") {
40800 var numericChars = "";
40801 for (var i = 1; i < v.length; i++) {
40802 var c = v.charAt(i);
40805 if (this.dialCodeMapping[numericChars]) {
40806 dialCode = v.substr(1, i);
40808 if (numericChars.length == 4) {
40818 this.setValue(this.defaultDialCode);
40822 hiddenEl : function()
40824 return this.el.select('input.hidden-tel-input',true).first();
40827 // after setting val
40828 onKeyUp : function(e){
40829 this.setValue(this.getValue());
40832 onKeyPress : function(e){
40833 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40840 * @class Roo.bootstrap.MoneyField
40841 * @extends Roo.bootstrap.ComboBox
40842 * Bootstrap MoneyField class
40845 * Create a new MoneyField.
40846 * @param {Object} config Configuration options
40849 Roo.bootstrap.MoneyField = function(config) {
40851 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40855 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40858 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40860 allowDecimals : true,
40862 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40864 decimalSeparator : ".",
40866 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40868 decimalPrecision : 0,
40870 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40872 allowNegative : true,
40874 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40878 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40880 minValue : Number.NEGATIVE_INFINITY,
40882 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40884 maxValue : Number.MAX_VALUE,
40886 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40888 minText : "The minimum value for this field is {0}",
40890 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40892 maxText : "The maximum value for this field is {0}",
40894 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40895 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40897 nanText : "{0} is not a valid number",
40899 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40903 * @cfg {String} defaults currency of the MoneyField
40904 * value should be in lkey
40906 defaultCurrency : false,
40908 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40910 thousandsDelimiter : false,
40912 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40923 getAutoCreate : function()
40925 var align = this.labelAlign || this.parentLabelAlign();
40937 cls : 'form-control roo-money-amount-input',
40938 autocomplete: 'new-password'
40941 var hiddenInput = {
40945 cls: 'hidden-number-input'
40948 if(this.max_length) {
40949 input.maxlength = this.max_length;
40953 hiddenInput.name = this.name;
40956 if (this.disabled) {
40957 input.disabled = true;
40960 var clg = 12 - this.inputlg;
40961 var cmd = 12 - this.inputmd;
40962 var csm = 12 - this.inputsm;
40963 var cxs = 12 - this.inputxs;
40967 cls : 'row roo-money-field',
40971 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40975 cls: 'roo-select2-container input-group',
40979 cls : 'form-control roo-money-currency-input',
40980 autocomplete: 'new-password',
40982 name : this.currencyName
40986 cls : 'input-group-addon',
41000 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
41004 cls: this.hasFeedback ? 'has-feedback' : '',
41015 if (this.fieldLabel.length) {
41018 tooltip: 'This field is required'
41024 cls: 'control-label',
41030 html: this.fieldLabel
41033 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
41039 if(this.indicatorpos == 'right') {
41040 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41047 if(align == 'left') {
41055 if(this.labelWidth > 12){
41056 label.style = "width: " + this.labelWidth + 'px';
41058 if(this.labelWidth < 13 && this.labelmd == 0){
41059 this.labelmd = this.labelWidth;
41061 if(this.labellg > 0){
41062 label.cls += ' col-lg-' + this.labellg;
41063 input.cls += ' col-lg-' + (12 - this.labellg);
41065 if(this.labelmd > 0){
41066 label.cls += ' col-md-' + this.labelmd;
41067 container.cls += ' col-md-' + (12 - this.labelmd);
41069 if(this.labelsm > 0){
41070 label.cls += ' col-sm-' + this.labelsm;
41071 container.cls += ' col-sm-' + (12 - this.labelsm);
41073 if(this.labelxs > 0){
41074 label.cls += ' col-xs-' + this.labelxs;
41075 container.cls += ' col-xs-' + (12 - this.labelxs);
41086 var settings = this;
41088 ['xs','sm','md','lg'].map(function(size){
41089 if (settings[size]) {
41090 cfg.cls += ' col-' + size + '-' + settings[size];
41097 initEvents : function()
41099 this.indicator = this.indicatorEl();
41101 this.initCurrencyEvent();
41103 this.initNumberEvent();
41106 initCurrencyEvent : function()
41109 throw "can not find store for combo";
41112 this.store = Roo.factory(this.store, Roo.data);
41113 this.store.parent = this;
41117 this.triggerEl = this.el.select('.input-group-addon', true).first();
41119 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41124 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41125 _this.list.setWidth(lw);
41128 this.list.on('mouseover', this.onViewOver, this);
41129 this.list.on('mousemove', this.onViewMove, this);
41130 this.list.on('scroll', this.onViewScroll, this);
41133 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41136 this.view = new Roo.View(this.list, this.tpl, {
41137 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41140 this.view.on('click', this.onViewClick, this);
41142 this.store.on('beforeload', this.onBeforeLoad, this);
41143 this.store.on('load', this.onLoad, this);
41144 this.store.on('loadexception', this.onLoadException, this);
41146 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41147 "up" : function(e){
41148 this.inKeyMode = true;
41152 "down" : function(e){
41153 if(!this.isExpanded()){
41154 this.onTriggerClick();
41156 this.inKeyMode = true;
41161 "enter" : function(e){
41164 if(this.fireEvent("specialkey", this, e)){
41165 this.onViewClick(false);
41171 "esc" : function(e){
41175 "tab" : function(e){
41178 if(this.fireEvent("specialkey", this, e)){
41179 this.onViewClick(false);
41187 doRelay : function(foo, bar, hname){
41188 if(hname == 'down' || this.scope.isExpanded()){
41189 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41197 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41201 initNumberEvent : function(e)
41203 this.inputEl().on("keydown" , this.fireKey, this);
41204 this.inputEl().on("focus", this.onFocus, this);
41205 this.inputEl().on("blur", this.onBlur, this);
41207 this.inputEl().relayEvent('keyup', this);
41209 if(this.indicator){
41210 this.indicator.addClass('invisible');
41213 this.originalValue = this.getValue();
41215 if(this.validationEvent == 'keyup'){
41216 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41217 this.inputEl().on('keyup', this.filterValidation, this);
41219 else if(this.validationEvent !== false){
41220 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41223 if(this.selectOnFocus){
41224 this.on("focus", this.preFocus, this);
41227 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41228 this.inputEl().on("keypress", this.filterKeys, this);
41230 this.inputEl().relayEvent('keypress', this);
41233 var allowed = "0123456789";
41235 if(this.allowDecimals){
41236 allowed += this.decimalSeparator;
41239 if(this.allowNegative){
41243 if(this.thousandsDelimiter) {
41247 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41249 var keyPress = function(e){
41251 var k = e.getKey();
41253 var c = e.getCharCode();
41256 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41257 allowed.indexOf(String.fromCharCode(c)) === -1
41263 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41267 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41272 this.inputEl().on("keypress", keyPress, this);
41276 onTriggerClick : function(e)
41283 this.loadNext = false;
41285 if(this.isExpanded()){
41290 this.hasFocus = true;
41292 if(this.triggerAction == 'all') {
41293 this.doQuery(this.allQuery, true);
41297 this.doQuery(this.getRawValue());
41300 getCurrency : function()
41302 var v = this.currencyEl().getValue();
41307 restrictHeight : function()
41309 this.list.alignTo(this.currencyEl(), this.listAlign);
41310 this.list.alignTo(this.currencyEl(), this.listAlign);
41313 onViewClick : function(view, doFocus, el, e)
41315 var index = this.view.getSelectedIndexes()[0];
41317 var r = this.store.getAt(index);
41320 this.onSelect(r, index);
41324 onSelect : function(record, index){
41326 if(this.fireEvent('beforeselect', this, record, index) !== false){
41328 this.setFromCurrencyData(index > -1 ? record.data : false);
41332 this.fireEvent('select', this, record, index);
41336 setFromCurrencyData : function(o)
41340 this.lastCurrency = o;
41342 if (this.currencyField) {
41343 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41345 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41348 this.lastSelectionText = currency;
41350 //setting default currency
41351 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41352 this.setCurrency(this.defaultCurrency);
41356 this.setCurrency(currency);
41359 setFromData : function(o)
41363 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41365 this.setFromCurrencyData(c);
41370 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41372 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41375 this.setValue(value);
41379 setCurrency : function(v)
41381 this.currencyValue = v;
41384 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41389 setValue : function(v)
41391 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41397 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41399 this.inputEl().dom.value = (v == '') ? '' :
41400 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41402 if(!this.allowZero && v === '0') {
41403 this.hiddenEl().dom.value = '';
41404 this.inputEl().dom.value = '';
41411 getRawValue : function()
41413 var v = this.inputEl().getValue();
41418 getValue : function()
41420 return this.fixPrecision(this.parseValue(this.getRawValue()));
41423 parseValue : function(value)
41425 if(this.thousandsDelimiter) {
41427 r = new RegExp(",", "g");
41428 value = value.replace(r, "");
41431 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41432 return isNaN(value) ? '' : value;
41436 fixPrecision : function(value)
41438 if(this.thousandsDelimiter) {
41440 r = new RegExp(",", "g");
41441 value = value.replace(r, "");
41444 var nan = isNaN(value);
41446 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41447 return nan ? '' : value;
41449 return parseFloat(value).toFixed(this.decimalPrecision);
41452 decimalPrecisionFcn : function(v)
41454 return Math.floor(v);
41457 validateValue : function(value)
41459 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41463 var num = this.parseValue(value);
41466 this.markInvalid(String.format(this.nanText, value));
41470 if(num < this.minValue){
41471 this.markInvalid(String.format(this.minText, this.minValue));
41475 if(num > this.maxValue){
41476 this.markInvalid(String.format(this.maxText, this.maxValue));
41483 validate : function()
41485 if(this.disabled || this.allowBlank){
41490 var currency = this.getCurrency();
41492 if(this.validateValue(this.getRawValue()) && currency.length){
41497 this.markInvalid();
41501 getName: function()
41506 beforeBlur : function()
41512 var v = this.parseValue(this.getRawValue());
41519 onBlur : function()
41523 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41524 //this.el.removeClass(this.focusClass);
41527 this.hasFocus = false;
41529 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41533 var v = this.getValue();
41535 if(String(v) !== String(this.startValue)){
41536 this.fireEvent('change', this, v, this.startValue);
41539 this.fireEvent("blur", this);
41542 inputEl : function()
41544 return this.el.select('.roo-money-amount-input', true).first();
41547 currencyEl : function()
41549 return this.el.select('.roo-money-currency-input', true).first();
41552 hiddenEl : function()
41554 return this.el.select('input.hidden-number-input',true).first();
41558 * @class Roo.bootstrap.BezierSignature
41559 * @extends Roo.bootstrap.Component
41560 * Bootstrap BezierSignature class
41561 * This script refer to:
41562 * Title: Signature Pad
41564 * Availability: https://github.com/szimek/signature_pad
41567 * Create a new BezierSignature
41568 * @param {Object} config The config object
41571 Roo.bootstrap.BezierSignature = function(config){
41572 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41578 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
41585 mouse_btn_down: true,
41588 * @cfg {int} canvas height
41590 canvas_height: '200px',
41593 * @cfg {float|function} Radius of a single dot.
41598 * @cfg {float} Minimum width of a line. Defaults to 0.5.
41603 * @cfg {float} Maximum width of a line. Defaults to 2.5.
41608 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41613 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41618 * @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.
41620 bg_color: 'rgba(0, 0, 0, 0)',
41623 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41625 dot_color: 'black',
41628 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41630 velocity_filter_weight: 0.7,
41633 * @cfg {function} Callback when stroke begin.
41638 * @cfg {function} Callback when stroke end.
41642 getAutoCreate : function()
41644 var cls = 'roo-signature column';
41647 cls += ' ' + this.cls;
41657 for(var i = 0; i < col_sizes.length; i++) {
41658 if(this[col_sizes[i]]) {
41659 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41669 cls: 'roo-signature-body',
41673 cls: 'roo-signature-body-canvas',
41674 height: this.canvas_height,
41675 width: this.canvas_width
41682 style: 'display: none'
41690 initEvents: function()
41692 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41694 var canvas = this.canvasEl();
41696 // mouse && touch event swapping...
41697 canvas.dom.style.touchAction = 'none';
41698 canvas.dom.style.msTouchAction = 'none';
41700 this.mouse_btn_down = false;
41701 canvas.on('mousedown', this._handleMouseDown, this);
41702 canvas.on('mousemove', this._handleMouseMove, this);
41703 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41705 if (window.PointerEvent) {
41706 canvas.on('pointerdown', this._handleMouseDown, this);
41707 canvas.on('pointermove', this._handleMouseMove, this);
41708 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41711 if ('ontouchstart' in window) {
41712 canvas.on('touchstart', this._handleTouchStart, this);
41713 canvas.on('touchmove', this._handleTouchMove, this);
41714 canvas.on('touchend', this._handleTouchEnd, this);
41717 Roo.EventManager.onWindowResize(this.resize, this, true);
41719 // file input event
41720 this.fileEl().on('change', this.uploadImage, this);
41727 resize: function(){
41729 var canvas = this.canvasEl().dom;
41730 var ctx = this.canvasElCtx();
41731 var img_data = false;
41733 if(canvas.width > 0) {
41734 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41736 // setting canvas width will clean img data
41739 var style = window.getComputedStyle ?
41740 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41742 var padding_left = parseInt(style.paddingLeft) || 0;
41743 var padding_right = parseInt(style.paddingRight) || 0;
41745 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41748 ctx.putImageData(img_data, 0, 0);
41752 _handleMouseDown: function(e)
41754 if (e.browserEvent.which === 1) {
41755 this.mouse_btn_down = true;
41756 this.strokeBegin(e);
41760 _handleMouseMove: function (e)
41762 if (this.mouse_btn_down) {
41763 this.strokeMoveUpdate(e);
41767 _handleMouseUp: function (e)
41769 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41770 this.mouse_btn_down = false;
41775 _handleTouchStart: function (e) {
41777 e.preventDefault();
41778 if (e.browserEvent.targetTouches.length === 1) {
41779 // var touch = e.browserEvent.changedTouches[0];
41780 // this.strokeBegin(touch);
41782 this.strokeBegin(e); // assume e catching the correct xy...
41786 _handleTouchMove: function (e) {
41787 e.preventDefault();
41788 // var touch = event.targetTouches[0];
41789 // _this._strokeMoveUpdate(touch);
41790 this.strokeMoveUpdate(e);
41793 _handleTouchEnd: function (e) {
41794 var wasCanvasTouched = e.target === this.canvasEl().dom;
41795 if (wasCanvasTouched) {
41796 e.preventDefault();
41797 // var touch = event.changedTouches[0];
41798 // _this._strokeEnd(touch);
41803 reset: function () {
41804 this._lastPoints = [];
41805 this._lastVelocity = 0;
41806 this._lastWidth = (this.min_width + this.max_width) / 2;
41807 this.canvasElCtx().fillStyle = this.dot_color;
41810 strokeMoveUpdate: function(e)
41812 this.strokeUpdate(e);
41814 if (this.throttle) {
41815 this.throttleStroke(this.strokeUpdate, this.throttle);
41818 this.strokeUpdate(e);
41822 strokeBegin: function(e)
41824 var newPointGroup = {
41825 color: this.dot_color,
41829 if (typeof this.onBegin === 'function') {
41833 this.curve_data.push(newPointGroup);
41835 this.strokeUpdate(e);
41838 strokeUpdate: function(e)
41840 var rect = this.canvasEl().dom.getBoundingClientRect();
41841 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41842 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41843 var lastPoints = lastPointGroup.points;
41844 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41845 var isLastPointTooClose = lastPoint
41846 ? point.distanceTo(lastPoint) <= this.min_distance
41848 var color = lastPointGroup.color;
41849 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41850 var curve = this.addPoint(point);
41852 this.drawDot({color: color, point: point});
41855 this.drawCurve({color: color, curve: curve});
41865 strokeEnd: function(e)
41867 this.strokeUpdate(e);
41868 if (typeof this.onEnd === 'function') {
41873 addPoint: function (point) {
41874 var _lastPoints = this._lastPoints;
41875 _lastPoints.push(point);
41876 if (_lastPoints.length > 2) {
41877 if (_lastPoints.length === 3) {
41878 _lastPoints.unshift(_lastPoints[0]);
41880 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41881 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41882 _lastPoints.shift();
41888 calculateCurveWidths: function (startPoint, endPoint) {
41889 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41890 (1 - this.velocity_filter_weight) * this._lastVelocity;
41892 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41895 start: this._lastWidth
41898 this._lastVelocity = velocity;
41899 this._lastWidth = newWidth;
41903 drawDot: function (_a) {
41904 var color = _a.color, point = _a.point;
41905 var ctx = this.canvasElCtx();
41906 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41908 this.drawCurveSegment(point.x, point.y, width);
41910 ctx.fillStyle = color;
41914 drawCurve: function (_a) {
41915 var color = _a.color, curve = _a.curve;
41916 var ctx = this.canvasElCtx();
41917 var widthDelta = curve.endWidth - curve.startWidth;
41918 var drawSteps = Math.floor(curve.length()) * 2;
41920 ctx.fillStyle = color;
41921 for (var i = 0; i < drawSteps; i += 1) {
41922 var t = i / drawSteps;
41928 var x = uuu * curve.startPoint.x;
41929 x += 3 * uu * t * curve.control1.x;
41930 x += 3 * u * tt * curve.control2.x;
41931 x += ttt * curve.endPoint.x;
41932 var y = uuu * curve.startPoint.y;
41933 y += 3 * uu * t * curve.control1.y;
41934 y += 3 * u * tt * curve.control2.y;
41935 y += ttt * curve.endPoint.y;
41936 var width = curve.startWidth + ttt * widthDelta;
41937 this.drawCurveSegment(x, y, width);
41943 drawCurveSegment: function (x, y, width) {
41944 var ctx = this.canvasElCtx();
41946 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41947 this.is_empty = false;
41952 var ctx = this.canvasElCtx();
41953 var canvas = this.canvasEl().dom;
41954 ctx.fillStyle = this.bg_color;
41955 ctx.clearRect(0, 0, canvas.width, canvas.height);
41956 ctx.fillRect(0, 0, canvas.width, canvas.height);
41957 this.curve_data = [];
41959 this.is_empty = true;
41964 return this.el.select('input',true).first();
41967 canvasEl: function()
41969 return this.el.select('canvas',true).first();
41972 canvasElCtx: function()
41974 return this.el.select('canvas',true).first().dom.getContext('2d');
41977 getImage: function(type)
41979 if(this.is_empty) {
41984 return this.canvasEl().dom.toDataURL('image/'+type, 1);
41987 drawFromImage: function(img_src)
41989 var img = new Image();
41991 img.onload = function(){
41992 this.canvasElCtx().drawImage(img, 0, 0);
41997 this.is_empty = false;
42000 selectImage: function()
42002 this.fileEl().dom.click();
42005 uploadImage: function(e)
42007 var reader = new FileReader();
42009 reader.onload = function(e){
42010 var img = new Image();
42011 img.onload = function(){
42013 this.canvasElCtx().drawImage(img, 0, 0);
42015 img.src = e.target.result;
42018 reader.readAsDataURL(e.target.files[0]);
42021 // Bezier Point Constructor
42022 Point: (function () {
42023 function Point(x, y, time) {
42026 this.time = time || Date.now();
42028 Point.prototype.distanceTo = function (start) {
42029 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
42031 Point.prototype.equals = function (other) {
42032 return this.x === other.x && this.y === other.y && this.time === other.time;
42034 Point.prototype.velocityFrom = function (start) {
42035 return this.time !== start.time
42036 ? this.distanceTo(start) / (this.time - start.time)
42043 // Bezier Constructor
42044 Bezier: (function () {
42045 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
42046 this.startPoint = startPoint;
42047 this.control2 = control2;
42048 this.control1 = control1;
42049 this.endPoint = endPoint;
42050 this.startWidth = startWidth;
42051 this.endWidth = endWidth;
42053 Bezier.fromPoints = function (points, widths, scope) {
42054 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42055 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42056 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42058 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42059 var dx1 = s1.x - s2.x;
42060 var dy1 = s1.y - s2.y;
42061 var dx2 = s2.x - s3.x;
42062 var dy2 = s2.y - s3.y;
42063 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42064 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42065 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42066 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42067 var dxm = m1.x - m2.x;
42068 var dym = m1.y - m2.y;
42069 var k = l2 / (l1 + l2);
42070 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42071 var tx = s2.x - cm.x;
42072 var ty = s2.y - cm.y;
42074 c1: new scope.Point(m1.x + tx, m1.y + ty),
42075 c2: new scope.Point(m2.x + tx, m2.y + ty)
42078 Bezier.prototype.length = function () {
42083 for (var i = 0; i <= steps; i += 1) {
42085 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42086 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42088 var xdiff = cx - px;
42089 var ydiff = cy - py;
42090 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42097 Bezier.prototype.point = function (t, start, c1, c2, end) {
42098 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42099 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42100 + (3.0 * c2 * (1.0 - t) * t * t)
42101 + (end * t * t * t);
42106 throttleStroke: function(fn, wait) {
42107 if (wait === void 0) { wait = 250; }
42109 var timeout = null;
42113 var later = function () {
42114 previous = Date.now();
42116 result = fn.apply(storedContext, storedArgs);
42118 storedContext = null;
42122 return function wrapper() {
42124 for (var _i = 0; _i < arguments.length; _i++) {
42125 args[_i] = arguments[_i];
42127 var now = Date.now();
42128 var remaining = wait - (now - previous);
42129 storedContext = this;
42131 if (remaining <= 0 || remaining > wait) {
42133 clearTimeout(timeout);
42137 result = fn.apply(storedContext, storedArgs);
42139 storedContext = null;
42143 else if (!timeout) {
42144 timeout = window.setTimeout(later, remaining);