2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets[0], 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
2064 * @param {Roo.menu.Menu} this
2069 * Fires before this menu is hidden
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){
2292 this.parentMenu = parentMenu;
2296 this.fireEvent("beforeshow", this);
2297 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2300 * Displays this menu at a specific xy position
2301 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2302 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2304 showAt : function(xy, parentMenu, /* private: */_e){
2305 this.parentMenu = parentMenu;
2310 this.fireEvent("beforeshow", this);
2311 //xy = this.el.adjustForConstraints(xy);
2315 this.hideMenuItems();
2316 this.hidden = false;
2317 this.triggerEl.addClass('open');
2318 this.el.addClass('show');
2320 // reassign x when hitting right
2321 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2322 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2325 // reassign y when hitting bottom
2326 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2327 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2330 // but the list may align on trigger left or trigger top... should it be a properity?
2332 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2337 this.fireEvent("show", this);
2343 this.doFocus.defer(50, this);
2347 doFocus : function(){
2349 this.focusEl.focus();
2354 * Hides this menu and optionally all parent menus
2355 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2357 hide : function(deep)
2360 this.hideMenuItems();
2361 if(this.el && this.isVisible()){
2362 this.fireEvent("beforehide", this);
2363 if(this.activeItem){
2364 this.activeItem.deactivate();
2365 this.activeItem = null;
2367 this.triggerEl.removeClass('open');;
2368 this.el.removeClass('show');
2370 this.fireEvent("hide", this);
2372 if(deep === true && this.parentMenu){
2373 this.parentMenu.hide(true);
2377 onTriggerClick : function(e)
2379 Roo.log('trigger click');
2381 var target = e.getTarget();
2383 Roo.log(target.nodeName.toLowerCase());
2385 if(target.nodeName.toLowerCase() === 'i'){
2391 onTriggerPress : function(e)
2393 Roo.log('trigger press');
2394 //Roo.log(e.getTarget());
2395 // Roo.log(this.triggerEl.dom);
2397 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2398 var pel = Roo.get(e.getTarget());
2399 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2400 Roo.log('is treeview or dropdown?');
2404 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2408 if (this.isVisible()) {
2413 this.show(this.triggerEl, '?', false);
2416 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2423 hideMenuItems : function()
2425 Roo.log("hide Menu Items");
2429 //$(backdrop).remove()
2430 this.el.select('.open',true).each(function(aa) {
2432 aa.removeClass('open');
2433 //var parent = getParent($(this))
2434 //var relatedTarget = { relatedTarget: this }
2436 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2437 //if (e.isDefaultPrevented()) return
2438 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2441 addxtypeChild : function (tree, cntr) {
2442 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2444 this.menuitems.add(comp);
2456 this.getEl().dom.innerHTML = '';
2457 this.menuitems.clear();
2471 * @class Roo.bootstrap.MenuItem
2472 * @extends Roo.bootstrap.Component
2473 * Bootstrap MenuItem class
2474 * @cfg {String} html the menu label
2475 * @cfg {String} href the link
2476 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2477 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2478 * @cfg {Boolean} active used on sidebars to highlight active itesm
2479 * @cfg {String} fa favicon to show on left of menu item.
2480 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2484 * Create a new MenuItem
2485 * @param {Object} config The config object
2489 Roo.bootstrap.MenuItem = function(config){
2490 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2495 * The raw click event for the entire grid.
2496 * @param {Roo.bootstrap.MenuItem} this
2497 * @param {Roo.EventObject} e
2503 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2507 preventDefault: false,
2508 isContainer : false,
2512 getAutoCreate : function(){
2514 if(this.isContainer){
2517 cls: 'dropdown-menu-item '
2527 cls : 'dropdown-item',
2532 if (this.fa !== false) {
2535 cls : 'fa fa-' + this.fa
2544 cls: 'dropdown-menu-item',
2547 if (this.parent().type == 'treeview') {
2548 cfg.cls = 'treeview-menu';
2551 cfg.cls += ' active';
2556 anc.href = this.href || cfg.cn[0].href ;
2557 ctag.html = this.html || cfg.cn[0].html ;
2561 initEvents: function()
2563 if (this.parent().type == 'treeview') {
2564 this.el.select('a').on('click', this.onClick, this);
2568 this.menu.parentType = this.xtype;
2569 this.menu.triggerEl = this.el;
2570 this.menu = this.addxtype(Roo.apply({}, this.menu));
2574 onClick : function(e)
2576 Roo.log('item on click ');
2578 if(this.preventDefault){
2581 //this.parent().hideMenuItems();
2583 this.fireEvent('click', this, e);
2602 * @class Roo.bootstrap.MenuSeparator
2603 * @extends Roo.bootstrap.Component
2604 * Bootstrap MenuSeparator class
2607 * Create a new MenuItem
2608 * @param {Object} config The config object
2612 Roo.bootstrap.MenuSeparator = function(config){
2613 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2616 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2618 getAutoCreate : function(){
2637 * @class Roo.bootstrap.Modal
2638 * @extends Roo.bootstrap.Component
2639 * Bootstrap Modal class
2640 * @cfg {String} title Title of dialog
2641 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2642 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2643 * @cfg {Boolean} specificTitle default false
2644 * @cfg {Array} buttons Array of buttons or standard button set..
2645 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2646 * @cfg {Boolean} animate default true
2647 * @cfg {Boolean} allow_close default true
2648 * @cfg {Boolean} fitwindow default false
2649 * @cfg {String} size (sm|lg) default empty
2650 * @cfg {Number} max_width set the max width of modal
2654 * Create a new Modal Dialog
2655 * @param {Object} config The config object
2658 Roo.bootstrap.Modal = function(config){
2659 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2664 * The raw btnclick event for the button
2665 * @param {Roo.EventObject} e
2670 * Fire when dialog resize
2671 * @param {Roo.bootstrap.Modal} this
2672 * @param {Roo.EventObject} e
2676 this.buttons = this.buttons || [];
2679 this.tmpl = Roo.factory(this.tmpl);
2684 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2686 title : 'test dialog',
2696 specificTitle: false,
2698 buttonPosition: 'right',
2721 onRender : function(ct, position)
2723 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2726 var cfg = Roo.apply({}, this.getAutoCreate());
2729 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2731 //if (!cfg.name.length) {
2735 cfg.cls += ' ' + this.cls;
2738 cfg.style = this.style;
2740 this.el = Roo.get(document.body).createChild(cfg, position);
2742 //var type = this.el.dom.type;
2745 if(this.tabIndex !== undefined){
2746 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2749 this.dialogEl = this.el.select('.modal-dialog',true).first();
2750 this.bodyEl = this.el.select('.modal-body',true).first();
2751 this.closeEl = this.el.select('.modal-header .close', true).first();
2752 this.headerEl = this.el.select('.modal-header',true).first();
2753 this.titleEl = this.el.select('.modal-title',true).first();
2754 this.footerEl = this.el.select('.modal-footer',true).first();
2756 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2758 //this.el.addClass("x-dlg-modal");
2760 if (this.buttons.length) {
2761 Roo.each(this.buttons, function(bb) {
2762 var b = Roo.apply({}, bb);
2763 b.xns = b.xns || Roo.bootstrap;
2764 b.xtype = b.xtype || 'Button';
2765 if (typeof(b.listeners) == 'undefined') {
2766 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2769 var btn = Roo.factory(b);
2771 btn.render(this.getButtonContainer());
2775 // render the children.
2778 if(typeof(this.items) != 'undefined'){
2779 var items = this.items;
2782 for(var i =0;i < items.length;i++) {
2783 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2787 this.items = nitems;
2789 // where are these used - they used to be body/close/footer
2793 //this.el.addClass([this.fieldClass, this.cls]);
2797 getAutoCreate : function()
2801 html : this.html || ''
2806 cls : 'modal-title',
2810 if(this.specificTitle){
2816 if (this.allow_close && Roo.bootstrap.version == 3) {
2826 if (this.allow_close && Roo.bootstrap.version == 4) {
2836 if(this.size.length){
2837 size = 'modal-' + this.size;
2840 var footer = Roo.bootstrap.version == 3 ?
2842 cls : 'modal-footer',
2846 cls: 'btn-' + this.buttonPosition
2851 { // BS4 uses mr-auto on left buttons....
2852 cls : 'modal-footer'
2863 cls: "modal-dialog " + size,
2866 cls : "modal-content",
2869 cls : 'modal-header',
2884 modal.cls += ' fade';
2890 getChildContainer : function() {
2895 getButtonContainer : function() {
2897 return Roo.bootstrap.version == 4 ?
2898 this.el.select('.modal-footer',true).first()
2899 : this.el.select('.modal-footer div',true).first();
2902 initEvents : function()
2904 if (this.allow_close) {
2905 this.closeEl.on('click', this.hide, this);
2907 Roo.EventManager.onWindowResize(this.resize, this, true);
2914 this.maskEl.setSize(
2915 Roo.lib.Dom.getViewWidth(true),
2916 Roo.lib.Dom.getViewHeight(true)
2919 if (this.fitwindow) {
2921 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2922 this.height || Roo.lib.Dom.getViewportHeight(true) - 60
2927 if(this.max_width !== 0) {
2929 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2932 this.setSize(w, this.height);
2936 if(this.max_height) {
2937 this.setSize(w,Math.min(
2939 Roo.lib.Dom.getViewportHeight(true) - 60
2945 if(!this.fit_content) {
2946 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2950 this.setSize(w, Math.min(
2952 this.headerEl.getHeight() +
2953 this.footerEl.getHeight() +
2954 this.getChildHeight(this.bodyEl.dom.childNodes),
2955 Roo.lib.Dom.getViewportHeight(true) - 60)
2961 setSize : function(w,h)
2972 if (!this.rendered) {
2976 //this.el.setStyle('display', 'block');
2977 this.el.removeClass('hideing');
2978 this.el.dom.style.display='block';
2980 Roo.get(document.body).addClass('modal-open');
2982 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2985 this.el.addClass('show');
2986 this.el.addClass('in');
2989 this.el.addClass('show');
2990 this.el.addClass('in');
2993 // not sure how we can show data in here..
2995 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2998 Roo.get(document.body).addClass("x-body-masked");
3000 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3001 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3002 this.maskEl.dom.style.display = 'block';
3003 this.maskEl.addClass('show');
3008 this.fireEvent('show', this);
3010 // set zindex here - otherwise it appears to be ignored...
3011 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3014 this.items.forEach( function(e) {
3015 e.layout ? e.layout() : false;
3023 if(this.fireEvent("beforehide", this) !== false){
3025 this.maskEl.removeClass('show');
3027 this.maskEl.dom.style.display = '';
3028 Roo.get(document.body).removeClass("x-body-masked");
3029 this.el.removeClass('in');
3030 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3032 if(this.animate){ // why
3033 this.el.addClass('hideing');
3034 this.el.removeClass('show');
3036 if (!this.el.hasClass('hideing')) {
3037 return; // it's been shown again...
3040 this.el.dom.style.display='';
3042 Roo.get(document.body).removeClass('modal-open');
3043 this.el.removeClass('hideing');
3047 this.el.removeClass('show');
3048 this.el.dom.style.display='';
3049 Roo.get(document.body).removeClass('modal-open');
3052 this.fireEvent('hide', this);
3055 isVisible : function()
3058 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3062 addButton : function(str, cb)
3066 var b = Roo.apply({}, { html : str } );
3067 b.xns = b.xns || Roo.bootstrap;
3068 b.xtype = b.xtype || 'Button';
3069 if (typeof(b.listeners) == 'undefined') {
3070 b.listeners = { click : cb.createDelegate(this) };
3073 var btn = Roo.factory(b);
3075 btn.render(this.getButtonContainer());
3081 setDefaultButton : function(btn)
3083 //this.el.select('.modal-footer').()
3087 resizeTo: function(w,h)
3091 this.dialogEl.setWidth(w);
3092 if (this.diff === false) {
3093 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
3096 this.bodyEl.setHeight(h - this.diff);
3098 this.fireEvent('resize', this);
3101 setContentSize : function(w, h)
3105 onButtonClick: function(btn,e)
3108 this.fireEvent('btnclick', btn.name, e);
3111 * Set the title of the Dialog
3112 * @param {String} str new Title
3114 setTitle: function(str) {
3115 this.titleEl.dom.innerHTML = str;
3118 * Set the body of the Dialog
3119 * @param {String} str new Title
3121 setBody: function(str) {
3122 this.bodyEl.dom.innerHTML = str;
3125 * Set the body of the Dialog using the template
3126 * @param {Obj} data - apply this data to the template and replace the body contents.
3128 applyBody: function(obj)
3131 Roo.log("Error - using apply Body without a template");
3134 this.tmpl.overwrite(this.bodyEl, obj);
3137 getChildHeight : function(child_nodes)
3141 child_nodes.length == 0
3146 var child_height = 0;
3148 for(var i = 0; i < child_nodes.length; i++) {
3151 * for modal with tabs...
3152 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3154 var layout_childs = child_nodes[i].childNodes;
3156 for(var j = 0; j < layout_childs.length; j++) {
3158 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3160 var layout_body_childs = layout_childs[j].childNodes;
3162 for(var k = 0; k < layout_body_childs.length; k++) {
3164 if(layout_body_childs[k].classList.contains('navbar')) {
3165 child_height += layout_body_childs[k].offsetHeight;
3169 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3171 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3173 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3175 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3176 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3191 child_height += child_nodes[i].offsetHeight;
3192 // Roo.log(child_nodes[i].offsetHeight);
3195 return child_height;
3201 Roo.apply(Roo.bootstrap.Modal, {
3203 * Button config that displays a single OK button
3212 * Button config that displays Yes and No buttons
3228 * Button config that displays OK and Cancel buttons
3243 * Button config that displays Yes, No and Cancel buttons
3267 * messagebox - can be used as a replace
3271 * @class Roo.MessageBox
3272 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3276 Roo.Msg.alert('Status', 'Changes saved successfully.');
3278 // Prompt for user data:
3279 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3281 // process text value...
3285 // Show a dialog using config options:
3287 title:'Save Changes?',
3288 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3289 buttons: Roo.Msg.YESNOCANCEL,
3296 Roo.bootstrap.MessageBox = function(){
3297 var dlg, opt, mask, waitTimer;
3298 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3299 var buttons, activeTextEl, bwidth;
3303 var handleButton = function(button){
3305 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3309 var handleHide = function(){
3311 dlg.el.removeClass(opt.cls);
3314 // Roo.TaskMgr.stop(waitTimer);
3315 // waitTimer = null;
3320 var updateButtons = function(b){
3323 buttons["ok"].hide();
3324 buttons["cancel"].hide();
3325 buttons["yes"].hide();
3326 buttons["no"].hide();
3327 dlg.footerEl.hide();
3331 dlg.footerEl.show();
3332 for(var k in buttons){
3333 if(typeof buttons[k] != "function"){
3336 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3337 width += buttons[k].el.getWidth()+15;
3347 var handleEsc = function(d, k, e){
3348 if(opt && opt.closable !== false){
3358 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3359 * @return {Roo.BasicDialog} The BasicDialog element
3361 getDialog : function(){
3363 dlg = new Roo.bootstrap.Modal( {
3366 //constraintoviewport:false,
3368 //collapsible : false,
3373 //buttonAlign:"center",
3374 closeClick : function(){
3375 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3378 handleButton("cancel");
3383 dlg.on("hide", handleHide);
3385 //dlg.addKeyListener(27, handleEsc);
3387 this.buttons = buttons;
3388 var bt = this.buttonText;
3389 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3390 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3391 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3392 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3394 bodyEl = dlg.bodyEl.createChild({
3396 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3397 '<textarea class="roo-mb-textarea"></textarea>' +
3398 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3400 msgEl = bodyEl.dom.firstChild;
3401 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3402 textboxEl.enableDisplayMode();
3403 textboxEl.addKeyListener([10,13], function(){
3404 if(dlg.isVisible() && opt && opt.buttons){
3407 }else if(opt.buttons.yes){
3408 handleButton("yes");
3412 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3413 textareaEl.enableDisplayMode();
3414 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3415 progressEl.enableDisplayMode();
3417 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3418 var pf = progressEl.dom.firstChild;
3420 pp = Roo.get(pf.firstChild);
3421 pp.setHeight(pf.offsetHeight);
3429 * Updates the message box body text
3430 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3431 * the XHTML-compliant non-breaking space character '&#160;')
3432 * @return {Roo.MessageBox} This message box
3434 updateText : function(text)
3436 if(!dlg.isVisible() && !opt.width){
3437 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3438 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3440 msgEl.innerHTML = text || ' ';
3442 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3443 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3445 Math.min(opt.width || cw , this.maxWidth),
3446 Math.max(opt.minWidth || this.minWidth, bwidth)
3449 activeTextEl.setWidth(w);
3451 if(dlg.isVisible()){
3452 dlg.fixedcenter = false;
3454 // to big, make it scroll. = But as usual stupid IE does not support
3457 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3458 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3459 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3461 bodyEl.dom.style.height = '';
3462 bodyEl.dom.style.overflowY = '';
3465 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3467 bodyEl.dom.style.overflowX = '';
3470 dlg.setContentSize(w, bodyEl.getHeight());
3471 if(dlg.isVisible()){
3472 dlg.fixedcenter = true;
3478 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3479 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3480 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3481 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3482 * @return {Roo.MessageBox} This message box
3484 updateProgress : function(value, text){
3486 this.updateText(text);
3489 if (pp) { // weird bug on my firefox - for some reason this is not defined
3490 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3491 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3497 * Returns true if the message box is currently displayed
3498 * @return {Boolean} True if the message box is visible, else false
3500 isVisible : function(){
3501 return dlg && dlg.isVisible();
3505 * Hides the message box if it is displayed
3508 if(this.isVisible()){
3514 * Displays a new message box, or reinitializes an existing message box, based on the config options
3515 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3516 * The following config object properties are supported:
3518 Property Type Description
3519 ---------- --------------- ------------------------------------------------------------------------------------
3520 animEl String/Element An id or Element from which the message box should animate as it opens and
3521 closes (defaults to undefined)
3522 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3523 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3524 closable Boolean False to hide the top-right close button (defaults to true). Note that
3525 progress and wait dialogs will ignore this property and always hide the
3526 close button as they can only be closed programmatically.
3527 cls String A custom CSS class to apply to the message box element
3528 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3529 displayed (defaults to 75)
3530 fn Function A callback function to execute after closing the dialog. The arguments to the
3531 function will be btn (the name of the button that was clicked, if applicable,
3532 e.g. "ok"), and text (the value of the active text field, if applicable).
3533 Progress and wait dialogs will ignore this option since they do not respond to
3534 user actions and can only be closed programmatically, so any required function
3535 should be called by the same code after it closes the dialog.
3536 icon String A CSS class that provides a background image to be used as an icon for
3537 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3538 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3539 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3540 modal Boolean False to allow user interaction with the page while the message box is
3541 displayed (defaults to true)
3542 msg String A string that will replace the existing message box body text (defaults
3543 to the XHTML-compliant non-breaking space character ' ')
3544 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3545 progress Boolean True to display a progress bar (defaults to false)
3546 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3547 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3548 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3549 title String The title text
3550 value String The string value to set into the active textbox element if displayed
3551 wait Boolean True to display a progress bar (defaults to false)
3552 width Number The width of the dialog in pixels
3559 msg: 'Please enter your address:',
3561 buttons: Roo.MessageBox.OKCANCEL,
3564 animEl: 'addAddressBtn'
3567 * @param {Object} config Configuration options
3568 * @return {Roo.MessageBox} This message box
3570 show : function(options)
3573 // this causes nightmares if you show one dialog after another
3574 // especially on callbacks..
3576 if(this.isVisible()){
3579 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3580 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3581 Roo.log("New Dialog Message:" + options.msg )
3582 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3583 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3586 var d = this.getDialog();
3588 d.setTitle(opt.title || " ");
3589 d.closeEl.setDisplayed(opt.closable !== false);
3590 activeTextEl = textboxEl;
3591 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3596 textareaEl.setHeight(typeof opt.multiline == "number" ?
3597 opt.multiline : this.defaultTextHeight);
3598 activeTextEl = textareaEl;
3607 progressEl.setDisplayed(opt.progress === true);
3609 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3611 this.updateProgress(0);
3612 activeTextEl.dom.value = opt.value || "";
3614 dlg.setDefaultButton(activeTextEl);
3616 var bs = opt.buttons;
3620 }else if(bs && bs.yes){
3621 db = buttons["yes"];
3623 dlg.setDefaultButton(db);
3625 bwidth = updateButtons(opt.buttons);
3626 this.updateText(opt.msg);
3628 d.el.addClass(opt.cls);
3630 d.proxyDrag = opt.proxyDrag === true;
3631 d.modal = opt.modal !== false;
3632 d.mask = opt.modal !== false ? mask : false;
3634 // force it to the end of the z-index stack so it gets a cursor in FF
3635 document.body.appendChild(dlg.el.dom);
3636 d.animateTarget = null;
3637 d.show(options.animEl);
3643 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3644 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3645 * and closing the message box when the process is complete.
3646 * @param {String} title The title bar text
3647 * @param {String} msg The message box body text
3648 * @return {Roo.MessageBox} This message box
3650 progress : function(title, msg){
3657 minWidth: this.minProgressWidth,
3664 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3665 * If a callback function is passed it will be called after the user clicks the button, and the
3666 * id of the button that was clicked will be passed as the only parameter to the callback
3667 * (could also be the top-right close button).
3668 * @param {String} title The title bar text
3669 * @param {String} msg The message box body text
3670 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3671 * @param {Object} scope (optional) The scope of the callback function
3672 * @return {Roo.MessageBox} This message box
3674 alert : function(title, msg, fn, scope)
3689 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3690 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3691 * You are responsible for closing the message box when the process is complete.
3692 * @param {String} msg The message box body text
3693 * @param {String} title (optional) The title bar text
3694 * @return {Roo.MessageBox} This message box
3696 wait : function(msg, title){
3707 waitTimer = Roo.TaskMgr.start({
3709 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3717 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3718 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3719 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3720 * @param {String} title The title bar text
3721 * @param {String} msg The message box body text
3722 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3723 * @param {Object} scope (optional) The scope of the callback function
3724 * @return {Roo.MessageBox} This message box
3726 confirm : function(title, msg, fn, scope){
3730 buttons: this.YESNO,
3739 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3740 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3741 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3742 * (could also be the top-right close button) and the text that was entered will be passed as the two
3743 * parameters to the callback.
3744 * @param {String} title The title bar text
3745 * @param {String} msg The message box body text
3746 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3747 * @param {Object} scope (optional) The scope of the callback function
3748 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3749 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3750 * @return {Roo.MessageBox} This message box
3752 prompt : function(title, msg, fn, scope, multiline){
3756 buttons: this.OKCANCEL,
3761 multiline: multiline,
3768 * Button config that displays a single OK button
3773 * Button config that displays Yes and No buttons
3776 YESNO : {yes:true, no:true},
3778 * Button config that displays OK and Cancel buttons
3781 OKCANCEL : {ok:true, cancel:true},
3783 * Button config that displays Yes, No and Cancel buttons
3786 YESNOCANCEL : {yes:true, no:true, cancel:true},
3789 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3792 defaultTextHeight : 75,
3794 * The maximum width in pixels of the message box (defaults to 600)
3799 * The minimum width in pixels of the message box (defaults to 100)
3804 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3805 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3808 minProgressWidth : 250,
3810 * An object containing the default button text strings that can be overriden for localized language support.
3811 * Supported properties are: ok, cancel, yes and no.
3812 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3825 * Shorthand for {@link Roo.MessageBox}
3827 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3828 Roo.Msg = Roo.Msg || Roo.MessageBox;
3837 * @class Roo.bootstrap.Navbar
3838 * @extends Roo.bootstrap.Component
3839 * Bootstrap Navbar class
3842 * Create a new Navbar
3843 * @param {Object} config The config object
3847 Roo.bootstrap.Navbar = function(config){
3848 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3852 * @event beforetoggle
3853 * Fire before toggle the menu
3854 * @param {Roo.EventObject} e
3856 "beforetoggle" : true
3860 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3869 getAutoCreate : function(){
3872 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3876 initEvents :function ()
3878 //Roo.log(this.el.select('.navbar-toggle',true));
3879 this.el.select('.navbar-toggle',true).on('click', function() {
3880 if(this.fireEvent('beforetoggle', this) !== false){
3881 var ce = this.el.select('.navbar-collapse',true).first();
3882 ce.toggleClass('in'); // old...
3883 if (ce.hasClass('collapse')) {
3885 ce.removeClass('collapse');
3886 ce.addClass('show');
3887 var h = ce.getHeight();
3889 ce.removeClass('show');
3890 // at this point we should be able to see it..
3891 ce.addClass('collapsing');
3893 ce.setHeight(0); // resize it ...
3894 ce.on('transitionend', function() {
3895 Roo.log('done transition');
3896 ce.removeClass('collapsing');
3897 ce.addClass('show');
3898 ce.removeClass('collapse');
3900 ce.dom.style.height = '';
3901 }, this, { single: true} );
3905 ce.setHeight(ce.getHeight());
3906 ce.removeClass('show');
3907 ce.addClass('collapsing');
3909 ce.on('transitionend', function() {
3910 ce.dom.style.height = '';
3911 ce.removeClass('collapsing');
3912 ce.addClass('collapse');
3913 }, this, { single: true} );
3925 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3927 var size = this.el.getSize();
3928 this.maskEl.setSize(size.width, size.height);
3929 this.maskEl.enableDisplayMode("block");
3938 getChildContainer : function()
3940 if (this.el.select('.collapse').getCount()) {
3941 return this.el.select('.collapse',true).first();
3974 * @class Roo.bootstrap.NavSimplebar
3975 * @extends Roo.bootstrap.Navbar
3976 * Bootstrap Sidebar class
3978 * @cfg {Boolean} inverse is inverted color
3980 * @cfg {String} type (nav | pills | tabs)
3981 * @cfg {Boolean} arrangement stacked | justified
3982 * @cfg {String} align (left | right) alignment
3984 * @cfg {Boolean} main (true|false) main nav bar? default false
3985 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3987 * @cfg {String} tag (header|footer|nav|div) default is nav
3989 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
3993 * Create a new Sidebar
3994 * @param {Object} config The config object
3998 Roo.bootstrap.NavSimplebar = function(config){
3999 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4002 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4018 getAutoCreate : function(){
4022 tag : this.tag || 'div',
4023 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4025 if (['light','white'].indexOf(this.weight) > -1) {
4026 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4028 cfg.cls += ' bg-' + this.weight;
4031 cfg.cls += ' navbar-inverse';
4035 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4037 //if (Roo.bootstrap.version == 4) {
4049 this.type = this.type || 'nav';
4050 if (['tabs','pills'].indexOf(this.type) != -1) {
4051 cfg.cn[0].cls += ' nav-' + this.type
4055 if (this.type!=='nav') {
4056 Roo.log('nav type must be nav/tabs/pills')
4058 cfg.cn[0].cls += ' navbar-nav'
4064 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4065 cfg.cn[0].cls += ' nav-' + this.arrangement;
4069 if (this.align === 'right') {
4070 cfg.cn[0].cls += ' navbar-right';
4095 * navbar-expand-md fixed-top
4099 * @class Roo.bootstrap.NavHeaderbar
4100 * @extends Roo.bootstrap.NavSimplebar
4101 * Bootstrap Sidebar class
4103 * @cfg {String} brand what is brand
4104 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4105 * @cfg {String} brand_href href of the brand
4106 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4107 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4108 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4109 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4112 * Create a new Sidebar
4113 * @param {Object} config The config object
4117 Roo.bootstrap.NavHeaderbar = function(config){
4118 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4122 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4129 desktopCenter : false,
4132 getAutoCreate : function(){
4135 tag: this.nav || 'nav',
4136 cls: 'navbar navbar-expand-md',
4142 if (this.desktopCenter) {
4143 cn.push({cls : 'container', cn : []});
4151 cls: 'navbar-toggle navbar-toggler',
4152 'data-toggle': 'collapse',
4157 html: 'Toggle navigation'
4161 cls: 'icon-bar navbar-toggler-icon'
4174 cn.push( Roo.bootstrap.version == 4 ? btn : {
4176 cls: 'navbar-header',
4185 cls: 'collapse navbar-collapse',
4189 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4191 if (['light','white'].indexOf(this.weight) > -1) {
4192 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4194 cfg.cls += ' bg-' + this.weight;
4197 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4198 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4200 // tag can override this..
4202 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4205 if (this.brand !== '') {
4206 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4207 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4209 href: this.brand_href ? this.brand_href : '#',
4210 cls: 'navbar-brand',
4218 cfg.cls += ' main-nav';
4226 getHeaderChildContainer : function()
4228 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4229 return this.el.select('.navbar-header',true).first();
4232 return this.getChildContainer();
4236 initEvents : function()
4238 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4240 if (this.autohide) {
4245 Roo.get(document).on('scroll',function(e) {
4246 var ns = Roo.get(document).getScroll().top;
4247 var os = prevScroll;
4251 ft.removeClass('slideDown');
4252 ft.addClass('slideUp');
4255 ft.removeClass('slideUp');
4256 ft.addClass('slideDown');
4277 * @class Roo.bootstrap.NavSidebar
4278 * @extends Roo.bootstrap.Navbar
4279 * Bootstrap Sidebar class
4282 * Create a new Sidebar
4283 * @param {Object} config The config object
4287 Roo.bootstrap.NavSidebar = function(config){
4288 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4291 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4293 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4295 getAutoCreate : function(){
4300 cls: 'sidebar sidebar-nav'
4322 * @class Roo.bootstrap.NavGroup
4323 * @extends Roo.bootstrap.Component
4324 * Bootstrap NavGroup class
4325 * @cfg {String} align (left|right)
4326 * @cfg {Boolean} inverse
4327 * @cfg {String} type (nav|pills|tab) default nav
4328 * @cfg {String} navId - reference Id for navbar.
4332 * Create a new nav group
4333 * @param {Object} config The config object
4336 Roo.bootstrap.NavGroup = function(config){
4337 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4340 Roo.bootstrap.NavGroup.register(this);
4344 * Fires when the active item changes
4345 * @param {Roo.bootstrap.NavGroup} this
4346 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4347 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4354 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4365 getAutoCreate : function()
4367 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4373 if (Roo.bootstrap.version == 4) {
4374 if (['tabs','pills'].indexOf(this.type) != -1) {
4375 cfg.cls += ' nav-' + this.type;
4377 cfg.cls += ' navbar-nav';
4380 if (['tabs','pills'].indexOf(this.type) != -1) {
4381 cfg.cls += ' nav-' + this.type
4383 if (this.type !== 'nav') {
4384 Roo.log('nav type must be nav/tabs/pills')
4386 cfg.cls += ' navbar-nav'
4390 if (this.parent() && this.parent().sidebar) {
4393 cls: 'dashboard-menu sidebar-menu'
4399 if (this.form === true) {
4402 cls: 'navbar-form form-inline'
4405 if (this.align === 'right') {
4406 cfg.cls += ' navbar-right ml-md-auto';
4408 cfg.cls += ' navbar-left';
4412 if (this.align === 'right') {
4413 cfg.cls += ' navbar-right ml-md-auto';
4415 cfg.cls += ' mr-auto';
4419 cfg.cls += ' navbar-inverse';
4427 * sets the active Navigation item
4428 * @param {Roo.bootstrap.NavItem} the new current navitem
4430 setActiveItem : function(item)
4433 Roo.each(this.navItems, function(v){
4438 v.setActive(false, true);
4445 item.setActive(true, true);
4446 this.fireEvent('changed', this, item, prev);
4451 * gets the active Navigation item
4452 * @return {Roo.bootstrap.NavItem} the current navitem
4454 getActive : function()
4458 Roo.each(this.navItems, function(v){
4469 indexOfNav : function()
4473 Roo.each(this.navItems, function(v,i){
4484 * adds a Navigation item
4485 * @param {Roo.bootstrap.NavItem} the navitem to add
4487 addItem : function(cfg)
4489 if (this.form && Roo.bootstrap.version == 4) {
4492 var cn = new Roo.bootstrap.NavItem(cfg);
4494 cn.parentId = this.id;
4495 cn.onRender(this.el, null);
4499 * register a Navigation item
4500 * @param {Roo.bootstrap.NavItem} the navitem to add
4502 register : function(item)
4504 this.navItems.push( item);
4505 item.navId = this.navId;
4510 * clear all the Navigation item
4513 clearAll : function()
4516 this.el.dom.innerHTML = '';
4519 getNavItem: function(tabId)
4522 Roo.each(this.navItems, function(e) {
4523 if (e.tabId == tabId) {
4533 setActiveNext : function()
4535 var i = this.indexOfNav(this.getActive());
4536 if (i > this.navItems.length) {
4539 this.setActiveItem(this.navItems[i+1]);
4541 setActivePrev : function()
4543 var i = this.indexOfNav(this.getActive());
4547 this.setActiveItem(this.navItems[i-1]);
4549 clearWasActive : function(except) {
4550 Roo.each(this.navItems, function(e) {
4551 if (e.tabId != except.tabId && e.was_active) {
4552 e.was_active = false;
4559 getWasActive : function ()
4562 Roo.each(this.navItems, function(e) {
4577 Roo.apply(Roo.bootstrap.NavGroup, {
4581 * register a Navigation Group
4582 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4584 register : function(navgrp)
4586 this.groups[navgrp.navId] = navgrp;
4590 * fetch a Navigation Group based on the navigation ID
4591 * @param {string} the navgroup to add
4592 * @returns {Roo.bootstrap.NavGroup} the navgroup
4594 get: function(navId) {
4595 if (typeof(this.groups[navId]) == 'undefined') {
4597 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4599 return this.groups[navId] ;
4614 * @class Roo.bootstrap.NavItem
4615 * @extends Roo.bootstrap.Component
4616 * Bootstrap Navbar.NavItem class
4617 * @cfg {String} href link to
4618 * @cfg {String} html content of button
4619 * @cfg {String} badge text inside badge
4620 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4621 * @cfg {String} glyphicon DEPRICATED - use fa
4622 * @cfg {String} icon DEPRICATED - use fa
4623 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4624 * @cfg {Boolean} active Is item active
4625 * @cfg {Boolean} disabled Is item disabled
4627 * @cfg {Boolean} preventDefault (true | false) default false
4628 * @cfg {String} tabId the tab that this item activates.
4629 * @cfg {String} tagtype (a|span) render as a href or span?
4630 * @cfg {Boolean} animateRef (true|false) link to element default false
4633 * Create a new Navbar Item
4634 * @param {Object} config The config object
4636 Roo.bootstrap.NavItem = function(config){
4637 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4642 * The raw click event for the entire grid.
4643 * @param {Roo.EventObject} e
4648 * Fires when the active item active state changes
4649 * @param {Roo.bootstrap.NavItem} this
4650 * @param {boolean} state the new state
4656 * Fires when scroll to element
4657 * @param {Roo.bootstrap.NavItem} this
4658 * @param {Object} options
4659 * @param {Roo.EventObject} e
4667 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4676 preventDefault : false,
4686 getAutoCreate : function(){
4695 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4697 if (this.disabled) {
4698 cfg.cls += ' disabled';
4701 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4705 href : this.href || "#",
4706 html: this.html || ''
4709 if (this.tagtype == 'a') {
4710 cfg.cn[0].cls = 'nav-link';
4713 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4716 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>'
4718 if(this.glyphicon) {
4719 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4724 cfg.cn[0].html += " <span class='caret'></span>";
4728 if (this.badge !== '') {
4730 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4738 onRender : function(ct, position)
4740 // Roo.log("Call onRender: " + this.xtype);
4741 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4745 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4746 this.navLink = this.el.select('.nav-link',true).first();
4751 initEvents: function()
4753 if (typeof (this.menu) != 'undefined') {
4754 this.menu.parentType = this.xtype;
4755 this.menu.triggerEl = this.el;
4756 this.menu = this.addxtype(Roo.apply({}, this.menu));
4759 this.el.select('a',true).on('click', this.onClick, this);
4761 if(this.tagtype == 'span'){
4762 this.el.select('span',true).on('click', this.onClick, this);
4765 // at this point parent should be available..
4766 this.parent().register(this);
4769 onClick : function(e)
4771 if (e.getTarget('.dropdown-menu-item')) {
4772 // did you click on a menu itemm.... - then don't trigger onclick..
4777 this.preventDefault ||
4780 Roo.log("NavItem - prevent Default?");
4784 if (this.disabled) {
4788 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4789 if (tg && tg.transition) {
4790 Roo.log("waiting for the transitionend");
4796 //Roo.log("fire event clicked");
4797 if(this.fireEvent('click', this, e) === false){
4801 if(this.tagtype == 'span'){
4805 //Roo.log(this.href);
4806 var ael = this.el.select('a',true).first();
4809 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4810 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4811 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4812 return; // ignore... - it's a 'hash' to another page.
4814 Roo.log("NavItem - prevent Default?");
4816 this.scrollToElement(e);
4820 var p = this.parent();
4822 if (['tabs','pills'].indexOf(p.type)!==-1) {
4823 if (typeof(p.setActiveItem) !== 'undefined') {
4824 p.setActiveItem(this);
4828 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4829 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4830 // remove the collapsed menu expand...
4831 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4835 isActive: function () {
4838 setActive : function(state, fire, is_was_active)
4840 if (this.active && !state && this.navId) {
4841 this.was_active = true;
4842 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4844 nv.clearWasActive(this);
4848 this.active = state;
4851 this.el.removeClass('active');
4852 this.navLink ? this.navLink.removeClass('active') : false;
4853 } else if (!this.el.hasClass('active')) {
4855 this.el.addClass('active');
4856 if (Roo.bootstrap.version == 4 && this.navLink ) {
4857 this.navLink.addClass('active');
4862 this.fireEvent('changed', this, state);
4865 // show a panel if it's registered and related..
4867 if (!this.navId || !this.tabId || !state || is_was_active) {
4871 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4875 var pan = tg.getPanelByName(this.tabId);
4879 // if we can not flip to new panel - go back to old nav highlight..
4880 if (false == tg.showPanel(pan)) {
4881 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4883 var onav = nv.getWasActive();
4885 onav.setActive(true, false, true);
4894 // this should not be here...
4895 setDisabled : function(state)
4897 this.disabled = state;
4899 this.el.removeClass('disabled');
4900 } else if (!this.el.hasClass('disabled')) {
4901 this.el.addClass('disabled');
4907 * Fetch the element to display the tooltip on.
4908 * @return {Roo.Element} defaults to this.el
4910 tooltipEl : function()
4912 return this.el.select('' + this.tagtype + '', true).first();
4915 scrollToElement : function(e)
4917 var c = document.body;
4920 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4922 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4923 c = document.documentElement;
4926 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4932 var o = target.calcOffsetsTo(c);
4939 this.fireEvent('scrollto', this, options, e);
4941 Roo.get(c).scrollTo('top', options.value, true);
4954 * <span> icon </span>
4955 * <span> text </span>
4956 * <span>badge </span>
4960 * @class Roo.bootstrap.NavSidebarItem
4961 * @extends Roo.bootstrap.NavItem
4962 * Bootstrap Navbar.NavSidebarItem class
4963 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4964 * {Boolean} open is the menu open
4965 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4966 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4967 * {String} buttonSize (sm|md|lg)the extra classes for the button
4968 * {Boolean} showArrow show arrow next to the text (default true)
4970 * Create a new Navbar Button
4971 * @param {Object} config The config object
4973 Roo.bootstrap.NavSidebarItem = function(config){
4974 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4979 * The raw click event for the entire grid.
4980 * @param {Roo.EventObject} e
4985 * Fires when the active item active state changes
4986 * @param {Roo.bootstrap.NavSidebarItem} this
4987 * @param {boolean} state the new state
4995 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4997 badgeWeight : 'default',
5003 buttonWeight : 'default',
5009 getAutoCreate : function(){
5014 href : this.href || '#',
5020 if(this.buttonView){
5023 href : this.href || '#',
5024 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5037 cfg.cls += ' active';
5040 if (this.disabled) {
5041 cfg.cls += ' disabled';
5044 cfg.cls += ' open x-open';
5047 if (this.glyphicon || this.icon) {
5048 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5049 a.cn.push({ tag : 'i', cls : c }) ;
5052 if(!this.buttonView){
5055 html : this.html || ''
5062 if (this.badge !== '') {
5063 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5069 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5072 a.cls += ' dropdown-toggle treeview' ;
5078 initEvents : function()
5080 if (typeof (this.menu) != 'undefined') {
5081 this.menu.parentType = this.xtype;
5082 this.menu.triggerEl = this.el;
5083 this.menu = this.addxtype(Roo.apply({}, this.menu));
5086 this.el.on('click', this.onClick, this);
5088 if(this.badge !== ''){
5089 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5094 onClick : function(e)
5101 if(this.preventDefault){
5105 this.fireEvent('click', this);
5108 disable : function()
5110 this.setDisabled(true);
5115 this.setDisabled(false);
5118 setDisabled : function(state)
5120 if(this.disabled == state){
5124 this.disabled = state;
5127 this.el.addClass('disabled');
5131 this.el.removeClass('disabled');
5136 setActive : function(state)
5138 if(this.active == state){
5142 this.active = state;
5145 this.el.addClass('active');
5149 this.el.removeClass('active');
5154 isActive: function ()
5159 setBadge : function(str)
5165 this.badgeEl.dom.innerHTML = str;
5182 * @class Roo.bootstrap.Row
5183 * @extends Roo.bootstrap.Component
5184 * Bootstrap Row class (contains columns...)
5188 * @param {Object} config The config object
5191 Roo.bootstrap.Row = function(config){
5192 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5195 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5197 getAutoCreate : function(){
5216 * @class Roo.bootstrap.Element
5217 * @extends Roo.bootstrap.Component
5218 * Bootstrap Element class
5219 * @cfg {String} html contents of the element
5220 * @cfg {String} tag tag of the element
5221 * @cfg {String} cls class of the element
5222 * @cfg {Boolean} preventDefault (true|false) default false
5223 * @cfg {Boolean} clickable (true|false) default false
5226 * Create a new Element
5227 * @param {Object} config The config object
5230 Roo.bootstrap.Element = function(config){
5231 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5237 * When a element is chick
5238 * @param {Roo.bootstrap.Element} this
5239 * @param {Roo.EventObject} e
5245 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5250 preventDefault: false,
5253 getAutoCreate : function(){
5257 // cls: this.cls, double assign in parent class Component.js :: onRender
5264 initEvents: function()
5266 Roo.bootstrap.Element.superclass.initEvents.call(this);
5269 this.el.on('click', this.onClick, this);
5274 onClick : function(e)
5276 if(this.preventDefault){
5280 this.fireEvent('click', this, e);
5283 getValue : function()
5285 return this.el.dom.innerHTML;
5288 setValue : function(value)
5290 this.el.dom.innerHTML = value;
5305 * @class Roo.bootstrap.Pagination
5306 * @extends Roo.bootstrap.Component
5307 * Bootstrap Pagination class
5308 * @cfg {String} size xs | sm | md | lg
5309 * @cfg {Boolean} inverse false | true
5312 * Create a new Pagination
5313 * @param {Object} config The config object
5316 Roo.bootstrap.Pagination = function(config){
5317 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5320 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5326 getAutoCreate : function(){
5332 cfg.cls += ' inverse';
5338 cfg.cls += " " + this.cls;
5356 * @class Roo.bootstrap.PaginationItem
5357 * @extends Roo.bootstrap.Component
5358 * Bootstrap PaginationItem class
5359 * @cfg {String} html text
5360 * @cfg {String} href the link
5361 * @cfg {Boolean} preventDefault (true | false) default true
5362 * @cfg {Boolean} active (true | false) default false
5363 * @cfg {Boolean} disabled default false
5367 * Create a new PaginationItem
5368 * @param {Object} config The config object
5372 Roo.bootstrap.PaginationItem = function(config){
5373 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5378 * The raw click event for the entire grid.
5379 * @param {Roo.EventObject} e
5385 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5389 preventDefault: true,
5394 getAutoCreate : function(){
5400 href : this.href ? this.href : '#',
5401 html : this.html ? this.html : ''
5411 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5415 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5421 initEvents: function() {
5423 this.el.on('click', this.onClick, this);
5426 onClick : function(e)
5428 Roo.log('PaginationItem on click ');
5429 if(this.preventDefault){
5437 this.fireEvent('click', this, e);
5453 * @class Roo.bootstrap.Slider
5454 * @extends Roo.bootstrap.Component
5455 * Bootstrap Slider class
5458 * Create a new Slider
5459 * @param {Object} config The config object
5462 Roo.bootstrap.Slider = function(config){
5463 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5466 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5468 getAutoCreate : function(){
5472 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5476 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5488 * Ext JS Library 1.1.1
5489 * Copyright(c) 2006-2007, Ext JS, LLC.
5491 * Originally Released Under LGPL - original licence link has changed is not relivant.
5494 * <script type="text/javascript">
5499 * @class Roo.grid.ColumnModel
5500 * @extends Roo.util.Observable
5501 * This is the default implementation of a ColumnModel used by the Grid. It defines
5502 * the columns in the grid.
5505 var colModel = new Roo.grid.ColumnModel([
5506 {header: "Ticker", width: 60, sortable: true, locked: true},
5507 {header: "Company Name", width: 150, sortable: true},
5508 {header: "Market Cap.", width: 100, sortable: true},
5509 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5510 {header: "Employees", width: 100, sortable: true, resizable: false}
5515 * The config options listed for this class are options which may appear in each
5516 * individual column definition.
5517 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5519 * @param {Object} config An Array of column config objects. See this class's
5520 * config objects for details.
5522 Roo.grid.ColumnModel = function(config){
5524 * The config passed into the constructor
5526 this.config = config;
5529 // if no id, create one
5530 // if the column does not have a dataIndex mapping,
5531 // map it to the order it is in the config
5532 for(var i = 0, len = config.length; i < len; i++){
5534 if(typeof c.dataIndex == "undefined"){
5537 if(typeof c.renderer == "string"){
5538 c.renderer = Roo.util.Format[c.renderer];
5540 if(typeof c.id == "undefined"){
5543 if(c.editor && c.editor.xtype){
5544 c.editor = Roo.factory(c.editor, Roo.grid);
5546 if(c.editor && c.editor.isFormField){
5547 c.editor = new Roo.grid.GridEditor(c.editor);
5549 this.lookup[c.id] = c;
5553 * The width of columns which have no width specified (defaults to 100)
5556 this.defaultWidth = 100;
5559 * Default sortable of columns which have no sortable specified (defaults to false)
5562 this.defaultSortable = false;
5566 * @event widthchange
5567 * Fires when the width of a column changes.
5568 * @param {ColumnModel} this
5569 * @param {Number} columnIndex The column index
5570 * @param {Number} newWidth The new width
5572 "widthchange": true,
5574 * @event headerchange
5575 * Fires when the text of a header changes.
5576 * @param {ColumnModel} this
5577 * @param {Number} columnIndex The column index
5578 * @param {Number} newText The new header text
5580 "headerchange": true,
5582 * @event hiddenchange
5583 * Fires when a column is hidden or "unhidden".
5584 * @param {ColumnModel} this
5585 * @param {Number} columnIndex The column index
5586 * @param {Boolean} hidden true if hidden, false otherwise
5588 "hiddenchange": true,
5590 * @event columnmoved
5591 * Fires when a column is moved.
5592 * @param {ColumnModel} this
5593 * @param {Number} oldIndex
5594 * @param {Number} newIndex
5596 "columnmoved" : true,
5598 * @event columlockchange
5599 * Fires when a column's locked state is changed
5600 * @param {ColumnModel} this
5601 * @param {Number} colIndex
5602 * @param {Boolean} locked true if locked
5604 "columnlockchange" : true
5606 Roo.grid.ColumnModel.superclass.constructor.call(this);
5608 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5610 * @cfg {String} header The header text to display in the Grid view.
5613 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5614 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5615 * specified, the column's index is used as an index into the Record's data Array.
5618 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5619 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5622 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5623 * Defaults to the value of the {@link #defaultSortable} property.
5624 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5627 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5630 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5633 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5636 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5639 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5640 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5641 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5642 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5645 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5648 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5651 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5654 * @cfg {String} cursor (Optional)
5657 * @cfg {String} tooltip (Optional)
5660 * @cfg {Number} xs (Optional)
5663 * @cfg {Number} sm (Optional)
5666 * @cfg {Number} md (Optional)
5669 * @cfg {Number} lg (Optional)
5672 * Returns the id of the column at the specified index.
5673 * @param {Number} index The column index
5674 * @return {String} the id
5676 getColumnId : function(index){
5677 return this.config[index].id;
5681 * Returns the column for a specified id.
5682 * @param {String} id The column id
5683 * @return {Object} the column
5685 getColumnById : function(id){
5686 return this.lookup[id];
5691 * Returns the column for a specified dataIndex.
5692 * @param {String} dataIndex The column dataIndex
5693 * @return {Object|Boolean} the column or false if not found
5695 getColumnByDataIndex: function(dataIndex){
5696 var index = this.findColumnIndex(dataIndex);
5697 return index > -1 ? this.config[index] : false;
5701 * Returns the index for a specified column id.
5702 * @param {String} id The column id
5703 * @return {Number} the index, or -1 if not found
5705 getIndexById : function(id){
5706 for(var i = 0, len = this.config.length; i < len; i++){
5707 if(this.config[i].id == id){
5715 * Returns the index for a specified column dataIndex.
5716 * @param {String} dataIndex The column dataIndex
5717 * @return {Number} the index, or -1 if not found
5720 findColumnIndex : function(dataIndex){
5721 for(var i = 0, len = this.config.length; i < len; i++){
5722 if(this.config[i].dataIndex == dataIndex){
5730 moveColumn : function(oldIndex, newIndex){
5731 var c = this.config[oldIndex];
5732 this.config.splice(oldIndex, 1);
5733 this.config.splice(newIndex, 0, c);
5734 this.dataMap = null;
5735 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5738 isLocked : function(colIndex){
5739 return this.config[colIndex].locked === true;
5742 setLocked : function(colIndex, value, suppressEvent){
5743 if(this.isLocked(colIndex) == value){
5746 this.config[colIndex].locked = value;
5748 this.fireEvent("columnlockchange", this, colIndex, value);
5752 getTotalLockedWidth : function(){
5754 for(var i = 0; i < this.config.length; i++){
5755 if(this.isLocked(i) && !this.isHidden(i)){
5756 this.totalWidth += this.getColumnWidth(i);
5762 getLockedCount : function(){
5763 for(var i = 0, len = this.config.length; i < len; i++){
5764 if(!this.isLocked(i)){
5769 return this.config.length;
5773 * Returns the number of columns.
5776 getColumnCount : function(visibleOnly){
5777 if(visibleOnly === true){
5779 for(var i = 0, len = this.config.length; i < len; i++){
5780 if(!this.isHidden(i)){
5786 return this.config.length;
5790 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5791 * @param {Function} fn
5792 * @param {Object} scope (optional)
5793 * @return {Array} result
5795 getColumnsBy : function(fn, scope){
5797 for(var i = 0, len = this.config.length; i < len; i++){
5798 var c = this.config[i];
5799 if(fn.call(scope||this, c, i) === true){
5807 * Returns true if the specified column is sortable.
5808 * @param {Number} col The column index
5811 isSortable : function(col){
5812 if(typeof this.config[col].sortable == "undefined"){
5813 return this.defaultSortable;
5815 return this.config[col].sortable;
5819 * Returns the rendering (formatting) function defined for the column.
5820 * @param {Number} col The column index.
5821 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5823 getRenderer : function(col){
5824 if(!this.config[col].renderer){
5825 return Roo.grid.ColumnModel.defaultRenderer;
5827 return this.config[col].renderer;
5831 * Sets the rendering (formatting) function for a column.
5832 * @param {Number} col The column index
5833 * @param {Function} fn The function to use to process the cell's raw data
5834 * to return HTML markup for the grid view. The render function is called with
5835 * the following parameters:<ul>
5836 * <li>Data value.</li>
5837 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5838 * <li>css A CSS style string to apply to the table cell.</li>
5839 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5840 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5841 * <li>Row index</li>
5842 * <li>Column index</li>
5843 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5845 setRenderer : function(col, fn){
5846 this.config[col].renderer = fn;
5850 * Returns the width for the specified column.
5851 * @param {Number} col The column index
5854 getColumnWidth : function(col){
5855 return this.config[col].width * 1 || this.defaultWidth;
5859 * Sets the width for a column.
5860 * @param {Number} col The column index
5861 * @param {Number} width The new width
5863 setColumnWidth : function(col, width, suppressEvent){
5864 this.config[col].width = width;
5865 this.totalWidth = null;
5867 this.fireEvent("widthchange", this, col, width);
5872 * Returns the total width of all columns.
5873 * @param {Boolean} includeHidden True to include hidden column widths
5876 getTotalWidth : function(includeHidden){
5877 if(!this.totalWidth){
5878 this.totalWidth = 0;
5879 for(var i = 0, len = this.config.length; i < len; i++){
5880 if(includeHidden || !this.isHidden(i)){
5881 this.totalWidth += this.getColumnWidth(i);
5885 return this.totalWidth;
5889 * Returns the header for the specified column.
5890 * @param {Number} col The column index
5893 getColumnHeader : function(col){
5894 return this.config[col].header;
5898 * Sets the header for a column.
5899 * @param {Number} col The column index
5900 * @param {String} header The new header
5902 setColumnHeader : function(col, header){
5903 this.config[col].header = header;
5904 this.fireEvent("headerchange", this, col, header);
5908 * Returns the tooltip for the specified column.
5909 * @param {Number} col The column index
5912 getColumnTooltip : function(col){
5913 return this.config[col].tooltip;
5916 * Sets the tooltip for a column.
5917 * @param {Number} col The column index
5918 * @param {String} tooltip The new tooltip
5920 setColumnTooltip : function(col, tooltip){
5921 this.config[col].tooltip = tooltip;
5925 * Returns the dataIndex for the specified column.
5926 * @param {Number} col The column index
5929 getDataIndex : function(col){
5930 return this.config[col].dataIndex;
5934 * Sets the dataIndex for a column.
5935 * @param {Number} col The column index
5936 * @param {Number} dataIndex The new dataIndex
5938 setDataIndex : function(col, dataIndex){
5939 this.config[col].dataIndex = dataIndex;
5945 * Returns true if the cell is editable.
5946 * @param {Number} colIndex The column index
5947 * @param {Number} rowIndex The row index - this is nto actually used..?
5950 isCellEditable : function(colIndex, rowIndex){
5951 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5955 * Returns the editor defined for the cell/column.
5956 * return false or null to disable editing.
5957 * @param {Number} colIndex The column index
5958 * @param {Number} rowIndex The row index
5961 getCellEditor : function(colIndex, rowIndex){
5962 return this.config[colIndex].editor;
5966 * Sets if a column is editable.
5967 * @param {Number} col The column index
5968 * @param {Boolean} editable True if the column is editable
5970 setEditable : function(col, editable){
5971 this.config[col].editable = editable;
5976 * Returns true if the column is hidden.
5977 * @param {Number} colIndex The column index
5980 isHidden : function(colIndex){
5981 return this.config[colIndex].hidden;
5986 * Returns true if the column width cannot be changed
5988 isFixed : function(colIndex){
5989 return this.config[colIndex].fixed;
5993 * Returns true if the column can be resized
5996 isResizable : function(colIndex){
5997 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6000 * Sets if a column is hidden.
6001 * @param {Number} colIndex The column index
6002 * @param {Boolean} hidden True if the column is hidden
6004 setHidden : function(colIndex, hidden){
6005 this.config[colIndex].hidden = hidden;
6006 this.totalWidth = null;
6007 this.fireEvent("hiddenchange", this, colIndex, hidden);
6011 * Sets the editor for a column.
6012 * @param {Number} col The column index
6013 * @param {Object} editor The editor object
6015 setEditor : function(col, editor){
6016 this.config[col].editor = editor;
6020 Roo.grid.ColumnModel.defaultRenderer = function(value)
6022 if(typeof value == "object") {
6025 if(typeof value == "string" && value.length < 1){
6029 return String.format("{0}", value);
6032 // Alias for backwards compatibility
6033 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6036 * Ext JS Library 1.1.1
6037 * Copyright(c) 2006-2007, Ext JS, LLC.
6039 * Originally Released Under LGPL - original licence link has changed is not relivant.
6042 * <script type="text/javascript">
6046 * @class Roo.LoadMask
6047 * A simple utility class for generically masking elements while loading data. If the element being masked has
6048 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6049 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6050 * element's UpdateManager load indicator and will be destroyed after the initial load.
6052 * Create a new LoadMask
6053 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6054 * @param {Object} config The config object
6056 Roo.LoadMask = function(el, config){
6057 this.el = Roo.get(el);
6058 Roo.apply(this, config);
6060 this.store.on('beforeload', this.onBeforeLoad, this);
6061 this.store.on('load', this.onLoad, this);
6062 this.store.on('loadexception', this.onLoadException, this);
6063 this.removeMask = false;
6065 var um = this.el.getUpdateManager();
6066 um.showLoadIndicator = false; // disable the default indicator
6067 um.on('beforeupdate', this.onBeforeLoad, this);
6068 um.on('update', this.onLoad, this);
6069 um.on('failure', this.onLoad, this);
6070 this.removeMask = true;
6074 Roo.LoadMask.prototype = {
6076 * @cfg {Boolean} removeMask
6077 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6078 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6082 * The text to display in a centered loading message box (defaults to 'Loading...')
6086 * @cfg {String} msgCls
6087 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6089 msgCls : 'x-mask-loading',
6092 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6098 * Disables the mask to prevent it from being displayed
6100 disable : function(){
6101 this.disabled = true;
6105 * Enables the mask so that it can be displayed
6107 enable : function(){
6108 this.disabled = false;
6111 onLoadException : function()
6115 if (typeof(arguments[3]) != 'undefined') {
6116 Roo.MessageBox.alert("Error loading",arguments[3]);
6120 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6121 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6128 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6133 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6137 onBeforeLoad : function(){
6139 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6144 destroy : function(){
6146 this.store.un('beforeload', this.onBeforeLoad, this);
6147 this.store.un('load', this.onLoad, this);
6148 this.store.un('loadexception', this.onLoadException, this);
6150 var um = this.el.getUpdateManager();
6151 um.un('beforeupdate', this.onBeforeLoad, this);
6152 um.un('update', this.onLoad, this);
6153 um.un('failure', this.onLoad, this);
6164 * @class Roo.bootstrap.Table
6165 * @extends Roo.bootstrap.Component
6166 * Bootstrap Table class
6167 * @cfg {String} cls table class
6168 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6169 * @cfg {String} bgcolor Specifies the background color for a table
6170 * @cfg {Number} border Specifies whether the table cells should have borders or not
6171 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6172 * @cfg {Number} cellspacing Specifies the space between cells
6173 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6174 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6175 * @cfg {String} sortable Specifies that the table should be sortable
6176 * @cfg {String} summary Specifies a summary of the content of a table
6177 * @cfg {Number} width Specifies the width of a table
6178 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6180 * @cfg {boolean} striped Should the rows be alternative striped
6181 * @cfg {boolean} bordered Add borders to the table
6182 * @cfg {boolean} hover Add hover highlighting
6183 * @cfg {boolean} condensed Format condensed
6184 * @cfg {boolean} responsive Format condensed
6185 * @cfg {Boolean} loadMask (true|false) default false
6186 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6187 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6188 * @cfg {Boolean} rowSelection (true|false) default false
6189 * @cfg {Boolean} cellSelection (true|false) default false
6190 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6191 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6192 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6193 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6197 * Create a new Table
6198 * @param {Object} config The config object
6201 Roo.bootstrap.Table = function(config){
6202 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6207 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6208 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6209 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6210 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6212 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6214 this.sm.grid = this;
6215 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6216 this.sm = this.selModel;
6217 this.sm.xmodule = this.xmodule || false;
6220 if (this.cm && typeof(this.cm.config) == 'undefined') {
6221 this.colModel = new Roo.grid.ColumnModel(this.cm);
6222 this.cm = this.colModel;
6223 this.cm.xmodule = this.xmodule || false;
6226 this.store= Roo.factory(this.store, Roo.data);
6227 this.ds = this.store;
6228 this.ds.xmodule = this.xmodule || false;
6231 if (this.footer && this.store) {
6232 this.footer.dataSource = this.ds;
6233 this.footer = Roo.factory(this.footer);
6240 * Fires when a cell is clicked
6241 * @param {Roo.bootstrap.Table} this
6242 * @param {Roo.Element} el
6243 * @param {Number} rowIndex
6244 * @param {Number} columnIndex
6245 * @param {Roo.EventObject} e
6249 * @event celldblclick
6250 * Fires when a cell is double clicked
6251 * @param {Roo.bootstrap.Table} this
6252 * @param {Roo.Element} el
6253 * @param {Number} rowIndex
6254 * @param {Number} columnIndex
6255 * @param {Roo.EventObject} e
6257 "celldblclick" : true,
6260 * Fires when a row is clicked
6261 * @param {Roo.bootstrap.Table} this
6262 * @param {Roo.Element} el
6263 * @param {Number} rowIndex
6264 * @param {Roo.EventObject} e
6268 * @event rowdblclick
6269 * Fires when a row is double clicked
6270 * @param {Roo.bootstrap.Table} this
6271 * @param {Roo.Element} el
6272 * @param {Number} rowIndex
6273 * @param {Roo.EventObject} e
6275 "rowdblclick" : true,
6278 * Fires when a mouseover occur
6279 * @param {Roo.bootstrap.Table} this
6280 * @param {Roo.Element} el
6281 * @param {Number} rowIndex
6282 * @param {Number} columnIndex
6283 * @param {Roo.EventObject} e
6288 * Fires when a mouseout occur
6289 * @param {Roo.bootstrap.Table} this
6290 * @param {Roo.Element} el
6291 * @param {Number} rowIndex
6292 * @param {Number} columnIndex
6293 * @param {Roo.EventObject} e
6298 * Fires when a row is rendered, so you can change add a style to it.
6299 * @param {Roo.bootstrap.Table} this
6300 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6304 * @event rowsrendered
6305 * Fires when all the rows have been rendered
6306 * @param {Roo.bootstrap.Table} this
6308 'rowsrendered' : true,
6310 * @event contextmenu
6311 * The raw contextmenu event for the entire grid.
6312 * @param {Roo.EventObject} e
6314 "contextmenu" : true,
6316 * @event rowcontextmenu
6317 * Fires when a row is right clicked
6318 * @param {Roo.bootstrap.Table} this
6319 * @param {Number} rowIndex
6320 * @param {Roo.EventObject} e
6322 "rowcontextmenu" : true,
6324 * @event cellcontextmenu
6325 * Fires when a cell is right clicked
6326 * @param {Roo.bootstrap.Table} this
6327 * @param {Number} rowIndex
6328 * @param {Number} cellIndex
6329 * @param {Roo.EventObject} e
6331 "cellcontextmenu" : true,
6333 * @event headercontextmenu
6334 * Fires when a header is right clicked
6335 * @param {Roo.bootstrap.Table} this
6336 * @param {Number} columnIndex
6337 * @param {Roo.EventObject} e
6339 "headercontextmenu" : true
6343 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6369 rowSelection : false,
6370 cellSelection : false,
6373 // Roo.Element - the tbody
6375 // Roo.Element - thead element
6378 container: false, // used by gridpanel...
6384 auto_hide_footer : false,
6386 getAutoCreate : function()
6388 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6395 if (this.scrollBody) {
6396 cfg.cls += ' table-body-fixed';
6399 cfg.cls += ' table-striped';
6403 cfg.cls += ' table-hover';
6405 if (this.bordered) {
6406 cfg.cls += ' table-bordered';
6408 if (this.condensed) {
6409 cfg.cls += ' table-condensed';
6411 if (this.responsive) {
6412 cfg.cls += ' table-responsive';
6416 cfg.cls+= ' ' +this.cls;
6419 // this lot should be simplifed...
6432 ].forEach(function(k) {
6440 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6443 if(this.store || this.cm){
6444 if(this.headerShow){
6445 cfg.cn.push(this.renderHeader());
6448 cfg.cn.push(this.renderBody());
6450 if(this.footerShow){
6451 cfg.cn.push(this.renderFooter());
6453 // where does this come from?
6454 //cfg.cls+= ' TableGrid';
6457 return { cn : [ cfg ] };
6460 initEvents : function()
6462 if(!this.store || !this.cm){
6465 if (this.selModel) {
6466 this.selModel.initEvents();
6470 //Roo.log('initEvents with ds!!!!');
6472 this.mainBody = this.el.select('tbody', true).first();
6473 this.mainHead = this.el.select('thead', true).first();
6474 this.mainFoot = this.el.select('tfoot', true).first();
6480 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6481 e.on('click', _this.sort, _this);
6484 this.mainBody.on("click", this.onClick, this);
6485 this.mainBody.on("dblclick", this.onDblClick, this);
6487 // why is this done????? = it breaks dialogs??
6488 //this.parent().el.setStyle('position', 'relative');
6492 this.footer.parentId = this.id;
6493 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6496 this.el.select('tfoot tr td').first().addClass('hide');
6501 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6504 this.store.on('load', this.onLoad, this);
6505 this.store.on('beforeload', this.onBeforeLoad, this);
6506 this.store.on('update', this.onUpdate, this);
6507 this.store.on('add', this.onAdd, this);
6508 this.store.on("clear", this.clear, this);
6510 this.el.on("contextmenu", this.onContextMenu, this);
6512 this.mainBody.on('scroll', this.onBodyScroll, this);
6514 this.cm.on("headerchange", this.onHeaderChange, this);
6516 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6520 onContextMenu : function(e, t)
6522 this.processEvent("contextmenu", e);
6525 processEvent : function(name, e)
6527 if (name != 'touchstart' ) {
6528 this.fireEvent(name, e);
6531 var t = e.getTarget();
6533 var cell = Roo.get(t);
6539 if(cell.findParent('tfoot', false, true)){
6543 if(cell.findParent('thead', false, true)){
6545 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6546 cell = Roo.get(t).findParent('th', false, true);
6548 Roo.log("failed to find th in thead?");
6549 Roo.log(e.getTarget());
6554 var cellIndex = cell.dom.cellIndex;
6556 var ename = name == 'touchstart' ? 'click' : name;
6557 this.fireEvent("header" + ename, this, cellIndex, e);
6562 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6563 cell = Roo.get(t).findParent('td', false, true);
6565 Roo.log("failed to find th in tbody?");
6566 Roo.log(e.getTarget());
6571 var row = cell.findParent('tr', false, true);
6572 var cellIndex = cell.dom.cellIndex;
6573 var rowIndex = row.dom.rowIndex - 1;
6577 this.fireEvent("row" + name, this, rowIndex, e);
6581 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6587 onMouseover : function(e, el)
6589 var cell = Roo.get(el);
6595 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6596 cell = cell.findParent('td', false, true);
6599 var row = cell.findParent('tr', false, true);
6600 var cellIndex = cell.dom.cellIndex;
6601 var rowIndex = row.dom.rowIndex - 1; // start from 0
6603 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6607 onMouseout : function(e, el)
6609 var cell = Roo.get(el);
6615 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6616 cell = cell.findParent('td', false, true);
6619 var row = cell.findParent('tr', false, true);
6620 var cellIndex = cell.dom.cellIndex;
6621 var rowIndex = row.dom.rowIndex - 1; // start from 0
6623 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6627 onClick : function(e, el)
6629 var cell = Roo.get(el);
6631 if(!cell || (!this.cellSelection && !this.rowSelection)){
6635 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6636 cell = cell.findParent('td', false, true);
6639 if(!cell || typeof(cell) == 'undefined'){
6643 var row = cell.findParent('tr', false, true);
6645 if(!row || typeof(row) == 'undefined'){
6649 var cellIndex = cell.dom.cellIndex;
6650 var rowIndex = this.getRowIndex(row);
6652 // why??? - should these not be based on SelectionModel?
6653 if(this.cellSelection){
6654 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6657 if(this.rowSelection){
6658 this.fireEvent('rowclick', this, row, rowIndex, e);
6664 onDblClick : function(e,el)
6666 var cell = Roo.get(el);
6668 if(!cell || (!this.cellSelection && !this.rowSelection)){
6672 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6673 cell = cell.findParent('td', false, true);
6676 if(!cell || typeof(cell) == 'undefined'){
6680 var row = cell.findParent('tr', false, true);
6682 if(!row || typeof(row) == 'undefined'){
6686 var cellIndex = cell.dom.cellIndex;
6687 var rowIndex = this.getRowIndex(row);
6689 if(this.cellSelection){
6690 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6693 if(this.rowSelection){
6694 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6698 sort : function(e,el)
6700 var col = Roo.get(el);
6702 if(!col.hasClass('sortable')){
6706 var sort = col.attr('sort');
6709 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6713 this.store.sortInfo = {field : sort, direction : dir};
6716 Roo.log("calling footer first");
6717 this.footer.onClick('first');
6720 this.store.load({ params : { start : 0 } });
6724 renderHeader : function()
6732 this.totalWidth = 0;
6734 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6736 var config = cm.config[i];
6740 cls : 'x-hcol-' + i,
6742 html: cm.getColumnHeader(i)
6747 if(typeof(config.sortable) != 'undefined' && config.sortable){
6749 c.html = '<i class="glyphicon"></i>' + c.html;
6752 if(typeof(config.lgHeader) != 'undefined'){
6753 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6756 if(typeof(config.mdHeader) != 'undefined'){
6757 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6760 if(typeof(config.smHeader) != 'undefined'){
6761 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6764 if(typeof(config.xsHeader) != 'undefined'){
6765 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6772 if(typeof(config.tooltip) != 'undefined'){
6773 c.tooltip = config.tooltip;
6776 if(typeof(config.colspan) != 'undefined'){
6777 c.colspan = config.colspan;
6780 if(typeof(config.hidden) != 'undefined' && config.hidden){
6781 c.style += ' display:none;';
6784 if(typeof(config.dataIndex) != 'undefined'){
6785 c.sort = config.dataIndex;
6790 if(typeof(config.align) != 'undefined' && config.align.length){
6791 c.style += ' text-align:' + config.align + ';';
6794 if(typeof(config.width) != 'undefined'){
6795 c.style += ' width:' + config.width + 'px;';
6796 this.totalWidth += config.width;
6798 this.totalWidth += 100; // assume minimum of 100 per column?
6801 if(typeof(config.cls) != 'undefined'){
6802 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6805 ['xs','sm','md','lg'].map(function(size){
6807 if(typeof(config[size]) == 'undefined'){
6811 if (!config[size]) { // 0 = hidden
6812 c.cls += ' hidden-' + size;
6816 c.cls += ' col-' + size + '-' + config[size];
6826 renderBody : function()
6836 colspan : this.cm.getColumnCount()
6846 renderFooter : function()
6856 colspan : this.cm.getColumnCount()
6870 // Roo.log('ds onload');
6875 var ds = this.store;
6877 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6878 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6879 if (_this.store.sortInfo) {
6881 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6882 e.select('i', true).addClass(['glyphicon-arrow-up']);
6885 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6886 e.select('i', true).addClass(['glyphicon-arrow-down']);
6891 var tbody = this.mainBody;
6893 if(ds.getCount() > 0){
6894 ds.data.each(function(d,rowIndex){
6895 var row = this.renderRow(cm, ds, rowIndex);
6897 tbody.createChild(row);
6901 if(row.cellObjects.length){
6902 Roo.each(row.cellObjects, function(r){
6903 _this.renderCellObject(r);
6910 var tfoot = this.el.select('tfoot', true).first();
6912 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6914 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6916 var total = this.ds.getTotalCount();
6918 if(this.footer.pageSize < total){
6919 this.mainFoot.show();
6923 Roo.each(this.el.select('tbody td', true).elements, function(e){
6924 e.on('mouseover', _this.onMouseover, _this);
6927 Roo.each(this.el.select('tbody td', true).elements, function(e){
6928 e.on('mouseout', _this.onMouseout, _this);
6930 this.fireEvent('rowsrendered', this);
6936 onUpdate : function(ds,record)
6938 this.refreshRow(record);
6942 onRemove : function(ds, record, index, isUpdate){
6943 if(isUpdate !== true){
6944 this.fireEvent("beforerowremoved", this, index, record);
6946 var bt = this.mainBody.dom;
6948 var rows = this.el.select('tbody > tr', true).elements;
6950 if(typeof(rows[index]) != 'undefined'){
6951 bt.removeChild(rows[index].dom);
6954 // if(bt.rows[index]){
6955 // bt.removeChild(bt.rows[index]);
6958 if(isUpdate !== true){
6959 //this.stripeRows(index);
6960 //this.syncRowHeights(index, index);
6962 this.fireEvent("rowremoved", this, index, record);
6966 onAdd : function(ds, records, rowIndex)
6968 //Roo.log('on Add called');
6969 // - note this does not handle multiple adding very well..
6970 var bt = this.mainBody.dom;
6971 for (var i =0 ; i < records.length;i++) {
6972 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6973 //Roo.log(records[i]);
6974 //Roo.log(this.store.getAt(rowIndex+i));
6975 this.insertRow(this.store, rowIndex + i, false);
6982 refreshRow : function(record){
6983 var ds = this.store, index;
6984 if(typeof record == 'number'){
6986 record = ds.getAt(index);
6988 index = ds.indexOf(record);
6990 this.insertRow(ds, index, true);
6992 this.onRemove(ds, record, index+1, true);
6994 //this.syncRowHeights(index, index);
6996 this.fireEvent("rowupdated", this, index, record);
6999 insertRow : function(dm, rowIndex, isUpdate){
7002 this.fireEvent("beforerowsinserted", this, rowIndex);
7004 //var s = this.getScrollState();
7005 var row = this.renderRow(this.cm, this.store, rowIndex);
7006 // insert before rowIndex..
7007 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7011 if(row.cellObjects.length){
7012 Roo.each(row.cellObjects, function(r){
7013 _this.renderCellObject(r);
7018 this.fireEvent("rowsinserted", this, rowIndex);
7019 //this.syncRowHeights(firstRow, lastRow);
7020 //this.stripeRows(firstRow);
7027 getRowDom : function(rowIndex)
7029 var rows = this.el.select('tbody > tr', true).elements;
7031 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7034 // returns the object tree for a tr..
7037 renderRow : function(cm, ds, rowIndex)
7039 var d = ds.getAt(rowIndex);
7043 cls : 'x-row-' + rowIndex,
7047 var cellObjects = [];
7049 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7050 var config = cm.config[i];
7052 var renderer = cm.getRenderer(i);
7056 if(typeof(renderer) !== 'undefined'){
7057 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7059 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7060 // and are rendered into the cells after the row is rendered - using the id for the element.
7062 if(typeof(value) === 'object'){
7072 rowIndex : rowIndex,
7077 this.fireEvent('rowclass', this, rowcfg);
7081 cls : rowcfg.rowClass + ' x-col-' + i,
7083 html: (typeof(value) === 'object') ? '' : value
7090 if(typeof(config.colspan) != 'undefined'){
7091 td.colspan = config.colspan;
7094 if(typeof(config.hidden) != 'undefined' && config.hidden){
7095 td.style += ' display:none;';
7098 if(typeof(config.align) != 'undefined' && config.align.length){
7099 td.style += ' text-align:' + config.align + ';';
7101 if(typeof(config.valign) != 'undefined' && config.valign.length){
7102 td.style += ' vertical-align:' + config.valign + ';';
7105 if(typeof(config.width) != 'undefined'){
7106 td.style += ' width:' + config.width + 'px;';
7109 if(typeof(config.cursor) != 'undefined'){
7110 td.style += ' cursor:' + config.cursor + ';';
7113 if(typeof(config.cls) != 'undefined'){
7114 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7117 ['xs','sm','md','lg'].map(function(size){
7119 if(typeof(config[size]) == 'undefined'){
7123 if (!config[size]) { // 0 = hidden
7124 td.cls += ' hidden-' + size;
7128 td.cls += ' col-' + size + '-' + config[size];
7136 row.cellObjects = cellObjects;
7144 onBeforeLoad : function()
7153 this.el.select('tbody', true).first().dom.innerHTML = '';
7156 * Show or hide a row.
7157 * @param {Number} rowIndex to show or hide
7158 * @param {Boolean} state hide
7160 setRowVisibility : function(rowIndex, state)
7162 var bt = this.mainBody.dom;
7164 var rows = this.el.select('tbody > tr', true).elements;
7166 if(typeof(rows[rowIndex]) == 'undefined'){
7169 rows[rowIndex].dom.style.display = state ? '' : 'none';
7173 getSelectionModel : function(){
7175 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7177 return this.selModel;
7180 * Render the Roo.bootstrap object from renderder
7182 renderCellObject : function(r)
7186 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7188 var t = r.cfg.render(r.container);
7191 Roo.each(r.cfg.cn, function(c){
7193 container: t.getChildContainer(),
7196 _this.renderCellObject(child);
7201 getRowIndex : function(row)
7205 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7216 * Returns the grid's underlying element = used by panel.Grid
7217 * @return {Element} The element
7219 getGridEl : function(){
7223 * Forces a resize - used by panel.Grid
7224 * @return {Element} The element
7226 autoSize : function()
7228 //var ctr = Roo.get(this.container.dom.parentElement);
7229 var ctr = Roo.get(this.el.dom);
7231 var thd = this.getGridEl().select('thead',true).first();
7232 var tbd = this.getGridEl().select('tbody', true).first();
7233 var tfd = this.getGridEl().select('tfoot', true).first();
7235 var cw = ctr.getWidth();
7239 tbd.setSize(ctr.getWidth(),
7240 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7242 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7245 cw = Math.max(cw, this.totalWidth);
7246 this.getGridEl().select('tr',true).setWidth(cw);
7247 // resize 'expandable coloumn?
7249 return; // we doe not have a view in this design..
7252 onBodyScroll: function()
7254 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7256 this.mainHead.setStyle({
7257 'position' : 'relative',
7258 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7264 var scrollHeight = this.mainBody.dom.scrollHeight;
7266 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7268 var height = this.mainBody.getHeight();
7270 if(scrollHeight - height == scrollTop) {
7272 var total = this.ds.getTotalCount();
7274 if(this.footer.cursor + this.footer.pageSize < total){
7276 this.footer.ds.load({
7278 start : this.footer.cursor + this.footer.pageSize,
7279 limit : this.footer.pageSize
7289 onHeaderChange : function()
7291 var header = this.renderHeader();
7292 var table = this.el.select('table', true).first();
7294 this.mainHead.remove();
7295 this.mainHead = table.createChild(header, this.mainBody, false);
7298 onHiddenChange : function(colModel, colIndex, hidden)
7300 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7301 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7303 this.CSS.updateRule(thSelector, "display", "");
7304 this.CSS.updateRule(tdSelector, "display", "");
7307 this.CSS.updateRule(thSelector, "display", "none");
7308 this.CSS.updateRule(tdSelector, "display", "none");
7311 this.onHeaderChange();
7315 setColumnWidth: function(col_index, width)
7317 // width = "md-2 xs-2..."
7318 if(!this.colModel.config[col_index]) {
7322 var w = width.split(" ");
7324 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7326 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7329 for(var j = 0; j < w.length; j++) {
7335 var size_cls = w[j].split("-");
7337 if(!Number.isInteger(size_cls[1] * 1)) {
7341 if(!this.colModel.config[col_index][size_cls[0]]) {
7345 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7349 h_row[0].classList.replace(
7350 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7351 "col-"+size_cls[0]+"-"+size_cls[1]
7354 for(var i = 0; i < rows.length; i++) {
7356 var size_cls = w[j].split("-");
7358 if(!Number.isInteger(size_cls[1] * 1)) {
7362 if(!this.colModel.config[col_index][size_cls[0]]) {
7366 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7370 rows[i].classList.replace(
7371 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7372 "col-"+size_cls[0]+"-"+size_cls[1]
7376 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7391 * @class Roo.bootstrap.TableCell
7392 * @extends Roo.bootstrap.Component
7393 * Bootstrap TableCell class
7394 * @cfg {String} html cell contain text
7395 * @cfg {String} cls cell class
7396 * @cfg {String} tag cell tag (td|th) default td
7397 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7398 * @cfg {String} align Aligns the content in a cell
7399 * @cfg {String} axis Categorizes cells
7400 * @cfg {String} bgcolor Specifies the background color of a cell
7401 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7402 * @cfg {Number} colspan Specifies the number of columns a cell should span
7403 * @cfg {String} headers Specifies one or more header cells a cell is related to
7404 * @cfg {Number} height Sets the height of a cell
7405 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7406 * @cfg {Number} rowspan Sets the number of rows a cell should span
7407 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7408 * @cfg {String} valign Vertical aligns the content in a cell
7409 * @cfg {Number} width Specifies the width of a cell
7412 * Create a new TableCell
7413 * @param {Object} config The config object
7416 Roo.bootstrap.TableCell = function(config){
7417 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7420 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7440 getAutoCreate : function(){
7441 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7461 cfg.align=this.align
7467 cfg.bgcolor=this.bgcolor
7470 cfg.charoff=this.charoff
7473 cfg.colspan=this.colspan
7476 cfg.headers=this.headers
7479 cfg.height=this.height
7482 cfg.nowrap=this.nowrap
7485 cfg.rowspan=this.rowspan
7488 cfg.scope=this.scope
7491 cfg.valign=this.valign
7494 cfg.width=this.width
7513 * @class Roo.bootstrap.TableRow
7514 * @extends Roo.bootstrap.Component
7515 * Bootstrap TableRow class
7516 * @cfg {String} cls row class
7517 * @cfg {String} align Aligns the content in a table row
7518 * @cfg {String} bgcolor Specifies a background color for a table row
7519 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7520 * @cfg {String} valign Vertical aligns the content in a table row
7523 * Create a new TableRow
7524 * @param {Object} config The config object
7527 Roo.bootstrap.TableRow = function(config){
7528 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7531 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7539 getAutoCreate : function(){
7540 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7550 cfg.align = this.align;
7553 cfg.bgcolor = this.bgcolor;
7556 cfg.charoff = this.charoff;
7559 cfg.valign = this.valign;
7577 * @class Roo.bootstrap.TableBody
7578 * @extends Roo.bootstrap.Component
7579 * Bootstrap TableBody class
7580 * @cfg {String} cls element class
7581 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7582 * @cfg {String} align Aligns the content inside the element
7583 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7584 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7587 * Create a new TableBody
7588 * @param {Object} config The config object
7591 Roo.bootstrap.TableBody = function(config){
7592 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7595 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7603 getAutoCreate : function(){
7604 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7618 cfg.align = this.align;
7621 cfg.charoff = this.charoff;
7624 cfg.valign = this.valign;
7631 // initEvents : function()
7638 // this.store = Roo.factory(this.store, Roo.data);
7639 // this.store.on('load', this.onLoad, this);
7641 // this.store.load();
7645 // onLoad: function ()
7647 // this.fireEvent('load', this);
7657 * Ext JS Library 1.1.1
7658 * Copyright(c) 2006-2007, Ext JS, LLC.
7660 * Originally Released Under LGPL - original licence link has changed is not relivant.
7663 * <script type="text/javascript">
7666 // as we use this in bootstrap.
7667 Roo.namespace('Roo.form');
7669 * @class Roo.form.Action
7670 * Internal Class used to handle form actions
7672 * @param {Roo.form.BasicForm} el The form element or its id
7673 * @param {Object} config Configuration options
7678 // define the action interface
7679 Roo.form.Action = function(form, options){
7681 this.options = options || {};
7684 * Client Validation Failed
7687 Roo.form.Action.CLIENT_INVALID = 'client';
7689 * Server Validation Failed
7692 Roo.form.Action.SERVER_INVALID = 'server';
7694 * Connect to Server Failed
7697 Roo.form.Action.CONNECT_FAILURE = 'connect';
7699 * Reading Data from Server Failed
7702 Roo.form.Action.LOAD_FAILURE = 'load';
7704 Roo.form.Action.prototype = {
7706 failureType : undefined,
7707 response : undefined,
7711 run : function(options){
7716 success : function(response){
7721 handleResponse : function(response){
7725 // default connection failure
7726 failure : function(response){
7728 this.response = response;
7729 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7730 this.form.afterAction(this, false);
7733 processResponse : function(response){
7734 this.response = response;
7735 if(!response.responseText){
7738 this.result = this.handleResponse(response);
7742 // utility functions used internally
7743 getUrl : function(appendParams){
7744 var url = this.options.url || this.form.url || this.form.el.dom.action;
7746 var p = this.getParams();
7748 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7754 getMethod : function(){
7755 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7758 getParams : function(){
7759 var bp = this.form.baseParams;
7760 var p = this.options.params;
7762 if(typeof p == "object"){
7763 p = Roo.urlEncode(Roo.applyIf(p, bp));
7764 }else if(typeof p == 'string' && bp){
7765 p += '&' + Roo.urlEncode(bp);
7768 p = Roo.urlEncode(bp);
7773 createCallback : function(){
7775 success: this.success,
7776 failure: this.failure,
7778 timeout: (this.form.timeout*1000),
7779 upload: this.form.fileUpload ? this.success : undefined
7784 Roo.form.Action.Submit = function(form, options){
7785 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7788 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7791 haveProgress : false,
7792 uploadComplete : false,
7794 // uploadProgress indicator.
7795 uploadProgress : function()
7797 if (!this.form.progressUrl) {
7801 if (!this.haveProgress) {
7802 Roo.MessageBox.progress("Uploading", "Uploading");
7804 if (this.uploadComplete) {
7805 Roo.MessageBox.hide();
7809 this.haveProgress = true;
7811 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7813 var c = new Roo.data.Connection();
7815 url : this.form.progressUrl,
7820 success : function(req){
7821 //console.log(data);
7825 rdata = Roo.decode(req.responseText)
7827 Roo.log("Invalid data from server..");
7831 if (!rdata || !rdata.success) {
7833 Roo.MessageBox.alert(Roo.encode(rdata));
7836 var data = rdata.data;
7838 if (this.uploadComplete) {
7839 Roo.MessageBox.hide();
7844 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7845 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7848 this.uploadProgress.defer(2000,this);
7851 failure: function(data) {
7852 Roo.log('progress url failed ');
7863 // run get Values on the form, so it syncs any secondary forms.
7864 this.form.getValues();
7866 var o = this.options;
7867 var method = this.getMethod();
7868 var isPost = method == 'POST';
7869 if(o.clientValidation === false || this.form.isValid()){
7871 if (this.form.progressUrl) {
7872 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7873 (new Date() * 1) + '' + Math.random());
7878 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7879 form:this.form.el.dom,
7880 url:this.getUrl(!isPost),
7882 params:isPost ? this.getParams() : null,
7883 isUpload: this.form.fileUpload
7886 this.uploadProgress();
7888 }else if (o.clientValidation !== false){ // client validation failed
7889 this.failureType = Roo.form.Action.CLIENT_INVALID;
7890 this.form.afterAction(this, false);
7894 success : function(response)
7896 this.uploadComplete= true;
7897 if (this.haveProgress) {
7898 Roo.MessageBox.hide();
7902 var result = this.processResponse(response);
7903 if(result === true || result.success){
7904 this.form.afterAction(this, true);
7908 this.form.markInvalid(result.errors);
7909 this.failureType = Roo.form.Action.SERVER_INVALID;
7911 this.form.afterAction(this, false);
7913 failure : function(response)
7915 this.uploadComplete= true;
7916 if (this.haveProgress) {
7917 Roo.MessageBox.hide();
7920 this.response = response;
7921 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7922 this.form.afterAction(this, false);
7925 handleResponse : function(response){
7926 if(this.form.errorReader){
7927 var rs = this.form.errorReader.read(response);
7930 for(var i = 0, len = rs.records.length; i < len; i++) {
7931 var r = rs.records[i];
7935 if(errors.length < 1){
7939 success : rs.success,
7945 ret = Roo.decode(response.responseText);
7949 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7959 Roo.form.Action.Load = function(form, options){
7960 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7961 this.reader = this.form.reader;
7964 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7969 Roo.Ajax.request(Roo.apply(
7970 this.createCallback(), {
7971 method:this.getMethod(),
7972 url:this.getUrl(false),
7973 params:this.getParams()
7977 success : function(response){
7979 var result = this.processResponse(response);
7980 if(result === true || !result.success || !result.data){
7981 this.failureType = Roo.form.Action.LOAD_FAILURE;
7982 this.form.afterAction(this, false);
7985 this.form.clearInvalid();
7986 this.form.setValues(result.data);
7987 this.form.afterAction(this, true);
7990 handleResponse : function(response){
7991 if(this.form.reader){
7992 var rs = this.form.reader.read(response);
7993 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7995 success : rs.success,
7999 return Roo.decode(response.responseText);
8003 Roo.form.Action.ACTION_TYPES = {
8004 'load' : Roo.form.Action.Load,
8005 'submit' : Roo.form.Action.Submit
8014 * @class Roo.bootstrap.Form
8015 * @extends Roo.bootstrap.Component
8016 * Bootstrap Form class
8017 * @cfg {String} method GET | POST (default POST)
8018 * @cfg {String} labelAlign top | left (default top)
8019 * @cfg {String} align left | right - for navbars
8020 * @cfg {Boolean} loadMask load mask when submit (default true)
8025 * @param {Object} config The config object
8029 Roo.bootstrap.Form = function(config){
8031 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8033 Roo.bootstrap.Form.popover.apply();
8037 * @event clientvalidation
8038 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8039 * @param {Form} this
8040 * @param {Boolean} valid true if the form has passed client-side validation
8042 clientvalidation: true,
8044 * @event beforeaction
8045 * Fires before any action is performed. Return false to cancel the action.
8046 * @param {Form} this
8047 * @param {Action} action The action to be performed
8051 * @event actionfailed
8052 * Fires when an action fails.
8053 * @param {Form} this
8054 * @param {Action} action The action that failed
8056 actionfailed : true,
8058 * @event actioncomplete
8059 * Fires when an action is completed.
8060 * @param {Form} this
8061 * @param {Action} action The action that completed
8063 actioncomplete : true
8067 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8070 * @cfg {String} method
8071 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8076 * The URL to use for form actions if one isn't supplied in the action options.
8079 * @cfg {Boolean} fileUpload
8080 * Set to true if this form is a file upload.
8084 * @cfg {Object} baseParams
8085 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8089 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8093 * @cfg {Sting} align (left|right) for navbar forms
8098 activeAction : null,
8101 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8102 * element by passing it or its id or mask the form itself by passing in true.
8105 waitMsgTarget : false,
8110 * @cfg {Boolean} errorMask (true|false) default false
8115 * @cfg {Number} maskOffset Default 100
8120 * @cfg {Boolean} maskBody
8124 getAutoCreate : function(){
8128 method : this.method || 'POST',
8129 id : this.id || Roo.id(),
8132 if (this.parent().xtype.match(/^Nav/)) {
8133 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8137 if (this.labelAlign == 'left' ) {
8138 cfg.cls += ' form-horizontal';
8144 initEvents : function()
8146 this.el.on('submit', this.onSubmit, this);
8147 // this was added as random key presses on the form where triggering form submit.
8148 this.el.on('keypress', function(e) {
8149 if (e.getCharCode() != 13) {
8152 // we might need to allow it for textareas.. and some other items.
8153 // check e.getTarget().
8155 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8159 Roo.log("keypress blocked");
8167 onSubmit : function(e){
8172 * Returns true if client-side validation on the form is successful.
8175 isValid : function(){
8176 var items = this.getItems();
8180 items.each(function(f){
8186 Roo.log('invalid field: ' + f.name);
8190 if(!target && f.el.isVisible(true)){
8196 if(this.errorMask && !valid){
8197 Roo.bootstrap.Form.popover.mask(this, target);
8204 * Returns true if any fields in this form have changed since their original load.
8207 isDirty : function(){
8209 var items = this.getItems();
8210 items.each(function(f){
8220 * Performs a predefined action (submit or load) or custom actions you define on this form.
8221 * @param {String} actionName The name of the action type
8222 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8223 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8224 * accept other config options):
8226 Property Type Description
8227 ---------------- --------------- ----------------------------------------------------------------------------------
8228 url String The url for the action (defaults to the form's url)
8229 method String The form method to use (defaults to the form's method, or POST if not defined)
8230 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8231 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8232 validate the form on the client (defaults to false)
8234 * @return {BasicForm} this
8236 doAction : function(action, options){
8237 if(typeof action == 'string'){
8238 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8240 if(this.fireEvent('beforeaction', this, action) !== false){
8241 this.beforeAction(action);
8242 action.run.defer(100, action);
8248 beforeAction : function(action){
8249 var o = action.options;
8254 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8256 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8259 // not really supported yet.. ??
8261 //if(this.waitMsgTarget === true){
8262 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8263 //}else if(this.waitMsgTarget){
8264 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8265 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8267 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8273 afterAction : function(action, success){
8274 this.activeAction = null;
8275 var o = action.options;
8280 Roo.get(document.body).unmask();
8286 //if(this.waitMsgTarget === true){
8287 // this.el.unmask();
8288 //}else if(this.waitMsgTarget){
8289 // this.waitMsgTarget.unmask();
8291 // Roo.MessageBox.updateProgress(1);
8292 // Roo.MessageBox.hide();
8299 Roo.callback(o.success, o.scope, [this, action]);
8300 this.fireEvent('actioncomplete', this, action);
8304 // failure condition..
8305 // we have a scenario where updates need confirming.
8306 // eg. if a locking scenario exists..
8307 // we look for { errors : { needs_confirm : true }} in the response.
8309 (typeof(action.result) != 'undefined') &&
8310 (typeof(action.result.errors) != 'undefined') &&
8311 (typeof(action.result.errors.needs_confirm) != 'undefined')
8314 Roo.log("not supported yet");
8317 Roo.MessageBox.confirm(
8318 "Change requires confirmation",
8319 action.result.errorMsg,
8324 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8334 Roo.callback(o.failure, o.scope, [this, action]);
8335 // show an error message if no failed handler is set..
8336 if (!this.hasListener('actionfailed')) {
8337 Roo.log("need to add dialog support");
8339 Roo.MessageBox.alert("Error",
8340 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8341 action.result.errorMsg :
8342 "Saving Failed, please check your entries or try again"
8347 this.fireEvent('actionfailed', this, action);
8352 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8353 * @param {String} id The value to search for
8356 findField : function(id){
8357 var items = this.getItems();
8358 var field = items.get(id);
8360 items.each(function(f){
8361 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8368 return field || null;
8371 * Mark fields in this form invalid in bulk.
8372 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8373 * @return {BasicForm} this
8375 markInvalid : function(errors){
8376 if(errors instanceof Array){
8377 for(var i = 0, len = errors.length; i < len; i++){
8378 var fieldError = errors[i];
8379 var f = this.findField(fieldError.id);
8381 f.markInvalid(fieldError.msg);
8387 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8388 field.markInvalid(errors[id]);
8392 //Roo.each(this.childForms || [], function (f) {
8393 // f.markInvalid(errors);
8400 * Set values for fields in this form in bulk.
8401 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8402 * @return {BasicForm} this
8404 setValues : function(values){
8405 if(values instanceof Array){ // array of objects
8406 for(var i = 0, len = values.length; i < len; i++){
8408 var f = this.findField(v.id);
8410 f.setValue(v.value);
8411 if(this.trackResetOnLoad){
8412 f.originalValue = f.getValue();
8416 }else{ // object hash
8419 if(typeof values[id] != 'function' && (field = this.findField(id))){
8421 if (field.setFromData &&
8423 field.displayField &&
8424 // combos' with local stores can
8425 // be queried via setValue()
8426 // to set their value..
8427 (field.store && !field.store.isLocal)
8431 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8432 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8433 field.setFromData(sd);
8435 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8437 field.setFromData(values);
8440 field.setValue(values[id]);
8444 if(this.trackResetOnLoad){
8445 field.originalValue = field.getValue();
8451 //Roo.each(this.childForms || [], function (f) {
8452 // f.setValues(values);
8459 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8460 * they are returned as an array.
8461 * @param {Boolean} asString
8464 getValues : function(asString){
8465 //if (this.childForms) {
8466 // copy values from the child forms
8467 // Roo.each(this.childForms, function (f) {
8468 // this.setValues(f.getValues());
8474 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8475 if(asString === true){
8478 return Roo.urlDecode(fs);
8482 * Returns the fields in this form as an object with key/value pairs.
8483 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8486 getFieldValues : function(with_hidden)
8488 var items = this.getItems();
8490 items.each(function(f){
8496 var v = f.getValue();
8498 if (f.inputType =='radio') {
8499 if (typeof(ret[f.getName()]) == 'undefined') {
8500 ret[f.getName()] = ''; // empty..
8503 if (!f.el.dom.checked) {
8511 if(f.xtype == 'MoneyField'){
8512 ret[f.currencyName] = f.getCurrency();
8515 // not sure if this supported any more..
8516 if ((typeof(v) == 'object') && f.getRawValue) {
8517 v = f.getRawValue() ; // dates..
8519 // combo boxes where name != hiddenName...
8520 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8521 ret[f.name] = f.getRawValue();
8523 ret[f.getName()] = v;
8530 * Clears all invalid messages in this form.
8531 * @return {BasicForm} this
8533 clearInvalid : function(){
8534 var items = this.getItems();
8536 items.each(function(f){
8545 * @return {BasicForm} this
8548 var items = this.getItems();
8549 items.each(function(f){
8553 Roo.each(this.childForms || [], function (f) {
8561 getItems : function()
8563 var r=new Roo.util.MixedCollection(false, function(o){
8564 return o.id || (o.id = Roo.id());
8566 var iter = function(el) {
8573 Roo.each(el.items,function(e) {
8582 hideFields : function(items)
8584 Roo.each(items, function(i){
8586 var f = this.findField(i);
8597 showFields : function(items)
8599 Roo.each(items, function(i){
8601 var f = this.findField(i);
8614 Roo.apply(Roo.bootstrap.Form, {
8641 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8642 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8643 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8644 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8647 this.maskEl.top.enableDisplayMode("block");
8648 this.maskEl.left.enableDisplayMode("block");
8649 this.maskEl.bottom.enableDisplayMode("block");
8650 this.maskEl.right.enableDisplayMode("block");
8652 this.toolTip = new Roo.bootstrap.Tooltip({
8653 cls : 'roo-form-error-popover',
8655 'left' : ['r-l', [-2,0], 'right'],
8656 'right' : ['l-r', [2,0], 'left'],
8657 'bottom' : ['tl-bl', [0,2], 'top'],
8658 'top' : [ 'bl-tl', [0,-2], 'bottom']
8662 this.toolTip.render(Roo.get(document.body));
8664 this.toolTip.el.enableDisplayMode("block");
8666 Roo.get(document.body).on('click', function(){
8670 Roo.get(document.body).on('touchstart', function(){
8674 this.isApplied = true
8677 mask : function(form, target)
8681 this.target = target;
8683 if(!this.form.errorMask || !target.el){
8687 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8689 Roo.log(scrollable);
8691 var ot = this.target.el.calcOffsetsTo(scrollable);
8693 var scrollTo = ot[1] - this.form.maskOffset;
8695 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8697 scrollable.scrollTo('top', scrollTo);
8699 var box = this.target.el.getBox();
8701 var zIndex = Roo.bootstrap.Modal.zIndex++;
8704 this.maskEl.top.setStyle('position', 'absolute');
8705 this.maskEl.top.setStyle('z-index', zIndex);
8706 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8707 this.maskEl.top.setLeft(0);
8708 this.maskEl.top.setTop(0);
8709 this.maskEl.top.show();
8711 this.maskEl.left.setStyle('position', 'absolute');
8712 this.maskEl.left.setStyle('z-index', zIndex);
8713 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8714 this.maskEl.left.setLeft(0);
8715 this.maskEl.left.setTop(box.y - this.padding);
8716 this.maskEl.left.show();
8718 this.maskEl.bottom.setStyle('position', 'absolute');
8719 this.maskEl.bottom.setStyle('z-index', zIndex);
8720 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8721 this.maskEl.bottom.setLeft(0);
8722 this.maskEl.bottom.setTop(box.bottom + this.padding);
8723 this.maskEl.bottom.show();
8725 this.maskEl.right.setStyle('position', 'absolute');
8726 this.maskEl.right.setStyle('z-index', zIndex);
8727 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8728 this.maskEl.right.setLeft(box.right + this.padding);
8729 this.maskEl.right.setTop(box.y - this.padding);
8730 this.maskEl.right.show();
8732 this.toolTip.bindEl = this.target.el;
8734 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8736 var tip = this.target.blankText;
8738 if(this.target.getValue() !== '' ) {
8740 if (this.target.invalidText.length) {
8741 tip = this.target.invalidText;
8742 } else if (this.target.regexText.length){
8743 tip = this.target.regexText;
8747 this.toolTip.show(tip);
8749 this.intervalID = window.setInterval(function() {
8750 Roo.bootstrap.Form.popover.unmask();
8753 window.onwheel = function(){ return false;};
8755 (function(){ this.isMasked = true; }).defer(500, this);
8761 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8765 this.maskEl.top.setStyle('position', 'absolute');
8766 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8767 this.maskEl.top.hide();
8769 this.maskEl.left.setStyle('position', 'absolute');
8770 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8771 this.maskEl.left.hide();
8773 this.maskEl.bottom.setStyle('position', 'absolute');
8774 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8775 this.maskEl.bottom.hide();
8777 this.maskEl.right.setStyle('position', 'absolute');
8778 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8779 this.maskEl.right.hide();
8781 this.toolTip.hide();
8783 this.toolTip.el.hide();
8785 window.onwheel = function(){ return true;};
8787 if(this.intervalID){
8788 window.clearInterval(this.intervalID);
8789 this.intervalID = false;
8792 this.isMasked = false;
8802 * Ext JS Library 1.1.1
8803 * Copyright(c) 2006-2007, Ext JS, LLC.
8805 * Originally Released Under LGPL - original licence link has changed is not relivant.
8808 * <script type="text/javascript">
8811 * @class Roo.form.VTypes
8812 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8815 Roo.form.VTypes = function(){
8816 // closure these in so they are only created once.
8817 var alpha = /^[a-zA-Z_]+$/;
8818 var alphanum = /^[a-zA-Z0-9_]+$/;
8819 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8820 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8822 // All these messages and functions are configurable
8825 * The function used to validate email addresses
8826 * @param {String} value The email address
8828 'email' : function(v){
8829 return email.test(v);
8832 * The error text to display when the email validation function returns false
8835 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8837 * The keystroke filter mask to be applied on email input
8840 'emailMask' : /[a-z0-9_\.\-@]/i,
8843 * The function used to validate URLs
8844 * @param {String} value The URL
8846 'url' : function(v){
8850 * The error text to display when the url validation function returns false
8853 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8856 * The function used to validate alpha values
8857 * @param {String} value The value
8859 'alpha' : function(v){
8860 return alpha.test(v);
8863 * The error text to display when the alpha validation function returns false
8866 'alphaText' : 'This field should only contain letters and _',
8868 * The keystroke filter mask to be applied on alpha input
8871 'alphaMask' : /[a-z_]/i,
8874 * The function used to validate alphanumeric values
8875 * @param {String} value The value
8877 'alphanum' : function(v){
8878 return alphanum.test(v);
8881 * The error text to display when the alphanumeric validation function returns false
8884 'alphanumText' : 'This field should only contain letters, numbers and _',
8886 * The keystroke filter mask to be applied on alphanumeric input
8889 'alphanumMask' : /[a-z0-9_]/i
8899 * @class Roo.bootstrap.Input
8900 * @extends Roo.bootstrap.Component
8901 * Bootstrap Input class
8902 * @cfg {Boolean} disabled is it disabled
8903 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8904 * @cfg {String} name name of the input
8905 * @cfg {string} fieldLabel - the label associated
8906 * @cfg {string} placeholder - placeholder to put in text.
8907 * @cfg {string} before - input group add on before
8908 * @cfg {string} after - input group add on after
8909 * @cfg {string} size - (lg|sm) or leave empty..
8910 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8911 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8912 * @cfg {Number} md colspan out of 12 for computer-sized screens
8913 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8914 * @cfg {string} value default value of the input
8915 * @cfg {Number} labelWidth set the width of label
8916 * @cfg {Number} labellg set the width of label (1-12)
8917 * @cfg {Number} labelmd set the width of label (1-12)
8918 * @cfg {Number} labelsm set the width of label (1-12)
8919 * @cfg {Number} labelxs set the width of label (1-12)
8920 * @cfg {String} labelAlign (top|left)
8921 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8922 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8923 * @cfg {String} indicatorpos (left|right) default left
8924 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8925 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8927 * @cfg {String} align (left|center|right) Default left
8928 * @cfg {Boolean} forceFeedback (true|false) Default false
8931 * Create a new Input
8932 * @param {Object} config The config object
8935 Roo.bootstrap.Input = function(config){
8937 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8942 * Fires when this field receives input focus.
8943 * @param {Roo.form.Field} this
8948 * Fires when this field loses input focus.
8949 * @param {Roo.form.Field} this
8954 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8955 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8956 * @param {Roo.form.Field} this
8957 * @param {Roo.EventObject} e The event object
8962 * Fires just before the field blurs if the field value has changed.
8963 * @param {Roo.form.Field} this
8964 * @param {Mixed} newValue The new value
8965 * @param {Mixed} oldValue The original value
8970 * Fires after the field has been marked as invalid.
8971 * @param {Roo.form.Field} this
8972 * @param {String} msg The validation message
8977 * Fires after the field has been validated with no errors.
8978 * @param {Roo.form.Field} this
8983 * Fires after the key up
8984 * @param {Roo.form.Field} this
8985 * @param {Roo.EventObject} e The event Object
8991 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8993 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8994 automatic validation (defaults to "keyup").
8996 validationEvent : "keyup",
8998 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9000 validateOnBlur : true,
9002 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9004 validationDelay : 250,
9006 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9008 focusClass : "x-form-focus", // not needed???
9012 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9014 invalidClass : "has-warning",
9017 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9019 validClass : "has-success",
9022 * @cfg {Boolean} hasFeedback (true|false) default true
9027 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9029 invalidFeedbackClass : "glyphicon-warning-sign",
9032 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9034 validFeedbackClass : "glyphicon-ok",
9037 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9039 selectOnFocus : false,
9042 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9046 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9051 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9053 disableKeyFilter : false,
9056 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9060 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9064 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9066 blankText : "Please complete this mandatory field",
9069 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9073 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9075 maxLength : Number.MAX_VALUE,
9077 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9079 minLengthText : "The minimum length for this field is {0}",
9081 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9083 maxLengthText : "The maximum length for this field is {0}",
9087 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9088 * If available, this function will be called only after the basic validators all return true, and will be passed the
9089 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9093 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9094 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9095 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9099 * @cfg {String} regexText -- Depricated - use Invalid Text
9104 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9110 autocomplete: false,
9129 formatedValue : false,
9130 forceFeedback : false,
9132 indicatorpos : 'left',
9142 parentLabelAlign : function()
9145 while (parent.parent()) {
9146 parent = parent.parent();
9147 if (typeof(parent.labelAlign) !='undefined') {
9148 return parent.labelAlign;
9155 getAutoCreate : function()
9157 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9163 if(this.inputType != 'hidden'){
9164 cfg.cls = 'form-group' //input-group
9170 type : this.inputType,
9172 cls : 'form-control',
9173 placeholder : this.placeholder || '',
9174 autocomplete : this.autocomplete || 'new-password'
9177 if(this.capture.length){
9178 input.capture = this.capture;
9181 if(this.accept.length){
9182 input.accept = this.accept + "/*";
9186 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9189 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9190 input.maxLength = this.maxLength;
9193 if (this.disabled) {
9194 input.disabled=true;
9197 if (this.readOnly) {
9198 input.readonly=true;
9202 input.name = this.name;
9206 input.cls += ' input-' + this.size;
9210 ['xs','sm','md','lg'].map(function(size){
9211 if (settings[size]) {
9212 cfg.cls += ' col-' + size + '-' + settings[size];
9216 var inputblock = input;
9220 cls: 'glyphicon form-control-feedback'
9223 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9226 cls : 'has-feedback',
9234 if (this.before || this.after) {
9237 cls : 'input-group',
9241 if (this.before && typeof(this.before) == 'string') {
9243 inputblock.cn.push({
9245 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9249 if (this.before && typeof(this.before) == 'object') {
9250 this.before = Roo.factory(this.before);
9252 inputblock.cn.push({
9254 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9255 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9259 inputblock.cn.push(input);
9261 if (this.after && typeof(this.after) == 'string') {
9262 inputblock.cn.push({
9264 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9268 if (this.after && typeof(this.after) == 'object') {
9269 this.after = Roo.factory(this.after);
9271 inputblock.cn.push({
9273 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9274 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9278 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9279 inputblock.cls += ' has-feedback';
9280 inputblock.cn.push(feedback);
9285 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9286 tooltip : 'This field is required'
9288 if (Roo.bootstrap.version == 4) {
9291 style : 'display-none'
9294 if (align ==='left' && this.fieldLabel.length) {
9296 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9303 cls : 'control-label col-form-label',
9304 html : this.fieldLabel
9315 var labelCfg = cfg.cn[1];
9316 var contentCfg = cfg.cn[2];
9318 if(this.indicatorpos == 'right'){
9323 cls : 'control-label col-form-label',
9327 html : this.fieldLabel
9341 labelCfg = cfg.cn[0];
9342 contentCfg = cfg.cn[1];
9346 if(this.labelWidth > 12){
9347 labelCfg.style = "width: " + this.labelWidth + 'px';
9350 if(this.labelWidth < 13 && this.labelmd == 0){
9351 this.labelmd = this.labelWidth;
9354 if(this.labellg > 0){
9355 labelCfg.cls += ' col-lg-' + this.labellg;
9356 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9359 if(this.labelmd > 0){
9360 labelCfg.cls += ' col-md-' + this.labelmd;
9361 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9364 if(this.labelsm > 0){
9365 labelCfg.cls += ' col-sm-' + this.labelsm;
9366 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9369 if(this.labelxs > 0){
9370 labelCfg.cls += ' col-xs-' + this.labelxs;
9371 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9375 } else if ( this.fieldLabel.length) {
9380 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9381 tooltip : 'This field is required'
9385 //cls : 'input-group-addon',
9386 html : this.fieldLabel
9394 if(this.indicatorpos == 'right'){
9399 //cls : 'input-group-addon',
9400 html : this.fieldLabel
9405 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9406 tooltip : 'This field is required'
9426 if (this.parentType === 'Navbar' && this.parent().bar) {
9427 cfg.cls += ' navbar-form';
9430 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9431 // on BS4 we do this only if not form
9432 cfg.cls += ' navbar-form';
9440 * return the real input element.
9442 inputEl: function ()
9444 return this.el.select('input.form-control',true).first();
9447 tooltipEl : function()
9449 return this.inputEl();
9452 indicatorEl : function()
9454 if (Roo.bootstrap.version == 4) {
9455 return false; // not enabled in v4 yet.
9458 var indicator = this.el.select('i.roo-required-indicator',true).first();
9468 setDisabled : function(v)
9470 var i = this.inputEl().dom;
9472 i.removeAttribute('disabled');
9476 i.setAttribute('disabled','true');
9478 initEvents : function()
9481 this.inputEl().on("keydown" , this.fireKey, this);
9482 this.inputEl().on("focus", this.onFocus, this);
9483 this.inputEl().on("blur", this.onBlur, this);
9485 this.inputEl().relayEvent('keyup', this);
9487 this.indicator = this.indicatorEl();
9490 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9493 // reference to original value for reset
9494 this.originalValue = this.getValue();
9495 //Roo.form.TextField.superclass.initEvents.call(this);
9496 if(this.validationEvent == 'keyup'){
9497 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9498 this.inputEl().on('keyup', this.filterValidation, this);
9500 else if(this.validationEvent !== false){
9501 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9504 if(this.selectOnFocus){
9505 this.on("focus", this.preFocus, this);
9508 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9509 this.inputEl().on("keypress", this.filterKeys, this);
9511 this.inputEl().relayEvent('keypress', this);
9514 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9515 this.el.on("click", this.autoSize, this);
9518 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9519 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9522 if (typeof(this.before) == 'object') {
9523 this.before.render(this.el.select('.roo-input-before',true).first());
9525 if (typeof(this.after) == 'object') {
9526 this.after.render(this.el.select('.roo-input-after',true).first());
9529 this.inputEl().on('change', this.onChange, this);
9532 filterValidation : function(e){
9533 if(!e.isNavKeyPress()){
9534 this.validationTask.delay(this.validationDelay);
9538 * Validates the field value
9539 * @return {Boolean} True if the value is valid, else false
9541 validate : function(){
9542 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9543 if(this.disabled || this.validateValue(this.getRawValue())){
9554 * Validates a value according to the field's validation rules and marks the field as invalid
9555 * if the validation fails
9556 * @param {Mixed} value The value to validate
9557 * @return {Boolean} True if the value is valid, else false
9559 validateValue : function(value)
9561 if(this.getVisibilityEl().hasClass('hidden')){
9565 if(value.length < 1) { // if it's blank
9566 if(this.allowBlank){
9572 if(value.length < this.minLength){
9575 if(value.length > this.maxLength){
9579 var vt = Roo.form.VTypes;
9580 if(!vt[this.vtype](value, this)){
9584 if(typeof this.validator == "function"){
9585 var msg = this.validator(value);
9589 if (typeof(msg) == 'string') {
9590 this.invalidText = msg;
9594 if(this.regex && !this.regex.test(value)){
9602 fireKey : function(e){
9603 //Roo.log('field ' + e.getKey());
9604 if(e.isNavKeyPress()){
9605 this.fireEvent("specialkey", this, e);
9608 focus : function (selectText){
9610 this.inputEl().focus();
9611 if(selectText === true){
9612 this.inputEl().dom.select();
9618 onFocus : function(){
9619 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9620 // this.el.addClass(this.focusClass);
9623 this.hasFocus = true;
9624 this.startValue = this.getValue();
9625 this.fireEvent("focus", this);
9629 beforeBlur : Roo.emptyFn,
9633 onBlur : function(){
9635 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9636 //this.el.removeClass(this.focusClass);
9638 this.hasFocus = false;
9639 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9642 var v = this.getValue();
9643 if(String(v) !== String(this.startValue)){
9644 this.fireEvent('change', this, v, this.startValue);
9646 this.fireEvent("blur", this);
9649 onChange : function(e)
9651 var v = this.getValue();
9652 if(String(v) !== String(this.startValue)){
9653 this.fireEvent('change', this, v, this.startValue);
9659 * Resets the current field value to the originally loaded value and clears any validation messages
9662 this.setValue(this.originalValue);
9666 * Returns the name of the field
9667 * @return {Mixed} name The name field
9669 getName: function(){
9673 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9674 * @return {Mixed} value The field value
9676 getValue : function(){
9678 var v = this.inputEl().getValue();
9683 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9684 * @return {Mixed} value The field value
9686 getRawValue : function(){
9687 var v = this.inputEl().getValue();
9693 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9694 * @param {Mixed} value The value to set
9696 setRawValue : function(v){
9697 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9700 selectText : function(start, end){
9701 var v = this.getRawValue();
9703 start = start === undefined ? 0 : start;
9704 end = end === undefined ? v.length : end;
9705 var d = this.inputEl().dom;
9706 if(d.setSelectionRange){
9707 d.setSelectionRange(start, end);
9708 }else if(d.createTextRange){
9709 var range = d.createTextRange();
9710 range.moveStart("character", start);
9711 range.moveEnd("character", v.length-end);
9718 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9719 * @param {Mixed} value The value to set
9721 setValue : function(v){
9724 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9730 processValue : function(value){
9731 if(this.stripCharsRe){
9732 var newValue = value.replace(this.stripCharsRe, '');
9733 if(newValue !== value){
9734 this.setRawValue(newValue);
9741 preFocus : function(){
9743 if(this.selectOnFocus){
9744 this.inputEl().dom.select();
9747 filterKeys : function(e){
9749 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9752 var c = e.getCharCode(), cc = String.fromCharCode(c);
9753 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9756 if(!this.maskRe.test(cc)){
9761 * Clear any invalid styles/messages for this field
9763 clearInvalid : function(){
9765 if(!this.el || this.preventMark){ // not rendered
9770 this.el.removeClass([this.invalidClass, 'is-invalid']);
9772 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9774 var feedback = this.el.select('.form-control-feedback', true).first();
9777 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9783 this.indicator.removeClass('visible');
9784 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9787 this.fireEvent('valid', this);
9791 * Mark this field as valid
9793 markValid : function()
9795 if(!this.el || this.preventMark){ // not rendered...
9799 this.el.removeClass([this.invalidClass, this.validClass]);
9800 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9802 var feedback = this.el.select('.form-control-feedback', true).first();
9805 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9809 this.indicator.removeClass('visible');
9810 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9817 if(this.allowBlank && !this.getRawValue().length){
9820 if (Roo.bootstrap.version == 3) {
9821 this.el.addClass(this.validClass);
9823 this.inputEl().addClass('is-valid');
9826 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9828 var feedback = this.el.select('.form-control-feedback', true).first();
9831 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9832 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9837 this.fireEvent('valid', this);
9841 * Mark this field as invalid
9842 * @param {String} msg The validation message
9844 markInvalid : function(msg)
9846 if(!this.el || this.preventMark){ // not rendered
9850 this.el.removeClass([this.invalidClass, this.validClass]);
9851 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9853 var feedback = this.el.select('.form-control-feedback', true).first();
9856 this.el.select('.form-control-feedback', true).first().removeClass(
9857 [this.invalidFeedbackClass, this.validFeedbackClass]);
9864 if(this.allowBlank && !this.getRawValue().length){
9869 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9870 this.indicator.addClass('visible');
9872 if (Roo.bootstrap.version == 3) {
9873 this.el.addClass(this.invalidClass);
9875 this.inputEl().addClass('is-invalid');
9880 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9882 var feedback = this.el.select('.form-control-feedback', true).first();
9885 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9887 if(this.getValue().length || this.forceFeedback){
9888 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9895 this.fireEvent('invalid', this, msg);
9898 SafariOnKeyDown : function(event)
9900 // this is a workaround for a password hang bug on chrome/ webkit.
9901 if (this.inputEl().dom.type != 'password') {
9905 var isSelectAll = false;
9907 if(this.inputEl().dom.selectionEnd > 0){
9908 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9910 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9911 event.preventDefault();
9916 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9918 event.preventDefault();
9919 // this is very hacky as keydown always get's upper case.
9921 var cc = String.fromCharCode(event.getCharCode());
9922 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9926 adjustWidth : function(tag, w){
9927 tag = tag.toLowerCase();
9928 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9929 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9933 if(tag == 'textarea'){
9936 }else if(Roo.isOpera){
9940 if(tag == 'textarea'){
9948 setFieldLabel : function(v)
9954 if(this.indicatorEl()){
9955 var ar = this.el.select('label > span',true);
9957 if (ar.elements.length) {
9958 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9959 this.fieldLabel = v;
9963 var br = this.el.select('label',true);
9965 if(br.elements.length) {
9966 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9967 this.fieldLabel = v;
9971 Roo.log('Cannot Found any of label > span || label in input');
9975 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9976 this.fieldLabel = v;
9991 * @class Roo.bootstrap.TextArea
9992 * @extends Roo.bootstrap.Input
9993 * Bootstrap TextArea class
9994 * @cfg {Number} cols Specifies the visible width of a text area
9995 * @cfg {Number} rows Specifies the visible number of lines in a text area
9996 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9997 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9998 * @cfg {string} html text
10001 * Create a new TextArea
10002 * @param {Object} config The config object
10005 Roo.bootstrap.TextArea = function(config){
10006 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10010 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10020 getAutoCreate : function(){
10022 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10028 if(this.inputType != 'hidden'){
10029 cfg.cls = 'form-group' //input-group
10037 value : this.value || '',
10038 html: this.html || '',
10039 cls : 'form-control',
10040 placeholder : this.placeholder || ''
10044 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10045 input.maxLength = this.maxLength;
10049 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10053 input.cols = this.cols;
10056 if (this.readOnly) {
10057 input.readonly = true;
10061 input.name = this.name;
10065 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10069 ['xs','sm','md','lg'].map(function(size){
10070 if (settings[size]) {
10071 cfg.cls += ' col-' + size + '-' + settings[size];
10075 var inputblock = input;
10077 if(this.hasFeedback && !this.allowBlank){
10081 cls: 'glyphicon form-control-feedback'
10085 cls : 'has-feedback',
10094 if (this.before || this.after) {
10097 cls : 'input-group',
10101 inputblock.cn.push({
10103 cls : 'input-group-addon',
10108 inputblock.cn.push(input);
10110 if(this.hasFeedback && !this.allowBlank){
10111 inputblock.cls += ' has-feedback';
10112 inputblock.cn.push(feedback);
10116 inputblock.cn.push({
10118 cls : 'input-group-addon',
10125 if (align ==='left' && this.fieldLabel.length) {
10130 cls : 'control-label',
10131 html : this.fieldLabel
10142 if(this.labelWidth > 12){
10143 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10146 if(this.labelWidth < 13 && this.labelmd == 0){
10147 this.labelmd = this.labelWidth;
10150 if(this.labellg > 0){
10151 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10152 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10155 if(this.labelmd > 0){
10156 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10157 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10160 if(this.labelsm > 0){
10161 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10162 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10165 if(this.labelxs > 0){
10166 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10167 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10170 } else if ( this.fieldLabel.length) {
10175 //cls : 'input-group-addon',
10176 html : this.fieldLabel
10194 if (this.disabled) {
10195 input.disabled=true;
10202 * return the real textarea element.
10204 inputEl: function ()
10206 return this.el.select('textarea.form-control',true).first();
10210 * Clear any invalid styles/messages for this field
10212 clearInvalid : function()
10215 if(!this.el || this.preventMark){ // not rendered
10219 var label = this.el.select('label', true).first();
10220 var icon = this.el.select('i.fa-star', true).first();
10225 this.el.removeClass( this.validClass);
10226 this.inputEl().removeClass('is-invalid');
10228 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10230 var feedback = this.el.select('.form-control-feedback', true).first();
10233 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10238 this.fireEvent('valid', this);
10242 * Mark this field as valid
10244 markValid : function()
10246 if(!this.el || this.preventMark){ // not rendered
10250 this.el.removeClass([this.invalidClass, this.validClass]);
10251 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10253 var feedback = this.el.select('.form-control-feedback', true).first();
10256 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10259 if(this.disabled || this.allowBlank){
10263 var label = this.el.select('label', true).first();
10264 var icon = this.el.select('i.fa-star', true).first();
10269 if (Roo.bootstrap.version == 3) {
10270 this.el.addClass(this.validClass);
10272 this.inputEl().addClass('is-valid');
10276 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10278 var feedback = this.el.select('.form-control-feedback', true).first();
10281 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10282 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10287 this.fireEvent('valid', this);
10291 * Mark this field as invalid
10292 * @param {String} msg The validation message
10294 markInvalid : function(msg)
10296 if(!this.el || this.preventMark){ // not rendered
10300 this.el.removeClass([this.invalidClass, this.validClass]);
10301 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10303 var feedback = this.el.select('.form-control-feedback', true).first();
10306 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10309 if(this.disabled || this.allowBlank){
10313 var label = this.el.select('label', true).first();
10314 var icon = this.el.select('i.fa-star', true).first();
10316 if(!this.getValue().length && label && !icon){
10317 this.el.createChild({
10319 cls : 'text-danger fa fa-lg fa-star',
10320 tooltip : 'This field is required',
10321 style : 'margin-right:5px;'
10325 if (Roo.bootstrap.version == 3) {
10326 this.el.addClass(this.invalidClass);
10328 this.inputEl().addClass('is-invalid');
10331 // fixme ... this may be depricated need to test..
10332 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10334 var feedback = this.el.select('.form-control-feedback', true).first();
10337 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10339 if(this.getValue().length || this.forceFeedback){
10340 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10347 this.fireEvent('invalid', this, msg);
10355 * trigger field - base class for combo..
10360 * @class Roo.bootstrap.TriggerField
10361 * @extends Roo.bootstrap.Input
10362 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10363 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10364 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10365 * for which you can provide a custom implementation. For example:
10367 var trigger = new Roo.bootstrap.TriggerField();
10368 trigger.onTriggerClick = myTriggerFn;
10369 trigger.applyTo('my-field');
10372 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10373 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10374 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10375 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10376 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10379 * Create a new TriggerField.
10380 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10381 * to the base TextField)
10383 Roo.bootstrap.TriggerField = function(config){
10384 this.mimicing = false;
10385 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10388 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10390 * @cfg {String} triggerClass A CSS class to apply to the trigger
10393 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10398 * @cfg {Boolean} removable (true|false) special filter default false
10402 /** @cfg {Boolean} grow @hide */
10403 /** @cfg {Number} growMin @hide */
10404 /** @cfg {Number} growMax @hide */
10410 autoSize: Roo.emptyFn,
10414 deferHeight : true,
10417 actionMode : 'wrap',
10422 getAutoCreate : function(){
10424 var align = this.labelAlign || this.parentLabelAlign();
10429 cls: 'form-group' //input-group
10436 type : this.inputType,
10437 cls : 'form-control',
10438 autocomplete: 'new-password',
10439 placeholder : this.placeholder || ''
10443 input.name = this.name;
10446 input.cls += ' input-' + this.size;
10449 if (this.disabled) {
10450 input.disabled=true;
10453 var inputblock = input;
10455 if(this.hasFeedback && !this.allowBlank){
10459 cls: 'glyphicon form-control-feedback'
10462 if(this.removable && !this.editable && !this.tickable){
10464 cls : 'has-feedback',
10470 cls : 'roo-combo-removable-btn close'
10477 cls : 'has-feedback',
10486 if(this.removable && !this.editable && !this.tickable){
10488 cls : 'roo-removable',
10494 cls : 'roo-combo-removable-btn close'
10501 if (this.before || this.after) {
10504 cls : 'input-group',
10508 inputblock.cn.push({
10510 cls : 'input-group-addon input-group-prepend input-group-text',
10515 inputblock.cn.push(input);
10517 if(this.hasFeedback && !this.allowBlank){
10518 inputblock.cls += ' has-feedback';
10519 inputblock.cn.push(feedback);
10523 inputblock.cn.push({
10525 cls : 'input-group-addon input-group-append input-group-text',
10534 var ibwrap = inputblock;
10539 cls: 'roo-select2-choices',
10543 cls: 'roo-select2-search-field',
10555 cls: 'roo-select2-container input-group',
10560 cls: 'form-hidden-field'
10566 if(!this.multiple && this.showToggleBtn){
10572 if (this.caret != false) {
10575 cls: 'fa fa-' + this.caret
10582 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10587 cls: 'combobox-clear',
10601 combobox.cls += ' roo-select2-container-multi';
10605 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10606 tooltip : 'This field is required'
10608 if (Roo.bootstrap.version == 4) {
10611 style : 'display:none'
10616 if (align ==='left' && this.fieldLabel.length) {
10618 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10625 cls : 'control-label',
10626 html : this.fieldLabel
10638 var labelCfg = cfg.cn[1];
10639 var contentCfg = cfg.cn[2];
10641 if(this.indicatorpos == 'right'){
10646 cls : 'control-label',
10650 html : this.fieldLabel
10664 labelCfg = cfg.cn[0];
10665 contentCfg = cfg.cn[1];
10668 if(this.labelWidth > 12){
10669 labelCfg.style = "width: " + this.labelWidth + 'px';
10672 if(this.labelWidth < 13 && this.labelmd == 0){
10673 this.labelmd = this.labelWidth;
10676 if(this.labellg > 0){
10677 labelCfg.cls += ' col-lg-' + this.labellg;
10678 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10681 if(this.labelmd > 0){
10682 labelCfg.cls += ' col-md-' + this.labelmd;
10683 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10686 if(this.labelsm > 0){
10687 labelCfg.cls += ' col-sm-' + this.labelsm;
10688 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10691 if(this.labelxs > 0){
10692 labelCfg.cls += ' col-xs-' + this.labelxs;
10693 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10696 } else if ( this.fieldLabel.length) {
10697 // Roo.log(" label");
10702 //cls : 'input-group-addon',
10703 html : this.fieldLabel
10711 if(this.indicatorpos == 'right'){
10719 html : this.fieldLabel
10733 // Roo.log(" no label && no align");
10740 ['xs','sm','md','lg'].map(function(size){
10741 if (settings[size]) {
10742 cfg.cls += ' col-' + size + '-' + settings[size];
10753 onResize : function(w, h){
10754 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10755 // if(typeof w == 'number'){
10756 // var x = w - this.trigger.getWidth();
10757 // this.inputEl().setWidth(this.adjustWidth('input', x));
10758 // this.trigger.setStyle('left', x+'px');
10763 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10766 getResizeEl : function(){
10767 return this.inputEl();
10771 getPositionEl : function(){
10772 return this.inputEl();
10776 alignErrorIcon : function(){
10777 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10781 initEvents : function(){
10785 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10786 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10787 if(!this.multiple && this.showToggleBtn){
10788 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10789 if(this.hideTrigger){
10790 this.trigger.setDisplayed(false);
10792 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10796 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10799 if(this.removable && !this.editable && !this.tickable){
10800 var close = this.closeTriggerEl();
10803 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10804 close.on('click', this.removeBtnClick, this, close);
10808 //this.trigger.addClassOnOver('x-form-trigger-over');
10809 //this.trigger.addClassOnClick('x-form-trigger-click');
10812 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10816 closeTriggerEl : function()
10818 var close = this.el.select('.roo-combo-removable-btn', true).first();
10819 return close ? close : false;
10822 removeBtnClick : function(e, h, el)
10824 e.preventDefault();
10826 if(this.fireEvent("remove", this) !== false){
10828 this.fireEvent("afterremove", this)
10832 createList : function()
10834 this.list = Roo.get(document.body).createChild({
10835 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10836 cls: 'typeahead typeahead-long dropdown-menu',
10837 style: 'display:none'
10840 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10845 initTrigger : function(){
10850 onDestroy : function(){
10852 this.trigger.removeAllListeners();
10853 // this.trigger.remove();
10856 // this.wrap.remove();
10858 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10862 onFocus : function(){
10863 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10865 if(!this.mimicing){
10866 this.wrap.addClass('x-trigger-wrap-focus');
10867 this.mimicing = true;
10868 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10869 if(this.monitorTab){
10870 this.el.on("keydown", this.checkTab, this);
10877 checkTab : function(e){
10878 if(e.getKey() == e.TAB){
10879 this.triggerBlur();
10884 onBlur : function(){
10889 mimicBlur : function(e, t){
10891 if(!this.wrap.contains(t) && this.validateBlur()){
10892 this.triggerBlur();
10898 triggerBlur : function(){
10899 this.mimicing = false;
10900 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10901 if(this.monitorTab){
10902 this.el.un("keydown", this.checkTab, this);
10904 //this.wrap.removeClass('x-trigger-wrap-focus');
10905 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10909 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10910 validateBlur : function(e, t){
10915 onDisable : function(){
10916 this.inputEl().dom.disabled = true;
10917 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10919 // this.wrap.addClass('x-item-disabled');
10924 onEnable : function(){
10925 this.inputEl().dom.disabled = false;
10926 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10928 // this.el.removeClass('x-item-disabled');
10933 onShow : function(){
10934 var ae = this.getActionEl();
10937 ae.dom.style.display = '';
10938 ae.dom.style.visibility = 'visible';
10944 onHide : function(){
10945 var ae = this.getActionEl();
10946 ae.dom.style.display = 'none';
10950 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10951 * by an implementing function.
10953 * @param {EventObject} e
10955 onTriggerClick : Roo.emptyFn
10959 * Ext JS Library 1.1.1
10960 * Copyright(c) 2006-2007, Ext JS, LLC.
10962 * Originally Released Under LGPL - original licence link has changed is not relivant.
10965 * <script type="text/javascript">
10970 * @class Roo.data.SortTypes
10972 * Defines the default sorting (casting?) comparison functions used when sorting data.
10974 Roo.data.SortTypes = {
10976 * Default sort that does nothing
10977 * @param {Mixed} s The value being converted
10978 * @return {Mixed} The comparison value
10980 none : function(s){
10985 * The regular expression used to strip tags
10989 stripTagsRE : /<\/?[^>]+>/gi,
10992 * Strips all HTML tags to sort on text only
10993 * @param {Mixed} s The value being converted
10994 * @return {String} The comparison value
10996 asText : function(s){
10997 return String(s).replace(this.stripTagsRE, "");
11001 * Strips all HTML tags to sort on text only - Case insensitive
11002 * @param {Mixed} s The value being converted
11003 * @return {String} The comparison value
11005 asUCText : function(s){
11006 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11010 * Case insensitive string
11011 * @param {Mixed} s The value being converted
11012 * @return {String} The comparison value
11014 asUCString : function(s) {
11015 return String(s).toUpperCase();
11020 * @param {Mixed} s The value being converted
11021 * @return {Number} The comparison value
11023 asDate : function(s) {
11027 if(s instanceof Date){
11028 return s.getTime();
11030 return Date.parse(String(s));
11035 * @param {Mixed} s The value being converted
11036 * @return {Float} The comparison value
11038 asFloat : function(s) {
11039 var val = parseFloat(String(s).replace(/,/g, ""));
11048 * @param {Mixed} s The value being converted
11049 * @return {Number} The comparison value
11051 asInt : function(s) {
11052 var val = parseInt(String(s).replace(/,/g, ""));
11060 * Ext JS Library 1.1.1
11061 * Copyright(c) 2006-2007, Ext JS, LLC.
11063 * Originally Released Under LGPL - original licence link has changed is not relivant.
11066 * <script type="text/javascript">
11070 * @class Roo.data.Record
11071 * Instances of this class encapsulate both record <em>definition</em> information, and record
11072 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11073 * to access Records cached in an {@link Roo.data.Store} object.<br>
11075 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11076 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11079 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11081 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11082 * {@link #create}. The parameters are the same.
11083 * @param {Array} data An associative Array of data values keyed by the field name.
11084 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11085 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11086 * not specified an integer id is generated.
11088 Roo.data.Record = function(data, id){
11089 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11094 * Generate a constructor for a specific record layout.
11095 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11096 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11097 * Each field definition object may contain the following properties: <ul>
11098 * <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,
11099 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11100 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11101 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11102 * is being used, then this is a string containing the javascript expression to reference the data relative to
11103 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11104 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11105 * this may be omitted.</p></li>
11106 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11107 * <ul><li>auto (Default, implies no conversion)</li>
11112 * <li>date</li></ul></p></li>
11113 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11114 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11115 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11116 * by the Reader into an object that will be stored in the Record. It is passed the
11117 * following parameters:<ul>
11118 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11120 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11122 * <br>usage:<br><pre><code>
11123 var TopicRecord = Roo.data.Record.create(
11124 {name: 'title', mapping: 'topic_title'},
11125 {name: 'author', mapping: 'username'},
11126 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11127 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11128 {name: 'lastPoster', mapping: 'user2'},
11129 {name: 'excerpt', mapping: 'post_text'}
11132 var myNewRecord = new TopicRecord({
11133 title: 'Do my job please',
11136 lastPost: new Date(),
11137 lastPoster: 'Animal',
11138 excerpt: 'No way dude!'
11140 myStore.add(myNewRecord);
11145 Roo.data.Record.create = function(o){
11146 var f = function(){
11147 f.superclass.constructor.apply(this, arguments);
11149 Roo.extend(f, Roo.data.Record);
11150 var p = f.prototype;
11151 p.fields = new Roo.util.MixedCollection(false, function(field){
11154 for(var i = 0, len = o.length; i < len; i++){
11155 p.fields.add(new Roo.data.Field(o[i]));
11157 f.getField = function(name){
11158 return p.fields.get(name);
11163 Roo.data.Record.AUTO_ID = 1000;
11164 Roo.data.Record.EDIT = 'edit';
11165 Roo.data.Record.REJECT = 'reject';
11166 Roo.data.Record.COMMIT = 'commit';
11168 Roo.data.Record.prototype = {
11170 * Readonly flag - true if this record has been modified.
11179 join : function(store){
11180 this.store = store;
11184 * Set the named field to the specified value.
11185 * @param {String} name The name of the field to set.
11186 * @param {Object} value The value to set the field to.
11188 set : function(name, value){
11189 if(this.data[name] == value){
11193 if(!this.modified){
11194 this.modified = {};
11196 if(typeof this.modified[name] == 'undefined'){
11197 this.modified[name] = this.data[name];
11199 this.data[name] = value;
11200 if(!this.editing && this.store){
11201 this.store.afterEdit(this);
11206 * Get the value of the named field.
11207 * @param {String} name The name of the field to get the value of.
11208 * @return {Object} The value of the field.
11210 get : function(name){
11211 return this.data[name];
11215 beginEdit : function(){
11216 this.editing = true;
11217 this.modified = {};
11221 cancelEdit : function(){
11222 this.editing = false;
11223 delete this.modified;
11227 endEdit : function(){
11228 this.editing = false;
11229 if(this.dirty && this.store){
11230 this.store.afterEdit(this);
11235 * Usually called by the {@link Roo.data.Store} which owns the Record.
11236 * Rejects all changes made to the Record since either creation, or the last commit operation.
11237 * Modified fields are reverted to their original values.
11239 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11240 * of reject operations.
11242 reject : function(){
11243 var m = this.modified;
11245 if(typeof m[n] != "function"){
11246 this.data[n] = m[n];
11249 this.dirty = false;
11250 delete this.modified;
11251 this.editing = false;
11253 this.store.afterReject(this);
11258 * Usually called by the {@link Roo.data.Store} which owns the Record.
11259 * Commits all changes made to the Record since either creation, or the last commit operation.
11261 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11262 * of commit operations.
11264 commit : function(){
11265 this.dirty = false;
11266 delete this.modified;
11267 this.editing = false;
11269 this.store.afterCommit(this);
11274 hasError : function(){
11275 return this.error != null;
11279 clearError : function(){
11284 * Creates a copy of this record.
11285 * @param {String} id (optional) A new record id if you don't want to use this record's id
11288 copy : function(newId) {
11289 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11293 * Ext JS Library 1.1.1
11294 * Copyright(c) 2006-2007, Ext JS, LLC.
11296 * Originally Released Under LGPL - original licence link has changed is not relivant.
11299 * <script type="text/javascript">
11305 * @class Roo.data.Store
11306 * @extends Roo.util.Observable
11307 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11308 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11310 * 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
11311 * has no knowledge of the format of the data returned by the Proxy.<br>
11313 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11314 * instances from the data object. These records are cached and made available through accessor functions.
11316 * Creates a new Store.
11317 * @param {Object} config A config object containing the objects needed for the Store to access data,
11318 * and read the data into Records.
11320 Roo.data.Store = function(config){
11321 this.data = new Roo.util.MixedCollection(false);
11322 this.data.getKey = function(o){
11325 this.baseParams = {};
11327 this.paramNames = {
11332 "multisort" : "_multisort"
11335 if(config && config.data){
11336 this.inlineData = config.data;
11337 delete config.data;
11340 Roo.apply(this, config);
11342 if(this.reader){ // reader passed
11343 this.reader = Roo.factory(this.reader, Roo.data);
11344 this.reader.xmodule = this.xmodule || false;
11345 if(!this.recordType){
11346 this.recordType = this.reader.recordType;
11348 if(this.reader.onMetaChange){
11349 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11353 if(this.recordType){
11354 this.fields = this.recordType.prototype.fields;
11356 this.modified = [];
11360 * @event datachanged
11361 * Fires when the data cache has changed, and a widget which is using this Store
11362 * as a Record cache should refresh its view.
11363 * @param {Store} this
11365 datachanged : true,
11367 * @event metachange
11368 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11369 * @param {Store} this
11370 * @param {Object} meta The JSON metadata
11375 * Fires when Records have been added to the Store
11376 * @param {Store} this
11377 * @param {Roo.data.Record[]} records The array of Records added
11378 * @param {Number} index The index at which the record(s) were added
11383 * Fires when a Record has been removed from the Store
11384 * @param {Store} this
11385 * @param {Roo.data.Record} record The Record that was removed
11386 * @param {Number} index The index at which the record was removed
11391 * Fires when a Record has been updated
11392 * @param {Store} this
11393 * @param {Roo.data.Record} record The Record that was updated
11394 * @param {String} operation The update operation being performed. Value may be one of:
11396 Roo.data.Record.EDIT
11397 Roo.data.Record.REJECT
11398 Roo.data.Record.COMMIT
11404 * Fires when the data cache has been cleared.
11405 * @param {Store} this
11409 * @event beforeload
11410 * Fires before a request is made for a new data object. If the beforeload handler returns false
11411 * the load action will be canceled.
11412 * @param {Store} this
11413 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11417 * @event beforeloadadd
11418 * Fires after a new set of Records has been loaded.
11419 * @param {Store} this
11420 * @param {Roo.data.Record[]} records The Records that were loaded
11421 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11423 beforeloadadd : true,
11426 * Fires after a new set of Records has been loaded, before they are added to the store.
11427 * @param {Store} this
11428 * @param {Roo.data.Record[]} records The Records that were loaded
11429 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11430 * @params {Object} return from reader
11434 * @event loadexception
11435 * Fires if an exception occurs in the Proxy during loading.
11436 * Called with the signature of the Proxy's "loadexception" event.
11437 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11440 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11441 * @param {Object} load options
11442 * @param {Object} jsonData from your request (normally this contains the Exception)
11444 loadexception : true
11448 this.proxy = Roo.factory(this.proxy, Roo.data);
11449 this.proxy.xmodule = this.xmodule || false;
11450 this.relayEvents(this.proxy, ["loadexception"]);
11452 this.sortToggle = {};
11453 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11455 Roo.data.Store.superclass.constructor.call(this);
11457 if(this.inlineData){
11458 this.loadData(this.inlineData);
11459 delete this.inlineData;
11463 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11465 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11466 * without a remote query - used by combo/forms at present.
11470 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11473 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11476 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11477 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11480 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11481 * on any HTTP request
11484 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11487 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11491 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11492 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11494 remoteSort : false,
11497 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11498 * loaded or when a record is removed. (defaults to false).
11500 pruneModifiedRecords : false,
11503 lastOptions : null,
11506 * Add Records to the Store and fires the add event.
11507 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11509 add : function(records){
11510 records = [].concat(records);
11511 for(var i = 0, len = records.length; i < len; i++){
11512 records[i].join(this);
11514 var index = this.data.length;
11515 this.data.addAll(records);
11516 this.fireEvent("add", this, records, index);
11520 * Remove a Record from the Store and fires the remove event.
11521 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11523 remove : function(record){
11524 var index = this.data.indexOf(record);
11525 this.data.removeAt(index);
11527 if(this.pruneModifiedRecords){
11528 this.modified.remove(record);
11530 this.fireEvent("remove", this, record, index);
11534 * Remove all Records from the Store and fires the clear event.
11536 removeAll : function(){
11538 if(this.pruneModifiedRecords){
11539 this.modified = [];
11541 this.fireEvent("clear", this);
11545 * Inserts Records to the Store at the given index and fires the add event.
11546 * @param {Number} index The start index at which to insert the passed Records.
11547 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11549 insert : function(index, records){
11550 records = [].concat(records);
11551 for(var i = 0, len = records.length; i < len; i++){
11552 this.data.insert(index, records[i]);
11553 records[i].join(this);
11555 this.fireEvent("add", this, records, index);
11559 * Get the index within the cache of the passed Record.
11560 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11561 * @return {Number} The index of the passed Record. Returns -1 if not found.
11563 indexOf : function(record){
11564 return this.data.indexOf(record);
11568 * Get the index within the cache of the Record with the passed id.
11569 * @param {String} id The id of the Record to find.
11570 * @return {Number} The index of the Record. Returns -1 if not found.
11572 indexOfId : function(id){
11573 return this.data.indexOfKey(id);
11577 * Get the Record with the specified id.
11578 * @param {String} id The id of the Record to find.
11579 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11581 getById : function(id){
11582 return this.data.key(id);
11586 * Get the Record at the specified index.
11587 * @param {Number} index The index of the Record to find.
11588 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11590 getAt : function(index){
11591 return this.data.itemAt(index);
11595 * Returns a range of Records between specified indices.
11596 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11597 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11598 * @return {Roo.data.Record[]} An array of Records
11600 getRange : function(start, end){
11601 return this.data.getRange(start, end);
11605 storeOptions : function(o){
11606 o = Roo.apply({}, o);
11609 this.lastOptions = o;
11613 * Loads the Record cache from the configured Proxy using the configured Reader.
11615 * If using remote paging, then the first load call must specify the <em>start</em>
11616 * and <em>limit</em> properties in the options.params property to establish the initial
11617 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11619 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11620 * and this call will return before the new data has been loaded. Perform any post-processing
11621 * in a callback function, or in a "load" event handler.</strong>
11623 * @param {Object} options An object containing properties which control loading options:<ul>
11624 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11625 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11626 * passed the following arguments:<ul>
11627 * <li>r : Roo.data.Record[]</li>
11628 * <li>options: Options object from the load call</li>
11629 * <li>success: Boolean success indicator</li></ul></li>
11630 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11631 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11634 load : function(options){
11635 options = options || {};
11636 if(this.fireEvent("beforeload", this, options) !== false){
11637 this.storeOptions(options);
11638 var p = Roo.apply(options.params || {}, this.baseParams);
11639 // if meta was not loaded from remote source.. try requesting it.
11640 if (!this.reader.metaFromRemote) {
11641 p._requestMeta = 1;
11643 if(this.sortInfo && this.remoteSort){
11644 var pn = this.paramNames;
11645 p[pn["sort"]] = this.sortInfo.field;
11646 p[pn["dir"]] = this.sortInfo.direction;
11648 if (this.multiSort) {
11649 var pn = this.paramNames;
11650 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11653 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11658 * Reloads the Record cache from the configured Proxy using the configured Reader and
11659 * the options from the last load operation performed.
11660 * @param {Object} options (optional) An object containing properties which may override the options
11661 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11662 * the most recently used options are reused).
11664 reload : function(options){
11665 this.load(Roo.applyIf(options||{}, this.lastOptions));
11669 // Called as a callback by the Reader during a load operation.
11670 loadRecords : function(o, options, success){
11671 if(!o || success === false){
11672 if(success !== false){
11673 this.fireEvent("load", this, [], options, o);
11675 if(options.callback){
11676 options.callback.call(options.scope || this, [], options, false);
11680 // if data returned failure - throw an exception.
11681 if (o.success === false) {
11682 // show a message if no listener is registered.
11683 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11684 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11686 // loadmask wil be hooked into this..
11687 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11690 var r = o.records, t = o.totalRecords || r.length;
11692 this.fireEvent("beforeloadadd", this, r, options, o);
11694 if(!options || options.add !== true){
11695 if(this.pruneModifiedRecords){
11696 this.modified = [];
11698 for(var i = 0, len = r.length; i < len; i++){
11702 this.data = this.snapshot;
11703 delete this.snapshot;
11706 this.data.addAll(r);
11707 this.totalLength = t;
11709 this.fireEvent("datachanged", this);
11711 this.totalLength = Math.max(t, this.data.length+r.length);
11715 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11717 var e = new Roo.data.Record({});
11719 e.set(this.parent.displayField, this.parent.emptyTitle);
11720 e.set(this.parent.valueField, '');
11725 this.fireEvent("load", this, r, options, o);
11726 if(options.callback){
11727 options.callback.call(options.scope || this, r, options, true);
11733 * Loads data from a passed data block. A Reader which understands the format of the data
11734 * must have been configured in the constructor.
11735 * @param {Object} data The data block from which to read the Records. The format of the data expected
11736 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11737 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11739 loadData : function(o, append){
11740 var r = this.reader.readRecords(o);
11741 this.loadRecords(r, {add: append}, true);
11745 * Gets the number of cached records.
11747 * <em>If using paging, this may not be the total size of the dataset. If the data object
11748 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11749 * the data set size</em>
11751 getCount : function(){
11752 return this.data.length || 0;
11756 * Gets the total number of records in the dataset as returned by the server.
11758 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11759 * the dataset size</em>
11761 getTotalCount : function(){
11762 return this.totalLength || 0;
11766 * Returns the sort state of the Store as an object with two properties:
11768 field {String} The name of the field by which the Records are sorted
11769 direction {String} The sort order, "ASC" or "DESC"
11772 getSortState : function(){
11773 return this.sortInfo;
11777 applySort : function(){
11778 if(this.sortInfo && !this.remoteSort){
11779 var s = this.sortInfo, f = s.field;
11780 var st = this.fields.get(f).sortType;
11781 var fn = function(r1, r2){
11782 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11783 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11785 this.data.sort(s.direction, fn);
11786 if(this.snapshot && this.snapshot != this.data){
11787 this.snapshot.sort(s.direction, fn);
11793 * Sets the default sort column and order to be used by the next load operation.
11794 * @param {String} fieldName The name of the field to sort by.
11795 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11797 setDefaultSort : function(field, dir){
11798 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11802 * Sort the Records.
11803 * If remote sorting is used, the sort is performed on the server, and the cache is
11804 * reloaded. If local sorting is used, the cache is sorted internally.
11805 * @param {String} fieldName The name of the field to sort by.
11806 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11808 sort : function(fieldName, dir){
11809 var f = this.fields.get(fieldName);
11811 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11813 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11814 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11819 this.sortToggle[f.name] = dir;
11820 this.sortInfo = {field: f.name, direction: dir};
11821 if(!this.remoteSort){
11823 this.fireEvent("datachanged", this);
11825 this.load(this.lastOptions);
11830 * Calls the specified function for each of the Records in the cache.
11831 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11832 * Returning <em>false</em> aborts and exits the iteration.
11833 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11835 each : function(fn, scope){
11836 this.data.each(fn, scope);
11840 * Gets all records modified since the last commit. Modified records are persisted across load operations
11841 * (e.g., during paging).
11842 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11844 getModifiedRecords : function(){
11845 return this.modified;
11849 createFilterFn : function(property, value, anyMatch){
11850 if(!value.exec){ // not a regex
11851 value = String(value);
11852 if(value.length == 0){
11855 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11857 return function(r){
11858 return value.test(r.data[property]);
11863 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11864 * @param {String} property A field on your records
11865 * @param {Number} start The record index to start at (defaults to 0)
11866 * @param {Number} end The last record index to include (defaults to length - 1)
11867 * @return {Number} The sum
11869 sum : function(property, start, end){
11870 var rs = this.data.items, v = 0;
11871 start = start || 0;
11872 end = (end || end === 0) ? end : rs.length-1;
11874 for(var i = start; i <= end; i++){
11875 v += (rs[i].data[property] || 0);
11881 * Filter the records by a specified property.
11882 * @param {String} field A field on your records
11883 * @param {String/RegExp} value Either a string that the field
11884 * should start with or a RegExp to test against the field
11885 * @param {Boolean} anyMatch True to match any part not just the beginning
11887 filter : function(property, value, anyMatch){
11888 var fn = this.createFilterFn(property, value, anyMatch);
11889 return fn ? this.filterBy(fn) : this.clearFilter();
11893 * Filter by a function. The specified function will be called with each
11894 * record in this data source. If the function returns true the record is included,
11895 * otherwise it is filtered.
11896 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11897 * @param {Object} scope (optional) The scope of the function (defaults to this)
11899 filterBy : function(fn, scope){
11900 this.snapshot = this.snapshot || this.data;
11901 this.data = this.queryBy(fn, scope||this);
11902 this.fireEvent("datachanged", this);
11906 * Query the records by a specified property.
11907 * @param {String} field A field on your records
11908 * @param {String/RegExp} value Either a string that the field
11909 * should start with or a RegExp to test against the field
11910 * @param {Boolean} anyMatch True to match any part not just the beginning
11911 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11913 query : function(property, value, anyMatch){
11914 var fn = this.createFilterFn(property, value, anyMatch);
11915 return fn ? this.queryBy(fn) : this.data.clone();
11919 * Query by a function. The specified function will be called with each
11920 * record in this data source. If the function returns true the record is included
11922 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11923 * @param {Object} scope (optional) The scope of the function (defaults to this)
11924 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11926 queryBy : function(fn, scope){
11927 var data = this.snapshot || this.data;
11928 return data.filterBy(fn, scope||this);
11932 * Collects unique values for a particular dataIndex from this store.
11933 * @param {String} dataIndex The property to collect
11934 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11935 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11936 * @return {Array} An array of the unique values
11938 collect : function(dataIndex, allowNull, bypassFilter){
11939 var d = (bypassFilter === true && this.snapshot) ?
11940 this.snapshot.items : this.data.items;
11941 var v, sv, r = [], l = {};
11942 for(var i = 0, len = d.length; i < len; i++){
11943 v = d[i].data[dataIndex];
11945 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11954 * Revert to a view of the Record cache with no filtering applied.
11955 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11957 clearFilter : function(suppressEvent){
11958 if(this.snapshot && this.snapshot != this.data){
11959 this.data = this.snapshot;
11960 delete this.snapshot;
11961 if(suppressEvent !== true){
11962 this.fireEvent("datachanged", this);
11968 afterEdit : function(record){
11969 if(this.modified.indexOf(record) == -1){
11970 this.modified.push(record);
11972 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11976 afterReject : function(record){
11977 this.modified.remove(record);
11978 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11982 afterCommit : function(record){
11983 this.modified.remove(record);
11984 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11988 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11989 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11991 commitChanges : function(){
11992 var m = this.modified.slice(0);
11993 this.modified = [];
11994 for(var i = 0, len = m.length; i < len; i++){
12000 * Cancel outstanding changes on all changed records.
12002 rejectChanges : function(){
12003 var m = this.modified.slice(0);
12004 this.modified = [];
12005 for(var i = 0, len = m.length; i < len; i++){
12010 onMetaChange : function(meta, rtype, o){
12011 this.recordType = rtype;
12012 this.fields = rtype.prototype.fields;
12013 delete this.snapshot;
12014 this.sortInfo = meta.sortInfo || this.sortInfo;
12015 this.modified = [];
12016 this.fireEvent('metachange', this, this.reader.meta);
12019 moveIndex : function(data, type)
12021 var index = this.indexOf(data);
12023 var newIndex = index + type;
12027 this.insert(newIndex, data);
12032 * Ext JS Library 1.1.1
12033 * Copyright(c) 2006-2007, Ext JS, LLC.
12035 * Originally Released Under LGPL - original licence link has changed is not relivant.
12038 * <script type="text/javascript">
12042 * @class Roo.data.SimpleStore
12043 * @extends Roo.data.Store
12044 * Small helper class to make creating Stores from Array data easier.
12045 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12046 * @cfg {Array} fields An array of field definition objects, or field name strings.
12047 * @cfg {Array} data The multi-dimensional array of data
12049 * @param {Object} config
12051 Roo.data.SimpleStore = function(config){
12052 Roo.data.SimpleStore.superclass.constructor.call(this, {
12054 reader: new Roo.data.ArrayReader({
12057 Roo.data.Record.create(config.fields)
12059 proxy : new Roo.data.MemoryProxy(config.data)
12063 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12065 * Ext JS Library 1.1.1
12066 * Copyright(c) 2006-2007, Ext JS, LLC.
12068 * Originally Released Under LGPL - original licence link has changed is not relivant.
12071 * <script type="text/javascript">
12076 * @extends Roo.data.Store
12077 * @class Roo.data.JsonStore
12078 * Small helper class to make creating Stores for JSON data easier. <br/>
12080 var store = new Roo.data.JsonStore({
12081 url: 'get-images.php',
12083 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12086 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12087 * JsonReader and HttpProxy (unless inline data is provided).</b>
12088 * @cfg {Array} fields An array of field definition objects, or field name strings.
12090 * @param {Object} config
12092 Roo.data.JsonStore = function(c){
12093 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12094 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12095 reader: new Roo.data.JsonReader(c, c.fields)
12098 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12100 * Ext JS Library 1.1.1
12101 * Copyright(c) 2006-2007, Ext JS, LLC.
12103 * Originally Released Under LGPL - original licence link has changed is not relivant.
12106 * <script type="text/javascript">
12110 Roo.data.Field = function(config){
12111 if(typeof config == "string"){
12112 config = {name: config};
12114 Roo.apply(this, config);
12117 this.type = "auto";
12120 var st = Roo.data.SortTypes;
12121 // named sortTypes are supported, here we look them up
12122 if(typeof this.sortType == "string"){
12123 this.sortType = st[this.sortType];
12126 // set default sortType for strings and dates
12127 if(!this.sortType){
12130 this.sortType = st.asUCString;
12133 this.sortType = st.asDate;
12136 this.sortType = st.none;
12141 var stripRe = /[\$,%]/g;
12143 // prebuilt conversion function for this field, instead of
12144 // switching every time we're reading a value
12146 var cv, dateFormat = this.dateFormat;
12151 cv = function(v){ return v; };
12154 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12158 return v !== undefined && v !== null && v !== '' ?
12159 parseInt(String(v).replace(stripRe, ""), 10) : '';
12164 return v !== undefined && v !== null && v !== '' ?
12165 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12170 cv = function(v){ return v === true || v === "true" || v == 1; };
12177 if(v instanceof Date){
12181 if(dateFormat == "timestamp"){
12182 return new Date(v*1000);
12184 return Date.parseDate(v, dateFormat);
12186 var parsed = Date.parse(v);
12187 return parsed ? new Date(parsed) : null;
12196 Roo.data.Field.prototype = {
12204 * Ext JS Library 1.1.1
12205 * Copyright(c) 2006-2007, Ext JS, LLC.
12207 * Originally Released Under LGPL - original licence link has changed is not relivant.
12210 * <script type="text/javascript">
12213 // Base class for reading structured data from a data source. This class is intended to be
12214 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12217 * @class Roo.data.DataReader
12218 * Base class for reading structured data from a data source. This class is intended to be
12219 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12222 Roo.data.DataReader = function(meta, recordType){
12226 this.recordType = recordType instanceof Array ?
12227 Roo.data.Record.create(recordType) : recordType;
12230 Roo.data.DataReader.prototype = {
12232 * Create an empty record
12233 * @param {Object} data (optional) - overlay some values
12234 * @return {Roo.data.Record} record created.
12236 newRow : function(d) {
12238 this.recordType.prototype.fields.each(function(c) {
12240 case 'int' : da[c.name] = 0; break;
12241 case 'date' : da[c.name] = new Date(); break;
12242 case 'float' : da[c.name] = 0.0; break;
12243 case 'boolean' : da[c.name] = false; break;
12244 default : da[c.name] = ""; break;
12248 return new this.recordType(Roo.apply(da, d));
12253 * Ext JS Library 1.1.1
12254 * Copyright(c) 2006-2007, Ext JS, LLC.
12256 * Originally Released Under LGPL - original licence link has changed is not relivant.
12259 * <script type="text/javascript">
12263 * @class Roo.data.DataProxy
12264 * @extends Roo.data.Observable
12265 * This class is an abstract base class for implementations which provide retrieval of
12266 * unformatted data objects.<br>
12268 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12269 * (of the appropriate type which knows how to parse the data object) to provide a block of
12270 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12272 * Custom implementations must implement the load method as described in
12273 * {@link Roo.data.HttpProxy#load}.
12275 Roo.data.DataProxy = function(){
12278 * @event beforeload
12279 * Fires before a network request is made to retrieve a data object.
12280 * @param {Object} This DataProxy object.
12281 * @param {Object} params The params parameter to the load function.
12286 * Fires before the load method's callback is called.
12287 * @param {Object} This DataProxy object.
12288 * @param {Object} o The data object.
12289 * @param {Object} arg The callback argument object passed to the load function.
12293 * @event loadexception
12294 * Fires if an Exception occurs during data retrieval.
12295 * @param {Object} This DataProxy object.
12296 * @param {Object} o The data object.
12297 * @param {Object} arg The callback argument object passed to the load function.
12298 * @param {Object} e The Exception.
12300 loadexception : true
12302 Roo.data.DataProxy.superclass.constructor.call(this);
12305 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12308 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12312 * Ext JS Library 1.1.1
12313 * Copyright(c) 2006-2007, Ext JS, LLC.
12315 * Originally Released Under LGPL - original licence link has changed is not relivant.
12318 * <script type="text/javascript">
12321 * @class Roo.data.MemoryProxy
12322 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12323 * to the Reader when its load method is called.
12325 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12327 Roo.data.MemoryProxy = function(data){
12331 Roo.data.MemoryProxy.superclass.constructor.call(this);
12335 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12338 * Load data from the requested source (in this case an in-memory
12339 * data object passed to the constructor), read the data object into
12340 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12341 * process that block using the passed callback.
12342 * @param {Object} params This parameter is not used by the MemoryProxy class.
12343 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12344 * object into a block of Roo.data.Records.
12345 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12346 * The function must be passed <ul>
12347 * <li>The Record block object</li>
12348 * <li>The "arg" argument from the load function</li>
12349 * <li>A boolean success indicator</li>
12351 * @param {Object} scope The scope in which to call the callback
12352 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12354 load : function(params, reader, callback, scope, arg){
12355 params = params || {};
12358 result = reader.readRecords(this.data);
12360 this.fireEvent("loadexception", this, arg, null, e);
12361 callback.call(scope, null, arg, false);
12364 callback.call(scope, result, arg, true);
12368 update : function(params, records){
12373 * Ext JS Library 1.1.1
12374 * Copyright(c) 2006-2007, Ext JS, LLC.
12376 * Originally Released Under LGPL - original licence link has changed is not relivant.
12379 * <script type="text/javascript">
12382 * @class Roo.data.HttpProxy
12383 * @extends Roo.data.DataProxy
12384 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12385 * configured to reference a certain URL.<br><br>
12387 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12388 * from which the running page was served.<br><br>
12390 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12392 * Be aware that to enable the browser to parse an XML document, the server must set
12393 * the Content-Type header in the HTTP response to "text/xml".
12395 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12396 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12397 * will be used to make the request.
12399 Roo.data.HttpProxy = function(conn){
12400 Roo.data.HttpProxy.superclass.constructor.call(this);
12401 // is conn a conn config or a real conn?
12403 this.useAjax = !conn || !conn.events;
12407 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12408 // thse are take from connection...
12411 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12414 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12415 * extra parameters to each request made by this object. (defaults to undefined)
12418 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12419 * to each request made by this object. (defaults to undefined)
12422 * @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)
12425 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12428 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12434 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12438 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12439 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12440 * a finer-grained basis than the DataProxy events.
12442 getConnection : function(){
12443 return this.useAjax ? Roo.Ajax : this.conn;
12447 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12448 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12449 * process that block using the passed callback.
12450 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12451 * for the request to the remote server.
12452 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12453 * object into a block of Roo.data.Records.
12454 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12455 * The function must be passed <ul>
12456 * <li>The Record block object</li>
12457 * <li>The "arg" argument from the load function</li>
12458 * <li>A boolean success indicator</li>
12460 * @param {Object} scope The scope in which to call the callback
12461 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12463 load : function(params, reader, callback, scope, arg){
12464 if(this.fireEvent("beforeload", this, params) !== false){
12466 params : params || {},
12468 callback : callback,
12473 callback : this.loadResponse,
12477 Roo.applyIf(o, this.conn);
12478 if(this.activeRequest){
12479 Roo.Ajax.abort(this.activeRequest);
12481 this.activeRequest = Roo.Ajax.request(o);
12483 this.conn.request(o);
12486 callback.call(scope||this, null, arg, false);
12491 loadResponse : function(o, success, response){
12492 delete this.activeRequest;
12494 this.fireEvent("loadexception", this, o, response);
12495 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12500 result = o.reader.read(response);
12502 this.fireEvent("loadexception", this, o, response, e);
12503 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12507 this.fireEvent("load", this, o, o.request.arg);
12508 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12512 update : function(dataSet){
12517 updateResponse : function(dataSet){
12522 * Ext JS Library 1.1.1
12523 * Copyright(c) 2006-2007, Ext JS, LLC.
12525 * Originally Released Under LGPL - original licence link has changed is not relivant.
12528 * <script type="text/javascript">
12532 * @class Roo.data.ScriptTagProxy
12533 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12534 * other than the originating domain of the running page.<br><br>
12536 * <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
12537 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12539 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12540 * source code that is used as the source inside a <script> tag.<br><br>
12542 * In order for the browser to process the returned data, the server must wrap the data object
12543 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12544 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12545 * depending on whether the callback name was passed:
12548 boolean scriptTag = false;
12549 String cb = request.getParameter("callback");
12552 response.setContentType("text/javascript");
12554 response.setContentType("application/x-json");
12556 Writer out = response.getWriter();
12558 out.write(cb + "(");
12560 out.print(dataBlock.toJsonString());
12567 * @param {Object} config A configuration object.
12569 Roo.data.ScriptTagProxy = function(config){
12570 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12571 Roo.apply(this, config);
12572 this.head = document.getElementsByTagName("head")[0];
12575 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12577 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12579 * @cfg {String} url The URL from which to request the data object.
12582 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12586 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12587 * the server the name of the callback function set up by the load call to process the returned data object.
12588 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12589 * javascript output which calls this named function passing the data object as its only parameter.
12591 callbackParam : "callback",
12593 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12594 * name to the request.
12599 * Load data from the configured URL, read the data object into
12600 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12601 * process that block using the passed callback.
12602 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12603 * for the request to the remote server.
12604 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12605 * object into a block of Roo.data.Records.
12606 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12607 * The function must be passed <ul>
12608 * <li>The Record block object</li>
12609 * <li>The "arg" argument from the load function</li>
12610 * <li>A boolean success indicator</li>
12612 * @param {Object} scope The scope in which to call the callback
12613 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12615 load : function(params, reader, callback, scope, arg){
12616 if(this.fireEvent("beforeload", this, params) !== false){
12618 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12620 var url = this.url;
12621 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12623 url += "&_dc=" + (new Date().getTime());
12625 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12628 cb : "stcCallback"+transId,
12629 scriptId : "stcScript"+transId,
12633 callback : callback,
12639 window[trans.cb] = function(o){
12640 conn.handleResponse(o, trans);
12643 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12645 if(this.autoAbort !== false){
12649 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12651 var script = document.createElement("script");
12652 script.setAttribute("src", url);
12653 script.setAttribute("type", "text/javascript");
12654 script.setAttribute("id", trans.scriptId);
12655 this.head.appendChild(script);
12657 this.trans = trans;
12659 callback.call(scope||this, null, arg, false);
12664 isLoading : function(){
12665 return this.trans ? true : false;
12669 * Abort the current server request.
12671 abort : function(){
12672 if(this.isLoading()){
12673 this.destroyTrans(this.trans);
12678 destroyTrans : function(trans, isLoaded){
12679 this.head.removeChild(document.getElementById(trans.scriptId));
12680 clearTimeout(trans.timeoutId);
12682 window[trans.cb] = undefined;
12684 delete window[trans.cb];
12687 // if hasn't been loaded, wait for load to remove it to prevent script error
12688 window[trans.cb] = function(){
12689 window[trans.cb] = undefined;
12691 delete window[trans.cb];
12698 handleResponse : function(o, trans){
12699 this.trans = false;
12700 this.destroyTrans(trans, true);
12703 result = trans.reader.readRecords(o);
12705 this.fireEvent("loadexception", this, o, trans.arg, e);
12706 trans.callback.call(trans.scope||window, null, trans.arg, false);
12709 this.fireEvent("load", this, o, trans.arg);
12710 trans.callback.call(trans.scope||window, result, trans.arg, true);
12714 handleFailure : function(trans){
12715 this.trans = false;
12716 this.destroyTrans(trans, false);
12717 this.fireEvent("loadexception", this, null, trans.arg);
12718 trans.callback.call(trans.scope||window, null, trans.arg, false);
12722 * Ext JS Library 1.1.1
12723 * Copyright(c) 2006-2007, Ext JS, LLC.
12725 * Originally Released Under LGPL - original licence link has changed is not relivant.
12728 * <script type="text/javascript">
12732 * @class Roo.data.JsonReader
12733 * @extends Roo.data.DataReader
12734 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12735 * based on mappings in a provided Roo.data.Record constructor.
12737 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12738 * in the reply previously.
12743 var RecordDef = Roo.data.Record.create([
12744 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12745 {name: 'occupation'} // This field will use "occupation" as the mapping.
12747 var myReader = new Roo.data.JsonReader({
12748 totalProperty: "results", // The property which contains the total dataset size (optional)
12749 root: "rows", // The property which contains an Array of row objects
12750 id: "id" // The property within each row object that provides an ID for the record (optional)
12754 * This would consume a JSON file like this:
12756 { 'results': 2, 'rows': [
12757 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12758 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12761 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12762 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12763 * paged from the remote server.
12764 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12765 * @cfg {String} root name of the property which contains the Array of row objects.
12766 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12767 * @cfg {Array} fields Array of field definition objects
12769 * Create a new JsonReader
12770 * @param {Object} meta Metadata configuration options
12771 * @param {Object} recordType Either an Array of field definition objects,
12772 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12774 Roo.data.JsonReader = function(meta, recordType){
12777 // set some defaults:
12778 Roo.applyIf(meta, {
12779 totalProperty: 'total',
12780 successProperty : 'success',
12785 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12787 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12790 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12791 * Used by Store query builder to append _requestMeta to params.
12794 metaFromRemote : false,
12796 * This method is only used by a DataProxy which has retrieved data from a remote server.
12797 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12798 * @return {Object} data A data block which is used by an Roo.data.Store object as
12799 * a cache of Roo.data.Records.
12801 read : function(response){
12802 var json = response.responseText;
12804 var o = /* eval:var:o */ eval("("+json+")");
12806 throw {message: "JsonReader.read: Json object not found"};
12812 this.metaFromRemote = true;
12813 this.meta = o.metaData;
12814 this.recordType = Roo.data.Record.create(o.metaData.fields);
12815 this.onMetaChange(this.meta, this.recordType, o);
12817 return this.readRecords(o);
12820 // private function a store will implement
12821 onMetaChange : function(meta, recordType, o){
12828 simpleAccess: function(obj, subsc) {
12835 getJsonAccessor: function(){
12837 return function(expr) {
12839 return(re.test(expr))
12840 ? new Function("obj", "return obj." + expr)
12845 return Roo.emptyFn;
12850 * Create a data block containing Roo.data.Records from an XML document.
12851 * @param {Object} o An object which contains an Array of row objects in the property specified
12852 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12853 * which contains the total size of the dataset.
12854 * @return {Object} data A data block which is used by an Roo.data.Store object as
12855 * a cache of Roo.data.Records.
12857 readRecords : function(o){
12859 * After any data loads, the raw JSON data is available for further custom processing.
12863 var s = this.meta, Record = this.recordType,
12864 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12866 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12868 if(s.totalProperty) {
12869 this.getTotal = this.getJsonAccessor(s.totalProperty);
12871 if(s.successProperty) {
12872 this.getSuccess = this.getJsonAccessor(s.successProperty);
12874 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12876 var g = this.getJsonAccessor(s.id);
12877 this.getId = function(rec) {
12879 return (r === undefined || r === "") ? null : r;
12882 this.getId = function(){return null;};
12885 for(var jj = 0; jj < fl; jj++){
12887 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12888 this.ef[jj] = this.getJsonAccessor(map);
12892 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12893 if(s.totalProperty){
12894 var vt = parseInt(this.getTotal(o), 10);
12899 if(s.successProperty){
12900 var vs = this.getSuccess(o);
12901 if(vs === false || vs === 'false'){
12906 for(var i = 0; i < c; i++){
12909 var id = this.getId(n);
12910 for(var j = 0; j < fl; j++){
12912 var v = this.ef[j](n);
12914 Roo.log('missing convert for ' + f.name);
12918 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12920 var record = new Record(values, id);
12922 records[i] = record;
12928 totalRecords : totalRecords
12933 * Ext JS Library 1.1.1
12934 * Copyright(c) 2006-2007, Ext JS, LLC.
12936 * Originally Released Under LGPL - original licence link has changed is not relivant.
12939 * <script type="text/javascript">
12943 * @class Roo.data.ArrayReader
12944 * @extends Roo.data.DataReader
12945 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12946 * Each element of that Array represents a row of data fields. The
12947 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12948 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12952 var RecordDef = Roo.data.Record.create([
12953 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12954 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12956 var myReader = new Roo.data.ArrayReader({
12957 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12961 * This would consume an Array like this:
12963 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12965 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12967 * Create a new JsonReader
12968 * @param {Object} meta Metadata configuration options.
12969 * @param {Object} recordType Either an Array of field definition objects
12970 * as specified to {@link Roo.data.Record#create},
12971 * or an {@link Roo.data.Record} object
12972 * created using {@link Roo.data.Record#create}.
12974 Roo.data.ArrayReader = function(meta, recordType){
12975 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12978 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12980 * Create a data block containing Roo.data.Records from an XML document.
12981 * @param {Object} o An Array of row objects which represents the dataset.
12982 * @return {Object} data A data block which is used by an Roo.data.Store object as
12983 * a cache of Roo.data.Records.
12985 readRecords : function(o){
12986 var sid = this.meta ? this.meta.id : null;
12987 var recordType = this.recordType, fields = recordType.prototype.fields;
12990 for(var i = 0; i < root.length; i++){
12993 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12994 for(var j = 0, jlen = fields.length; j < jlen; j++){
12995 var f = fields.items[j];
12996 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12997 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12999 values[f.name] = v;
13001 var record = new recordType(values, id);
13003 records[records.length] = record;
13007 totalRecords : records.length
13016 * @class Roo.bootstrap.ComboBox
13017 * @extends Roo.bootstrap.TriggerField
13018 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13019 * @cfg {Boolean} append (true|false) default false
13020 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13021 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13022 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13023 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13024 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13025 * @cfg {Boolean} animate default true
13026 * @cfg {Boolean} emptyResultText only for touch device
13027 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13028 * @cfg {String} emptyTitle default ''
13030 * Create a new ComboBox.
13031 * @param {Object} config Configuration options
13033 Roo.bootstrap.ComboBox = function(config){
13034 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13038 * Fires when the dropdown list is expanded
13039 * @param {Roo.bootstrap.ComboBox} combo This combo box
13044 * Fires when the dropdown list is collapsed
13045 * @param {Roo.bootstrap.ComboBox} combo This combo box
13049 * @event beforeselect
13050 * Fires before a list item is selected. Return false to cancel the selection.
13051 * @param {Roo.bootstrap.ComboBox} combo This combo box
13052 * @param {Roo.data.Record} record The data record returned from the underlying store
13053 * @param {Number} index The index of the selected item in the dropdown list
13055 'beforeselect' : true,
13058 * Fires when a list item is selected
13059 * @param {Roo.bootstrap.ComboBox} combo This combo box
13060 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13061 * @param {Number} index The index of the selected item in the dropdown list
13065 * @event beforequery
13066 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13067 * The event object passed has these properties:
13068 * @param {Roo.bootstrap.ComboBox} combo This combo box
13069 * @param {String} query The query
13070 * @param {Boolean} forceAll true to force "all" query
13071 * @param {Boolean} cancel true to cancel the query
13072 * @param {Object} e The query event object
13074 'beforequery': true,
13077 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13078 * @param {Roo.bootstrap.ComboBox} combo This combo box
13083 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13084 * @param {Roo.bootstrap.ComboBox} combo This combo box
13085 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13090 * Fires when the remove value from the combobox array
13091 * @param {Roo.bootstrap.ComboBox} combo This combo box
13095 * @event afterremove
13096 * Fires when the remove value from the combobox array
13097 * @param {Roo.bootstrap.ComboBox} combo This combo box
13099 'afterremove' : true,
13101 * @event specialfilter
13102 * Fires when specialfilter
13103 * @param {Roo.bootstrap.ComboBox} combo This combo box
13105 'specialfilter' : true,
13108 * Fires when tick the element
13109 * @param {Roo.bootstrap.ComboBox} combo This combo box
13113 * @event touchviewdisplay
13114 * Fires when touch view require special display (default is using displayField)
13115 * @param {Roo.bootstrap.ComboBox} combo This combo box
13116 * @param {Object} cfg set html .
13118 'touchviewdisplay' : true
13123 this.tickItems = [];
13125 this.selectedIndex = -1;
13126 if(this.mode == 'local'){
13127 if(config.queryDelay === undefined){
13128 this.queryDelay = 10;
13130 if(config.minChars === undefined){
13136 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13139 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13140 * rendering into an Roo.Editor, defaults to false)
13143 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13144 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13147 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13150 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13151 * the dropdown list (defaults to undefined, with no header element)
13155 * @cfg {String/Roo.Template} tpl The template to use to render the output
13159 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13161 listWidth: undefined,
13163 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13164 * mode = 'remote' or 'text' if mode = 'local')
13166 displayField: undefined,
13169 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13170 * mode = 'remote' or 'value' if mode = 'local').
13171 * Note: use of a valueField requires the user make a selection
13172 * in order for a value to be mapped.
13174 valueField: undefined,
13176 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13181 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13182 * field's data value (defaults to the underlying DOM element's name)
13184 hiddenName: undefined,
13186 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13190 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13192 selectedClass: 'active',
13195 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13199 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13200 * anchor positions (defaults to 'tl-bl')
13202 listAlign: 'tl-bl?',
13204 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13208 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13209 * query specified by the allQuery config option (defaults to 'query')
13211 triggerAction: 'query',
13213 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13214 * (defaults to 4, does not apply if editable = false)
13218 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13219 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13223 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13224 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13228 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13229 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13233 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13234 * when editable = true (defaults to false)
13236 selectOnFocus:false,
13238 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13240 queryParam: 'query',
13242 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13243 * when mode = 'remote' (defaults to 'Loading...')
13245 loadingText: 'Loading...',
13247 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13251 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13255 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13256 * traditional select (defaults to true)
13260 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13264 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13268 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13269 * listWidth has a higher value)
13273 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13274 * allow the user to set arbitrary text into the field (defaults to false)
13276 forceSelection:false,
13278 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13279 * if typeAhead = true (defaults to 250)
13281 typeAheadDelay : 250,
13283 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13284 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13286 valueNotFoundText : undefined,
13288 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13290 blockFocus : false,
13293 * @cfg {Boolean} disableClear Disable showing of clear button.
13295 disableClear : false,
13297 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13299 alwaysQuery : false,
13302 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13307 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13309 invalidClass : "has-warning",
13312 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13314 validClass : "has-success",
13317 * @cfg {Boolean} specialFilter (true|false) special filter default false
13319 specialFilter : false,
13322 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13324 mobileTouchView : true,
13327 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13329 useNativeIOS : false,
13332 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13334 mobile_restrict_height : false,
13336 ios_options : false,
13348 btnPosition : 'right',
13349 triggerList : true,
13350 showToggleBtn : true,
13352 emptyResultText: 'Empty',
13353 triggerText : 'Select',
13356 // element that contains real text value.. (when hidden is used..)
13358 getAutoCreate : function()
13363 * Render classic select for iso
13366 if(Roo.isIOS && this.useNativeIOS){
13367 cfg = this.getAutoCreateNativeIOS();
13375 if(Roo.isTouch && this.mobileTouchView){
13376 cfg = this.getAutoCreateTouchView();
13383 if(!this.tickable){
13384 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13389 * ComboBox with tickable selections
13392 var align = this.labelAlign || this.parentLabelAlign();
13395 cls : 'form-group roo-combobox-tickable' //input-group
13398 var btn_text_select = '';
13399 var btn_text_done = '';
13400 var btn_text_cancel = '';
13402 if (this.btn_text_show) {
13403 btn_text_select = 'Select';
13404 btn_text_done = 'Done';
13405 btn_text_cancel = 'Cancel';
13410 cls : 'tickable-buttons',
13415 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13416 //html : this.triggerText
13417 html: btn_text_select
13423 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13425 html: btn_text_done
13431 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13433 html: btn_text_cancel
13439 buttons.cn.unshift({
13441 cls: 'roo-select2-search-field-input'
13447 Roo.each(buttons.cn, function(c){
13449 c.cls += ' btn-' + _this.size;
13452 if (_this.disabled) {
13459 style : 'display: contents',
13464 cls: 'form-hidden-field'
13468 cls: 'roo-select2-choices',
13472 cls: 'roo-select2-search-field',
13483 cls: 'roo-select2-container input-group roo-select2-container-multi',
13489 // cls: 'typeahead typeahead-long dropdown-menu',
13490 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13495 if(this.hasFeedback && !this.allowBlank){
13499 cls: 'glyphicon form-control-feedback'
13502 combobox.cn.push(feedback);
13507 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13508 tooltip : 'This field is required'
13510 if (Roo.bootstrap.version == 4) {
13513 style : 'display:none'
13516 if (align ==='left' && this.fieldLabel.length) {
13518 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13525 cls : 'control-label col-form-label',
13526 html : this.fieldLabel
13538 var labelCfg = cfg.cn[1];
13539 var contentCfg = cfg.cn[2];
13542 if(this.indicatorpos == 'right'){
13548 cls : 'control-label col-form-label',
13552 html : this.fieldLabel
13568 labelCfg = cfg.cn[0];
13569 contentCfg = cfg.cn[1];
13573 if(this.labelWidth > 12){
13574 labelCfg.style = "width: " + this.labelWidth + 'px';
13577 if(this.labelWidth < 13 && this.labelmd == 0){
13578 this.labelmd = this.labelWidth;
13581 if(this.labellg > 0){
13582 labelCfg.cls += ' col-lg-' + this.labellg;
13583 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13586 if(this.labelmd > 0){
13587 labelCfg.cls += ' col-md-' + this.labelmd;
13588 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13591 if(this.labelsm > 0){
13592 labelCfg.cls += ' col-sm-' + this.labelsm;
13593 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13596 if(this.labelxs > 0){
13597 labelCfg.cls += ' col-xs-' + this.labelxs;
13598 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13602 } else if ( this.fieldLabel.length) {
13603 // Roo.log(" label");
13608 //cls : 'input-group-addon',
13609 html : this.fieldLabel
13614 if(this.indicatorpos == 'right'){
13618 //cls : 'input-group-addon',
13619 html : this.fieldLabel
13629 // Roo.log(" no label && no align");
13636 ['xs','sm','md','lg'].map(function(size){
13637 if (settings[size]) {
13638 cfg.cls += ' col-' + size + '-' + settings[size];
13646 _initEventsCalled : false,
13649 initEvents: function()
13651 if (this._initEventsCalled) { // as we call render... prevent looping...
13654 this._initEventsCalled = true;
13657 throw "can not find store for combo";
13660 this.indicator = this.indicatorEl();
13662 this.store = Roo.factory(this.store, Roo.data);
13663 this.store.parent = this;
13665 // if we are building from html. then this element is so complex, that we can not really
13666 // use the rendered HTML.
13667 // so we have to trash and replace the previous code.
13668 if (Roo.XComponent.build_from_html) {
13669 // remove this element....
13670 var e = this.el.dom, k=0;
13671 while (e ) { e = e.previousSibling; ++k;}
13676 this.rendered = false;
13678 this.render(this.parent().getChildContainer(true), k);
13681 if(Roo.isIOS && this.useNativeIOS){
13682 this.initIOSView();
13690 if(Roo.isTouch && this.mobileTouchView){
13691 this.initTouchView();
13696 this.initTickableEvents();
13700 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13702 if(this.hiddenName){
13704 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13706 this.hiddenField.dom.value =
13707 this.hiddenValue !== undefined ? this.hiddenValue :
13708 this.value !== undefined ? this.value : '';
13710 // prevent input submission
13711 this.el.dom.removeAttribute('name');
13712 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13717 // this.el.dom.setAttribute('autocomplete', 'off');
13720 var cls = 'x-combo-list';
13722 //this.list = new Roo.Layer({
13723 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13729 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13730 _this.list.setWidth(lw);
13733 this.list.on('mouseover', this.onViewOver, this);
13734 this.list.on('mousemove', this.onViewMove, this);
13735 this.list.on('scroll', this.onViewScroll, this);
13738 this.list.swallowEvent('mousewheel');
13739 this.assetHeight = 0;
13742 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13743 this.assetHeight += this.header.getHeight();
13746 this.innerList = this.list.createChild({cls:cls+'-inner'});
13747 this.innerList.on('mouseover', this.onViewOver, this);
13748 this.innerList.on('mousemove', this.onViewMove, this);
13749 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13751 if(this.allowBlank && !this.pageSize && !this.disableClear){
13752 this.footer = this.list.createChild({cls:cls+'-ft'});
13753 this.pageTb = new Roo.Toolbar(this.footer);
13757 this.footer = this.list.createChild({cls:cls+'-ft'});
13758 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13759 {pageSize: this.pageSize});
13763 if (this.pageTb && this.allowBlank && !this.disableClear) {
13765 this.pageTb.add(new Roo.Toolbar.Fill(), {
13766 cls: 'x-btn-icon x-btn-clear',
13768 handler: function()
13771 _this.clearValue();
13772 _this.onSelect(false, -1);
13777 this.assetHeight += this.footer.getHeight();
13782 this.tpl = Roo.bootstrap.version == 4 ?
13783 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13784 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13787 this.view = new Roo.View(this.list, this.tpl, {
13788 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13790 //this.view.wrapEl.setDisplayed(false);
13791 this.view.on('click', this.onViewClick, this);
13794 this.store.on('beforeload', this.onBeforeLoad, this);
13795 this.store.on('load', this.onLoad, this);
13796 this.store.on('loadexception', this.onLoadException, this);
13798 if(this.resizable){
13799 this.resizer = new Roo.Resizable(this.list, {
13800 pinned:true, handles:'se'
13802 this.resizer.on('resize', function(r, w, h){
13803 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13804 this.listWidth = w;
13805 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13806 this.restrictHeight();
13808 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13811 if(!this.editable){
13812 this.editable = true;
13813 this.setEditable(false);
13818 if (typeof(this.events.add.listeners) != 'undefined') {
13820 this.addicon = this.wrap.createChild(
13821 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13823 this.addicon.on('click', function(e) {
13824 this.fireEvent('add', this);
13827 if (typeof(this.events.edit.listeners) != 'undefined') {
13829 this.editicon = this.wrap.createChild(
13830 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13831 if (this.addicon) {
13832 this.editicon.setStyle('margin-left', '40px');
13834 this.editicon.on('click', function(e) {
13836 // we fire even if inothing is selected..
13837 this.fireEvent('edit', this, this.lastData );
13843 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13844 "up" : function(e){
13845 this.inKeyMode = true;
13849 "down" : function(e){
13850 if(!this.isExpanded()){
13851 this.onTriggerClick();
13853 this.inKeyMode = true;
13858 "enter" : function(e){
13859 // this.onViewClick();
13863 if(this.fireEvent("specialkey", this, e)){
13864 this.onViewClick(false);
13870 "esc" : function(e){
13874 "tab" : function(e){
13877 if(this.fireEvent("specialkey", this, e)){
13878 this.onViewClick(false);
13886 doRelay : function(foo, bar, hname){
13887 if(hname == 'down' || this.scope.isExpanded()){
13888 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13897 this.queryDelay = Math.max(this.queryDelay || 10,
13898 this.mode == 'local' ? 10 : 250);
13901 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13903 if(this.typeAhead){
13904 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13906 if(this.editable !== false){
13907 this.inputEl().on("keyup", this.onKeyUp, this);
13909 if(this.forceSelection){
13910 this.inputEl().on('blur', this.doForce, this);
13914 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13915 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13919 initTickableEvents: function()
13923 if(this.hiddenName){
13925 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13927 this.hiddenField.dom.value =
13928 this.hiddenValue !== undefined ? this.hiddenValue :
13929 this.value !== undefined ? this.value : '';
13931 // prevent input submission
13932 this.el.dom.removeAttribute('name');
13933 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13938 // this.list = this.el.select('ul.dropdown-menu',true).first();
13940 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13941 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13942 if(this.triggerList){
13943 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13946 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13947 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13949 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13950 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13952 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13953 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13955 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13956 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13957 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13960 this.cancelBtn.hide();
13965 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13966 _this.list.setWidth(lw);
13969 this.list.on('mouseover', this.onViewOver, this);
13970 this.list.on('mousemove', this.onViewMove, this);
13972 this.list.on('scroll', this.onViewScroll, this);
13975 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
13976 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13979 this.view = new Roo.View(this.list, this.tpl, {
13984 selectedClass: this.selectedClass
13987 //this.view.wrapEl.setDisplayed(false);
13988 this.view.on('click', this.onViewClick, this);
13992 this.store.on('beforeload', this.onBeforeLoad, this);
13993 this.store.on('load', this.onLoad, this);
13994 this.store.on('loadexception', this.onLoadException, this);
13997 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13998 "up" : function(e){
13999 this.inKeyMode = true;
14003 "down" : function(e){
14004 this.inKeyMode = true;
14008 "enter" : function(e){
14009 if(this.fireEvent("specialkey", this, e)){
14010 this.onViewClick(false);
14016 "esc" : function(e){
14017 this.onTickableFooterButtonClick(e, false, false);
14020 "tab" : function(e){
14021 this.fireEvent("specialkey", this, e);
14023 this.onTickableFooterButtonClick(e, false, false);
14030 doRelay : function(e, fn, key){
14031 if(this.scope.isExpanded()){
14032 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14041 this.queryDelay = Math.max(this.queryDelay || 10,
14042 this.mode == 'local' ? 10 : 250);
14045 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14047 if(this.typeAhead){
14048 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14051 if(this.editable !== false){
14052 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14055 this.indicator = this.indicatorEl();
14057 if(this.indicator){
14058 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14059 this.indicator.hide();
14064 onDestroy : function(){
14066 this.view.setStore(null);
14067 this.view.el.removeAllListeners();
14068 this.view.el.remove();
14069 this.view.purgeListeners();
14072 this.list.dom.innerHTML = '';
14076 this.store.un('beforeload', this.onBeforeLoad, this);
14077 this.store.un('load', this.onLoad, this);
14078 this.store.un('loadexception', this.onLoadException, this);
14080 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14084 fireKey : function(e){
14085 if(e.isNavKeyPress() && !this.list.isVisible()){
14086 this.fireEvent("specialkey", this, e);
14091 onResize: function(w, h){
14092 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14094 // if(typeof w != 'number'){
14095 // // we do not handle it!?!?
14098 // var tw = this.trigger.getWidth();
14099 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14100 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14102 // this.inputEl().setWidth( this.adjustWidth('input', x));
14104 // //this.trigger.setStyle('left', x+'px');
14106 // if(this.list && this.listWidth === undefined){
14107 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14108 // this.list.setWidth(lw);
14109 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14117 * Allow or prevent the user from directly editing the field text. If false is passed,
14118 * the user will only be able to select from the items defined in the dropdown list. This method
14119 * is the runtime equivalent of setting the 'editable' config option at config time.
14120 * @param {Boolean} value True to allow the user to directly edit the field text
14122 setEditable : function(value){
14123 if(value == this.editable){
14126 this.editable = value;
14128 this.inputEl().dom.setAttribute('readOnly', true);
14129 this.inputEl().on('mousedown', this.onTriggerClick, this);
14130 this.inputEl().addClass('x-combo-noedit');
14132 this.inputEl().dom.setAttribute('readOnly', false);
14133 this.inputEl().un('mousedown', this.onTriggerClick, this);
14134 this.inputEl().removeClass('x-combo-noedit');
14140 onBeforeLoad : function(combo,opts){
14141 if(!this.hasFocus){
14145 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14147 this.restrictHeight();
14148 this.selectedIndex = -1;
14152 onLoad : function(){
14154 this.hasQuery = false;
14156 if(!this.hasFocus){
14160 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14161 this.loading.hide();
14164 if(this.store.getCount() > 0){
14167 this.restrictHeight();
14168 if(this.lastQuery == this.allQuery){
14169 if(this.editable && !this.tickable){
14170 this.inputEl().dom.select();
14174 !this.selectByValue(this.value, true) &&
14177 !this.store.lastOptions ||
14178 typeof(this.store.lastOptions.add) == 'undefined' ||
14179 this.store.lastOptions.add != true
14182 this.select(0, true);
14185 if(this.autoFocus){
14188 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14189 this.taTask.delay(this.typeAheadDelay);
14193 this.onEmptyResults();
14199 onLoadException : function()
14201 this.hasQuery = false;
14203 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14204 this.loading.hide();
14207 if(this.tickable && this.editable){
14212 // only causes errors at present
14213 //Roo.log(this.store.reader.jsonData);
14214 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14216 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14222 onTypeAhead : function(){
14223 if(this.store.getCount() > 0){
14224 var r = this.store.getAt(0);
14225 var newValue = r.data[this.displayField];
14226 var len = newValue.length;
14227 var selStart = this.getRawValue().length;
14229 if(selStart != len){
14230 this.setRawValue(newValue);
14231 this.selectText(selStart, newValue.length);
14237 onSelect : function(record, index){
14239 if(this.fireEvent('beforeselect', this, record, index) !== false){
14241 this.setFromData(index > -1 ? record.data : false);
14244 this.fireEvent('select', this, record, index);
14249 * Returns the currently selected field value or empty string if no value is set.
14250 * @return {String} value The selected value
14252 getValue : function()
14254 if(Roo.isIOS && this.useNativeIOS){
14255 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14259 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14262 if(this.valueField){
14263 return typeof this.value != 'undefined' ? this.value : '';
14265 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14269 getRawValue : function()
14271 if(Roo.isIOS && this.useNativeIOS){
14272 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14275 var v = this.inputEl().getValue();
14281 * Clears any text/value currently set in the field
14283 clearValue : function(){
14285 if(this.hiddenField){
14286 this.hiddenField.dom.value = '';
14289 this.setRawValue('');
14290 this.lastSelectionText = '';
14291 this.lastData = false;
14293 var close = this.closeTriggerEl();
14304 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14305 * will be displayed in the field. If the value does not match the data value of an existing item,
14306 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14307 * Otherwise the field will be blank (although the value will still be set).
14308 * @param {String} value The value to match
14310 setValue : function(v)
14312 if(Roo.isIOS && this.useNativeIOS){
14313 this.setIOSValue(v);
14323 if(this.valueField){
14324 var r = this.findRecord(this.valueField, v);
14326 text = r.data[this.displayField];
14327 }else if(this.valueNotFoundText !== undefined){
14328 text = this.valueNotFoundText;
14331 this.lastSelectionText = text;
14332 if(this.hiddenField){
14333 this.hiddenField.dom.value = v;
14335 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14338 var close = this.closeTriggerEl();
14341 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14347 * @property {Object} the last set data for the element
14352 * Sets the value of the field based on a object which is related to the record format for the store.
14353 * @param {Object} value the value to set as. or false on reset?
14355 setFromData : function(o){
14362 var dv = ''; // display value
14363 var vv = ''; // value value..
14365 if (this.displayField) {
14366 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14368 // this is an error condition!!!
14369 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14372 if(this.valueField){
14373 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14376 var close = this.closeTriggerEl();
14379 if(dv.length || vv * 1 > 0){
14381 this.blockFocus=true;
14387 if(this.hiddenField){
14388 this.hiddenField.dom.value = vv;
14390 this.lastSelectionText = dv;
14391 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14395 // no hidden field.. - we store the value in 'value', but still display
14396 // display field!!!!
14397 this.lastSelectionText = dv;
14398 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14405 reset : function(){
14406 // overridden so that last data is reset..
14413 this.setValue(this.originalValue);
14414 //this.clearInvalid();
14415 this.lastData = false;
14417 this.view.clearSelections();
14423 findRecord : function(prop, value){
14425 if(this.store.getCount() > 0){
14426 this.store.each(function(r){
14427 if(r.data[prop] == value){
14437 getName: function()
14439 // returns hidden if it's set..
14440 if (!this.rendered) {return ''};
14441 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14445 onViewMove : function(e, t){
14446 this.inKeyMode = false;
14450 onViewOver : function(e, t){
14451 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14454 var item = this.view.findItemFromChild(t);
14457 var index = this.view.indexOf(item);
14458 this.select(index, false);
14463 onViewClick : function(view, doFocus, el, e)
14465 var index = this.view.getSelectedIndexes()[0];
14467 var r = this.store.getAt(index);
14471 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14478 Roo.each(this.tickItems, function(v,k){
14480 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14482 _this.tickItems.splice(k, 1);
14484 if(typeof(e) == 'undefined' && view == false){
14485 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14497 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14498 this.tickItems.push(r.data);
14501 if(typeof(e) == 'undefined' && view == false){
14502 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14509 this.onSelect(r, index);
14511 if(doFocus !== false && !this.blockFocus){
14512 this.inputEl().focus();
14517 restrictHeight : function(){
14518 //this.innerList.dom.style.height = '';
14519 //var inner = this.innerList.dom;
14520 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14521 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14522 //this.list.beginUpdate();
14523 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14524 this.list.alignTo(this.inputEl(), this.listAlign);
14525 this.list.alignTo(this.inputEl(), this.listAlign);
14526 //this.list.endUpdate();
14530 onEmptyResults : function(){
14532 if(this.tickable && this.editable){
14533 this.hasFocus = false;
14534 this.restrictHeight();
14542 * Returns true if the dropdown list is expanded, else false.
14544 isExpanded : function(){
14545 return this.list.isVisible();
14549 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14550 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14551 * @param {String} value The data value of the item to select
14552 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14553 * selected item if it is not currently in view (defaults to true)
14554 * @return {Boolean} True if the value matched an item in the list, else false
14556 selectByValue : function(v, scrollIntoView){
14557 if(v !== undefined && v !== null){
14558 var r = this.findRecord(this.valueField || this.displayField, v);
14560 this.select(this.store.indexOf(r), scrollIntoView);
14568 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14569 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14570 * @param {Number} index The zero-based index of the list item to select
14571 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14572 * selected item if it is not currently in view (defaults to true)
14574 select : function(index, scrollIntoView){
14575 this.selectedIndex = index;
14576 this.view.select(index);
14577 if(scrollIntoView !== false){
14578 var el = this.view.getNode(index);
14580 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14583 this.list.scrollChildIntoView(el, false);
14589 selectNext : function(){
14590 var ct = this.store.getCount();
14592 if(this.selectedIndex == -1){
14594 }else if(this.selectedIndex < ct-1){
14595 this.select(this.selectedIndex+1);
14601 selectPrev : function(){
14602 var ct = this.store.getCount();
14604 if(this.selectedIndex == -1){
14606 }else if(this.selectedIndex != 0){
14607 this.select(this.selectedIndex-1);
14613 onKeyUp : function(e){
14614 if(this.editable !== false && !e.isSpecialKey()){
14615 this.lastKey = e.getKey();
14616 this.dqTask.delay(this.queryDelay);
14621 validateBlur : function(){
14622 return !this.list || !this.list.isVisible();
14626 initQuery : function(){
14628 var v = this.getRawValue();
14630 if(this.tickable && this.editable){
14631 v = this.tickableInputEl().getValue();
14638 doForce : function(){
14639 if(this.inputEl().dom.value.length > 0){
14640 this.inputEl().dom.value =
14641 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14647 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14648 * query allowing the query action to be canceled if needed.
14649 * @param {String} query The SQL query to execute
14650 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14651 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14652 * saved in the current store (defaults to false)
14654 doQuery : function(q, forceAll){
14656 if(q === undefined || q === null){
14661 forceAll: forceAll,
14665 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14670 forceAll = qe.forceAll;
14671 if(forceAll === true || (q.length >= this.minChars)){
14673 this.hasQuery = true;
14675 if(this.lastQuery != q || this.alwaysQuery){
14676 this.lastQuery = q;
14677 if(this.mode == 'local'){
14678 this.selectedIndex = -1;
14680 this.store.clearFilter();
14683 if(this.specialFilter){
14684 this.fireEvent('specialfilter', this);
14689 this.store.filter(this.displayField, q);
14692 this.store.fireEvent("datachanged", this.store);
14699 this.store.baseParams[this.queryParam] = q;
14701 var options = {params : this.getParams(q)};
14704 options.add = true;
14705 options.params.start = this.page * this.pageSize;
14708 this.store.load(options);
14711 * this code will make the page width larger, at the beginning, the list not align correctly,
14712 * we should expand the list on onLoad
14713 * so command out it
14718 this.selectedIndex = -1;
14723 this.loadNext = false;
14727 getParams : function(q){
14729 //p[this.queryParam] = q;
14733 p.limit = this.pageSize;
14739 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14741 collapse : function(){
14742 if(!this.isExpanded()){
14748 this.hasFocus = false;
14752 this.cancelBtn.hide();
14753 this.trigger.show();
14756 this.tickableInputEl().dom.value = '';
14757 this.tickableInputEl().blur();
14762 Roo.get(document).un('mousedown', this.collapseIf, this);
14763 Roo.get(document).un('mousewheel', this.collapseIf, this);
14764 if (!this.editable) {
14765 Roo.get(document).un('keydown', this.listKeyPress, this);
14767 this.fireEvent('collapse', this);
14773 collapseIf : function(e){
14774 var in_combo = e.within(this.el);
14775 var in_list = e.within(this.list);
14776 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14778 if (in_combo || in_list || is_list) {
14779 //e.stopPropagation();
14784 this.onTickableFooterButtonClick(e, false, false);
14792 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14794 expand : function(){
14796 if(this.isExpanded() || !this.hasFocus){
14800 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14801 this.list.setWidth(lw);
14807 this.restrictHeight();
14811 this.tickItems = Roo.apply([], this.item);
14814 this.cancelBtn.show();
14815 this.trigger.hide();
14818 this.tickableInputEl().focus();
14823 Roo.get(document).on('mousedown', this.collapseIf, this);
14824 Roo.get(document).on('mousewheel', this.collapseIf, this);
14825 if (!this.editable) {
14826 Roo.get(document).on('keydown', this.listKeyPress, this);
14829 this.fireEvent('expand', this);
14833 // Implements the default empty TriggerField.onTriggerClick function
14834 onTriggerClick : function(e)
14836 Roo.log('trigger click');
14838 if(this.disabled || !this.triggerList){
14843 this.loadNext = false;
14845 if(this.isExpanded()){
14847 if (!this.blockFocus) {
14848 this.inputEl().focus();
14852 this.hasFocus = true;
14853 if(this.triggerAction == 'all') {
14854 this.doQuery(this.allQuery, true);
14856 this.doQuery(this.getRawValue());
14858 if (!this.blockFocus) {
14859 this.inputEl().focus();
14864 onTickableTriggerClick : function(e)
14871 this.loadNext = false;
14872 this.hasFocus = true;
14874 if(this.triggerAction == 'all') {
14875 this.doQuery(this.allQuery, true);
14877 this.doQuery(this.getRawValue());
14881 onSearchFieldClick : function(e)
14883 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14884 this.onTickableFooterButtonClick(e, false, false);
14888 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14893 this.loadNext = false;
14894 this.hasFocus = true;
14896 if(this.triggerAction == 'all') {
14897 this.doQuery(this.allQuery, true);
14899 this.doQuery(this.getRawValue());
14903 listKeyPress : function(e)
14905 //Roo.log('listkeypress');
14906 // scroll to first matching element based on key pres..
14907 if (e.isSpecialKey()) {
14910 var k = String.fromCharCode(e.getKey()).toUpperCase();
14913 var csel = this.view.getSelectedNodes();
14914 var cselitem = false;
14916 var ix = this.view.indexOf(csel[0]);
14917 cselitem = this.store.getAt(ix);
14918 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14924 this.store.each(function(v) {
14926 // start at existing selection.
14927 if (cselitem.id == v.id) {
14933 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14934 match = this.store.indexOf(v);
14940 if (match === false) {
14941 return true; // no more action?
14944 this.view.select(match);
14945 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14946 sn.scrollIntoView(sn.dom.parentNode, false);
14949 onViewScroll : function(e, t){
14951 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){
14955 this.hasQuery = true;
14957 this.loading = this.list.select('.loading', true).first();
14959 if(this.loading === null){
14960 this.list.createChild({
14962 cls: 'loading roo-select2-more-results roo-select2-active',
14963 html: 'Loading more results...'
14966 this.loading = this.list.select('.loading', true).first();
14968 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14970 this.loading.hide();
14973 this.loading.show();
14978 this.loadNext = true;
14980 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14985 addItem : function(o)
14987 var dv = ''; // display value
14989 if (this.displayField) {
14990 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14992 // this is an error condition!!!
14993 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15000 var choice = this.choices.createChild({
15002 cls: 'roo-select2-search-choice',
15011 cls: 'roo-select2-search-choice-close fa fa-times',
15016 }, this.searchField);
15018 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15020 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15028 this.inputEl().dom.value = '';
15033 onRemoveItem : function(e, _self, o)
15035 e.preventDefault();
15037 this.lastItem = Roo.apply([], this.item);
15039 var index = this.item.indexOf(o.data) * 1;
15042 Roo.log('not this item?!');
15046 this.item.splice(index, 1);
15051 this.fireEvent('remove', this, e);
15057 syncValue : function()
15059 if(!this.item.length){
15066 Roo.each(this.item, function(i){
15067 if(_this.valueField){
15068 value.push(i[_this.valueField]);
15075 this.value = value.join(',');
15077 if(this.hiddenField){
15078 this.hiddenField.dom.value = this.value;
15081 this.store.fireEvent("datachanged", this.store);
15086 clearItem : function()
15088 if(!this.multiple){
15094 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15102 if(this.tickable && !Roo.isTouch){
15103 this.view.refresh();
15107 inputEl: function ()
15109 if(Roo.isIOS && this.useNativeIOS){
15110 return this.el.select('select.roo-ios-select', true).first();
15113 if(Roo.isTouch && this.mobileTouchView){
15114 return this.el.select('input.form-control',true).first();
15118 return this.searchField;
15121 return this.el.select('input.form-control',true).first();
15124 onTickableFooterButtonClick : function(e, btn, el)
15126 e.preventDefault();
15128 this.lastItem = Roo.apply([], this.item);
15130 if(btn && btn.name == 'cancel'){
15131 this.tickItems = Roo.apply([], this.item);
15140 Roo.each(this.tickItems, function(o){
15148 validate : function()
15150 if(this.getVisibilityEl().hasClass('hidden')){
15154 var v = this.getRawValue();
15157 v = this.getValue();
15160 if(this.disabled || this.allowBlank || v.length){
15165 this.markInvalid();
15169 tickableInputEl : function()
15171 if(!this.tickable || !this.editable){
15172 return this.inputEl();
15175 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15179 getAutoCreateTouchView : function()
15184 cls: 'form-group' //input-group
15190 type : this.inputType,
15191 cls : 'form-control x-combo-noedit',
15192 autocomplete: 'new-password',
15193 placeholder : this.placeholder || '',
15198 input.name = this.name;
15202 input.cls += ' input-' + this.size;
15205 if (this.disabled) {
15206 input.disabled = true;
15217 inputblock.cls += ' input-group';
15219 inputblock.cn.unshift({
15221 cls : 'input-group-addon input-group-prepend input-group-text',
15226 if(this.removable && !this.multiple){
15227 inputblock.cls += ' roo-removable';
15229 inputblock.cn.push({
15232 cls : 'roo-combo-removable-btn close'
15236 if(this.hasFeedback && !this.allowBlank){
15238 inputblock.cls += ' has-feedback';
15240 inputblock.cn.push({
15242 cls: 'glyphicon form-control-feedback'
15249 inputblock.cls += (this.before) ? '' : ' input-group';
15251 inputblock.cn.push({
15253 cls : 'input-group-addon input-group-append input-group-text',
15259 var ibwrap = inputblock;
15264 cls: 'roo-select2-choices',
15268 cls: 'roo-select2-search-field',
15281 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15286 cls: 'form-hidden-field'
15292 if(!this.multiple && this.showToggleBtn){
15299 if (this.caret != false) {
15302 cls: 'fa fa-' + this.caret
15309 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15314 cls: 'combobox-clear',
15328 combobox.cls += ' roo-select2-container-multi';
15331 var align = this.labelAlign || this.parentLabelAlign();
15333 if (align ==='left' && this.fieldLabel.length) {
15338 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15339 tooltip : 'This field is required'
15343 cls : 'control-label col-form-label',
15344 html : this.fieldLabel
15355 var labelCfg = cfg.cn[1];
15356 var contentCfg = cfg.cn[2];
15359 if(this.indicatorpos == 'right'){
15364 cls : 'control-label col-form-label',
15368 html : this.fieldLabel
15372 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15373 tooltip : 'This field is required'
15386 labelCfg = cfg.cn[0];
15387 contentCfg = cfg.cn[1];
15392 if(this.labelWidth > 12){
15393 labelCfg.style = "width: " + this.labelWidth + 'px';
15396 if(this.labelWidth < 13 && this.labelmd == 0){
15397 this.labelmd = this.labelWidth;
15400 if(this.labellg > 0){
15401 labelCfg.cls += ' col-lg-' + this.labellg;
15402 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15405 if(this.labelmd > 0){
15406 labelCfg.cls += ' col-md-' + this.labelmd;
15407 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15410 if(this.labelsm > 0){
15411 labelCfg.cls += ' col-sm-' + this.labelsm;
15412 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15415 if(this.labelxs > 0){
15416 labelCfg.cls += ' col-xs-' + this.labelxs;
15417 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15421 } else if ( this.fieldLabel.length) {
15425 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15426 tooltip : 'This field is required'
15430 cls : 'control-label',
15431 html : this.fieldLabel
15442 if(this.indicatorpos == 'right'){
15446 cls : 'control-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'
15469 var settings = this;
15471 ['xs','sm','md','lg'].map(function(size){
15472 if (settings[size]) {
15473 cfg.cls += ' col-' + size + '-' + settings[size];
15480 initTouchView : function()
15482 this.renderTouchView();
15484 this.touchViewEl.on('scroll', function(){
15485 this.el.dom.scrollTop = 0;
15488 this.originalValue = this.getValue();
15490 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15492 this.inputEl().on("click", this.showTouchView, this);
15493 if (this.triggerEl) {
15494 this.triggerEl.on("click", this.showTouchView, this);
15498 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15499 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15501 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15503 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15504 this.store.on('load', this.onTouchViewLoad, this);
15505 this.store.on('loadexception', this.onTouchViewLoadException, this);
15507 if(this.hiddenName){
15509 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15511 this.hiddenField.dom.value =
15512 this.hiddenValue !== undefined ? this.hiddenValue :
15513 this.value !== undefined ? this.value : '';
15515 this.el.dom.removeAttribute('name');
15516 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15520 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15521 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15524 if(this.removable && !this.multiple){
15525 var close = this.closeTriggerEl();
15527 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15528 close.on('click', this.removeBtnClick, this, close);
15532 * fix the bug in Safari iOS8
15534 this.inputEl().on("focus", function(e){
15535 document.activeElement.blur();
15538 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15545 renderTouchView : function()
15547 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15548 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15550 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15551 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15553 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15554 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15555 this.touchViewBodyEl.setStyle('overflow', 'auto');
15557 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15558 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15560 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15561 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15565 showTouchView : function()
15571 this.touchViewHeaderEl.hide();
15573 if(this.modalTitle.length){
15574 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15575 this.touchViewHeaderEl.show();
15578 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15579 this.touchViewEl.show();
15581 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15583 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15584 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15586 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15588 if(this.modalTitle.length){
15589 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15592 this.touchViewBodyEl.setHeight(bodyHeight);
15596 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15598 this.touchViewEl.addClass('in');
15601 if(this._touchViewMask){
15602 Roo.get(document.body).addClass("x-body-masked");
15603 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15604 this._touchViewMask.setStyle('z-index', 10000);
15605 this._touchViewMask.addClass('show');
15608 this.doTouchViewQuery();
15612 hideTouchView : function()
15614 this.touchViewEl.removeClass('in');
15618 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15620 this.touchViewEl.setStyle('display', 'none');
15623 if(this._touchViewMask){
15624 this._touchViewMask.removeClass('show');
15625 Roo.get(document.body).removeClass("x-body-masked");
15629 setTouchViewValue : function()
15636 Roo.each(this.tickItems, function(o){
15641 this.hideTouchView();
15644 doTouchViewQuery : function()
15653 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15657 if(!this.alwaysQuery || this.mode == 'local'){
15658 this.onTouchViewLoad();
15665 onTouchViewBeforeLoad : function(combo,opts)
15671 onTouchViewLoad : function()
15673 if(this.store.getCount() < 1){
15674 this.onTouchViewEmptyResults();
15678 this.clearTouchView();
15680 var rawValue = this.getRawValue();
15682 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15684 this.tickItems = [];
15686 this.store.data.each(function(d, rowIndex){
15687 var row = this.touchViewListGroup.createChild(template);
15689 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15690 row.addClass(d.data.cls);
15693 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15696 html : d.data[this.displayField]
15699 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15700 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15703 row.removeClass('selected');
15704 if(!this.multiple && this.valueField &&
15705 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15708 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15709 row.addClass('selected');
15712 if(this.multiple && this.valueField &&
15713 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15717 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15718 this.tickItems.push(d.data);
15721 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15725 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15727 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15729 if(this.modalTitle.length){
15730 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15733 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15735 if(this.mobile_restrict_height && listHeight < bodyHeight){
15736 this.touchViewBodyEl.setHeight(listHeight);
15741 if(firstChecked && listHeight > bodyHeight){
15742 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15747 onTouchViewLoadException : function()
15749 this.hideTouchView();
15752 onTouchViewEmptyResults : function()
15754 this.clearTouchView();
15756 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15758 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15762 clearTouchView : function()
15764 this.touchViewListGroup.dom.innerHTML = '';
15767 onTouchViewClick : function(e, el, o)
15769 e.preventDefault();
15772 var rowIndex = o.rowIndex;
15774 var r = this.store.getAt(rowIndex);
15776 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15778 if(!this.multiple){
15779 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15780 c.dom.removeAttribute('checked');
15783 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15785 this.setFromData(r.data);
15787 var close = this.closeTriggerEl();
15793 this.hideTouchView();
15795 this.fireEvent('select', this, r, rowIndex);
15800 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15801 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15802 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15806 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15807 this.addItem(r.data);
15808 this.tickItems.push(r.data);
15812 getAutoCreateNativeIOS : function()
15815 cls: 'form-group' //input-group,
15820 cls : 'roo-ios-select'
15824 combobox.name = this.name;
15827 if (this.disabled) {
15828 combobox.disabled = true;
15831 var settings = this;
15833 ['xs','sm','md','lg'].map(function(size){
15834 if (settings[size]) {
15835 cfg.cls += ' col-' + size + '-' + settings[size];
15845 initIOSView : function()
15847 this.store.on('load', this.onIOSViewLoad, this);
15852 onIOSViewLoad : function()
15854 if(this.store.getCount() < 1){
15858 this.clearIOSView();
15860 if(this.allowBlank) {
15862 var default_text = '-- SELECT --';
15864 if(this.placeholder.length){
15865 default_text = this.placeholder;
15868 if(this.emptyTitle.length){
15869 default_text += ' - ' + this.emptyTitle + ' -';
15872 var opt = this.inputEl().createChild({
15875 html : default_text
15879 o[this.valueField] = 0;
15880 o[this.displayField] = default_text;
15882 this.ios_options.push({
15889 this.store.data.each(function(d, rowIndex){
15893 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15894 html = d.data[this.displayField];
15899 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15900 value = d.data[this.valueField];
15909 if(this.value == d.data[this.valueField]){
15910 option['selected'] = true;
15913 var opt = this.inputEl().createChild(option);
15915 this.ios_options.push({
15922 this.inputEl().on('change', function(){
15923 this.fireEvent('select', this);
15928 clearIOSView: function()
15930 this.inputEl().dom.innerHTML = '';
15932 this.ios_options = [];
15935 setIOSValue: function(v)
15939 if(!this.ios_options){
15943 Roo.each(this.ios_options, function(opts){
15945 opts.el.dom.removeAttribute('selected');
15947 if(opts.data[this.valueField] != v){
15951 opts.el.dom.setAttribute('selected', true);
15957 * @cfg {Boolean} grow
15961 * @cfg {Number} growMin
15965 * @cfg {Number} growMax
15974 Roo.apply(Roo.bootstrap.ComboBox, {
15978 cls: 'modal-header',
16000 cls: 'list-group-item',
16004 cls: 'roo-combobox-list-group-item-value'
16008 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16022 listItemCheckbox : {
16024 cls: 'list-group-item',
16028 cls: 'roo-combobox-list-group-item-value'
16032 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16048 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16053 cls: 'modal-footer',
16061 cls: 'col-xs-6 text-left',
16064 cls: 'btn btn-danger roo-touch-view-cancel',
16070 cls: 'col-xs-6 text-right',
16073 cls: 'btn btn-success roo-touch-view-ok',
16084 Roo.apply(Roo.bootstrap.ComboBox, {
16086 touchViewTemplate : {
16088 cls: 'modal fade roo-combobox-touch-view',
16092 cls: 'modal-dialog',
16093 style : 'position:fixed', // we have to fix position....
16097 cls: 'modal-content',
16099 Roo.bootstrap.ComboBox.header,
16100 Roo.bootstrap.ComboBox.body,
16101 Roo.bootstrap.ComboBox.footer
16110 * Ext JS Library 1.1.1
16111 * Copyright(c) 2006-2007, Ext JS, LLC.
16113 * Originally Released Under LGPL - original licence link has changed is not relivant.
16116 * <script type="text/javascript">
16121 * @extends Roo.util.Observable
16122 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16123 * This class also supports single and multi selection modes. <br>
16124 * Create a data model bound view:
16126 var store = new Roo.data.Store(...);
16128 var view = new Roo.View({
16130 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16132 singleSelect: true,
16133 selectedClass: "ydataview-selected",
16137 // listen for node click?
16138 view.on("click", function(vw, index, node, e){
16139 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16143 dataModel.load("foobar.xml");
16145 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16147 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16148 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16150 * Note: old style constructor is still suported (container, template, config)
16153 * Create a new View
16154 * @param {Object} config The config object
16157 Roo.View = function(config, depreciated_tpl, depreciated_config){
16159 this.parent = false;
16161 if (typeof(depreciated_tpl) == 'undefined') {
16162 // new way.. - universal constructor.
16163 Roo.apply(this, config);
16164 this.el = Roo.get(this.el);
16167 this.el = Roo.get(config);
16168 this.tpl = depreciated_tpl;
16169 Roo.apply(this, depreciated_config);
16171 this.wrapEl = this.el.wrap().wrap();
16172 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16175 if(typeof(this.tpl) == "string"){
16176 this.tpl = new Roo.Template(this.tpl);
16178 // support xtype ctors..
16179 this.tpl = new Roo.factory(this.tpl, Roo);
16183 this.tpl.compile();
16188 * @event beforeclick
16189 * Fires before a click is processed. Returns false to cancel the default action.
16190 * @param {Roo.View} this
16191 * @param {Number} index The index of the target node
16192 * @param {HTMLElement} node The target node
16193 * @param {Roo.EventObject} e The raw event object
16195 "beforeclick" : true,
16198 * Fires when a template node is clicked.
16199 * @param {Roo.View} this
16200 * @param {Number} index The index of the target node
16201 * @param {HTMLElement} node The target node
16202 * @param {Roo.EventObject} e The raw event object
16207 * Fires when a template node is double clicked.
16208 * @param {Roo.View} this
16209 * @param {Number} index The index of the target node
16210 * @param {HTMLElement} node The target node
16211 * @param {Roo.EventObject} e The raw event object
16215 * @event contextmenu
16216 * Fires when a template node is right clicked.
16217 * @param {Roo.View} this
16218 * @param {Number} index The index of the target node
16219 * @param {HTMLElement} node The target node
16220 * @param {Roo.EventObject} e The raw event object
16222 "contextmenu" : true,
16224 * @event selectionchange
16225 * Fires when the selected nodes change.
16226 * @param {Roo.View} this
16227 * @param {Array} selections Array of the selected nodes
16229 "selectionchange" : true,
16232 * @event beforeselect
16233 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16234 * @param {Roo.View} this
16235 * @param {HTMLElement} node The node to be selected
16236 * @param {Array} selections Array of currently selected nodes
16238 "beforeselect" : true,
16240 * @event preparedata
16241 * Fires on every row to render, to allow you to change the data.
16242 * @param {Roo.View} this
16243 * @param {Object} data to be rendered (change this)
16245 "preparedata" : true
16253 "click": this.onClick,
16254 "dblclick": this.onDblClick,
16255 "contextmenu": this.onContextMenu,
16259 this.selections = [];
16261 this.cmp = new Roo.CompositeElementLite([]);
16263 this.store = Roo.factory(this.store, Roo.data);
16264 this.setStore(this.store, true);
16267 if ( this.footer && this.footer.xtype) {
16269 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16271 this.footer.dataSource = this.store;
16272 this.footer.container = fctr;
16273 this.footer = Roo.factory(this.footer, Roo);
16274 fctr.insertFirst(this.el);
16276 // this is a bit insane - as the paging toolbar seems to detach the el..
16277 // dom.parentNode.parentNode.parentNode
16278 // they get detached?
16282 Roo.View.superclass.constructor.call(this);
16287 Roo.extend(Roo.View, Roo.util.Observable, {
16290 * @cfg {Roo.data.Store} store Data store to load data from.
16295 * @cfg {String|Roo.Element} el The container element.
16300 * @cfg {String|Roo.Template} tpl The template used by this View
16304 * @cfg {String} dataName the named area of the template to use as the data area
16305 * Works with domtemplates roo-name="name"
16309 * @cfg {String} selectedClass The css class to add to selected nodes
16311 selectedClass : "x-view-selected",
16313 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16318 * @cfg {String} text to display on mask (default Loading)
16322 * @cfg {Boolean} multiSelect Allow multiple selection
16324 multiSelect : false,
16326 * @cfg {Boolean} singleSelect Allow single selection
16328 singleSelect: false,
16331 * @cfg {Boolean} toggleSelect - selecting
16333 toggleSelect : false,
16336 * @cfg {Boolean} tickable - selecting
16341 * Returns the element this view is bound to.
16342 * @return {Roo.Element}
16344 getEl : function(){
16345 return this.wrapEl;
16351 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16353 refresh : function(){
16354 //Roo.log('refresh');
16357 // if we are using something like 'domtemplate', then
16358 // the what gets used is:
16359 // t.applySubtemplate(NAME, data, wrapping data..)
16360 // the outer template then get' applied with
16361 // the store 'extra data'
16362 // and the body get's added to the
16363 // roo-name="data" node?
16364 // <span class='roo-tpl-{name}'></span> ?????
16368 this.clearSelections();
16369 this.el.update("");
16371 var records = this.store.getRange();
16372 if(records.length < 1) {
16374 // is this valid?? = should it render a template??
16376 this.el.update(this.emptyText);
16380 if (this.dataName) {
16381 this.el.update(t.apply(this.store.meta)); //????
16382 el = this.el.child('.roo-tpl-' + this.dataName);
16385 for(var i = 0, len = records.length; i < len; i++){
16386 var data = this.prepareData(records[i].data, i, records[i]);
16387 this.fireEvent("preparedata", this, data, i, records[i]);
16389 var d = Roo.apply({}, data);
16392 Roo.apply(d, {'roo-id' : Roo.id()});
16396 Roo.each(this.parent.item, function(item){
16397 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16400 Roo.apply(d, {'roo-data-checked' : 'checked'});
16404 html[html.length] = Roo.util.Format.trim(
16406 t.applySubtemplate(this.dataName, d, this.store.meta) :
16413 el.update(html.join(""));
16414 this.nodes = el.dom.childNodes;
16415 this.updateIndexes(0);
16420 * Function to override to reformat the data that is sent to
16421 * the template for each node.
16422 * DEPRICATED - use the preparedata event handler.
16423 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16424 * a JSON object for an UpdateManager bound view).
16426 prepareData : function(data, index, record)
16428 this.fireEvent("preparedata", this, data, index, record);
16432 onUpdate : function(ds, record){
16433 // Roo.log('on update');
16434 this.clearSelections();
16435 var index = this.store.indexOf(record);
16436 var n = this.nodes[index];
16437 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16438 n.parentNode.removeChild(n);
16439 this.updateIndexes(index, index);
16445 onAdd : function(ds, records, index)
16447 //Roo.log(['on Add', ds, records, index] );
16448 this.clearSelections();
16449 if(this.nodes.length == 0){
16453 var n = this.nodes[index];
16454 for(var i = 0, len = records.length; i < len; i++){
16455 var d = this.prepareData(records[i].data, i, records[i]);
16457 this.tpl.insertBefore(n, d);
16460 this.tpl.append(this.el, d);
16463 this.updateIndexes(index);
16466 onRemove : function(ds, record, index){
16467 // Roo.log('onRemove');
16468 this.clearSelections();
16469 var el = this.dataName ?
16470 this.el.child('.roo-tpl-' + this.dataName) :
16473 el.dom.removeChild(this.nodes[index]);
16474 this.updateIndexes(index);
16478 * Refresh an individual node.
16479 * @param {Number} index
16481 refreshNode : function(index){
16482 this.onUpdate(this.store, this.store.getAt(index));
16485 updateIndexes : function(startIndex, endIndex){
16486 var ns = this.nodes;
16487 startIndex = startIndex || 0;
16488 endIndex = endIndex || ns.length - 1;
16489 for(var i = startIndex; i <= endIndex; i++){
16490 ns[i].nodeIndex = i;
16495 * Changes the data store this view uses and refresh the view.
16496 * @param {Store} store
16498 setStore : function(store, initial){
16499 if(!initial && this.store){
16500 this.store.un("datachanged", this.refresh);
16501 this.store.un("add", this.onAdd);
16502 this.store.un("remove", this.onRemove);
16503 this.store.un("update", this.onUpdate);
16504 this.store.un("clear", this.refresh);
16505 this.store.un("beforeload", this.onBeforeLoad);
16506 this.store.un("load", this.onLoad);
16507 this.store.un("loadexception", this.onLoad);
16511 store.on("datachanged", this.refresh, this);
16512 store.on("add", this.onAdd, this);
16513 store.on("remove", this.onRemove, this);
16514 store.on("update", this.onUpdate, this);
16515 store.on("clear", this.refresh, this);
16516 store.on("beforeload", this.onBeforeLoad, this);
16517 store.on("load", this.onLoad, this);
16518 store.on("loadexception", this.onLoad, this);
16526 * onbeforeLoad - masks the loading area.
16529 onBeforeLoad : function(store,opts)
16531 //Roo.log('onBeforeLoad');
16533 this.el.update("");
16535 this.el.mask(this.mask ? this.mask : "Loading" );
16537 onLoad : function ()
16544 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16545 * @param {HTMLElement} node
16546 * @return {HTMLElement} The template node
16548 findItemFromChild : function(node){
16549 var el = this.dataName ?
16550 this.el.child('.roo-tpl-' + this.dataName,true) :
16553 if(!node || node.parentNode == el){
16556 var p = node.parentNode;
16557 while(p && p != el){
16558 if(p.parentNode == el){
16567 onClick : function(e){
16568 var item = this.findItemFromChild(e.getTarget());
16570 var index = this.indexOf(item);
16571 if(this.onItemClick(item, index, e) !== false){
16572 this.fireEvent("click", this, index, item, e);
16575 this.clearSelections();
16580 onContextMenu : function(e){
16581 var item = this.findItemFromChild(e.getTarget());
16583 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16588 onDblClick : function(e){
16589 var item = this.findItemFromChild(e.getTarget());
16591 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16595 onItemClick : function(item, index, e)
16597 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16600 if (this.toggleSelect) {
16601 var m = this.isSelected(item) ? 'unselect' : 'select';
16604 _t[m](item, true, false);
16607 if(this.multiSelect || this.singleSelect){
16608 if(this.multiSelect && e.shiftKey && this.lastSelection){
16609 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16611 this.select(item, this.multiSelect && e.ctrlKey);
16612 this.lastSelection = item;
16615 if(!this.tickable){
16616 e.preventDefault();
16624 * Get the number of selected nodes.
16627 getSelectionCount : function(){
16628 return this.selections.length;
16632 * Get the currently selected nodes.
16633 * @return {Array} An array of HTMLElements
16635 getSelectedNodes : function(){
16636 return this.selections;
16640 * Get the indexes of the selected nodes.
16643 getSelectedIndexes : function(){
16644 var indexes = [], s = this.selections;
16645 for(var i = 0, len = s.length; i < len; i++){
16646 indexes.push(s[i].nodeIndex);
16652 * Clear all selections
16653 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16655 clearSelections : function(suppressEvent){
16656 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16657 this.cmp.elements = this.selections;
16658 this.cmp.removeClass(this.selectedClass);
16659 this.selections = [];
16660 if(!suppressEvent){
16661 this.fireEvent("selectionchange", this, this.selections);
16667 * Returns true if the passed node is selected
16668 * @param {HTMLElement/Number} node The node or node index
16669 * @return {Boolean}
16671 isSelected : function(node){
16672 var s = this.selections;
16676 node = this.getNode(node);
16677 return s.indexOf(node) !== -1;
16682 * @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
16683 * @param {Boolean} keepExisting (optional) true to keep existing selections
16684 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16686 select : function(nodeInfo, keepExisting, suppressEvent){
16687 if(nodeInfo instanceof Array){
16689 this.clearSelections(true);
16691 for(var i = 0, len = nodeInfo.length; i < len; i++){
16692 this.select(nodeInfo[i], true, true);
16696 var node = this.getNode(nodeInfo);
16697 if(!node || this.isSelected(node)){
16698 return; // already selected.
16701 this.clearSelections(true);
16704 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16705 Roo.fly(node).addClass(this.selectedClass);
16706 this.selections.push(node);
16707 if(!suppressEvent){
16708 this.fireEvent("selectionchange", this, this.selections);
16716 * @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
16717 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16718 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16720 unselect : function(nodeInfo, keepExisting, suppressEvent)
16722 if(nodeInfo instanceof Array){
16723 Roo.each(this.selections, function(s) {
16724 this.unselect(s, nodeInfo);
16728 var node = this.getNode(nodeInfo);
16729 if(!node || !this.isSelected(node)){
16730 //Roo.log("not selected");
16731 return; // not selected.
16735 Roo.each(this.selections, function(s) {
16737 Roo.fly(node).removeClass(this.selectedClass);
16744 this.selections= ns;
16745 this.fireEvent("selectionchange", this, this.selections);
16749 * Gets a template node.
16750 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16751 * @return {HTMLElement} The node or null if it wasn't found
16753 getNode : function(nodeInfo){
16754 if(typeof nodeInfo == "string"){
16755 return document.getElementById(nodeInfo);
16756 }else if(typeof nodeInfo == "number"){
16757 return this.nodes[nodeInfo];
16763 * Gets a range template nodes.
16764 * @param {Number} startIndex
16765 * @param {Number} endIndex
16766 * @return {Array} An array of nodes
16768 getNodes : function(start, end){
16769 var ns = this.nodes;
16770 start = start || 0;
16771 end = typeof end == "undefined" ? ns.length - 1 : end;
16774 for(var i = start; i <= end; i++){
16778 for(var i = start; i >= end; i--){
16786 * Finds the index of the passed node
16787 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16788 * @return {Number} The index of the node or -1
16790 indexOf : function(node){
16791 node = this.getNode(node);
16792 if(typeof node.nodeIndex == "number"){
16793 return node.nodeIndex;
16795 var ns = this.nodes;
16796 for(var i = 0, len = ns.length; i < len; i++){
16807 * based on jquery fullcalendar
16811 Roo.bootstrap = Roo.bootstrap || {};
16813 * @class Roo.bootstrap.Calendar
16814 * @extends Roo.bootstrap.Component
16815 * Bootstrap Calendar class
16816 * @cfg {Boolean} loadMask (true|false) default false
16817 * @cfg {Object} header generate the user specific header of the calendar, default false
16820 * Create a new Container
16821 * @param {Object} config The config object
16826 Roo.bootstrap.Calendar = function(config){
16827 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16831 * Fires when a date is selected
16832 * @param {DatePicker} this
16833 * @param {Date} date The selected date
16837 * @event monthchange
16838 * Fires when the displayed month changes
16839 * @param {DatePicker} this
16840 * @param {Date} date The selected month
16842 'monthchange': true,
16844 * @event evententer
16845 * Fires when mouse over an event
16846 * @param {Calendar} this
16847 * @param {event} Event
16849 'evententer': true,
16851 * @event eventleave
16852 * Fires when the mouse leaves an
16853 * @param {Calendar} this
16856 'eventleave': true,
16858 * @event eventclick
16859 * Fires when the mouse click an
16860 * @param {Calendar} this
16869 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16872 * @cfg {Number} startDay
16873 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16881 getAutoCreate : function(){
16884 var fc_button = function(name, corner, style, content ) {
16885 return Roo.apply({},{
16887 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16889 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16892 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16903 style : 'width:100%',
16910 cls : 'fc-header-left',
16912 fc_button('prev', 'left', 'arrow', '‹' ),
16913 fc_button('next', 'right', 'arrow', '›' ),
16914 { tag: 'span', cls: 'fc-header-space' },
16915 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16923 cls : 'fc-header-center',
16927 cls: 'fc-header-title',
16930 html : 'month / year'
16938 cls : 'fc-header-right',
16940 /* fc_button('month', 'left', '', 'month' ),
16941 fc_button('week', '', '', 'week' ),
16942 fc_button('day', 'right', '', 'day' )
16954 header = this.header;
16957 var cal_heads = function() {
16959 // fixme - handle this.
16961 for (var i =0; i < Date.dayNames.length; i++) {
16962 var d = Date.dayNames[i];
16965 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16966 html : d.substring(0,3)
16970 ret[0].cls += ' fc-first';
16971 ret[6].cls += ' fc-last';
16974 var cal_cell = function(n) {
16977 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16982 cls: 'fc-day-number',
16986 cls: 'fc-day-content',
16990 style: 'position: relative;' // height: 17px;
17002 var cal_rows = function() {
17005 for (var r = 0; r < 6; r++) {
17012 for (var i =0; i < Date.dayNames.length; i++) {
17013 var d = Date.dayNames[i];
17014 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17017 row.cn[0].cls+=' fc-first';
17018 row.cn[0].cn[0].style = 'min-height:90px';
17019 row.cn[6].cls+=' fc-last';
17023 ret[0].cls += ' fc-first';
17024 ret[4].cls += ' fc-prev-last';
17025 ret[5].cls += ' fc-last';
17032 cls: 'fc-border-separate',
17033 style : 'width:100%',
17041 cls : 'fc-first fc-last',
17059 cls : 'fc-content',
17060 style : "position: relative;",
17063 cls : 'fc-view fc-view-month fc-grid',
17064 style : 'position: relative',
17065 unselectable : 'on',
17068 cls : 'fc-event-container',
17069 style : 'position:absolute;z-index:8;top:0;left:0;'
17087 initEvents : function()
17090 throw "can not find store for calendar";
17096 style: "text-align:center",
17100 style: "background-color:white;width:50%;margin:250 auto",
17104 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17115 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17117 var size = this.el.select('.fc-content', true).first().getSize();
17118 this.maskEl.setSize(size.width, size.height);
17119 this.maskEl.enableDisplayMode("block");
17120 if(!this.loadMask){
17121 this.maskEl.hide();
17124 this.store = Roo.factory(this.store, Roo.data);
17125 this.store.on('load', this.onLoad, this);
17126 this.store.on('beforeload', this.onBeforeLoad, this);
17130 this.cells = this.el.select('.fc-day',true);
17131 //Roo.log(this.cells);
17132 this.textNodes = this.el.query('.fc-day-number');
17133 this.cells.addClassOnOver('fc-state-hover');
17135 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17136 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17137 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17138 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17140 this.on('monthchange', this.onMonthChange, this);
17142 this.update(new Date().clearTime());
17145 resize : function() {
17146 var sz = this.el.getSize();
17148 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17149 this.el.select('.fc-day-content div',true).setHeight(34);
17154 showPrevMonth : function(e){
17155 this.update(this.activeDate.add("mo", -1));
17157 showToday : function(e){
17158 this.update(new Date().clearTime());
17161 showNextMonth : function(e){
17162 this.update(this.activeDate.add("mo", 1));
17166 showPrevYear : function(){
17167 this.update(this.activeDate.add("y", -1));
17171 showNextYear : function(){
17172 this.update(this.activeDate.add("y", 1));
17177 update : function(date)
17179 var vd = this.activeDate;
17180 this.activeDate = date;
17181 // if(vd && this.el){
17182 // var t = date.getTime();
17183 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17184 // Roo.log('using add remove');
17186 // this.fireEvent('monthchange', this, date);
17188 // this.cells.removeClass("fc-state-highlight");
17189 // this.cells.each(function(c){
17190 // if(c.dateValue == t){
17191 // c.addClass("fc-state-highlight");
17192 // setTimeout(function(){
17193 // try{c.dom.firstChild.focus();}catch(e){}
17203 var days = date.getDaysInMonth();
17205 var firstOfMonth = date.getFirstDateOfMonth();
17206 var startingPos = firstOfMonth.getDay()-this.startDay;
17208 if(startingPos < this.startDay){
17212 var pm = date.add(Date.MONTH, -1);
17213 var prevStart = pm.getDaysInMonth()-startingPos;
17215 this.cells = this.el.select('.fc-day',true);
17216 this.textNodes = this.el.query('.fc-day-number');
17217 this.cells.addClassOnOver('fc-state-hover');
17219 var cells = this.cells.elements;
17220 var textEls = this.textNodes;
17222 Roo.each(cells, function(cell){
17223 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17226 days += startingPos;
17228 // convert everything to numbers so it's fast
17229 var day = 86400000;
17230 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17233 //Roo.log(prevStart);
17235 var today = new Date().clearTime().getTime();
17236 var sel = date.clearTime().getTime();
17237 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17238 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17239 var ddMatch = this.disabledDatesRE;
17240 var ddText = this.disabledDatesText;
17241 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17242 var ddaysText = this.disabledDaysText;
17243 var format = this.format;
17245 var setCellClass = function(cal, cell){
17249 //Roo.log('set Cell Class');
17251 var t = d.getTime();
17255 cell.dateValue = t;
17257 cell.className += " fc-today";
17258 cell.className += " fc-state-highlight";
17259 cell.title = cal.todayText;
17262 // disable highlight in other month..
17263 //cell.className += " fc-state-highlight";
17268 cell.className = " fc-state-disabled";
17269 cell.title = cal.minText;
17273 cell.className = " fc-state-disabled";
17274 cell.title = cal.maxText;
17278 if(ddays.indexOf(d.getDay()) != -1){
17279 cell.title = ddaysText;
17280 cell.className = " fc-state-disabled";
17283 if(ddMatch && format){
17284 var fvalue = d.dateFormat(format);
17285 if(ddMatch.test(fvalue)){
17286 cell.title = ddText.replace("%0", fvalue);
17287 cell.className = " fc-state-disabled";
17291 if (!cell.initialClassName) {
17292 cell.initialClassName = cell.dom.className;
17295 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17300 for(; i < startingPos; i++) {
17301 textEls[i].innerHTML = (++prevStart);
17302 d.setDate(d.getDate()+1);
17304 cells[i].className = "fc-past fc-other-month";
17305 setCellClass(this, cells[i]);
17310 for(; i < days; i++){
17311 intDay = i - startingPos + 1;
17312 textEls[i].innerHTML = (intDay);
17313 d.setDate(d.getDate()+1);
17315 cells[i].className = ''; // "x-date-active";
17316 setCellClass(this, cells[i]);
17320 for(; i < 42; i++) {
17321 textEls[i].innerHTML = (++extraDays);
17322 d.setDate(d.getDate()+1);
17324 cells[i].className = "fc-future fc-other-month";
17325 setCellClass(this, cells[i]);
17328 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17330 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17332 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17333 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17335 if(totalRows != 6){
17336 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17337 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17340 this.fireEvent('monthchange', this, date);
17344 if(!this.internalRender){
17345 var main = this.el.dom.firstChild;
17346 var w = main.offsetWidth;
17347 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17348 Roo.fly(main).setWidth(w);
17349 this.internalRender = true;
17350 // opera does not respect the auto grow header center column
17351 // then, after it gets a width opera refuses to recalculate
17352 // without a second pass
17353 if(Roo.isOpera && !this.secondPass){
17354 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17355 this.secondPass = true;
17356 this.update.defer(10, this, [date]);
17363 findCell : function(dt) {
17364 dt = dt.clearTime().getTime();
17366 this.cells.each(function(c){
17367 //Roo.log("check " +c.dateValue + '?=' + dt);
17368 if(c.dateValue == dt){
17378 findCells : function(ev) {
17379 var s = ev.start.clone().clearTime().getTime();
17381 var e= ev.end.clone().clearTime().getTime();
17384 this.cells.each(function(c){
17385 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17387 if(c.dateValue > e){
17390 if(c.dateValue < s){
17399 // findBestRow: function(cells)
17403 // for (var i =0 ; i < cells.length;i++) {
17404 // ret = Math.max(cells[i].rows || 0,ret);
17411 addItem : function(ev)
17413 // look for vertical location slot in
17414 var cells = this.findCells(ev);
17416 // ev.row = this.findBestRow(cells);
17418 // work out the location.
17422 for(var i =0; i < cells.length; i++) {
17424 cells[i].row = cells[0].row;
17427 cells[i].row = cells[i].row + 1;
17437 if (crow.start.getY() == cells[i].getY()) {
17439 crow.end = cells[i];
17456 cells[0].events.push(ev);
17458 this.calevents.push(ev);
17461 clearEvents: function() {
17463 if(!this.calevents){
17467 Roo.each(this.cells.elements, function(c){
17473 Roo.each(this.calevents, function(e) {
17474 Roo.each(e.els, function(el) {
17475 el.un('mouseenter' ,this.onEventEnter, this);
17476 el.un('mouseleave' ,this.onEventLeave, this);
17481 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17487 renderEvents: function()
17491 this.cells.each(function(c) {
17500 if(c.row != c.events.length){
17501 r = 4 - (4 - (c.row - c.events.length));
17504 c.events = ev.slice(0, r);
17505 c.more = ev.slice(r);
17507 if(c.more.length && c.more.length == 1){
17508 c.events.push(c.more.pop());
17511 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17515 this.cells.each(function(c) {
17517 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17520 for (var e = 0; e < c.events.length; e++){
17521 var ev = c.events[e];
17522 var rows = ev.rows;
17524 for(var i = 0; i < rows.length; i++) {
17526 // how many rows should it span..
17529 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17530 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17532 unselectable : "on",
17535 cls: 'fc-event-inner',
17539 // cls: 'fc-event-time',
17540 // html : cells.length > 1 ? '' : ev.time
17544 cls: 'fc-event-title',
17545 html : String.format('{0}', ev.title)
17552 cls: 'ui-resizable-handle ui-resizable-e',
17553 html : '  '
17560 cfg.cls += ' fc-event-start';
17562 if ((i+1) == rows.length) {
17563 cfg.cls += ' fc-event-end';
17566 var ctr = _this.el.select('.fc-event-container',true).first();
17567 var cg = ctr.createChild(cfg);
17569 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17570 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17572 var r = (c.more.length) ? 1 : 0;
17573 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17574 cg.setWidth(ebox.right - sbox.x -2);
17576 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17577 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17578 cg.on('click', _this.onEventClick, _this, ev);
17589 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17590 style : 'position: absolute',
17591 unselectable : "on",
17594 cls: 'fc-event-inner',
17598 cls: 'fc-event-title',
17606 cls: 'ui-resizable-handle ui-resizable-e',
17607 html : '  '
17613 var ctr = _this.el.select('.fc-event-container',true).first();
17614 var cg = ctr.createChild(cfg);
17616 var sbox = c.select('.fc-day-content',true).first().getBox();
17617 var ebox = c.select('.fc-day-content',true).first().getBox();
17619 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17620 cg.setWidth(ebox.right - sbox.x -2);
17622 cg.on('click', _this.onMoreEventClick, _this, c.more);
17632 onEventEnter: function (e, el,event,d) {
17633 this.fireEvent('evententer', this, el, event);
17636 onEventLeave: function (e, el,event,d) {
17637 this.fireEvent('eventleave', this, el, event);
17640 onEventClick: function (e, el,event,d) {
17641 this.fireEvent('eventclick', this, el, event);
17644 onMonthChange: function () {
17648 onMoreEventClick: function(e, el, more)
17652 this.calpopover.placement = 'right';
17653 this.calpopover.setTitle('More');
17655 this.calpopover.setContent('');
17657 var ctr = this.calpopover.el.select('.popover-content', true).first();
17659 Roo.each(more, function(m){
17661 cls : 'fc-event-hori fc-event-draggable',
17664 var cg = ctr.createChild(cfg);
17666 cg.on('click', _this.onEventClick, _this, m);
17669 this.calpopover.show(el);
17674 onLoad: function ()
17676 this.calevents = [];
17679 if(this.store.getCount() > 0){
17680 this.store.data.each(function(d){
17683 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17684 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17685 time : d.data.start_time,
17686 title : d.data.title,
17687 description : d.data.description,
17688 venue : d.data.venue
17693 this.renderEvents();
17695 if(this.calevents.length && this.loadMask){
17696 this.maskEl.hide();
17700 onBeforeLoad: function()
17702 this.clearEvents();
17704 this.maskEl.show();
17718 * @class Roo.bootstrap.Popover
17719 * @extends Roo.bootstrap.Component
17720 * Bootstrap Popover class
17721 * @cfg {String} html contents of the popover (or false to use children..)
17722 * @cfg {String} title of popover (or false to hide)
17723 * @cfg {String} placement how it is placed
17724 * @cfg {String} trigger click || hover (or false to trigger manually)
17725 * @cfg {String} over what (parent or false to trigger manually.)
17726 * @cfg {Number} delay - delay before showing
17729 * Create a new Popover
17730 * @param {Object} config The config object
17733 Roo.bootstrap.Popover = function(config){
17734 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17740 * After the popover show
17742 * @param {Roo.bootstrap.Popover} this
17747 * After the popover hide
17749 * @param {Roo.bootstrap.Popover} this
17755 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17757 title: 'Fill in a title',
17760 placement : 'right',
17761 trigger : 'hover', // hover
17767 can_build_overlaid : false,
17769 getChildContainer : function()
17771 return this.el.select('.popover-content',true).first();
17774 getAutoCreate : function(){
17777 cls : 'popover roo-dynamic',
17778 style: 'display:block',
17784 cls : 'popover-inner',
17788 cls: 'popover-title popover-header',
17792 cls : 'popover-content popover-body',
17803 setTitle: function(str)
17806 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17808 setContent: function(str)
17811 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17813 // as it get's added to the bottom of the page.
17814 onRender : function(ct, position)
17816 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17818 var cfg = Roo.apply({}, this.getAutoCreate());
17822 cfg.cls += ' ' + this.cls;
17825 cfg.style = this.style;
17827 //Roo.log("adding to ");
17828 this.el = Roo.get(document.body).createChild(cfg, position);
17829 // Roo.log(this.el);
17834 initEvents : function()
17836 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17837 this.el.enableDisplayMode('block');
17839 if (this.over === false) {
17842 if (this.triggers === false) {
17845 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17846 var triggers = this.trigger ? this.trigger.split(' ') : [];
17847 Roo.each(triggers, function(trigger) {
17849 if (trigger == 'click') {
17850 on_el.on('click', this.toggle, this);
17851 } else if (trigger != 'manual') {
17852 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17853 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17855 on_el.on(eventIn ,this.enter, this);
17856 on_el.on(eventOut, this.leave, this);
17867 toggle : function () {
17868 this.hoverState == 'in' ? this.leave() : this.enter();
17871 enter : function () {
17873 clearTimeout(this.timeout);
17875 this.hoverState = 'in';
17877 if (!this.delay || !this.delay.show) {
17882 this.timeout = setTimeout(function () {
17883 if (_t.hoverState == 'in') {
17886 }, this.delay.show)
17889 leave : function() {
17890 clearTimeout(this.timeout);
17892 this.hoverState = 'out';
17894 if (!this.delay || !this.delay.hide) {
17899 this.timeout = setTimeout(function () {
17900 if (_t.hoverState == 'out') {
17903 }, this.delay.hide)
17906 show : function (on_el)
17909 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17913 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17914 if (this.html !== false) {
17915 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17917 this.el.removeClass([
17918 'fade','top','bottom', 'left', 'right','in',
17919 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17921 if (!this.title.length) {
17922 this.el.select('.popover-title',true).hide();
17925 var placement = typeof this.placement == 'function' ?
17926 this.placement.call(this, this.el, on_el) :
17929 var autoToken = /\s?auto?\s?/i;
17930 var autoPlace = autoToken.test(placement);
17932 placement = placement.replace(autoToken, '') || 'top';
17936 //this.el.setXY([0,0]);
17938 this.el.dom.style.display='block';
17939 this.el.addClass(placement);
17941 //this.el.appendTo(on_el);
17943 var p = this.getPosition();
17944 var box = this.el.getBox();
17949 var align = Roo.bootstrap.Popover.alignment[placement];
17952 this.el.alignTo(on_el, align[0],align[1]);
17953 //var arrow = this.el.select('.arrow',true).first();
17954 //arrow.set(align[2],
17956 this.el.addClass('in');
17959 if (this.el.hasClass('fade')) {
17963 this.hoverState = 'in';
17965 this.fireEvent('show', this);
17970 this.el.setXY([0,0]);
17971 this.el.removeClass('in');
17973 this.hoverState = null;
17975 this.fireEvent('hide', this);
17980 Roo.bootstrap.Popover.alignment = {
17981 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
17982 'right' : ['l-r', [10,0], 'left bs-popover-left'],
17983 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
17984 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
17995 * @class Roo.bootstrap.Progress
17996 * @extends Roo.bootstrap.Component
17997 * Bootstrap Progress class
17998 * @cfg {Boolean} striped striped of the progress bar
17999 * @cfg {Boolean} active animated of the progress bar
18003 * Create a new Progress
18004 * @param {Object} config The config object
18007 Roo.bootstrap.Progress = function(config){
18008 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18011 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18016 getAutoCreate : function(){
18024 cfg.cls += ' progress-striped';
18028 cfg.cls += ' active';
18047 * @class Roo.bootstrap.ProgressBar
18048 * @extends Roo.bootstrap.Component
18049 * Bootstrap ProgressBar class
18050 * @cfg {Number} aria_valuenow aria-value now
18051 * @cfg {Number} aria_valuemin aria-value min
18052 * @cfg {Number} aria_valuemax aria-value max
18053 * @cfg {String} label label for the progress bar
18054 * @cfg {String} panel (success | info | warning | danger )
18055 * @cfg {String} role role of the progress bar
18056 * @cfg {String} sr_only text
18060 * Create a new ProgressBar
18061 * @param {Object} config The config object
18064 Roo.bootstrap.ProgressBar = function(config){
18065 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18068 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18072 aria_valuemax : 100,
18078 getAutoCreate : function()
18083 cls: 'progress-bar',
18084 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18096 cfg.role = this.role;
18099 if(this.aria_valuenow){
18100 cfg['aria-valuenow'] = this.aria_valuenow;
18103 if(this.aria_valuemin){
18104 cfg['aria-valuemin'] = this.aria_valuemin;
18107 if(this.aria_valuemax){
18108 cfg['aria-valuemax'] = this.aria_valuemax;
18111 if(this.label && !this.sr_only){
18112 cfg.html = this.label;
18116 cfg.cls += ' progress-bar-' + this.panel;
18122 update : function(aria_valuenow)
18124 this.aria_valuenow = aria_valuenow;
18126 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18141 * @class Roo.bootstrap.TabGroup
18142 * @extends Roo.bootstrap.Column
18143 * Bootstrap Column class
18144 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18145 * @cfg {Boolean} carousel true to make the group behave like a carousel
18146 * @cfg {Boolean} bullets show bullets for the panels
18147 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18148 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18149 * @cfg {Boolean} showarrow (true|false) show arrow default true
18152 * Create a new TabGroup
18153 * @param {Object} config The config object
18156 Roo.bootstrap.TabGroup = function(config){
18157 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18159 this.navId = Roo.id();
18162 Roo.bootstrap.TabGroup.register(this);
18166 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18169 transition : false,
18174 slideOnTouch : false,
18177 getAutoCreate : function()
18179 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18181 cfg.cls += ' tab-content';
18183 if (this.carousel) {
18184 cfg.cls += ' carousel slide';
18187 cls : 'carousel-inner',
18191 if(this.bullets && !Roo.isTouch){
18194 cls : 'carousel-bullets',
18198 if(this.bullets_cls){
18199 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18206 cfg.cn[0].cn.push(bullets);
18209 if(this.showarrow){
18210 cfg.cn[0].cn.push({
18212 class : 'carousel-arrow',
18216 class : 'carousel-prev',
18220 class : 'fa fa-chevron-left'
18226 class : 'carousel-next',
18230 class : 'fa fa-chevron-right'
18243 initEvents: function()
18245 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18246 // this.el.on("touchstart", this.onTouchStart, this);
18249 if(this.autoslide){
18252 this.slideFn = window.setInterval(function() {
18253 _this.showPanelNext();
18257 if(this.showarrow){
18258 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18259 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18265 // onTouchStart : function(e, el, o)
18267 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18271 // this.showPanelNext();
18275 getChildContainer : function()
18277 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18281 * register a Navigation item
18282 * @param {Roo.bootstrap.NavItem} the navitem to add
18284 register : function(item)
18286 this.tabs.push( item);
18287 item.navId = this.navId; // not really needed..
18292 getActivePanel : function()
18295 Roo.each(this.tabs, function(t) {
18305 getPanelByName : function(n)
18308 Roo.each(this.tabs, function(t) {
18309 if (t.tabId == n) {
18317 indexOfPanel : function(p)
18320 Roo.each(this.tabs, function(t,i) {
18321 if (t.tabId == p.tabId) {
18330 * show a specific panel
18331 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18332 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18334 showPanel : function (pan)
18336 if(this.transition || typeof(pan) == 'undefined'){
18337 Roo.log("waiting for the transitionend");
18341 if (typeof(pan) == 'number') {
18342 pan = this.tabs[pan];
18345 if (typeof(pan) == 'string') {
18346 pan = this.getPanelByName(pan);
18349 var cur = this.getActivePanel();
18352 Roo.log('pan or acitve pan is undefined');
18356 if (pan.tabId == this.getActivePanel().tabId) {
18360 if (false === cur.fireEvent('beforedeactivate')) {
18364 if(this.bullets > 0 && !Roo.isTouch){
18365 this.setActiveBullet(this.indexOfPanel(pan));
18368 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18370 //class="carousel-item carousel-item-next carousel-item-left"
18372 this.transition = true;
18373 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18374 var lr = dir == 'next' ? 'left' : 'right';
18375 pan.el.addClass(dir); // or prev
18376 pan.el.addClass('carousel-item-' + dir); // or prev
18377 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18378 cur.el.addClass(lr); // or right
18379 pan.el.addClass(lr);
18380 cur.el.addClass('carousel-item-' +lr); // or right
18381 pan.el.addClass('carousel-item-' +lr);
18385 cur.el.on('transitionend', function() {
18386 Roo.log("trans end?");
18388 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18389 pan.setActive(true);
18391 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18392 cur.setActive(false);
18394 _this.transition = false;
18396 }, this, { single: true } );
18401 cur.setActive(false);
18402 pan.setActive(true);
18407 showPanelNext : function()
18409 var i = this.indexOfPanel(this.getActivePanel());
18411 if (i >= this.tabs.length - 1 && !this.autoslide) {
18415 if (i >= this.tabs.length - 1 && this.autoslide) {
18419 this.showPanel(this.tabs[i+1]);
18422 showPanelPrev : function()
18424 var i = this.indexOfPanel(this.getActivePanel());
18426 if (i < 1 && !this.autoslide) {
18430 if (i < 1 && this.autoslide) {
18431 i = this.tabs.length;
18434 this.showPanel(this.tabs[i-1]);
18438 addBullet: function()
18440 if(!this.bullets || Roo.isTouch){
18443 var ctr = this.el.select('.carousel-bullets',true).first();
18444 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18445 var bullet = ctr.createChild({
18446 cls : 'bullet bullet-' + i
18447 },ctr.dom.lastChild);
18452 bullet.on('click', (function(e, el, o, ii, t){
18454 e.preventDefault();
18456 this.showPanel(ii);
18458 if(this.autoslide && this.slideFn){
18459 clearInterval(this.slideFn);
18460 this.slideFn = window.setInterval(function() {
18461 _this.showPanelNext();
18465 }).createDelegate(this, [i, bullet], true));
18470 setActiveBullet : function(i)
18476 Roo.each(this.el.select('.bullet', true).elements, function(el){
18477 el.removeClass('selected');
18480 var bullet = this.el.select('.bullet-' + i, true).first();
18486 bullet.addClass('selected');
18497 Roo.apply(Roo.bootstrap.TabGroup, {
18501 * register a Navigation Group
18502 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18504 register : function(navgrp)
18506 this.groups[navgrp.navId] = navgrp;
18510 * fetch a Navigation Group based on the navigation ID
18511 * if one does not exist , it will get created.
18512 * @param {string} the navgroup to add
18513 * @returns {Roo.bootstrap.NavGroup} the navgroup
18515 get: function(navId) {
18516 if (typeof(this.groups[navId]) == 'undefined') {
18517 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18519 return this.groups[navId] ;
18534 * @class Roo.bootstrap.TabPanel
18535 * @extends Roo.bootstrap.Component
18536 * Bootstrap TabPanel class
18537 * @cfg {Boolean} active panel active
18538 * @cfg {String} html panel content
18539 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18540 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18541 * @cfg {String} href click to link..
18545 * Create a new TabPanel
18546 * @param {Object} config The config object
18549 Roo.bootstrap.TabPanel = function(config){
18550 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18554 * Fires when the active status changes
18555 * @param {Roo.bootstrap.TabPanel} this
18556 * @param {Boolean} state the new state
18561 * @event beforedeactivate
18562 * Fires before a tab is de-activated - can be used to do validation on a form.
18563 * @param {Roo.bootstrap.TabPanel} this
18564 * @return {Boolean} false if there is an error
18567 'beforedeactivate': true
18570 this.tabId = this.tabId || Roo.id();
18574 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18582 getAutoCreate : function(){
18587 // item is needed for carousel - not sure if it has any effect otherwise
18588 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18589 html: this.html || ''
18593 cfg.cls += ' active';
18597 cfg.tabId = this.tabId;
18605 initEvents: function()
18607 var p = this.parent();
18609 this.navId = this.navId || p.navId;
18611 if (typeof(this.navId) != 'undefined') {
18612 // not really needed.. but just in case.. parent should be a NavGroup.
18613 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18617 var i = tg.tabs.length - 1;
18619 if(this.active && tg.bullets > 0 && i < tg.bullets){
18620 tg.setActiveBullet(i);
18624 this.el.on('click', this.onClick, this);
18627 this.el.on("touchstart", this.onTouchStart, this);
18628 this.el.on("touchmove", this.onTouchMove, this);
18629 this.el.on("touchend", this.onTouchEnd, this);
18634 onRender : function(ct, position)
18636 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18639 setActive : function(state)
18641 Roo.log("panel - set active " + this.tabId + "=" + state);
18643 this.active = state;
18645 this.el.removeClass('active');
18647 } else if (!this.el.hasClass('active')) {
18648 this.el.addClass('active');
18651 this.fireEvent('changed', this, state);
18654 onClick : function(e)
18656 e.preventDefault();
18658 if(!this.href.length){
18662 window.location.href = this.href;
18671 onTouchStart : function(e)
18673 this.swiping = false;
18675 this.startX = e.browserEvent.touches[0].clientX;
18676 this.startY = e.browserEvent.touches[0].clientY;
18679 onTouchMove : function(e)
18681 this.swiping = true;
18683 this.endX = e.browserEvent.touches[0].clientX;
18684 this.endY = e.browserEvent.touches[0].clientY;
18687 onTouchEnd : function(e)
18694 var tabGroup = this.parent();
18696 if(this.endX > this.startX){ // swiping right
18697 tabGroup.showPanelPrev();
18701 if(this.startX > this.endX){ // swiping left
18702 tabGroup.showPanelNext();
18721 * @class Roo.bootstrap.DateField
18722 * @extends Roo.bootstrap.Input
18723 * Bootstrap DateField class
18724 * @cfg {Number} weekStart default 0
18725 * @cfg {String} viewMode default empty, (months|years)
18726 * @cfg {String} minViewMode default empty, (months|years)
18727 * @cfg {Number} startDate default -Infinity
18728 * @cfg {Number} endDate default Infinity
18729 * @cfg {Boolean} todayHighlight default false
18730 * @cfg {Boolean} todayBtn default false
18731 * @cfg {Boolean} calendarWeeks default false
18732 * @cfg {Object} daysOfWeekDisabled default empty
18733 * @cfg {Boolean} singleMode default false (true | false)
18735 * @cfg {Boolean} keyboardNavigation default true
18736 * @cfg {String} language default en
18739 * Create a new DateField
18740 * @param {Object} config The config object
18743 Roo.bootstrap.DateField = function(config){
18744 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18748 * Fires when this field show.
18749 * @param {Roo.bootstrap.DateField} this
18750 * @param {Mixed} date The date value
18755 * Fires when this field hide.
18756 * @param {Roo.bootstrap.DateField} this
18757 * @param {Mixed} date The date value
18762 * Fires when select a date.
18763 * @param {Roo.bootstrap.DateField} this
18764 * @param {Mixed} date The date value
18768 * @event beforeselect
18769 * Fires when before select a date.
18770 * @param {Roo.bootstrap.DateField} this
18771 * @param {Mixed} date The date value
18773 beforeselect : true
18777 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18780 * @cfg {String} format
18781 * The default date format string which can be overriden for localization support. The format must be
18782 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18786 * @cfg {String} altFormats
18787 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18788 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18790 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18798 todayHighlight : false,
18804 keyboardNavigation: true,
18806 calendarWeeks: false,
18808 startDate: -Infinity,
18812 daysOfWeekDisabled: [],
18816 singleMode : false,
18818 UTCDate: function()
18820 return new Date(Date.UTC.apply(Date, arguments));
18823 UTCToday: function()
18825 var today = new Date();
18826 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18829 getDate: function() {
18830 var d = this.getUTCDate();
18831 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18834 getUTCDate: function() {
18838 setDate: function(d) {
18839 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18842 setUTCDate: function(d) {
18844 this.setValue(this.formatDate(this.date));
18847 onRender: function(ct, position)
18850 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18852 this.language = this.language || 'en';
18853 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18854 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18856 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18857 this.format = this.format || 'm/d/y';
18858 this.isInline = false;
18859 this.isInput = true;
18860 this.component = this.el.select('.add-on', true).first() || false;
18861 this.component = (this.component && this.component.length === 0) ? false : this.component;
18862 this.hasInput = this.component && this.inputEl().length;
18864 if (typeof(this.minViewMode === 'string')) {
18865 switch (this.minViewMode) {
18867 this.minViewMode = 1;
18870 this.minViewMode = 2;
18873 this.minViewMode = 0;
18878 if (typeof(this.viewMode === 'string')) {
18879 switch (this.viewMode) {
18892 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18894 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18896 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18898 this.picker().on('mousedown', this.onMousedown, this);
18899 this.picker().on('click', this.onClick, this);
18901 this.picker().addClass('datepicker-dropdown');
18903 this.startViewMode = this.viewMode;
18905 if(this.singleMode){
18906 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18907 v.setVisibilityMode(Roo.Element.DISPLAY);
18911 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18912 v.setStyle('width', '189px');
18916 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18917 if(!this.calendarWeeks){
18922 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18923 v.attr('colspan', function(i, val){
18924 return parseInt(val) + 1;
18929 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18931 this.setStartDate(this.startDate);
18932 this.setEndDate(this.endDate);
18934 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18941 if(this.isInline) {
18946 picker : function()
18948 return this.pickerEl;
18949 // return this.el.select('.datepicker', true).first();
18952 fillDow: function()
18954 var dowCnt = this.weekStart;
18963 if(this.calendarWeeks){
18971 while (dowCnt < this.weekStart + 7) {
18975 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18979 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18982 fillMonths: function()
18985 var months = this.picker().select('>.datepicker-months td', true).first();
18987 months.dom.innerHTML = '';
18993 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18996 months.createChild(month);
19003 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;
19005 if (this.date < this.startDate) {
19006 this.viewDate = new Date(this.startDate);
19007 } else if (this.date > this.endDate) {
19008 this.viewDate = new Date(this.endDate);
19010 this.viewDate = new Date(this.date);
19018 var d = new Date(this.viewDate),
19019 year = d.getUTCFullYear(),
19020 month = d.getUTCMonth(),
19021 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19022 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19023 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19024 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19025 currentDate = this.date && this.date.valueOf(),
19026 today = this.UTCToday();
19028 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19030 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19032 // this.picker.select('>tfoot th.today').
19033 // .text(dates[this.language].today)
19034 // .toggle(this.todayBtn !== false);
19036 this.updateNavArrows();
19039 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19041 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19043 prevMonth.setUTCDate(day);
19045 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19047 var nextMonth = new Date(prevMonth);
19049 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19051 nextMonth = nextMonth.valueOf();
19053 var fillMonths = false;
19055 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19057 while(prevMonth.valueOf() <= nextMonth) {
19060 if (prevMonth.getUTCDay() === this.weekStart) {
19062 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19070 if(this.calendarWeeks){
19071 // ISO 8601: First week contains first thursday.
19072 // ISO also states week starts on Monday, but we can be more abstract here.
19074 // Start of current week: based on weekstart/current date
19075 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19076 // Thursday of this week
19077 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19078 // First Thursday of year, year from thursday
19079 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19080 // Calendar week: ms between thursdays, div ms per day, div 7 days
19081 calWeek = (th - yth) / 864e5 / 7 + 1;
19083 fillMonths.cn.push({
19091 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19093 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19096 if (this.todayHighlight &&
19097 prevMonth.getUTCFullYear() == today.getFullYear() &&
19098 prevMonth.getUTCMonth() == today.getMonth() &&
19099 prevMonth.getUTCDate() == today.getDate()) {
19100 clsName += ' today';
19103 if (currentDate && prevMonth.valueOf() === currentDate) {
19104 clsName += ' active';
19107 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19108 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19109 clsName += ' disabled';
19112 fillMonths.cn.push({
19114 cls: 'day ' + clsName,
19115 html: prevMonth.getDate()
19118 prevMonth.setDate(prevMonth.getDate()+1);
19121 var currentYear = this.date && this.date.getUTCFullYear();
19122 var currentMonth = this.date && this.date.getUTCMonth();
19124 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19126 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19127 v.removeClass('active');
19129 if(currentYear === year && k === currentMonth){
19130 v.addClass('active');
19133 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19134 v.addClass('disabled');
19140 year = parseInt(year/10, 10) * 10;
19142 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19144 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19147 for (var i = -1; i < 11; i++) {
19148 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19150 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19158 showMode: function(dir)
19161 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19164 Roo.each(this.picker().select('>div',true).elements, function(v){
19165 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19168 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19173 if(this.isInline) {
19177 this.picker().removeClass(['bottom', 'top']);
19179 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19181 * place to the top of element!
19185 this.picker().addClass('top');
19186 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19191 this.picker().addClass('bottom');
19193 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19196 parseDate : function(value)
19198 if(!value || value instanceof Date){
19201 var v = Date.parseDate(value, this.format);
19202 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19203 v = Date.parseDate(value, 'Y-m-d');
19205 if(!v && this.altFormats){
19206 if(!this.altFormatsArray){
19207 this.altFormatsArray = this.altFormats.split("|");
19209 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19210 v = Date.parseDate(value, this.altFormatsArray[i]);
19216 formatDate : function(date, fmt)
19218 return (!date || !(date instanceof Date)) ?
19219 date : date.dateFormat(fmt || this.format);
19222 onFocus : function()
19224 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19228 onBlur : function()
19230 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19232 var d = this.inputEl().getValue();
19239 showPopup : function()
19241 this.picker().show();
19245 this.fireEvent('showpopup', this, this.date);
19248 hidePopup : function()
19250 if(this.isInline) {
19253 this.picker().hide();
19254 this.viewMode = this.startViewMode;
19257 this.fireEvent('hidepopup', this, this.date);
19261 onMousedown: function(e)
19263 e.stopPropagation();
19264 e.preventDefault();
19269 Roo.bootstrap.DateField.superclass.keyup.call(this);
19273 setValue: function(v)
19275 if(this.fireEvent('beforeselect', this, v) !== false){
19276 var d = new Date(this.parseDate(v) ).clearTime();
19278 if(isNaN(d.getTime())){
19279 this.date = this.viewDate = '';
19280 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19284 v = this.formatDate(d);
19286 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19288 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19292 this.fireEvent('select', this, this.date);
19296 getValue: function()
19298 return this.formatDate(this.date);
19301 fireKey: function(e)
19303 if (!this.picker().isVisible()){
19304 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19310 var dateChanged = false,
19312 newDate, newViewDate;
19317 e.preventDefault();
19321 if (!this.keyboardNavigation) {
19324 dir = e.keyCode == 37 ? -1 : 1;
19327 newDate = this.moveYear(this.date, dir);
19328 newViewDate = this.moveYear(this.viewDate, dir);
19329 } else if (e.shiftKey){
19330 newDate = this.moveMonth(this.date, dir);
19331 newViewDate = this.moveMonth(this.viewDate, dir);
19333 newDate = new Date(this.date);
19334 newDate.setUTCDate(this.date.getUTCDate() + dir);
19335 newViewDate = new Date(this.viewDate);
19336 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19338 if (this.dateWithinRange(newDate)){
19339 this.date = newDate;
19340 this.viewDate = newViewDate;
19341 this.setValue(this.formatDate(this.date));
19343 e.preventDefault();
19344 dateChanged = true;
19349 if (!this.keyboardNavigation) {
19352 dir = e.keyCode == 38 ? -1 : 1;
19354 newDate = this.moveYear(this.date, dir);
19355 newViewDate = this.moveYear(this.viewDate, dir);
19356 } else if (e.shiftKey){
19357 newDate = this.moveMonth(this.date, dir);
19358 newViewDate = this.moveMonth(this.viewDate, dir);
19360 newDate = new Date(this.date);
19361 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19362 newViewDate = new Date(this.viewDate);
19363 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19365 if (this.dateWithinRange(newDate)){
19366 this.date = newDate;
19367 this.viewDate = newViewDate;
19368 this.setValue(this.formatDate(this.date));
19370 e.preventDefault();
19371 dateChanged = true;
19375 this.setValue(this.formatDate(this.date));
19377 e.preventDefault();
19380 this.setValue(this.formatDate(this.date));
19394 onClick: function(e)
19396 e.stopPropagation();
19397 e.preventDefault();
19399 var target = e.getTarget();
19401 if(target.nodeName.toLowerCase() === 'i'){
19402 target = Roo.get(target).dom.parentNode;
19405 var nodeName = target.nodeName;
19406 var className = target.className;
19407 var html = target.innerHTML;
19408 //Roo.log(nodeName);
19410 switch(nodeName.toLowerCase()) {
19412 switch(className) {
19418 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19419 switch(this.viewMode){
19421 this.viewDate = this.moveMonth(this.viewDate, dir);
19425 this.viewDate = this.moveYear(this.viewDate, dir);
19431 var date = new Date();
19432 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19434 this.setValue(this.formatDate(this.date));
19441 if (className.indexOf('disabled') < 0) {
19442 this.viewDate.setUTCDate(1);
19443 if (className.indexOf('month') > -1) {
19444 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19446 var year = parseInt(html, 10) || 0;
19447 this.viewDate.setUTCFullYear(year);
19451 if(this.singleMode){
19452 this.setValue(this.formatDate(this.viewDate));
19463 //Roo.log(className);
19464 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19465 var day = parseInt(html, 10) || 1;
19466 var year = this.viewDate.getUTCFullYear(),
19467 month = this.viewDate.getUTCMonth();
19469 if (className.indexOf('old') > -1) {
19476 } else if (className.indexOf('new') > -1) {
19484 //Roo.log([year,month,day]);
19485 this.date = this.UTCDate(year, month, day,0,0,0,0);
19486 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19488 //Roo.log(this.formatDate(this.date));
19489 this.setValue(this.formatDate(this.date));
19496 setStartDate: function(startDate)
19498 this.startDate = startDate || -Infinity;
19499 if (this.startDate !== -Infinity) {
19500 this.startDate = this.parseDate(this.startDate);
19503 this.updateNavArrows();
19506 setEndDate: function(endDate)
19508 this.endDate = endDate || Infinity;
19509 if (this.endDate !== Infinity) {
19510 this.endDate = this.parseDate(this.endDate);
19513 this.updateNavArrows();
19516 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19518 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19519 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19520 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19522 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19523 return parseInt(d, 10);
19526 this.updateNavArrows();
19529 updateNavArrows: function()
19531 if(this.singleMode){
19535 var d = new Date(this.viewDate),
19536 year = d.getUTCFullYear(),
19537 month = d.getUTCMonth();
19539 Roo.each(this.picker().select('.prev', true).elements, function(v){
19541 switch (this.viewMode) {
19544 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19550 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19557 Roo.each(this.picker().select('.next', true).elements, function(v){
19559 switch (this.viewMode) {
19562 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19568 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19576 moveMonth: function(date, dir)
19581 var new_date = new Date(date.valueOf()),
19582 day = new_date.getUTCDate(),
19583 month = new_date.getUTCMonth(),
19584 mag = Math.abs(dir),
19586 dir = dir > 0 ? 1 : -1;
19589 // If going back one month, make sure month is not current month
19590 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19592 return new_date.getUTCMonth() == month;
19594 // If going forward one month, make sure month is as expected
19595 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19597 return new_date.getUTCMonth() != new_month;
19599 new_month = month + dir;
19600 new_date.setUTCMonth(new_month);
19601 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19602 if (new_month < 0 || new_month > 11) {
19603 new_month = (new_month + 12) % 12;
19606 // For magnitudes >1, move one month at a time...
19607 for (var i=0; i<mag; i++) {
19608 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19609 new_date = this.moveMonth(new_date, dir);
19611 // ...then reset the day, keeping it in the new month
19612 new_month = new_date.getUTCMonth();
19613 new_date.setUTCDate(day);
19615 return new_month != new_date.getUTCMonth();
19618 // Common date-resetting loop -- if date is beyond end of month, make it
19621 new_date.setUTCDate(--day);
19622 new_date.setUTCMonth(new_month);
19627 moveYear: function(date, dir)
19629 return this.moveMonth(date, dir*12);
19632 dateWithinRange: function(date)
19634 return date >= this.startDate && date <= this.endDate;
19640 this.picker().remove();
19643 validateValue : function(value)
19645 if(this.getVisibilityEl().hasClass('hidden')){
19649 if(value.length < 1) {
19650 if(this.allowBlank){
19656 if(value.length < this.minLength){
19659 if(value.length > this.maxLength){
19663 var vt = Roo.form.VTypes;
19664 if(!vt[this.vtype](value, this)){
19668 if(typeof this.validator == "function"){
19669 var msg = this.validator(value);
19675 if(this.regex && !this.regex.test(value)){
19679 if(typeof(this.parseDate(value)) == 'undefined'){
19683 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19687 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19697 this.date = this.viewDate = '';
19699 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19704 Roo.apply(Roo.bootstrap.DateField, {
19715 html: '<i class="fa fa-arrow-left"/>'
19725 html: '<i class="fa fa-arrow-right"/>'
19767 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19768 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19769 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19770 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19771 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19784 navFnc: 'FullYear',
19789 navFnc: 'FullYear',
19794 Roo.apply(Roo.bootstrap.DateField, {
19798 cls: 'datepicker dropdown-menu roo-dynamic',
19802 cls: 'datepicker-days',
19806 cls: 'table-condensed',
19808 Roo.bootstrap.DateField.head,
19812 Roo.bootstrap.DateField.footer
19819 cls: 'datepicker-months',
19823 cls: 'table-condensed',
19825 Roo.bootstrap.DateField.head,
19826 Roo.bootstrap.DateField.content,
19827 Roo.bootstrap.DateField.footer
19834 cls: 'datepicker-years',
19838 cls: 'table-condensed',
19840 Roo.bootstrap.DateField.head,
19841 Roo.bootstrap.DateField.content,
19842 Roo.bootstrap.DateField.footer
19861 * @class Roo.bootstrap.TimeField
19862 * @extends Roo.bootstrap.Input
19863 * Bootstrap DateField class
19867 * Create a new TimeField
19868 * @param {Object} config The config object
19871 Roo.bootstrap.TimeField = function(config){
19872 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19876 * Fires when this field show.
19877 * @param {Roo.bootstrap.DateField} thisthis
19878 * @param {Mixed} date The date value
19883 * Fires when this field hide.
19884 * @param {Roo.bootstrap.DateField} this
19885 * @param {Mixed} date The date value
19890 * Fires when select a date.
19891 * @param {Roo.bootstrap.DateField} this
19892 * @param {Mixed} date The date value
19898 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19901 * @cfg {String} format
19902 * The default time format string which can be overriden for localization support. The format must be
19903 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19907 onRender: function(ct, position)
19910 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19912 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19914 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19916 this.pop = this.picker().select('>.datepicker-time',true).first();
19917 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19919 this.picker().on('mousedown', this.onMousedown, this);
19920 this.picker().on('click', this.onClick, this);
19922 this.picker().addClass('datepicker-dropdown');
19927 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19928 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19929 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19930 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19931 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19932 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19936 fireKey: function(e){
19937 if (!this.picker().isVisible()){
19938 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19944 e.preventDefault();
19952 this.onTogglePeriod();
19955 this.onIncrementMinutes();
19958 this.onDecrementMinutes();
19967 onClick: function(e) {
19968 e.stopPropagation();
19969 e.preventDefault();
19972 picker : function()
19974 return this.el.select('.datepicker', true).first();
19977 fillTime: function()
19979 var time = this.pop.select('tbody', true).first();
19981 time.dom.innerHTML = '';
19996 cls: 'hours-up glyphicon glyphicon-chevron-up'
20016 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20037 cls: 'timepicker-hour',
20052 cls: 'timepicker-minute',
20067 cls: 'btn btn-primary period',
20089 cls: 'hours-down glyphicon glyphicon-chevron-down'
20109 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20127 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20134 var hours = this.time.getHours();
20135 var minutes = this.time.getMinutes();
20148 hours = hours - 12;
20152 hours = '0' + hours;
20156 minutes = '0' + minutes;
20159 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20160 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20161 this.pop.select('button', true).first().dom.innerHTML = period;
20167 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20169 var cls = ['bottom'];
20171 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20178 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20183 this.picker().addClass(cls.join('-'));
20187 Roo.each(cls, function(c){
20189 _this.picker().setTop(_this.inputEl().getHeight());
20193 _this.picker().setTop(0 - _this.picker().getHeight());
20198 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20202 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20209 onFocus : function()
20211 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20215 onBlur : function()
20217 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20223 this.picker().show();
20228 this.fireEvent('show', this, this.date);
20233 this.picker().hide();
20236 this.fireEvent('hide', this, this.date);
20239 setTime : function()
20242 this.setValue(this.time.format(this.format));
20244 this.fireEvent('select', this, this.date);
20249 onMousedown: function(e){
20250 e.stopPropagation();
20251 e.preventDefault();
20254 onIncrementHours: function()
20256 Roo.log('onIncrementHours');
20257 this.time = this.time.add(Date.HOUR, 1);
20262 onDecrementHours: function()
20264 Roo.log('onDecrementHours');
20265 this.time = this.time.add(Date.HOUR, -1);
20269 onIncrementMinutes: function()
20271 Roo.log('onIncrementMinutes');
20272 this.time = this.time.add(Date.MINUTE, 1);
20276 onDecrementMinutes: function()
20278 Roo.log('onDecrementMinutes');
20279 this.time = this.time.add(Date.MINUTE, -1);
20283 onTogglePeriod: function()
20285 Roo.log('onTogglePeriod');
20286 this.time = this.time.add(Date.HOUR, 12);
20293 Roo.apply(Roo.bootstrap.TimeField, {
20323 cls: 'btn btn-info ok',
20335 Roo.apply(Roo.bootstrap.TimeField, {
20339 cls: 'datepicker dropdown-menu',
20343 cls: 'datepicker-time',
20347 cls: 'table-condensed',
20349 Roo.bootstrap.TimeField.content,
20350 Roo.bootstrap.TimeField.footer
20369 * @class Roo.bootstrap.MonthField
20370 * @extends Roo.bootstrap.Input
20371 * Bootstrap MonthField class
20373 * @cfg {String} language default en
20376 * Create a new MonthField
20377 * @param {Object} config The config object
20380 Roo.bootstrap.MonthField = function(config){
20381 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20386 * Fires when this field show.
20387 * @param {Roo.bootstrap.MonthField} this
20388 * @param {Mixed} date The date value
20393 * Fires when this field hide.
20394 * @param {Roo.bootstrap.MonthField} this
20395 * @param {Mixed} date The date value
20400 * Fires when select a date.
20401 * @param {Roo.bootstrap.MonthField} this
20402 * @param {String} oldvalue The old value
20403 * @param {String} newvalue The new value
20409 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20411 onRender: function(ct, position)
20414 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20416 this.language = this.language || 'en';
20417 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20418 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20420 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20421 this.isInline = false;
20422 this.isInput = true;
20423 this.component = this.el.select('.add-on', true).first() || false;
20424 this.component = (this.component && this.component.length === 0) ? false : this.component;
20425 this.hasInput = this.component && this.inputEL().length;
20427 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20429 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20431 this.picker().on('mousedown', this.onMousedown, this);
20432 this.picker().on('click', this.onClick, this);
20434 this.picker().addClass('datepicker-dropdown');
20436 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20437 v.setStyle('width', '189px');
20444 if(this.isInline) {
20450 setValue: function(v, suppressEvent)
20452 var o = this.getValue();
20454 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20458 if(suppressEvent !== true){
20459 this.fireEvent('select', this, o, v);
20464 getValue: function()
20469 onClick: function(e)
20471 e.stopPropagation();
20472 e.preventDefault();
20474 var target = e.getTarget();
20476 if(target.nodeName.toLowerCase() === 'i'){
20477 target = Roo.get(target).dom.parentNode;
20480 var nodeName = target.nodeName;
20481 var className = target.className;
20482 var html = target.innerHTML;
20484 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20488 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20490 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20496 picker : function()
20498 return this.pickerEl;
20501 fillMonths: function()
20504 var months = this.picker().select('>.datepicker-months td', true).first();
20506 months.dom.innerHTML = '';
20512 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20515 months.createChild(month);
20524 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20525 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20528 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20529 e.removeClass('active');
20531 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20532 e.addClass('active');
20539 if(this.isInline) {
20543 this.picker().removeClass(['bottom', 'top']);
20545 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20547 * place to the top of element!
20551 this.picker().addClass('top');
20552 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20557 this.picker().addClass('bottom');
20559 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20562 onFocus : function()
20564 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20568 onBlur : function()
20570 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20572 var d = this.inputEl().getValue();
20581 this.picker().show();
20582 this.picker().select('>.datepicker-months', true).first().show();
20586 this.fireEvent('show', this, this.date);
20591 if(this.isInline) {
20594 this.picker().hide();
20595 this.fireEvent('hide', this, this.date);
20599 onMousedown: function(e)
20601 e.stopPropagation();
20602 e.preventDefault();
20607 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20611 fireKey: function(e)
20613 if (!this.picker().isVisible()){
20614 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20625 e.preventDefault();
20629 dir = e.keyCode == 37 ? -1 : 1;
20631 this.vIndex = this.vIndex + dir;
20633 if(this.vIndex < 0){
20637 if(this.vIndex > 11){
20641 if(isNaN(this.vIndex)){
20645 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20651 dir = e.keyCode == 38 ? -1 : 1;
20653 this.vIndex = this.vIndex + dir * 4;
20655 if(this.vIndex < 0){
20659 if(this.vIndex > 11){
20663 if(isNaN(this.vIndex)){
20667 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20672 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20673 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20677 e.preventDefault();
20680 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20681 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20697 this.picker().remove();
20702 Roo.apply(Roo.bootstrap.MonthField, {
20721 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20722 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20727 Roo.apply(Roo.bootstrap.MonthField, {
20731 cls: 'datepicker dropdown-menu roo-dynamic',
20735 cls: 'datepicker-months',
20739 cls: 'table-condensed',
20741 Roo.bootstrap.DateField.content
20761 * @class Roo.bootstrap.CheckBox
20762 * @extends Roo.bootstrap.Input
20763 * Bootstrap CheckBox class
20765 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20766 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20767 * @cfg {String} boxLabel The text that appears beside the checkbox
20768 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20769 * @cfg {Boolean} checked initnal the element
20770 * @cfg {Boolean} inline inline the element (default false)
20771 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20772 * @cfg {String} tooltip label tooltip
20775 * Create a new CheckBox
20776 * @param {Object} config The config object
20779 Roo.bootstrap.CheckBox = function(config){
20780 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20785 * Fires when the element is checked or unchecked.
20786 * @param {Roo.bootstrap.CheckBox} this This input
20787 * @param {Boolean} checked The new checked value
20792 * Fires when the element is click.
20793 * @param {Roo.bootstrap.CheckBox} this This input
20800 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20802 inputType: 'checkbox',
20811 getAutoCreate : function()
20813 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20819 cfg.cls = 'form-group ' + this.inputType; //input-group
20822 cfg.cls += ' ' + this.inputType + '-inline';
20828 type : this.inputType,
20829 value : this.inputValue,
20830 cls : 'roo-' + this.inputType, //'form-box',
20831 placeholder : this.placeholder || ''
20835 if(this.inputType != 'radio'){
20839 cls : 'roo-hidden-value',
20840 value : this.checked ? this.inputValue : this.valueOff
20845 if (this.weight) { // Validity check?
20846 cfg.cls += " " + this.inputType + "-" + this.weight;
20849 if (this.disabled) {
20850 input.disabled=true;
20854 input.checked = this.checked;
20859 input.name = this.name;
20861 if(this.inputType != 'radio'){
20862 hidden.name = this.name;
20863 input.name = '_hidden_' + this.name;
20868 input.cls += ' input-' + this.size;
20873 ['xs','sm','md','lg'].map(function(size){
20874 if (settings[size]) {
20875 cfg.cls += ' col-' + size + '-' + settings[size];
20879 var inputblock = input;
20881 if (this.before || this.after) {
20884 cls : 'input-group',
20889 inputblock.cn.push({
20891 cls : 'input-group-addon',
20896 inputblock.cn.push(input);
20898 if(this.inputType != 'radio'){
20899 inputblock.cn.push(hidden);
20903 inputblock.cn.push({
20905 cls : 'input-group-addon',
20912 if (align ==='left' && this.fieldLabel.length) {
20913 // Roo.log("left and has label");
20918 cls : 'control-label',
20919 html : this.fieldLabel
20929 if(this.labelWidth > 12){
20930 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20933 if(this.labelWidth < 13 && this.labelmd == 0){
20934 this.labelmd = this.labelWidth;
20937 if(this.labellg > 0){
20938 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20939 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20942 if(this.labelmd > 0){
20943 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20944 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20947 if(this.labelsm > 0){
20948 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20949 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20952 if(this.labelxs > 0){
20953 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20954 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20957 } else if ( this.fieldLabel.length) {
20958 // Roo.log(" label");
20962 tag: this.boxLabel ? 'span' : 'label',
20964 cls: 'control-label box-input-label',
20965 //cls : 'input-group-addon',
20966 html : this.fieldLabel
20975 // Roo.log(" no label && no align");
20976 cfg.cn = [ inputblock ] ;
20982 var boxLabelCfg = {
20984 //'for': id, // box label is handled by onclick - so no for...
20986 html: this.boxLabel
20990 boxLabelCfg.tooltip = this.tooltip;
20993 cfg.cn.push(boxLabelCfg);
20996 if(this.inputType != 'radio'){
20997 cfg.cn.push(hidden);
21005 * return the real input element.
21007 inputEl: function ()
21009 return this.el.select('input.roo-' + this.inputType,true).first();
21011 hiddenEl: function ()
21013 return this.el.select('input.roo-hidden-value',true).first();
21016 labelEl: function()
21018 return this.el.select('label.control-label',true).first();
21020 /* depricated... */
21024 return this.labelEl();
21027 boxLabelEl: function()
21029 return this.el.select('label.box-label',true).first();
21032 initEvents : function()
21034 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21036 this.inputEl().on('click', this.onClick, this);
21038 if (this.boxLabel) {
21039 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21042 this.startValue = this.getValue();
21045 Roo.bootstrap.CheckBox.register(this);
21049 onClick : function(e)
21051 if(this.fireEvent('click', this, e) !== false){
21052 this.setChecked(!this.checked);
21057 setChecked : function(state,suppressEvent)
21059 this.startValue = this.getValue();
21061 if(this.inputType == 'radio'){
21063 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21064 e.dom.checked = false;
21067 this.inputEl().dom.checked = true;
21069 this.inputEl().dom.value = this.inputValue;
21071 if(suppressEvent !== true){
21072 this.fireEvent('check', this, true);
21080 this.checked = state;
21082 this.inputEl().dom.checked = state;
21085 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21087 if(suppressEvent !== true){
21088 this.fireEvent('check', this, state);
21094 getValue : function()
21096 if(this.inputType == 'radio'){
21097 return this.getGroupValue();
21100 return this.hiddenEl().dom.value;
21104 getGroupValue : function()
21106 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21110 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21113 setValue : function(v,suppressEvent)
21115 if(this.inputType == 'radio'){
21116 this.setGroupValue(v, suppressEvent);
21120 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21125 setGroupValue : function(v, suppressEvent)
21127 this.startValue = this.getValue();
21129 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21130 e.dom.checked = false;
21132 if(e.dom.value == v){
21133 e.dom.checked = true;
21137 if(suppressEvent !== true){
21138 this.fireEvent('check', this, true);
21146 validate : function()
21148 if(this.getVisibilityEl().hasClass('hidden')){
21154 (this.inputType == 'radio' && this.validateRadio()) ||
21155 (this.inputType == 'checkbox' && this.validateCheckbox())
21161 this.markInvalid();
21165 validateRadio : function()
21167 if(this.getVisibilityEl().hasClass('hidden')){
21171 if(this.allowBlank){
21177 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21178 if(!e.dom.checked){
21190 validateCheckbox : function()
21193 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21194 //return (this.getValue() == this.inputValue) ? true : false;
21197 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21205 for(var i in group){
21206 if(group[i].el.isVisible(true)){
21214 for(var i in group){
21219 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21226 * Mark this field as valid
21228 markValid : function()
21232 this.fireEvent('valid', this);
21234 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21237 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21244 if(this.inputType == 'radio'){
21245 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21246 var fg = e.findParent('.form-group', false, true);
21247 if (Roo.bootstrap.version == 3) {
21248 fg.removeClass([_this.invalidClass, _this.validClass]);
21249 fg.addClass(_this.validClass);
21251 fg.removeClass(['is-valid', 'is-invalid']);
21252 fg.addClass('is-valid');
21260 var fg = this.el.findParent('.form-group', false, true);
21261 if (Roo.bootstrap.version == 3) {
21262 fg.removeClass([this.invalidClass, this.validClass]);
21263 fg.addClass(this.validClass);
21265 fg.removeClass(['is-valid', 'is-invalid']);
21266 fg.addClass('is-valid');
21271 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21277 for(var i in group){
21278 var fg = group[i].el.findParent('.form-group', false, true);
21279 if (Roo.bootstrap.version == 3) {
21280 fg.removeClass([this.invalidClass, this.validClass]);
21281 fg.addClass(this.validClass);
21283 fg.removeClass(['is-valid', 'is-invalid']);
21284 fg.addClass('is-valid');
21290 * Mark this field as invalid
21291 * @param {String} msg The validation message
21293 markInvalid : function(msg)
21295 if(this.allowBlank){
21301 this.fireEvent('invalid', this, msg);
21303 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21306 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21310 label.markInvalid();
21313 if(this.inputType == 'radio'){
21315 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21316 var fg = e.findParent('.form-group', false, true);
21317 if (Roo.bootstrap.version == 3) {
21318 fg.removeClass([_this.invalidClass, _this.validClass]);
21319 fg.addClass(_this.invalidClass);
21321 fg.removeClass(['is-invalid', 'is-valid']);
21322 fg.addClass('is-invalid');
21330 var fg = this.el.findParent('.form-group', false, true);
21331 if (Roo.bootstrap.version == 3) {
21332 fg.removeClass([_this.invalidClass, _this.validClass]);
21333 fg.addClass(_this.invalidClass);
21335 fg.removeClass(['is-invalid', 'is-valid']);
21336 fg.addClass('is-invalid');
21341 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21347 for(var i in group){
21348 var fg = group[i].el.findParent('.form-group', false, true);
21349 if (Roo.bootstrap.version == 3) {
21350 fg.removeClass([_this.invalidClass, _this.validClass]);
21351 fg.addClass(_this.invalidClass);
21353 fg.removeClass(['is-invalid', 'is-valid']);
21354 fg.addClass('is-invalid');
21360 clearInvalid : function()
21362 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21364 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21366 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21368 if (label && label.iconEl) {
21369 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21370 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21374 disable : function()
21376 if(this.inputType != 'radio'){
21377 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21384 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21385 _this.getActionEl().addClass(this.disabledClass);
21386 e.dom.disabled = true;
21390 this.disabled = true;
21391 this.fireEvent("disable", this);
21395 enable : function()
21397 if(this.inputType != 'radio'){
21398 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21405 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21406 _this.getActionEl().removeClass(this.disabledClass);
21407 e.dom.disabled = false;
21411 this.disabled = false;
21412 this.fireEvent("enable", this);
21416 setBoxLabel : function(v)
21421 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21427 Roo.apply(Roo.bootstrap.CheckBox, {
21432 * register a CheckBox Group
21433 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21435 register : function(checkbox)
21437 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21438 this.groups[checkbox.groupId] = {};
21441 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21445 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21449 * fetch a CheckBox Group based on the group ID
21450 * @param {string} the group ID
21451 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21453 get: function(groupId) {
21454 if (typeof(this.groups[groupId]) == 'undefined') {
21458 return this.groups[groupId] ;
21471 * @class Roo.bootstrap.Radio
21472 * @extends Roo.bootstrap.Component
21473 * Bootstrap Radio class
21474 * @cfg {String} boxLabel - the label associated
21475 * @cfg {String} value - the value of radio
21478 * Create a new Radio
21479 * @param {Object} config The config object
21481 Roo.bootstrap.Radio = function(config){
21482 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21486 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21492 getAutoCreate : function()
21496 cls : 'form-group radio',
21501 html : this.boxLabel
21509 initEvents : function()
21511 this.parent().register(this);
21513 this.el.on('click', this.onClick, this);
21517 onClick : function(e)
21519 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21520 this.setChecked(true);
21524 setChecked : function(state, suppressEvent)
21526 this.parent().setValue(this.value, suppressEvent);
21530 setBoxLabel : function(v)
21535 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21550 * @class Roo.bootstrap.SecurePass
21551 * @extends Roo.bootstrap.Input
21552 * Bootstrap SecurePass class
21556 * Create a new SecurePass
21557 * @param {Object} config The config object
21560 Roo.bootstrap.SecurePass = function (config) {
21561 // these go here, so the translation tool can replace them..
21563 PwdEmpty: "Please type a password, and then retype it to confirm.",
21564 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21565 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21566 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21567 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21568 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21569 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21570 TooWeak: "Your password is Too Weak."
21572 this.meterLabel = "Password strength:";
21573 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21574 this.meterClass = [
21575 "roo-password-meter-tooweak",
21576 "roo-password-meter-weak",
21577 "roo-password-meter-medium",
21578 "roo-password-meter-strong",
21579 "roo-password-meter-grey"
21584 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21587 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21589 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21591 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21592 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21593 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21594 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21595 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21596 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21597 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21607 * @cfg {String/Object} Label for the strength meter (defaults to
21608 * 'Password strength:')
21613 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21614 * ['Weak', 'Medium', 'Strong'])
21617 pwdStrengths: false,
21630 initEvents: function ()
21632 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21634 if (this.el.is('input[type=password]') && Roo.isSafari) {
21635 this.el.on('keydown', this.SafariOnKeyDown, this);
21638 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21641 onRender: function (ct, position)
21643 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21644 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21645 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21647 this.trigger.createChild({
21652 cls: 'roo-password-meter-grey col-xs-12',
21655 //width: this.meterWidth + 'px'
21659 cls: 'roo-password-meter-text'
21665 if (this.hideTrigger) {
21666 this.trigger.setDisplayed(false);
21668 this.setSize(this.width || '', this.height || '');
21671 onDestroy: function ()
21673 if (this.trigger) {
21674 this.trigger.removeAllListeners();
21675 this.trigger.remove();
21678 this.wrap.remove();
21680 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21683 checkStrength: function ()
21685 var pwd = this.inputEl().getValue();
21686 if (pwd == this._lastPwd) {
21691 if (this.ClientSideStrongPassword(pwd)) {
21693 } else if (this.ClientSideMediumPassword(pwd)) {
21695 } else if (this.ClientSideWeakPassword(pwd)) {
21701 Roo.log('strength1: ' + strength);
21703 //var pm = this.trigger.child('div/div/div').dom;
21704 var pm = this.trigger.child('div/div');
21705 pm.removeClass(this.meterClass);
21706 pm.addClass(this.meterClass[strength]);
21709 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21711 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21713 this._lastPwd = pwd;
21717 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21719 this._lastPwd = '';
21721 var pm = this.trigger.child('div/div');
21722 pm.removeClass(this.meterClass);
21723 pm.addClass('roo-password-meter-grey');
21726 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21729 this.inputEl().dom.type='password';
21732 validateValue: function (value)
21735 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21738 if (value.length == 0) {
21739 if (this.allowBlank) {
21740 this.clearInvalid();
21744 this.markInvalid(this.errors.PwdEmpty);
21745 this.errorMsg = this.errors.PwdEmpty;
21753 if ('[\x21-\x7e]*'.match(value)) {
21754 this.markInvalid(this.errors.PwdBadChar);
21755 this.errorMsg = this.errors.PwdBadChar;
21758 if (value.length < 6) {
21759 this.markInvalid(this.errors.PwdShort);
21760 this.errorMsg = this.errors.PwdShort;
21763 if (value.length > 16) {
21764 this.markInvalid(this.errors.PwdLong);
21765 this.errorMsg = this.errors.PwdLong;
21769 if (this.ClientSideStrongPassword(value)) {
21771 } else if (this.ClientSideMediumPassword(value)) {
21773 } else if (this.ClientSideWeakPassword(value)) {
21780 if (strength < 2) {
21781 //this.markInvalid(this.errors.TooWeak);
21782 this.errorMsg = this.errors.TooWeak;
21787 console.log('strength2: ' + strength);
21789 //var pm = this.trigger.child('div/div/div').dom;
21791 var pm = this.trigger.child('div/div');
21792 pm.removeClass(this.meterClass);
21793 pm.addClass(this.meterClass[strength]);
21795 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21797 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21799 this.errorMsg = '';
21803 CharacterSetChecks: function (type)
21806 this.fResult = false;
21809 isctype: function (character, type)
21812 case this.kCapitalLetter:
21813 if (character >= 'A' && character <= 'Z') {
21818 case this.kSmallLetter:
21819 if (character >= 'a' && character <= 'z') {
21825 if (character >= '0' && character <= '9') {
21830 case this.kPunctuation:
21831 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21842 IsLongEnough: function (pwd, size)
21844 return !(pwd == null || isNaN(size) || pwd.length < size);
21847 SpansEnoughCharacterSets: function (word, nb)
21849 if (!this.IsLongEnough(word, nb))
21854 var characterSetChecks = new Array(
21855 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21856 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21859 for (var index = 0; index < word.length; ++index) {
21860 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21861 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21862 characterSetChecks[nCharSet].fResult = true;
21869 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21870 if (characterSetChecks[nCharSet].fResult) {
21875 if (nCharSets < nb) {
21881 ClientSideStrongPassword: function (pwd)
21883 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21886 ClientSideMediumPassword: function (pwd)
21888 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21891 ClientSideWeakPassword: function (pwd)
21893 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21896 })//<script type="text/javascript">
21899 * Based Ext JS Library 1.1.1
21900 * Copyright(c) 2006-2007, Ext JS, LLC.
21906 * @class Roo.HtmlEditorCore
21907 * @extends Roo.Component
21908 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21910 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21913 Roo.HtmlEditorCore = function(config){
21916 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21921 * @event initialize
21922 * Fires when the editor is fully initialized (including the iframe)
21923 * @param {Roo.HtmlEditorCore} this
21928 * Fires when the editor is first receives the focus. Any insertion must wait
21929 * until after this event.
21930 * @param {Roo.HtmlEditorCore} this
21934 * @event beforesync
21935 * Fires before the textarea is updated with content from the editor iframe. Return false
21936 * to cancel the sync.
21937 * @param {Roo.HtmlEditorCore} this
21938 * @param {String} html
21942 * @event beforepush
21943 * Fires before the iframe editor is updated with content from the textarea. Return false
21944 * to cancel the push.
21945 * @param {Roo.HtmlEditorCore} this
21946 * @param {String} html
21951 * Fires when the textarea is updated with content from the editor iframe.
21952 * @param {Roo.HtmlEditorCore} this
21953 * @param {String} html
21958 * Fires when the iframe editor is updated with content from the textarea.
21959 * @param {Roo.HtmlEditorCore} this
21960 * @param {String} html
21965 * @event editorevent
21966 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21967 * @param {Roo.HtmlEditorCore} this
21973 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21975 // defaults : white / black...
21976 this.applyBlacklists();
21983 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21987 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21993 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21998 * @cfg {Number} height (in pixels)
22002 * @cfg {Number} width (in pixels)
22007 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22010 stylesheets: false,
22015 // private properties
22016 validationEvent : false,
22018 initialized : false,
22020 sourceEditMode : false,
22021 onFocus : Roo.emptyFn,
22023 hideMode:'offsets',
22027 // blacklist + whitelisted elements..
22034 * Protected method that will not generally be called directly. It
22035 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22036 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22038 getDocMarkup : function(){
22042 // inherit styels from page...??
22043 if (this.stylesheets === false) {
22045 Roo.get(document.head).select('style').each(function(node) {
22046 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22049 Roo.get(document.head).select('link').each(function(node) {
22050 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22053 } else if (!this.stylesheets.length) {
22055 st = '<style type="text/css">' +
22056 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22059 st = '<style type="text/css">' +
22064 st += '<style type="text/css">' +
22065 'IMG { cursor: pointer } ' +
22068 var cls = 'roo-htmleditor-body';
22070 if(this.bodyCls.length){
22071 cls += ' ' + this.bodyCls;
22074 return '<html><head>' + st +
22075 //<style type="text/css">' +
22076 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22078 ' </head><body class="' + cls + '"></body></html>';
22082 onRender : function(ct, position)
22085 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22086 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22089 this.el.dom.style.border = '0 none';
22090 this.el.dom.setAttribute('tabIndex', -1);
22091 this.el.addClass('x-hidden hide');
22095 if(Roo.isIE){ // fix IE 1px bogus margin
22096 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22100 this.frameId = Roo.id();
22104 var iframe = this.owner.wrap.createChild({
22106 cls: 'form-control', // bootstrap..
22108 name: this.frameId,
22109 frameBorder : 'no',
22110 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22115 this.iframe = iframe.dom;
22117 this.assignDocWin();
22119 this.doc.designMode = 'on';
22122 this.doc.write(this.getDocMarkup());
22126 var task = { // must defer to wait for browser to be ready
22128 //console.log("run task?" + this.doc.readyState);
22129 this.assignDocWin();
22130 if(this.doc.body || this.doc.readyState == 'complete'){
22132 this.doc.designMode="on";
22136 Roo.TaskMgr.stop(task);
22137 this.initEditor.defer(10, this);
22144 Roo.TaskMgr.start(task);
22149 onResize : function(w, h)
22151 Roo.log('resize: ' +w + ',' + h );
22152 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22156 if(typeof w == 'number'){
22158 this.iframe.style.width = w + 'px';
22160 if(typeof h == 'number'){
22162 this.iframe.style.height = h + 'px';
22164 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22171 * Toggles the editor between standard and source edit mode.
22172 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22174 toggleSourceEdit : function(sourceEditMode){
22176 this.sourceEditMode = sourceEditMode === true;
22178 if(this.sourceEditMode){
22180 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22183 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22184 //this.iframe.className = '';
22187 //this.setSize(this.owner.wrap.getSize());
22188 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22195 * Protected method that will not generally be called directly. If you need/want
22196 * custom HTML cleanup, this is the method you should override.
22197 * @param {String} html The HTML to be cleaned
22198 * return {String} The cleaned HTML
22200 cleanHtml : function(html){
22201 html = String(html);
22202 if(html.length > 5){
22203 if(Roo.isSafari){ // strip safari nonsense
22204 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22207 if(html == ' '){
22214 * HTML Editor -> Textarea
22215 * Protected method that will not generally be called directly. Syncs the contents
22216 * of the editor iframe with the textarea.
22218 syncValue : function(){
22219 if(this.initialized){
22220 var bd = (this.doc.body || this.doc.documentElement);
22221 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22222 var html = bd.innerHTML;
22224 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22225 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22227 html = '<div style="'+m[0]+'">' + html + '</div>';
22230 html = this.cleanHtml(html);
22231 // fix up the special chars.. normaly like back quotes in word...
22232 // however we do not want to do this with chinese..
22233 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22234 var cc = b.charCodeAt();
22236 (cc >= 0x4E00 && cc < 0xA000 ) ||
22237 (cc >= 0x3400 && cc < 0x4E00 ) ||
22238 (cc >= 0xf900 && cc < 0xfb00 )
22244 if(this.owner.fireEvent('beforesync', this, html) !== false){
22245 this.el.dom.value = html;
22246 this.owner.fireEvent('sync', this, html);
22252 * Protected method that will not generally be called directly. Pushes the value of the textarea
22253 * into the iframe editor.
22255 pushValue : function(){
22256 if(this.initialized){
22257 var v = this.el.dom.value.trim();
22259 // if(v.length < 1){
22263 if(this.owner.fireEvent('beforepush', this, v) !== false){
22264 var d = (this.doc.body || this.doc.documentElement);
22266 this.cleanUpPaste();
22267 this.el.dom.value = d.innerHTML;
22268 this.owner.fireEvent('push', this, v);
22274 deferFocus : function(){
22275 this.focus.defer(10, this);
22279 focus : function(){
22280 if(this.win && !this.sourceEditMode){
22287 assignDocWin: function()
22289 var iframe = this.iframe;
22292 this.doc = iframe.contentWindow.document;
22293 this.win = iframe.contentWindow;
22295 // if (!Roo.get(this.frameId)) {
22298 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22299 // this.win = Roo.get(this.frameId).dom.contentWindow;
22301 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22305 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22306 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22311 initEditor : function(){
22312 //console.log("INIT EDITOR");
22313 this.assignDocWin();
22317 this.doc.designMode="on";
22319 this.doc.write(this.getDocMarkup());
22322 var dbody = (this.doc.body || this.doc.documentElement);
22323 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22324 // this copies styles from the containing element into thsi one..
22325 // not sure why we need all of this..
22326 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22328 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22329 //ss['background-attachment'] = 'fixed'; // w3c
22330 dbody.bgProperties = 'fixed'; // ie
22331 //Roo.DomHelper.applyStyles(dbody, ss);
22332 Roo.EventManager.on(this.doc, {
22333 //'mousedown': this.onEditorEvent,
22334 'mouseup': this.onEditorEvent,
22335 'dblclick': this.onEditorEvent,
22336 'click': this.onEditorEvent,
22337 'keyup': this.onEditorEvent,
22342 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22344 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22345 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22347 this.initialized = true;
22349 this.owner.fireEvent('initialize', this);
22354 onDestroy : function(){
22360 //for (var i =0; i < this.toolbars.length;i++) {
22361 // // fixme - ask toolbars for heights?
22362 // this.toolbars[i].onDestroy();
22365 //this.wrap.dom.innerHTML = '';
22366 //this.wrap.remove();
22371 onFirstFocus : function(){
22373 this.assignDocWin();
22376 this.activated = true;
22379 if(Roo.isGecko){ // prevent silly gecko errors
22381 var s = this.win.getSelection();
22382 if(!s.focusNode || s.focusNode.nodeType != 3){
22383 var r = s.getRangeAt(0);
22384 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22389 this.execCmd('useCSS', true);
22390 this.execCmd('styleWithCSS', false);
22393 this.owner.fireEvent('activate', this);
22397 adjustFont: function(btn){
22398 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22399 //if(Roo.isSafari){ // safari
22402 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22403 if(Roo.isSafari){ // safari
22404 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22405 v = (v < 10) ? 10 : v;
22406 v = (v > 48) ? 48 : v;
22407 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22412 v = Math.max(1, v+adjust);
22414 this.execCmd('FontSize', v );
22417 onEditorEvent : function(e)
22419 this.owner.fireEvent('editorevent', this, e);
22420 // this.updateToolbar();
22421 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22424 insertTag : function(tg)
22426 // could be a bit smarter... -> wrap the current selected tRoo..
22427 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22429 range = this.createRange(this.getSelection());
22430 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22431 wrappingNode.appendChild(range.extractContents());
22432 range.insertNode(wrappingNode);
22439 this.execCmd("formatblock", tg);
22443 insertText : function(txt)
22447 var range = this.createRange();
22448 range.deleteContents();
22449 //alert(Sender.getAttribute('label'));
22451 range.insertNode(this.doc.createTextNode(txt));
22457 * Executes a Midas editor command on the editor document and performs necessary focus and
22458 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22459 * @param {String} cmd The Midas command
22460 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22462 relayCmd : function(cmd, value){
22464 this.execCmd(cmd, value);
22465 this.owner.fireEvent('editorevent', this);
22466 //this.updateToolbar();
22467 this.owner.deferFocus();
22471 * Executes a Midas editor command directly on the editor document.
22472 * For visual commands, you should use {@link #relayCmd} instead.
22473 * <b>This should only be called after the editor is initialized.</b>
22474 * @param {String} cmd The Midas command
22475 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22477 execCmd : function(cmd, value){
22478 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22485 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22487 * @param {String} text | dom node..
22489 insertAtCursor : function(text)
22492 if(!this.activated){
22498 var r = this.doc.selection.createRange();
22509 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22513 // from jquery ui (MIT licenced)
22515 var win = this.win;
22517 if (win.getSelection && win.getSelection().getRangeAt) {
22518 range = win.getSelection().getRangeAt(0);
22519 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22520 range.insertNode(node);
22521 } else if (win.document.selection && win.document.selection.createRange) {
22522 // no firefox support
22523 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22524 win.document.selection.createRange().pasteHTML(txt);
22526 // no firefox support
22527 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22528 this.execCmd('InsertHTML', txt);
22537 mozKeyPress : function(e){
22539 var c = e.getCharCode(), cmd;
22542 c = String.fromCharCode(c).toLowerCase();
22556 this.cleanUpPaste.defer(100, this);
22564 e.preventDefault();
22572 fixKeys : function(){ // load time branching for fastest keydown performance
22574 return function(e){
22575 var k = e.getKey(), r;
22578 r = this.doc.selection.createRange();
22581 r.pasteHTML('    ');
22588 r = this.doc.selection.createRange();
22590 var target = r.parentElement();
22591 if(!target || target.tagName.toLowerCase() != 'li'){
22593 r.pasteHTML('<br />');
22599 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22600 this.cleanUpPaste.defer(100, this);
22606 }else if(Roo.isOpera){
22607 return function(e){
22608 var k = e.getKey();
22612 this.execCmd('InsertHTML','    ');
22615 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22616 this.cleanUpPaste.defer(100, this);
22621 }else if(Roo.isSafari){
22622 return function(e){
22623 var k = e.getKey();
22627 this.execCmd('InsertText','\t');
22631 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22632 this.cleanUpPaste.defer(100, this);
22640 getAllAncestors: function()
22642 var p = this.getSelectedNode();
22645 a.push(p); // push blank onto stack..
22646 p = this.getParentElement();
22650 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22654 a.push(this.doc.body);
22658 lastSelNode : false,
22661 getSelection : function()
22663 this.assignDocWin();
22664 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22667 getSelectedNode: function()
22669 // this may only work on Gecko!!!
22671 // should we cache this!!!!
22676 var range = this.createRange(this.getSelection()).cloneRange();
22679 var parent = range.parentElement();
22681 var testRange = range.duplicate();
22682 testRange.moveToElementText(parent);
22683 if (testRange.inRange(range)) {
22686 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22689 parent = parent.parentElement;
22694 // is ancestor a text element.
22695 var ac = range.commonAncestorContainer;
22696 if (ac.nodeType == 3) {
22697 ac = ac.parentNode;
22700 var ar = ac.childNodes;
22703 var other_nodes = [];
22704 var has_other_nodes = false;
22705 for (var i=0;i<ar.length;i++) {
22706 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22709 // fullly contained node.
22711 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22716 // probably selected..
22717 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22718 other_nodes.push(ar[i]);
22722 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22727 has_other_nodes = true;
22729 if (!nodes.length && other_nodes.length) {
22730 nodes= other_nodes;
22732 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22738 createRange: function(sel)
22740 // this has strange effects when using with
22741 // top toolbar - not sure if it's a great idea.
22742 //this.editor.contentWindow.focus();
22743 if (typeof sel != "undefined") {
22745 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22747 return this.doc.createRange();
22750 return this.doc.createRange();
22753 getParentElement: function()
22756 this.assignDocWin();
22757 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22759 var range = this.createRange(sel);
22762 var p = range.commonAncestorContainer;
22763 while (p.nodeType == 3) { // text node
22774 * Range intersection.. the hard stuff...
22778 * [ -- selected range --- ]
22782 * if end is before start or hits it. fail.
22783 * if start is after end or hits it fail.
22785 * if either hits (but other is outside. - then it's not
22791 // @see http://www.thismuchiknow.co.uk/?p=64.
22792 rangeIntersectsNode : function(range, node)
22794 var nodeRange = node.ownerDocument.createRange();
22796 nodeRange.selectNode(node);
22798 nodeRange.selectNodeContents(node);
22801 var rangeStartRange = range.cloneRange();
22802 rangeStartRange.collapse(true);
22804 var rangeEndRange = range.cloneRange();
22805 rangeEndRange.collapse(false);
22807 var nodeStartRange = nodeRange.cloneRange();
22808 nodeStartRange.collapse(true);
22810 var nodeEndRange = nodeRange.cloneRange();
22811 nodeEndRange.collapse(false);
22813 return rangeStartRange.compareBoundaryPoints(
22814 Range.START_TO_START, nodeEndRange) == -1 &&
22815 rangeEndRange.compareBoundaryPoints(
22816 Range.START_TO_START, nodeStartRange) == 1;
22820 rangeCompareNode : function(range, node)
22822 var nodeRange = node.ownerDocument.createRange();
22824 nodeRange.selectNode(node);
22826 nodeRange.selectNodeContents(node);
22830 range.collapse(true);
22832 nodeRange.collapse(true);
22834 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22835 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22837 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22839 var nodeIsBefore = ss == 1;
22840 var nodeIsAfter = ee == -1;
22842 if (nodeIsBefore && nodeIsAfter) {
22845 if (!nodeIsBefore && nodeIsAfter) {
22846 return 1; //right trailed.
22849 if (nodeIsBefore && !nodeIsAfter) {
22850 return 2; // left trailed.
22856 // private? - in a new class?
22857 cleanUpPaste : function()
22859 // cleans up the whole document..
22860 Roo.log('cleanuppaste');
22862 this.cleanUpChildren(this.doc.body);
22863 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22864 if (clean != this.doc.body.innerHTML) {
22865 this.doc.body.innerHTML = clean;
22870 cleanWordChars : function(input) {// change the chars to hex code
22871 var he = Roo.HtmlEditorCore;
22873 var output = input;
22874 Roo.each(he.swapCodes, function(sw) {
22875 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22877 output = output.replace(swapper, sw[1]);
22884 cleanUpChildren : function (n)
22886 if (!n.childNodes.length) {
22889 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22890 this.cleanUpChild(n.childNodes[i]);
22897 cleanUpChild : function (node)
22900 //console.log(node);
22901 if (node.nodeName == "#text") {
22902 // clean up silly Windows -- stuff?
22905 if (node.nodeName == "#comment") {
22906 node.parentNode.removeChild(node);
22907 // clean up silly Windows -- stuff?
22910 var lcname = node.tagName.toLowerCase();
22911 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22912 // whitelist of tags..
22914 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22916 node.parentNode.removeChild(node);
22921 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22923 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22924 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22926 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22927 // remove_keep_children = true;
22930 if (remove_keep_children) {
22931 this.cleanUpChildren(node);
22932 // inserts everything just before this node...
22933 while (node.childNodes.length) {
22934 var cn = node.childNodes[0];
22935 node.removeChild(cn);
22936 node.parentNode.insertBefore(cn, node);
22938 node.parentNode.removeChild(node);
22942 if (!node.attributes || !node.attributes.length) {
22943 this.cleanUpChildren(node);
22947 function cleanAttr(n,v)
22950 if (v.match(/^\./) || v.match(/^\//)) {
22953 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22956 if (v.match(/^#/)) {
22959 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22960 node.removeAttribute(n);
22964 var cwhite = this.cwhite;
22965 var cblack = this.cblack;
22967 function cleanStyle(n,v)
22969 if (v.match(/expression/)) { //XSS?? should we even bother..
22970 node.removeAttribute(n);
22974 var parts = v.split(/;/);
22977 Roo.each(parts, function(p) {
22978 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22982 var l = p.split(':').shift().replace(/\s+/g,'');
22983 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22985 if ( cwhite.length && cblack.indexOf(l) > -1) {
22986 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22987 //node.removeAttribute(n);
22991 // only allow 'c whitelisted system attributes'
22992 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22993 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22994 //node.removeAttribute(n);
23004 if (clean.length) {
23005 node.setAttribute(n, clean.join(';'));
23007 node.removeAttribute(n);
23013 for (var i = node.attributes.length-1; i > -1 ; i--) {
23014 var a = node.attributes[i];
23017 if (a.name.toLowerCase().substr(0,2)=='on') {
23018 node.removeAttribute(a.name);
23021 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23022 node.removeAttribute(a.name);
23025 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23026 cleanAttr(a.name,a.value); // fixme..
23029 if (a.name == 'style') {
23030 cleanStyle(a.name,a.value);
23033 /// clean up MS crap..
23034 // tecnically this should be a list of valid class'es..
23037 if (a.name == 'class') {
23038 if (a.value.match(/^Mso/)) {
23039 node.className = '';
23042 if (a.value.match(/^body$/)) {
23043 node.className = '';
23054 this.cleanUpChildren(node);
23060 * Clean up MS wordisms...
23062 cleanWord : function(node)
23067 this.cleanWord(this.doc.body);
23070 if (node.nodeName == "#text") {
23071 // clean up silly Windows -- stuff?
23074 if (node.nodeName == "#comment") {
23075 node.parentNode.removeChild(node);
23076 // clean up silly Windows -- stuff?
23080 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23081 node.parentNode.removeChild(node);
23085 // remove - but keep children..
23086 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23087 while (node.childNodes.length) {
23088 var cn = node.childNodes[0];
23089 node.removeChild(cn);
23090 node.parentNode.insertBefore(cn, node);
23092 node.parentNode.removeChild(node);
23093 this.iterateChildren(node, this.cleanWord);
23097 if (node.className.length) {
23099 var cn = node.className.split(/\W+/);
23101 Roo.each(cn, function(cls) {
23102 if (cls.match(/Mso[a-zA-Z]+/)) {
23107 node.className = cna.length ? cna.join(' ') : '';
23109 node.removeAttribute("class");
23113 if (node.hasAttribute("lang")) {
23114 node.removeAttribute("lang");
23117 if (node.hasAttribute("style")) {
23119 var styles = node.getAttribute("style").split(";");
23121 Roo.each(styles, function(s) {
23122 if (!s.match(/:/)) {
23125 var kv = s.split(":");
23126 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23129 // what ever is left... we allow.
23132 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23133 if (!nstyle.length) {
23134 node.removeAttribute('style');
23137 this.iterateChildren(node, this.cleanWord);
23143 * iterateChildren of a Node, calling fn each time, using this as the scole..
23144 * @param {DomNode} node node to iterate children of.
23145 * @param {Function} fn method of this class to call on each item.
23147 iterateChildren : function(node, fn)
23149 if (!node.childNodes.length) {
23152 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23153 fn.call(this, node.childNodes[i])
23159 * cleanTableWidths.
23161 * Quite often pasting from word etc.. results in tables with column and widths.
23162 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23165 cleanTableWidths : function(node)
23170 this.cleanTableWidths(this.doc.body);
23175 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23178 Roo.log(node.tagName);
23179 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23180 this.iterateChildren(node, this.cleanTableWidths);
23183 if (node.hasAttribute('width')) {
23184 node.removeAttribute('width');
23188 if (node.hasAttribute("style")) {
23191 var styles = node.getAttribute("style").split(";");
23193 Roo.each(styles, function(s) {
23194 if (!s.match(/:/)) {
23197 var kv = s.split(":");
23198 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23201 // what ever is left... we allow.
23204 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23205 if (!nstyle.length) {
23206 node.removeAttribute('style');
23210 this.iterateChildren(node, this.cleanTableWidths);
23218 domToHTML : function(currentElement, depth, nopadtext) {
23220 depth = depth || 0;
23221 nopadtext = nopadtext || false;
23223 if (!currentElement) {
23224 return this.domToHTML(this.doc.body);
23227 //Roo.log(currentElement);
23229 var allText = false;
23230 var nodeName = currentElement.nodeName;
23231 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23233 if (nodeName == '#text') {
23235 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23240 if (nodeName != 'BODY') {
23243 // Prints the node tagName, such as <A>, <IMG>, etc
23246 for(i = 0; i < currentElement.attributes.length;i++) {
23248 var aname = currentElement.attributes.item(i).name;
23249 if (!currentElement.attributes.item(i).value.length) {
23252 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23255 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23264 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23267 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23272 // Traverse the tree
23274 var currentElementChild = currentElement.childNodes.item(i);
23275 var allText = true;
23276 var innerHTML = '';
23278 while (currentElementChild) {
23279 // Formatting code (indent the tree so it looks nice on the screen)
23280 var nopad = nopadtext;
23281 if (lastnode == 'SPAN') {
23285 if (currentElementChild.nodeName == '#text') {
23286 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23287 toadd = nopadtext ? toadd : toadd.trim();
23288 if (!nopad && toadd.length > 80) {
23289 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23291 innerHTML += toadd;
23294 currentElementChild = currentElement.childNodes.item(i);
23300 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23302 // Recursively traverse the tree structure of the child node
23303 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23304 lastnode = currentElementChild.nodeName;
23306 currentElementChild=currentElement.childNodes.item(i);
23312 // The remaining code is mostly for formatting the tree
23313 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23318 ret+= "</"+tagName+">";
23324 applyBlacklists : function()
23326 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23327 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23331 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23332 if (b.indexOf(tag) > -1) {
23335 this.white.push(tag);
23339 Roo.each(w, function(tag) {
23340 if (b.indexOf(tag) > -1) {
23343 if (this.white.indexOf(tag) > -1) {
23346 this.white.push(tag);
23351 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23352 if (w.indexOf(tag) > -1) {
23355 this.black.push(tag);
23359 Roo.each(b, function(tag) {
23360 if (w.indexOf(tag) > -1) {
23363 if (this.black.indexOf(tag) > -1) {
23366 this.black.push(tag);
23371 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23372 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23376 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23377 if (b.indexOf(tag) > -1) {
23380 this.cwhite.push(tag);
23384 Roo.each(w, function(tag) {
23385 if (b.indexOf(tag) > -1) {
23388 if (this.cwhite.indexOf(tag) > -1) {
23391 this.cwhite.push(tag);
23396 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23397 if (w.indexOf(tag) > -1) {
23400 this.cblack.push(tag);
23404 Roo.each(b, function(tag) {
23405 if (w.indexOf(tag) > -1) {
23408 if (this.cblack.indexOf(tag) > -1) {
23411 this.cblack.push(tag);
23416 setStylesheets : function(stylesheets)
23418 if(typeof(stylesheets) == 'string'){
23419 Roo.get(this.iframe.contentDocument.head).createChild({
23421 rel : 'stylesheet',
23430 Roo.each(stylesheets, function(s) {
23435 Roo.get(_this.iframe.contentDocument.head).createChild({
23437 rel : 'stylesheet',
23446 removeStylesheets : function()
23450 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23455 setStyle : function(style)
23457 Roo.get(this.iframe.contentDocument.head).createChild({
23466 // hide stuff that is not compatible
23480 * @event specialkey
23484 * @cfg {String} fieldClass @hide
23487 * @cfg {String} focusClass @hide
23490 * @cfg {String} autoCreate @hide
23493 * @cfg {String} inputType @hide
23496 * @cfg {String} invalidClass @hide
23499 * @cfg {String} invalidText @hide
23502 * @cfg {String} msgFx @hide
23505 * @cfg {String} validateOnBlur @hide
23509 Roo.HtmlEditorCore.white = [
23510 'area', 'br', 'img', 'input', 'hr', 'wbr',
23512 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23513 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23514 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23515 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23516 'table', 'ul', 'xmp',
23518 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23521 'dir', 'menu', 'ol', 'ul', 'dl',
23527 Roo.HtmlEditorCore.black = [
23528 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23530 'base', 'basefont', 'bgsound', 'blink', 'body',
23531 'frame', 'frameset', 'head', 'html', 'ilayer',
23532 'iframe', 'layer', 'link', 'meta', 'object',
23533 'script', 'style' ,'title', 'xml' // clean later..
23535 Roo.HtmlEditorCore.clean = [
23536 'script', 'style', 'title', 'xml'
23538 Roo.HtmlEditorCore.remove = [
23543 Roo.HtmlEditorCore.ablack = [
23547 Roo.HtmlEditorCore.aclean = [
23548 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23552 Roo.HtmlEditorCore.pwhite= [
23553 'http', 'https', 'mailto'
23556 // white listed style attributes.
23557 Roo.HtmlEditorCore.cwhite= [
23558 // 'text-align', /// default is to allow most things..
23564 // black listed style attributes.
23565 Roo.HtmlEditorCore.cblack= [
23566 // 'font-size' -- this can be set by the project
23570 Roo.HtmlEditorCore.swapCodes =[
23589 * @class Roo.bootstrap.HtmlEditor
23590 * @extends Roo.bootstrap.TextArea
23591 * Bootstrap HtmlEditor class
23594 * Create a new HtmlEditor
23595 * @param {Object} config The config object
23598 Roo.bootstrap.HtmlEditor = function(config){
23599 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23600 if (!this.toolbars) {
23601 this.toolbars = [];
23604 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23607 * @event initialize
23608 * Fires when the editor is fully initialized (including the iframe)
23609 * @param {HtmlEditor} this
23614 * Fires when the editor is first receives the focus. Any insertion must wait
23615 * until after this event.
23616 * @param {HtmlEditor} this
23620 * @event beforesync
23621 * Fires before the textarea is updated with content from the editor iframe. Return false
23622 * to cancel the sync.
23623 * @param {HtmlEditor} this
23624 * @param {String} html
23628 * @event beforepush
23629 * Fires before the iframe editor is updated with content from the textarea. Return false
23630 * to cancel the push.
23631 * @param {HtmlEditor} this
23632 * @param {String} html
23637 * Fires when the textarea is updated with content from the editor iframe.
23638 * @param {HtmlEditor} this
23639 * @param {String} html
23644 * Fires when the iframe editor is updated with content from the textarea.
23645 * @param {HtmlEditor} this
23646 * @param {String} html
23650 * @event editmodechange
23651 * Fires when the editor switches edit modes
23652 * @param {HtmlEditor} this
23653 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23655 editmodechange: true,
23657 * @event editorevent
23658 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23659 * @param {HtmlEditor} this
23663 * @event firstfocus
23664 * Fires when on first focus - needed by toolbars..
23665 * @param {HtmlEditor} this
23670 * Auto save the htmlEditor value as a file into Events
23671 * @param {HtmlEditor} this
23675 * @event savedpreview
23676 * preview the saved version of htmlEditor
23677 * @param {HtmlEditor} this
23684 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23688 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23693 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23698 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23703 * @cfg {Number} height (in pixels)
23707 * @cfg {Number} width (in pixels)
23712 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23715 stylesheets: false,
23720 // private properties
23721 validationEvent : false,
23723 initialized : false,
23726 onFocus : Roo.emptyFn,
23728 hideMode:'offsets',
23730 tbContainer : false,
23734 toolbarContainer :function() {
23735 return this.wrap.select('.x-html-editor-tb',true).first();
23739 * Protected method that will not generally be called directly. It
23740 * is called when the editor creates its toolbar. Override this method if you need to
23741 * add custom toolbar buttons.
23742 * @param {HtmlEditor} editor
23744 createToolbar : function(){
23745 Roo.log('renewing');
23746 Roo.log("create toolbars");
23748 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23749 this.toolbars[0].render(this.toolbarContainer());
23753 // if (!editor.toolbars || !editor.toolbars.length) {
23754 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23757 // for (var i =0 ; i < editor.toolbars.length;i++) {
23758 // editor.toolbars[i] = Roo.factory(
23759 // typeof(editor.toolbars[i]) == 'string' ?
23760 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23761 // Roo.bootstrap.HtmlEditor);
23762 // editor.toolbars[i].init(editor);
23768 onRender : function(ct, position)
23770 // Roo.log("Call onRender: " + this.xtype);
23772 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23774 this.wrap = this.inputEl().wrap({
23775 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23778 this.editorcore.onRender(ct, position);
23780 if (this.resizable) {
23781 this.resizeEl = new Roo.Resizable(this.wrap, {
23785 minHeight : this.height,
23786 height: this.height,
23787 handles : this.resizable,
23790 resize : function(r, w, h) {
23791 _t.onResize(w,h); // -something
23797 this.createToolbar(this);
23800 if(!this.width && this.resizable){
23801 this.setSize(this.wrap.getSize());
23803 if (this.resizeEl) {
23804 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23805 // should trigger onReize..
23811 onResize : function(w, h)
23813 Roo.log('resize: ' +w + ',' + h );
23814 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23818 if(this.inputEl() ){
23819 if(typeof w == 'number'){
23820 var aw = w - this.wrap.getFrameWidth('lr');
23821 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23824 if(typeof h == 'number'){
23825 var tbh = -11; // fixme it needs to tool bar size!
23826 for (var i =0; i < this.toolbars.length;i++) {
23827 // fixme - ask toolbars for heights?
23828 tbh += this.toolbars[i].el.getHeight();
23829 //if (this.toolbars[i].footer) {
23830 // tbh += this.toolbars[i].footer.el.getHeight();
23838 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23839 ah -= 5; // knock a few pixes off for look..
23840 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23844 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23845 this.editorcore.onResize(ew,eh);
23850 * Toggles the editor between standard and source edit mode.
23851 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23853 toggleSourceEdit : function(sourceEditMode)
23855 this.editorcore.toggleSourceEdit(sourceEditMode);
23857 if(this.editorcore.sourceEditMode){
23858 Roo.log('editor - showing textarea');
23861 // Roo.log(this.syncValue());
23863 this.inputEl().removeClass(['hide', 'x-hidden']);
23864 this.inputEl().dom.removeAttribute('tabIndex');
23865 this.inputEl().focus();
23867 Roo.log('editor - hiding textarea');
23869 // Roo.log(this.pushValue());
23872 this.inputEl().addClass(['hide', 'x-hidden']);
23873 this.inputEl().dom.setAttribute('tabIndex', -1);
23874 //this.deferFocus();
23877 if(this.resizable){
23878 this.setSize(this.wrap.getSize());
23881 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23884 // private (for BoxComponent)
23885 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23887 // private (for BoxComponent)
23888 getResizeEl : function(){
23892 // private (for BoxComponent)
23893 getPositionEl : function(){
23898 initEvents : function(){
23899 this.originalValue = this.getValue();
23903 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23906 // markInvalid : Roo.emptyFn,
23908 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23911 // clearInvalid : Roo.emptyFn,
23913 setValue : function(v){
23914 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23915 this.editorcore.pushValue();
23920 deferFocus : function(){
23921 this.focus.defer(10, this);
23925 focus : function(){
23926 this.editorcore.focus();
23932 onDestroy : function(){
23938 for (var i =0; i < this.toolbars.length;i++) {
23939 // fixme - ask toolbars for heights?
23940 this.toolbars[i].onDestroy();
23943 this.wrap.dom.innerHTML = '';
23944 this.wrap.remove();
23949 onFirstFocus : function(){
23950 //Roo.log("onFirstFocus");
23951 this.editorcore.onFirstFocus();
23952 for (var i =0; i < this.toolbars.length;i++) {
23953 this.toolbars[i].onFirstFocus();
23959 syncValue : function()
23961 this.editorcore.syncValue();
23964 pushValue : function()
23966 this.editorcore.pushValue();
23970 // hide stuff that is not compatible
23984 * @event specialkey
23988 * @cfg {String} fieldClass @hide
23991 * @cfg {String} focusClass @hide
23994 * @cfg {String} autoCreate @hide
23997 * @cfg {String} inputType @hide
24001 * @cfg {String} invalidText @hide
24004 * @cfg {String} msgFx @hide
24007 * @cfg {String} validateOnBlur @hide
24016 Roo.namespace('Roo.bootstrap.htmleditor');
24018 * @class Roo.bootstrap.HtmlEditorToolbar1
24023 new Roo.bootstrap.HtmlEditor({
24026 new Roo.bootstrap.HtmlEditorToolbar1({
24027 disable : { fonts: 1 , format: 1, ..., ... , ...],
24033 * @cfg {Object} disable List of elements to disable..
24034 * @cfg {Array} btns List of additional buttons.
24038 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24041 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24044 Roo.apply(this, config);
24046 // default disabled, based on 'good practice'..
24047 this.disable = this.disable || {};
24048 Roo.applyIf(this.disable, {
24051 specialElements : true
24053 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24055 this.editor = config.editor;
24056 this.editorcore = config.editor.editorcore;
24058 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24060 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24061 // dont call parent... till later.
24063 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24068 editorcore : false,
24073 "h1","h2","h3","h4","h5","h6",
24075 "abbr", "acronym", "address", "cite", "samp", "var",
24079 onRender : function(ct, position)
24081 // Roo.log("Call onRender: " + this.xtype);
24083 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24085 this.el.dom.style.marginBottom = '0';
24087 var editorcore = this.editorcore;
24088 var editor= this.editor;
24091 var btn = function(id,cmd , toggle, handler, html){
24093 var event = toggle ? 'toggle' : 'click';
24098 xns: Roo.bootstrap,
24102 enableToggle:toggle !== false,
24104 pressed : toggle ? false : null,
24107 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24108 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24114 // var cb_box = function...
24119 xns: Roo.bootstrap,
24124 xns: Roo.bootstrap,
24128 Roo.each(this.formats, function(f) {
24129 style.menu.items.push({
24131 xns: Roo.bootstrap,
24132 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24137 editorcore.insertTag(this.tagname);
24144 children.push(style);
24146 btn('bold',false,true);
24147 btn('italic',false,true);
24148 btn('align-left', 'justifyleft',true);
24149 btn('align-center', 'justifycenter',true);
24150 btn('align-right' , 'justifyright',true);
24151 btn('link', false, false, function(btn) {
24152 //Roo.log("create link?");
24153 var url = prompt(this.createLinkText, this.defaultLinkValue);
24154 if(url && url != 'http:/'+'/'){
24155 this.editorcore.relayCmd('createlink', url);
24158 btn('list','insertunorderedlist',true);
24159 btn('pencil', false,true, function(btn){
24161 this.toggleSourceEdit(btn.pressed);
24164 if (this.editor.btns.length > 0) {
24165 for (var i = 0; i<this.editor.btns.length; i++) {
24166 children.push(this.editor.btns[i]);
24174 xns: Roo.bootstrap,
24179 xns: Roo.bootstrap,
24184 cog.menu.items.push({
24186 xns: Roo.bootstrap,
24187 html : Clean styles,
24192 editorcore.insertTag(this.tagname);
24201 this.xtype = 'NavSimplebar';
24203 for(var i=0;i< children.length;i++) {
24205 this.buttons.add(this.addxtypeChild(children[i]));
24209 editor.on('editorevent', this.updateToolbar, this);
24211 onBtnClick : function(id)
24213 this.editorcore.relayCmd(id);
24214 this.editorcore.focus();
24218 * Protected method that will not generally be called directly. It triggers
24219 * a toolbar update by reading the markup state of the current selection in the editor.
24221 updateToolbar: function(){
24223 if(!this.editorcore.activated){
24224 this.editor.onFirstFocus(); // is this neeed?
24228 var btns = this.buttons;
24229 var doc = this.editorcore.doc;
24230 btns.get('bold').setActive(doc.queryCommandState('bold'));
24231 btns.get('italic').setActive(doc.queryCommandState('italic'));
24232 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24234 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24235 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24236 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24238 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24239 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24242 var ans = this.editorcore.getAllAncestors();
24243 if (this.formatCombo) {
24246 var store = this.formatCombo.store;
24247 this.formatCombo.setValue("");
24248 for (var i =0; i < ans.length;i++) {
24249 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24251 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24259 // hides menus... - so this cant be on a menu...
24260 Roo.bootstrap.MenuMgr.hideAll();
24262 Roo.bootstrap.MenuMgr.hideAll();
24263 //this.editorsyncValue();
24265 onFirstFocus: function() {
24266 this.buttons.each(function(item){
24270 toggleSourceEdit : function(sourceEditMode){
24273 if(sourceEditMode){
24274 Roo.log("disabling buttons");
24275 this.buttons.each( function(item){
24276 if(item.cmd != 'pencil'){
24282 Roo.log("enabling buttons");
24283 if(this.editorcore.initialized){
24284 this.buttons.each( function(item){
24290 Roo.log("calling toggole on editor");
24291 // tell the editor that it's been pressed..
24292 this.editor.toggleSourceEdit(sourceEditMode);
24302 * @class Roo.bootstrap.Table.AbstractSelectionModel
24303 * @extends Roo.util.Observable
24304 * Abstract base class for grid SelectionModels. It provides the interface that should be
24305 * implemented by descendant classes. This class should not be directly instantiated.
24308 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24309 this.locked = false;
24310 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24314 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24315 /** @ignore Called by the grid automatically. Do not call directly. */
24316 init : function(grid){
24322 * Locks the selections.
24325 this.locked = true;
24329 * Unlocks the selections.
24331 unlock : function(){
24332 this.locked = false;
24336 * Returns true if the selections are locked.
24337 * @return {Boolean}
24339 isLocked : function(){
24340 return this.locked;
24344 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24345 * @class Roo.bootstrap.Table.RowSelectionModel
24346 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24347 * It supports multiple selections and keyboard selection/navigation.
24349 * @param {Object} config
24352 Roo.bootstrap.Table.RowSelectionModel = function(config){
24353 Roo.apply(this, config);
24354 this.selections = new Roo.util.MixedCollection(false, function(o){
24359 this.lastActive = false;
24363 * @event selectionchange
24364 * Fires when the selection changes
24365 * @param {SelectionModel} this
24367 "selectionchange" : true,
24369 * @event afterselectionchange
24370 * Fires after the selection changes (eg. by key press or clicking)
24371 * @param {SelectionModel} this
24373 "afterselectionchange" : true,
24375 * @event beforerowselect
24376 * Fires when a row is selected being selected, return false to cancel.
24377 * @param {SelectionModel} this
24378 * @param {Number} rowIndex The selected index
24379 * @param {Boolean} keepExisting False if other selections will be cleared
24381 "beforerowselect" : true,
24384 * Fires when a row is selected.
24385 * @param {SelectionModel} this
24386 * @param {Number} rowIndex The selected index
24387 * @param {Roo.data.Record} r The record
24389 "rowselect" : true,
24391 * @event rowdeselect
24392 * Fires when a row is deselected.
24393 * @param {SelectionModel} this
24394 * @param {Number} rowIndex The selected index
24396 "rowdeselect" : true
24398 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24399 this.locked = false;
24402 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24404 * @cfg {Boolean} singleSelect
24405 * True to allow selection of only one row at a time (defaults to false)
24407 singleSelect : false,
24410 initEvents : function()
24413 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24414 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24415 //}else{ // allow click to work like normal
24416 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24418 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24419 this.grid.on("rowclick", this.handleMouseDown, this);
24421 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24422 "up" : function(e){
24424 this.selectPrevious(e.shiftKey);
24425 }else if(this.last !== false && this.lastActive !== false){
24426 var last = this.last;
24427 this.selectRange(this.last, this.lastActive-1);
24428 this.grid.getView().focusRow(this.lastActive);
24429 if(last !== false){
24433 this.selectFirstRow();
24435 this.fireEvent("afterselectionchange", this);
24437 "down" : function(e){
24439 this.selectNext(e.shiftKey);
24440 }else if(this.last !== false && this.lastActive !== false){
24441 var last = this.last;
24442 this.selectRange(this.last, this.lastActive+1);
24443 this.grid.getView().focusRow(this.lastActive);
24444 if(last !== false){
24448 this.selectFirstRow();
24450 this.fireEvent("afterselectionchange", this);
24454 this.grid.store.on('load', function(){
24455 this.selections.clear();
24458 var view = this.grid.view;
24459 view.on("refresh", this.onRefresh, this);
24460 view.on("rowupdated", this.onRowUpdated, this);
24461 view.on("rowremoved", this.onRemove, this);
24466 onRefresh : function()
24468 var ds = this.grid.store, i, v = this.grid.view;
24469 var s = this.selections;
24470 s.each(function(r){
24471 if((i = ds.indexOfId(r.id)) != -1){
24480 onRemove : function(v, index, r){
24481 this.selections.remove(r);
24485 onRowUpdated : function(v, index, r){
24486 if(this.isSelected(r)){
24487 v.onRowSelect(index);
24493 * @param {Array} records The records to select
24494 * @param {Boolean} keepExisting (optional) True to keep existing selections
24496 selectRecords : function(records, keepExisting)
24499 this.clearSelections();
24501 var ds = this.grid.store;
24502 for(var i = 0, len = records.length; i < len; i++){
24503 this.selectRow(ds.indexOf(records[i]), true);
24508 * Gets the number of selected rows.
24511 getCount : function(){
24512 return this.selections.length;
24516 * Selects the first row in the grid.
24518 selectFirstRow : function(){
24523 * Select the last row.
24524 * @param {Boolean} keepExisting (optional) True to keep existing selections
24526 selectLastRow : function(keepExisting){
24527 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24528 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24532 * Selects the row immediately following the last selected row.
24533 * @param {Boolean} keepExisting (optional) True to keep existing selections
24535 selectNext : function(keepExisting)
24537 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24538 this.selectRow(this.last+1, keepExisting);
24539 this.grid.getView().focusRow(this.last);
24544 * Selects the row that precedes the last selected row.
24545 * @param {Boolean} keepExisting (optional) True to keep existing selections
24547 selectPrevious : function(keepExisting){
24549 this.selectRow(this.last-1, keepExisting);
24550 this.grid.getView().focusRow(this.last);
24555 * Returns the selected records
24556 * @return {Array} Array of selected records
24558 getSelections : function(){
24559 return [].concat(this.selections.items);
24563 * Returns the first selected record.
24566 getSelected : function(){
24567 return this.selections.itemAt(0);
24572 * Clears all selections.
24574 clearSelections : function(fast)
24580 var ds = this.grid.store;
24581 var s = this.selections;
24582 s.each(function(r){
24583 this.deselectRow(ds.indexOfId(r.id));
24587 this.selections.clear();
24594 * Selects all rows.
24596 selectAll : function(){
24600 this.selections.clear();
24601 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24602 this.selectRow(i, true);
24607 * Returns True if there is a selection.
24608 * @return {Boolean}
24610 hasSelection : function(){
24611 return this.selections.length > 0;
24615 * Returns True if the specified row is selected.
24616 * @param {Number/Record} record The record or index of the record to check
24617 * @return {Boolean}
24619 isSelected : function(index){
24620 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24621 return (r && this.selections.key(r.id) ? true : false);
24625 * Returns True if the specified record id is selected.
24626 * @param {String} id The id of record to check
24627 * @return {Boolean}
24629 isIdSelected : function(id){
24630 return (this.selections.key(id) ? true : false);
24635 handleMouseDBClick : function(e, t){
24639 handleMouseDown : function(e, t)
24641 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24642 if(this.isLocked() || rowIndex < 0 ){
24645 if(e.shiftKey && this.last !== false){
24646 var last = this.last;
24647 this.selectRange(last, rowIndex, e.ctrlKey);
24648 this.last = last; // reset the last
24652 var isSelected = this.isSelected(rowIndex);
24653 //Roo.log("select row:" + rowIndex);
24655 this.deselectRow(rowIndex);
24657 this.selectRow(rowIndex, true);
24661 if(e.button !== 0 && isSelected){
24662 alert('rowIndex 2: ' + rowIndex);
24663 view.focusRow(rowIndex);
24664 }else if(e.ctrlKey && isSelected){
24665 this.deselectRow(rowIndex);
24666 }else if(!isSelected){
24667 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24668 view.focusRow(rowIndex);
24672 this.fireEvent("afterselectionchange", this);
24675 handleDragableRowClick : function(grid, rowIndex, e)
24677 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24678 this.selectRow(rowIndex, false);
24679 grid.view.focusRow(rowIndex);
24680 this.fireEvent("afterselectionchange", this);
24685 * Selects multiple rows.
24686 * @param {Array} rows Array of the indexes of the row to select
24687 * @param {Boolean} keepExisting (optional) True to keep existing selections
24689 selectRows : function(rows, keepExisting){
24691 this.clearSelections();
24693 for(var i = 0, len = rows.length; i < len; i++){
24694 this.selectRow(rows[i], true);
24699 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24700 * @param {Number} startRow The index of the first row in the range
24701 * @param {Number} endRow The index of the last row in the range
24702 * @param {Boolean} keepExisting (optional) True to retain existing selections
24704 selectRange : function(startRow, endRow, keepExisting){
24709 this.clearSelections();
24711 if(startRow <= endRow){
24712 for(var i = startRow; i <= endRow; i++){
24713 this.selectRow(i, true);
24716 for(var i = startRow; i >= endRow; i--){
24717 this.selectRow(i, true);
24723 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24724 * @param {Number} startRow The index of the first row in the range
24725 * @param {Number} endRow The index of the last row in the range
24727 deselectRange : function(startRow, endRow, preventViewNotify){
24731 for(var i = startRow; i <= endRow; i++){
24732 this.deselectRow(i, preventViewNotify);
24738 * @param {Number} row The index of the row to select
24739 * @param {Boolean} keepExisting (optional) True to keep existing selections
24741 selectRow : function(index, keepExisting, preventViewNotify)
24743 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24746 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24747 if(!keepExisting || this.singleSelect){
24748 this.clearSelections();
24751 var r = this.grid.store.getAt(index);
24752 //console.log('selectRow - record id :' + r.id);
24754 this.selections.add(r);
24755 this.last = this.lastActive = index;
24756 if(!preventViewNotify){
24757 var proxy = new Roo.Element(
24758 this.grid.getRowDom(index)
24760 proxy.addClass('bg-info info');
24762 this.fireEvent("rowselect", this, index, r);
24763 this.fireEvent("selectionchange", this);
24769 * @param {Number} row The index of the row to deselect
24771 deselectRow : function(index, preventViewNotify)
24776 if(this.last == index){
24779 if(this.lastActive == index){
24780 this.lastActive = false;
24783 var r = this.grid.store.getAt(index);
24788 this.selections.remove(r);
24789 //.console.log('deselectRow - record id :' + r.id);
24790 if(!preventViewNotify){
24792 var proxy = new Roo.Element(
24793 this.grid.getRowDom(index)
24795 proxy.removeClass('bg-info info');
24797 this.fireEvent("rowdeselect", this, index);
24798 this.fireEvent("selectionchange", this);
24802 restoreLast : function(){
24804 this.last = this._last;
24809 acceptsNav : function(row, col, cm){
24810 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24814 onEditorKey : function(field, e){
24815 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24820 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24822 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24824 }else if(k == e.ENTER && !e.ctrlKey){
24828 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24830 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24832 }else if(k == e.ESC){
24836 g.startEditing(newCell[0], newCell[1]);
24842 * Ext JS Library 1.1.1
24843 * Copyright(c) 2006-2007, Ext JS, LLC.
24845 * Originally Released Under LGPL - original licence link has changed is not relivant.
24848 * <script type="text/javascript">
24852 * @class Roo.bootstrap.PagingToolbar
24853 * @extends Roo.bootstrap.NavSimplebar
24854 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24856 * Create a new PagingToolbar
24857 * @param {Object} config The config object
24858 * @param {Roo.data.Store} store
24860 Roo.bootstrap.PagingToolbar = function(config)
24862 // old args format still supported... - xtype is prefered..
24863 // created from xtype...
24865 this.ds = config.dataSource;
24867 if (config.store && !this.ds) {
24868 this.store= Roo.factory(config.store, Roo.data);
24869 this.ds = this.store;
24870 this.ds.xmodule = this.xmodule || false;
24873 this.toolbarItems = [];
24874 if (config.items) {
24875 this.toolbarItems = config.items;
24878 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24883 this.bind(this.ds);
24886 if (Roo.bootstrap.version == 4) {
24887 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24889 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24894 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24896 * @cfg {Roo.data.Store} dataSource
24897 * The underlying data store providing the paged data
24900 * @cfg {String/HTMLElement/Element} container
24901 * container The id or element that will contain the toolbar
24904 * @cfg {Boolean} displayInfo
24905 * True to display the displayMsg (defaults to false)
24908 * @cfg {Number} pageSize
24909 * The number of records to display per page (defaults to 20)
24913 * @cfg {String} displayMsg
24914 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24916 displayMsg : 'Displaying {0} - {1} of {2}',
24918 * @cfg {String} emptyMsg
24919 * The message to display when no records are found (defaults to "No data to display")
24921 emptyMsg : 'No data to display',
24923 * Customizable piece of the default paging text (defaults to "Page")
24926 beforePageText : "Page",
24928 * Customizable piece of the default paging text (defaults to "of %0")
24931 afterPageText : "of {0}",
24933 * Customizable piece of the default paging text (defaults to "First Page")
24936 firstText : "First Page",
24938 * Customizable piece of the default paging text (defaults to "Previous Page")
24941 prevText : "Previous Page",
24943 * Customizable piece of the default paging text (defaults to "Next Page")
24946 nextText : "Next Page",
24948 * Customizable piece of the default paging text (defaults to "Last Page")
24951 lastText : "Last Page",
24953 * Customizable piece of the default paging text (defaults to "Refresh")
24956 refreshText : "Refresh",
24960 onRender : function(ct, position)
24962 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24963 this.navgroup.parentId = this.id;
24964 this.navgroup.onRender(this.el, null);
24965 // add the buttons to the navgroup
24967 if(this.displayInfo){
24968 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24969 this.displayEl = this.el.select('.x-paging-info', true).first();
24970 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24971 // this.displayEl = navel.el.select('span',true).first();
24977 Roo.each(_this.buttons, function(e){ // this might need to use render????
24978 Roo.factory(e).render(_this.el);
24982 Roo.each(_this.toolbarItems, function(e) {
24983 _this.navgroup.addItem(e);
24987 this.first = this.navgroup.addItem({
24988 tooltip: this.firstText,
24989 cls: "prev btn-outline-secondary",
24990 html : ' <i class="fa fa-step-backward"></i>',
24992 preventDefault: true,
24993 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24996 this.prev = this.navgroup.addItem({
24997 tooltip: this.prevText,
24998 cls: "prev btn-outline-secondary",
24999 html : ' <i class="fa fa-backward"></i>',
25001 preventDefault: true,
25002 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25004 //this.addSeparator();
25007 var field = this.navgroup.addItem( {
25009 cls : 'x-paging-position btn-outline-secondary',
25011 html : this.beforePageText +
25012 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25013 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25016 this.field = field.el.select('input', true).first();
25017 this.field.on("keydown", this.onPagingKeydown, this);
25018 this.field.on("focus", function(){this.dom.select();});
25021 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25022 //this.field.setHeight(18);
25023 //this.addSeparator();
25024 this.next = this.navgroup.addItem({
25025 tooltip: this.nextText,
25026 cls: "next btn-outline-secondary",
25027 html : ' <i class="fa fa-forward"></i>',
25029 preventDefault: true,
25030 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25032 this.last = this.navgroup.addItem({
25033 tooltip: this.lastText,
25034 html : ' <i class="fa fa-step-forward"></i>',
25035 cls: "next btn-outline-secondary",
25037 preventDefault: true,
25038 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25040 //this.addSeparator();
25041 this.loading = this.navgroup.addItem({
25042 tooltip: this.refreshText,
25043 cls: "btn-outline-secondary",
25044 html : ' <i class="fa fa-refresh"></i>',
25045 preventDefault: true,
25046 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25052 updateInfo : function(){
25053 if(this.displayEl){
25054 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25055 var msg = count == 0 ?
25059 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25061 this.displayEl.update(msg);
25066 onLoad : function(ds, r, o)
25068 this.cursor = o.params.start ? o.params.start : 0;
25070 var d = this.getPageData(),
25075 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25076 this.field.dom.value = ap;
25077 this.first.setDisabled(ap == 1);
25078 this.prev.setDisabled(ap == 1);
25079 this.next.setDisabled(ap == ps);
25080 this.last.setDisabled(ap == ps);
25081 this.loading.enable();
25086 getPageData : function(){
25087 var total = this.ds.getTotalCount();
25090 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25091 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25096 onLoadError : function(){
25097 this.loading.enable();
25101 onPagingKeydown : function(e){
25102 var k = e.getKey();
25103 var d = this.getPageData();
25105 var v = this.field.dom.value, pageNum;
25106 if(!v || isNaN(pageNum = parseInt(v, 10))){
25107 this.field.dom.value = d.activePage;
25110 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25111 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25114 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))
25116 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25117 this.field.dom.value = pageNum;
25118 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25121 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25123 var v = this.field.dom.value, pageNum;
25124 var increment = (e.shiftKey) ? 10 : 1;
25125 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25128 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25129 this.field.dom.value = d.activePage;
25132 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25134 this.field.dom.value = parseInt(v, 10) + increment;
25135 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25136 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25143 beforeLoad : function(){
25145 this.loading.disable();
25150 onClick : function(which){
25159 ds.load({params:{start: 0, limit: this.pageSize}});
25162 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25165 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25168 var total = ds.getTotalCount();
25169 var extra = total % this.pageSize;
25170 var lastStart = extra ? (total - extra) : total-this.pageSize;
25171 ds.load({params:{start: lastStart, limit: this.pageSize}});
25174 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25180 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25181 * @param {Roo.data.Store} store The data store to unbind
25183 unbind : function(ds){
25184 ds.un("beforeload", this.beforeLoad, this);
25185 ds.un("load", this.onLoad, this);
25186 ds.un("loadexception", this.onLoadError, this);
25187 ds.un("remove", this.updateInfo, this);
25188 ds.un("add", this.updateInfo, this);
25189 this.ds = undefined;
25193 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25194 * @param {Roo.data.Store} store The data store to bind
25196 bind : function(ds){
25197 ds.on("beforeload", this.beforeLoad, this);
25198 ds.on("load", this.onLoad, this);
25199 ds.on("loadexception", this.onLoadError, this);
25200 ds.on("remove", this.updateInfo, this);
25201 ds.on("add", this.updateInfo, this);
25212 * @class Roo.bootstrap.MessageBar
25213 * @extends Roo.bootstrap.Component
25214 * Bootstrap MessageBar class
25215 * @cfg {String} html contents of the MessageBar
25216 * @cfg {String} weight (info | success | warning | danger) default info
25217 * @cfg {String} beforeClass insert the bar before the given class
25218 * @cfg {Boolean} closable (true | false) default false
25219 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25222 * Create a new Element
25223 * @param {Object} config The config object
25226 Roo.bootstrap.MessageBar = function(config){
25227 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25230 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25236 beforeClass: 'bootstrap-sticky-wrap',
25238 getAutoCreate : function(){
25242 cls: 'alert alert-dismissable alert-' + this.weight,
25247 html: this.html || ''
25253 cfg.cls += ' alert-messages-fixed';
25267 onRender : function(ct, position)
25269 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25272 var cfg = Roo.apply({}, this.getAutoCreate());
25276 cfg.cls += ' ' + this.cls;
25279 cfg.style = this.style;
25281 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25283 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25286 this.el.select('>button.close').on('click', this.hide, this);
25292 if (!this.rendered) {
25298 this.fireEvent('show', this);
25304 if (!this.rendered) {
25310 this.fireEvent('hide', this);
25313 update : function()
25315 // var e = this.el.dom.firstChild;
25317 // if(this.closable){
25318 // e = e.nextSibling;
25321 // e.data = this.html || '';
25323 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25339 * @class Roo.bootstrap.Graph
25340 * @extends Roo.bootstrap.Component
25341 * Bootstrap Graph class
25345 @cfg {String} graphtype bar | vbar | pie
25346 @cfg {number} g_x coodinator | centre x (pie)
25347 @cfg {number} g_y coodinator | centre y (pie)
25348 @cfg {number} g_r radius (pie)
25349 @cfg {number} g_height height of the chart (respected by all elements in the set)
25350 @cfg {number} g_width width of the chart (respected by all elements in the set)
25351 @cfg {Object} title The title of the chart
25354 -opts (object) options for the chart
25356 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25357 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25359 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.
25360 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25362 o stretch (boolean)
25364 -opts (object) options for the pie
25367 o startAngle (number)
25368 o endAngle (number)
25372 * Create a new Input
25373 * @param {Object} config The config object
25376 Roo.bootstrap.Graph = function(config){
25377 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25383 * The img click event for the img.
25384 * @param {Roo.EventObject} e
25390 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25401 //g_colors: this.colors,
25408 getAutoCreate : function(){
25419 onRender : function(ct,position){
25422 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25424 if (typeof(Raphael) == 'undefined') {
25425 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25429 this.raphael = Raphael(this.el.dom);
25431 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25432 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25433 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25434 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25436 r.text(160, 10, "Single Series Chart").attr(txtattr);
25437 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25438 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25439 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25441 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25442 r.barchart(330, 10, 300, 220, data1);
25443 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25444 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25447 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25448 // r.barchart(30, 30, 560, 250, xdata, {
25449 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25450 // axis : "0 0 1 1",
25451 // axisxlabels : xdata
25452 // //yvalues : cols,
25455 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25457 // this.load(null,xdata,{
25458 // axis : "0 0 1 1",
25459 // axisxlabels : xdata
25464 load : function(graphtype,xdata,opts)
25466 this.raphael.clear();
25468 graphtype = this.graphtype;
25473 var r = this.raphael,
25474 fin = function () {
25475 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25477 fout = function () {
25478 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25480 pfin = function() {
25481 this.sector.stop();
25482 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25485 this.label[0].stop();
25486 this.label[0].attr({ r: 7.5 });
25487 this.label[1].attr({ "font-weight": 800 });
25490 pfout = function() {
25491 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25494 this.label[0].animate({ r: 5 }, 500, "bounce");
25495 this.label[1].attr({ "font-weight": 400 });
25501 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25504 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25507 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25508 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25510 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25517 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25522 setTitle: function(o)
25527 initEvents: function() {
25530 this.el.on('click', this.onClick, this);
25534 onClick : function(e)
25536 Roo.log('img onclick');
25537 this.fireEvent('click', this, e);
25549 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25552 * @class Roo.bootstrap.dash.NumberBox
25553 * @extends Roo.bootstrap.Component
25554 * Bootstrap NumberBox class
25555 * @cfg {String} headline Box headline
25556 * @cfg {String} content Box content
25557 * @cfg {String} icon Box icon
25558 * @cfg {String} footer Footer text
25559 * @cfg {String} fhref Footer href
25562 * Create a new NumberBox
25563 * @param {Object} config The config object
25567 Roo.bootstrap.dash.NumberBox = function(config){
25568 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25572 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25581 getAutoCreate : function(){
25585 cls : 'small-box ',
25593 cls : 'roo-headline',
25594 html : this.headline
25598 cls : 'roo-content',
25599 html : this.content
25613 cls : 'ion ' + this.icon
25622 cls : 'small-box-footer',
25623 href : this.fhref || '#',
25627 cfg.cn.push(footer);
25634 onRender : function(ct,position){
25635 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25642 setHeadline: function (value)
25644 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25647 setFooter: function (value, href)
25649 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25652 this.el.select('a.small-box-footer',true).first().attr('href', href);
25657 setContent: function (value)
25659 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25662 initEvents: function()
25676 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25679 * @class Roo.bootstrap.dash.TabBox
25680 * @extends Roo.bootstrap.Component
25681 * Bootstrap TabBox class
25682 * @cfg {String} title Title of the TabBox
25683 * @cfg {String} icon Icon of the TabBox
25684 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25685 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25688 * Create a new TabBox
25689 * @param {Object} config The config object
25693 Roo.bootstrap.dash.TabBox = function(config){
25694 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25699 * When a pane is added
25700 * @param {Roo.bootstrap.dash.TabPane} pane
25704 * @event activatepane
25705 * When a pane is activated
25706 * @param {Roo.bootstrap.dash.TabPane} pane
25708 "activatepane" : true
25716 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25721 tabScrollable : false,
25723 getChildContainer : function()
25725 return this.el.select('.tab-content', true).first();
25728 getAutoCreate : function(){
25732 cls: 'pull-left header',
25740 cls: 'fa ' + this.icon
25746 cls: 'nav nav-tabs pull-right',
25752 if(this.tabScrollable){
25759 cls: 'nav nav-tabs pull-right',
25770 cls: 'nav-tabs-custom',
25775 cls: 'tab-content no-padding',
25783 initEvents : function()
25785 //Roo.log('add add pane handler');
25786 this.on('addpane', this.onAddPane, this);
25789 * Updates the box title
25790 * @param {String} html to set the title to.
25792 setTitle : function(value)
25794 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25796 onAddPane : function(pane)
25798 this.panes.push(pane);
25799 //Roo.log('addpane');
25801 // tabs are rendere left to right..
25802 if(!this.showtabs){
25806 var ctr = this.el.select('.nav-tabs', true).first();
25809 var existing = ctr.select('.nav-tab',true);
25810 var qty = existing.getCount();;
25813 var tab = ctr.createChild({
25815 cls : 'nav-tab' + (qty ? '' : ' active'),
25823 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25826 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25828 pane.el.addClass('active');
25833 onTabClick : function(ev,un,ob,pane)
25835 //Roo.log('tab - prev default');
25836 ev.preventDefault();
25839 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25840 pane.tab.addClass('active');
25841 //Roo.log(pane.title);
25842 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25843 // technically we should have a deactivate event.. but maybe add later.
25844 // and it should not de-activate the selected tab...
25845 this.fireEvent('activatepane', pane);
25846 pane.el.addClass('active');
25847 pane.fireEvent('activate');
25852 getActivePane : function()
25855 Roo.each(this.panes, function(p) {
25856 if(p.el.hasClass('active')){
25877 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25879 * @class Roo.bootstrap.TabPane
25880 * @extends Roo.bootstrap.Component
25881 * Bootstrap TabPane class
25882 * @cfg {Boolean} active (false | true) Default false
25883 * @cfg {String} title title of panel
25887 * Create a new TabPane
25888 * @param {Object} config The config object
25891 Roo.bootstrap.dash.TabPane = function(config){
25892 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25898 * When a pane is activated
25899 * @param {Roo.bootstrap.dash.TabPane} pane
25906 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25911 // the tabBox that this is attached to.
25914 getAutoCreate : function()
25922 cfg.cls += ' active';
25927 initEvents : function()
25929 //Roo.log('trigger add pane handler');
25930 this.parent().fireEvent('addpane', this)
25934 * Updates the tab title
25935 * @param {String} html to set the title to.
25937 setTitle: function(str)
25943 this.tab.select('a', true).first().dom.innerHTML = str;
25960 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25963 * @class Roo.bootstrap.menu.Menu
25964 * @extends Roo.bootstrap.Component
25965 * Bootstrap Menu class - container for Menu
25966 * @cfg {String} html Text of the menu
25967 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25968 * @cfg {String} icon Font awesome icon
25969 * @cfg {String} pos Menu align to (top | bottom) default bottom
25973 * Create a new Menu
25974 * @param {Object} config The config object
25978 Roo.bootstrap.menu.Menu = function(config){
25979 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25983 * @event beforeshow
25984 * Fires before this menu is displayed
25985 * @param {Roo.bootstrap.menu.Menu} this
25989 * @event beforehide
25990 * Fires before this menu is hidden
25991 * @param {Roo.bootstrap.menu.Menu} this
25996 * Fires after this menu is displayed
25997 * @param {Roo.bootstrap.menu.Menu} this
26002 * Fires after this menu is hidden
26003 * @param {Roo.bootstrap.menu.Menu} this
26008 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26009 * @param {Roo.bootstrap.menu.Menu} this
26010 * @param {Roo.EventObject} e
26017 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26021 weight : 'default',
26026 getChildContainer : function() {
26027 if(this.isSubMenu){
26031 return this.el.select('ul.dropdown-menu', true).first();
26034 getAutoCreate : function()
26039 cls : 'roo-menu-text',
26047 cls : 'fa ' + this.icon
26058 cls : 'dropdown-button btn btn-' + this.weight,
26063 cls : 'dropdown-toggle btn btn-' + this.weight,
26073 cls : 'dropdown-menu'
26079 if(this.pos == 'top'){
26080 cfg.cls += ' dropup';
26083 if(this.isSubMenu){
26086 cls : 'dropdown-menu'
26093 onRender : function(ct, position)
26095 this.isSubMenu = ct.hasClass('dropdown-submenu');
26097 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26100 initEvents : function()
26102 if(this.isSubMenu){
26106 this.hidden = true;
26108 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26109 this.triggerEl.on('click', this.onTriggerPress, this);
26111 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26112 this.buttonEl.on('click', this.onClick, this);
26118 if(this.isSubMenu){
26122 return this.el.select('ul.dropdown-menu', true).first();
26125 onClick : function(e)
26127 this.fireEvent("click", this, e);
26130 onTriggerPress : function(e)
26132 if (this.isVisible()) {
26139 isVisible : function(){
26140 return !this.hidden;
26145 this.fireEvent("beforeshow", this);
26147 this.hidden = false;
26148 this.el.addClass('open');
26150 Roo.get(document).on("mouseup", this.onMouseUp, this);
26152 this.fireEvent("show", this);
26159 this.fireEvent("beforehide", this);
26161 this.hidden = true;
26162 this.el.removeClass('open');
26164 Roo.get(document).un("mouseup", this.onMouseUp);
26166 this.fireEvent("hide", this);
26169 onMouseUp : function()
26183 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26186 * @class Roo.bootstrap.menu.Item
26187 * @extends Roo.bootstrap.Component
26188 * Bootstrap MenuItem class
26189 * @cfg {Boolean} submenu (true | false) default false
26190 * @cfg {String} html text of the item
26191 * @cfg {String} href the link
26192 * @cfg {Boolean} disable (true | false) default false
26193 * @cfg {Boolean} preventDefault (true | false) default true
26194 * @cfg {String} icon Font awesome icon
26195 * @cfg {String} pos Submenu align to (left | right) default right
26199 * Create a new Item
26200 * @param {Object} config The config object
26204 Roo.bootstrap.menu.Item = function(config){
26205 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26209 * Fires when the mouse is hovering over this menu
26210 * @param {Roo.bootstrap.menu.Item} this
26211 * @param {Roo.EventObject} e
26216 * Fires when the mouse exits this menu
26217 * @param {Roo.bootstrap.menu.Item} this
26218 * @param {Roo.EventObject} e
26224 * The raw click event for the entire grid.
26225 * @param {Roo.EventObject} e
26231 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26236 preventDefault: true,
26241 getAutoCreate : function()
26246 cls : 'roo-menu-item-text',
26254 cls : 'fa ' + this.icon
26263 href : this.href || '#',
26270 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26274 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26276 if(this.pos == 'left'){
26277 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26284 initEvents : function()
26286 this.el.on('mouseover', this.onMouseOver, this);
26287 this.el.on('mouseout', this.onMouseOut, this);
26289 this.el.select('a', true).first().on('click', this.onClick, this);
26293 onClick : function(e)
26295 if(this.preventDefault){
26296 e.preventDefault();
26299 this.fireEvent("click", this, e);
26302 onMouseOver : function(e)
26304 if(this.submenu && this.pos == 'left'){
26305 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26308 this.fireEvent("mouseover", this, e);
26311 onMouseOut : function(e)
26313 this.fireEvent("mouseout", this, e);
26325 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26328 * @class Roo.bootstrap.menu.Separator
26329 * @extends Roo.bootstrap.Component
26330 * Bootstrap Separator class
26333 * Create a new Separator
26334 * @param {Object} config The config object
26338 Roo.bootstrap.menu.Separator = function(config){
26339 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26342 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26344 getAutoCreate : function(){
26365 * @class Roo.bootstrap.Tooltip
26366 * Bootstrap Tooltip class
26367 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26368 * to determine which dom element triggers the tooltip.
26370 * It needs to add support for additional attributes like tooltip-position
26373 * Create a new Toolti
26374 * @param {Object} config The config object
26377 Roo.bootstrap.Tooltip = function(config){
26378 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26380 this.alignment = Roo.bootstrap.Tooltip.alignment;
26382 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26383 this.alignment = config.alignment;
26388 Roo.apply(Roo.bootstrap.Tooltip, {
26390 * @function init initialize tooltip monitoring.
26394 currentTip : false,
26395 currentRegion : false,
26401 Roo.get(document).on('mouseover', this.enter ,this);
26402 Roo.get(document).on('mouseout', this.leave, this);
26405 this.currentTip = new Roo.bootstrap.Tooltip();
26408 enter : function(ev)
26410 var dom = ev.getTarget();
26412 //Roo.log(['enter',dom]);
26413 var el = Roo.fly(dom);
26414 if (this.currentEl) {
26416 //Roo.log(this.currentEl);
26417 //Roo.log(this.currentEl.contains(dom));
26418 if (this.currentEl == el) {
26421 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26427 if (this.currentTip.el) {
26428 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26432 if(!el || el.dom == document){
26438 // you can not look for children, as if el is the body.. then everythign is the child..
26439 if (!el.attr('tooltip')) { //
26440 if (!el.select("[tooltip]").elements.length) {
26443 // is the mouse over this child...?
26444 bindEl = el.select("[tooltip]").first();
26445 var xy = ev.getXY();
26446 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26447 //Roo.log("not in region.");
26450 //Roo.log("child element over..");
26453 this.currentEl = bindEl;
26454 this.currentTip.bind(bindEl);
26455 this.currentRegion = Roo.lib.Region.getRegion(dom);
26456 this.currentTip.enter();
26459 leave : function(ev)
26461 var dom = ev.getTarget();
26462 //Roo.log(['leave',dom]);
26463 if (!this.currentEl) {
26468 if (dom != this.currentEl.dom) {
26471 var xy = ev.getXY();
26472 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26475 // only activate leave if mouse cursor is outside... bounding box..
26480 if (this.currentTip) {
26481 this.currentTip.leave();
26483 //Roo.log('clear currentEl');
26484 this.currentEl = false;
26489 'left' : ['r-l', [-2,0], 'right'],
26490 'right' : ['l-r', [2,0], 'left'],
26491 'bottom' : ['t-b', [0,2], 'top'],
26492 'top' : [ 'b-t', [0,-2], 'bottom']
26498 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26503 delay : null, // can be { show : 300 , hide: 500}
26507 hoverState : null, //???
26509 placement : 'bottom',
26513 getAutoCreate : function(){
26520 cls : 'tooltip-arrow'
26523 cls : 'tooltip-inner'
26530 bind : function(el)
26536 enter : function () {
26538 if (this.timeout != null) {
26539 clearTimeout(this.timeout);
26542 this.hoverState = 'in';
26543 //Roo.log("enter - show");
26544 if (!this.delay || !this.delay.show) {
26549 this.timeout = setTimeout(function () {
26550 if (_t.hoverState == 'in') {
26553 }, this.delay.show);
26557 clearTimeout(this.timeout);
26559 this.hoverState = 'out';
26560 if (!this.delay || !this.delay.hide) {
26566 this.timeout = setTimeout(function () {
26567 //Roo.log("leave - timeout");
26569 if (_t.hoverState == 'out') {
26571 Roo.bootstrap.Tooltip.currentEl = false;
26576 show : function (msg)
26579 this.render(document.body);
26582 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26584 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26586 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26588 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26590 var placement = typeof this.placement == 'function' ?
26591 this.placement.call(this, this.el, on_el) :
26594 var autoToken = /\s?auto?\s?/i;
26595 var autoPlace = autoToken.test(placement);
26597 placement = placement.replace(autoToken, '') || 'top';
26601 //this.el.setXY([0,0]);
26603 //this.el.dom.style.display='block';
26605 //this.el.appendTo(on_el);
26607 var p = this.getPosition();
26608 var box = this.el.getBox();
26614 var align = this.alignment[placement];
26616 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26618 if(placement == 'top' || placement == 'bottom'){
26620 placement = 'right';
26623 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26624 placement = 'left';
26627 var scroll = Roo.select('body', true).first().getScroll();
26629 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26633 align = this.alignment[placement];
26636 this.el.alignTo(this.bindEl, align[0],align[1]);
26637 //var arrow = this.el.select('.arrow',true).first();
26638 //arrow.set(align[2],
26640 this.el.addClass(placement);
26642 this.el.addClass('in fade');
26644 this.hoverState = null;
26646 if (this.el.hasClass('fade')) {
26657 //this.el.setXY([0,0]);
26658 this.el.removeClass('in');
26674 * @class Roo.bootstrap.LocationPicker
26675 * @extends Roo.bootstrap.Component
26676 * Bootstrap LocationPicker class
26677 * @cfg {Number} latitude Position when init default 0
26678 * @cfg {Number} longitude Position when init default 0
26679 * @cfg {Number} zoom default 15
26680 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26681 * @cfg {Boolean} mapTypeControl default false
26682 * @cfg {Boolean} disableDoubleClickZoom default false
26683 * @cfg {Boolean} scrollwheel default true
26684 * @cfg {Boolean} streetViewControl default false
26685 * @cfg {Number} radius default 0
26686 * @cfg {String} locationName
26687 * @cfg {Boolean} draggable default true
26688 * @cfg {Boolean} enableAutocomplete default false
26689 * @cfg {Boolean} enableReverseGeocode default true
26690 * @cfg {String} markerTitle
26693 * Create a new LocationPicker
26694 * @param {Object} config The config object
26698 Roo.bootstrap.LocationPicker = function(config){
26700 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26705 * Fires when the picker initialized.
26706 * @param {Roo.bootstrap.LocationPicker} this
26707 * @param {Google Location} location
26711 * @event positionchanged
26712 * Fires when the picker position changed.
26713 * @param {Roo.bootstrap.LocationPicker} this
26714 * @param {Google Location} location
26716 positionchanged : true,
26719 * Fires when the map resize.
26720 * @param {Roo.bootstrap.LocationPicker} this
26725 * Fires when the map show.
26726 * @param {Roo.bootstrap.LocationPicker} this
26731 * Fires when the map hide.
26732 * @param {Roo.bootstrap.LocationPicker} this
26737 * Fires when click the map.
26738 * @param {Roo.bootstrap.LocationPicker} this
26739 * @param {Map event} e
26743 * @event mapRightClick
26744 * Fires when right click the map.
26745 * @param {Roo.bootstrap.LocationPicker} this
26746 * @param {Map event} e
26748 mapRightClick : true,
26750 * @event markerClick
26751 * Fires when click the marker.
26752 * @param {Roo.bootstrap.LocationPicker} this
26753 * @param {Map event} e
26755 markerClick : true,
26757 * @event markerRightClick
26758 * Fires when right click the marker.
26759 * @param {Roo.bootstrap.LocationPicker} this
26760 * @param {Map event} e
26762 markerRightClick : true,
26764 * @event OverlayViewDraw
26765 * Fires when OverlayView Draw
26766 * @param {Roo.bootstrap.LocationPicker} this
26768 OverlayViewDraw : true,
26770 * @event OverlayViewOnAdd
26771 * Fires when OverlayView Draw
26772 * @param {Roo.bootstrap.LocationPicker} this
26774 OverlayViewOnAdd : true,
26776 * @event OverlayViewOnRemove
26777 * Fires when OverlayView Draw
26778 * @param {Roo.bootstrap.LocationPicker} this
26780 OverlayViewOnRemove : true,
26782 * @event OverlayViewShow
26783 * Fires when OverlayView Draw
26784 * @param {Roo.bootstrap.LocationPicker} this
26785 * @param {Pixel} cpx
26787 OverlayViewShow : true,
26789 * @event OverlayViewHide
26790 * Fires when OverlayView Draw
26791 * @param {Roo.bootstrap.LocationPicker} this
26793 OverlayViewHide : true,
26795 * @event loadexception
26796 * Fires when load google lib failed.
26797 * @param {Roo.bootstrap.LocationPicker} this
26799 loadexception : true
26804 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26806 gMapContext: false,
26812 mapTypeControl: false,
26813 disableDoubleClickZoom: false,
26815 streetViewControl: false,
26819 enableAutocomplete: false,
26820 enableReverseGeocode: true,
26823 getAutoCreate: function()
26828 cls: 'roo-location-picker'
26834 initEvents: function(ct, position)
26836 if(!this.el.getWidth() || this.isApplied()){
26840 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26845 initial: function()
26847 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26848 this.fireEvent('loadexception', this);
26852 if(!this.mapTypeId){
26853 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26856 this.gMapContext = this.GMapContext();
26858 this.initOverlayView();
26860 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26864 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26865 _this.setPosition(_this.gMapContext.marker.position);
26868 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26869 _this.fireEvent('mapClick', this, event);
26873 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26874 _this.fireEvent('mapRightClick', this, event);
26878 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26879 _this.fireEvent('markerClick', this, event);
26883 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26884 _this.fireEvent('markerRightClick', this, event);
26888 this.setPosition(this.gMapContext.location);
26890 this.fireEvent('initial', this, this.gMapContext.location);
26893 initOverlayView: function()
26897 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26901 _this.fireEvent('OverlayViewDraw', _this);
26906 _this.fireEvent('OverlayViewOnAdd', _this);
26909 onRemove: function()
26911 _this.fireEvent('OverlayViewOnRemove', _this);
26914 show: function(cpx)
26916 _this.fireEvent('OverlayViewShow', _this, cpx);
26921 _this.fireEvent('OverlayViewHide', _this);
26927 fromLatLngToContainerPixel: function(event)
26929 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26932 isApplied: function()
26934 return this.getGmapContext() == false ? false : true;
26937 getGmapContext: function()
26939 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26942 GMapContext: function()
26944 var position = new google.maps.LatLng(this.latitude, this.longitude);
26946 var _map = new google.maps.Map(this.el.dom, {
26949 mapTypeId: this.mapTypeId,
26950 mapTypeControl: this.mapTypeControl,
26951 disableDoubleClickZoom: this.disableDoubleClickZoom,
26952 scrollwheel: this.scrollwheel,
26953 streetViewControl: this.streetViewControl,
26954 locationName: this.locationName,
26955 draggable: this.draggable,
26956 enableAutocomplete: this.enableAutocomplete,
26957 enableReverseGeocode: this.enableReverseGeocode
26960 var _marker = new google.maps.Marker({
26961 position: position,
26963 title: this.markerTitle,
26964 draggable: this.draggable
26971 location: position,
26972 radius: this.radius,
26973 locationName: this.locationName,
26974 addressComponents: {
26975 formatted_address: null,
26976 addressLine1: null,
26977 addressLine2: null,
26979 streetNumber: null,
26983 stateOrProvince: null
26986 domContainer: this.el.dom,
26987 geodecoder: new google.maps.Geocoder()
26991 drawCircle: function(center, radius, options)
26993 if (this.gMapContext.circle != null) {
26994 this.gMapContext.circle.setMap(null);
26998 options = Roo.apply({}, options, {
26999 strokeColor: "#0000FF",
27000 strokeOpacity: .35,
27002 fillColor: "#0000FF",
27006 options.map = this.gMapContext.map;
27007 options.radius = radius;
27008 options.center = center;
27009 this.gMapContext.circle = new google.maps.Circle(options);
27010 return this.gMapContext.circle;
27016 setPosition: function(location)
27018 this.gMapContext.location = location;
27019 this.gMapContext.marker.setPosition(location);
27020 this.gMapContext.map.panTo(location);
27021 this.drawCircle(location, this.gMapContext.radius, {});
27025 if (this.gMapContext.settings.enableReverseGeocode) {
27026 this.gMapContext.geodecoder.geocode({
27027 latLng: this.gMapContext.location
27028 }, function(results, status) {
27030 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27031 _this.gMapContext.locationName = results[0].formatted_address;
27032 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27034 _this.fireEvent('positionchanged', this, location);
27041 this.fireEvent('positionchanged', this, location);
27046 google.maps.event.trigger(this.gMapContext.map, "resize");
27048 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27050 this.fireEvent('resize', this);
27053 setPositionByLatLng: function(latitude, longitude)
27055 this.setPosition(new google.maps.LatLng(latitude, longitude));
27058 getCurrentPosition: function()
27061 latitude: this.gMapContext.location.lat(),
27062 longitude: this.gMapContext.location.lng()
27066 getAddressName: function()
27068 return this.gMapContext.locationName;
27071 getAddressComponents: function()
27073 return this.gMapContext.addressComponents;
27076 address_component_from_google_geocode: function(address_components)
27080 for (var i = 0; i < address_components.length; i++) {
27081 var component = address_components[i];
27082 if (component.types.indexOf("postal_code") >= 0) {
27083 result.postalCode = component.short_name;
27084 } else if (component.types.indexOf("street_number") >= 0) {
27085 result.streetNumber = component.short_name;
27086 } else if (component.types.indexOf("route") >= 0) {
27087 result.streetName = component.short_name;
27088 } else if (component.types.indexOf("neighborhood") >= 0) {
27089 result.city = component.short_name;
27090 } else if (component.types.indexOf("locality") >= 0) {
27091 result.city = component.short_name;
27092 } else if (component.types.indexOf("sublocality") >= 0) {
27093 result.district = component.short_name;
27094 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27095 result.stateOrProvince = component.short_name;
27096 } else if (component.types.indexOf("country") >= 0) {
27097 result.country = component.short_name;
27101 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27102 result.addressLine2 = "";
27106 setZoomLevel: function(zoom)
27108 this.gMapContext.map.setZoom(zoom);
27121 this.fireEvent('show', this);
27132 this.fireEvent('hide', this);
27137 Roo.apply(Roo.bootstrap.LocationPicker, {
27139 OverlayView : function(map, options)
27141 options = options || {};
27155 * @class Roo.bootstrap.Alert
27156 * @extends Roo.bootstrap.Component
27157 * Bootstrap Alert class
27158 * @cfg {String} title The title of alert
27159 * @cfg {String} html The content of alert
27160 * @cfg {String} weight ( success | info | warning | danger )
27161 * @cfg {String} faicon font-awesomeicon
27164 * Create a new alert
27165 * @param {Object} config The config object
27169 Roo.bootstrap.Alert = function(config){
27170 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27174 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27181 getAutoCreate : function()
27190 cls : 'roo-alert-icon'
27195 cls : 'roo-alert-title',
27200 cls : 'roo-alert-text',
27207 cfg.cn[0].cls += ' fa ' + this.faicon;
27211 cfg.cls += ' alert-' + this.weight;
27217 initEvents: function()
27219 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27222 setTitle : function(str)
27224 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27227 setText : function(str)
27229 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27232 setWeight : function(weight)
27235 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27238 this.weight = weight;
27240 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27243 setIcon : function(icon)
27246 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27249 this.faicon = icon;
27251 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27272 * @class Roo.bootstrap.UploadCropbox
27273 * @extends Roo.bootstrap.Component
27274 * Bootstrap UploadCropbox class
27275 * @cfg {String} emptyText show when image has been loaded
27276 * @cfg {String} rotateNotify show when image too small to rotate
27277 * @cfg {Number} errorTimeout default 3000
27278 * @cfg {Number} minWidth default 300
27279 * @cfg {Number} minHeight default 300
27280 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27281 * @cfg {Boolean} isDocument (true|false) default false
27282 * @cfg {String} url action url
27283 * @cfg {String} paramName default 'imageUpload'
27284 * @cfg {String} method default POST
27285 * @cfg {Boolean} loadMask (true|false) default true
27286 * @cfg {Boolean} loadingText default 'Loading...'
27289 * Create a new UploadCropbox
27290 * @param {Object} config The config object
27293 Roo.bootstrap.UploadCropbox = function(config){
27294 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27298 * @event beforeselectfile
27299 * Fire before select file
27300 * @param {Roo.bootstrap.UploadCropbox} this
27302 "beforeselectfile" : true,
27305 * Fire after initEvent
27306 * @param {Roo.bootstrap.UploadCropbox} this
27311 * Fire after initEvent
27312 * @param {Roo.bootstrap.UploadCropbox} this
27313 * @param {String} data
27318 * Fire when preparing the file data
27319 * @param {Roo.bootstrap.UploadCropbox} this
27320 * @param {Object} file
27325 * Fire when get exception
27326 * @param {Roo.bootstrap.UploadCropbox} this
27327 * @param {XMLHttpRequest} xhr
27329 "exception" : true,
27331 * @event beforeloadcanvas
27332 * Fire before load the canvas
27333 * @param {Roo.bootstrap.UploadCropbox} this
27334 * @param {String} src
27336 "beforeloadcanvas" : true,
27339 * Fire when trash image
27340 * @param {Roo.bootstrap.UploadCropbox} this
27345 * Fire when download the image
27346 * @param {Roo.bootstrap.UploadCropbox} this
27350 * @event footerbuttonclick
27351 * Fire when footerbuttonclick
27352 * @param {Roo.bootstrap.UploadCropbox} this
27353 * @param {String} type
27355 "footerbuttonclick" : true,
27359 * @param {Roo.bootstrap.UploadCropbox} this
27364 * Fire when rotate the image
27365 * @param {Roo.bootstrap.UploadCropbox} this
27366 * @param {String} pos
27371 * Fire when inspect the file
27372 * @param {Roo.bootstrap.UploadCropbox} this
27373 * @param {Object} file
27378 * Fire when xhr upload the file
27379 * @param {Roo.bootstrap.UploadCropbox} this
27380 * @param {Object} data
27385 * Fire when arrange the file data
27386 * @param {Roo.bootstrap.UploadCropbox} this
27387 * @param {Object} formData
27392 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27395 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27397 emptyText : 'Click to upload image',
27398 rotateNotify : 'Image is too small to rotate',
27399 errorTimeout : 3000,
27413 cropType : 'image/jpeg',
27415 canvasLoaded : false,
27416 isDocument : false,
27418 paramName : 'imageUpload',
27420 loadingText : 'Loading...',
27423 getAutoCreate : function()
27427 cls : 'roo-upload-cropbox',
27431 cls : 'roo-upload-cropbox-selector',
27436 cls : 'roo-upload-cropbox-body',
27437 style : 'cursor:pointer',
27441 cls : 'roo-upload-cropbox-preview'
27445 cls : 'roo-upload-cropbox-thumb'
27449 cls : 'roo-upload-cropbox-empty-notify',
27450 html : this.emptyText
27454 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27455 html : this.rotateNotify
27461 cls : 'roo-upload-cropbox-footer',
27464 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27474 onRender : function(ct, position)
27476 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27478 if (this.buttons.length) {
27480 Roo.each(this.buttons, function(bb) {
27482 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27484 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27490 this.maskEl = this.el;
27494 initEvents : function()
27496 this.urlAPI = (window.createObjectURL && window) ||
27497 (window.URL && URL.revokeObjectURL && URL) ||
27498 (window.webkitURL && webkitURL);
27500 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27501 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27503 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27504 this.selectorEl.hide();
27506 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27507 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27509 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27510 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27511 this.thumbEl.hide();
27513 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27514 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27516 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27517 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27518 this.errorEl.hide();
27520 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27521 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27522 this.footerEl.hide();
27524 this.setThumbBoxSize();
27530 this.fireEvent('initial', this);
27537 window.addEventListener("resize", function() { _this.resize(); } );
27539 this.bodyEl.on('click', this.beforeSelectFile, this);
27542 this.bodyEl.on('touchstart', this.onTouchStart, this);
27543 this.bodyEl.on('touchmove', this.onTouchMove, this);
27544 this.bodyEl.on('touchend', this.onTouchEnd, this);
27548 this.bodyEl.on('mousedown', this.onMouseDown, this);
27549 this.bodyEl.on('mousemove', this.onMouseMove, this);
27550 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27551 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27552 Roo.get(document).on('mouseup', this.onMouseUp, this);
27555 this.selectorEl.on('change', this.onFileSelected, this);
27561 this.baseScale = 1;
27563 this.baseRotate = 1;
27564 this.dragable = false;
27565 this.pinching = false;
27568 this.cropData = false;
27569 this.notifyEl.dom.innerHTML = this.emptyText;
27571 this.selectorEl.dom.value = '';
27575 resize : function()
27577 if(this.fireEvent('resize', this) != false){
27578 this.setThumbBoxPosition();
27579 this.setCanvasPosition();
27583 onFooterButtonClick : function(e, el, o, type)
27586 case 'rotate-left' :
27587 this.onRotateLeft(e);
27589 case 'rotate-right' :
27590 this.onRotateRight(e);
27593 this.beforeSelectFile(e);
27608 this.fireEvent('footerbuttonclick', this, type);
27611 beforeSelectFile : function(e)
27613 e.preventDefault();
27615 if(this.fireEvent('beforeselectfile', this) != false){
27616 this.selectorEl.dom.click();
27620 onFileSelected : function(e)
27622 e.preventDefault();
27624 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27628 var file = this.selectorEl.dom.files[0];
27630 if(this.fireEvent('inspect', this, file) != false){
27631 this.prepare(file);
27636 trash : function(e)
27638 this.fireEvent('trash', this);
27641 download : function(e)
27643 this.fireEvent('download', this);
27646 loadCanvas : function(src)
27648 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27652 this.imageEl = document.createElement('img');
27656 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27658 this.imageEl.src = src;
27662 onLoadCanvas : function()
27664 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27665 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27667 this.bodyEl.un('click', this.beforeSelectFile, this);
27669 this.notifyEl.hide();
27670 this.thumbEl.show();
27671 this.footerEl.show();
27673 this.baseRotateLevel();
27675 if(this.isDocument){
27676 this.setThumbBoxSize();
27679 this.setThumbBoxPosition();
27681 this.baseScaleLevel();
27687 this.canvasLoaded = true;
27690 this.maskEl.unmask();
27695 setCanvasPosition : function()
27697 if(!this.canvasEl){
27701 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27702 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27704 this.previewEl.setLeft(pw);
27705 this.previewEl.setTop(ph);
27709 onMouseDown : function(e)
27713 this.dragable = true;
27714 this.pinching = false;
27716 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27717 this.dragable = false;
27721 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27722 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27726 onMouseMove : function(e)
27730 if(!this.canvasLoaded){
27734 if (!this.dragable){
27738 var minX = Math.ceil(this.thumbEl.getLeft(true));
27739 var minY = Math.ceil(this.thumbEl.getTop(true));
27741 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27742 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27744 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27745 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27747 x = x - this.mouseX;
27748 y = y - this.mouseY;
27750 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27751 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27753 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27754 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27756 this.previewEl.setLeft(bgX);
27757 this.previewEl.setTop(bgY);
27759 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27760 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27763 onMouseUp : function(e)
27767 this.dragable = false;
27770 onMouseWheel : function(e)
27774 this.startScale = this.scale;
27776 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27778 if(!this.zoomable()){
27779 this.scale = this.startScale;
27788 zoomable : function()
27790 var minScale = this.thumbEl.getWidth() / this.minWidth;
27792 if(this.minWidth < this.minHeight){
27793 minScale = this.thumbEl.getHeight() / this.minHeight;
27796 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27797 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27801 (this.rotate == 0 || this.rotate == 180) &&
27803 width > this.imageEl.OriginWidth ||
27804 height > this.imageEl.OriginHeight ||
27805 (width < this.minWidth && height < this.minHeight)
27813 (this.rotate == 90 || this.rotate == 270) &&
27815 width > this.imageEl.OriginWidth ||
27816 height > this.imageEl.OriginHeight ||
27817 (width < this.minHeight && height < this.minWidth)
27824 !this.isDocument &&
27825 (this.rotate == 0 || this.rotate == 180) &&
27827 width < this.minWidth ||
27828 width > this.imageEl.OriginWidth ||
27829 height < this.minHeight ||
27830 height > this.imageEl.OriginHeight
27837 !this.isDocument &&
27838 (this.rotate == 90 || this.rotate == 270) &&
27840 width < this.minHeight ||
27841 width > this.imageEl.OriginWidth ||
27842 height < this.minWidth ||
27843 height > this.imageEl.OriginHeight
27853 onRotateLeft : function(e)
27855 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27857 var minScale = this.thumbEl.getWidth() / this.minWidth;
27859 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27860 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27862 this.startScale = this.scale;
27864 while (this.getScaleLevel() < minScale){
27866 this.scale = this.scale + 1;
27868 if(!this.zoomable()){
27873 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27874 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27879 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27886 this.scale = this.startScale;
27888 this.onRotateFail();
27893 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27895 if(this.isDocument){
27896 this.setThumbBoxSize();
27897 this.setThumbBoxPosition();
27898 this.setCanvasPosition();
27903 this.fireEvent('rotate', this, 'left');
27907 onRotateRight : function(e)
27909 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27911 var minScale = this.thumbEl.getWidth() / this.minWidth;
27913 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27914 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27916 this.startScale = this.scale;
27918 while (this.getScaleLevel() < minScale){
27920 this.scale = this.scale + 1;
27922 if(!this.zoomable()){
27927 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27928 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27933 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27940 this.scale = this.startScale;
27942 this.onRotateFail();
27947 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27949 if(this.isDocument){
27950 this.setThumbBoxSize();
27951 this.setThumbBoxPosition();
27952 this.setCanvasPosition();
27957 this.fireEvent('rotate', this, 'right');
27960 onRotateFail : function()
27962 this.errorEl.show(true);
27966 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27971 this.previewEl.dom.innerHTML = '';
27973 var canvasEl = document.createElement("canvas");
27975 var contextEl = canvasEl.getContext("2d");
27977 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27978 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27979 var center = this.imageEl.OriginWidth / 2;
27981 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27982 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27983 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27984 center = this.imageEl.OriginHeight / 2;
27987 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27989 contextEl.translate(center, center);
27990 contextEl.rotate(this.rotate * Math.PI / 180);
27992 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27994 this.canvasEl = document.createElement("canvas");
27996 this.contextEl = this.canvasEl.getContext("2d");
27998 switch (this.rotate) {
28001 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28002 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28004 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28009 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28010 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28012 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28013 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);
28017 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28022 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28023 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28025 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28026 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);
28030 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);
28035 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28036 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28038 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28039 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28043 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);
28050 this.previewEl.appendChild(this.canvasEl);
28052 this.setCanvasPosition();
28057 if(!this.canvasLoaded){
28061 var imageCanvas = document.createElement("canvas");
28063 var imageContext = imageCanvas.getContext("2d");
28065 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28066 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28068 var center = imageCanvas.width / 2;
28070 imageContext.translate(center, center);
28072 imageContext.rotate(this.rotate * Math.PI / 180);
28074 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28076 var canvas = document.createElement("canvas");
28078 var context = canvas.getContext("2d");
28080 canvas.width = this.minWidth;
28081 canvas.height = this.minHeight;
28083 switch (this.rotate) {
28086 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28087 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28089 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28090 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28092 var targetWidth = this.minWidth - 2 * x;
28093 var targetHeight = this.minHeight - 2 * y;
28097 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28098 scale = targetWidth / width;
28101 if(x > 0 && y == 0){
28102 scale = targetHeight / height;
28105 if(x > 0 && y > 0){
28106 scale = targetWidth / width;
28108 if(width < height){
28109 scale = targetHeight / height;
28113 context.scale(scale, scale);
28115 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28116 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28118 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28119 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28121 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28126 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28127 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28129 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28130 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28132 var targetWidth = this.minWidth - 2 * x;
28133 var targetHeight = this.minHeight - 2 * y;
28137 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28138 scale = targetWidth / width;
28141 if(x > 0 && y == 0){
28142 scale = targetHeight / height;
28145 if(x > 0 && y > 0){
28146 scale = targetWidth / width;
28148 if(width < height){
28149 scale = targetHeight / height;
28153 context.scale(scale, scale);
28155 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28156 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28158 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28159 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28161 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28163 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28168 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28169 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28171 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28172 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28174 var targetWidth = this.minWidth - 2 * x;
28175 var targetHeight = this.minHeight - 2 * y;
28179 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28180 scale = targetWidth / width;
28183 if(x > 0 && y == 0){
28184 scale = targetHeight / height;
28187 if(x > 0 && y > 0){
28188 scale = targetWidth / width;
28190 if(width < height){
28191 scale = targetHeight / height;
28195 context.scale(scale, scale);
28197 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28198 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28200 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28201 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28203 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28204 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28206 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28211 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28212 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28214 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28215 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28217 var targetWidth = this.minWidth - 2 * x;
28218 var targetHeight = this.minHeight - 2 * y;
28222 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28223 scale = targetWidth / width;
28226 if(x > 0 && y == 0){
28227 scale = targetHeight / height;
28230 if(x > 0 && y > 0){
28231 scale = targetWidth / width;
28233 if(width < height){
28234 scale = targetHeight / height;
28238 context.scale(scale, scale);
28240 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28241 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28243 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28244 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28246 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28248 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28255 this.cropData = canvas.toDataURL(this.cropType);
28257 if(this.fireEvent('crop', this, this.cropData) !== false){
28258 this.process(this.file, this.cropData);
28265 setThumbBoxSize : function()
28269 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28270 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28271 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28273 this.minWidth = width;
28274 this.minHeight = height;
28276 if(this.rotate == 90 || this.rotate == 270){
28277 this.minWidth = height;
28278 this.minHeight = width;
28283 width = Math.ceil(this.minWidth * height / this.minHeight);
28285 if(this.minWidth > this.minHeight){
28287 height = Math.ceil(this.minHeight * width / this.minWidth);
28290 this.thumbEl.setStyle({
28291 width : width + 'px',
28292 height : height + 'px'
28299 setThumbBoxPosition : function()
28301 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28302 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28304 this.thumbEl.setLeft(x);
28305 this.thumbEl.setTop(y);
28309 baseRotateLevel : function()
28311 this.baseRotate = 1;
28314 typeof(this.exif) != 'undefined' &&
28315 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28316 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28318 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28321 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28325 baseScaleLevel : function()
28329 if(this.isDocument){
28331 if(this.baseRotate == 6 || this.baseRotate == 8){
28333 height = this.thumbEl.getHeight();
28334 this.baseScale = height / this.imageEl.OriginWidth;
28336 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28337 width = this.thumbEl.getWidth();
28338 this.baseScale = width / this.imageEl.OriginHeight;
28344 height = this.thumbEl.getHeight();
28345 this.baseScale = height / this.imageEl.OriginHeight;
28347 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28348 width = this.thumbEl.getWidth();
28349 this.baseScale = width / this.imageEl.OriginWidth;
28355 if(this.baseRotate == 6 || this.baseRotate == 8){
28357 width = this.thumbEl.getHeight();
28358 this.baseScale = width / this.imageEl.OriginHeight;
28360 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28361 height = this.thumbEl.getWidth();
28362 this.baseScale = height / this.imageEl.OriginHeight;
28365 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28366 height = this.thumbEl.getWidth();
28367 this.baseScale = height / this.imageEl.OriginHeight;
28369 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28370 width = this.thumbEl.getHeight();
28371 this.baseScale = width / this.imageEl.OriginWidth;
28378 width = this.thumbEl.getWidth();
28379 this.baseScale = width / this.imageEl.OriginWidth;
28381 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28382 height = this.thumbEl.getHeight();
28383 this.baseScale = height / this.imageEl.OriginHeight;
28386 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28388 height = this.thumbEl.getHeight();
28389 this.baseScale = height / this.imageEl.OriginHeight;
28391 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28392 width = this.thumbEl.getWidth();
28393 this.baseScale = width / this.imageEl.OriginWidth;
28401 getScaleLevel : function()
28403 return this.baseScale * Math.pow(1.1, this.scale);
28406 onTouchStart : function(e)
28408 if(!this.canvasLoaded){
28409 this.beforeSelectFile(e);
28413 var touches = e.browserEvent.touches;
28419 if(touches.length == 1){
28420 this.onMouseDown(e);
28424 if(touches.length != 2){
28430 for(var i = 0, finger; finger = touches[i]; i++){
28431 coords.push(finger.pageX, finger.pageY);
28434 var x = Math.pow(coords[0] - coords[2], 2);
28435 var y = Math.pow(coords[1] - coords[3], 2);
28437 this.startDistance = Math.sqrt(x + y);
28439 this.startScale = this.scale;
28441 this.pinching = true;
28442 this.dragable = false;
28446 onTouchMove : function(e)
28448 if(!this.pinching && !this.dragable){
28452 var touches = e.browserEvent.touches;
28459 this.onMouseMove(e);
28465 for(var i = 0, finger; finger = touches[i]; i++){
28466 coords.push(finger.pageX, finger.pageY);
28469 var x = Math.pow(coords[0] - coords[2], 2);
28470 var y = Math.pow(coords[1] - coords[3], 2);
28472 this.endDistance = Math.sqrt(x + y);
28474 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28476 if(!this.zoomable()){
28477 this.scale = this.startScale;
28485 onTouchEnd : function(e)
28487 this.pinching = false;
28488 this.dragable = false;
28492 process : function(file, crop)
28495 this.maskEl.mask(this.loadingText);
28498 this.xhr = new XMLHttpRequest();
28500 file.xhr = this.xhr;
28502 this.xhr.open(this.method, this.url, true);
28505 "Accept": "application/json",
28506 "Cache-Control": "no-cache",
28507 "X-Requested-With": "XMLHttpRequest"
28510 for (var headerName in headers) {
28511 var headerValue = headers[headerName];
28513 this.xhr.setRequestHeader(headerName, headerValue);
28519 this.xhr.onload = function()
28521 _this.xhrOnLoad(_this.xhr);
28524 this.xhr.onerror = function()
28526 _this.xhrOnError(_this.xhr);
28529 var formData = new FormData();
28531 formData.append('returnHTML', 'NO');
28534 formData.append('crop', crop);
28537 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28538 formData.append(this.paramName, file, file.name);
28541 if(typeof(file.filename) != 'undefined'){
28542 formData.append('filename', file.filename);
28545 if(typeof(file.mimetype) != 'undefined'){
28546 formData.append('mimetype', file.mimetype);
28549 if(this.fireEvent('arrange', this, formData) != false){
28550 this.xhr.send(formData);
28554 xhrOnLoad : function(xhr)
28557 this.maskEl.unmask();
28560 if (xhr.readyState !== 4) {
28561 this.fireEvent('exception', this, xhr);
28565 var response = Roo.decode(xhr.responseText);
28567 if(!response.success){
28568 this.fireEvent('exception', this, xhr);
28572 var response = Roo.decode(xhr.responseText);
28574 this.fireEvent('upload', this, response);
28578 xhrOnError : function()
28581 this.maskEl.unmask();
28584 Roo.log('xhr on error');
28586 var response = Roo.decode(xhr.responseText);
28592 prepare : function(file)
28595 this.maskEl.mask(this.loadingText);
28601 if(typeof(file) === 'string'){
28602 this.loadCanvas(file);
28606 if(!file || !this.urlAPI){
28611 this.cropType = file.type;
28615 if(this.fireEvent('prepare', this, this.file) != false){
28617 var reader = new FileReader();
28619 reader.onload = function (e) {
28620 if (e.target.error) {
28621 Roo.log(e.target.error);
28625 var buffer = e.target.result,
28626 dataView = new DataView(buffer),
28628 maxOffset = dataView.byteLength - 4,
28632 if (dataView.getUint16(0) === 0xffd8) {
28633 while (offset < maxOffset) {
28634 markerBytes = dataView.getUint16(offset);
28636 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28637 markerLength = dataView.getUint16(offset + 2) + 2;
28638 if (offset + markerLength > dataView.byteLength) {
28639 Roo.log('Invalid meta data: Invalid segment size.');
28643 if(markerBytes == 0xffe1){
28644 _this.parseExifData(
28651 offset += markerLength;
28661 var url = _this.urlAPI.createObjectURL(_this.file);
28663 _this.loadCanvas(url);
28668 reader.readAsArrayBuffer(this.file);
28674 parseExifData : function(dataView, offset, length)
28676 var tiffOffset = offset + 10,
28680 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28681 // No Exif data, might be XMP data instead
28685 // Check for the ASCII code for "Exif" (0x45786966):
28686 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28687 // No Exif data, might be XMP data instead
28690 if (tiffOffset + 8 > dataView.byteLength) {
28691 Roo.log('Invalid Exif data: Invalid segment size.');
28694 // Check for the two null bytes:
28695 if (dataView.getUint16(offset + 8) !== 0x0000) {
28696 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28699 // Check the byte alignment:
28700 switch (dataView.getUint16(tiffOffset)) {
28702 littleEndian = true;
28705 littleEndian = false;
28708 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28711 // Check for the TIFF tag marker (0x002A):
28712 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28713 Roo.log('Invalid Exif data: Missing TIFF marker.');
28716 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28717 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28719 this.parseExifTags(
28722 tiffOffset + dirOffset,
28727 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28732 if (dirOffset + 6 > dataView.byteLength) {
28733 Roo.log('Invalid Exif data: Invalid directory offset.');
28736 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28737 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28738 if (dirEndOffset + 4 > dataView.byteLength) {
28739 Roo.log('Invalid Exif data: Invalid directory size.');
28742 for (i = 0; i < tagsNumber; i += 1) {
28746 dirOffset + 2 + 12 * i, // tag offset
28750 // Return the offset to the next directory:
28751 return dataView.getUint32(dirEndOffset, littleEndian);
28754 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28756 var tag = dataView.getUint16(offset, littleEndian);
28758 this.exif[tag] = this.getExifValue(
28762 dataView.getUint16(offset + 2, littleEndian), // tag type
28763 dataView.getUint32(offset + 4, littleEndian), // tag length
28768 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28770 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28779 Roo.log('Invalid Exif data: Invalid tag type.');
28783 tagSize = tagType.size * length;
28784 // Determine if the value is contained in the dataOffset bytes,
28785 // or if the value at the dataOffset is a pointer to the actual data:
28786 dataOffset = tagSize > 4 ?
28787 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28788 if (dataOffset + tagSize > dataView.byteLength) {
28789 Roo.log('Invalid Exif data: Invalid data offset.');
28792 if (length === 1) {
28793 return tagType.getValue(dataView, dataOffset, littleEndian);
28796 for (i = 0; i < length; i += 1) {
28797 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28800 if (tagType.ascii) {
28802 // Concatenate the chars:
28803 for (i = 0; i < values.length; i += 1) {
28805 // Ignore the terminating NULL byte(s):
28806 if (c === '\u0000') {
28818 Roo.apply(Roo.bootstrap.UploadCropbox, {
28820 'Orientation': 0x0112
28824 1: 0, //'top-left',
28826 3: 180, //'bottom-right',
28827 // 4: 'bottom-left',
28829 6: 90, //'right-top',
28830 // 7: 'right-bottom',
28831 8: 270 //'left-bottom'
28835 // byte, 8-bit unsigned int:
28837 getValue: function (dataView, dataOffset) {
28838 return dataView.getUint8(dataOffset);
28842 // ascii, 8-bit byte:
28844 getValue: function (dataView, dataOffset) {
28845 return String.fromCharCode(dataView.getUint8(dataOffset));
28850 // short, 16 bit int:
28852 getValue: function (dataView, dataOffset, littleEndian) {
28853 return dataView.getUint16(dataOffset, littleEndian);
28857 // long, 32 bit int:
28859 getValue: function (dataView, dataOffset, littleEndian) {
28860 return dataView.getUint32(dataOffset, littleEndian);
28864 // rational = two long values, first is numerator, second is denominator:
28866 getValue: function (dataView, dataOffset, littleEndian) {
28867 return dataView.getUint32(dataOffset, littleEndian) /
28868 dataView.getUint32(dataOffset + 4, littleEndian);
28872 // slong, 32 bit signed int:
28874 getValue: function (dataView, dataOffset, littleEndian) {
28875 return dataView.getInt32(dataOffset, littleEndian);
28879 // srational, two slongs, first is numerator, second is denominator:
28881 getValue: function (dataView, dataOffset, littleEndian) {
28882 return dataView.getInt32(dataOffset, littleEndian) /
28883 dataView.getInt32(dataOffset + 4, littleEndian);
28893 cls : 'btn-group roo-upload-cropbox-rotate-left',
28894 action : 'rotate-left',
28898 cls : 'btn btn-default',
28899 html : '<i class="fa fa-undo"></i>'
28905 cls : 'btn-group roo-upload-cropbox-picture',
28906 action : 'picture',
28910 cls : 'btn btn-default',
28911 html : '<i class="fa fa-picture-o"></i>'
28917 cls : 'btn-group roo-upload-cropbox-rotate-right',
28918 action : 'rotate-right',
28922 cls : 'btn btn-default',
28923 html : '<i class="fa fa-repeat"></i>'
28931 cls : 'btn-group roo-upload-cropbox-rotate-left',
28932 action : 'rotate-left',
28936 cls : 'btn btn-default',
28937 html : '<i class="fa fa-undo"></i>'
28943 cls : 'btn-group roo-upload-cropbox-download',
28944 action : 'download',
28948 cls : 'btn btn-default',
28949 html : '<i class="fa fa-download"></i>'
28955 cls : 'btn-group roo-upload-cropbox-crop',
28960 cls : 'btn btn-default',
28961 html : '<i class="fa fa-crop"></i>'
28967 cls : 'btn-group roo-upload-cropbox-trash',
28972 cls : 'btn btn-default',
28973 html : '<i class="fa fa-trash"></i>'
28979 cls : 'btn-group roo-upload-cropbox-rotate-right',
28980 action : 'rotate-right',
28984 cls : 'btn btn-default',
28985 html : '<i class="fa fa-repeat"></i>'
28993 cls : 'btn-group roo-upload-cropbox-rotate-left',
28994 action : 'rotate-left',
28998 cls : 'btn btn-default',
28999 html : '<i class="fa fa-undo"></i>'
29005 cls : 'btn-group roo-upload-cropbox-rotate-right',
29006 action : 'rotate-right',
29010 cls : 'btn btn-default',
29011 html : '<i class="fa fa-repeat"></i>'
29024 * @class Roo.bootstrap.DocumentManager
29025 * @extends Roo.bootstrap.Component
29026 * Bootstrap DocumentManager class
29027 * @cfg {String} paramName default 'imageUpload'
29028 * @cfg {String} toolTipName default 'filename'
29029 * @cfg {String} method default POST
29030 * @cfg {String} url action url
29031 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29032 * @cfg {Boolean} multiple multiple upload default true
29033 * @cfg {Number} thumbSize default 300
29034 * @cfg {String} fieldLabel
29035 * @cfg {Number} labelWidth default 4
29036 * @cfg {String} labelAlign (left|top) default left
29037 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29038 * @cfg {Number} labellg set the width of label (1-12)
29039 * @cfg {Number} labelmd set the width of label (1-12)
29040 * @cfg {Number} labelsm set the width of label (1-12)
29041 * @cfg {Number} labelxs set the width of label (1-12)
29044 * Create a new DocumentManager
29045 * @param {Object} config The config object
29048 Roo.bootstrap.DocumentManager = function(config){
29049 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29052 this.delegates = [];
29057 * Fire when initial the DocumentManager
29058 * @param {Roo.bootstrap.DocumentManager} this
29063 * inspect selected file
29064 * @param {Roo.bootstrap.DocumentManager} this
29065 * @param {File} file
29070 * Fire when xhr load exception
29071 * @param {Roo.bootstrap.DocumentManager} this
29072 * @param {XMLHttpRequest} xhr
29074 "exception" : true,
29076 * @event afterupload
29077 * Fire when xhr load exception
29078 * @param {Roo.bootstrap.DocumentManager} this
29079 * @param {XMLHttpRequest} xhr
29081 "afterupload" : true,
29084 * prepare the form data
29085 * @param {Roo.bootstrap.DocumentManager} this
29086 * @param {Object} formData
29091 * Fire when remove the file
29092 * @param {Roo.bootstrap.DocumentManager} this
29093 * @param {Object} file
29098 * Fire after refresh the file
29099 * @param {Roo.bootstrap.DocumentManager} this
29104 * Fire after click the image
29105 * @param {Roo.bootstrap.DocumentManager} this
29106 * @param {Object} file
29111 * Fire when upload a image and editable set to true
29112 * @param {Roo.bootstrap.DocumentManager} this
29113 * @param {Object} file
29117 * @event beforeselectfile
29118 * Fire before select file
29119 * @param {Roo.bootstrap.DocumentManager} this
29121 "beforeselectfile" : true,
29124 * Fire before process file
29125 * @param {Roo.bootstrap.DocumentManager} this
29126 * @param {Object} file
29130 * @event previewrendered
29131 * Fire when preview rendered
29132 * @param {Roo.bootstrap.DocumentManager} this
29133 * @param {Object} file
29135 "previewrendered" : true,
29138 "previewResize" : true
29143 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29152 paramName : 'imageUpload',
29153 toolTipName : 'filename',
29156 labelAlign : 'left',
29166 getAutoCreate : function()
29168 var managerWidget = {
29170 cls : 'roo-document-manager',
29174 cls : 'roo-document-manager-selector',
29179 cls : 'roo-document-manager-uploader',
29183 cls : 'roo-document-manager-upload-btn',
29184 html : '<i class="fa fa-plus"></i>'
29195 cls : 'column col-md-12',
29200 if(this.fieldLabel.length){
29205 cls : 'column col-md-12',
29206 html : this.fieldLabel
29210 cls : 'column col-md-12',
29215 if(this.labelAlign == 'left'){
29220 html : this.fieldLabel
29229 if(this.labelWidth > 12){
29230 content[0].style = "width: " + this.labelWidth + 'px';
29233 if(this.labelWidth < 13 && this.labelmd == 0){
29234 this.labelmd = this.labelWidth;
29237 if(this.labellg > 0){
29238 content[0].cls += ' col-lg-' + this.labellg;
29239 content[1].cls += ' col-lg-' + (12 - this.labellg);
29242 if(this.labelmd > 0){
29243 content[0].cls += ' col-md-' + this.labelmd;
29244 content[1].cls += ' col-md-' + (12 - this.labelmd);
29247 if(this.labelsm > 0){
29248 content[0].cls += ' col-sm-' + this.labelsm;
29249 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29252 if(this.labelxs > 0){
29253 content[0].cls += ' col-xs-' + this.labelxs;
29254 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29262 cls : 'row clearfix',
29270 initEvents : function()
29272 this.managerEl = this.el.select('.roo-document-manager', true).first();
29273 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29275 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29276 this.selectorEl.hide();
29279 this.selectorEl.attr('multiple', 'multiple');
29282 this.selectorEl.on('change', this.onFileSelected, this);
29284 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29285 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29287 this.uploader.on('click', this.onUploaderClick, this);
29289 this.renderProgressDialog();
29293 window.addEventListener("resize", function() { _this.refresh(); } );
29295 this.fireEvent('initial', this);
29298 renderProgressDialog : function()
29302 this.progressDialog = new Roo.bootstrap.Modal({
29303 cls : 'roo-document-manager-progress-dialog',
29304 allow_close : false,
29315 btnclick : function() {
29316 _this.uploadCancel();
29322 this.progressDialog.render(Roo.get(document.body));
29324 this.progress = new Roo.bootstrap.Progress({
29325 cls : 'roo-document-manager-progress',
29330 this.progress.render(this.progressDialog.getChildContainer());
29332 this.progressBar = new Roo.bootstrap.ProgressBar({
29333 cls : 'roo-document-manager-progress-bar',
29336 aria_valuemax : 12,
29340 this.progressBar.render(this.progress.getChildContainer());
29343 onUploaderClick : function(e)
29345 e.preventDefault();
29347 if(this.fireEvent('beforeselectfile', this) != false){
29348 this.selectorEl.dom.click();
29353 onFileSelected : function(e)
29355 e.preventDefault();
29357 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29361 Roo.each(this.selectorEl.dom.files, function(file){
29362 if(this.fireEvent('inspect', this, file) != false){
29363 this.files.push(file);
29373 this.selectorEl.dom.value = '';
29375 if(!this.files || !this.files.length){
29379 if(this.boxes > 0 && this.files.length > this.boxes){
29380 this.files = this.files.slice(0, this.boxes);
29383 this.uploader.show();
29385 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29386 this.uploader.hide();
29395 Roo.each(this.files, function(file){
29397 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29398 var f = this.renderPreview(file);
29403 if(file.type.indexOf('image') != -1){
29404 this.delegates.push(
29406 _this.process(file);
29407 }).createDelegate(this)
29415 _this.process(file);
29416 }).createDelegate(this)
29421 this.files = files;
29423 this.delegates = this.delegates.concat(docs);
29425 if(!this.delegates.length){
29430 this.progressBar.aria_valuemax = this.delegates.length;
29437 arrange : function()
29439 if(!this.delegates.length){
29440 this.progressDialog.hide();
29445 var delegate = this.delegates.shift();
29447 this.progressDialog.show();
29449 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29451 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29456 refresh : function()
29458 this.uploader.show();
29460 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29461 this.uploader.hide();
29464 Roo.isTouch ? this.closable(false) : this.closable(true);
29466 this.fireEvent('refresh', this);
29469 onRemove : function(e, el, o)
29471 e.preventDefault();
29473 this.fireEvent('remove', this, o);
29477 remove : function(o)
29481 Roo.each(this.files, function(file){
29482 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29491 this.files = files;
29498 Roo.each(this.files, function(file){
29503 file.target.remove();
29512 onClick : function(e, el, o)
29514 e.preventDefault();
29516 this.fireEvent('click', this, o);
29520 closable : function(closable)
29522 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29524 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29536 xhrOnLoad : function(xhr)
29538 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29542 if (xhr.readyState !== 4) {
29544 this.fireEvent('exception', this, xhr);
29548 var response = Roo.decode(xhr.responseText);
29550 if(!response.success){
29552 this.fireEvent('exception', this, xhr);
29556 var file = this.renderPreview(response.data);
29558 this.files.push(file);
29562 this.fireEvent('afterupload', this, xhr);
29566 xhrOnError : function(xhr)
29568 Roo.log('xhr on error');
29570 var response = Roo.decode(xhr.responseText);
29577 process : function(file)
29579 if(this.fireEvent('process', this, file) !== false){
29580 if(this.editable && file.type.indexOf('image') != -1){
29581 this.fireEvent('edit', this, file);
29585 this.uploadStart(file, false);
29592 uploadStart : function(file, crop)
29594 this.xhr = new XMLHttpRequest();
29596 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29601 file.xhr = this.xhr;
29603 this.managerEl.createChild({
29605 cls : 'roo-document-manager-loading',
29609 tooltip : file.name,
29610 cls : 'roo-document-manager-thumb',
29611 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29617 this.xhr.open(this.method, this.url, true);
29620 "Accept": "application/json",
29621 "Cache-Control": "no-cache",
29622 "X-Requested-With": "XMLHttpRequest"
29625 for (var headerName in headers) {
29626 var headerValue = headers[headerName];
29628 this.xhr.setRequestHeader(headerName, headerValue);
29634 this.xhr.onload = function()
29636 _this.xhrOnLoad(_this.xhr);
29639 this.xhr.onerror = function()
29641 _this.xhrOnError(_this.xhr);
29644 var formData = new FormData();
29646 formData.append('returnHTML', 'NO');
29649 formData.append('crop', crop);
29652 formData.append(this.paramName, file, file.name);
29659 if(this.fireEvent('prepare', this, formData, options) != false){
29661 if(options.manually){
29665 this.xhr.send(formData);
29669 this.uploadCancel();
29672 uploadCancel : function()
29678 this.delegates = [];
29680 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29687 renderPreview : function(file)
29689 if(typeof(file.target) != 'undefined' && file.target){
29693 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29695 var previewEl = this.managerEl.createChild({
29697 cls : 'roo-document-manager-preview',
29701 tooltip : file[this.toolTipName],
29702 cls : 'roo-document-manager-thumb',
29703 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29708 html : '<i class="fa fa-times-circle"></i>'
29713 var close = previewEl.select('button.close', true).first();
29715 close.on('click', this.onRemove, this, file);
29717 file.target = previewEl;
29719 var image = previewEl.select('img', true).first();
29723 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29725 image.on('click', this.onClick, this, file);
29727 this.fireEvent('previewrendered', this, file);
29733 onPreviewLoad : function(file, image)
29735 if(typeof(file.target) == 'undefined' || !file.target){
29739 var width = image.dom.naturalWidth || image.dom.width;
29740 var height = image.dom.naturalHeight || image.dom.height;
29742 if(!this.previewResize) {
29746 if(width > height){
29747 file.target.addClass('wide');
29751 file.target.addClass('tall');
29756 uploadFromSource : function(file, crop)
29758 this.xhr = new XMLHttpRequest();
29760 this.managerEl.createChild({
29762 cls : 'roo-document-manager-loading',
29766 tooltip : file.name,
29767 cls : 'roo-document-manager-thumb',
29768 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29774 this.xhr.open(this.method, this.url, true);
29777 "Accept": "application/json",
29778 "Cache-Control": "no-cache",
29779 "X-Requested-With": "XMLHttpRequest"
29782 for (var headerName in headers) {
29783 var headerValue = headers[headerName];
29785 this.xhr.setRequestHeader(headerName, headerValue);
29791 this.xhr.onload = function()
29793 _this.xhrOnLoad(_this.xhr);
29796 this.xhr.onerror = function()
29798 _this.xhrOnError(_this.xhr);
29801 var formData = new FormData();
29803 formData.append('returnHTML', 'NO');
29805 formData.append('crop', crop);
29807 if(typeof(file.filename) != 'undefined'){
29808 formData.append('filename', file.filename);
29811 if(typeof(file.mimetype) != 'undefined'){
29812 formData.append('mimetype', file.mimetype);
29817 if(this.fireEvent('prepare', this, formData) != false){
29818 this.xhr.send(formData);
29828 * @class Roo.bootstrap.DocumentViewer
29829 * @extends Roo.bootstrap.Component
29830 * Bootstrap DocumentViewer class
29831 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29832 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29835 * Create a new DocumentViewer
29836 * @param {Object} config The config object
29839 Roo.bootstrap.DocumentViewer = function(config){
29840 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29845 * Fire after initEvent
29846 * @param {Roo.bootstrap.DocumentViewer} this
29852 * @param {Roo.bootstrap.DocumentViewer} this
29857 * Fire after download button
29858 * @param {Roo.bootstrap.DocumentViewer} this
29863 * Fire after trash button
29864 * @param {Roo.bootstrap.DocumentViewer} this
29871 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29873 showDownload : true,
29877 getAutoCreate : function()
29881 cls : 'roo-document-viewer',
29885 cls : 'roo-document-viewer-body',
29889 cls : 'roo-document-viewer-thumb',
29893 cls : 'roo-document-viewer-image'
29901 cls : 'roo-document-viewer-footer',
29904 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29908 cls : 'btn-group roo-document-viewer-download',
29912 cls : 'btn btn-default',
29913 html : '<i class="fa fa-download"></i>'
29919 cls : 'btn-group roo-document-viewer-trash',
29923 cls : 'btn btn-default',
29924 html : '<i class="fa fa-trash"></i>'
29937 initEvents : function()
29939 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29940 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29942 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29943 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29945 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29946 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29948 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29949 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29951 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29952 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29954 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29955 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29957 this.bodyEl.on('click', this.onClick, this);
29958 this.downloadBtn.on('click', this.onDownload, this);
29959 this.trashBtn.on('click', this.onTrash, this);
29961 this.downloadBtn.hide();
29962 this.trashBtn.hide();
29964 if(this.showDownload){
29965 this.downloadBtn.show();
29968 if(this.showTrash){
29969 this.trashBtn.show();
29972 if(!this.showDownload && !this.showTrash) {
29973 this.footerEl.hide();
29978 initial : function()
29980 this.fireEvent('initial', this);
29984 onClick : function(e)
29986 e.preventDefault();
29988 this.fireEvent('click', this);
29991 onDownload : function(e)
29993 e.preventDefault();
29995 this.fireEvent('download', this);
29998 onTrash : function(e)
30000 e.preventDefault();
30002 this.fireEvent('trash', this);
30014 * @class Roo.bootstrap.NavProgressBar
30015 * @extends Roo.bootstrap.Component
30016 * Bootstrap NavProgressBar class
30019 * Create a new nav progress bar
30020 * @param {Object} config The config object
30023 Roo.bootstrap.NavProgressBar = function(config){
30024 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30026 this.bullets = this.bullets || [];
30028 // Roo.bootstrap.NavProgressBar.register(this);
30032 * Fires when the active item changes
30033 * @param {Roo.bootstrap.NavProgressBar} this
30034 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30035 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30042 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30047 getAutoCreate : function()
30049 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30053 cls : 'roo-navigation-bar-group',
30057 cls : 'roo-navigation-top-bar'
30061 cls : 'roo-navigation-bullets-bar',
30065 cls : 'roo-navigation-bar'
30072 cls : 'roo-navigation-bottom-bar'
30082 initEvents: function()
30087 onRender : function(ct, position)
30089 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30091 if(this.bullets.length){
30092 Roo.each(this.bullets, function(b){
30101 addItem : function(cfg)
30103 var item = new Roo.bootstrap.NavProgressItem(cfg);
30105 item.parentId = this.id;
30106 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30109 var top = new Roo.bootstrap.Element({
30111 cls : 'roo-navigation-bar-text'
30114 var bottom = new Roo.bootstrap.Element({
30116 cls : 'roo-navigation-bar-text'
30119 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30120 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30122 var topText = new Roo.bootstrap.Element({
30124 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30127 var bottomText = new Roo.bootstrap.Element({
30129 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30132 topText.onRender(top.el, null);
30133 bottomText.onRender(bottom.el, null);
30136 item.bottomEl = bottom;
30139 this.barItems.push(item);
30144 getActive : function()
30146 var active = false;
30148 Roo.each(this.barItems, function(v){
30150 if (!v.isActive()) {
30162 setActiveItem : function(item)
30166 Roo.each(this.barItems, function(v){
30167 if (v.rid == item.rid) {
30171 if (v.isActive()) {
30172 v.setActive(false);
30177 item.setActive(true);
30179 this.fireEvent('changed', this, item, prev);
30182 getBarItem: function(rid)
30186 Roo.each(this.barItems, function(e) {
30187 if (e.rid != rid) {
30198 indexOfItem : function(item)
30202 Roo.each(this.barItems, function(v, i){
30204 if (v.rid != item.rid) {
30215 setActiveNext : function()
30217 var i = this.indexOfItem(this.getActive());
30219 if (i > this.barItems.length) {
30223 this.setActiveItem(this.barItems[i+1]);
30226 setActivePrev : function()
30228 var i = this.indexOfItem(this.getActive());
30234 this.setActiveItem(this.barItems[i-1]);
30237 format : function()
30239 if(!this.barItems.length){
30243 var width = 100 / this.barItems.length;
30245 Roo.each(this.barItems, function(i){
30246 i.el.setStyle('width', width + '%');
30247 i.topEl.el.setStyle('width', width + '%');
30248 i.bottomEl.el.setStyle('width', width + '%');
30257 * Nav Progress Item
30262 * @class Roo.bootstrap.NavProgressItem
30263 * @extends Roo.bootstrap.Component
30264 * Bootstrap NavProgressItem class
30265 * @cfg {String} rid the reference id
30266 * @cfg {Boolean} active (true|false) Is item active default false
30267 * @cfg {Boolean} disabled (true|false) Is item active default false
30268 * @cfg {String} html
30269 * @cfg {String} position (top|bottom) text position default bottom
30270 * @cfg {String} icon show icon instead of number
30273 * Create a new NavProgressItem
30274 * @param {Object} config The config object
30276 Roo.bootstrap.NavProgressItem = function(config){
30277 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30282 * The raw click event for the entire grid.
30283 * @param {Roo.bootstrap.NavProgressItem} this
30284 * @param {Roo.EventObject} e
30291 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30297 position : 'bottom',
30300 getAutoCreate : function()
30302 var iconCls = 'roo-navigation-bar-item-icon';
30304 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30308 cls: 'roo-navigation-bar-item',
30318 cfg.cls += ' active';
30321 cfg.cls += ' disabled';
30327 disable : function()
30329 this.setDisabled(true);
30332 enable : function()
30334 this.setDisabled(false);
30337 initEvents: function()
30339 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30341 this.iconEl.on('click', this.onClick, this);
30344 onClick : function(e)
30346 e.preventDefault();
30352 if(this.fireEvent('click', this, e) === false){
30356 this.parent().setActiveItem(this);
30359 isActive: function ()
30361 return this.active;
30364 setActive : function(state)
30366 if(this.active == state){
30370 this.active = state;
30373 this.el.addClass('active');
30377 this.el.removeClass('active');
30382 setDisabled : function(state)
30384 if(this.disabled == state){
30388 this.disabled = state;
30391 this.el.addClass('disabled');
30395 this.el.removeClass('disabled');
30398 tooltipEl : function()
30400 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30413 * @class Roo.bootstrap.FieldLabel
30414 * @extends Roo.bootstrap.Component
30415 * Bootstrap FieldLabel class
30416 * @cfg {String} html contents of the element
30417 * @cfg {String} tag tag of the element default label
30418 * @cfg {String} cls class of the element
30419 * @cfg {String} target label target
30420 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30421 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30422 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30423 * @cfg {String} iconTooltip default "This field is required"
30424 * @cfg {String} indicatorpos (left|right) default left
30427 * Create a new FieldLabel
30428 * @param {Object} config The config object
30431 Roo.bootstrap.FieldLabel = function(config){
30432 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30437 * Fires after the field has been marked as invalid.
30438 * @param {Roo.form.FieldLabel} this
30439 * @param {String} msg The validation message
30444 * Fires after the field has been validated with no errors.
30445 * @param {Roo.form.FieldLabel} this
30451 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30458 invalidClass : 'has-warning',
30459 validClass : 'has-success',
30460 iconTooltip : 'This field is required',
30461 indicatorpos : 'left',
30463 getAutoCreate : function(){
30466 if (!this.allowBlank) {
30472 cls : 'roo-bootstrap-field-label ' + this.cls,
30477 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30478 tooltip : this.iconTooltip
30487 if(this.indicatorpos == 'right'){
30490 cls : 'roo-bootstrap-field-label ' + this.cls,
30499 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30500 tooltip : this.iconTooltip
30509 initEvents: function()
30511 Roo.bootstrap.Element.superclass.initEvents.call(this);
30513 this.indicator = this.indicatorEl();
30515 if(this.indicator){
30516 this.indicator.removeClass('visible');
30517 this.indicator.addClass('invisible');
30520 Roo.bootstrap.FieldLabel.register(this);
30523 indicatorEl : function()
30525 var indicator = this.el.select('i.roo-required-indicator',true).first();
30536 * Mark this field as valid
30538 markValid : function()
30540 if(this.indicator){
30541 this.indicator.removeClass('visible');
30542 this.indicator.addClass('invisible');
30544 if (Roo.bootstrap.version == 3) {
30545 this.el.removeClass(this.invalidClass);
30546 this.el.addClass(this.validClass);
30548 this.el.removeClass('is-invalid');
30549 this.el.addClass('is-valid');
30553 this.fireEvent('valid', this);
30557 * Mark this field as invalid
30558 * @param {String} msg The validation message
30560 markInvalid : function(msg)
30562 if(this.indicator){
30563 this.indicator.removeClass('invisible');
30564 this.indicator.addClass('visible');
30566 if (Roo.bootstrap.version == 3) {
30567 this.el.removeClass(this.validClass);
30568 this.el.addClass(this.invalidClass);
30570 this.el.removeClass('is-valid');
30571 this.el.addClass('is-invalid');
30575 this.fireEvent('invalid', this, msg);
30581 Roo.apply(Roo.bootstrap.FieldLabel, {
30586 * register a FieldLabel Group
30587 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30589 register : function(label)
30591 if(this.groups.hasOwnProperty(label.target)){
30595 this.groups[label.target] = label;
30599 * fetch a FieldLabel Group based on the target
30600 * @param {string} target
30601 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30603 get: function(target) {
30604 if (typeof(this.groups[target]) == 'undefined') {
30608 return this.groups[target] ;
30617 * page DateSplitField.
30623 * @class Roo.bootstrap.DateSplitField
30624 * @extends Roo.bootstrap.Component
30625 * Bootstrap DateSplitField class
30626 * @cfg {string} fieldLabel - the label associated
30627 * @cfg {Number} labelWidth set the width of label (0-12)
30628 * @cfg {String} labelAlign (top|left)
30629 * @cfg {Boolean} dayAllowBlank (true|false) default false
30630 * @cfg {Boolean} monthAllowBlank (true|false) default false
30631 * @cfg {Boolean} yearAllowBlank (true|false) default false
30632 * @cfg {string} dayPlaceholder
30633 * @cfg {string} monthPlaceholder
30634 * @cfg {string} yearPlaceholder
30635 * @cfg {string} dayFormat default 'd'
30636 * @cfg {string} monthFormat default 'm'
30637 * @cfg {string} yearFormat default 'Y'
30638 * @cfg {Number} labellg set the width of label (1-12)
30639 * @cfg {Number} labelmd set the width of label (1-12)
30640 * @cfg {Number} labelsm set the width of label (1-12)
30641 * @cfg {Number} labelxs set the width of label (1-12)
30645 * Create a new DateSplitField
30646 * @param {Object} config The config object
30649 Roo.bootstrap.DateSplitField = function(config){
30650 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30656 * getting the data of years
30657 * @param {Roo.bootstrap.DateSplitField} this
30658 * @param {Object} years
30663 * getting the data of days
30664 * @param {Roo.bootstrap.DateSplitField} this
30665 * @param {Object} days
30670 * Fires after the field has been marked as invalid.
30671 * @param {Roo.form.Field} this
30672 * @param {String} msg The validation message
30677 * Fires after the field has been validated with no errors.
30678 * @param {Roo.form.Field} this
30684 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30687 labelAlign : 'top',
30689 dayAllowBlank : false,
30690 monthAllowBlank : false,
30691 yearAllowBlank : false,
30692 dayPlaceholder : '',
30693 monthPlaceholder : '',
30694 yearPlaceholder : '',
30698 isFormField : true,
30704 getAutoCreate : function()
30708 cls : 'row roo-date-split-field-group',
30713 cls : 'form-hidden-field roo-date-split-field-group-value',
30719 var labelCls = 'col-md-12';
30720 var contentCls = 'col-md-4';
30722 if(this.fieldLabel){
30726 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30730 html : this.fieldLabel
30735 if(this.labelAlign == 'left'){
30737 if(this.labelWidth > 12){
30738 label.style = "width: " + this.labelWidth + 'px';
30741 if(this.labelWidth < 13 && this.labelmd == 0){
30742 this.labelmd = this.labelWidth;
30745 if(this.labellg > 0){
30746 labelCls = ' col-lg-' + this.labellg;
30747 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30750 if(this.labelmd > 0){
30751 labelCls = ' col-md-' + this.labelmd;
30752 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30755 if(this.labelsm > 0){
30756 labelCls = ' col-sm-' + this.labelsm;
30757 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30760 if(this.labelxs > 0){
30761 labelCls = ' col-xs-' + this.labelxs;
30762 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30766 label.cls += ' ' + labelCls;
30768 cfg.cn.push(label);
30771 Roo.each(['day', 'month', 'year'], function(t){
30774 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30781 inputEl: function ()
30783 return this.el.select('.roo-date-split-field-group-value', true).first();
30786 onRender : function(ct, position)
30790 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30792 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30794 this.dayField = new Roo.bootstrap.ComboBox({
30795 allowBlank : this.dayAllowBlank,
30796 alwaysQuery : true,
30797 displayField : 'value',
30800 forceSelection : true,
30802 placeholder : this.dayPlaceholder,
30803 selectOnFocus : true,
30804 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30805 triggerAction : 'all',
30807 valueField : 'value',
30808 store : new Roo.data.SimpleStore({
30809 data : (function() {
30811 _this.fireEvent('days', _this, days);
30814 fields : [ 'value' ]
30817 select : function (_self, record, index)
30819 _this.setValue(_this.getValue());
30824 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30826 this.monthField = new Roo.bootstrap.MonthField({
30827 after : '<i class=\"fa fa-calendar\"></i>',
30828 allowBlank : this.monthAllowBlank,
30829 placeholder : this.monthPlaceholder,
30832 render : function (_self)
30834 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30835 e.preventDefault();
30839 select : function (_self, oldvalue, newvalue)
30841 _this.setValue(_this.getValue());
30846 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30848 this.yearField = new Roo.bootstrap.ComboBox({
30849 allowBlank : this.yearAllowBlank,
30850 alwaysQuery : true,
30851 displayField : 'value',
30854 forceSelection : true,
30856 placeholder : this.yearPlaceholder,
30857 selectOnFocus : true,
30858 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30859 triggerAction : 'all',
30861 valueField : 'value',
30862 store : new Roo.data.SimpleStore({
30863 data : (function() {
30865 _this.fireEvent('years', _this, years);
30868 fields : [ 'value' ]
30871 select : function (_self, record, index)
30873 _this.setValue(_this.getValue());
30878 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30881 setValue : function(v, format)
30883 this.inputEl.dom.value = v;
30885 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30887 var d = Date.parseDate(v, f);
30894 this.setDay(d.format(this.dayFormat));
30895 this.setMonth(d.format(this.monthFormat));
30896 this.setYear(d.format(this.yearFormat));
30903 setDay : function(v)
30905 this.dayField.setValue(v);
30906 this.inputEl.dom.value = this.getValue();
30911 setMonth : function(v)
30913 this.monthField.setValue(v, true);
30914 this.inputEl.dom.value = this.getValue();
30919 setYear : function(v)
30921 this.yearField.setValue(v);
30922 this.inputEl.dom.value = this.getValue();
30927 getDay : function()
30929 return this.dayField.getValue();
30932 getMonth : function()
30934 return this.monthField.getValue();
30937 getYear : function()
30939 return this.yearField.getValue();
30942 getValue : function()
30944 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30946 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30956 this.inputEl.dom.value = '';
30961 validate : function()
30963 var d = this.dayField.validate();
30964 var m = this.monthField.validate();
30965 var y = this.yearField.validate();
30970 (!this.dayAllowBlank && !d) ||
30971 (!this.monthAllowBlank && !m) ||
30972 (!this.yearAllowBlank && !y)
30977 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30986 this.markInvalid();
30991 markValid : function()
30994 var label = this.el.select('label', true).first();
30995 var icon = this.el.select('i.fa-star', true).first();
31001 this.fireEvent('valid', this);
31005 * Mark this field as invalid
31006 * @param {String} msg The validation message
31008 markInvalid : function(msg)
31011 var label = this.el.select('label', true).first();
31012 var icon = this.el.select('i.fa-star', true).first();
31014 if(label && !icon){
31015 this.el.select('.roo-date-split-field-label', true).createChild({
31017 cls : 'text-danger fa fa-lg fa-star',
31018 tooltip : 'This field is required',
31019 style : 'margin-right:5px;'
31023 this.fireEvent('invalid', this, msg);
31026 clearInvalid : function()
31028 var label = this.el.select('label', true).first();
31029 var icon = this.el.select('i.fa-star', true).first();
31035 this.fireEvent('valid', this);
31038 getName: function()
31048 * http://masonry.desandro.com
31050 * The idea is to render all the bricks based on vertical width...
31052 * The original code extends 'outlayer' - we might need to use that....
31058 * @class Roo.bootstrap.LayoutMasonry
31059 * @extends Roo.bootstrap.Component
31060 * Bootstrap Layout Masonry class
31063 * Create a new Element
31064 * @param {Object} config The config object
31067 Roo.bootstrap.LayoutMasonry = function(config){
31069 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31073 Roo.bootstrap.LayoutMasonry.register(this);
31079 * Fire after layout the items
31080 * @param {Roo.bootstrap.LayoutMasonry} this
31081 * @param {Roo.EventObject} e
31088 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31091 * @cfg {Boolean} isLayoutInstant = no animation?
31093 isLayoutInstant : false, // needed?
31096 * @cfg {Number} boxWidth width of the columns
31101 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31106 * @cfg {Number} padWidth padding below box..
31111 * @cfg {Number} gutter gutter width..
31116 * @cfg {Number} maxCols maximum number of columns
31122 * @cfg {Boolean} isAutoInitial defalut true
31124 isAutoInitial : true,
31129 * @cfg {Boolean} isHorizontal defalut false
31131 isHorizontal : false,
31133 currentSize : null,
31139 bricks: null, //CompositeElement
31143 _isLayoutInited : false,
31145 // isAlternative : false, // only use for vertical layout...
31148 * @cfg {Number} alternativePadWidth padding below box..
31150 alternativePadWidth : 50,
31152 selectedBrick : [],
31154 getAutoCreate : function(){
31156 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31160 cls: 'blog-masonary-wrapper ' + this.cls,
31162 cls : 'mas-boxes masonary'
31169 getChildContainer: function( )
31171 if (this.boxesEl) {
31172 return this.boxesEl;
31175 this.boxesEl = this.el.select('.mas-boxes').first();
31177 return this.boxesEl;
31181 initEvents : function()
31185 if(this.isAutoInitial){
31186 Roo.log('hook children rendered');
31187 this.on('childrenrendered', function() {
31188 Roo.log('children rendered');
31194 initial : function()
31196 this.selectedBrick = [];
31198 this.currentSize = this.el.getBox(true);
31200 Roo.EventManager.onWindowResize(this.resize, this);
31202 if(!this.isAutoInitial){
31210 //this.layout.defer(500,this);
31214 resize : function()
31216 var cs = this.el.getBox(true);
31219 this.currentSize.width == cs.width &&
31220 this.currentSize.x == cs.x &&
31221 this.currentSize.height == cs.height &&
31222 this.currentSize.y == cs.y
31224 Roo.log("no change in with or X or Y");
31228 this.currentSize = cs;
31234 layout : function()
31236 this._resetLayout();
31238 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31240 this.layoutItems( isInstant );
31242 this._isLayoutInited = true;
31244 this.fireEvent('layout', this);
31248 _resetLayout : function()
31250 if(this.isHorizontal){
31251 this.horizontalMeasureColumns();
31255 this.verticalMeasureColumns();
31259 verticalMeasureColumns : function()
31261 this.getContainerWidth();
31263 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31264 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31268 var boxWidth = this.boxWidth + this.padWidth;
31270 if(this.containerWidth < this.boxWidth){
31271 boxWidth = this.containerWidth
31274 var containerWidth = this.containerWidth;
31276 var cols = Math.floor(containerWidth / boxWidth);
31278 this.cols = Math.max( cols, 1 );
31280 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31282 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31284 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31286 this.colWidth = boxWidth + avail - this.padWidth;
31288 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31289 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31292 horizontalMeasureColumns : function()
31294 this.getContainerWidth();
31296 var boxWidth = this.boxWidth;
31298 if(this.containerWidth < boxWidth){
31299 boxWidth = this.containerWidth;
31302 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31304 this.el.setHeight(boxWidth);
31308 getContainerWidth : function()
31310 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31313 layoutItems : function( isInstant )
31315 Roo.log(this.bricks);
31317 var items = Roo.apply([], this.bricks);
31319 if(this.isHorizontal){
31320 this._horizontalLayoutItems( items , isInstant );
31324 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31325 // this._verticalAlternativeLayoutItems( items , isInstant );
31329 this._verticalLayoutItems( items , isInstant );
31333 _verticalLayoutItems : function ( items , isInstant)
31335 if ( !items || !items.length ) {
31340 ['xs', 'xs', 'xs', 'tall'],
31341 ['xs', 'xs', 'tall'],
31342 ['xs', 'xs', 'sm'],
31343 ['xs', 'xs', 'xs'],
31349 ['sm', 'xs', 'xs'],
31353 ['tall', 'xs', 'xs', 'xs'],
31354 ['tall', 'xs', 'xs'],
31366 Roo.each(items, function(item, k){
31368 switch (item.size) {
31369 // these layouts take up a full box,
31380 boxes.push([item]);
31403 var filterPattern = function(box, length)
31411 var pattern = box.slice(0, length);
31415 Roo.each(pattern, function(i){
31416 format.push(i.size);
31419 Roo.each(standard, function(s){
31421 if(String(s) != String(format)){
31430 if(!match && length == 1){
31435 filterPattern(box, length - 1);
31439 queue.push(pattern);
31441 box = box.slice(length, box.length);
31443 filterPattern(box, 4);
31449 Roo.each(boxes, function(box, k){
31455 if(box.length == 1){
31460 filterPattern(box, 4);
31464 this._processVerticalLayoutQueue( queue, isInstant );
31468 // _verticalAlternativeLayoutItems : function( items , isInstant )
31470 // if ( !items || !items.length ) {
31474 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31478 _horizontalLayoutItems : function ( items , isInstant)
31480 if ( !items || !items.length || items.length < 3) {
31486 var eItems = items.slice(0, 3);
31488 items = items.slice(3, items.length);
31491 ['xs', 'xs', 'xs', 'wide'],
31492 ['xs', 'xs', 'wide'],
31493 ['xs', 'xs', 'sm'],
31494 ['xs', 'xs', 'xs'],
31500 ['sm', 'xs', 'xs'],
31504 ['wide', 'xs', 'xs', 'xs'],
31505 ['wide', 'xs', 'xs'],
31518 Roo.each(items, function(item, k){
31520 switch (item.size) {
31531 boxes.push([item]);
31555 var filterPattern = function(box, length)
31563 var pattern = box.slice(0, length);
31567 Roo.each(pattern, function(i){
31568 format.push(i.size);
31571 Roo.each(standard, function(s){
31573 if(String(s) != String(format)){
31582 if(!match && length == 1){
31587 filterPattern(box, length - 1);
31591 queue.push(pattern);
31593 box = box.slice(length, box.length);
31595 filterPattern(box, 4);
31601 Roo.each(boxes, function(box, k){
31607 if(box.length == 1){
31612 filterPattern(box, 4);
31619 var pos = this.el.getBox(true);
31623 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31625 var hit_end = false;
31627 Roo.each(queue, function(box){
31631 Roo.each(box, function(b){
31633 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31643 Roo.each(box, function(b){
31645 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31648 mx = Math.max(mx, b.x);
31652 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31656 Roo.each(box, function(b){
31658 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31672 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31675 /** Sets position of item in DOM
31676 * @param {Element} item
31677 * @param {Number} x - horizontal position
31678 * @param {Number} y - vertical position
31679 * @param {Boolean} isInstant - disables transitions
31681 _processVerticalLayoutQueue : function( queue, isInstant )
31683 var pos = this.el.getBox(true);
31688 for (var i = 0; i < this.cols; i++){
31692 Roo.each(queue, function(box, k){
31694 var col = k % this.cols;
31696 Roo.each(box, function(b,kk){
31698 b.el.position('absolute');
31700 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31701 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31703 if(b.size == 'md-left' || b.size == 'md-right'){
31704 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31705 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31708 b.el.setWidth(width);
31709 b.el.setHeight(height);
31711 b.el.select('iframe',true).setSize(width,height);
31715 for (var i = 0; i < this.cols; i++){
31717 if(maxY[i] < maxY[col]){
31722 col = Math.min(col, i);
31726 x = pos.x + col * (this.colWidth + this.padWidth);
31730 var positions = [];
31732 switch (box.length){
31734 positions = this.getVerticalOneBoxColPositions(x, y, box);
31737 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31740 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31743 positions = this.getVerticalFourBoxColPositions(x, y, box);
31749 Roo.each(box, function(b,kk){
31751 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31753 var sz = b.el.getSize();
31755 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31763 for (var i = 0; i < this.cols; i++){
31764 mY = Math.max(mY, maxY[i]);
31767 this.el.setHeight(mY - pos.y);
31771 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31773 // var pos = this.el.getBox(true);
31776 // var maxX = pos.right;
31778 // var maxHeight = 0;
31780 // Roo.each(items, function(item, k){
31784 // item.el.position('absolute');
31786 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31788 // item.el.setWidth(width);
31790 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31792 // item.el.setHeight(height);
31795 // item.el.setXY([x, y], isInstant ? false : true);
31797 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31800 // y = y + height + this.alternativePadWidth;
31802 // maxHeight = maxHeight + height + this.alternativePadWidth;
31806 // this.el.setHeight(maxHeight);
31810 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31812 var pos = this.el.getBox(true);
31817 var maxX = pos.right;
31819 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31821 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31823 Roo.each(queue, function(box, k){
31825 Roo.each(box, function(b, kk){
31827 b.el.position('absolute');
31829 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31830 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31832 if(b.size == 'md-left' || b.size == 'md-right'){
31833 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31834 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31837 b.el.setWidth(width);
31838 b.el.setHeight(height);
31846 var positions = [];
31848 switch (box.length){
31850 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31853 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31856 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31859 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31865 Roo.each(box, function(b,kk){
31867 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31869 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31877 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31879 Roo.each(eItems, function(b,k){
31881 b.size = (k == 0) ? 'sm' : 'xs';
31882 b.x = (k == 0) ? 2 : 1;
31883 b.y = (k == 0) ? 2 : 1;
31885 b.el.position('absolute');
31887 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31889 b.el.setWidth(width);
31891 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31893 b.el.setHeight(height);
31897 var positions = [];
31900 x : maxX - this.unitWidth * 2 - this.gutter,
31905 x : maxX - this.unitWidth,
31906 y : minY + (this.unitWidth + this.gutter) * 2
31910 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31914 Roo.each(eItems, function(b,k){
31916 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31922 getVerticalOneBoxColPositions : function(x, y, box)
31926 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31928 if(box[0].size == 'md-left'){
31932 if(box[0].size == 'md-right'){
31937 x : x + (this.unitWidth + this.gutter) * rand,
31944 getVerticalTwoBoxColPositions : function(x, y, box)
31948 if(box[0].size == 'xs'){
31952 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31956 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31970 x : x + (this.unitWidth + this.gutter) * 2,
31971 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31978 getVerticalThreeBoxColPositions : function(x, y, box)
31982 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31990 x : x + (this.unitWidth + this.gutter) * 1,
31995 x : x + (this.unitWidth + this.gutter) * 2,
32003 if(box[0].size == 'xs' && box[1].size == 'xs'){
32012 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32016 x : x + (this.unitWidth + this.gutter) * 1,
32030 x : x + (this.unitWidth + this.gutter) * 2,
32035 x : x + (this.unitWidth + this.gutter) * 2,
32036 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32043 getVerticalFourBoxColPositions : function(x, y, box)
32047 if(box[0].size == 'xs'){
32056 y : y + (this.unitHeight + this.gutter) * 1
32061 y : y + (this.unitHeight + this.gutter) * 2
32065 x : x + (this.unitWidth + this.gutter) * 1,
32079 x : x + (this.unitWidth + this.gutter) * 2,
32084 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32085 y : y + (this.unitHeight + this.gutter) * 1
32089 x : x + (this.unitWidth + this.gutter) * 2,
32090 y : y + (this.unitWidth + this.gutter) * 2
32097 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32101 if(box[0].size == 'md-left'){
32103 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32110 if(box[0].size == 'md-right'){
32112 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32113 y : minY + (this.unitWidth + this.gutter) * 1
32119 var rand = Math.floor(Math.random() * (4 - box[0].y));
32122 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32123 y : minY + (this.unitWidth + this.gutter) * rand
32130 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32134 if(box[0].size == 'xs'){
32137 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32142 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32143 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32151 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32156 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32157 y : minY + (this.unitWidth + this.gutter) * 2
32164 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32168 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32171 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32176 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32177 y : minY + (this.unitWidth + this.gutter) * 1
32181 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32182 y : minY + (this.unitWidth + this.gutter) * 2
32189 if(box[0].size == 'xs' && box[1].size == 'xs'){
32192 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32197 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32202 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32203 y : minY + (this.unitWidth + this.gutter) * 1
32211 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32216 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32217 y : minY + (this.unitWidth + this.gutter) * 2
32221 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32222 y : minY + (this.unitWidth + this.gutter) * 2
32229 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32233 if(box[0].size == 'xs'){
32236 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32241 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32246 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),
32251 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32252 y : minY + (this.unitWidth + this.gutter) * 1
32260 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32265 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32266 y : minY + (this.unitWidth + this.gutter) * 2
32270 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32271 y : minY + (this.unitWidth + this.gutter) * 2
32275 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),
32276 y : minY + (this.unitWidth + this.gutter) * 2
32284 * remove a Masonry Brick
32285 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32287 removeBrick : function(brick_id)
32293 for (var i = 0; i<this.bricks.length; i++) {
32294 if (this.bricks[i].id == brick_id) {
32295 this.bricks.splice(i,1);
32296 this.el.dom.removeChild(Roo.get(brick_id).dom);
32303 * adds a Masonry Brick
32304 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32306 addBrick : function(cfg)
32308 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32309 //this.register(cn);
32310 cn.parentId = this.id;
32311 cn.render(this.el);
32316 * register a Masonry Brick
32317 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32320 register : function(brick)
32322 this.bricks.push(brick);
32323 brick.masonryId = this.id;
32327 * clear all the Masonry Brick
32329 clearAll : function()
32332 //this.getChildContainer().dom.innerHTML = "";
32333 this.el.dom.innerHTML = '';
32336 getSelected : function()
32338 if (!this.selectedBrick) {
32342 return this.selectedBrick;
32346 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32350 * register a Masonry Layout
32351 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32354 register : function(layout)
32356 this.groups[layout.id] = layout;
32359 * fetch a Masonry Layout based on the masonry layout ID
32360 * @param {string} the masonry layout to add
32361 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32364 get: function(layout_id) {
32365 if (typeof(this.groups[layout_id]) == 'undefined') {
32368 return this.groups[layout_id] ;
32380 * http://masonry.desandro.com
32382 * The idea is to render all the bricks based on vertical width...
32384 * The original code extends 'outlayer' - we might need to use that....
32390 * @class Roo.bootstrap.LayoutMasonryAuto
32391 * @extends Roo.bootstrap.Component
32392 * Bootstrap Layout Masonry class
32395 * Create a new Element
32396 * @param {Object} config The config object
32399 Roo.bootstrap.LayoutMasonryAuto = function(config){
32400 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32403 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32406 * @cfg {Boolean} isFitWidth - resize the width..
32408 isFitWidth : false, // options..
32410 * @cfg {Boolean} isOriginLeft = left align?
32412 isOriginLeft : true,
32414 * @cfg {Boolean} isOriginTop = top align?
32416 isOriginTop : false,
32418 * @cfg {Boolean} isLayoutInstant = no animation?
32420 isLayoutInstant : false, // needed?
32422 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32424 isResizingContainer : true,
32426 * @cfg {Number} columnWidth width of the columns
32432 * @cfg {Number} maxCols maximum number of columns
32437 * @cfg {Number} padHeight padding below box..
32443 * @cfg {Boolean} isAutoInitial defalut true
32446 isAutoInitial : true,
32452 initialColumnWidth : 0,
32453 currentSize : null,
32455 colYs : null, // array.
32462 bricks: null, //CompositeElement
32463 cols : 0, // array?
32464 // element : null, // wrapped now this.el
32465 _isLayoutInited : null,
32468 getAutoCreate : function(){
32472 cls: 'blog-masonary-wrapper ' + this.cls,
32474 cls : 'mas-boxes masonary'
32481 getChildContainer: function( )
32483 if (this.boxesEl) {
32484 return this.boxesEl;
32487 this.boxesEl = this.el.select('.mas-boxes').first();
32489 return this.boxesEl;
32493 initEvents : function()
32497 if(this.isAutoInitial){
32498 Roo.log('hook children rendered');
32499 this.on('childrenrendered', function() {
32500 Roo.log('children rendered');
32507 initial : function()
32509 this.reloadItems();
32511 this.currentSize = this.el.getBox(true);
32513 /// was window resize... - let's see if this works..
32514 Roo.EventManager.onWindowResize(this.resize, this);
32516 if(!this.isAutoInitial){
32521 this.layout.defer(500,this);
32524 reloadItems: function()
32526 this.bricks = this.el.select('.masonry-brick', true);
32528 this.bricks.each(function(b) {
32529 //Roo.log(b.getSize());
32530 if (!b.attr('originalwidth')) {
32531 b.attr('originalwidth', b.getSize().width);
32536 Roo.log(this.bricks.elements.length);
32539 resize : function()
32542 var cs = this.el.getBox(true);
32544 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32545 Roo.log("no change in with or X");
32548 this.currentSize = cs;
32552 layout : function()
32555 this._resetLayout();
32556 //this._manageStamps();
32558 // don't animate first layout
32559 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32560 this.layoutItems( isInstant );
32562 // flag for initalized
32563 this._isLayoutInited = true;
32566 layoutItems : function( isInstant )
32568 //var items = this._getItemsForLayout( this.items );
32569 // original code supports filtering layout items.. we just ignore it..
32571 this._layoutItems( this.bricks , isInstant );
32573 this._postLayout();
32575 _layoutItems : function ( items , isInstant)
32577 //this.fireEvent( 'layout', this, items );
32580 if ( !items || !items.elements.length ) {
32581 // no items, emit event with empty array
32586 items.each(function(item) {
32587 Roo.log("layout item");
32589 // get x/y object from method
32590 var position = this._getItemLayoutPosition( item );
32592 position.item = item;
32593 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32594 queue.push( position );
32597 this._processLayoutQueue( queue );
32599 /** Sets position of item in DOM
32600 * @param {Element} item
32601 * @param {Number} x - horizontal position
32602 * @param {Number} y - vertical position
32603 * @param {Boolean} isInstant - disables transitions
32605 _processLayoutQueue : function( queue )
32607 for ( var i=0, len = queue.length; i < len; i++ ) {
32608 var obj = queue[i];
32609 obj.item.position('absolute');
32610 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32616 * Any logic you want to do after each layout,
32617 * i.e. size the container
32619 _postLayout : function()
32621 this.resizeContainer();
32624 resizeContainer : function()
32626 if ( !this.isResizingContainer ) {
32629 var size = this._getContainerSize();
32631 this.el.setSize(size.width,size.height);
32632 this.boxesEl.setSize(size.width,size.height);
32638 _resetLayout : function()
32640 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32641 this.colWidth = this.el.getWidth();
32642 //this.gutter = this.el.getWidth();
32644 this.measureColumns();
32650 this.colYs.push( 0 );
32656 measureColumns : function()
32658 this.getContainerWidth();
32659 // if columnWidth is 0, default to outerWidth of first item
32660 if ( !this.columnWidth ) {
32661 var firstItem = this.bricks.first();
32662 Roo.log(firstItem);
32663 this.columnWidth = this.containerWidth;
32664 if (firstItem && firstItem.attr('originalwidth') ) {
32665 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32667 // columnWidth fall back to item of first element
32668 Roo.log("set column width?");
32669 this.initialColumnWidth = this.columnWidth ;
32671 // if first elem has no width, default to size of container
32676 if (this.initialColumnWidth) {
32677 this.columnWidth = this.initialColumnWidth;
32682 // column width is fixed at the top - however if container width get's smaller we should
32685 // this bit calcs how man columns..
32687 var columnWidth = this.columnWidth += this.gutter;
32689 // calculate columns
32690 var containerWidth = this.containerWidth + this.gutter;
32692 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32693 // fix rounding errors, typically with gutters
32694 var excess = columnWidth - containerWidth % columnWidth;
32697 // if overshoot is less than a pixel, round up, otherwise floor it
32698 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32699 cols = Math[ mathMethod ]( cols );
32700 this.cols = Math.max( cols, 1 );
32701 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32703 // padding positioning..
32704 var totalColWidth = this.cols * this.columnWidth;
32705 var padavail = this.containerWidth - totalColWidth;
32706 // so for 2 columns - we need 3 'pads'
32708 var padNeeded = (1+this.cols) * this.padWidth;
32710 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32712 this.columnWidth += padExtra
32713 //this.padWidth = Math.floor(padavail / ( this.cols));
32715 // adjust colum width so that padding is fixed??
32717 // we have 3 columns ... total = width * 3
32718 // we have X left over... that should be used by
32720 //if (this.expandC) {
32728 getContainerWidth : function()
32730 /* // container is parent if fit width
32731 var container = this.isFitWidth ? this.element.parentNode : this.element;
32732 // check that this.size and size are there
32733 // IE8 triggers resize on body size change, so they might not be
32735 var size = getSize( container ); //FIXME
32736 this.containerWidth = size && size.innerWidth; //FIXME
32739 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32743 _getItemLayoutPosition : function( item ) // what is item?
32745 // we resize the item to our columnWidth..
32747 item.setWidth(this.columnWidth);
32748 item.autoBoxAdjust = false;
32750 var sz = item.getSize();
32752 // how many columns does this brick span
32753 var remainder = this.containerWidth % this.columnWidth;
32755 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32756 // round if off by 1 pixel, otherwise use ceil
32757 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32758 colSpan = Math.min( colSpan, this.cols );
32760 // normally this should be '1' as we dont' currently allow multi width columns..
32762 var colGroup = this._getColGroup( colSpan );
32763 // get the minimum Y value from the columns
32764 var minimumY = Math.min.apply( Math, colGroup );
32765 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32767 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32769 // position the brick
32771 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32772 y: this.currentSize.y + minimumY + this.padHeight
32776 // apply setHeight to necessary columns
32777 var setHeight = minimumY + sz.height + this.padHeight;
32778 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32780 var setSpan = this.cols + 1 - colGroup.length;
32781 for ( var i = 0; i < setSpan; i++ ) {
32782 this.colYs[ shortColIndex + i ] = setHeight ;
32789 * @param {Number} colSpan - number of columns the element spans
32790 * @returns {Array} colGroup
32792 _getColGroup : function( colSpan )
32794 if ( colSpan < 2 ) {
32795 // if brick spans only one column, use all the column Ys
32800 // how many different places could this brick fit horizontally
32801 var groupCount = this.cols + 1 - colSpan;
32802 // for each group potential horizontal position
32803 for ( var i = 0; i < groupCount; i++ ) {
32804 // make an array of colY values for that one group
32805 var groupColYs = this.colYs.slice( i, i + colSpan );
32806 // and get the max value of the array
32807 colGroup[i] = Math.max.apply( Math, groupColYs );
32812 _manageStamp : function( stamp )
32814 var stampSize = stamp.getSize();
32815 var offset = stamp.getBox();
32816 // get the columns that this stamp affects
32817 var firstX = this.isOriginLeft ? offset.x : offset.right;
32818 var lastX = firstX + stampSize.width;
32819 var firstCol = Math.floor( firstX / this.columnWidth );
32820 firstCol = Math.max( 0, firstCol );
32822 var lastCol = Math.floor( lastX / this.columnWidth );
32823 // lastCol should not go over if multiple of columnWidth #425
32824 lastCol -= lastX % this.columnWidth ? 0 : 1;
32825 lastCol = Math.min( this.cols - 1, lastCol );
32827 // set colYs to bottom of the stamp
32828 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32831 for ( var i = firstCol; i <= lastCol; i++ ) {
32832 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32837 _getContainerSize : function()
32839 this.maxY = Math.max.apply( Math, this.colYs );
32844 if ( this.isFitWidth ) {
32845 size.width = this._getContainerFitWidth();
32851 _getContainerFitWidth : function()
32853 var unusedCols = 0;
32854 // count unused columns
32857 if ( this.colYs[i] !== 0 ) {
32862 // fit container to columns that have been used
32863 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32866 needsResizeLayout : function()
32868 var previousWidth = this.containerWidth;
32869 this.getContainerWidth();
32870 return previousWidth !== this.containerWidth;
32885 * @class Roo.bootstrap.MasonryBrick
32886 * @extends Roo.bootstrap.Component
32887 * Bootstrap MasonryBrick class
32890 * Create a new MasonryBrick
32891 * @param {Object} config The config object
32894 Roo.bootstrap.MasonryBrick = function(config){
32896 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32898 Roo.bootstrap.MasonryBrick.register(this);
32904 * When a MasonryBrick is clcik
32905 * @param {Roo.bootstrap.MasonryBrick} this
32906 * @param {Roo.EventObject} e
32912 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32915 * @cfg {String} title
32919 * @cfg {String} html
32923 * @cfg {String} bgimage
32927 * @cfg {String} videourl
32931 * @cfg {String} cls
32935 * @cfg {String} href
32939 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32944 * @cfg {String} placetitle (center|bottom)
32949 * @cfg {Boolean} isFitContainer defalut true
32951 isFitContainer : true,
32954 * @cfg {Boolean} preventDefault defalut false
32956 preventDefault : false,
32959 * @cfg {Boolean} inverse defalut false
32961 maskInverse : false,
32963 getAutoCreate : function()
32965 if(!this.isFitContainer){
32966 return this.getSplitAutoCreate();
32969 var cls = 'masonry-brick masonry-brick-full';
32971 if(this.href.length){
32972 cls += ' masonry-brick-link';
32975 if(this.bgimage.length){
32976 cls += ' masonry-brick-image';
32979 if(this.maskInverse){
32980 cls += ' mask-inverse';
32983 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32984 cls += ' enable-mask';
32988 cls += ' masonry-' + this.size + '-brick';
32991 if(this.placetitle.length){
32993 switch (this.placetitle) {
32995 cls += ' masonry-center-title';
32998 cls += ' masonry-bottom-title';
33005 if(!this.html.length && !this.bgimage.length){
33006 cls += ' masonry-center-title';
33009 if(!this.html.length && this.bgimage.length){
33010 cls += ' masonry-bottom-title';
33015 cls += ' ' + this.cls;
33019 tag: (this.href.length) ? 'a' : 'div',
33024 cls: 'masonry-brick-mask'
33028 cls: 'masonry-brick-paragraph',
33034 if(this.href.length){
33035 cfg.href = this.href;
33038 var cn = cfg.cn[1].cn;
33040 if(this.title.length){
33043 cls: 'masonry-brick-title',
33048 if(this.html.length){
33051 cls: 'masonry-brick-text',
33056 if (!this.title.length && !this.html.length) {
33057 cfg.cn[1].cls += ' hide';
33060 if(this.bgimage.length){
33063 cls: 'masonry-brick-image-view',
33068 if(this.videourl.length){
33069 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33070 // youtube support only?
33073 cls: 'masonry-brick-image-view',
33076 allowfullscreen : true
33084 getSplitAutoCreate : function()
33086 var cls = 'masonry-brick masonry-brick-split';
33088 if(this.href.length){
33089 cls += ' masonry-brick-link';
33092 if(this.bgimage.length){
33093 cls += ' masonry-brick-image';
33097 cls += ' masonry-' + this.size + '-brick';
33100 switch (this.placetitle) {
33102 cls += ' masonry-center-title';
33105 cls += ' masonry-bottom-title';
33108 if(!this.bgimage.length){
33109 cls += ' masonry-center-title';
33112 if(this.bgimage.length){
33113 cls += ' masonry-bottom-title';
33119 cls += ' ' + this.cls;
33123 tag: (this.href.length) ? 'a' : 'div',
33128 cls: 'masonry-brick-split-head',
33132 cls: 'masonry-brick-paragraph',
33139 cls: 'masonry-brick-split-body',
33145 if(this.href.length){
33146 cfg.href = this.href;
33149 if(this.title.length){
33150 cfg.cn[0].cn[0].cn.push({
33152 cls: 'masonry-brick-title',
33157 if(this.html.length){
33158 cfg.cn[1].cn.push({
33160 cls: 'masonry-brick-text',
33165 if(this.bgimage.length){
33166 cfg.cn[0].cn.push({
33168 cls: 'masonry-brick-image-view',
33173 if(this.videourl.length){
33174 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33175 // youtube support only?
33176 cfg.cn[0].cn.cn.push({
33178 cls: 'masonry-brick-image-view',
33181 allowfullscreen : true
33188 initEvents: function()
33190 switch (this.size) {
33223 this.el.on('touchstart', this.onTouchStart, this);
33224 this.el.on('touchmove', this.onTouchMove, this);
33225 this.el.on('touchend', this.onTouchEnd, this);
33226 this.el.on('contextmenu', this.onContextMenu, this);
33228 this.el.on('mouseenter' ,this.enter, this);
33229 this.el.on('mouseleave', this.leave, this);
33230 this.el.on('click', this.onClick, this);
33233 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33234 this.parent().bricks.push(this);
33239 onClick: function(e, el)
33241 var time = this.endTimer - this.startTimer;
33242 // Roo.log(e.preventDefault());
33245 e.preventDefault();
33250 if(!this.preventDefault){
33254 e.preventDefault();
33256 if (this.activeClass != '') {
33257 this.selectBrick();
33260 this.fireEvent('click', this, e);
33263 enter: function(e, el)
33265 e.preventDefault();
33267 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33271 if(this.bgimage.length && this.html.length){
33272 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33276 leave: function(e, el)
33278 e.preventDefault();
33280 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33284 if(this.bgimage.length && this.html.length){
33285 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33289 onTouchStart: function(e, el)
33291 // e.preventDefault();
33293 this.touchmoved = false;
33295 if(!this.isFitContainer){
33299 if(!this.bgimage.length || !this.html.length){
33303 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33305 this.timer = new Date().getTime();
33309 onTouchMove: function(e, el)
33311 this.touchmoved = true;
33314 onContextMenu : function(e,el)
33316 e.preventDefault();
33317 e.stopPropagation();
33321 onTouchEnd: function(e, el)
33323 // e.preventDefault();
33325 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33332 if(!this.bgimage.length || !this.html.length){
33334 if(this.href.length){
33335 window.location.href = this.href;
33341 if(!this.isFitContainer){
33345 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33347 window.location.href = this.href;
33350 //selection on single brick only
33351 selectBrick : function() {
33353 if (!this.parentId) {
33357 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33358 var index = m.selectedBrick.indexOf(this.id);
33361 m.selectedBrick.splice(index,1);
33362 this.el.removeClass(this.activeClass);
33366 for(var i = 0; i < m.selectedBrick.length; i++) {
33367 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33368 b.el.removeClass(b.activeClass);
33371 m.selectedBrick = [];
33373 m.selectedBrick.push(this.id);
33374 this.el.addClass(this.activeClass);
33378 isSelected : function(){
33379 return this.el.hasClass(this.activeClass);
33384 Roo.apply(Roo.bootstrap.MasonryBrick, {
33387 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33389 * register a Masonry Brick
33390 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33393 register : function(brick)
33395 //this.groups[brick.id] = brick;
33396 this.groups.add(brick.id, brick);
33399 * fetch a masonry brick based on the masonry brick ID
33400 * @param {string} the masonry brick to add
33401 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33404 get: function(brick_id)
33406 // if (typeof(this.groups[brick_id]) == 'undefined') {
33409 // return this.groups[brick_id] ;
33411 if(this.groups.key(brick_id)) {
33412 return this.groups.key(brick_id);
33430 * @class Roo.bootstrap.Brick
33431 * @extends Roo.bootstrap.Component
33432 * Bootstrap Brick class
33435 * Create a new Brick
33436 * @param {Object} config The config object
33439 Roo.bootstrap.Brick = function(config){
33440 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33446 * When a Brick is click
33447 * @param {Roo.bootstrap.Brick} this
33448 * @param {Roo.EventObject} e
33454 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33457 * @cfg {String} title
33461 * @cfg {String} html
33465 * @cfg {String} bgimage
33469 * @cfg {String} cls
33473 * @cfg {String} href
33477 * @cfg {String} video
33481 * @cfg {Boolean} square
33485 getAutoCreate : function()
33487 var cls = 'roo-brick';
33489 if(this.href.length){
33490 cls += ' roo-brick-link';
33493 if(this.bgimage.length){
33494 cls += ' roo-brick-image';
33497 if(!this.html.length && !this.bgimage.length){
33498 cls += ' roo-brick-center-title';
33501 if(!this.html.length && this.bgimage.length){
33502 cls += ' roo-brick-bottom-title';
33506 cls += ' ' + this.cls;
33510 tag: (this.href.length) ? 'a' : 'div',
33515 cls: 'roo-brick-paragraph',
33521 if(this.href.length){
33522 cfg.href = this.href;
33525 var cn = cfg.cn[0].cn;
33527 if(this.title.length){
33530 cls: 'roo-brick-title',
33535 if(this.html.length){
33538 cls: 'roo-brick-text',
33545 if(this.bgimage.length){
33548 cls: 'roo-brick-image-view',
33556 initEvents: function()
33558 if(this.title.length || this.html.length){
33559 this.el.on('mouseenter' ,this.enter, this);
33560 this.el.on('mouseleave', this.leave, this);
33563 Roo.EventManager.onWindowResize(this.resize, this);
33565 if(this.bgimage.length){
33566 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33567 this.imageEl.on('load', this.onImageLoad, this);
33574 onImageLoad : function()
33579 resize : function()
33581 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33583 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33585 if(this.bgimage.length){
33586 var image = this.el.select('.roo-brick-image-view', true).first();
33588 image.setWidth(paragraph.getWidth());
33591 image.setHeight(paragraph.getWidth());
33594 this.el.setHeight(image.getHeight());
33595 paragraph.setHeight(image.getHeight());
33601 enter: function(e, el)
33603 e.preventDefault();
33605 if(this.bgimage.length){
33606 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33607 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33611 leave: function(e, el)
33613 e.preventDefault();
33615 if(this.bgimage.length){
33616 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33617 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33632 * @class Roo.bootstrap.NumberField
33633 * @extends Roo.bootstrap.Input
33634 * Bootstrap NumberField class
33640 * Create a new NumberField
33641 * @param {Object} config The config object
33644 Roo.bootstrap.NumberField = function(config){
33645 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33648 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33651 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33653 allowDecimals : true,
33655 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33657 decimalSeparator : ".",
33659 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33661 decimalPrecision : 2,
33663 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33665 allowNegative : true,
33668 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33672 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33674 minValue : Number.NEGATIVE_INFINITY,
33676 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33678 maxValue : Number.MAX_VALUE,
33680 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33682 minText : "The minimum value for this field is {0}",
33684 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33686 maxText : "The maximum value for this field is {0}",
33688 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33689 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33691 nanText : "{0} is not a valid number",
33693 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33695 thousandsDelimiter : false,
33697 * @cfg {String} valueAlign alignment of value
33699 valueAlign : "left",
33701 getAutoCreate : function()
33703 var hiddenInput = {
33707 cls: 'hidden-number-input'
33711 hiddenInput.name = this.name;
33716 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33718 this.name = hiddenInput.name;
33720 if(cfg.cn.length > 0) {
33721 cfg.cn.push(hiddenInput);
33728 initEvents : function()
33730 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33732 var allowed = "0123456789";
33734 if(this.allowDecimals){
33735 allowed += this.decimalSeparator;
33738 if(this.allowNegative){
33742 if(this.thousandsDelimiter) {
33746 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33748 var keyPress = function(e){
33750 var k = e.getKey();
33752 var c = e.getCharCode();
33755 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33756 allowed.indexOf(String.fromCharCode(c)) === -1
33762 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33766 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33771 this.el.on("keypress", keyPress, this);
33774 validateValue : function(value)
33777 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33781 var num = this.parseValue(value);
33784 this.markInvalid(String.format(this.nanText, value));
33788 if(num < this.minValue){
33789 this.markInvalid(String.format(this.minText, this.minValue));
33793 if(num > this.maxValue){
33794 this.markInvalid(String.format(this.maxText, this.maxValue));
33801 getValue : function()
33803 var v = this.hiddenEl().getValue();
33805 return this.fixPrecision(this.parseValue(v));
33808 parseValue : function(value)
33810 if(this.thousandsDelimiter) {
33812 r = new RegExp(",", "g");
33813 value = value.replace(r, "");
33816 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33817 return isNaN(value) ? '' : value;
33820 fixPrecision : function(value)
33822 if(this.thousandsDelimiter) {
33824 r = new RegExp(",", "g");
33825 value = value.replace(r, "");
33828 var nan = isNaN(value);
33830 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33831 return nan ? '' : value;
33833 return parseFloat(value).toFixed(this.decimalPrecision);
33836 setValue : function(v)
33838 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33844 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33846 this.inputEl().dom.value = (v == '') ? '' :
33847 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33849 if(!this.allowZero && v === '0') {
33850 this.hiddenEl().dom.value = '';
33851 this.inputEl().dom.value = '';
33858 decimalPrecisionFcn : function(v)
33860 return Math.floor(v);
33863 beforeBlur : function()
33865 var v = this.parseValue(this.getRawValue());
33867 if(v || v === 0 || v === ''){
33872 hiddenEl : function()
33874 return this.el.select('input.hidden-number-input',true).first();
33886 * @class Roo.bootstrap.DocumentSlider
33887 * @extends Roo.bootstrap.Component
33888 * Bootstrap DocumentSlider class
33891 * Create a new DocumentViewer
33892 * @param {Object} config The config object
33895 Roo.bootstrap.DocumentSlider = function(config){
33896 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33903 * Fire after initEvent
33904 * @param {Roo.bootstrap.DocumentSlider} this
33909 * Fire after update
33910 * @param {Roo.bootstrap.DocumentSlider} this
33916 * @param {Roo.bootstrap.DocumentSlider} this
33922 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33928 getAutoCreate : function()
33932 cls : 'roo-document-slider',
33936 cls : 'roo-document-slider-header',
33940 cls : 'roo-document-slider-header-title'
33946 cls : 'roo-document-slider-body',
33950 cls : 'roo-document-slider-prev',
33954 cls : 'fa fa-chevron-left'
33960 cls : 'roo-document-slider-thumb',
33964 cls : 'roo-document-slider-image'
33970 cls : 'roo-document-slider-next',
33974 cls : 'fa fa-chevron-right'
33986 initEvents : function()
33988 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33989 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33991 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33992 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33994 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33995 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33997 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33998 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34000 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34001 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34003 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34004 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34006 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34007 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34009 this.thumbEl.on('click', this.onClick, this);
34011 this.prevIndicator.on('click', this.prev, this);
34013 this.nextIndicator.on('click', this.next, this);
34017 initial : function()
34019 if(this.files.length){
34020 this.indicator = 1;
34024 this.fireEvent('initial', this);
34027 update : function()
34029 this.imageEl.attr('src', this.files[this.indicator - 1]);
34031 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34033 this.prevIndicator.show();
34035 if(this.indicator == 1){
34036 this.prevIndicator.hide();
34039 this.nextIndicator.show();
34041 if(this.indicator == this.files.length){
34042 this.nextIndicator.hide();
34045 this.thumbEl.scrollTo('top');
34047 this.fireEvent('update', this);
34050 onClick : function(e)
34052 e.preventDefault();
34054 this.fireEvent('click', this);
34059 e.preventDefault();
34061 this.indicator = Math.max(1, this.indicator - 1);
34068 e.preventDefault();
34070 this.indicator = Math.min(this.files.length, this.indicator + 1);
34084 * @class Roo.bootstrap.RadioSet
34085 * @extends Roo.bootstrap.Input
34086 * Bootstrap RadioSet class
34087 * @cfg {String} indicatorpos (left|right) default left
34088 * @cfg {Boolean} inline (true|false) inline the element (default true)
34089 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34091 * Create a new RadioSet
34092 * @param {Object} config The config object
34095 Roo.bootstrap.RadioSet = function(config){
34097 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34101 Roo.bootstrap.RadioSet.register(this);
34106 * Fires when the element is checked or unchecked.
34107 * @param {Roo.bootstrap.RadioSet} this This radio
34108 * @param {Roo.bootstrap.Radio} item The checked item
34113 * Fires when the element is click.
34114 * @param {Roo.bootstrap.RadioSet} this This radio set
34115 * @param {Roo.bootstrap.Radio} item The checked item
34116 * @param {Roo.EventObject} e The event object
34123 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34131 indicatorpos : 'left',
34133 getAutoCreate : function()
34137 cls : 'roo-radio-set-label',
34141 html : this.fieldLabel
34145 if (Roo.bootstrap.version == 3) {
34148 if(this.indicatorpos == 'left'){
34151 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34152 tooltip : 'This field is required'
34157 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34158 tooltip : 'This field is required'
34164 cls : 'roo-radio-set-items'
34167 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34169 if (align === 'left' && this.fieldLabel.length) {
34172 cls : "roo-radio-set-right",
34178 if(this.labelWidth > 12){
34179 label.style = "width: " + this.labelWidth + 'px';
34182 if(this.labelWidth < 13 && this.labelmd == 0){
34183 this.labelmd = this.labelWidth;
34186 if(this.labellg > 0){
34187 label.cls += ' col-lg-' + this.labellg;
34188 items.cls += ' col-lg-' + (12 - this.labellg);
34191 if(this.labelmd > 0){
34192 label.cls += ' col-md-' + this.labelmd;
34193 items.cls += ' col-md-' + (12 - this.labelmd);
34196 if(this.labelsm > 0){
34197 label.cls += ' col-sm-' + this.labelsm;
34198 items.cls += ' col-sm-' + (12 - this.labelsm);
34201 if(this.labelxs > 0){
34202 label.cls += ' col-xs-' + this.labelxs;
34203 items.cls += ' col-xs-' + (12 - this.labelxs);
34209 cls : 'roo-radio-set',
34213 cls : 'roo-radio-set-input',
34216 value : this.value ? this.value : ''
34223 if(this.weight.length){
34224 cfg.cls += ' roo-radio-' + this.weight;
34228 cfg.cls += ' roo-radio-set-inline';
34232 ['xs','sm','md','lg'].map(function(size){
34233 if (settings[size]) {
34234 cfg.cls += ' col-' + size + '-' + settings[size];
34242 initEvents : function()
34244 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34245 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34247 if(!this.fieldLabel.length){
34248 this.labelEl.hide();
34251 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34252 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34254 this.indicator = this.indicatorEl();
34256 if(this.indicator){
34257 this.indicator.addClass('invisible');
34260 this.originalValue = this.getValue();
34264 inputEl: function ()
34266 return this.el.select('.roo-radio-set-input', true).first();
34269 getChildContainer : function()
34271 return this.itemsEl;
34274 register : function(item)
34276 this.radioes.push(item);
34280 validate : function()
34282 if(this.getVisibilityEl().hasClass('hidden')){
34288 Roo.each(this.radioes, function(i){
34297 if(this.allowBlank) {
34301 if(this.disabled || valid){
34306 this.markInvalid();
34311 markValid : function()
34313 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34314 this.indicatorEl().removeClass('visible');
34315 this.indicatorEl().addClass('invisible');
34319 if (Roo.bootstrap.version == 3) {
34320 this.el.removeClass([this.invalidClass, this.validClass]);
34321 this.el.addClass(this.validClass);
34323 this.el.removeClass(['is-invalid','is-valid']);
34324 this.el.addClass(['is-valid']);
34326 this.fireEvent('valid', this);
34329 markInvalid : function(msg)
34331 if(this.allowBlank || this.disabled){
34335 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34336 this.indicatorEl().removeClass('invisible');
34337 this.indicatorEl().addClass('visible');
34339 if (Roo.bootstrap.version == 3) {
34340 this.el.removeClass([this.invalidClass, this.validClass]);
34341 this.el.addClass(this.invalidClass);
34343 this.el.removeClass(['is-invalid','is-valid']);
34344 this.el.addClass(['is-invalid']);
34347 this.fireEvent('invalid', this, msg);
34351 setValue : function(v, suppressEvent)
34353 if(this.value === v){
34360 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34363 Roo.each(this.radioes, function(i){
34365 i.el.removeClass('checked');
34368 Roo.each(this.radioes, function(i){
34370 if(i.value === v || i.value.toString() === v.toString()){
34372 i.el.addClass('checked');
34374 if(suppressEvent !== true){
34375 this.fireEvent('check', this, i);
34386 clearInvalid : function(){
34388 if(!this.el || this.preventMark){
34392 this.el.removeClass([this.invalidClass]);
34394 this.fireEvent('valid', this);
34399 Roo.apply(Roo.bootstrap.RadioSet, {
34403 register : function(set)
34405 this.groups[set.name] = set;
34408 get: function(name)
34410 if (typeof(this.groups[name]) == 'undefined') {
34414 return this.groups[name] ;
34420 * Ext JS Library 1.1.1
34421 * Copyright(c) 2006-2007, Ext JS, LLC.
34423 * Originally Released Under LGPL - original licence link has changed is not relivant.
34426 * <script type="text/javascript">
34431 * @class Roo.bootstrap.SplitBar
34432 * @extends Roo.util.Observable
34433 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34437 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34438 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34439 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34440 split.minSize = 100;
34441 split.maxSize = 600;
34442 split.animate = true;
34443 split.on('moved', splitterMoved);
34446 * Create a new SplitBar
34447 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34448 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34449 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34450 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34451 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34452 position of the SplitBar).
34454 Roo.bootstrap.SplitBar = function(cfg){
34459 // dragElement : elm
34460 // resizingElement: el,
34462 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34463 // placement : Roo.bootstrap.SplitBar.LEFT ,
34464 // existingProxy ???
34467 this.el = Roo.get(cfg.dragElement, true);
34468 this.el.dom.unselectable = "on";
34470 this.resizingEl = Roo.get(cfg.resizingElement, true);
34474 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34475 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34478 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34481 * The minimum size of the resizing element. (Defaults to 0)
34487 * The maximum size of the resizing element. (Defaults to 2000)
34490 this.maxSize = 2000;
34493 * Whether to animate the transition to the new size
34496 this.animate = false;
34499 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34502 this.useShim = false;
34507 if(!cfg.existingProxy){
34509 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34511 this.proxy = Roo.get(cfg.existingProxy).dom;
34514 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34517 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34520 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34523 this.dragSpecs = {};
34526 * @private The adapter to use to positon and resize elements
34528 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34529 this.adapter.init(this);
34531 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34533 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34534 this.el.addClass("roo-splitbar-h");
34537 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34538 this.el.addClass("roo-splitbar-v");
34544 * Fires when the splitter is moved (alias for {@link #event-moved})
34545 * @param {Roo.bootstrap.SplitBar} this
34546 * @param {Number} newSize the new width or height
34551 * Fires when the splitter is moved
34552 * @param {Roo.bootstrap.SplitBar} this
34553 * @param {Number} newSize the new width or height
34557 * @event beforeresize
34558 * Fires before the splitter is dragged
34559 * @param {Roo.bootstrap.SplitBar} this
34561 "beforeresize" : true,
34563 "beforeapply" : true
34566 Roo.util.Observable.call(this);
34569 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34570 onStartProxyDrag : function(x, y){
34571 this.fireEvent("beforeresize", this);
34573 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34575 o.enableDisplayMode("block");
34576 // all splitbars share the same overlay
34577 Roo.bootstrap.SplitBar.prototype.overlay = o;
34579 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34580 this.overlay.show();
34581 Roo.get(this.proxy).setDisplayed("block");
34582 var size = this.adapter.getElementSize(this);
34583 this.activeMinSize = this.getMinimumSize();;
34584 this.activeMaxSize = this.getMaximumSize();;
34585 var c1 = size - this.activeMinSize;
34586 var c2 = Math.max(this.activeMaxSize - size, 0);
34587 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34588 this.dd.resetConstraints();
34589 this.dd.setXConstraint(
34590 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34591 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34593 this.dd.setYConstraint(0, 0);
34595 this.dd.resetConstraints();
34596 this.dd.setXConstraint(0, 0);
34597 this.dd.setYConstraint(
34598 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34599 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34602 this.dragSpecs.startSize = size;
34603 this.dragSpecs.startPoint = [x, y];
34604 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34608 * @private Called after the drag operation by the DDProxy
34610 onEndProxyDrag : function(e){
34611 Roo.get(this.proxy).setDisplayed(false);
34612 var endPoint = Roo.lib.Event.getXY(e);
34614 this.overlay.hide();
34617 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34618 newSize = this.dragSpecs.startSize +
34619 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34620 endPoint[0] - this.dragSpecs.startPoint[0] :
34621 this.dragSpecs.startPoint[0] - endPoint[0]
34624 newSize = this.dragSpecs.startSize +
34625 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34626 endPoint[1] - this.dragSpecs.startPoint[1] :
34627 this.dragSpecs.startPoint[1] - endPoint[1]
34630 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34631 if(newSize != this.dragSpecs.startSize){
34632 if(this.fireEvent('beforeapply', this, newSize) !== false){
34633 this.adapter.setElementSize(this, newSize);
34634 this.fireEvent("moved", this, newSize);
34635 this.fireEvent("resize", this, newSize);
34641 * Get the adapter this SplitBar uses
34642 * @return The adapter object
34644 getAdapter : function(){
34645 return this.adapter;
34649 * Set the adapter this SplitBar uses
34650 * @param {Object} adapter A SplitBar adapter object
34652 setAdapter : function(adapter){
34653 this.adapter = adapter;
34654 this.adapter.init(this);
34658 * Gets the minimum size for the resizing element
34659 * @return {Number} The minimum size
34661 getMinimumSize : function(){
34662 return this.minSize;
34666 * Sets the minimum size for the resizing element
34667 * @param {Number} minSize The minimum size
34669 setMinimumSize : function(minSize){
34670 this.minSize = minSize;
34674 * Gets the maximum size for the resizing element
34675 * @return {Number} The maximum size
34677 getMaximumSize : function(){
34678 return this.maxSize;
34682 * Sets the maximum size for the resizing element
34683 * @param {Number} maxSize The maximum size
34685 setMaximumSize : function(maxSize){
34686 this.maxSize = maxSize;
34690 * Sets the initialize size for the resizing element
34691 * @param {Number} size The initial size
34693 setCurrentSize : function(size){
34694 var oldAnimate = this.animate;
34695 this.animate = false;
34696 this.adapter.setElementSize(this, size);
34697 this.animate = oldAnimate;
34701 * Destroy this splitbar.
34702 * @param {Boolean} removeEl True to remove the element
34704 destroy : function(removeEl){
34706 this.shim.remove();
34709 this.proxy.parentNode.removeChild(this.proxy);
34717 * @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.
34719 Roo.bootstrap.SplitBar.createProxy = function(dir){
34720 var proxy = new Roo.Element(document.createElement("div"));
34721 proxy.unselectable();
34722 var cls = 'roo-splitbar-proxy';
34723 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34724 document.body.appendChild(proxy.dom);
34729 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34730 * Default Adapter. It assumes the splitter and resizing element are not positioned
34731 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34733 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34736 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34737 // do nothing for now
34738 init : function(s){
34742 * Called before drag operations to get the current size of the resizing element.
34743 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34745 getElementSize : function(s){
34746 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34747 return s.resizingEl.getWidth();
34749 return s.resizingEl.getHeight();
34754 * Called after drag operations to set the size of the resizing element.
34755 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34756 * @param {Number} newSize The new size to set
34757 * @param {Function} onComplete A function to be invoked when resizing is complete
34759 setElementSize : function(s, newSize, onComplete){
34760 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34762 s.resizingEl.setWidth(newSize);
34764 onComplete(s, newSize);
34767 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34772 s.resizingEl.setHeight(newSize);
34774 onComplete(s, newSize);
34777 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34784 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34785 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34786 * Adapter that moves the splitter element to align with the resized sizing element.
34787 * Used with an absolute positioned SplitBar.
34788 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34789 * document.body, make sure you assign an id to the body element.
34791 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34792 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34793 this.container = Roo.get(container);
34796 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34797 init : function(s){
34798 this.basic.init(s);
34801 getElementSize : function(s){
34802 return this.basic.getElementSize(s);
34805 setElementSize : function(s, newSize, onComplete){
34806 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34809 moveSplitter : function(s){
34810 var yes = Roo.bootstrap.SplitBar;
34811 switch(s.placement){
34813 s.el.setX(s.resizingEl.getRight());
34816 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34819 s.el.setY(s.resizingEl.getBottom());
34822 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34829 * Orientation constant - Create a vertical SplitBar
34833 Roo.bootstrap.SplitBar.VERTICAL = 1;
34836 * Orientation constant - Create a horizontal SplitBar
34840 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34843 * Placement constant - The resizing element is to the left of the splitter element
34847 Roo.bootstrap.SplitBar.LEFT = 1;
34850 * Placement constant - The resizing element is to the right of the splitter element
34854 Roo.bootstrap.SplitBar.RIGHT = 2;
34857 * Placement constant - The resizing element is positioned above the splitter element
34861 Roo.bootstrap.SplitBar.TOP = 3;
34864 * Placement constant - The resizing element is positioned under splitter element
34868 Roo.bootstrap.SplitBar.BOTTOM = 4;
34869 Roo.namespace("Roo.bootstrap.layout");/*
34871 * Ext JS Library 1.1.1
34872 * Copyright(c) 2006-2007, Ext JS, LLC.
34874 * Originally Released Under LGPL - original licence link has changed is not relivant.
34877 * <script type="text/javascript">
34881 * @class Roo.bootstrap.layout.Manager
34882 * @extends Roo.bootstrap.Component
34883 * Base class for layout managers.
34885 Roo.bootstrap.layout.Manager = function(config)
34887 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34893 /** false to disable window resize monitoring @type Boolean */
34894 this.monitorWindowResize = true;
34899 * Fires when a layout is performed.
34900 * @param {Roo.LayoutManager} this
34904 * @event regionresized
34905 * Fires when the user resizes a region.
34906 * @param {Roo.LayoutRegion} region The resized region
34907 * @param {Number} newSize The new size (width for east/west, height for north/south)
34909 "regionresized" : true,
34911 * @event regioncollapsed
34912 * Fires when a region is collapsed.
34913 * @param {Roo.LayoutRegion} region The collapsed region
34915 "regioncollapsed" : true,
34917 * @event regionexpanded
34918 * Fires when a region is expanded.
34919 * @param {Roo.LayoutRegion} region The expanded region
34921 "regionexpanded" : true
34923 this.updating = false;
34926 this.el = Roo.get(config.el);
34932 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34937 monitorWindowResize : true,
34943 onRender : function(ct, position)
34946 this.el = Roo.get(ct);
34949 //this.fireEvent('render',this);
34953 initEvents: function()
34957 // ie scrollbar fix
34958 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34959 document.body.scroll = "no";
34960 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34961 this.el.position('relative');
34963 this.id = this.el.id;
34964 this.el.addClass("roo-layout-container");
34965 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34966 if(this.el.dom != document.body ) {
34967 this.el.on('resize', this.layout,this);
34968 this.el.on('show', this.layout,this);
34974 * Returns true if this layout is currently being updated
34975 * @return {Boolean}
34977 isUpdating : function(){
34978 return this.updating;
34982 * Suspend the LayoutManager from doing auto-layouts while
34983 * making multiple add or remove calls
34985 beginUpdate : function(){
34986 this.updating = true;
34990 * Restore auto-layouts and optionally disable the manager from performing a layout
34991 * @param {Boolean} noLayout true to disable a layout update
34993 endUpdate : function(noLayout){
34994 this.updating = false;
35000 layout: function(){
35004 onRegionResized : function(region, newSize){
35005 this.fireEvent("regionresized", region, newSize);
35009 onRegionCollapsed : function(region){
35010 this.fireEvent("regioncollapsed", region);
35013 onRegionExpanded : function(region){
35014 this.fireEvent("regionexpanded", region);
35018 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35019 * performs box-model adjustments.
35020 * @return {Object} The size as an object {width: (the width), height: (the height)}
35022 getViewSize : function()
35025 if(this.el.dom != document.body){
35026 size = this.el.getSize();
35028 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35030 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35031 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35036 * Returns the Element this layout is bound to.
35037 * @return {Roo.Element}
35039 getEl : function(){
35044 * Returns the specified region.
35045 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35046 * @return {Roo.LayoutRegion}
35048 getRegion : function(target){
35049 return this.regions[target.toLowerCase()];
35052 onWindowResize : function(){
35053 if(this.monitorWindowResize){
35060 * Ext JS Library 1.1.1
35061 * Copyright(c) 2006-2007, Ext JS, LLC.
35063 * Originally Released Under LGPL - original licence link has changed is not relivant.
35066 * <script type="text/javascript">
35069 * @class Roo.bootstrap.layout.Border
35070 * @extends Roo.bootstrap.layout.Manager
35071 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35072 * please see: examples/bootstrap/nested.html<br><br>
35074 <b>The container the layout is rendered into can be either the body element or any other element.
35075 If it is not the body element, the container needs to either be an absolute positioned element,
35076 or you will need to add "position:relative" to the css of the container. You will also need to specify
35077 the container size if it is not the body element.</b>
35080 * Create a new Border
35081 * @param {Object} config Configuration options
35083 Roo.bootstrap.layout.Border = function(config){
35084 config = config || {};
35085 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35089 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35090 if(config[region]){
35091 config[region].region = region;
35092 this.addRegion(config[region]);
35098 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35100 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35102 * Creates and adds a new region if it doesn't already exist.
35103 * @param {String} target The target region key (north, south, east, west or center).
35104 * @param {Object} config The regions config object
35105 * @return {BorderLayoutRegion} The new region
35107 addRegion : function(config)
35109 if(!this.regions[config.region]){
35110 var r = this.factory(config);
35111 this.bindRegion(r);
35113 return this.regions[config.region];
35117 bindRegion : function(r){
35118 this.regions[r.config.region] = r;
35120 r.on("visibilitychange", this.layout, this);
35121 r.on("paneladded", this.layout, this);
35122 r.on("panelremoved", this.layout, this);
35123 r.on("invalidated", this.layout, this);
35124 r.on("resized", this.onRegionResized, this);
35125 r.on("collapsed", this.onRegionCollapsed, this);
35126 r.on("expanded", this.onRegionExpanded, this);
35130 * Performs a layout update.
35132 layout : function()
35134 if(this.updating) {
35138 // render all the rebions if they have not been done alreayd?
35139 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35140 if(this.regions[region] && !this.regions[region].bodyEl){
35141 this.regions[region].onRender(this.el)
35145 var size = this.getViewSize();
35146 var w = size.width;
35147 var h = size.height;
35152 //var x = 0, y = 0;
35154 var rs = this.regions;
35155 var north = rs["north"];
35156 var south = rs["south"];
35157 var west = rs["west"];
35158 var east = rs["east"];
35159 var center = rs["center"];
35160 //if(this.hideOnLayout){ // not supported anymore
35161 //c.el.setStyle("display", "none");
35163 if(north && north.isVisible()){
35164 var b = north.getBox();
35165 var m = north.getMargins();
35166 b.width = w - (m.left+m.right);
35169 centerY = b.height + b.y + m.bottom;
35170 centerH -= centerY;
35171 north.updateBox(this.safeBox(b));
35173 if(south && south.isVisible()){
35174 var b = south.getBox();
35175 var m = south.getMargins();
35176 b.width = w - (m.left+m.right);
35178 var totalHeight = (b.height + m.top + m.bottom);
35179 b.y = h - totalHeight + m.top;
35180 centerH -= totalHeight;
35181 south.updateBox(this.safeBox(b));
35183 if(west && west.isVisible()){
35184 var b = west.getBox();
35185 var m = west.getMargins();
35186 b.height = centerH - (m.top+m.bottom);
35188 b.y = centerY + m.top;
35189 var totalWidth = (b.width + m.left + m.right);
35190 centerX += totalWidth;
35191 centerW -= totalWidth;
35192 west.updateBox(this.safeBox(b));
35194 if(east && east.isVisible()){
35195 var b = east.getBox();
35196 var m = east.getMargins();
35197 b.height = centerH - (m.top+m.bottom);
35198 var totalWidth = (b.width + m.left + m.right);
35199 b.x = w - totalWidth + m.left;
35200 b.y = centerY + m.top;
35201 centerW -= totalWidth;
35202 east.updateBox(this.safeBox(b));
35205 var m = center.getMargins();
35207 x: centerX + m.left,
35208 y: centerY + m.top,
35209 width: centerW - (m.left+m.right),
35210 height: centerH - (m.top+m.bottom)
35212 //if(this.hideOnLayout){
35213 //center.el.setStyle("display", "block");
35215 center.updateBox(this.safeBox(centerBox));
35218 this.fireEvent("layout", this);
35222 safeBox : function(box){
35223 box.width = Math.max(0, box.width);
35224 box.height = Math.max(0, box.height);
35229 * Adds a ContentPanel (or subclass) to this layout.
35230 * @param {String} target The target region key (north, south, east, west or center).
35231 * @param {Roo.ContentPanel} panel The panel to add
35232 * @return {Roo.ContentPanel} The added panel
35234 add : function(target, panel){
35236 target = target.toLowerCase();
35237 return this.regions[target].add(panel);
35241 * Remove a ContentPanel (or subclass) to this layout.
35242 * @param {String} target The target region key (north, south, east, west or center).
35243 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35244 * @return {Roo.ContentPanel} The removed panel
35246 remove : function(target, panel){
35247 target = target.toLowerCase();
35248 return this.regions[target].remove(panel);
35252 * Searches all regions for a panel with the specified id
35253 * @param {String} panelId
35254 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35256 findPanel : function(panelId){
35257 var rs = this.regions;
35258 for(var target in rs){
35259 if(typeof rs[target] != "function"){
35260 var p = rs[target].getPanel(panelId);
35270 * Searches all regions for a panel with the specified id and activates (shows) it.
35271 * @param {String/ContentPanel} panelId The panels id or the panel itself
35272 * @return {Roo.ContentPanel} The shown panel or null
35274 showPanel : function(panelId) {
35275 var rs = this.regions;
35276 for(var target in rs){
35277 var r = rs[target];
35278 if(typeof r != "function"){
35279 if(r.hasPanel(panelId)){
35280 return r.showPanel(panelId);
35288 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35289 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35292 restoreState : function(provider){
35294 provider = Roo.state.Manager;
35296 var sm = new Roo.LayoutStateManager();
35297 sm.init(this, provider);
35303 * Adds a xtype elements to the layout.
35307 xtype : 'ContentPanel',
35314 xtype : 'NestedLayoutPanel',
35320 items : [ ... list of content panels or nested layout panels.. ]
35324 * @param {Object} cfg Xtype definition of item to add.
35326 addxtype : function(cfg)
35328 // basically accepts a pannel...
35329 // can accept a layout region..!?!?
35330 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35333 // theory? children can only be panels??
35335 //if (!cfg.xtype.match(/Panel$/)) {
35340 if (typeof(cfg.region) == 'undefined') {
35341 Roo.log("Failed to add Panel, region was not set");
35345 var region = cfg.region;
35351 xitems = cfg.items;
35358 case 'Content': // ContentPanel (el, cfg)
35359 case 'Scroll': // ContentPanel (el, cfg)
35361 cfg.autoCreate = true;
35362 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35364 // var el = this.el.createChild();
35365 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35368 this.add(region, ret);
35372 case 'TreePanel': // our new panel!
35373 cfg.el = this.el.createChild();
35374 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35375 this.add(region, ret);
35380 // create a new Layout (which is a Border Layout...
35382 var clayout = cfg.layout;
35383 clayout.el = this.el.createChild();
35384 clayout.items = clayout.items || [];
35388 // replace this exitems with the clayout ones..
35389 xitems = clayout.items;
35391 // force background off if it's in center...
35392 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35393 cfg.background = false;
35395 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35398 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35399 //console.log('adding nested layout panel ' + cfg.toSource());
35400 this.add(region, ret);
35401 nb = {}; /// find first...
35406 // needs grid and region
35408 //var el = this.getRegion(region).el.createChild();
35410 *var el = this.el.createChild();
35411 // create the grid first...
35412 cfg.grid.container = el;
35413 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35416 if (region == 'center' && this.active ) {
35417 cfg.background = false;
35420 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35422 this.add(region, ret);
35424 if (cfg.background) {
35425 // render grid on panel activation (if panel background)
35426 ret.on('activate', function(gp) {
35427 if (!gp.grid.rendered) {
35428 // gp.grid.render(el);
35432 // cfg.grid.render(el);
35438 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35439 // it was the old xcomponent building that caused this before.
35440 // espeically if border is the top element in the tree.
35450 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35452 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35453 this.add(region, ret);
35457 throw "Can not add '" + cfg.xtype + "' to Border";
35463 this.beginUpdate();
35467 Roo.each(xitems, function(i) {
35468 region = nb && i.region ? i.region : false;
35470 var add = ret.addxtype(i);
35473 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35474 if (!i.background) {
35475 abn[region] = nb[region] ;
35482 // make the last non-background panel active..
35483 //if (nb) { Roo.log(abn); }
35486 for(var r in abn) {
35487 region = this.getRegion(r);
35489 // tried using nb[r], but it does not work..
35491 region.showPanel(abn[r]);
35502 factory : function(cfg)
35505 var validRegions = Roo.bootstrap.layout.Border.regions;
35507 var target = cfg.region;
35510 var r = Roo.bootstrap.layout;
35514 return new r.North(cfg);
35516 return new r.South(cfg);
35518 return new r.East(cfg);
35520 return new r.West(cfg);
35522 return new r.Center(cfg);
35524 throw 'Layout region "'+target+'" not supported.';
35531 * Ext JS Library 1.1.1
35532 * Copyright(c) 2006-2007, Ext JS, LLC.
35534 * Originally Released Under LGPL - original licence link has changed is not relivant.
35537 * <script type="text/javascript">
35541 * @class Roo.bootstrap.layout.Basic
35542 * @extends Roo.util.Observable
35543 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35544 * and does not have a titlebar, tabs or any other features. All it does is size and position
35545 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35546 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35547 * @cfg {string} region the region that it inhabits..
35548 * @cfg {bool} skipConfig skip config?
35552 Roo.bootstrap.layout.Basic = function(config){
35554 this.mgr = config.mgr;
35556 this.position = config.region;
35558 var skipConfig = config.skipConfig;
35562 * @scope Roo.BasicLayoutRegion
35566 * @event beforeremove
35567 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35568 * @param {Roo.LayoutRegion} this
35569 * @param {Roo.ContentPanel} panel The panel
35570 * @param {Object} e The cancel event object
35572 "beforeremove" : true,
35574 * @event invalidated
35575 * Fires when the layout for this region is changed.
35576 * @param {Roo.LayoutRegion} this
35578 "invalidated" : true,
35580 * @event visibilitychange
35581 * Fires when this region is shown or hidden
35582 * @param {Roo.LayoutRegion} this
35583 * @param {Boolean} visibility true or false
35585 "visibilitychange" : true,
35587 * @event paneladded
35588 * Fires when a panel is added.
35589 * @param {Roo.LayoutRegion} this
35590 * @param {Roo.ContentPanel} panel The panel
35592 "paneladded" : true,
35594 * @event panelremoved
35595 * Fires when a panel is removed.
35596 * @param {Roo.LayoutRegion} this
35597 * @param {Roo.ContentPanel} panel The panel
35599 "panelremoved" : true,
35601 * @event beforecollapse
35602 * Fires when this region before collapse.
35603 * @param {Roo.LayoutRegion} this
35605 "beforecollapse" : true,
35608 * Fires when this region is collapsed.
35609 * @param {Roo.LayoutRegion} this
35611 "collapsed" : true,
35614 * Fires when this region is expanded.
35615 * @param {Roo.LayoutRegion} this
35620 * Fires when this region is slid into view.
35621 * @param {Roo.LayoutRegion} this
35623 "slideshow" : true,
35626 * Fires when this region slides out of view.
35627 * @param {Roo.LayoutRegion} this
35629 "slidehide" : true,
35631 * @event panelactivated
35632 * Fires when a panel is activated.
35633 * @param {Roo.LayoutRegion} this
35634 * @param {Roo.ContentPanel} panel The activated panel
35636 "panelactivated" : true,
35639 * Fires when the user resizes this region.
35640 * @param {Roo.LayoutRegion} this
35641 * @param {Number} newSize The new size (width for east/west, height for north/south)
35645 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35646 this.panels = new Roo.util.MixedCollection();
35647 this.panels.getKey = this.getPanelId.createDelegate(this);
35649 this.activePanel = null;
35650 // ensure listeners are added...
35652 if (config.listeners || config.events) {
35653 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35654 listeners : config.listeners || {},
35655 events : config.events || {}
35659 if(skipConfig !== true){
35660 this.applyConfig(config);
35664 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35666 getPanelId : function(p){
35670 applyConfig : function(config){
35671 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35672 this.config = config;
35677 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35678 * the width, for horizontal (north, south) the height.
35679 * @param {Number} newSize The new width or height
35681 resizeTo : function(newSize){
35682 var el = this.el ? this.el :
35683 (this.activePanel ? this.activePanel.getEl() : null);
35685 switch(this.position){
35688 el.setWidth(newSize);
35689 this.fireEvent("resized", this, newSize);
35693 el.setHeight(newSize);
35694 this.fireEvent("resized", this, newSize);
35700 getBox : function(){
35701 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35704 getMargins : function(){
35705 return this.margins;
35708 updateBox : function(box){
35710 var el = this.activePanel.getEl();
35711 el.dom.style.left = box.x + "px";
35712 el.dom.style.top = box.y + "px";
35713 this.activePanel.setSize(box.width, box.height);
35717 * Returns the container element for this region.
35718 * @return {Roo.Element}
35720 getEl : function(){
35721 return this.activePanel;
35725 * Returns true if this region is currently visible.
35726 * @return {Boolean}
35728 isVisible : function(){
35729 return this.activePanel ? true : false;
35732 setActivePanel : function(panel){
35733 panel = this.getPanel(panel);
35734 if(this.activePanel && this.activePanel != panel){
35735 this.activePanel.setActiveState(false);
35736 this.activePanel.getEl().setLeftTop(-10000,-10000);
35738 this.activePanel = panel;
35739 panel.setActiveState(true);
35741 panel.setSize(this.box.width, this.box.height);
35743 this.fireEvent("panelactivated", this, panel);
35744 this.fireEvent("invalidated");
35748 * Show the specified panel.
35749 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35750 * @return {Roo.ContentPanel} The shown panel or null
35752 showPanel : function(panel){
35753 panel = this.getPanel(panel);
35755 this.setActivePanel(panel);
35761 * Get the active panel for this region.
35762 * @return {Roo.ContentPanel} The active panel or null
35764 getActivePanel : function(){
35765 return this.activePanel;
35769 * Add the passed ContentPanel(s)
35770 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35771 * @return {Roo.ContentPanel} The panel added (if only one was added)
35773 add : function(panel){
35774 if(arguments.length > 1){
35775 for(var i = 0, len = arguments.length; i < len; i++) {
35776 this.add(arguments[i]);
35780 if(this.hasPanel(panel)){
35781 this.showPanel(panel);
35784 var el = panel.getEl();
35785 if(el.dom.parentNode != this.mgr.el.dom){
35786 this.mgr.el.dom.appendChild(el.dom);
35788 if(panel.setRegion){
35789 panel.setRegion(this);
35791 this.panels.add(panel);
35792 el.setStyle("position", "absolute");
35793 if(!panel.background){
35794 this.setActivePanel(panel);
35795 if(this.config.initialSize && this.panels.getCount()==1){
35796 this.resizeTo(this.config.initialSize);
35799 this.fireEvent("paneladded", this, panel);
35804 * Returns true if the panel is in this region.
35805 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35806 * @return {Boolean}
35808 hasPanel : function(panel){
35809 if(typeof panel == "object"){ // must be panel obj
35810 panel = panel.getId();
35812 return this.getPanel(panel) ? true : false;
35816 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35817 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35818 * @param {Boolean} preservePanel Overrides the config preservePanel option
35819 * @return {Roo.ContentPanel} The panel that was removed
35821 remove : function(panel, preservePanel){
35822 panel = this.getPanel(panel);
35827 this.fireEvent("beforeremove", this, panel, e);
35828 if(e.cancel === true){
35831 var panelId = panel.getId();
35832 this.panels.removeKey(panelId);
35837 * Returns the panel specified or null if it's not in this region.
35838 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35839 * @return {Roo.ContentPanel}
35841 getPanel : function(id){
35842 if(typeof id == "object"){ // must be panel obj
35845 return this.panels.get(id);
35849 * Returns this regions position (north/south/east/west/center).
35852 getPosition: function(){
35853 return this.position;
35857 * Ext JS Library 1.1.1
35858 * Copyright(c) 2006-2007, Ext JS, LLC.
35860 * Originally Released Under LGPL - original licence link has changed is not relivant.
35863 * <script type="text/javascript">
35867 * @class Roo.bootstrap.layout.Region
35868 * @extends Roo.bootstrap.layout.Basic
35869 * This class represents a region in a layout manager.
35871 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35872 * @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})
35873 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35874 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35875 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35876 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35877 * @cfg {String} title The title for the region (overrides panel titles)
35878 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35879 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35880 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35881 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35882 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35883 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35884 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35885 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35886 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35887 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35889 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35890 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35891 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35892 * @cfg {Number} width For East/West panels
35893 * @cfg {Number} height For North/South panels
35894 * @cfg {Boolean} split To show the splitter
35895 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35897 * @cfg {string} cls Extra CSS classes to add to region
35899 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35900 * @cfg {string} region the region that it inhabits..
35903 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35904 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35906 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35907 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35908 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35910 Roo.bootstrap.layout.Region = function(config)
35912 this.applyConfig(config);
35914 var mgr = config.mgr;
35915 var pos = config.region;
35916 config.skipConfig = true;
35917 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35920 this.onRender(mgr.el);
35923 this.visible = true;
35924 this.collapsed = false;
35925 this.unrendered_panels = [];
35928 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35930 position: '', // set by wrapper (eg. north/south etc..)
35931 unrendered_panels : null, // unrendered panels.
35932 createBody : function(){
35933 /** This region's body element
35934 * @type Roo.Element */
35935 this.bodyEl = this.el.createChild({
35937 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35941 onRender: function(ctr, pos)
35943 var dh = Roo.DomHelper;
35944 /** This region's container element
35945 * @type Roo.Element */
35946 this.el = dh.append(ctr.dom, {
35948 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35950 /** This region's title element
35951 * @type Roo.Element */
35953 this.titleEl = dh.append(this.el.dom,
35956 unselectable: "on",
35957 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35959 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35960 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35963 this.titleEl.enableDisplayMode();
35964 /** This region's title text element
35965 * @type HTMLElement */
35966 this.titleTextEl = this.titleEl.dom.firstChild;
35967 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35969 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35970 this.closeBtn.enableDisplayMode();
35971 this.closeBtn.on("click", this.closeClicked, this);
35972 this.closeBtn.hide();
35974 this.createBody(this.config);
35975 if(this.config.hideWhenEmpty){
35977 this.on("paneladded", this.validateVisibility, this);
35978 this.on("panelremoved", this.validateVisibility, this);
35980 if(this.autoScroll){
35981 this.bodyEl.setStyle("overflow", "auto");
35983 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35985 //if(c.titlebar !== false){
35986 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35987 this.titleEl.hide();
35989 this.titleEl.show();
35990 if(this.config.title){
35991 this.titleTextEl.innerHTML = this.config.title;
35995 if(this.config.collapsed){
35996 this.collapse(true);
35998 if(this.config.hidden){
36002 if (this.unrendered_panels && this.unrendered_panels.length) {
36003 for (var i =0;i< this.unrendered_panels.length; i++) {
36004 this.add(this.unrendered_panels[i]);
36006 this.unrendered_panels = null;
36012 applyConfig : function(c)
36015 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36016 var dh = Roo.DomHelper;
36017 if(c.titlebar !== false){
36018 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36019 this.collapseBtn.on("click", this.collapse, this);
36020 this.collapseBtn.enableDisplayMode();
36022 if(c.showPin === true || this.showPin){
36023 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36024 this.stickBtn.enableDisplayMode();
36025 this.stickBtn.on("click", this.expand, this);
36026 this.stickBtn.hide();
36031 /** This region's collapsed element
36032 * @type Roo.Element */
36035 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36036 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36039 if(c.floatable !== false){
36040 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36041 this.collapsedEl.on("click", this.collapseClick, this);
36044 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36045 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36046 id: "message", unselectable: "on", style:{"float":"left"}});
36047 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36049 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36050 this.expandBtn.on("click", this.expand, this);
36054 if(this.collapseBtn){
36055 this.collapseBtn.setVisible(c.collapsible == true);
36058 this.cmargins = c.cmargins || this.cmargins ||
36059 (this.position == "west" || this.position == "east" ?
36060 {top: 0, left: 2, right:2, bottom: 0} :
36061 {top: 2, left: 0, right:0, bottom: 2});
36063 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36066 this.bottomTabs = c.tabPosition != "top";
36068 this.autoScroll = c.autoScroll || false;
36073 this.duration = c.duration || .30;
36074 this.slideDuration = c.slideDuration || .45;
36079 * Returns true if this region is currently visible.
36080 * @return {Boolean}
36082 isVisible : function(){
36083 return this.visible;
36087 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36088 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36090 //setCollapsedTitle : function(title){
36091 // title = title || " ";
36092 // if(this.collapsedTitleTextEl){
36093 // this.collapsedTitleTextEl.innerHTML = title;
36097 getBox : function(){
36099 // if(!this.collapsed){
36100 b = this.el.getBox(false, true);
36102 // b = this.collapsedEl.getBox(false, true);
36107 getMargins : function(){
36108 return this.margins;
36109 //return this.collapsed ? this.cmargins : this.margins;
36112 highlight : function(){
36113 this.el.addClass("x-layout-panel-dragover");
36116 unhighlight : function(){
36117 this.el.removeClass("x-layout-panel-dragover");
36120 updateBox : function(box)
36122 if (!this.bodyEl) {
36123 return; // not rendered yet..
36127 if(!this.collapsed){
36128 this.el.dom.style.left = box.x + "px";
36129 this.el.dom.style.top = box.y + "px";
36130 this.updateBody(box.width, box.height);
36132 this.collapsedEl.dom.style.left = box.x + "px";
36133 this.collapsedEl.dom.style.top = box.y + "px";
36134 this.collapsedEl.setSize(box.width, box.height);
36137 this.tabs.autoSizeTabs();
36141 updateBody : function(w, h)
36144 this.el.setWidth(w);
36145 w -= this.el.getBorderWidth("rl");
36146 if(this.config.adjustments){
36147 w += this.config.adjustments[0];
36150 if(h !== null && h > 0){
36151 this.el.setHeight(h);
36152 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36153 h -= this.el.getBorderWidth("tb");
36154 if(this.config.adjustments){
36155 h += this.config.adjustments[1];
36157 this.bodyEl.setHeight(h);
36159 h = this.tabs.syncHeight(h);
36162 if(this.panelSize){
36163 w = w !== null ? w : this.panelSize.width;
36164 h = h !== null ? h : this.panelSize.height;
36166 if(this.activePanel){
36167 var el = this.activePanel.getEl();
36168 w = w !== null ? w : el.getWidth();
36169 h = h !== null ? h : el.getHeight();
36170 this.panelSize = {width: w, height: h};
36171 this.activePanel.setSize(w, h);
36173 if(Roo.isIE && this.tabs){
36174 this.tabs.el.repaint();
36179 * Returns the container element for this region.
36180 * @return {Roo.Element}
36182 getEl : function(){
36187 * Hides this region.
36190 //if(!this.collapsed){
36191 this.el.dom.style.left = "-2000px";
36194 // this.collapsedEl.dom.style.left = "-2000px";
36195 // this.collapsedEl.hide();
36197 this.visible = false;
36198 this.fireEvent("visibilitychange", this, false);
36202 * Shows this region if it was previously hidden.
36205 //if(!this.collapsed){
36208 // this.collapsedEl.show();
36210 this.visible = true;
36211 this.fireEvent("visibilitychange", this, true);
36214 closeClicked : function(){
36215 if(this.activePanel){
36216 this.remove(this.activePanel);
36220 collapseClick : function(e){
36222 e.stopPropagation();
36225 e.stopPropagation();
36231 * Collapses this region.
36232 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36235 collapse : function(skipAnim, skipCheck = false){
36236 if(this.collapsed) {
36240 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36242 this.collapsed = true;
36244 this.split.el.hide();
36246 if(this.config.animate && skipAnim !== true){
36247 this.fireEvent("invalidated", this);
36248 this.animateCollapse();
36250 this.el.setLocation(-20000,-20000);
36252 this.collapsedEl.show();
36253 this.fireEvent("collapsed", this);
36254 this.fireEvent("invalidated", this);
36260 animateCollapse : function(){
36265 * Expands this region if it was previously collapsed.
36266 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36267 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36270 expand : function(e, skipAnim){
36272 e.stopPropagation();
36274 if(!this.collapsed || this.el.hasActiveFx()) {
36278 this.afterSlideIn();
36281 this.collapsed = false;
36282 if(this.config.animate && skipAnim !== true){
36283 this.animateExpand();
36287 this.split.el.show();
36289 this.collapsedEl.setLocation(-2000,-2000);
36290 this.collapsedEl.hide();
36291 this.fireEvent("invalidated", this);
36292 this.fireEvent("expanded", this);
36296 animateExpand : function(){
36300 initTabs : function()
36302 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36304 var ts = new Roo.bootstrap.panel.Tabs({
36305 el: this.bodyEl.dom,
36306 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36307 disableTooltips: this.config.disableTabTips,
36308 toolbar : this.config.toolbar
36311 if(this.config.hideTabs){
36312 ts.stripWrap.setDisplayed(false);
36315 ts.resizeTabs = this.config.resizeTabs === true;
36316 ts.minTabWidth = this.config.minTabWidth || 40;
36317 ts.maxTabWidth = this.config.maxTabWidth || 250;
36318 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36319 ts.monitorResize = false;
36320 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36321 ts.bodyEl.addClass('roo-layout-tabs-body');
36322 this.panels.each(this.initPanelAsTab, this);
36325 initPanelAsTab : function(panel){
36326 var ti = this.tabs.addTab(
36330 this.config.closeOnTab && panel.isClosable(),
36333 if(panel.tabTip !== undefined){
36334 ti.setTooltip(panel.tabTip);
36336 ti.on("activate", function(){
36337 this.setActivePanel(panel);
36340 if(this.config.closeOnTab){
36341 ti.on("beforeclose", function(t, e){
36343 this.remove(panel);
36347 panel.tabItem = ti;
36352 updatePanelTitle : function(panel, title)
36354 if(this.activePanel == panel){
36355 this.updateTitle(title);
36358 var ti = this.tabs.getTab(panel.getEl().id);
36360 if(panel.tabTip !== undefined){
36361 ti.setTooltip(panel.tabTip);
36366 updateTitle : function(title){
36367 if(this.titleTextEl && !this.config.title){
36368 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36372 setActivePanel : function(panel)
36374 panel = this.getPanel(panel);
36375 if(this.activePanel && this.activePanel != panel){
36376 if(this.activePanel.setActiveState(false) === false){
36380 this.activePanel = panel;
36381 panel.setActiveState(true);
36382 if(this.panelSize){
36383 panel.setSize(this.panelSize.width, this.panelSize.height);
36386 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36388 this.updateTitle(panel.getTitle());
36390 this.fireEvent("invalidated", this);
36392 this.fireEvent("panelactivated", this, panel);
36396 * Shows the specified panel.
36397 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36398 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36400 showPanel : function(panel)
36402 panel = this.getPanel(panel);
36405 var tab = this.tabs.getTab(panel.getEl().id);
36406 if(tab.isHidden()){
36407 this.tabs.unhideTab(tab.id);
36411 this.setActivePanel(panel);
36418 * Get the active panel for this region.
36419 * @return {Roo.ContentPanel} The active panel or null
36421 getActivePanel : function(){
36422 return this.activePanel;
36425 validateVisibility : function(){
36426 if(this.panels.getCount() < 1){
36427 this.updateTitle(" ");
36428 this.closeBtn.hide();
36431 if(!this.isVisible()){
36438 * Adds the passed ContentPanel(s) to this region.
36439 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36440 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36442 add : function(panel)
36444 if(arguments.length > 1){
36445 for(var i = 0, len = arguments.length; i < len; i++) {
36446 this.add(arguments[i]);
36451 // if we have not been rendered yet, then we can not really do much of this..
36452 if (!this.bodyEl) {
36453 this.unrendered_panels.push(panel);
36460 if(this.hasPanel(panel)){
36461 this.showPanel(panel);
36464 panel.setRegion(this);
36465 this.panels.add(panel);
36466 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36467 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36468 // and hide them... ???
36469 this.bodyEl.dom.appendChild(panel.getEl().dom);
36470 if(panel.background !== true){
36471 this.setActivePanel(panel);
36473 this.fireEvent("paneladded", this, panel);
36480 this.initPanelAsTab(panel);
36484 if(panel.background !== true){
36485 this.tabs.activate(panel.getEl().id);
36487 this.fireEvent("paneladded", this, panel);
36492 * Hides the tab for the specified panel.
36493 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36495 hidePanel : function(panel){
36496 if(this.tabs && (panel = this.getPanel(panel))){
36497 this.tabs.hideTab(panel.getEl().id);
36502 * Unhides the tab for a previously hidden panel.
36503 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36505 unhidePanel : function(panel){
36506 if(this.tabs && (panel = this.getPanel(panel))){
36507 this.tabs.unhideTab(panel.getEl().id);
36511 clearPanels : function(){
36512 while(this.panels.getCount() > 0){
36513 this.remove(this.panels.first());
36518 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36519 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36520 * @param {Boolean} preservePanel Overrides the config preservePanel option
36521 * @return {Roo.ContentPanel} The panel that was removed
36523 remove : function(panel, preservePanel)
36525 panel = this.getPanel(panel);
36530 this.fireEvent("beforeremove", this, panel, e);
36531 if(e.cancel === true){
36534 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36535 var panelId = panel.getId();
36536 this.panels.removeKey(panelId);
36538 document.body.appendChild(panel.getEl().dom);
36541 this.tabs.removeTab(panel.getEl().id);
36542 }else if (!preservePanel){
36543 this.bodyEl.dom.removeChild(panel.getEl().dom);
36545 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36546 var p = this.panels.first();
36547 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36548 tempEl.appendChild(p.getEl().dom);
36549 this.bodyEl.update("");
36550 this.bodyEl.dom.appendChild(p.getEl().dom);
36552 this.updateTitle(p.getTitle());
36554 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36555 this.setActivePanel(p);
36557 panel.setRegion(null);
36558 if(this.activePanel == panel){
36559 this.activePanel = null;
36561 if(this.config.autoDestroy !== false && preservePanel !== true){
36562 try{panel.destroy();}catch(e){}
36564 this.fireEvent("panelremoved", this, panel);
36569 * Returns the TabPanel component used by this region
36570 * @return {Roo.TabPanel}
36572 getTabs : function(){
36576 createTool : function(parentEl, className){
36577 var btn = Roo.DomHelper.append(parentEl, {
36579 cls: "x-layout-tools-button",
36582 cls: "roo-layout-tools-button-inner " + className,
36586 btn.addClassOnOver("roo-layout-tools-button-over");
36591 * Ext JS Library 1.1.1
36592 * Copyright(c) 2006-2007, Ext JS, LLC.
36594 * Originally Released Under LGPL - original licence link has changed is not relivant.
36597 * <script type="text/javascript">
36603 * @class Roo.SplitLayoutRegion
36604 * @extends Roo.LayoutRegion
36605 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36607 Roo.bootstrap.layout.Split = function(config){
36608 this.cursor = config.cursor;
36609 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36612 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36614 splitTip : "Drag to resize.",
36615 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36616 useSplitTips : false,
36618 applyConfig : function(config){
36619 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36622 onRender : function(ctr,pos) {
36624 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36625 if(!this.config.split){
36630 var splitEl = Roo.DomHelper.append(ctr.dom, {
36632 id: this.el.id + "-split",
36633 cls: "roo-layout-split roo-layout-split-"+this.position,
36636 /** The SplitBar for this region
36637 * @type Roo.SplitBar */
36638 // does not exist yet...
36639 Roo.log([this.position, this.orientation]);
36641 this.split = new Roo.bootstrap.SplitBar({
36642 dragElement : splitEl,
36643 resizingElement: this.el,
36644 orientation : this.orientation
36647 this.split.on("moved", this.onSplitMove, this);
36648 this.split.useShim = this.config.useShim === true;
36649 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36650 if(this.useSplitTips){
36651 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36653 //if(config.collapsible){
36654 // this.split.el.on("dblclick", this.collapse, this);
36657 if(typeof this.config.minSize != "undefined"){
36658 this.split.minSize = this.config.minSize;
36660 if(typeof this.config.maxSize != "undefined"){
36661 this.split.maxSize = this.config.maxSize;
36663 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36664 this.hideSplitter();
36669 getHMaxSize : function(){
36670 var cmax = this.config.maxSize || 10000;
36671 var center = this.mgr.getRegion("center");
36672 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36675 getVMaxSize : function(){
36676 var cmax = this.config.maxSize || 10000;
36677 var center = this.mgr.getRegion("center");
36678 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36681 onSplitMove : function(split, newSize){
36682 this.fireEvent("resized", this, newSize);
36686 * Returns the {@link Roo.SplitBar} for this region.
36687 * @return {Roo.SplitBar}
36689 getSplitBar : function(){
36694 this.hideSplitter();
36695 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36698 hideSplitter : function(){
36700 this.split.el.setLocation(-2000,-2000);
36701 this.split.el.hide();
36707 this.split.el.show();
36709 Roo.bootstrap.layout.Split.superclass.show.call(this);
36712 beforeSlide: function(){
36713 if(Roo.isGecko){// firefox overflow auto bug workaround
36714 this.bodyEl.clip();
36716 this.tabs.bodyEl.clip();
36718 if(this.activePanel){
36719 this.activePanel.getEl().clip();
36721 if(this.activePanel.beforeSlide){
36722 this.activePanel.beforeSlide();
36728 afterSlide : function(){
36729 if(Roo.isGecko){// firefox overflow auto bug workaround
36730 this.bodyEl.unclip();
36732 this.tabs.bodyEl.unclip();
36734 if(this.activePanel){
36735 this.activePanel.getEl().unclip();
36736 if(this.activePanel.afterSlide){
36737 this.activePanel.afterSlide();
36743 initAutoHide : function(){
36744 if(this.autoHide !== false){
36745 if(!this.autoHideHd){
36746 var st = new Roo.util.DelayedTask(this.slideIn, this);
36747 this.autoHideHd = {
36748 "mouseout": function(e){
36749 if(!e.within(this.el, true)){
36753 "mouseover" : function(e){
36759 this.el.on(this.autoHideHd);
36763 clearAutoHide : function(){
36764 if(this.autoHide !== false){
36765 this.el.un("mouseout", this.autoHideHd.mouseout);
36766 this.el.un("mouseover", this.autoHideHd.mouseover);
36770 clearMonitor : function(){
36771 Roo.get(document).un("click", this.slideInIf, this);
36774 // these names are backwards but not changed for compat
36775 slideOut : function(){
36776 if(this.isSlid || this.el.hasActiveFx()){
36779 this.isSlid = true;
36780 if(this.collapseBtn){
36781 this.collapseBtn.hide();
36783 this.closeBtnState = this.closeBtn.getStyle('display');
36784 this.closeBtn.hide();
36786 this.stickBtn.show();
36789 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36790 this.beforeSlide();
36791 this.el.setStyle("z-index", 10001);
36792 this.el.slideIn(this.getSlideAnchor(), {
36793 callback: function(){
36795 this.initAutoHide();
36796 Roo.get(document).on("click", this.slideInIf, this);
36797 this.fireEvent("slideshow", this);
36804 afterSlideIn : function(){
36805 this.clearAutoHide();
36806 this.isSlid = false;
36807 this.clearMonitor();
36808 this.el.setStyle("z-index", "");
36809 if(this.collapseBtn){
36810 this.collapseBtn.show();
36812 this.closeBtn.setStyle('display', this.closeBtnState);
36814 this.stickBtn.hide();
36816 this.fireEvent("slidehide", this);
36819 slideIn : function(cb){
36820 if(!this.isSlid || this.el.hasActiveFx()){
36824 this.isSlid = false;
36825 this.beforeSlide();
36826 this.el.slideOut(this.getSlideAnchor(), {
36827 callback: function(){
36828 this.el.setLeftTop(-10000, -10000);
36830 this.afterSlideIn();
36838 slideInIf : function(e){
36839 if(!e.within(this.el)){
36844 animateCollapse : function(){
36845 this.beforeSlide();
36846 this.el.setStyle("z-index", 20000);
36847 var anchor = this.getSlideAnchor();
36848 this.el.slideOut(anchor, {
36849 callback : function(){
36850 this.el.setStyle("z-index", "");
36851 this.collapsedEl.slideIn(anchor, {duration:.3});
36853 this.el.setLocation(-10000,-10000);
36855 this.fireEvent("collapsed", this);
36862 animateExpand : function(){
36863 this.beforeSlide();
36864 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36865 this.el.setStyle("z-index", 20000);
36866 this.collapsedEl.hide({
36869 this.el.slideIn(this.getSlideAnchor(), {
36870 callback : function(){
36871 this.el.setStyle("z-index", "");
36874 this.split.el.show();
36876 this.fireEvent("invalidated", this);
36877 this.fireEvent("expanded", this);
36905 getAnchor : function(){
36906 return this.anchors[this.position];
36909 getCollapseAnchor : function(){
36910 return this.canchors[this.position];
36913 getSlideAnchor : function(){
36914 return this.sanchors[this.position];
36917 getAlignAdj : function(){
36918 var cm = this.cmargins;
36919 switch(this.position){
36935 getExpandAdj : function(){
36936 var c = this.collapsedEl, cm = this.cmargins;
36937 switch(this.position){
36939 return [-(cm.right+c.getWidth()+cm.left), 0];
36942 return [cm.right+c.getWidth()+cm.left, 0];
36945 return [0, -(cm.top+cm.bottom+c.getHeight())];
36948 return [0, cm.top+cm.bottom+c.getHeight()];
36954 * Ext JS Library 1.1.1
36955 * Copyright(c) 2006-2007, Ext JS, LLC.
36957 * Originally Released Under LGPL - original licence link has changed is not relivant.
36960 * <script type="text/javascript">
36963 * These classes are private internal classes
36965 Roo.bootstrap.layout.Center = function(config){
36966 config.region = "center";
36967 Roo.bootstrap.layout.Region.call(this, config);
36968 this.visible = true;
36969 this.minWidth = config.minWidth || 20;
36970 this.minHeight = config.minHeight || 20;
36973 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36975 // center panel can't be hidden
36979 // center panel can't be hidden
36982 getMinWidth: function(){
36983 return this.minWidth;
36986 getMinHeight: function(){
36987 return this.minHeight;
37000 Roo.bootstrap.layout.North = function(config)
37002 config.region = 'north';
37003 config.cursor = 'n-resize';
37005 Roo.bootstrap.layout.Split.call(this, config);
37009 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37010 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37011 this.split.el.addClass("roo-layout-split-v");
37013 var size = config.initialSize || config.height;
37014 if(typeof size != "undefined"){
37015 this.el.setHeight(size);
37018 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37020 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37024 getBox : function(){
37025 if(this.collapsed){
37026 return this.collapsedEl.getBox();
37028 var box = this.el.getBox();
37030 box.height += this.split.el.getHeight();
37035 updateBox : function(box){
37036 if(this.split && !this.collapsed){
37037 box.height -= this.split.el.getHeight();
37038 this.split.el.setLeft(box.x);
37039 this.split.el.setTop(box.y+box.height);
37040 this.split.el.setWidth(box.width);
37042 if(this.collapsed){
37043 this.updateBody(box.width, null);
37045 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37053 Roo.bootstrap.layout.South = function(config){
37054 config.region = 'south';
37055 config.cursor = 's-resize';
37056 Roo.bootstrap.layout.Split.call(this, config);
37058 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37059 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37060 this.split.el.addClass("roo-layout-split-v");
37062 var size = config.initialSize || config.height;
37063 if(typeof size != "undefined"){
37064 this.el.setHeight(size);
37068 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37069 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37070 getBox : function(){
37071 if(this.collapsed){
37072 return this.collapsedEl.getBox();
37074 var box = this.el.getBox();
37076 var sh = this.split.el.getHeight();
37083 updateBox : function(box){
37084 if(this.split && !this.collapsed){
37085 var sh = this.split.el.getHeight();
37088 this.split.el.setLeft(box.x);
37089 this.split.el.setTop(box.y-sh);
37090 this.split.el.setWidth(box.width);
37092 if(this.collapsed){
37093 this.updateBody(box.width, null);
37095 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37099 Roo.bootstrap.layout.East = function(config){
37100 config.region = "east";
37101 config.cursor = "e-resize";
37102 Roo.bootstrap.layout.Split.call(this, config);
37104 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37105 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37106 this.split.el.addClass("roo-layout-split-h");
37108 var size = config.initialSize || config.width;
37109 if(typeof size != "undefined"){
37110 this.el.setWidth(size);
37113 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37114 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37115 getBox : function(){
37116 if(this.collapsed){
37117 return this.collapsedEl.getBox();
37119 var box = this.el.getBox();
37121 var sw = this.split.el.getWidth();
37128 updateBox : function(box){
37129 if(this.split && !this.collapsed){
37130 var sw = this.split.el.getWidth();
37132 this.split.el.setLeft(box.x);
37133 this.split.el.setTop(box.y);
37134 this.split.el.setHeight(box.height);
37137 if(this.collapsed){
37138 this.updateBody(null, box.height);
37140 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37144 Roo.bootstrap.layout.West = function(config){
37145 config.region = "west";
37146 config.cursor = "w-resize";
37148 Roo.bootstrap.layout.Split.call(this, config);
37150 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37151 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37152 this.split.el.addClass("roo-layout-split-h");
37156 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37157 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37159 onRender: function(ctr, pos)
37161 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37162 var size = this.config.initialSize || this.config.width;
37163 if(typeof size != "undefined"){
37164 this.el.setWidth(size);
37168 getBox : function(){
37169 if(this.collapsed){
37170 return this.collapsedEl.getBox();
37172 var box = this.el.getBox();
37174 box.width += this.split.el.getWidth();
37179 updateBox : function(box){
37180 if(this.split && !this.collapsed){
37181 var sw = this.split.el.getWidth();
37183 this.split.el.setLeft(box.x+box.width);
37184 this.split.el.setTop(box.y);
37185 this.split.el.setHeight(box.height);
37187 if(this.collapsed){
37188 this.updateBody(null, box.height);
37190 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37193 Roo.namespace("Roo.bootstrap.panel");/*
37195 * Ext JS Library 1.1.1
37196 * Copyright(c) 2006-2007, Ext JS, LLC.
37198 * Originally Released Under LGPL - original licence link has changed is not relivant.
37201 * <script type="text/javascript">
37204 * @class Roo.ContentPanel
37205 * @extends Roo.util.Observable
37206 * A basic ContentPanel element.
37207 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37208 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37209 * @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
37210 * @cfg {Boolean} closable True if the panel can be closed/removed
37211 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37212 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37213 * @cfg {Toolbar} toolbar A toolbar for this panel
37214 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37215 * @cfg {String} title The title for this panel
37216 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37217 * @cfg {String} url Calls {@link #setUrl} with this value
37218 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37219 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37220 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37221 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37222 * @cfg {Boolean} badges render the badges
37225 * Create a new ContentPanel.
37226 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37227 * @param {String/Object} config A string to set only the title or a config object
37228 * @param {String} content (optional) Set the HTML content for this panel
37229 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37231 Roo.bootstrap.panel.Content = function( config){
37233 this.tpl = config.tpl || false;
37235 var el = config.el;
37236 var content = config.content;
37238 if(config.autoCreate){ // xtype is available if this is called from factory
37241 this.el = Roo.get(el);
37242 if(!this.el && config && config.autoCreate){
37243 if(typeof config.autoCreate == "object"){
37244 if(!config.autoCreate.id){
37245 config.autoCreate.id = config.id||el;
37247 this.el = Roo.DomHelper.append(document.body,
37248 config.autoCreate, true);
37250 var elcfg = { tag: "div",
37251 cls: "roo-layout-inactive-content",
37255 elcfg.html = config.html;
37259 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37262 this.closable = false;
37263 this.loaded = false;
37264 this.active = false;
37267 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37269 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37271 this.wrapEl = this.el; //this.el.wrap();
37273 if (config.toolbar.items) {
37274 ti = config.toolbar.items ;
37275 delete config.toolbar.items ;
37279 this.toolbar.render(this.wrapEl, 'before');
37280 for(var i =0;i < ti.length;i++) {
37281 // Roo.log(['add child', items[i]]);
37282 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37284 this.toolbar.items = nitems;
37285 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37286 delete config.toolbar;
37290 // xtype created footer. - not sure if will work as we normally have to render first..
37291 if (this.footer && !this.footer.el && this.footer.xtype) {
37292 if (!this.wrapEl) {
37293 this.wrapEl = this.el.wrap();
37296 this.footer.container = this.wrapEl.createChild();
37298 this.footer = Roo.factory(this.footer, Roo);
37303 if(typeof config == "string"){
37304 this.title = config;
37306 Roo.apply(this, config);
37310 this.resizeEl = Roo.get(this.resizeEl, true);
37312 this.resizeEl = this.el;
37314 // handle view.xtype
37322 * Fires when this panel is activated.
37323 * @param {Roo.ContentPanel} this
37327 * @event deactivate
37328 * Fires when this panel is activated.
37329 * @param {Roo.ContentPanel} this
37331 "deactivate" : true,
37335 * Fires when this panel is resized if fitToFrame is true.
37336 * @param {Roo.ContentPanel} this
37337 * @param {Number} width The width after any component adjustments
37338 * @param {Number} height The height after any component adjustments
37344 * Fires when this tab is created
37345 * @param {Roo.ContentPanel} this
37356 if(this.autoScroll){
37357 this.resizeEl.setStyle("overflow", "auto");
37359 // fix randome scrolling
37360 //this.el.on('scroll', function() {
37361 // Roo.log('fix random scolling');
37362 // this.scrollTo('top',0);
37365 content = content || this.content;
37367 this.setContent(content);
37369 if(config && config.url){
37370 this.setUrl(this.url, this.params, this.loadOnce);
37375 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37377 if (this.view && typeof(this.view.xtype) != 'undefined') {
37378 this.view.el = this.el.appendChild(document.createElement("div"));
37379 this.view = Roo.factory(this.view);
37380 this.view.render && this.view.render(false, '');
37384 this.fireEvent('render', this);
37387 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37391 setRegion : function(region){
37392 this.region = region;
37393 this.setActiveClass(region && !this.background);
37397 setActiveClass: function(state)
37400 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37401 this.el.setStyle('position','relative');
37403 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37404 this.el.setStyle('position', 'absolute');
37409 * Returns the toolbar for this Panel if one was configured.
37410 * @return {Roo.Toolbar}
37412 getToolbar : function(){
37413 return this.toolbar;
37416 setActiveState : function(active)
37418 this.active = active;
37419 this.setActiveClass(active);
37421 if(this.fireEvent("deactivate", this) === false){
37426 this.fireEvent("activate", this);
37430 * Updates this panel's element
37431 * @param {String} content The new content
37432 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37434 setContent : function(content, loadScripts){
37435 this.el.update(content, loadScripts);
37438 ignoreResize : function(w, h){
37439 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37442 this.lastSize = {width: w, height: h};
37447 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37448 * @return {Roo.UpdateManager} The UpdateManager
37450 getUpdateManager : function(){
37451 return this.el.getUpdateManager();
37454 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37455 * @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:
37458 url: "your-url.php",
37459 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37460 callback: yourFunction,
37461 scope: yourObject, //(optional scope)
37464 text: "Loading...",
37469 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37470 * 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.
37471 * @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}
37472 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37473 * @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.
37474 * @return {Roo.ContentPanel} this
37477 var um = this.el.getUpdateManager();
37478 um.update.apply(um, arguments);
37484 * 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.
37485 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37486 * @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)
37487 * @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)
37488 * @return {Roo.UpdateManager} The UpdateManager
37490 setUrl : function(url, params, loadOnce){
37491 if(this.refreshDelegate){
37492 this.removeListener("activate", this.refreshDelegate);
37494 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37495 this.on("activate", this.refreshDelegate);
37496 return this.el.getUpdateManager();
37499 _handleRefresh : function(url, params, loadOnce){
37500 if(!loadOnce || !this.loaded){
37501 var updater = this.el.getUpdateManager();
37502 updater.update(url, params, this._setLoaded.createDelegate(this));
37506 _setLoaded : function(){
37507 this.loaded = true;
37511 * Returns this panel's id
37514 getId : function(){
37519 * Returns this panel's element - used by regiosn to add.
37520 * @return {Roo.Element}
37522 getEl : function(){
37523 return this.wrapEl || this.el;
37528 adjustForComponents : function(width, height)
37530 //Roo.log('adjustForComponents ');
37531 if(this.resizeEl != this.el){
37532 width -= this.el.getFrameWidth('lr');
37533 height -= this.el.getFrameWidth('tb');
37536 var te = this.toolbar.getEl();
37537 te.setWidth(width);
37538 height -= te.getHeight();
37541 var te = this.footer.getEl();
37542 te.setWidth(width);
37543 height -= te.getHeight();
37547 if(this.adjustments){
37548 width += this.adjustments[0];
37549 height += this.adjustments[1];
37551 return {"width": width, "height": height};
37554 setSize : function(width, height){
37555 if(this.fitToFrame && !this.ignoreResize(width, height)){
37556 if(this.fitContainer && this.resizeEl != this.el){
37557 this.el.setSize(width, height);
37559 var size = this.adjustForComponents(width, height);
37560 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37561 this.fireEvent('resize', this, size.width, size.height);
37566 * Returns this panel's title
37569 getTitle : function(){
37571 if (typeof(this.title) != 'object') {
37576 for (var k in this.title) {
37577 if (!this.title.hasOwnProperty(k)) {
37581 if (k.indexOf('-') >= 0) {
37582 var s = k.split('-');
37583 for (var i = 0; i<s.length; i++) {
37584 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37587 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37594 * Set this panel's title
37595 * @param {String} title
37597 setTitle : function(title){
37598 this.title = title;
37600 this.region.updatePanelTitle(this, title);
37605 * Returns true is this panel was configured to be closable
37606 * @return {Boolean}
37608 isClosable : function(){
37609 return this.closable;
37612 beforeSlide : function(){
37614 this.resizeEl.clip();
37617 afterSlide : function(){
37619 this.resizeEl.unclip();
37623 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37624 * Will fail silently if the {@link #setUrl} method has not been called.
37625 * This does not activate the panel, just updates its content.
37627 refresh : function(){
37628 if(this.refreshDelegate){
37629 this.loaded = false;
37630 this.refreshDelegate();
37635 * Destroys this panel
37637 destroy : function(){
37638 this.el.removeAllListeners();
37639 var tempEl = document.createElement("span");
37640 tempEl.appendChild(this.el.dom);
37641 tempEl.innerHTML = "";
37647 * form - if the content panel contains a form - this is a reference to it.
37648 * @type {Roo.form.Form}
37652 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37653 * This contains a reference to it.
37659 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37669 * @param {Object} cfg Xtype definition of item to add.
37673 getChildContainer: function () {
37674 return this.getEl();
37679 var ret = new Roo.factory(cfg);
37684 if (cfg.xtype.match(/^Form$/)) {
37687 //if (this.footer) {
37688 // el = this.footer.container.insertSibling(false, 'before');
37690 el = this.el.createChild();
37693 this.form = new Roo.form.Form(cfg);
37696 if ( this.form.allItems.length) {
37697 this.form.render(el.dom);
37701 // should only have one of theses..
37702 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37703 // views.. should not be just added - used named prop 'view''
37705 cfg.el = this.el.appendChild(document.createElement("div"));
37708 var ret = new Roo.factory(cfg);
37710 ret.render && ret.render(false, ''); // render blank..
37720 * @class Roo.bootstrap.panel.Grid
37721 * @extends Roo.bootstrap.panel.Content
37723 * Create a new GridPanel.
37724 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37725 * @param {Object} config A the config object
37731 Roo.bootstrap.panel.Grid = function(config)
37735 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37736 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37738 config.el = this.wrapper;
37739 //this.el = this.wrapper;
37741 if (config.container) {
37742 // ctor'ed from a Border/panel.grid
37745 this.wrapper.setStyle("overflow", "hidden");
37746 this.wrapper.addClass('roo-grid-container');
37751 if(config.toolbar){
37752 var tool_el = this.wrapper.createChild();
37753 this.toolbar = Roo.factory(config.toolbar);
37755 if (config.toolbar.items) {
37756 ti = config.toolbar.items ;
37757 delete config.toolbar.items ;
37761 this.toolbar.render(tool_el);
37762 for(var i =0;i < ti.length;i++) {
37763 // Roo.log(['add child', items[i]]);
37764 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37766 this.toolbar.items = nitems;
37768 delete config.toolbar;
37771 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37772 config.grid.scrollBody = true;;
37773 config.grid.monitorWindowResize = false; // turn off autosizing
37774 config.grid.autoHeight = false;
37775 config.grid.autoWidth = false;
37777 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37779 if (config.background) {
37780 // render grid on panel activation (if panel background)
37781 this.on('activate', function(gp) {
37782 if (!gp.grid.rendered) {
37783 gp.grid.render(this.wrapper);
37784 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37789 this.grid.render(this.wrapper);
37790 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37793 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37794 // ??? needed ??? config.el = this.wrapper;
37799 // xtype created footer. - not sure if will work as we normally have to render first..
37800 if (this.footer && !this.footer.el && this.footer.xtype) {
37802 var ctr = this.grid.getView().getFooterPanel(true);
37803 this.footer.dataSource = this.grid.dataSource;
37804 this.footer = Roo.factory(this.footer, Roo);
37805 this.footer.render(ctr);
37815 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37816 getId : function(){
37817 return this.grid.id;
37821 * Returns the grid for this panel
37822 * @return {Roo.bootstrap.Table}
37824 getGrid : function(){
37828 setSize : function(width, height){
37829 if(!this.ignoreResize(width, height)){
37830 var grid = this.grid;
37831 var size = this.adjustForComponents(width, height);
37832 var gridel = grid.getGridEl();
37833 gridel.setSize(size.width, size.height);
37835 var thd = grid.getGridEl().select('thead',true).first();
37836 var tbd = grid.getGridEl().select('tbody', true).first();
37838 tbd.setSize(width, height - thd.getHeight());
37847 beforeSlide : function(){
37848 this.grid.getView().scroller.clip();
37851 afterSlide : function(){
37852 this.grid.getView().scroller.unclip();
37855 destroy : function(){
37856 this.grid.destroy();
37858 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37863 * @class Roo.bootstrap.panel.Nest
37864 * @extends Roo.bootstrap.panel.Content
37866 * Create a new Panel, that can contain a layout.Border.
37869 * @param {Roo.BorderLayout} layout The layout for this panel
37870 * @param {String/Object} config A string to set only the title or a config object
37872 Roo.bootstrap.panel.Nest = function(config)
37874 // construct with only one argument..
37875 /* FIXME - implement nicer consturctors
37876 if (layout.layout) {
37878 layout = config.layout;
37879 delete config.layout;
37881 if (layout.xtype && !layout.getEl) {
37882 // then layout needs constructing..
37883 layout = Roo.factory(layout, Roo);
37887 config.el = config.layout.getEl();
37889 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37891 config.layout.monitorWindowResize = false; // turn off autosizing
37892 this.layout = config.layout;
37893 this.layout.getEl().addClass("roo-layout-nested-layout");
37900 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37902 setSize : function(width, height){
37903 if(!this.ignoreResize(width, height)){
37904 var size = this.adjustForComponents(width, height);
37905 var el = this.layout.getEl();
37906 if (size.height < 1) {
37907 el.setWidth(size.width);
37909 el.setSize(size.width, size.height);
37911 var touch = el.dom.offsetWidth;
37912 this.layout.layout();
37913 // ie requires a double layout on the first pass
37914 if(Roo.isIE && !this.initialized){
37915 this.initialized = true;
37916 this.layout.layout();
37921 // activate all subpanels if not currently active..
37923 setActiveState : function(active){
37924 this.active = active;
37925 this.setActiveClass(active);
37928 this.fireEvent("deactivate", this);
37932 this.fireEvent("activate", this);
37933 // not sure if this should happen before or after..
37934 if (!this.layout) {
37935 return; // should not happen..
37938 for (var r in this.layout.regions) {
37939 reg = this.layout.getRegion(r);
37940 if (reg.getActivePanel()) {
37941 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37942 reg.setActivePanel(reg.getActivePanel());
37945 if (!reg.panels.length) {
37948 reg.showPanel(reg.getPanel(0));
37957 * Returns the nested BorderLayout for this panel
37958 * @return {Roo.BorderLayout}
37960 getLayout : function(){
37961 return this.layout;
37965 * Adds a xtype elements to the layout of the nested panel
37969 xtype : 'ContentPanel',
37976 xtype : 'NestedLayoutPanel',
37982 items : [ ... list of content panels or nested layout panels.. ]
37986 * @param {Object} cfg Xtype definition of item to add.
37988 addxtype : function(cfg) {
37989 return this.layout.addxtype(cfg);
37994 * Ext JS Library 1.1.1
37995 * Copyright(c) 2006-2007, Ext JS, LLC.
37997 * Originally Released Under LGPL - original licence link has changed is not relivant.
38000 * <script type="text/javascript">
38003 * @class Roo.TabPanel
38004 * @extends Roo.util.Observable
38005 * A lightweight tab container.
38009 // basic tabs 1, built from existing content
38010 var tabs = new Roo.TabPanel("tabs1");
38011 tabs.addTab("script", "View Script");
38012 tabs.addTab("markup", "View Markup");
38013 tabs.activate("script");
38015 // more advanced tabs, built from javascript
38016 var jtabs = new Roo.TabPanel("jtabs");
38017 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38019 // set up the UpdateManager
38020 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38021 var updater = tab2.getUpdateManager();
38022 updater.setDefaultUrl("ajax1.htm");
38023 tab2.on('activate', updater.refresh, updater, true);
38025 // Use setUrl for Ajax loading
38026 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38027 tab3.setUrl("ajax2.htm", null, true);
38030 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38033 jtabs.activate("jtabs-1");
38036 * Create a new TabPanel.
38037 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38038 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38040 Roo.bootstrap.panel.Tabs = function(config){
38042 * The container element for this TabPanel.
38043 * @type Roo.Element
38045 this.el = Roo.get(config.el);
38048 if(typeof config == "boolean"){
38049 this.tabPosition = config ? "bottom" : "top";
38051 Roo.apply(this, config);
38055 if(this.tabPosition == "bottom"){
38056 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38057 this.el.addClass("roo-tabs-bottom");
38059 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38060 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38061 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38062 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38064 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38066 if(this.tabPosition != "bottom"){
38067 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38068 * @type Roo.Element
38070 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38071 this.el.addClass("roo-tabs-top");
38075 this.bodyEl.setStyle("position", "relative");
38077 this.active = null;
38078 this.activateDelegate = this.activate.createDelegate(this);
38083 * Fires when the active tab changes
38084 * @param {Roo.TabPanel} this
38085 * @param {Roo.TabPanelItem} activePanel The new active tab
38089 * @event beforetabchange
38090 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38091 * @param {Roo.TabPanel} this
38092 * @param {Object} e Set cancel to true on this object to cancel the tab change
38093 * @param {Roo.TabPanelItem} tab The tab being changed to
38095 "beforetabchange" : true
38098 Roo.EventManager.onWindowResize(this.onResize, this);
38099 this.cpad = this.el.getPadding("lr");
38100 this.hiddenCount = 0;
38103 // toolbar on the tabbar support...
38104 if (this.toolbar) {
38105 alert("no toolbar support yet");
38106 this.toolbar = false;
38108 var tcfg = this.toolbar;
38109 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38110 this.toolbar = new Roo.Toolbar(tcfg);
38111 if (Roo.isSafari) {
38112 var tbl = tcfg.container.child('table', true);
38113 tbl.setAttribute('width', '100%');
38121 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38124 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38126 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38128 tabPosition : "top",
38130 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38132 currentTabWidth : 0,
38134 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38138 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38142 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38144 preferredTabWidth : 175,
38146 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38148 resizeTabs : false,
38150 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38152 monitorResize : true,
38154 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38159 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38160 * @param {String} id The id of the div to use <b>or create</b>
38161 * @param {String} text The text for the tab
38162 * @param {String} content (optional) Content to put in the TabPanelItem body
38163 * @param {Boolean} closable (optional) True to create a close icon on the tab
38164 * @return {Roo.TabPanelItem} The created TabPanelItem
38166 addTab : function(id, text, content, closable, tpl)
38168 var item = new Roo.bootstrap.panel.TabItem({
38172 closable : closable,
38175 this.addTabItem(item);
38177 item.setContent(content);
38183 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38184 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38185 * @return {Roo.TabPanelItem}
38187 getTab : function(id){
38188 return this.items[id];
38192 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38193 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38195 hideTab : function(id){
38196 var t = this.items[id];
38199 this.hiddenCount++;
38200 this.autoSizeTabs();
38205 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38206 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38208 unhideTab : function(id){
38209 var t = this.items[id];
38211 t.setHidden(false);
38212 this.hiddenCount--;
38213 this.autoSizeTabs();
38218 * Adds an existing {@link Roo.TabPanelItem}.
38219 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38221 addTabItem : function(item)
38223 this.items[item.id] = item;
38224 this.items.push(item);
38225 this.autoSizeTabs();
38226 // if(this.resizeTabs){
38227 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38228 // this.autoSizeTabs();
38230 // item.autoSize();
38235 * Removes a {@link Roo.TabPanelItem}.
38236 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38238 removeTab : function(id){
38239 var items = this.items;
38240 var tab = items[id];
38241 if(!tab) { return; }
38242 var index = items.indexOf(tab);
38243 if(this.active == tab && items.length > 1){
38244 var newTab = this.getNextAvailable(index);
38249 this.stripEl.dom.removeChild(tab.pnode.dom);
38250 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38251 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38253 items.splice(index, 1);
38254 delete this.items[tab.id];
38255 tab.fireEvent("close", tab);
38256 tab.purgeListeners();
38257 this.autoSizeTabs();
38260 getNextAvailable : function(start){
38261 var items = this.items;
38263 // look for a next tab that will slide over to
38264 // replace the one being removed
38265 while(index < items.length){
38266 var item = items[++index];
38267 if(item && !item.isHidden()){
38271 // if one isn't found select the previous tab (on the left)
38274 var item = items[--index];
38275 if(item && !item.isHidden()){
38283 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38284 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38286 disableTab : function(id){
38287 var tab = this.items[id];
38288 if(tab && this.active != tab){
38294 * Enables a {@link Roo.TabPanelItem} that is disabled.
38295 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38297 enableTab : function(id){
38298 var tab = this.items[id];
38303 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38304 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38305 * @return {Roo.TabPanelItem} The TabPanelItem.
38307 activate : function(id)
38309 var tab = this.items[id];
38313 if(tab == this.active || tab.disabled){
38317 this.fireEvent("beforetabchange", this, e, tab);
38318 if(e.cancel !== true && !tab.disabled){
38320 this.active.hide();
38322 this.active = this.items[id];
38323 this.active.show();
38324 this.fireEvent("tabchange", this, this.active);
38330 * Gets the active {@link Roo.TabPanelItem}.
38331 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38333 getActiveTab : function(){
38334 return this.active;
38338 * Updates the tab body element to fit the height of the container element
38339 * for overflow scrolling
38340 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38342 syncHeight : function(targetHeight){
38343 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38344 var bm = this.bodyEl.getMargins();
38345 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38346 this.bodyEl.setHeight(newHeight);
38350 onResize : function(){
38351 if(this.monitorResize){
38352 this.autoSizeTabs();
38357 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38359 beginUpdate : function(){
38360 this.updating = true;
38364 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38366 endUpdate : function(){
38367 this.updating = false;
38368 this.autoSizeTabs();
38372 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38374 autoSizeTabs : function()
38376 var count = this.items.length;
38377 var vcount = count - this.hiddenCount;
38380 this.stripEl.hide();
38382 this.stripEl.show();
38385 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38390 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38391 var availWidth = Math.floor(w / vcount);
38392 var b = this.stripBody;
38393 if(b.getWidth() > w){
38394 var tabs = this.items;
38395 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38396 if(availWidth < this.minTabWidth){
38397 /*if(!this.sleft){ // incomplete scrolling code
38398 this.createScrollButtons();
38401 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38404 if(this.currentTabWidth < this.preferredTabWidth){
38405 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38411 * Returns the number of tabs in this TabPanel.
38414 getCount : function(){
38415 return this.items.length;
38419 * Resizes all the tabs to the passed width
38420 * @param {Number} The new width
38422 setTabWidth : function(width){
38423 this.currentTabWidth = width;
38424 for(var i = 0, len = this.items.length; i < len; i++) {
38425 if(!this.items[i].isHidden()) {
38426 this.items[i].setWidth(width);
38432 * Destroys this TabPanel
38433 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38435 destroy : function(removeEl){
38436 Roo.EventManager.removeResizeListener(this.onResize, this);
38437 for(var i = 0, len = this.items.length; i < len; i++){
38438 this.items[i].purgeListeners();
38440 if(removeEl === true){
38441 this.el.update("");
38446 createStrip : function(container)
38448 var strip = document.createElement("nav");
38449 strip.className = Roo.bootstrap.version == 4 ?
38450 "navbar-light bg-light" :
38451 "navbar navbar-default"; //"x-tabs-wrap";
38452 container.appendChild(strip);
38456 createStripList : function(strip)
38458 // div wrapper for retard IE
38459 // returns the "tr" element.
38460 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38461 //'<div class="x-tabs-strip-wrap">'+
38462 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38463 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38464 return strip.firstChild; //.firstChild.firstChild.firstChild;
38466 createBody : function(container)
38468 var body = document.createElement("div");
38469 Roo.id(body, "tab-body");
38470 //Roo.fly(body).addClass("x-tabs-body");
38471 Roo.fly(body).addClass("tab-content");
38472 container.appendChild(body);
38475 createItemBody :function(bodyEl, id){
38476 var body = Roo.getDom(id);
38478 body = document.createElement("div");
38481 //Roo.fly(body).addClass("x-tabs-item-body");
38482 Roo.fly(body).addClass("tab-pane");
38483 bodyEl.insertBefore(body, bodyEl.firstChild);
38487 createStripElements : function(stripEl, text, closable, tpl)
38489 var td = document.createElement("li"); // was td..
38490 td.className = 'nav-item';
38492 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38495 stripEl.appendChild(td);
38497 td.className = "x-tabs-closable";
38498 if(!this.closeTpl){
38499 this.closeTpl = new Roo.Template(
38500 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38501 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38502 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38505 var el = this.closeTpl.overwrite(td, {"text": text});
38506 var close = el.getElementsByTagName("div")[0];
38507 var inner = el.getElementsByTagName("em")[0];
38508 return {"el": el, "close": close, "inner": inner};
38511 // not sure what this is..
38512 // if(!this.tabTpl){
38513 //this.tabTpl = new Roo.Template(
38514 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38515 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38517 // this.tabTpl = new Roo.Template(
38518 // '<a href="#">' +
38519 // '<span unselectable="on"' +
38520 // (this.disableTooltips ? '' : ' title="{text}"') +
38521 // ' >{text}</span></a>'
38527 var template = tpl || this.tabTpl || false;
38530 template = new Roo.Template(
38531 Roo.bootstrap.version == 4 ?
38533 '<a class="nav-link" href="#" unselectable="on"' +
38534 (this.disableTooltips ? '' : ' title="{text}"') +
38537 '<a class="nav-link" href="#">' +
38538 '<span unselectable="on"' +
38539 (this.disableTooltips ? '' : ' title="{text}"') +
38540 ' >{text}</span></a>'
38545 switch (typeof(template)) {
38549 template = new Roo.Template(template);
38555 var el = template.overwrite(td, {"text": text});
38557 var inner = el.getElementsByTagName("span")[0];
38559 return {"el": el, "inner": inner};
38567 * @class Roo.TabPanelItem
38568 * @extends Roo.util.Observable
38569 * Represents an individual item (tab plus body) in a TabPanel.
38570 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38571 * @param {String} id The id of this TabPanelItem
38572 * @param {String} text The text for the tab of this TabPanelItem
38573 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38575 Roo.bootstrap.panel.TabItem = function(config){
38577 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38578 * @type Roo.TabPanel
38580 this.tabPanel = config.panel;
38582 * The id for this TabPanelItem
38585 this.id = config.id;
38587 this.disabled = false;
38589 this.text = config.text;
38591 this.loaded = false;
38592 this.closable = config.closable;
38595 * The body element for this TabPanelItem.
38596 * @type Roo.Element
38598 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38599 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38600 this.bodyEl.setStyle("display", "block");
38601 this.bodyEl.setStyle("zoom", "1");
38602 //this.hideAction();
38604 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38606 this.el = Roo.get(els.el);
38607 this.inner = Roo.get(els.inner, true);
38608 this.textEl = Roo.bootstrap.version == 4 ?
38609 this.el : Roo.get(this.el.dom.firstChild, true);
38611 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38612 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38615 // this.el.on("mousedown", this.onTabMouseDown, this);
38616 this.el.on("click", this.onTabClick, this);
38618 if(config.closable){
38619 var c = Roo.get(els.close, true);
38620 c.dom.title = this.closeText;
38621 c.addClassOnOver("close-over");
38622 c.on("click", this.closeClick, this);
38628 * Fires when this tab becomes the active tab.
38629 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38630 * @param {Roo.TabPanelItem} this
38634 * @event beforeclose
38635 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38636 * @param {Roo.TabPanelItem} this
38637 * @param {Object} e Set cancel to true on this object to cancel the close.
38639 "beforeclose": true,
38642 * Fires when this tab is closed.
38643 * @param {Roo.TabPanelItem} this
38647 * @event deactivate
38648 * Fires when this tab is no longer the active tab.
38649 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38650 * @param {Roo.TabPanelItem} this
38652 "deactivate" : true
38654 this.hidden = false;
38656 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38659 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38661 purgeListeners : function(){
38662 Roo.util.Observable.prototype.purgeListeners.call(this);
38663 this.el.removeAllListeners();
38666 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38669 this.status_node.addClass("active");
38672 this.tabPanel.stripWrap.repaint();
38674 this.fireEvent("activate", this.tabPanel, this);
38678 * Returns true if this tab is the active tab.
38679 * @return {Boolean}
38681 isActive : function(){
38682 return this.tabPanel.getActiveTab() == this;
38686 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38689 this.status_node.removeClass("active");
38691 this.fireEvent("deactivate", this.tabPanel, this);
38694 hideAction : function(){
38695 this.bodyEl.hide();
38696 this.bodyEl.setStyle("position", "absolute");
38697 this.bodyEl.setLeft("-20000px");
38698 this.bodyEl.setTop("-20000px");
38701 showAction : function(){
38702 this.bodyEl.setStyle("position", "relative");
38703 this.bodyEl.setTop("");
38704 this.bodyEl.setLeft("");
38705 this.bodyEl.show();
38709 * Set the tooltip for the tab.
38710 * @param {String} tooltip The tab's tooltip
38712 setTooltip : function(text){
38713 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38714 this.textEl.dom.qtip = text;
38715 this.textEl.dom.removeAttribute('title');
38717 this.textEl.dom.title = text;
38721 onTabClick : function(e){
38722 e.preventDefault();
38723 this.tabPanel.activate(this.id);
38726 onTabMouseDown : function(e){
38727 e.preventDefault();
38728 this.tabPanel.activate(this.id);
38731 getWidth : function(){
38732 return this.inner.getWidth();
38735 setWidth : function(width){
38736 var iwidth = width - this.linode.getPadding("lr");
38737 this.inner.setWidth(iwidth);
38738 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38739 this.linode.setWidth(width);
38743 * Show or hide the tab
38744 * @param {Boolean} hidden True to hide or false to show.
38746 setHidden : function(hidden){
38747 this.hidden = hidden;
38748 this.linode.setStyle("display", hidden ? "none" : "");
38752 * Returns true if this tab is "hidden"
38753 * @return {Boolean}
38755 isHidden : function(){
38756 return this.hidden;
38760 * Returns the text for this tab
38763 getText : function(){
38767 autoSize : function(){
38768 //this.el.beginMeasure();
38769 this.textEl.setWidth(1);
38771 * #2804 [new] Tabs in Roojs
38772 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38774 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38775 //this.el.endMeasure();
38779 * Sets the text for the tab (Note: this also sets the tooltip text)
38780 * @param {String} text The tab's text and tooltip
38782 setText : function(text){
38784 this.textEl.update(text);
38785 this.setTooltip(text);
38786 //if(!this.tabPanel.resizeTabs){
38787 // this.autoSize();
38791 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38793 activate : function(){
38794 this.tabPanel.activate(this.id);
38798 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38800 disable : function(){
38801 if(this.tabPanel.active != this){
38802 this.disabled = true;
38803 this.status_node.addClass("disabled");
38808 * Enables this TabPanelItem if it was previously disabled.
38810 enable : function(){
38811 this.disabled = false;
38812 this.status_node.removeClass("disabled");
38816 * Sets the content for this TabPanelItem.
38817 * @param {String} content The content
38818 * @param {Boolean} loadScripts true to look for and load scripts
38820 setContent : function(content, loadScripts){
38821 this.bodyEl.update(content, loadScripts);
38825 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38826 * @return {Roo.UpdateManager} The UpdateManager
38828 getUpdateManager : function(){
38829 return this.bodyEl.getUpdateManager();
38833 * Set a URL to be used to load the content for this TabPanelItem.
38834 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38835 * @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)
38836 * @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)
38837 * @return {Roo.UpdateManager} The UpdateManager
38839 setUrl : function(url, params, loadOnce){
38840 if(this.refreshDelegate){
38841 this.un('activate', this.refreshDelegate);
38843 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38844 this.on("activate", this.refreshDelegate);
38845 return this.bodyEl.getUpdateManager();
38849 _handleRefresh : function(url, params, loadOnce){
38850 if(!loadOnce || !this.loaded){
38851 var updater = this.bodyEl.getUpdateManager();
38852 updater.update(url, params, this._setLoaded.createDelegate(this));
38857 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38858 * Will fail silently if the setUrl method has not been called.
38859 * This does not activate the panel, just updates its content.
38861 refresh : function(){
38862 if(this.refreshDelegate){
38863 this.loaded = false;
38864 this.refreshDelegate();
38869 _setLoaded : function(){
38870 this.loaded = true;
38874 closeClick : function(e){
38877 this.fireEvent("beforeclose", this, o);
38878 if(o.cancel !== true){
38879 this.tabPanel.removeTab(this.id);
38883 * The text displayed in the tooltip for the close icon.
38886 closeText : "Close this tab"
38889 * This script refer to:
38890 * Title: International Telephone Input
38891 * Author: Jack O'Connor
38892 * Code version: v12.1.12
38893 * Availability: https://github.com/jackocnr/intl-tel-input.git
38896 Roo.bootstrap.PhoneInputData = function() {
38899 "Afghanistan (افغانستان)",
38904 "Albania (Shqipëri)",
38909 "Algeria (الجزائر)",
38934 "Antigua and Barbuda",
38944 "Armenia (Հայաստան)",
38960 "Austria (Österreich)",
38965 "Azerbaijan (Azərbaycan)",
38975 "Bahrain (البحرين)",
38980 "Bangladesh (বাংলাদেশ)",
38990 "Belarus (Беларусь)",
38995 "Belgium (België)",
39025 "Bosnia and Herzegovina (Босна и Херцеговина)",
39040 "British Indian Ocean Territory",
39045 "British Virgin Islands",
39055 "Bulgaria (България)",
39065 "Burundi (Uburundi)",
39070 "Cambodia (កម្ពុជា)",
39075 "Cameroon (Cameroun)",
39084 ["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"]
39087 "Cape Verde (Kabu Verdi)",
39092 "Caribbean Netherlands",
39103 "Central African Republic (République centrafricaine)",
39123 "Christmas Island",
39129 "Cocos (Keeling) Islands",
39140 "Comoros (جزر القمر)",
39145 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39150 "Congo (Republic) (Congo-Brazzaville)",
39170 "Croatia (Hrvatska)",
39191 "Czech Republic (Česká republika)",
39196 "Denmark (Danmark)",
39211 "Dominican Republic (República Dominicana)",
39215 ["809", "829", "849"]
39233 "Equatorial Guinea (Guinea Ecuatorial)",
39253 "Falkland Islands (Islas Malvinas)",
39258 "Faroe Islands (Føroyar)",
39279 "French Guiana (Guyane française)",
39284 "French Polynesia (Polynésie française)",
39299 "Georgia (საქართველო)",
39304 "Germany (Deutschland)",
39324 "Greenland (Kalaallit Nunaat)",
39361 "Guinea-Bissau (Guiné Bissau)",
39386 "Hungary (Magyarország)",
39391 "Iceland (Ísland)",
39411 "Iraq (العراق)",
39427 "Israel (ישראל)",
39454 "Jordan (الأردن)",
39459 "Kazakhstan (Казахстан)",
39480 "Kuwait (الكويت)",
39485 "Kyrgyzstan (Кыргызстан)",
39495 "Latvia (Latvija)",
39500 "Lebanon (لبنان)",
39515 "Libya (ليبيا)",
39525 "Lithuania (Lietuva)",
39540 "Macedonia (FYROM) (Македонија)",
39545 "Madagascar (Madagasikara)",
39575 "Marshall Islands",
39585 "Mauritania (موريتانيا)",
39590 "Mauritius (Moris)",
39611 "Moldova (Republica Moldova)",
39621 "Mongolia (Монгол)",
39626 "Montenegro (Crna Gora)",
39636 "Morocco (المغرب)",
39642 "Mozambique (Moçambique)",
39647 "Myanmar (Burma) (မြန်မာ)",
39652 "Namibia (Namibië)",
39667 "Netherlands (Nederland)",
39672 "New Caledonia (Nouvelle-Calédonie)",
39707 "North Korea (조선 민주주의 인민 공화국)",
39712 "Northern Mariana Islands",
39728 "Pakistan (پاکستان)",
39738 "Palestine (فلسطين)",
39748 "Papua New Guinea",
39790 "Réunion (La Réunion)",
39796 "Romania (România)",
39812 "Saint Barthélemy",
39823 "Saint Kitts and Nevis",
39833 "Saint Martin (Saint-Martin (partie française))",
39839 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39844 "Saint Vincent and the Grenadines",
39859 "São Tomé and Príncipe (São Tomé e Príncipe)",
39864 "Saudi Arabia (المملكة العربية السعودية)",
39869 "Senegal (Sénégal)",
39899 "Slovakia (Slovensko)",
39904 "Slovenia (Slovenija)",
39914 "Somalia (Soomaaliya)",
39924 "South Korea (대한민국)",
39929 "South Sudan (جنوب السودان)",
39939 "Sri Lanka (ශ්රී ලංකාව)",
39944 "Sudan (السودان)",
39954 "Svalbard and Jan Mayen",
39965 "Sweden (Sverige)",
39970 "Switzerland (Schweiz)",
39975 "Syria (سوريا)",
40020 "Trinidad and Tobago",
40025 "Tunisia (تونس)",
40030 "Turkey (Türkiye)",
40040 "Turks and Caicos Islands",
40050 "U.S. Virgin Islands",
40060 "Ukraine (Україна)",
40065 "United Arab Emirates (الإمارات العربية المتحدة)",
40087 "Uzbekistan (Oʻzbekiston)",
40097 "Vatican City (Città del Vaticano)",
40108 "Vietnam (Việt Nam)",
40113 "Wallis and Futuna (Wallis-et-Futuna)",
40118 "Western Sahara (الصحراء الغربية)",
40124 "Yemen (اليمن)",
40148 * This script refer to:
40149 * Title: International Telephone Input
40150 * Author: Jack O'Connor
40151 * Code version: v12.1.12
40152 * Availability: https://github.com/jackocnr/intl-tel-input.git
40156 * @class Roo.bootstrap.PhoneInput
40157 * @extends Roo.bootstrap.TriggerField
40158 * An input with International dial-code selection
40160 * @cfg {String} defaultDialCode default '+852'
40161 * @cfg {Array} preferedCountries default []
40164 * Create a new PhoneInput.
40165 * @param {Object} config Configuration options
40168 Roo.bootstrap.PhoneInput = function(config) {
40169 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40172 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40174 listWidth: undefined,
40176 selectedClass: 'active',
40178 invalidClass : "has-warning",
40180 validClass: 'has-success',
40182 allowed: '0123456789',
40187 * @cfg {String} defaultDialCode The default dial code when initializing the input
40189 defaultDialCode: '+852',
40192 * @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
40194 preferedCountries: false,
40196 getAutoCreate : function()
40198 var data = Roo.bootstrap.PhoneInputData();
40199 var align = this.labelAlign || this.parentLabelAlign();
40202 this.allCountries = [];
40203 this.dialCodeMapping = [];
40205 for (var i = 0; i < data.length; i++) {
40207 this.allCountries[i] = {
40211 priority: c[3] || 0,
40212 areaCodes: c[4] || null
40214 this.dialCodeMapping[c[2]] = {
40217 priority: c[3] || 0,
40218 areaCodes: c[4] || null
40230 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40231 maxlength: this.max_length,
40232 cls : 'form-control tel-input',
40233 autocomplete: 'new-password'
40236 var hiddenInput = {
40239 cls: 'hidden-tel-input'
40243 hiddenInput.name = this.name;
40246 if (this.disabled) {
40247 input.disabled = true;
40250 var flag_container = {
40267 cls: this.hasFeedback ? 'has-feedback' : '',
40273 cls: 'dial-code-holder',
40280 cls: 'roo-select2-container input-group',
40287 if (this.fieldLabel.length) {
40290 tooltip: 'This field is required'
40296 cls: 'control-label',
40302 html: this.fieldLabel
40305 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40311 if(this.indicatorpos == 'right') {
40312 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40319 if(align == 'left') {
40327 if(this.labelWidth > 12){
40328 label.style = "width: " + this.labelWidth + 'px';
40330 if(this.labelWidth < 13 && this.labelmd == 0){
40331 this.labelmd = this.labelWidth;
40333 if(this.labellg > 0){
40334 label.cls += ' col-lg-' + this.labellg;
40335 input.cls += ' col-lg-' + (12 - this.labellg);
40337 if(this.labelmd > 0){
40338 label.cls += ' col-md-' + this.labelmd;
40339 container.cls += ' col-md-' + (12 - this.labelmd);
40341 if(this.labelsm > 0){
40342 label.cls += ' col-sm-' + this.labelsm;
40343 container.cls += ' col-sm-' + (12 - this.labelsm);
40345 if(this.labelxs > 0){
40346 label.cls += ' col-xs-' + this.labelxs;
40347 container.cls += ' col-xs-' + (12 - this.labelxs);
40357 var settings = this;
40359 ['xs','sm','md','lg'].map(function(size){
40360 if (settings[size]) {
40361 cfg.cls += ' col-' + size + '-' + settings[size];
40365 this.store = new Roo.data.Store({
40366 proxy : new Roo.data.MemoryProxy({}),
40367 reader : new Roo.data.JsonReader({
40378 'name' : 'dialCode',
40382 'name' : 'priority',
40386 'name' : 'areaCodes',
40393 if(!this.preferedCountries) {
40394 this.preferedCountries = [
40401 var p = this.preferedCountries.reverse();
40404 for (var i = 0; i < p.length; i++) {
40405 for (var j = 0; j < this.allCountries.length; j++) {
40406 if(this.allCountries[j].iso2 == p[i]) {
40407 var t = this.allCountries[j];
40408 this.allCountries.splice(j,1);
40409 this.allCountries.unshift(t);
40415 this.store.proxy.data = {
40417 data: this.allCountries
40423 initEvents : function()
40426 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40428 this.indicator = this.indicatorEl();
40429 this.flag = this.flagEl();
40430 this.dialCodeHolder = this.dialCodeHolderEl();
40432 this.trigger = this.el.select('div.flag-box',true).first();
40433 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40438 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40439 _this.list.setWidth(lw);
40442 this.list.on('mouseover', this.onViewOver, this);
40443 this.list.on('mousemove', this.onViewMove, this);
40444 this.inputEl().on("keyup", this.onKeyUp, this);
40445 this.inputEl().on("keypress", this.onKeyPress, this);
40447 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40449 this.view = new Roo.View(this.list, this.tpl, {
40450 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40453 this.view.on('click', this.onViewClick, this);
40454 this.setValue(this.defaultDialCode);
40457 onTriggerClick : function(e)
40459 Roo.log('trigger click');
40464 if(this.isExpanded()){
40466 this.hasFocus = false;
40468 this.store.load({});
40469 this.hasFocus = true;
40474 isExpanded : function()
40476 return this.list.isVisible();
40479 collapse : function()
40481 if(!this.isExpanded()){
40485 Roo.get(document).un('mousedown', this.collapseIf, this);
40486 Roo.get(document).un('mousewheel', this.collapseIf, this);
40487 this.fireEvent('collapse', this);
40491 expand : function()
40495 if(this.isExpanded() || !this.hasFocus){
40499 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40500 this.list.setWidth(lw);
40503 this.restrictHeight();
40505 Roo.get(document).on('mousedown', this.collapseIf, this);
40506 Roo.get(document).on('mousewheel', this.collapseIf, this);
40508 this.fireEvent('expand', this);
40511 restrictHeight : function()
40513 this.list.alignTo(this.inputEl(), this.listAlign);
40514 this.list.alignTo(this.inputEl(), this.listAlign);
40517 onViewOver : function(e, t)
40519 if(this.inKeyMode){
40522 var item = this.view.findItemFromChild(t);
40525 var index = this.view.indexOf(item);
40526 this.select(index, false);
40531 onViewClick : function(view, doFocus, el, e)
40533 var index = this.view.getSelectedIndexes()[0];
40535 var r = this.store.getAt(index);
40538 this.onSelect(r, index);
40540 if(doFocus !== false && !this.blockFocus){
40541 this.inputEl().focus();
40545 onViewMove : function(e, t)
40547 this.inKeyMode = false;
40550 select : function(index, scrollIntoView)
40552 this.selectedIndex = index;
40553 this.view.select(index);
40554 if(scrollIntoView !== false){
40555 var el = this.view.getNode(index);
40557 this.list.scrollChildIntoView(el, false);
40562 createList : function()
40564 this.list = Roo.get(document.body).createChild({
40566 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40567 style: 'display:none'
40570 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40573 collapseIf : function(e)
40575 var in_combo = e.within(this.el);
40576 var in_list = e.within(this.list);
40577 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40579 if (in_combo || in_list || is_list) {
40585 onSelect : function(record, index)
40587 if(this.fireEvent('beforeselect', this, record, index) !== false){
40589 this.setFlagClass(record.data.iso2);
40590 this.setDialCode(record.data.dialCode);
40591 this.hasFocus = false;
40593 this.fireEvent('select', this, record, index);
40597 flagEl : function()
40599 var flag = this.el.select('div.flag',true).first();
40606 dialCodeHolderEl : function()
40608 var d = this.el.select('input.dial-code-holder',true).first();
40615 setDialCode : function(v)
40617 this.dialCodeHolder.dom.value = '+'+v;
40620 setFlagClass : function(n)
40622 this.flag.dom.className = 'flag '+n;
40625 getValue : function()
40627 var v = this.inputEl().getValue();
40628 if(this.dialCodeHolder) {
40629 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40634 setValue : function(v)
40636 var d = this.getDialCode(v);
40638 //invalid dial code
40639 if(v.length == 0 || !d || d.length == 0) {
40641 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40642 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40648 this.setFlagClass(this.dialCodeMapping[d].iso2);
40649 this.setDialCode(d);
40650 this.inputEl().dom.value = v.replace('+'+d,'');
40651 this.hiddenEl().dom.value = this.getValue();
40656 getDialCode : function(v)
40660 if (v.length == 0) {
40661 return this.dialCodeHolder.dom.value;
40665 if (v.charAt(0) != "+") {
40668 var numericChars = "";
40669 for (var i = 1; i < v.length; i++) {
40670 var c = v.charAt(i);
40673 if (this.dialCodeMapping[numericChars]) {
40674 dialCode = v.substr(1, i);
40676 if (numericChars.length == 4) {
40686 this.setValue(this.defaultDialCode);
40690 hiddenEl : function()
40692 return this.el.select('input.hidden-tel-input',true).first();
40695 // after setting val
40696 onKeyUp : function(e){
40697 this.setValue(this.getValue());
40700 onKeyPress : function(e){
40701 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40708 * @class Roo.bootstrap.MoneyField
40709 * @extends Roo.bootstrap.ComboBox
40710 * Bootstrap MoneyField class
40713 * Create a new MoneyField.
40714 * @param {Object} config Configuration options
40717 Roo.bootstrap.MoneyField = function(config) {
40719 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40723 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40726 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40728 allowDecimals : true,
40730 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40732 decimalSeparator : ".",
40734 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40736 decimalPrecision : 0,
40738 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40740 allowNegative : true,
40742 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40746 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40748 minValue : Number.NEGATIVE_INFINITY,
40750 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40752 maxValue : Number.MAX_VALUE,
40754 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40756 minText : "The minimum value for this field is {0}",
40758 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40760 maxText : "The maximum value for this field is {0}",
40762 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40763 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40765 nanText : "{0} is not a valid number",
40767 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40771 * @cfg {String} defaults currency of the MoneyField
40772 * value should be in lkey
40774 defaultCurrency : false,
40776 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40778 thousandsDelimiter : false,
40780 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40791 getAutoCreate : function()
40793 var align = this.labelAlign || this.parentLabelAlign();
40805 cls : 'form-control roo-money-amount-input',
40806 autocomplete: 'new-password'
40809 var hiddenInput = {
40813 cls: 'hidden-number-input'
40816 if(this.max_length) {
40817 input.maxlength = this.max_length;
40821 hiddenInput.name = this.name;
40824 if (this.disabled) {
40825 input.disabled = true;
40828 var clg = 12 - this.inputlg;
40829 var cmd = 12 - this.inputmd;
40830 var csm = 12 - this.inputsm;
40831 var cxs = 12 - this.inputxs;
40835 cls : 'row roo-money-field',
40839 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40843 cls: 'roo-select2-container input-group',
40847 cls : 'form-control roo-money-currency-input',
40848 autocomplete: 'new-password',
40850 name : this.currencyName
40854 cls : 'input-group-addon',
40868 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40872 cls: this.hasFeedback ? 'has-feedback' : '',
40883 if (this.fieldLabel.length) {
40886 tooltip: 'This field is required'
40892 cls: 'control-label',
40898 html: this.fieldLabel
40901 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40907 if(this.indicatorpos == 'right') {
40908 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40915 if(align == 'left') {
40923 if(this.labelWidth > 12){
40924 label.style = "width: " + this.labelWidth + 'px';
40926 if(this.labelWidth < 13 && this.labelmd == 0){
40927 this.labelmd = this.labelWidth;
40929 if(this.labellg > 0){
40930 label.cls += ' col-lg-' + this.labellg;
40931 input.cls += ' col-lg-' + (12 - this.labellg);
40933 if(this.labelmd > 0){
40934 label.cls += ' col-md-' + this.labelmd;
40935 container.cls += ' col-md-' + (12 - this.labelmd);
40937 if(this.labelsm > 0){
40938 label.cls += ' col-sm-' + this.labelsm;
40939 container.cls += ' col-sm-' + (12 - this.labelsm);
40941 if(this.labelxs > 0){
40942 label.cls += ' col-xs-' + this.labelxs;
40943 container.cls += ' col-xs-' + (12 - this.labelxs);
40954 var settings = this;
40956 ['xs','sm','md','lg'].map(function(size){
40957 if (settings[size]) {
40958 cfg.cls += ' col-' + size + '-' + settings[size];
40965 initEvents : function()
40967 this.indicator = this.indicatorEl();
40969 this.initCurrencyEvent();
40971 this.initNumberEvent();
40974 initCurrencyEvent : function()
40977 throw "can not find store for combo";
40980 this.store = Roo.factory(this.store, Roo.data);
40981 this.store.parent = this;
40985 this.triggerEl = this.el.select('.input-group-addon', true).first();
40987 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40992 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40993 _this.list.setWidth(lw);
40996 this.list.on('mouseover', this.onViewOver, this);
40997 this.list.on('mousemove', this.onViewMove, this);
40998 this.list.on('scroll', this.onViewScroll, this);
41001 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41004 this.view = new Roo.View(this.list, this.tpl, {
41005 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41008 this.view.on('click', this.onViewClick, this);
41010 this.store.on('beforeload', this.onBeforeLoad, this);
41011 this.store.on('load', this.onLoad, this);
41012 this.store.on('loadexception', this.onLoadException, this);
41014 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41015 "up" : function(e){
41016 this.inKeyMode = true;
41020 "down" : function(e){
41021 if(!this.isExpanded()){
41022 this.onTriggerClick();
41024 this.inKeyMode = true;
41029 "enter" : function(e){
41032 if(this.fireEvent("specialkey", this, e)){
41033 this.onViewClick(false);
41039 "esc" : function(e){
41043 "tab" : function(e){
41046 if(this.fireEvent("specialkey", this, e)){
41047 this.onViewClick(false);
41055 doRelay : function(foo, bar, hname){
41056 if(hname == 'down' || this.scope.isExpanded()){
41057 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41065 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41069 initNumberEvent : function(e)
41071 this.inputEl().on("keydown" , this.fireKey, this);
41072 this.inputEl().on("focus", this.onFocus, this);
41073 this.inputEl().on("blur", this.onBlur, this);
41075 this.inputEl().relayEvent('keyup', this);
41077 if(this.indicator){
41078 this.indicator.addClass('invisible');
41081 this.originalValue = this.getValue();
41083 if(this.validationEvent == 'keyup'){
41084 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41085 this.inputEl().on('keyup', this.filterValidation, this);
41087 else if(this.validationEvent !== false){
41088 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41091 if(this.selectOnFocus){
41092 this.on("focus", this.preFocus, this);
41095 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41096 this.inputEl().on("keypress", this.filterKeys, this);
41098 this.inputEl().relayEvent('keypress', this);
41101 var allowed = "0123456789";
41103 if(this.allowDecimals){
41104 allowed += this.decimalSeparator;
41107 if(this.allowNegative){
41111 if(this.thousandsDelimiter) {
41115 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41117 var keyPress = function(e){
41119 var k = e.getKey();
41121 var c = e.getCharCode();
41124 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41125 allowed.indexOf(String.fromCharCode(c)) === -1
41131 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41135 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41140 this.inputEl().on("keypress", keyPress, this);
41144 onTriggerClick : function(e)
41151 this.loadNext = false;
41153 if(this.isExpanded()){
41158 this.hasFocus = true;
41160 if(this.triggerAction == 'all') {
41161 this.doQuery(this.allQuery, true);
41165 this.doQuery(this.getRawValue());
41168 getCurrency : function()
41170 var v = this.currencyEl().getValue();
41175 restrictHeight : function()
41177 this.list.alignTo(this.currencyEl(), this.listAlign);
41178 this.list.alignTo(this.currencyEl(), this.listAlign);
41181 onViewClick : function(view, doFocus, el, e)
41183 var index = this.view.getSelectedIndexes()[0];
41185 var r = this.store.getAt(index);
41188 this.onSelect(r, index);
41192 onSelect : function(record, index){
41194 if(this.fireEvent('beforeselect', this, record, index) !== false){
41196 this.setFromCurrencyData(index > -1 ? record.data : false);
41200 this.fireEvent('select', this, record, index);
41204 setFromCurrencyData : function(o)
41208 this.lastCurrency = o;
41210 if (this.currencyField) {
41211 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41213 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41216 this.lastSelectionText = currency;
41218 //setting default currency
41219 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41220 this.setCurrency(this.defaultCurrency);
41224 this.setCurrency(currency);
41227 setFromData : function(o)
41231 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41233 this.setFromCurrencyData(c);
41238 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41240 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41243 this.setValue(value);
41247 setCurrency : function(v)
41249 this.currencyValue = v;
41252 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41257 setValue : function(v)
41259 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41265 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41267 this.inputEl().dom.value = (v == '') ? '' :
41268 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41270 if(!this.allowZero && v === '0') {
41271 this.hiddenEl().dom.value = '';
41272 this.inputEl().dom.value = '';
41279 getRawValue : function()
41281 var v = this.inputEl().getValue();
41286 getValue : function()
41288 return this.fixPrecision(this.parseValue(this.getRawValue()));
41291 parseValue : function(value)
41293 if(this.thousandsDelimiter) {
41295 r = new RegExp(",", "g");
41296 value = value.replace(r, "");
41299 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41300 return isNaN(value) ? '' : value;
41304 fixPrecision : function(value)
41306 if(this.thousandsDelimiter) {
41308 r = new RegExp(",", "g");
41309 value = value.replace(r, "");
41312 var nan = isNaN(value);
41314 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41315 return nan ? '' : value;
41317 return parseFloat(value).toFixed(this.decimalPrecision);
41320 decimalPrecisionFcn : function(v)
41322 return Math.floor(v);
41325 validateValue : function(value)
41327 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41331 var num = this.parseValue(value);
41334 this.markInvalid(String.format(this.nanText, value));
41338 if(num < this.minValue){
41339 this.markInvalid(String.format(this.minText, this.minValue));
41343 if(num > this.maxValue){
41344 this.markInvalid(String.format(this.maxText, this.maxValue));
41351 validate : function()
41353 if(this.disabled || this.allowBlank){
41358 var currency = this.getCurrency();
41360 if(this.validateValue(this.getRawValue()) && currency.length){
41365 this.markInvalid();
41369 getName: function()
41374 beforeBlur : function()
41380 var v = this.parseValue(this.getRawValue());
41387 onBlur : function()
41391 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41392 //this.el.removeClass(this.focusClass);
41395 this.hasFocus = false;
41397 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41401 var v = this.getValue();
41403 if(String(v) !== String(this.startValue)){
41404 this.fireEvent('change', this, v, this.startValue);
41407 this.fireEvent("blur", this);
41410 inputEl : function()
41412 return this.el.select('.roo-money-amount-input', true).first();
41415 currencyEl : function()
41417 return this.el.select('.roo-money-currency-input', true).first();
41420 hiddenEl : function()
41422 return this.el.select('input.hidden-number-input',true).first();