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,
4684 getAutoCreate : function(){
4693 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4695 if (this.disabled) {
4696 cfg.cls += ' disabled';
4699 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4703 href : this.href || "#",
4704 html: this.html || ''
4707 if (this.tagtype == 'a') {
4708 cfg.cn[0].cls = 'nav-link';
4711 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4714 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>'
4716 if(this.glyphicon) {
4717 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4722 cfg.cn[0].html += " <span class='caret'></span>";
4726 if (this.badge !== '') {
4728 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4736 onRender : function(ct, position)
4738 // Roo.log("Call onRender: " + this.xtype);
4739 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4743 return Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4747 initEvents: function()
4749 if (typeof (this.menu) != 'undefined') {
4750 this.menu.parentType = this.xtype;
4751 this.menu.triggerEl = this.el;
4752 this.menu = this.addxtype(Roo.apply({}, this.menu));
4755 this.el.select('a',true).on('click', this.onClick, this);
4757 if(this.tagtype == 'span'){
4758 this.el.select('span',true).on('click', this.onClick, this);
4761 // at this point parent should be available..
4762 this.parent().register(this);
4765 onClick : function(e)
4767 if (e.getTarget('.dropdown-menu-item')) {
4768 // did you click on a menu itemm.... - then don't trigger onclick..
4773 this.preventDefault ||
4776 Roo.log("NavItem - prevent Default?");
4780 if (this.disabled) {
4784 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4785 if (tg && tg.transition) {
4786 Roo.log("waiting for the transitionend");
4792 //Roo.log("fire event clicked");
4793 if(this.fireEvent('click', this, e) === false){
4797 if(this.tagtype == 'span'){
4801 //Roo.log(this.href);
4802 var ael = this.el.select('a',true).first();
4805 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4806 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4807 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4808 return; // ignore... - it's a 'hash' to another page.
4810 Roo.log("NavItem - prevent Default?");
4812 this.scrollToElement(e);
4816 var p = this.parent();
4818 if (['tabs','pills'].indexOf(p.type)!==-1) {
4819 if (typeof(p.setActiveItem) !== 'undefined') {
4820 p.setActiveItem(this);
4824 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4825 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4826 // remove the collapsed menu expand...
4827 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4831 isActive: function () {
4834 setActive : function(state, fire, is_was_active)
4836 if (this.active && !state && this.navId) {
4837 this.was_active = true;
4838 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4840 nv.clearWasActive(this);
4844 this.active = state;
4847 this.el.removeClass('active');
4848 } else if (!this.el.hasClass('active')) {
4849 this.el.addClass('active');
4852 this.fireEvent('changed', this, state);
4855 // show a panel if it's registered and related..
4857 if (!this.navId || !this.tabId || !state || is_was_active) {
4861 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4865 var pan = tg.getPanelByName(this.tabId);
4869 // if we can not flip to new panel - go back to old nav highlight..
4870 if (false == tg.showPanel(pan)) {
4871 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4873 var onav = nv.getWasActive();
4875 onav.setActive(true, false, true);
4884 // this should not be here...
4885 setDisabled : function(state)
4887 this.disabled = state;
4889 this.el.removeClass('disabled');
4890 } else if (!this.el.hasClass('disabled')) {
4891 this.el.addClass('disabled');
4897 * Fetch the element to display the tooltip on.
4898 * @return {Roo.Element} defaults to this.el
4900 tooltipEl : function()
4902 return this.el.select('' + this.tagtype + '', true).first();
4905 scrollToElement : function(e)
4907 var c = document.body;
4910 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4912 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4913 c = document.documentElement;
4916 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4922 var o = target.calcOffsetsTo(c);
4929 this.fireEvent('scrollto', this, options, e);
4931 Roo.get(c).scrollTo('top', options.value, true);
4944 * <span> icon </span>
4945 * <span> text </span>
4946 * <span>badge </span>
4950 * @class Roo.bootstrap.NavSidebarItem
4951 * @extends Roo.bootstrap.NavItem
4952 * Bootstrap Navbar.NavSidebarItem class
4953 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4954 * {Boolean} open is the menu open
4955 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4956 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4957 * {String} buttonSize (sm|md|lg)the extra classes for the button
4958 * {Boolean} showArrow show arrow next to the text (default true)
4960 * Create a new Navbar Button
4961 * @param {Object} config The config object
4963 Roo.bootstrap.NavSidebarItem = function(config){
4964 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4969 * The raw click event for the entire grid.
4970 * @param {Roo.EventObject} e
4975 * Fires when the active item active state changes
4976 * @param {Roo.bootstrap.NavSidebarItem} this
4977 * @param {boolean} state the new state
4985 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4987 badgeWeight : 'default',
4993 buttonWeight : 'default',
4999 getAutoCreate : function(){
5004 href : this.href || '#',
5010 if(this.buttonView){
5013 href : this.href || '#',
5014 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5027 cfg.cls += ' active';
5030 if (this.disabled) {
5031 cfg.cls += ' disabled';
5034 cfg.cls += ' open x-open';
5037 if (this.glyphicon || this.icon) {
5038 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5039 a.cn.push({ tag : 'i', cls : c }) ;
5042 if(!this.buttonView){
5045 html : this.html || ''
5052 if (this.badge !== '') {
5053 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5059 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5062 a.cls += ' dropdown-toggle treeview' ;
5068 initEvents : function()
5070 if (typeof (this.menu) != 'undefined') {
5071 this.menu.parentType = this.xtype;
5072 this.menu.triggerEl = this.el;
5073 this.menu = this.addxtype(Roo.apply({}, this.menu));
5076 this.el.on('click', this.onClick, this);
5078 if(this.badge !== ''){
5079 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5084 onClick : function(e)
5091 if(this.preventDefault){
5095 this.fireEvent('click', this);
5098 disable : function()
5100 this.setDisabled(true);
5105 this.setDisabled(false);
5108 setDisabled : function(state)
5110 if(this.disabled == state){
5114 this.disabled = state;
5117 this.el.addClass('disabled');
5121 this.el.removeClass('disabled');
5126 setActive : function(state)
5128 if(this.active == state){
5132 this.active = state;
5135 this.el.addClass('active');
5139 this.el.removeClass('active');
5144 isActive: function ()
5149 setBadge : function(str)
5155 this.badgeEl.dom.innerHTML = str;
5172 * @class Roo.bootstrap.Row
5173 * @extends Roo.bootstrap.Component
5174 * Bootstrap Row class (contains columns...)
5178 * @param {Object} config The config object
5181 Roo.bootstrap.Row = function(config){
5182 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5185 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5187 getAutoCreate : function(){
5206 * @class Roo.bootstrap.Element
5207 * @extends Roo.bootstrap.Component
5208 * Bootstrap Element class
5209 * @cfg {String} html contents of the element
5210 * @cfg {String} tag tag of the element
5211 * @cfg {String} cls class of the element
5212 * @cfg {Boolean} preventDefault (true|false) default false
5213 * @cfg {Boolean} clickable (true|false) default false
5216 * Create a new Element
5217 * @param {Object} config The config object
5220 Roo.bootstrap.Element = function(config){
5221 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5227 * When a element is chick
5228 * @param {Roo.bootstrap.Element} this
5229 * @param {Roo.EventObject} e
5235 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5240 preventDefault: false,
5243 getAutoCreate : function(){
5247 // cls: this.cls, double assign in parent class Component.js :: onRender
5254 initEvents: function()
5256 Roo.bootstrap.Element.superclass.initEvents.call(this);
5259 this.el.on('click', this.onClick, this);
5264 onClick : function(e)
5266 if(this.preventDefault){
5270 this.fireEvent('click', this, e);
5273 getValue : function()
5275 return this.el.dom.innerHTML;
5278 setValue : function(value)
5280 this.el.dom.innerHTML = value;
5295 * @class Roo.bootstrap.Pagination
5296 * @extends Roo.bootstrap.Component
5297 * Bootstrap Pagination class
5298 * @cfg {String} size xs | sm | md | lg
5299 * @cfg {Boolean} inverse false | true
5302 * Create a new Pagination
5303 * @param {Object} config The config object
5306 Roo.bootstrap.Pagination = function(config){
5307 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5310 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5316 getAutoCreate : function(){
5322 cfg.cls += ' inverse';
5328 cfg.cls += " " + this.cls;
5346 * @class Roo.bootstrap.PaginationItem
5347 * @extends Roo.bootstrap.Component
5348 * Bootstrap PaginationItem class
5349 * @cfg {String} html text
5350 * @cfg {String} href the link
5351 * @cfg {Boolean} preventDefault (true | false) default true
5352 * @cfg {Boolean} active (true | false) default false
5353 * @cfg {Boolean} disabled default false
5357 * Create a new PaginationItem
5358 * @param {Object} config The config object
5362 Roo.bootstrap.PaginationItem = function(config){
5363 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5368 * The raw click event for the entire grid.
5369 * @param {Roo.EventObject} e
5375 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5379 preventDefault: true,
5384 getAutoCreate : function(){
5390 href : this.href ? this.href : '#',
5391 html : this.html ? this.html : ''
5401 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5405 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5411 initEvents: function() {
5413 this.el.on('click', this.onClick, this);
5416 onClick : function(e)
5418 Roo.log('PaginationItem on click ');
5419 if(this.preventDefault){
5427 this.fireEvent('click', this, e);
5443 * @class Roo.bootstrap.Slider
5444 * @extends Roo.bootstrap.Component
5445 * Bootstrap Slider class
5448 * Create a new Slider
5449 * @param {Object} config The config object
5452 Roo.bootstrap.Slider = function(config){
5453 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5456 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5458 getAutoCreate : function(){
5462 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5466 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5478 * Ext JS Library 1.1.1
5479 * Copyright(c) 2006-2007, Ext JS, LLC.
5481 * Originally Released Under LGPL - original licence link has changed is not relivant.
5484 * <script type="text/javascript">
5489 * @class Roo.grid.ColumnModel
5490 * @extends Roo.util.Observable
5491 * This is the default implementation of a ColumnModel used by the Grid. It defines
5492 * the columns in the grid.
5495 var colModel = new Roo.grid.ColumnModel([
5496 {header: "Ticker", width: 60, sortable: true, locked: true},
5497 {header: "Company Name", width: 150, sortable: true},
5498 {header: "Market Cap.", width: 100, sortable: true},
5499 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5500 {header: "Employees", width: 100, sortable: true, resizable: false}
5505 * The config options listed for this class are options which may appear in each
5506 * individual column definition.
5507 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5509 * @param {Object} config An Array of column config objects. See this class's
5510 * config objects for details.
5512 Roo.grid.ColumnModel = function(config){
5514 * The config passed into the constructor
5516 this.config = config;
5519 // if no id, create one
5520 // if the column does not have a dataIndex mapping,
5521 // map it to the order it is in the config
5522 for(var i = 0, len = config.length; i < len; i++){
5524 if(typeof c.dataIndex == "undefined"){
5527 if(typeof c.renderer == "string"){
5528 c.renderer = Roo.util.Format[c.renderer];
5530 if(typeof c.id == "undefined"){
5533 if(c.editor && c.editor.xtype){
5534 c.editor = Roo.factory(c.editor, Roo.grid);
5536 if(c.editor && c.editor.isFormField){
5537 c.editor = new Roo.grid.GridEditor(c.editor);
5539 this.lookup[c.id] = c;
5543 * The width of columns which have no width specified (defaults to 100)
5546 this.defaultWidth = 100;
5549 * Default sortable of columns which have no sortable specified (defaults to false)
5552 this.defaultSortable = false;
5556 * @event widthchange
5557 * Fires when the width of a column changes.
5558 * @param {ColumnModel} this
5559 * @param {Number} columnIndex The column index
5560 * @param {Number} newWidth The new width
5562 "widthchange": true,
5564 * @event headerchange
5565 * Fires when the text of a header changes.
5566 * @param {ColumnModel} this
5567 * @param {Number} columnIndex The column index
5568 * @param {Number} newText The new header text
5570 "headerchange": true,
5572 * @event hiddenchange
5573 * Fires when a column is hidden or "unhidden".
5574 * @param {ColumnModel} this
5575 * @param {Number} columnIndex The column index
5576 * @param {Boolean} hidden true if hidden, false otherwise
5578 "hiddenchange": true,
5580 * @event columnmoved
5581 * Fires when a column is moved.
5582 * @param {ColumnModel} this
5583 * @param {Number} oldIndex
5584 * @param {Number} newIndex
5586 "columnmoved" : true,
5588 * @event columlockchange
5589 * Fires when a column's locked state is changed
5590 * @param {ColumnModel} this
5591 * @param {Number} colIndex
5592 * @param {Boolean} locked true if locked
5594 "columnlockchange" : true
5596 Roo.grid.ColumnModel.superclass.constructor.call(this);
5598 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5600 * @cfg {String} header The header text to display in the Grid view.
5603 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5604 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5605 * specified, the column's index is used as an index into the Record's data Array.
5608 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5609 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5612 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5613 * Defaults to the value of the {@link #defaultSortable} property.
5614 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5617 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5620 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5623 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5626 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5629 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5630 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5631 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5632 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5635 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5638 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5641 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5644 * @cfg {String} cursor (Optional)
5647 * @cfg {String} tooltip (Optional)
5650 * @cfg {Number} xs (Optional)
5653 * @cfg {Number} sm (Optional)
5656 * @cfg {Number} md (Optional)
5659 * @cfg {Number} lg (Optional)
5662 * Returns the id of the column at the specified index.
5663 * @param {Number} index The column index
5664 * @return {String} the id
5666 getColumnId : function(index){
5667 return this.config[index].id;
5671 * Returns the column for a specified id.
5672 * @param {String} id The column id
5673 * @return {Object} the column
5675 getColumnById : function(id){
5676 return this.lookup[id];
5681 * Returns the column for a specified dataIndex.
5682 * @param {String} dataIndex The column dataIndex
5683 * @return {Object|Boolean} the column or false if not found
5685 getColumnByDataIndex: function(dataIndex){
5686 var index = this.findColumnIndex(dataIndex);
5687 return index > -1 ? this.config[index] : false;
5691 * Returns the index for a specified column id.
5692 * @param {String} id The column id
5693 * @return {Number} the index, or -1 if not found
5695 getIndexById : function(id){
5696 for(var i = 0, len = this.config.length; i < len; i++){
5697 if(this.config[i].id == id){
5705 * Returns the index for a specified column dataIndex.
5706 * @param {String} dataIndex The column dataIndex
5707 * @return {Number} the index, or -1 if not found
5710 findColumnIndex : function(dataIndex){
5711 for(var i = 0, len = this.config.length; i < len; i++){
5712 if(this.config[i].dataIndex == dataIndex){
5720 moveColumn : function(oldIndex, newIndex){
5721 var c = this.config[oldIndex];
5722 this.config.splice(oldIndex, 1);
5723 this.config.splice(newIndex, 0, c);
5724 this.dataMap = null;
5725 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5728 isLocked : function(colIndex){
5729 return this.config[colIndex].locked === true;
5732 setLocked : function(colIndex, value, suppressEvent){
5733 if(this.isLocked(colIndex) == value){
5736 this.config[colIndex].locked = value;
5738 this.fireEvent("columnlockchange", this, colIndex, value);
5742 getTotalLockedWidth : function(){
5744 for(var i = 0; i < this.config.length; i++){
5745 if(this.isLocked(i) && !this.isHidden(i)){
5746 this.totalWidth += this.getColumnWidth(i);
5752 getLockedCount : function(){
5753 for(var i = 0, len = this.config.length; i < len; i++){
5754 if(!this.isLocked(i)){
5759 return this.config.length;
5763 * Returns the number of columns.
5766 getColumnCount : function(visibleOnly){
5767 if(visibleOnly === true){
5769 for(var i = 0, len = this.config.length; i < len; i++){
5770 if(!this.isHidden(i)){
5776 return this.config.length;
5780 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5781 * @param {Function} fn
5782 * @param {Object} scope (optional)
5783 * @return {Array} result
5785 getColumnsBy : function(fn, scope){
5787 for(var i = 0, len = this.config.length; i < len; i++){
5788 var c = this.config[i];
5789 if(fn.call(scope||this, c, i) === true){
5797 * Returns true if the specified column is sortable.
5798 * @param {Number} col The column index
5801 isSortable : function(col){
5802 if(typeof this.config[col].sortable == "undefined"){
5803 return this.defaultSortable;
5805 return this.config[col].sortable;
5809 * Returns the rendering (formatting) function defined for the column.
5810 * @param {Number} col The column index.
5811 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5813 getRenderer : function(col){
5814 if(!this.config[col].renderer){
5815 return Roo.grid.ColumnModel.defaultRenderer;
5817 return this.config[col].renderer;
5821 * Sets the rendering (formatting) function for a column.
5822 * @param {Number} col The column index
5823 * @param {Function} fn The function to use to process the cell's raw data
5824 * to return HTML markup for the grid view. The render function is called with
5825 * the following parameters:<ul>
5826 * <li>Data value.</li>
5827 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5828 * <li>css A CSS style string to apply to the table cell.</li>
5829 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5830 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5831 * <li>Row index</li>
5832 * <li>Column index</li>
5833 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5835 setRenderer : function(col, fn){
5836 this.config[col].renderer = fn;
5840 * Returns the width for the specified column.
5841 * @param {Number} col The column index
5844 getColumnWidth : function(col){
5845 return this.config[col].width * 1 || this.defaultWidth;
5849 * Sets the width for a column.
5850 * @param {Number} col The column index
5851 * @param {Number} width The new width
5853 setColumnWidth : function(col, width, suppressEvent){
5854 this.config[col].width = width;
5855 this.totalWidth = null;
5857 this.fireEvent("widthchange", this, col, width);
5862 * Returns the total width of all columns.
5863 * @param {Boolean} includeHidden True to include hidden column widths
5866 getTotalWidth : function(includeHidden){
5867 if(!this.totalWidth){
5868 this.totalWidth = 0;
5869 for(var i = 0, len = this.config.length; i < len; i++){
5870 if(includeHidden || !this.isHidden(i)){
5871 this.totalWidth += this.getColumnWidth(i);
5875 return this.totalWidth;
5879 * Returns the header for the specified column.
5880 * @param {Number} col The column index
5883 getColumnHeader : function(col){
5884 return this.config[col].header;
5888 * Sets the header for a column.
5889 * @param {Number} col The column index
5890 * @param {String} header The new header
5892 setColumnHeader : function(col, header){
5893 this.config[col].header = header;
5894 this.fireEvent("headerchange", this, col, header);
5898 * Returns the tooltip for the specified column.
5899 * @param {Number} col The column index
5902 getColumnTooltip : function(col){
5903 return this.config[col].tooltip;
5906 * Sets the tooltip for a column.
5907 * @param {Number} col The column index
5908 * @param {String} tooltip The new tooltip
5910 setColumnTooltip : function(col, tooltip){
5911 this.config[col].tooltip = tooltip;
5915 * Returns the dataIndex for the specified column.
5916 * @param {Number} col The column index
5919 getDataIndex : function(col){
5920 return this.config[col].dataIndex;
5924 * Sets the dataIndex for a column.
5925 * @param {Number} col The column index
5926 * @param {Number} dataIndex The new dataIndex
5928 setDataIndex : function(col, dataIndex){
5929 this.config[col].dataIndex = dataIndex;
5935 * Returns true if the cell is editable.
5936 * @param {Number} colIndex The column index
5937 * @param {Number} rowIndex The row index - this is nto actually used..?
5940 isCellEditable : function(colIndex, rowIndex){
5941 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5945 * Returns the editor defined for the cell/column.
5946 * return false or null to disable editing.
5947 * @param {Number} colIndex The column index
5948 * @param {Number} rowIndex The row index
5951 getCellEditor : function(colIndex, rowIndex){
5952 return this.config[colIndex].editor;
5956 * Sets if a column is editable.
5957 * @param {Number} col The column index
5958 * @param {Boolean} editable True if the column is editable
5960 setEditable : function(col, editable){
5961 this.config[col].editable = editable;
5966 * Returns true if the column is hidden.
5967 * @param {Number} colIndex The column index
5970 isHidden : function(colIndex){
5971 return this.config[colIndex].hidden;
5976 * Returns true if the column width cannot be changed
5978 isFixed : function(colIndex){
5979 return this.config[colIndex].fixed;
5983 * Returns true if the column can be resized
5986 isResizable : function(colIndex){
5987 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5990 * Sets if a column is hidden.
5991 * @param {Number} colIndex The column index
5992 * @param {Boolean} hidden True if the column is hidden
5994 setHidden : function(colIndex, hidden){
5995 this.config[colIndex].hidden = hidden;
5996 this.totalWidth = null;
5997 this.fireEvent("hiddenchange", this, colIndex, hidden);
6001 * Sets the editor for a column.
6002 * @param {Number} col The column index
6003 * @param {Object} editor The editor object
6005 setEditor : function(col, editor){
6006 this.config[col].editor = editor;
6010 Roo.grid.ColumnModel.defaultRenderer = function(value)
6012 if(typeof value == "object") {
6015 if(typeof value == "string" && value.length < 1){
6019 return String.format("{0}", value);
6022 // Alias for backwards compatibility
6023 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6026 * Ext JS Library 1.1.1
6027 * Copyright(c) 2006-2007, Ext JS, LLC.
6029 * Originally Released Under LGPL - original licence link has changed is not relivant.
6032 * <script type="text/javascript">
6036 * @class Roo.LoadMask
6037 * A simple utility class for generically masking elements while loading data. If the element being masked has
6038 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6039 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6040 * element's UpdateManager load indicator and will be destroyed after the initial load.
6042 * Create a new LoadMask
6043 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6044 * @param {Object} config The config object
6046 Roo.LoadMask = function(el, config){
6047 this.el = Roo.get(el);
6048 Roo.apply(this, config);
6050 this.store.on('beforeload', this.onBeforeLoad, this);
6051 this.store.on('load', this.onLoad, this);
6052 this.store.on('loadexception', this.onLoadException, this);
6053 this.removeMask = false;
6055 var um = this.el.getUpdateManager();
6056 um.showLoadIndicator = false; // disable the default indicator
6057 um.on('beforeupdate', this.onBeforeLoad, this);
6058 um.on('update', this.onLoad, this);
6059 um.on('failure', this.onLoad, this);
6060 this.removeMask = true;
6064 Roo.LoadMask.prototype = {
6066 * @cfg {Boolean} removeMask
6067 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6068 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6072 * The text to display in a centered loading message box (defaults to 'Loading...')
6076 * @cfg {String} msgCls
6077 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6079 msgCls : 'x-mask-loading',
6082 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6088 * Disables the mask to prevent it from being displayed
6090 disable : function(){
6091 this.disabled = true;
6095 * Enables the mask so that it can be displayed
6097 enable : function(){
6098 this.disabled = false;
6101 onLoadException : function()
6105 if (typeof(arguments[3]) != 'undefined') {
6106 Roo.MessageBox.alert("Error loading",arguments[3]);
6110 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6111 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6118 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6123 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6127 onBeforeLoad : function(){
6129 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6134 destroy : function(){
6136 this.store.un('beforeload', this.onBeforeLoad, this);
6137 this.store.un('load', this.onLoad, this);
6138 this.store.un('loadexception', this.onLoadException, this);
6140 var um = this.el.getUpdateManager();
6141 um.un('beforeupdate', this.onBeforeLoad, this);
6142 um.un('update', this.onLoad, this);
6143 um.un('failure', this.onLoad, this);
6154 * @class Roo.bootstrap.Table
6155 * @extends Roo.bootstrap.Component
6156 * Bootstrap Table class
6157 * @cfg {String} cls table class
6158 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6159 * @cfg {String} bgcolor Specifies the background color for a table
6160 * @cfg {Number} border Specifies whether the table cells should have borders or not
6161 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6162 * @cfg {Number} cellspacing Specifies the space between cells
6163 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6164 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6165 * @cfg {String} sortable Specifies that the table should be sortable
6166 * @cfg {String} summary Specifies a summary of the content of a table
6167 * @cfg {Number} width Specifies the width of a table
6168 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6170 * @cfg {boolean} striped Should the rows be alternative striped
6171 * @cfg {boolean} bordered Add borders to the table
6172 * @cfg {boolean} hover Add hover highlighting
6173 * @cfg {boolean} condensed Format condensed
6174 * @cfg {boolean} responsive Format condensed
6175 * @cfg {Boolean} loadMask (true|false) default false
6176 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6177 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6178 * @cfg {Boolean} rowSelection (true|false) default false
6179 * @cfg {Boolean} cellSelection (true|false) default false
6180 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6181 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6182 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6183 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6187 * Create a new Table
6188 * @param {Object} config The config object
6191 Roo.bootstrap.Table = function(config){
6192 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6197 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6198 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6199 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6200 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6202 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6204 this.sm.grid = this;
6205 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6206 this.sm = this.selModel;
6207 this.sm.xmodule = this.xmodule || false;
6210 if (this.cm && typeof(this.cm.config) == 'undefined') {
6211 this.colModel = new Roo.grid.ColumnModel(this.cm);
6212 this.cm = this.colModel;
6213 this.cm.xmodule = this.xmodule || false;
6216 this.store= Roo.factory(this.store, Roo.data);
6217 this.ds = this.store;
6218 this.ds.xmodule = this.xmodule || false;
6221 if (this.footer && this.store) {
6222 this.footer.dataSource = this.ds;
6223 this.footer = Roo.factory(this.footer);
6230 * Fires when a cell is clicked
6231 * @param {Roo.bootstrap.Table} this
6232 * @param {Roo.Element} el
6233 * @param {Number} rowIndex
6234 * @param {Number} columnIndex
6235 * @param {Roo.EventObject} e
6239 * @event celldblclick
6240 * Fires when a cell is double 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
6247 "celldblclick" : true,
6250 * Fires when a row is clicked
6251 * @param {Roo.bootstrap.Table} this
6252 * @param {Roo.Element} el
6253 * @param {Number} rowIndex
6254 * @param {Roo.EventObject} e
6258 * @event rowdblclick
6259 * Fires when a row is double clicked
6260 * @param {Roo.bootstrap.Table} this
6261 * @param {Roo.Element} el
6262 * @param {Number} rowIndex
6263 * @param {Roo.EventObject} e
6265 "rowdblclick" : true,
6268 * Fires when a mouseover occur
6269 * @param {Roo.bootstrap.Table} this
6270 * @param {Roo.Element} el
6271 * @param {Number} rowIndex
6272 * @param {Number} columnIndex
6273 * @param {Roo.EventObject} e
6278 * Fires when a mouseout 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 row is rendered, so you can change add a style to it.
6289 * @param {Roo.bootstrap.Table} this
6290 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6294 * @event rowsrendered
6295 * Fires when all the rows have been rendered
6296 * @param {Roo.bootstrap.Table} this
6298 'rowsrendered' : true,
6300 * @event contextmenu
6301 * The raw contextmenu event for the entire grid.
6302 * @param {Roo.EventObject} e
6304 "contextmenu" : true,
6306 * @event rowcontextmenu
6307 * Fires when a row is right clicked
6308 * @param {Roo.bootstrap.Table} this
6309 * @param {Number} rowIndex
6310 * @param {Roo.EventObject} e
6312 "rowcontextmenu" : true,
6314 * @event cellcontextmenu
6315 * Fires when a cell is right clicked
6316 * @param {Roo.bootstrap.Table} this
6317 * @param {Number} rowIndex
6318 * @param {Number} cellIndex
6319 * @param {Roo.EventObject} e
6321 "cellcontextmenu" : true,
6323 * @event headercontextmenu
6324 * Fires when a header is right clicked
6325 * @param {Roo.bootstrap.Table} this
6326 * @param {Number} columnIndex
6327 * @param {Roo.EventObject} e
6329 "headercontextmenu" : true
6333 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6359 rowSelection : false,
6360 cellSelection : false,
6363 // Roo.Element - the tbody
6365 // Roo.Element - thead element
6368 container: false, // used by gridpanel...
6374 auto_hide_footer : false,
6376 getAutoCreate : function()
6378 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6385 if (this.scrollBody) {
6386 cfg.cls += ' table-body-fixed';
6389 cfg.cls += ' table-striped';
6393 cfg.cls += ' table-hover';
6395 if (this.bordered) {
6396 cfg.cls += ' table-bordered';
6398 if (this.condensed) {
6399 cfg.cls += ' table-condensed';
6401 if (this.responsive) {
6402 cfg.cls += ' table-responsive';
6406 cfg.cls+= ' ' +this.cls;
6409 // this lot should be simplifed...
6422 ].forEach(function(k) {
6430 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6433 if(this.store || this.cm){
6434 if(this.headerShow){
6435 cfg.cn.push(this.renderHeader());
6438 cfg.cn.push(this.renderBody());
6440 if(this.footerShow){
6441 cfg.cn.push(this.renderFooter());
6443 // where does this come from?
6444 //cfg.cls+= ' TableGrid';
6447 return { cn : [ cfg ] };
6450 initEvents : function()
6452 if(!this.store || !this.cm){
6455 if (this.selModel) {
6456 this.selModel.initEvents();
6460 //Roo.log('initEvents with ds!!!!');
6462 this.mainBody = this.el.select('tbody', true).first();
6463 this.mainHead = this.el.select('thead', true).first();
6464 this.mainFoot = this.el.select('tfoot', true).first();
6470 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6471 e.on('click', _this.sort, _this);
6474 this.mainBody.on("click", this.onClick, this);
6475 this.mainBody.on("dblclick", this.onDblClick, this);
6477 // why is this done????? = it breaks dialogs??
6478 //this.parent().el.setStyle('position', 'relative');
6482 this.footer.parentId = this.id;
6483 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6486 this.el.select('tfoot tr td').first().addClass('hide');
6491 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6494 this.store.on('load', this.onLoad, this);
6495 this.store.on('beforeload', this.onBeforeLoad, this);
6496 this.store.on('update', this.onUpdate, this);
6497 this.store.on('add', this.onAdd, this);
6498 this.store.on("clear", this.clear, this);
6500 this.el.on("contextmenu", this.onContextMenu, this);
6502 this.mainBody.on('scroll', this.onBodyScroll, this);
6504 this.cm.on("headerchange", this.onHeaderChange, this);
6506 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6510 onContextMenu : function(e, t)
6512 this.processEvent("contextmenu", e);
6515 processEvent : function(name, e)
6517 if (name != 'touchstart' ) {
6518 this.fireEvent(name, e);
6521 var t = e.getTarget();
6523 var cell = Roo.get(t);
6529 if(cell.findParent('tfoot', false, true)){
6533 if(cell.findParent('thead', false, true)){
6535 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6536 cell = Roo.get(t).findParent('th', false, true);
6538 Roo.log("failed to find th in thead?");
6539 Roo.log(e.getTarget());
6544 var cellIndex = cell.dom.cellIndex;
6546 var ename = name == 'touchstart' ? 'click' : name;
6547 this.fireEvent("header" + ename, this, cellIndex, e);
6552 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6553 cell = Roo.get(t).findParent('td', false, true);
6555 Roo.log("failed to find th in tbody?");
6556 Roo.log(e.getTarget());
6561 var row = cell.findParent('tr', false, true);
6562 var cellIndex = cell.dom.cellIndex;
6563 var rowIndex = row.dom.rowIndex - 1;
6567 this.fireEvent("row" + name, this, rowIndex, e);
6571 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6577 onMouseover : function(e, el)
6579 var cell = Roo.get(el);
6585 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6586 cell = cell.findParent('td', false, true);
6589 var row = cell.findParent('tr', false, true);
6590 var cellIndex = cell.dom.cellIndex;
6591 var rowIndex = row.dom.rowIndex - 1; // start from 0
6593 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6597 onMouseout : function(e, el)
6599 var cell = Roo.get(el);
6605 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6606 cell = cell.findParent('td', false, true);
6609 var row = cell.findParent('tr', false, true);
6610 var cellIndex = cell.dom.cellIndex;
6611 var rowIndex = row.dom.rowIndex - 1; // start from 0
6613 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6617 onClick : function(e, el)
6619 var cell = Roo.get(el);
6621 if(!cell || (!this.cellSelection && !this.rowSelection)){
6625 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6626 cell = cell.findParent('td', false, true);
6629 if(!cell || typeof(cell) == 'undefined'){
6633 var row = cell.findParent('tr', false, true);
6635 if(!row || typeof(row) == 'undefined'){
6639 var cellIndex = cell.dom.cellIndex;
6640 var rowIndex = this.getRowIndex(row);
6642 // why??? - should these not be based on SelectionModel?
6643 if(this.cellSelection){
6644 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6647 if(this.rowSelection){
6648 this.fireEvent('rowclick', this, row, rowIndex, e);
6654 onDblClick : function(e,el)
6656 var cell = Roo.get(el);
6658 if(!cell || (!this.cellSelection && !this.rowSelection)){
6662 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6663 cell = cell.findParent('td', false, true);
6666 if(!cell || typeof(cell) == 'undefined'){
6670 var row = cell.findParent('tr', false, true);
6672 if(!row || typeof(row) == 'undefined'){
6676 var cellIndex = cell.dom.cellIndex;
6677 var rowIndex = this.getRowIndex(row);
6679 if(this.cellSelection){
6680 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6683 if(this.rowSelection){
6684 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6688 sort : function(e,el)
6690 var col = Roo.get(el);
6692 if(!col.hasClass('sortable')){
6696 var sort = col.attr('sort');
6699 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6703 this.store.sortInfo = {field : sort, direction : dir};
6706 Roo.log("calling footer first");
6707 this.footer.onClick('first');
6710 this.store.load({ params : { start : 0 } });
6714 renderHeader : function()
6722 this.totalWidth = 0;
6724 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6726 var config = cm.config[i];
6730 cls : 'x-hcol-' + i,
6732 html: cm.getColumnHeader(i)
6737 if(typeof(config.sortable) != 'undefined' && config.sortable){
6739 c.html = '<i class="glyphicon"></i>' + c.html;
6742 if(typeof(config.lgHeader) != 'undefined'){
6743 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6746 if(typeof(config.mdHeader) != 'undefined'){
6747 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6750 if(typeof(config.smHeader) != 'undefined'){
6751 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6754 if(typeof(config.xsHeader) != 'undefined'){
6755 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6762 if(typeof(config.tooltip) != 'undefined'){
6763 c.tooltip = config.tooltip;
6766 if(typeof(config.colspan) != 'undefined'){
6767 c.colspan = config.colspan;
6770 if(typeof(config.hidden) != 'undefined' && config.hidden){
6771 c.style += ' display:none;';
6774 if(typeof(config.dataIndex) != 'undefined'){
6775 c.sort = config.dataIndex;
6780 if(typeof(config.align) != 'undefined' && config.align.length){
6781 c.style += ' text-align:' + config.align + ';';
6784 if(typeof(config.width) != 'undefined'){
6785 c.style += ' width:' + config.width + 'px;';
6786 this.totalWidth += config.width;
6788 this.totalWidth += 100; // assume minimum of 100 per column?
6791 if(typeof(config.cls) != 'undefined'){
6792 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6795 ['xs','sm','md','lg'].map(function(size){
6797 if(typeof(config[size]) == 'undefined'){
6801 if (!config[size]) { // 0 = hidden
6802 c.cls += ' hidden-' + size;
6806 c.cls += ' col-' + size + '-' + config[size];
6816 renderBody : function()
6826 colspan : this.cm.getColumnCount()
6836 renderFooter : function()
6846 colspan : this.cm.getColumnCount()
6860 // Roo.log('ds onload');
6865 var ds = this.store;
6867 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6868 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6869 if (_this.store.sortInfo) {
6871 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6872 e.select('i', true).addClass(['glyphicon-arrow-up']);
6875 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6876 e.select('i', true).addClass(['glyphicon-arrow-down']);
6881 var tbody = this.mainBody;
6883 if(ds.getCount() > 0){
6884 ds.data.each(function(d,rowIndex){
6885 var row = this.renderRow(cm, ds, rowIndex);
6887 tbody.createChild(row);
6891 if(row.cellObjects.length){
6892 Roo.each(row.cellObjects, function(r){
6893 _this.renderCellObject(r);
6900 var tfoot = this.el.select('tfoot', true).first();
6902 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6904 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6906 var total = this.ds.getTotalCount();
6908 if(this.footer.pageSize < total){
6909 this.mainFoot.show();
6913 Roo.each(this.el.select('tbody td', true).elements, function(e){
6914 e.on('mouseover', _this.onMouseover, _this);
6917 Roo.each(this.el.select('tbody td', true).elements, function(e){
6918 e.on('mouseout', _this.onMouseout, _this);
6920 this.fireEvent('rowsrendered', this);
6926 onUpdate : function(ds,record)
6928 this.refreshRow(record);
6932 onRemove : function(ds, record, index, isUpdate){
6933 if(isUpdate !== true){
6934 this.fireEvent("beforerowremoved", this, index, record);
6936 var bt = this.mainBody.dom;
6938 var rows = this.el.select('tbody > tr', true).elements;
6940 if(typeof(rows[index]) != 'undefined'){
6941 bt.removeChild(rows[index].dom);
6944 // if(bt.rows[index]){
6945 // bt.removeChild(bt.rows[index]);
6948 if(isUpdate !== true){
6949 //this.stripeRows(index);
6950 //this.syncRowHeights(index, index);
6952 this.fireEvent("rowremoved", this, index, record);
6956 onAdd : function(ds, records, rowIndex)
6958 //Roo.log('on Add called');
6959 // - note this does not handle multiple adding very well..
6960 var bt = this.mainBody.dom;
6961 for (var i =0 ; i < records.length;i++) {
6962 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6963 //Roo.log(records[i]);
6964 //Roo.log(this.store.getAt(rowIndex+i));
6965 this.insertRow(this.store, rowIndex + i, false);
6972 refreshRow : function(record){
6973 var ds = this.store, index;
6974 if(typeof record == 'number'){
6976 record = ds.getAt(index);
6978 index = ds.indexOf(record);
6980 this.insertRow(ds, index, true);
6982 this.onRemove(ds, record, index+1, true);
6984 //this.syncRowHeights(index, index);
6986 this.fireEvent("rowupdated", this, index, record);
6989 insertRow : function(dm, rowIndex, isUpdate){
6992 this.fireEvent("beforerowsinserted", this, rowIndex);
6994 //var s = this.getScrollState();
6995 var row = this.renderRow(this.cm, this.store, rowIndex);
6996 // insert before rowIndex..
6997 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7001 if(row.cellObjects.length){
7002 Roo.each(row.cellObjects, function(r){
7003 _this.renderCellObject(r);
7008 this.fireEvent("rowsinserted", this, rowIndex);
7009 //this.syncRowHeights(firstRow, lastRow);
7010 //this.stripeRows(firstRow);
7017 getRowDom : function(rowIndex)
7019 var rows = this.el.select('tbody > tr', true).elements;
7021 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7024 // returns the object tree for a tr..
7027 renderRow : function(cm, ds, rowIndex)
7029 var d = ds.getAt(rowIndex);
7033 cls : 'x-row-' + rowIndex,
7037 var cellObjects = [];
7039 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7040 var config = cm.config[i];
7042 var renderer = cm.getRenderer(i);
7046 if(typeof(renderer) !== 'undefined'){
7047 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7049 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7050 // and are rendered into the cells after the row is rendered - using the id for the element.
7052 if(typeof(value) === 'object'){
7062 rowIndex : rowIndex,
7067 this.fireEvent('rowclass', this, rowcfg);
7071 cls : rowcfg.rowClass + ' x-col-' + i,
7073 html: (typeof(value) === 'object') ? '' : value
7080 if(typeof(config.colspan) != 'undefined'){
7081 td.colspan = config.colspan;
7084 if(typeof(config.hidden) != 'undefined' && config.hidden){
7085 td.style += ' display:none;';
7088 if(typeof(config.align) != 'undefined' && config.align.length){
7089 td.style += ' text-align:' + config.align + ';';
7091 if(typeof(config.valign) != 'undefined' && config.valign.length){
7092 td.style += ' vertical-align:' + config.valign + ';';
7095 if(typeof(config.width) != 'undefined'){
7096 td.style += ' width:' + config.width + 'px;';
7099 if(typeof(config.cursor) != 'undefined'){
7100 td.style += ' cursor:' + config.cursor + ';';
7103 if(typeof(config.cls) != 'undefined'){
7104 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7107 ['xs','sm','md','lg'].map(function(size){
7109 if(typeof(config[size]) == 'undefined'){
7113 if (!config[size]) { // 0 = hidden
7114 td.cls += ' hidden-' + size;
7118 td.cls += ' col-' + size + '-' + config[size];
7126 row.cellObjects = cellObjects;
7134 onBeforeLoad : function()
7143 this.el.select('tbody', true).first().dom.innerHTML = '';
7146 * Show or hide a row.
7147 * @param {Number} rowIndex to show or hide
7148 * @param {Boolean} state hide
7150 setRowVisibility : function(rowIndex, state)
7152 var bt = this.mainBody.dom;
7154 var rows = this.el.select('tbody > tr', true).elements;
7156 if(typeof(rows[rowIndex]) == 'undefined'){
7159 rows[rowIndex].dom.style.display = state ? '' : 'none';
7163 getSelectionModel : function(){
7165 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7167 return this.selModel;
7170 * Render the Roo.bootstrap object from renderder
7172 renderCellObject : function(r)
7176 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7178 var t = r.cfg.render(r.container);
7181 Roo.each(r.cfg.cn, function(c){
7183 container: t.getChildContainer(),
7186 _this.renderCellObject(child);
7191 getRowIndex : function(row)
7195 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7206 * Returns the grid's underlying element = used by panel.Grid
7207 * @return {Element} The element
7209 getGridEl : function(){
7213 * Forces a resize - used by panel.Grid
7214 * @return {Element} The element
7216 autoSize : function()
7218 //var ctr = Roo.get(this.container.dom.parentElement);
7219 var ctr = Roo.get(this.el.dom);
7221 var thd = this.getGridEl().select('thead',true).first();
7222 var tbd = this.getGridEl().select('tbody', true).first();
7223 var tfd = this.getGridEl().select('tfoot', true).first();
7225 var cw = ctr.getWidth();
7229 tbd.setSize(ctr.getWidth(),
7230 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7232 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7235 cw = Math.max(cw, this.totalWidth);
7236 this.getGridEl().select('tr',true).setWidth(cw);
7237 // resize 'expandable coloumn?
7239 return; // we doe not have a view in this design..
7242 onBodyScroll: function()
7244 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7246 this.mainHead.setStyle({
7247 'position' : 'relative',
7248 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7254 var scrollHeight = this.mainBody.dom.scrollHeight;
7256 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7258 var height = this.mainBody.getHeight();
7260 if(scrollHeight - height == scrollTop) {
7262 var total = this.ds.getTotalCount();
7264 if(this.footer.cursor + this.footer.pageSize < total){
7266 this.footer.ds.load({
7268 start : this.footer.cursor + this.footer.pageSize,
7269 limit : this.footer.pageSize
7279 onHeaderChange : function()
7281 var header = this.renderHeader();
7282 var table = this.el.select('table', true).first();
7284 this.mainHead.remove();
7285 this.mainHead = table.createChild(header, this.mainBody, false);
7288 onHiddenChange : function(colModel, colIndex, hidden)
7290 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7291 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7293 this.CSS.updateRule(thSelector, "display", "");
7294 this.CSS.updateRule(tdSelector, "display", "");
7297 this.CSS.updateRule(thSelector, "display", "none");
7298 this.CSS.updateRule(tdSelector, "display", "none");
7301 this.onHeaderChange();
7305 setColumnWidth: function(col_index, width)
7307 // width = "md-2 xs-2..."
7308 if(!this.colModel.config[col_index]) {
7312 var w = width.split(" ");
7314 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7316 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7319 for(var j = 0; j < w.length; j++) {
7325 var size_cls = w[j].split("-");
7327 if(!Number.isInteger(size_cls[1] * 1)) {
7331 if(!this.colModel.config[col_index][size_cls[0]]) {
7335 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7339 h_row[0].classList.replace(
7340 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7341 "col-"+size_cls[0]+"-"+size_cls[1]
7344 for(var i = 0; i < rows.length; i++) {
7346 var size_cls = w[j].split("-");
7348 if(!Number.isInteger(size_cls[1] * 1)) {
7352 if(!this.colModel.config[col_index][size_cls[0]]) {
7356 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7360 rows[i].classList.replace(
7361 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7362 "col-"+size_cls[0]+"-"+size_cls[1]
7366 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7381 * @class Roo.bootstrap.TableCell
7382 * @extends Roo.bootstrap.Component
7383 * Bootstrap TableCell class
7384 * @cfg {String} html cell contain text
7385 * @cfg {String} cls cell class
7386 * @cfg {String} tag cell tag (td|th) default td
7387 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7388 * @cfg {String} align Aligns the content in a cell
7389 * @cfg {String} axis Categorizes cells
7390 * @cfg {String} bgcolor Specifies the background color of a cell
7391 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7392 * @cfg {Number} colspan Specifies the number of columns a cell should span
7393 * @cfg {String} headers Specifies one or more header cells a cell is related to
7394 * @cfg {Number} height Sets the height of a cell
7395 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7396 * @cfg {Number} rowspan Sets the number of rows a cell should span
7397 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7398 * @cfg {String} valign Vertical aligns the content in a cell
7399 * @cfg {Number} width Specifies the width of a cell
7402 * Create a new TableCell
7403 * @param {Object} config The config object
7406 Roo.bootstrap.TableCell = function(config){
7407 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7410 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7430 getAutoCreate : function(){
7431 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7451 cfg.align=this.align
7457 cfg.bgcolor=this.bgcolor
7460 cfg.charoff=this.charoff
7463 cfg.colspan=this.colspan
7466 cfg.headers=this.headers
7469 cfg.height=this.height
7472 cfg.nowrap=this.nowrap
7475 cfg.rowspan=this.rowspan
7478 cfg.scope=this.scope
7481 cfg.valign=this.valign
7484 cfg.width=this.width
7503 * @class Roo.bootstrap.TableRow
7504 * @extends Roo.bootstrap.Component
7505 * Bootstrap TableRow class
7506 * @cfg {String} cls row class
7507 * @cfg {String} align Aligns the content in a table row
7508 * @cfg {String} bgcolor Specifies a background color for a table row
7509 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7510 * @cfg {String} valign Vertical aligns the content in a table row
7513 * Create a new TableRow
7514 * @param {Object} config The config object
7517 Roo.bootstrap.TableRow = function(config){
7518 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7521 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7529 getAutoCreate : function(){
7530 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7540 cfg.align = this.align;
7543 cfg.bgcolor = this.bgcolor;
7546 cfg.charoff = this.charoff;
7549 cfg.valign = this.valign;
7567 * @class Roo.bootstrap.TableBody
7568 * @extends Roo.bootstrap.Component
7569 * Bootstrap TableBody class
7570 * @cfg {String} cls element class
7571 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7572 * @cfg {String} align Aligns the content inside the element
7573 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7574 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7577 * Create a new TableBody
7578 * @param {Object} config The config object
7581 Roo.bootstrap.TableBody = function(config){
7582 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7585 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7593 getAutoCreate : function(){
7594 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7608 cfg.align = this.align;
7611 cfg.charoff = this.charoff;
7614 cfg.valign = this.valign;
7621 // initEvents : function()
7628 // this.store = Roo.factory(this.store, Roo.data);
7629 // this.store.on('load', this.onLoad, this);
7631 // this.store.load();
7635 // onLoad: function ()
7637 // this.fireEvent('load', this);
7647 * Ext JS Library 1.1.1
7648 * Copyright(c) 2006-2007, Ext JS, LLC.
7650 * Originally Released Under LGPL - original licence link has changed is not relivant.
7653 * <script type="text/javascript">
7656 // as we use this in bootstrap.
7657 Roo.namespace('Roo.form');
7659 * @class Roo.form.Action
7660 * Internal Class used to handle form actions
7662 * @param {Roo.form.BasicForm} el The form element or its id
7663 * @param {Object} config Configuration options
7668 // define the action interface
7669 Roo.form.Action = function(form, options){
7671 this.options = options || {};
7674 * Client Validation Failed
7677 Roo.form.Action.CLIENT_INVALID = 'client';
7679 * Server Validation Failed
7682 Roo.form.Action.SERVER_INVALID = 'server';
7684 * Connect to Server Failed
7687 Roo.form.Action.CONNECT_FAILURE = 'connect';
7689 * Reading Data from Server Failed
7692 Roo.form.Action.LOAD_FAILURE = 'load';
7694 Roo.form.Action.prototype = {
7696 failureType : undefined,
7697 response : undefined,
7701 run : function(options){
7706 success : function(response){
7711 handleResponse : function(response){
7715 // default connection failure
7716 failure : function(response){
7718 this.response = response;
7719 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7720 this.form.afterAction(this, false);
7723 processResponse : function(response){
7724 this.response = response;
7725 if(!response.responseText){
7728 this.result = this.handleResponse(response);
7732 // utility functions used internally
7733 getUrl : function(appendParams){
7734 var url = this.options.url || this.form.url || this.form.el.dom.action;
7736 var p = this.getParams();
7738 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7744 getMethod : function(){
7745 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7748 getParams : function(){
7749 var bp = this.form.baseParams;
7750 var p = this.options.params;
7752 if(typeof p == "object"){
7753 p = Roo.urlEncode(Roo.applyIf(p, bp));
7754 }else if(typeof p == 'string' && bp){
7755 p += '&' + Roo.urlEncode(bp);
7758 p = Roo.urlEncode(bp);
7763 createCallback : function(){
7765 success: this.success,
7766 failure: this.failure,
7768 timeout: (this.form.timeout*1000),
7769 upload: this.form.fileUpload ? this.success : undefined
7774 Roo.form.Action.Submit = function(form, options){
7775 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7778 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7781 haveProgress : false,
7782 uploadComplete : false,
7784 // uploadProgress indicator.
7785 uploadProgress : function()
7787 if (!this.form.progressUrl) {
7791 if (!this.haveProgress) {
7792 Roo.MessageBox.progress("Uploading", "Uploading");
7794 if (this.uploadComplete) {
7795 Roo.MessageBox.hide();
7799 this.haveProgress = true;
7801 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7803 var c = new Roo.data.Connection();
7805 url : this.form.progressUrl,
7810 success : function(req){
7811 //console.log(data);
7815 rdata = Roo.decode(req.responseText)
7817 Roo.log("Invalid data from server..");
7821 if (!rdata || !rdata.success) {
7823 Roo.MessageBox.alert(Roo.encode(rdata));
7826 var data = rdata.data;
7828 if (this.uploadComplete) {
7829 Roo.MessageBox.hide();
7834 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7835 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7838 this.uploadProgress.defer(2000,this);
7841 failure: function(data) {
7842 Roo.log('progress url failed ');
7853 // run get Values on the form, so it syncs any secondary forms.
7854 this.form.getValues();
7856 var o = this.options;
7857 var method = this.getMethod();
7858 var isPost = method == 'POST';
7859 if(o.clientValidation === false || this.form.isValid()){
7861 if (this.form.progressUrl) {
7862 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7863 (new Date() * 1) + '' + Math.random());
7868 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7869 form:this.form.el.dom,
7870 url:this.getUrl(!isPost),
7872 params:isPost ? this.getParams() : null,
7873 isUpload: this.form.fileUpload
7876 this.uploadProgress();
7878 }else if (o.clientValidation !== false){ // client validation failed
7879 this.failureType = Roo.form.Action.CLIENT_INVALID;
7880 this.form.afterAction(this, false);
7884 success : function(response)
7886 this.uploadComplete= true;
7887 if (this.haveProgress) {
7888 Roo.MessageBox.hide();
7892 var result = this.processResponse(response);
7893 if(result === true || result.success){
7894 this.form.afterAction(this, true);
7898 this.form.markInvalid(result.errors);
7899 this.failureType = Roo.form.Action.SERVER_INVALID;
7901 this.form.afterAction(this, false);
7903 failure : function(response)
7905 this.uploadComplete= true;
7906 if (this.haveProgress) {
7907 Roo.MessageBox.hide();
7910 this.response = response;
7911 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7912 this.form.afterAction(this, false);
7915 handleResponse : function(response){
7916 if(this.form.errorReader){
7917 var rs = this.form.errorReader.read(response);
7920 for(var i = 0, len = rs.records.length; i < len; i++) {
7921 var r = rs.records[i];
7925 if(errors.length < 1){
7929 success : rs.success,
7935 ret = Roo.decode(response.responseText);
7939 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7949 Roo.form.Action.Load = function(form, options){
7950 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7951 this.reader = this.form.reader;
7954 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7959 Roo.Ajax.request(Roo.apply(
7960 this.createCallback(), {
7961 method:this.getMethod(),
7962 url:this.getUrl(false),
7963 params:this.getParams()
7967 success : function(response){
7969 var result = this.processResponse(response);
7970 if(result === true || !result.success || !result.data){
7971 this.failureType = Roo.form.Action.LOAD_FAILURE;
7972 this.form.afterAction(this, false);
7975 this.form.clearInvalid();
7976 this.form.setValues(result.data);
7977 this.form.afterAction(this, true);
7980 handleResponse : function(response){
7981 if(this.form.reader){
7982 var rs = this.form.reader.read(response);
7983 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7985 success : rs.success,
7989 return Roo.decode(response.responseText);
7993 Roo.form.Action.ACTION_TYPES = {
7994 'load' : Roo.form.Action.Load,
7995 'submit' : Roo.form.Action.Submit
8004 * @class Roo.bootstrap.Form
8005 * @extends Roo.bootstrap.Component
8006 * Bootstrap Form class
8007 * @cfg {String} method GET | POST (default POST)
8008 * @cfg {String} labelAlign top | left (default top)
8009 * @cfg {String} align left | right - for navbars
8010 * @cfg {Boolean} loadMask load mask when submit (default true)
8015 * @param {Object} config The config object
8019 Roo.bootstrap.Form = function(config){
8021 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8023 Roo.bootstrap.Form.popover.apply();
8027 * @event clientvalidation
8028 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8029 * @param {Form} this
8030 * @param {Boolean} valid true if the form has passed client-side validation
8032 clientvalidation: true,
8034 * @event beforeaction
8035 * Fires before any action is performed. Return false to cancel the action.
8036 * @param {Form} this
8037 * @param {Action} action The action to be performed
8041 * @event actionfailed
8042 * Fires when an action fails.
8043 * @param {Form} this
8044 * @param {Action} action The action that failed
8046 actionfailed : true,
8048 * @event actioncomplete
8049 * Fires when an action is completed.
8050 * @param {Form} this
8051 * @param {Action} action The action that completed
8053 actioncomplete : true
8057 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8060 * @cfg {String} method
8061 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8066 * The URL to use for form actions if one isn't supplied in the action options.
8069 * @cfg {Boolean} fileUpload
8070 * Set to true if this form is a file upload.
8074 * @cfg {Object} baseParams
8075 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8079 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8083 * @cfg {Sting} align (left|right) for navbar forms
8088 activeAction : null,
8091 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8092 * element by passing it or its id or mask the form itself by passing in true.
8095 waitMsgTarget : false,
8100 * @cfg {Boolean} errorMask (true|false) default false
8105 * @cfg {Number} maskOffset Default 100
8110 * @cfg {Boolean} maskBody
8114 getAutoCreate : function(){
8118 method : this.method || 'POST',
8119 id : this.id || Roo.id(),
8122 if (this.parent().xtype.match(/^Nav/)) {
8123 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8127 if (this.labelAlign == 'left' ) {
8128 cfg.cls += ' form-horizontal';
8134 initEvents : function()
8136 this.el.on('submit', this.onSubmit, this);
8137 // this was added as random key presses on the form where triggering form submit.
8138 this.el.on('keypress', function(e) {
8139 if (e.getCharCode() != 13) {
8142 // we might need to allow it for textareas.. and some other items.
8143 // check e.getTarget().
8145 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8149 Roo.log("keypress blocked");
8157 onSubmit : function(e){
8162 * Returns true if client-side validation on the form is successful.
8165 isValid : function(){
8166 var items = this.getItems();
8170 items.each(function(f){
8176 Roo.log('invalid field: ' + f.name);
8180 if(!target && f.el.isVisible(true)){
8186 if(this.errorMask && !valid){
8187 Roo.bootstrap.Form.popover.mask(this, target);
8194 * Returns true if any fields in this form have changed since their original load.
8197 isDirty : function(){
8199 var items = this.getItems();
8200 items.each(function(f){
8210 * Performs a predefined action (submit or load) or custom actions you define on this form.
8211 * @param {String} actionName The name of the action type
8212 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8213 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8214 * accept other config options):
8216 Property Type Description
8217 ---------------- --------------- ----------------------------------------------------------------------------------
8218 url String The url for the action (defaults to the form's url)
8219 method String The form method to use (defaults to the form's method, or POST if not defined)
8220 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8221 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8222 validate the form on the client (defaults to false)
8224 * @return {BasicForm} this
8226 doAction : function(action, options){
8227 if(typeof action == 'string'){
8228 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8230 if(this.fireEvent('beforeaction', this, action) !== false){
8231 this.beforeAction(action);
8232 action.run.defer(100, action);
8238 beforeAction : function(action){
8239 var o = action.options;
8244 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8246 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8249 // not really supported yet.. ??
8251 //if(this.waitMsgTarget === true){
8252 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8253 //}else if(this.waitMsgTarget){
8254 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8255 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8257 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8263 afterAction : function(action, success){
8264 this.activeAction = null;
8265 var o = action.options;
8270 Roo.get(document.body).unmask();
8276 //if(this.waitMsgTarget === true){
8277 // this.el.unmask();
8278 //}else if(this.waitMsgTarget){
8279 // this.waitMsgTarget.unmask();
8281 // Roo.MessageBox.updateProgress(1);
8282 // Roo.MessageBox.hide();
8289 Roo.callback(o.success, o.scope, [this, action]);
8290 this.fireEvent('actioncomplete', this, action);
8294 // failure condition..
8295 // we have a scenario where updates need confirming.
8296 // eg. if a locking scenario exists..
8297 // we look for { errors : { needs_confirm : true }} in the response.
8299 (typeof(action.result) != 'undefined') &&
8300 (typeof(action.result.errors) != 'undefined') &&
8301 (typeof(action.result.errors.needs_confirm) != 'undefined')
8304 Roo.log("not supported yet");
8307 Roo.MessageBox.confirm(
8308 "Change requires confirmation",
8309 action.result.errorMsg,
8314 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8324 Roo.callback(o.failure, o.scope, [this, action]);
8325 // show an error message if no failed handler is set..
8326 if (!this.hasListener('actionfailed')) {
8327 Roo.log("need to add dialog support");
8329 Roo.MessageBox.alert("Error",
8330 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8331 action.result.errorMsg :
8332 "Saving Failed, please check your entries or try again"
8337 this.fireEvent('actionfailed', this, action);
8342 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8343 * @param {String} id The value to search for
8346 findField : function(id){
8347 var items = this.getItems();
8348 var field = items.get(id);
8350 items.each(function(f){
8351 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8358 return field || null;
8361 * Mark fields in this form invalid in bulk.
8362 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8363 * @return {BasicForm} this
8365 markInvalid : function(errors){
8366 if(errors instanceof Array){
8367 for(var i = 0, len = errors.length; i < len; i++){
8368 var fieldError = errors[i];
8369 var f = this.findField(fieldError.id);
8371 f.markInvalid(fieldError.msg);
8377 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8378 field.markInvalid(errors[id]);
8382 //Roo.each(this.childForms || [], function (f) {
8383 // f.markInvalid(errors);
8390 * Set values for fields in this form in bulk.
8391 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8392 * @return {BasicForm} this
8394 setValues : function(values){
8395 if(values instanceof Array){ // array of objects
8396 for(var i = 0, len = values.length; i < len; i++){
8398 var f = this.findField(v.id);
8400 f.setValue(v.value);
8401 if(this.trackResetOnLoad){
8402 f.originalValue = f.getValue();
8406 }else{ // object hash
8409 if(typeof values[id] != 'function' && (field = this.findField(id))){
8411 if (field.setFromData &&
8413 field.displayField &&
8414 // combos' with local stores can
8415 // be queried via setValue()
8416 // to set their value..
8417 (field.store && !field.store.isLocal)
8421 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8422 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8423 field.setFromData(sd);
8425 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8427 field.setFromData(values);
8430 field.setValue(values[id]);
8434 if(this.trackResetOnLoad){
8435 field.originalValue = field.getValue();
8441 //Roo.each(this.childForms || [], function (f) {
8442 // f.setValues(values);
8449 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8450 * they are returned as an array.
8451 * @param {Boolean} asString
8454 getValues : function(asString){
8455 //if (this.childForms) {
8456 // copy values from the child forms
8457 // Roo.each(this.childForms, function (f) {
8458 // this.setValues(f.getValues());
8464 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8465 if(asString === true){
8468 return Roo.urlDecode(fs);
8472 * Returns the fields in this form as an object with key/value pairs.
8473 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8476 getFieldValues : function(with_hidden)
8478 var items = this.getItems();
8480 items.each(function(f){
8486 var v = f.getValue();
8488 if (f.inputType =='radio') {
8489 if (typeof(ret[f.getName()]) == 'undefined') {
8490 ret[f.getName()] = ''; // empty..
8493 if (!f.el.dom.checked) {
8501 if(f.xtype == 'MoneyField'){
8502 ret[f.currencyName] = f.getCurrency();
8505 // not sure if this supported any more..
8506 if ((typeof(v) == 'object') && f.getRawValue) {
8507 v = f.getRawValue() ; // dates..
8509 // combo boxes where name != hiddenName...
8510 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8511 ret[f.name] = f.getRawValue();
8513 ret[f.getName()] = v;
8520 * Clears all invalid messages in this form.
8521 * @return {BasicForm} this
8523 clearInvalid : function(){
8524 var items = this.getItems();
8526 items.each(function(f){
8535 * @return {BasicForm} this
8538 var items = this.getItems();
8539 items.each(function(f){
8543 Roo.each(this.childForms || [], function (f) {
8551 getItems : function()
8553 var r=new Roo.util.MixedCollection(false, function(o){
8554 return o.id || (o.id = Roo.id());
8556 var iter = function(el) {
8563 Roo.each(el.items,function(e) {
8572 hideFields : function(items)
8574 Roo.each(items, function(i){
8576 var f = this.findField(i);
8587 showFields : function(items)
8589 Roo.each(items, function(i){
8591 var f = this.findField(i);
8604 Roo.apply(Roo.bootstrap.Form, {
8631 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8632 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8633 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8634 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8637 this.maskEl.top.enableDisplayMode("block");
8638 this.maskEl.left.enableDisplayMode("block");
8639 this.maskEl.bottom.enableDisplayMode("block");
8640 this.maskEl.right.enableDisplayMode("block");
8642 this.toolTip = new Roo.bootstrap.Tooltip({
8643 cls : 'roo-form-error-popover',
8645 'left' : ['r-l', [-2,0], 'right'],
8646 'right' : ['l-r', [2,0], 'left'],
8647 'bottom' : ['tl-bl', [0,2], 'top'],
8648 'top' : [ 'bl-tl', [0,-2], 'bottom']
8652 this.toolTip.render(Roo.get(document.body));
8654 this.toolTip.el.enableDisplayMode("block");
8656 Roo.get(document.body).on('click', function(){
8660 Roo.get(document.body).on('touchstart', function(){
8664 this.isApplied = true
8667 mask : function(form, target)
8671 this.target = target;
8673 if(!this.form.errorMask || !target.el){
8677 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8679 Roo.log(scrollable);
8681 var ot = this.target.el.calcOffsetsTo(scrollable);
8683 var scrollTo = ot[1] - this.form.maskOffset;
8685 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8687 scrollable.scrollTo('top', scrollTo);
8689 var box = this.target.el.getBox();
8691 var zIndex = Roo.bootstrap.Modal.zIndex++;
8694 this.maskEl.top.setStyle('position', 'absolute');
8695 this.maskEl.top.setStyle('z-index', zIndex);
8696 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8697 this.maskEl.top.setLeft(0);
8698 this.maskEl.top.setTop(0);
8699 this.maskEl.top.show();
8701 this.maskEl.left.setStyle('position', 'absolute');
8702 this.maskEl.left.setStyle('z-index', zIndex);
8703 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8704 this.maskEl.left.setLeft(0);
8705 this.maskEl.left.setTop(box.y - this.padding);
8706 this.maskEl.left.show();
8708 this.maskEl.bottom.setStyle('position', 'absolute');
8709 this.maskEl.bottom.setStyle('z-index', zIndex);
8710 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8711 this.maskEl.bottom.setLeft(0);
8712 this.maskEl.bottom.setTop(box.bottom + this.padding);
8713 this.maskEl.bottom.show();
8715 this.maskEl.right.setStyle('position', 'absolute');
8716 this.maskEl.right.setStyle('z-index', zIndex);
8717 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8718 this.maskEl.right.setLeft(box.right + this.padding);
8719 this.maskEl.right.setTop(box.y - this.padding);
8720 this.maskEl.right.show();
8722 this.toolTip.bindEl = this.target.el;
8724 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8726 var tip = this.target.blankText;
8728 if(this.target.getValue() !== '' ) {
8730 if (this.target.invalidText.length) {
8731 tip = this.target.invalidText;
8732 } else if (this.target.regexText.length){
8733 tip = this.target.regexText;
8737 this.toolTip.show(tip);
8739 this.intervalID = window.setInterval(function() {
8740 Roo.bootstrap.Form.popover.unmask();
8743 window.onwheel = function(){ return false;};
8745 (function(){ this.isMasked = true; }).defer(500, this);
8751 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8755 this.maskEl.top.setStyle('position', 'absolute');
8756 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8757 this.maskEl.top.hide();
8759 this.maskEl.left.setStyle('position', 'absolute');
8760 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8761 this.maskEl.left.hide();
8763 this.maskEl.bottom.setStyle('position', 'absolute');
8764 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8765 this.maskEl.bottom.hide();
8767 this.maskEl.right.setStyle('position', 'absolute');
8768 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8769 this.maskEl.right.hide();
8771 this.toolTip.hide();
8773 this.toolTip.el.hide();
8775 window.onwheel = function(){ return true;};
8777 if(this.intervalID){
8778 window.clearInterval(this.intervalID);
8779 this.intervalID = false;
8782 this.isMasked = false;
8792 * Ext JS Library 1.1.1
8793 * Copyright(c) 2006-2007, Ext JS, LLC.
8795 * Originally Released Under LGPL - original licence link has changed is not relivant.
8798 * <script type="text/javascript">
8801 * @class Roo.form.VTypes
8802 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8805 Roo.form.VTypes = function(){
8806 // closure these in so they are only created once.
8807 var alpha = /^[a-zA-Z_]+$/;
8808 var alphanum = /^[a-zA-Z0-9_]+$/;
8809 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8810 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8812 // All these messages and functions are configurable
8815 * The function used to validate email addresses
8816 * @param {String} value The email address
8818 'email' : function(v){
8819 return email.test(v);
8822 * The error text to display when the email validation function returns false
8825 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8827 * The keystroke filter mask to be applied on email input
8830 'emailMask' : /[a-z0-9_\.\-@]/i,
8833 * The function used to validate URLs
8834 * @param {String} value The URL
8836 'url' : function(v){
8840 * The error text to display when the url validation function returns false
8843 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8846 * The function used to validate alpha values
8847 * @param {String} value The value
8849 'alpha' : function(v){
8850 return alpha.test(v);
8853 * The error text to display when the alpha validation function returns false
8856 'alphaText' : 'This field should only contain letters and _',
8858 * The keystroke filter mask to be applied on alpha input
8861 'alphaMask' : /[a-z_]/i,
8864 * The function used to validate alphanumeric values
8865 * @param {String} value The value
8867 'alphanum' : function(v){
8868 return alphanum.test(v);
8871 * The error text to display when the alphanumeric validation function returns false
8874 'alphanumText' : 'This field should only contain letters, numbers and _',
8876 * The keystroke filter mask to be applied on alphanumeric input
8879 'alphanumMask' : /[a-z0-9_]/i
8889 * @class Roo.bootstrap.Input
8890 * @extends Roo.bootstrap.Component
8891 * Bootstrap Input class
8892 * @cfg {Boolean} disabled is it disabled
8893 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8894 * @cfg {String} name name of the input
8895 * @cfg {string} fieldLabel - the label associated
8896 * @cfg {string} placeholder - placeholder to put in text.
8897 * @cfg {string} before - input group add on before
8898 * @cfg {string} after - input group add on after
8899 * @cfg {string} size - (lg|sm) or leave empty..
8900 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8901 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8902 * @cfg {Number} md colspan out of 12 for computer-sized screens
8903 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8904 * @cfg {string} value default value of the input
8905 * @cfg {Number} labelWidth set the width of label
8906 * @cfg {Number} labellg set the width of label (1-12)
8907 * @cfg {Number} labelmd set the width of label (1-12)
8908 * @cfg {Number} labelsm set the width of label (1-12)
8909 * @cfg {Number} labelxs set the width of label (1-12)
8910 * @cfg {String} labelAlign (top|left)
8911 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8912 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8913 * @cfg {String} indicatorpos (left|right) default left
8914 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8915 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8917 * @cfg {String} align (left|center|right) Default left
8918 * @cfg {Boolean} forceFeedback (true|false) Default false
8921 * Create a new Input
8922 * @param {Object} config The config object
8925 Roo.bootstrap.Input = function(config){
8927 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8932 * Fires when this field receives input focus.
8933 * @param {Roo.form.Field} this
8938 * Fires when this field loses input focus.
8939 * @param {Roo.form.Field} this
8944 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8945 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8946 * @param {Roo.form.Field} this
8947 * @param {Roo.EventObject} e The event object
8952 * Fires just before the field blurs if the field value has changed.
8953 * @param {Roo.form.Field} this
8954 * @param {Mixed} newValue The new value
8955 * @param {Mixed} oldValue The original value
8960 * Fires after the field has been marked as invalid.
8961 * @param {Roo.form.Field} this
8962 * @param {String} msg The validation message
8967 * Fires after the field has been validated with no errors.
8968 * @param {Roo.form.Field} this
8973 * Fires after the key up
8974 * @param {Roo.form.Field} this
8975 * @param {Roo.EventObject} e The event Object
8981 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8983 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8984 automatic validation (defaults to "keyup").
8986 validationEvent : "keyup",
8988 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8990 validateOnBlur : true,
8992 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8994 validationDelay : 250,
8996 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8998 focusClass : "x-form-focus", // not needed???
9002 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9004 invalidClass : "has-warning",
9007 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9009 validClass : "has-success",
9012 * @cfg {Boolean} hasFeedback (true|false) default true
9017 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9019 invalidFeedbackClass : "glyphicon-warning-sign",
9022 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9024 validFeedbackClass : "glyphicon-ok",
9027 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9029 selectOnFocus : false,
9032 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9036 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9041 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9043 disableKeyFilter : false,
9046 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9050 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9054 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9056 blankText : "Please complete this mandatory field",
9059 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9063 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9065 maxLength : Number.MAX_VALUE,
9067 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9069 minLengthText : "The minimum length for this field is {0}",
9071 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9073 maxLengthText : "The maximum length for this field is {0}",
9077 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9078 * If available, this function will be called only after the basic validators all return true, and will be passed the
9079 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9083 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9084 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9085 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9089 * @cfg {String} regexText -- Depricated - use Invalid Text
9094 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9100 autocomplete: false,
9119 formatedValue : false,
9120 forceFeedback : false,
9122 indicatorpos : 'left',
9132 parentLabelAlign : function()
9135 while (parent.parent()) {
9136 parent = parent.parent();
9137 if (typeof(parent.labelAlign) !='undefined') {
9138 return parent.labelAlign;
9145 getAutoCreate : function()
9147 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9153 if(this.inputType != 'hidden'){
9154 cfg.cls = 'form-group' //input-group
9160 type : this.inputType,
9162 cls : 'form-control',
9163 placeholder : this.placeholder || '',
9164 autocomplete : this.autocomplete || 'new-password'
9167 if(this.capture.length){
9168 input.capture = this.capture;
9171 if(this.accept.length){
9172 input.accept = this.accept + "/*";
9176 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9179 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9180 input.maxLength = this.maxLength;
9183 if (this.disabled) {
9184 input.disabled=true;
9187 if (this.readOnly) {
9188 input.readonly=true;
9192 input.name = this.name;
9196 input.cls += ' input-' + this.size;
9200 ['xs','sm','md','lg'].map(function(size){
9201 if (settings[size]) {
9202 cfg.cls += ' col-' + size + '-' + settings[size];
9206 var inputblock = input;
9210 cls: 'glyphicon form-control-feedback'
9213 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9216 cls : 'has-feedback',
9224 if (this.before || this.after) {
9227 cls : 'input-group',
9231 if (this.before && typeof(this.before) == 'string') {
9233 inputblock.cn.push({
9235 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9239 if (this.before && typeof(this.before) == 'object') {
9240 this.before = Roo.factory(this.before);
9242 inputblock.cn.push({
9244 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9245 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9249 inputblock.cn.push(input);
9251 if (this.after && typeof(this.after) == 'string') {
9252 inputblock.cn.push({
9254 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9258 if (this.after && typeof(this.after) == 'object') {
9259 this.after = Roo.factory(this.after);
9261 inputblock.cn.push({
9263 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9264 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9268 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9269 inputblock.cls += ' has-feedback';
9270 inputblock.cn.push(feedback);
9275 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9276 tooltip : 'This field is required'
9278 if (Roo.bootstrap.version == 4) {
9281 style : 'display-none'
9284 if (align ==='left' && this.fieldLabel.length) {
9286 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9293 cls : 'control-label col-form-label',
9294 html : this.fieldLabel
9305 var labelCfg = cfg.cn[1];
9306 var contentCfg = cfg.cn[2];
9308 if(this.indicatorpos == 'right'){
9313 cls : 'control-label col-form-label',
9317 html : this.fieldLabel
9331 labelCfg = cfg.cn[0];
9332 contentCfg = cfg.cn[1];
9336 if(this.labelWidth > 12){
9337 labelCfg.style = "width: " + this.labelWidth + 'px';
9340 if(this.labelWidth < 13 && this.labelmd == 0){
9341 this.labelmd = this.labelWidth;
9344 if(this.labellg > 0){
9345 labelCfg.cls += ' col-lg-' + this.labellg;
9346 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9349 if(this.labelmd > 0){
9350 labelCfg.cls += ' col-md-' + this.labelmd;
9351 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9354 if(this.labelsm > 0){
9355 labelCfg.cls += ' col-sm-' + this.labelsm;
9356 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9359 if(this.labelxs > 0){
9360 labelCfg.cls += ' col-xs-' + this.labelxs;
9361 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9365 } else if ( this.fieldLabel.length) {
9370 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9371 tooltip : 'This field is required'
9375 //cls : 'input-group-addon',
9376 html : this.fieldLabel
9384 if(this.indicatorpos == 'right'){
9389 //cls : 'input-group-addon',
9390 html : this.fieldLabel
9395 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9396 tooltip : 'This field is required'
9416 if (this.parentType === 'Navbar' && this.parent().bar) {
9417 cfg.cls += ' navbar-form';
9420 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9421 // on BS4 we do this only if not form
9422 cfg.cls += ' navbar-form';
9430 * return the real input element.
9432 inputEl: function ()
9434 return this.el.select('input.form-control',true).first();
9437 tooltipEl : function()
9439 return this.inputEl();
9442 indicatorEl : function()
9444 if (Roo.bootstrap.version == 4) {
9445 return false; // not enabled in v4 yet.
9448 var indicator = this.el.select('i.roo-required-indicator',true).first();
9458 setDisabled : function(v)
9460 var i = this.inputEl().dom;
9462 i.removeAttribute('disabled');
9466 i.setAttribute('disabled','true');
9468 initEvents : function()
9471 this.inputEl().on("keydown" , this.fireKey, this);
9472 this.inputEl().on("focus", this.onFocus, this);
9473 this.inputEl().on("blur", this.onBlur, this);
9475 this.inputEl().relayEvent('keyup', this);
9477 this.indicator = this.indicatorEl();
9480 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9483 // reference to original value for reset
9484 this.originalValue = this.getValue();
9485 //Roo.form.TextField.superclass.initEvents.call(this);
9486 if(this.validationEvent == 'keyup'){
9487 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9488 this.inputEl().on('keyup', this.filterValidation, this);
9490 else if(this.validationEvent !== false){
9491 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9494 if(this.selectOnFocus){
9495 this.on("focus", this.preFocus, this);
9498 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9499 this.inputEl().on("keypress", this.filterKeys, this);
9501 this.inputEl().relayEvent('keypress', this);
9504 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9505 this.el.on("click", this.autoSize, this);
9508 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9509 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9512 if (typeof(this.before) == 'object') {
9513 this.before.render(this.el.select('.roo-input-before',true).first());
9515 if (typeof(this.after) == 'object') {
9516 this.after.render(this.el.select('.roo-input-after',true).first());
9519 this.inputEl().on('change', this.onChange, this);
9522 filterValidation : function(e){
9523 if(!e.isNavKeyPress()){
9524 this.validationTask.delay(this.validationDelay);
9528 * Validates the field value
9529 * @return {Boolean} True if the value is valid, else false
9531 validate : function(){
9532 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9533 if(this.disabled || this.validateValue(this.getRawValue())){
9544 * Validates a value according to the field's validation rules and marks the field as invalid
9545 * if the validation fails
9546 * @param {Mixed} value The value to validate
9547 * @return {Boolean} True if the value is valid, else false
9549 validateValue : function(value)
9551 if(this.getVisibilityEl().hasClass('hidden')){
9555 if(value.length < 1) { // if it's blank
9556 if(this.allowBlank){
9562 if(value.length < this.minLength){
9565 if(value.length > this.maxLength){
9569 var vt = Roo.form.VTypes;
9570 if(!vt[this.vtype](value, this)){
9574 if(typeof this.validator == "function"){
9575 var msg = this.validator(value);
9579 if (typeof(msg) == 'string') {
9580 this.invalidText = msg;
9584 if(this.regex && !this.regex.test(value)){
9592 fireKey : function(e){
9593 //Roo.log('field ' + e.getKey());
9594 if(e.isNavKeyPress()){
9595 this.fireEvent("specialkey", this, e);
9598 focus : function (selectText){
9600 this.inputEl().focus();
9601 if(selectText === true){
9602 this.inputEl().dom.select();
9608 onFocus : function(){
9609 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9610 // this.el.addClass(this.focusClass);
9613 this.hasFocus = true;
9614 this.startValue = this.getValue();
9615 this.fireEvent("focus", this);
9619 beforeBlur : Roo.emptyFn,
9623 onBlur : function(){
9625 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9626 //this.el.removeClass(this.focusClass);
9628 this.hasFocus = false;
9629 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9632 var v = this.getValue();
9633 if(String(v) !== String(this.startValue)){
9634 this.fireEvent('change', this, v, this.startValue);
9636 this.fireEvent("blur", this);
9639 onChange : function(e)
9641 var v = this.getValue();
9642 if(String(v) !== String(this.startValue)){
9643 this.fireEvent('change', this, v, this.startValue);
9649 * Resets the current field value to the originally loaded value and clears any validation messages
9652 this.setValue(this.originalValue);
9656 * Returns the name of the field
9657 * @return {Mixed} name The name field
9659 getName: function(){
9663 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9664 * @return {Mixed} value The field value
9666 getValue : function(){
9668 var v = this.inputEl().getValue();
9673 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9674 * @return {Mixed} value The field value
9676 getRawValue : function(){
9677 var v = this.inputEl().getValue();
9683 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9684 * @param {Mixed} value The value to set
9686 setRawValue : function(v){
9687 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9690 selectText : function(start, end){
9691 var v = this.getRawValue();
9693 start = start === undefined ? 0 : start;
9694 end = end === undefined ? v.length : end;
9695 var d = this.inputEl().dom;
9696 if(d.setSelectionRange){
9697 d.setSelectionRange(start, end);
9698 }else if(d.createTextRange){
9699 var range = d.createTextRange();
9700 range.moveStart("character", start);
9701 range.moveEnd("character", v.length-end);
9708 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9709 * @param {Mixed} value The value to set
9711 setValue : function(v){
9714 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9720 processValue : function(value){
9721 if(this.stripCharsRe){
9722 var newValue = value.replace(this.stripCharsRe, '');
9723 if(newValue !== value){
9724 this.setRawValue(newValue);
9731 preFocus : function(){
9733 if(this.selectOnFocus){
9734 this.inputEl().dom.select();
9737 filterKeys : function(e){
9739 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9742 var c = e.getCharCode(), cc = String.fromCharCode(c);
9743 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9746 if(!this.maskRe.test(cc)){
9751 * Clear any invalid styles/messages for this field
9753 clearInvalid : function(){
9755 if(!this.el || this.preventMark){ // not rendered
9760 this.el.removeClass([this.invalidClass, 'is-invalid']);
9762 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9764 var feedback = this.el.select('.form-control-feedback', true).first();
9767 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9773 this.indicator.removeClass('visible');
9774 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9777 this.fireEvent('valid', this);
9781 * Mark this field as valid
9783 markValid : function()
9785 if(!this.el || this.preventMark){ // not rendered...
9789 this.el.removeClass([this.invalidClass, this.validClass]);
9790 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9792 var feedback = this.el.select('.form-control-feedback', true).first();
9795 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9799 this.indicator.removeClass('visible');
9800 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9807 if(this.allowBlank && !this.getRawValue().length){
9810 if (Roo.bootstrap.version == 3) {
9811 this.el.addClass(this.validClass);
9813 this.inputEl().addClass('is-valid');
9816 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9818 var feedback = this.el.select('.form-control-feedback', true).first();
9821 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9822 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9827 this.fireEvent('valid', this);
9831 * Mark this field as invalid
9832 * @param {String} msg The validation message
9834 markInvalid : function(msg)
9836 if(!this.el || this.preventMark){ // not rendered
9840 this.el.removeClass([this.invalidClass, this.validClass]);
9841 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9843 var feedback = this.el.select('.form-control-feedback', true).first();
9846 this.el.select('.form-control-feedback', true).first().removeClass(
9847 [this.invalidFeedbackClass, this.validFeedbackClass]);
9854 if(this.allowBlank && !this.getRawValue().length){
9859 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9860 this.indicator.addClass('visible');
9862 if (Roo.bootstrap.version == 3) {
9863 this.el.addClass(this.invalidClass);
9865 this.inputEl().addClass('is-invalid');
9870 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9872 var feedback = this.el.select('.form-control-feedback', true).first();
9875 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9877 if(this.getValue().length || this.forceFeedback){
9878 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9885 this.fireEvent('invalid', this, msg);
9888 SafariOnKeyDown : function(event)
9890 // this is a workaround for a password hang bug on chrome/ webkit.
9891 if (this.inputEl().dom.type != 'password') {
9895 var isSelectAll = false;
9897 if(this.inputEl().dom.selectionEnd > 0){
9898 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9900 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9901 event.preventDefault();
9906 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9908 event.preventDefault();
9909 // this is very hacky as keydown always get's upper case.
9911 var cc = String.fromCharCode(event.getCharCode());
9912 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9916 adjustWidth : function(tag, w){
9917 tag = tag.toLowerCase();
9918 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9919 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9923 if(tag == 'textarea'){
9926 }else if(Roo.isOpera){
9930 if(tag == 'textarea'){
9938 setFieldLabel : function(v)
9944 if(this.indicatorEl()){
9945 var ar = this.el.select('label > span',true);
9947 if (ar.elements.length) {
9948 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9949 this.fieldLabel = v;
9953 var br = this.el.select('label',true);
9955 if(br.elements.length) {
9956 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9957 this.fieldLabel = v;
9961 Roo.log('Cannot Found any of label > span || label in input');
9965 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9966 this.fieldLabel = v;
9981 * @class Roo.bootstrap.TextArea
9982 * @extends Roo.bootstrap.Input
9983 * Bootstrap TextArea class
9984 * @cfg {Number} cols Specifies the visible width of a text area
9985 * @cfg {Number} rows Specifies the visible number of lines in a text area
9986 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9987 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9988 * @cfg {string} html text
9991 * Create a new TextArea
9992 * @param {Object} config The config object
9995 Roo.bootstrap.TextArea = function(config){
9996 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10000 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10010 getAutoCreate : function(){
10012 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10018 if(this.inputType != 'hidden'){
10019 cfg.cls = 'form-group' //input-group
10027 value : this.value || '',
10028 html: this.html || '',
10029 cls : 'form-control',
10030 placeholder : this.placeholder || ''
10034 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10035 input.maxLength = this.maxLength;
10039 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10043 input.cols = this.cols;
10046 if (this.readOnly) {
10047 input.readonly = true;
10051 input.name = this.name;
10055 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10059 ['xs','sm','md','lg'].map(function(size){
10060 if (settings[size]) {
10061 cfg.cls += ' col-' + size + '-' + settings[size];
10065 var inputblock = input;
10067 if(this.hasFeedback && !this.allowBlank){
10071 cls: 'glyphicon form-control-feedback'
10075 cls : 'has-feedback',
10084 if (this.before || this.after) {
10087 cls : 'input-group',
10091 inputblock.cn.push({
10093 cls : 'input-group-addon',
10098 inputblock.cn.push(input);
10100 if(this.hasFeedback && !this.allowBlank){
10101 inputblock.cls += ' has-feedback';
10102 inputblock.cn.push(feedback);
10106 inputblock.cn.push({
10108 cls : 'input-group-addon',
10115 if (align ==='left' && this.fieldLabel.length) {
10120 cls : 'control-label',
10121 html : this.fieldLabel
10132 if(this.labelWidth > 12){
10133 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10136 if(this.labelWidth < 13 && this.labelmd == 0){
10137 this.labelmd = this.labelWidth;
10140 if(this.labellg > 0){
10141 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10142 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10145 if(this.labelmd > 0){
10146 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10147 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10150 if(this.labelsm > 0){
10151 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10152 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10155 if(this.labelxs > 0){
10156 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10157 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10160 } else if ( this.fieldLabel.length) {
10165 //cls : 'input-group-addon',
10166 html : this.fieldLabel
10184 if (this.disabled) {
10185 input.disabled=true;
10192 * return the real textarea element.
10194 inputEl: function ()
10196 return this.el.select('textarea.form-control',true).first();
10200 * Clear any invalid styles/messages for this field
10202 clearInvalid : function()
10205 if(!this.el || this.preventMark){ // not rendered
10209 var label = this.el.select('label', true).first();
10210 var icon = this.el.select('i.fa-star', true).first();
10215 this.el.removeClass( this.validClass);
10216 this.inputEl().removeClass('is-invalid');
10218 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10220 var feedback = this.el.select('.form-control-feedback', true).first();
10223 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10228 this.fireEvent('valid', this);
10232 * Mark this field as valid
10234 markValid : function()
10236 if(!this.el || this.preventMark){ // not rendered
10240 this.el.removeClass([this.invalidClass, this.validClass]);
10241 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10243 var feedback = this.el.select('.form-control-feedback', true).first();
10246 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10249 if(this.disabled || this.allowBlank){
10253 var label = this.el.select('label', true).first();
10254 var icon = this.el.select('i.fa-star', true).first();
10259 if (Roo.bootstrap.version == 3) {
10260 this.el.addClass(this.validClass);
10262 this.inputEl().addClass('is-valid');
10266 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10268 var feedback = this.el.select('.form-control-feedback', true).first();
10271 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10272 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10277 this.fireEvent('valid', this);
10281 * Mark this field as invalid
10282 * @param {String} msg The validation message
10284 markInvalid : function(msg)
10286 if(!this.el || this.preventMark){ // not rendered
10290 this.el.removeClass([this.invalidClass, this.validClass]);
10291 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10293 var feedback = this.el.select('.form-control-feedback', true).first();
10296 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10299 if(this.disabled || this.allowBlank){
10303 var label = this.el.select('label', true).first();
10304 var icon = this.el.select('i.fa-star', true).first();
10306 if(!this.getValue().length && label && !icon){
10307 this.el.createChild({
10309 cls : 'text-danger fa fa-lg fa-star',
10310 tooltip : 'This field is required',
10311 style : 'margin-right:5px;'
10315 if (Roo.bootstrap.version == 3) {
10316 this.el.addClass(this.invalidClass);
10318 this.inputEl().addClass('is-invalid');
10321 // fixme ... this may be depricated need to test..
10322 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10324 var feedback = this.el.select('.form-control-feedback', true).first();
10327 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10329 if(this.getValue().length || this.forceFeedback){
10330 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10337 this.fireEvent('invalid', this, msg);
10345 * trigger field - base class for combo..
10350 * @class Roo.bootstrap.TriggerField
10351 * @extends Roo.bootstrap.Input
10352 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10353 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10354 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10355 * for which you can provide a custom implementation. For example:
10357 var trigger = new Roo.bootstrap.TriggerField();
10358 trigger.onTriggerClick = myTriggerFn;
10359 trigger.applyTo('my-field');
10362 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10363 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10364 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10365 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10366 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10369 * Create a new TriggerField.
10370 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10371 * to the base TextField)
10373 Roo.bootstrap.TriggerField = function(config){
10374 this.mimicing = false;
10375 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10378 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10380 * @cfg {String} triggerClass A CSS class to apply to the trigger
10383 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10388 * @cfg {Boolean} removable (true|false) special filter default false
10392 /** @cfg {Boolean} grow @hide */
10393 /** @cfg {Number} growMin @hide */
10394 /** @cfg {Number} growMax @hide */
10400 autoSize: Roo.emptyFn,
10404 deferHeight : true,
10407 actionMode : 'wrap',
10412 getAutoCreate : function(){
10414 var align = this.labelAlign || this.parentLabelAlign();
10419 cls: 'form-group' //input-group
10426 type : this.inputType,
10427 cls : 'form-control',
10428 autocomplete: 'new-password',
10429 placeholder : this.placeholder || ''
10433 input.name = this.name;
10436 input.cls += ' input-' + this.size;
10439 if (this.disabled) {
10440 input.disabled=true;
10443 var inputblock = input;
10445 if(this.hasFeedback && !this.allowBlank){
10449 cls: 'glyphicon form-control-feedback'
10452 if(this.removable && !this.editable && !this.tickable){
10454 cls : 'has-feedback',
10460 cls : 'roo-combo-removable-btn close'
10467 cls : 'has-feedback',
10476 if(this.removable && !this.editable && !this.tickable){
10478 cls : 'roo-removable',
10484 cls : 'roo-combo-removable-btn close'
10491 if (this.before || this.after) {
10494 cls : 'input-group',
10498 inputblock.cn.push({
10500 cls : 'input-group-addon input-group-prepend input-group-text',
10505 inputblock.cn.push(input);
10507 if(this.hasFeedback && !this.allowBlank){
10508 inputblock.cls += ' has-feedback';
10509 inputblock.cn.push(feedback);
10513 inputblock.cn.push({
10515 cls : 'input-group-addon input-group-append input-group-text',
10524 var ibwrap = inputblock;
10529 cls: 'roo-select2-choices',
10533 cls: 'roo-select2-search-field',
10545 cls: 'roo-select2-container input-group',
10550 cls: 'form-hidden-field'
10556 if(!this.multiple && this.showToggleBtn){
10562 if (this.caret != false) {
10565 cls: 'fa fa-' + this.caret
10572 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10577 cls: 'combobox-clear',
10591 combobox.cls += ' roo-select2-container-multi';
10595 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10596 tooltip : 'This field is required'
10598 if (Roo.bootstrap.version == 4) {
10601 style : 'display:none'
10606 if (align ==='left' && this.fieldLabel.length) {
10608 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10615 cls : 'control-label',
10616 html : this.fieldLabel
10628 var labelCfg = cfg.cn[1];
10629 var contentCfg = cfg.cn[2];
10631 if(this.indicatorpos == 'right'){
10636 cls : 'control-label',
10640 html : this.fieldLabel
10654 labelCfg = cfg.cn[0];
10655 contentCfg = cfg.cn[1];
10658 if(this.labelWidth > 12){
10659 labelCfg.style = "width: " + this.labelWidth + 'px';
10662 if(this.labelWidth < 13 && this.labelmd == 0){
10663 this.labelmd = this.labelWidth;
10666 if(this.labellg > 0){
10667 labelCfg.cls += ' col-lg-' + this.labellg;
10668 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10671 if(this.labelmd > 0){
10672 labelCfg.cls += ' col-md-' + this.labelmd;
10673 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10676 if(this.labelsm > 0){
10677 labelCfg.cls += ' col-sm-' + this.labelsm;
10678 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10681 if(this.labelxs > 0){
10682 labelCfg.cls += ' col-xs-' + this.labelxs;
10683 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10686 } else if ( this.fieldLabel.length) {
10687 // Roo.log(" label");
10692 //cls : 'input-group-addon',
10693 html : this.fieldLabel
10701 if(this.indicatorpos == 'right'){
10709 html : this.fieldLabel
10723 // Roo.log(" no label && no align");
10730 ['xs','sm','md','lg'].map(function(size){
10731 if (settings[size]) {
10732 cfg.cls += ' col-' + size + '-' + settings[size];
10743 onResize : function(w, h){
10744 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10745 // if(typeof w == 'number'){
10746 // var x = w - this.trigger.getWidth();
10747 // this.inputEl().setWidth(this.adjustWidth('input', x));
10748 // this.trigger.setStyle('left', x+'px');
10753 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10756 getResizeEl : function(){
10757 return this.inputEl();
10761 getPositionEl : function(){
10762 return this.inputEl();
10766 alignErrorIcon : function(){
10767 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10771 initEvents : function(){
10775 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10776 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10777 if(!this.multiple && this.showToggleBtn){
10778 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10779 if(this.hideTrigger){
10780 this.trigger.setDisplayed(false);
10782 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10786 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10789 if(this.removable && !this.editable && !this.tickable){
10790 var close = this.closeTriggerEl();
10793 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10794 close.on('click', this.removeBtnClick, this, close);
10798 //this.trigger.addClassOnOver('x-form-trigger-over');
10799 //this.trigger.addClassOnClick('x-form-trigger-click');
10802 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10806 closeTriggerEl : function()
10808 var close = this.el.select('.roo-combo-removable-btn', true).first();
10809 return close ? close : false;
10812 removeBtnClick : function(e, h, el)
10814 e.preventDefault();
10816 if(this.fireEvent("remove", this) !== false){
10818 this.fireEvent("afterremove", this)
10822 createList : function()
10824 this.list = Roo.get(document.body).createChild({
10825 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10826 cls: 'typeahead typeahead-long dropdown-menu',
10827 style: 'display:none'
10830 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10835 initTrigger : function(){
10840 onDestroy : function(){
10842 this.trigger.removeAllListeners();
10843 // this.trigger.remove();
10846 // this.wrap.remove();
10848 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10852 onFocus : function(){
10853 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10855 if(!this.mimicing){
10856 this.wrap.addClass('x-trigger-wrap-focus');
10857 this.mimicing = true;
10858 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10859 if(this.monitorTab){
10860 this.el.on("keydown", this.checkTab, this);
10867 checkTab : function(e){
10868 if(e.getKey() == e.TAB){
10869 this.triggerBlur();
10874 onBlur : function(){
10879 mimicBlur : function(e, t){
10881 if(!this.wrap.contains(t) && this.validateBlur()){
10882 this.triggerBlur();
10888 triggerBlur : function(){
10889 this.mimicing = false;
10890 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10891 if(this.monitorTab){
10892 this.el.un("keydown", this.checkTab, this);
10894 //this.wrap.removeClass('x-trigger-wrap-focus');
10895 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10899 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10900 validateBlur : function(e, t){
10905 onDisable : function(){
10906 this.inputEl().dom.disabled = true;
10907 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10909 // this.wrap.addClass('x-item-disabled');
10914 onEnable : function(){
10915 this.inputEl().dom.disabled = false;
10916 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10918 // this.el.removeClass('x-item-disabled');
10923 onShow : function(){
10924 var ae = this.getActionEl();
10927 ae.dom.style.display = '';
10928 ae.dom.style.visibility = 'visible';
10934 onHide : function(){
10935 var ae = this.getActionEl();
10936 ae.dom.style.display = 'none';
10940 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10941 * by an implementing function.
10943 * @param {EventObject} e
10945 onTriggerClick : Roo.emptyFn
10949 * Ext JS Library 1.1.1
10950 * Copyright(c) 2006-2007, Ext JS, LLC.
10952 * Originally Released Under LGPL - original licence link has changed is not relivant.
10955 * <script type="text/javascript">
10960 * @class Roo.data.SortTypes
10962 * Defines the default sorting (casting?) comparison functions used when sorting data.
10964 Roo.data.SortTypes = {
10966 * Default sort that does nothing
10967 * @param {Mixed} s The value being converted
10968 * @return {Mixed} The comparison value
10970 none : function(s){
10975 * The regular expression used to strip tags
10979 stripTagsRE : /<\/?[^>]+>/gi,
10982 * Strips all HTML tags to sort on text only
10983 * @param {Mixed} s The value being converted
10984 * @return {String} The comparison value
10986 asText : function(s){
10987 return String(s).replace(this.stripTagsRE, "");
10991 * Strips all HTML tags to sort on text only - Case insensitive
10992 * @param {Mixed} s The value being converted
10993 * @return {String} The comparison value
10995 asUCText : function(s){
10996 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11000 * Case insensitive string
11001 * @param {Mixed} s The value being converted
11002 * @return {String} The comparison value
11004 asUCString : function(s) {
11005 return String(s).toUpperCase();
11010 * @param {Mixed} s The value being converted
11011 * @return {Number} The comparison value
11013 asDate : function(s) {
11017 if(s instanceof Date){
11018 return s.getTime();
11020 return Date.parse(String(s));
11025 * @param {Mixed} s The value being converted
11026 * @return {Float} The comparison value
11028 asFloat : function(s) {
11029 var val = parseFloat(String(s).replace(/,/g, ""));
11038 * @param {Mixed} s The value being converted
11039 * @return {Number} The comparison value
11041 asInt : function(s) {
11042 var val = parseInt(String(s).replace(/,/g, ""));
11050 * Ext JS Library 1.1.1
11051 * Copyright(c) 2006-2007, Ext JS, LLC.
11053 * Originally Released Under LGPL - original licence link has changed is not relivant.
11056 * <script type="text/javascript">
11060 * @class Roo.data.Record
11061 * Instances of this class encapsulate both record <em>definition</em> information, and record
11062 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11063 * to access Records cached in an {@link Roo.data.Store} object.<br>
11065 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11066 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11069 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11071 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11072 * {@link #create}. The parameters are the same.
11073 * @param {Array} data An associative Array of data values keyed by the field name.
11074 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11075 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11076 * not specified an integer id is generated.
11078 Roo.data.Record = function(data, id){
11079 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11084 * Generate a constructor for a specific record layout.
11085 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11086 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11087 * Each field definition object may contain the following properties: <ul>
11088 * <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,
11089 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11090 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11091 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11092 * is being used, then this is a string containing the javascript expression to reference the data relative to
11093 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11094 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11095 * this may be omitted.</p></li>
11096 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11097 * <ul><li>auto (Default, implies no conversion)</li>
11102 * <li>date</li></ul></p></li>
11103 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11104 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11105 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11106 * by the Reader into an object that will be stored in the Record. It is passed the
11107 * following parameters:<ul>
11108 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11110 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11112 * <br>usage:<br><pre><code>
11113 var TopicRecord = Roo.data.Record.create(
11114 {name: 'title', mapping: 'topic_title'},
11115 {name: 'author', mapping: 'username'},
11116 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11117 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11118 {name: 'lastPoster', mapping: 'user2'},
11119 {name: 'excerpt', mapping: 'post_text'}
11122 var myNewRecord = new TopicRecord({
11123 title: 'Do my job please',
11126 lastPost: new Date(),
11127 lastPoster: 'Animal',
11128 excerpt: 'No way dude!'
11130 myStore.add(myNewRecord);
11135 Roo.data.Record.create = function(o){
11136 var f = function(){
11137 f.superclass.constructor.apply(this, arguments);
11139 Roo.extend(f, Roo.data.Record);
11140 var p = f.prototype;
11141 p.fields = new Roo.util.MixedCollection(false, function(field){
11144 for(var i = 0, len = o.length; i < len; i++){
11145 p.fields.add(new Roo.data.Field(o[i]));
11147 f.getField = function(name){
11148 return p.fields.get(name);
11153 Roo.data.Record.AUTO_ID = 1000;
11154 Roo.data.Record.EDIT = 'edit';
11155 Roo.data.Record.REJECT = 'reject';
11156 Roo.data.Record.COMMIT = 'commit';
11158 Roo.data.Record.prototype = {
11160 * Readonly flag - true if this record has been modified.
11169 join : function(store){
11170 this.store = store;
11174 * Set the named field to the specified value.
11175 * @param {String} name The name of the field to set.
11176 * @param {Object} value The value to set the field to.
11178 set : function(name, value){
11179 if(this.data[name] == value){
11183 if(!this.modified){
11184 this.modified = {};
11186 if(typeof this.modified[name] == 'undefined'){
11187 this.modified[name] = this.data[name];
11189 this.data[name] = value;
11190 if(!this.editing && this.store){
11191 this.store.afterEdit(this);
11196 * Get the value of the named field.
11197 * @param {String} name The name of the field to get the value of.
11198 * @return {Object} The value of the field.
11200 get : function(name){
11201 return this.data[name];
11205 beginEdit : function(){
11206 this.editing = true;
11207 this.modified = {};
11211 cancelEdit : function(){
11212 this.editing = false;
11213 delete this.modified;
11217 endEdit : function(){
11218 this.editing = false;
11219 if(this.dirty && this.store){
11220 this.store.afterEdit(this);
11225 * Usually called by the {@link Roo.data.Store} which owns the Record.
11226 * Rejects all changes made to the Record since either creation, or the last commit operation.
11227 * Modified fields are reverted to their original values.
11229 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11230 * of reject operations.
11232 reject : function(){
11233 var m = this.modified;
11235 if(typeof m[n] != "function"){
11236 this.data[n] = m[n];
11239 this.dirty = false;
11240 delete this.modified;
11241 this.editing = false;
11243 this.store.afterReject(this);
11248 * Usually called by the {@link Roo.data.Store} which owns the Record.
11249 * Commits all changes made to the Record since either creation, or the last commit operation.
11251 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11252 * of commit operations.
11254 commit : function(){
11255 this.dirty = false;
11256 delete this.modified;
11257 this.editing = false;
11259 this.store.afterCommit(this);
11264 hasError : function(){
11265 return this.error != null;
11269 clearError : function(){
11274 * Creates a copy of this record.
11275 * @param {String} id (optional) A new record id if you don't want to use this record's id
11278 copy : function(newId) {
11279 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11283 * Ext JS Library 1.1.1
11284 * Copyright(c) 2006-2007, Ext JS, LLC.
11286 * Originally Released Under LGPL - original licence link has changed is not relivant.
11289 * <script type="text/javascript">
11295 * @class Roo.data.Store
11296 * @extends Roo.util.Observable
11297 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11298 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11300 * 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
11301 * has no knowledge of the format of the data returned by the Proxy.<br>
11303 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11304 * instances from the data object. These records are cached and made available through accessor functions.
11306 * Creates a new Store.
11307 * @param {Object} config A config object containing the objects needed for the Store to access data,
11308 * and read the data into Records.
11310 Roo.data.Store = function(config){
11311 this.data = new Roo.util.MixedCollection(false);
11312 this.data.getKey = function(o){
11315 this.baseParams = {};
11317 this.paramNames = {
11322 "multisort" : "_multisort"
11325 if(config && config.data){
11326 this.inlineData = config.data;
11327 delete config.data;
11330 Roo.apply(this, config);
11332 if(this.reader){ // reader passed
11333 this.reader = Roo.factory(this.reader, Roo.data);
11334 this.reader.xmodule = this.xmodule || false;
11335 if(!this.recordType){
11336 this.recordType = this.reader.recordType;
11338 if(this.reader.onMetaChange){
11339 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11343 if(this.recordType){
11344 this.fields = this.recordType.prototype.fields;
11346 this.modified = [];
11350 * @event datachanged
11351 * Fires when the data cache has changed, and a widget which is using this Store
11352 * as a Record cache should refresh its view.
11353 * @param {Store} this
11355 datachanged : true,
11357 * @event metachange
11358 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11359 * @param {Store} this
11360 * @param {Object} meta The JSON metadata
11365 * Fires when Records have been added to the Store
11366 * @param {Store} this
11367 * @param {Roo.data.Record[]} records The array of Records added
11368 * @param {Number} index The index at which the record(s) were added
11373 * Fires when a Record has been removed from the Store
11374 * @param {Store} this
11375 * @param {Roo.data.Record} record The Record that was removed
11376 * @param {Number} index The index at which the record was removed
11381 * Fires when a Record has been updated
11382 * @param {Store} this
11383 * @param {Roo.data.Record} record The Record that was updated
11384 * @param {String} operation The update operation being performed. Value may be one of:
11386 Roo.data.Record.EDIT
11387 Roo.data.Record.REJECT
11388 Roo.data.Record.COMMIT
11394 * Fires when the data cache has been cleared.
11395 * @param {Store} this
11399 * @event beforeload
11400 * Fires before a request is made for a new data object. If the beforeload handler returns false
11401 * the load action will be canceled.
11402 * @param {Store} this
11403 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11407 * @event beforeloadadd
11408 * Fires after a new set of Records has been loaded.
11409 * @param {Store} this
11410 * @param {Roo.data.Record[]} records The Records that were loaded
11411 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11413 beforeloadadd : true,
11416 * Fires after a new set of Records has been loaded, before they are added to the store.
11417 * @param {Store} this
11418 * @param {Roo.data.Record[]} records The Records that were loaded
11419 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11420 * @params {Object} return from reader
11424 * @event loadexception
11425 * Fires if an exception occurs in the Proxy during loading.
11426 * Called with the signature of the Proxy's "loadexception" event.
11427 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11430 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11431 * @param {Object} load options
11432 * @param {Object} jsonData from your request (normally this contains the Exception)
11434 loadexception : true
11438 this.proxy = Roo.factory(this.proxy, Roo.data);
11439 this.proxy.xmodule = this.xmodule || false;
11440 this.relayEvents(this.proxy, ["loadexception"]);
11442 this.sortToggle = {};
11443 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11445 Roo.data.Store.superclass.constructor.call(this);
11447 if(this.inlineData){
11448 this.loadData(this.inlineData);
11449 delete this.inlineData;
11453 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11455 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11456 * without a remote query - used by combo/forms at present.
11460 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11463 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11466 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11467 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11470 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11471 * on any HTTP request
11474 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11477 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11481 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11482 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11484 remoteSort : false,
11487 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11488 * loaded or when a record is removed. (defaults to false).
11490 pruneModifiedRecords : false,
11493 lastOptions : null,
11496 * Add Records to the Store and fires the add event.
11497 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11499 add : function(records){
11500 records = [].concat(records);
11501 for(var i = 0, len = records.length; i < len; i++){
11502 records[i].join(this);
11504 var index = this.data.length;
11505 this.data.addAll(records);
11506 this.fireEvent("add", this, records, index);
11510 * Remove a Record from the Store and fires the remove event.
11511 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11513 remove : function(record){
11514 var index = this.data.indexOf(record);
11515 this.data.removeAt(index);
11517 if(this.pruneModifiedRecords){
11518 this.modified.remove(record);
11520 this.fireEvent("remove", this, record, index);
11524 * Remove all Records from the Store and fires the clear event.
11526 removeAll : function(){
11528 if(this.pruneModifiedRecords){
11529 this.modified = [];
11531 this.fireEvent("clear", this);
11535 * Inserts Records to the Store at the given index and fires the add event.
11536 * @param {Number} index The start index at which to insert the passed Records.
11537 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11539 insert : function(index, records){
11540 records = [].concat(records);
11541 for(var i = 0, len = records.length; i < len; i++){
11542 this.data.insert(index, records[i]);
11543 records[i].join(this);
11545 this.fireEvent("add", this, records, index);
11549 * Get the index within the cache of the passed Record.
11550 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11551 * @return {Number} The index of the passed Record. Returns -1 if not found.
11553 indexOf : function(record){
11554 return this.data.indexOf(record);
11558 * Get the index within the cache of the Record with the passed id.
11559 * @param {String} id The id of the Record to find.
11560 * @return {Number} The index of the Record. Returns -1 if not found.
11562 indexOfId : function(id){
11563 return this.data.indexOfKey(id);
11567 * Get the Record with the specified id.
11568 * @param {String} id The id of the Record to find.
11569 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11571 getById : function(id){
11572 return this.data.key(id);
11576 * Get the Record at the specified index.
11577 * @param {Number} index The index of the Record to find.
11578 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11580 getAt : function(index){
11581 return this.data.itemAt(index);
11585 * Returns a range of Records between specified indices.
11586 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11587 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11588 * @return {Roo.data.Record[]} An array of Records
11590 getRange : function(start, end){
11591 return this.data.getRange(start, end);
11595 storeOptions : function(o){
11596 o = Roo.apply({}, o);
11599 this.lastOptions = o;
11603 * Loads the Record cache from the configured Proxy using the configured Reader.
11605 * If using remote paging, then the first load call must specify the <em>start</em>
11606 * and <em>limit</em> properties in the options.params property to establish the initial
11607 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11609 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11610 * and this call will return before the new data has been loaded. Perform any post-processing
11611 * in a callback function, or in a "load" event handler.</strong>
11613 * @param {Object} options An object containing properties which control loading options:<ul>
11614 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11615 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11616 * passed the following arguments:<ul>
11617 * <li>r : Roo.data.Record[]</li>
11618 * <li>options: Options object from the load call</li>
11619 * <li>success: Boolean success indicator</li></ul></li>
11620 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11621 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11624 load : function(options){
11625 options = options || {};
11626 if(this.fireEvent("beforeload", this, options) !== false){
11627 this.storeOptions(options);
11628 var p = Roo.apply(options.params || {}, this.baseParams);
11629 // if meta was not loaded from remote source.. try requesting it.
11630 if (!this.reader.metaFromRemote) {
11631 p._requestMeta = 1;
11633 if(this.sortInfo && this.remoteSort){
11634 var pn = this.paramNames;
11635 p[pn["sort"]] = this.sortInfo.field;
11636 p[pn["dir"]] = this.sortInfo.direction;
11638 if (this.multiSort) {
11639 var pn = this.paramNames;
11640 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11643 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11648 * Reloads the Record cache from the configured Proxy using the configured Reader and
11649 * the options from the last load operation performed.
11650 * @param {Object} options (optional) An object containing properties which may override the options
11651 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11652 * the most recently used options are reused).
11654 reload : function(options){
11655 this.load(Roo.applyIf(options||{}, this.lastOptions));
11659 // Called as a callback by the Reader during a load operation.
11660 loadRecords : function(o, options, success){
11661 if(!o || success === false){
11662 if(success !== false){
11663 this.fireEvent("load", this, [], options, o);
11665 if(options.callback){
11666 options.callback.call(options.scope || this, [], options, false);
11670 // if data returned failure - throw an exception.
11671 if (o.success === false) {
11672 // show a message if no listener is registered.
11673 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11674 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11676 // loadmask wil be hooked into this..
11677 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11680 var r = o.records, t = o.totalRecords || r.length;
11682 this.fireEvent("beforeloadadd", this, r, options, o);
11684 if(!options || options.add !== true){
11685 if(this.pruneModifiedRecords){
11686 this.modified = [];
11688 for(var i = 0, len = r.length; i < len; i++){
11692 this.data = this.snapshot;
11693 delete this.snapshot;
11696 this.data.addAll(r);
11697 this.totalLength = t;
11699 this.fireEvent("datachanged", this);
11701 this.totalLength = Math.max(t, this.data.length+r.length);
11705 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11707 var e = new Roo.data.Record({});
11709 e.set(this.parent.displayField, this.parent.emptyTitle);
11710 e.set(this.parent.valueField, '');
11715 this.fireEvent("load", this, r, options, o);
11716 if(options.callback){
11717 options.callback.call(options.scope || this, r, options, true);
11723 * Loads data from a passed data block. A Reader which understands the format of the data
11724 * must have been configured in the constructor.
11725 * @param {Object} data The data block from which to read the Records. The format of the data expected
11726 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11727 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11729 loadData : function(o, append){
11730 var r = this.reader.readRecords(o);
11731 this.loadRecords(r, {add: append}, true);
11735 * Gets the number of cached records.
11737 * <em>If using paging, this may not be the total size of the dataset. If the data object
11738 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11739 * the data set size</em>
11741 getCount : function(){
11742 return this.data.length || 0;
11746 * Gets the total number of records in the dataset as returned by the server.
11748 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11749 * the dataset size</em>
11751 getTotalCount : function(){
11752 return this.totalLength || 0;
11756 * Returns the sort state of the Store as an object with two properties:
11758 field {String} The name of the field by which the Records are sorted
11759 direction {String} The sort order, "ASC" or "DESC"
11762 getSortState : function(){
11763 return this.sortInfo;
11767 applySort : function(){
11768 if(this.sortInfo && !this.remoteSort){
11769 var s = this.sortInfo, f = s.field;
11770 var st = this.fields.get(f).sortType;
11771 var fn = function(r1, r2){
11772 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11773 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11775 this.data.sort(s.direction, fn);
11776 if(this.snapshot && this.snapshot != this.data){
11777 this.snapshot.sort(s.direction, fn);
11783 * Sets the default sort column and order to be used by the next load operation.
11784 * @param {String} fieldName The name of the field to sort by.
11785 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11787 setDefaultSort : function(field, dir){
11788 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11792 * Sort the Records.
11793 * If remote sorting is used, the sort is performed on the server, and the cache is
11794 * reloaded. If local sorting is used, the cache is sorted internally.
11795 * @param {String} fieldName The name of the field to sort by.
11796 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11798 sort : function(fieldName, dir){
11799 var f = this.fields.get(fieldName);
11801 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11803 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11804 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11809 this.sortToggle[f.name] = dir;
11810 this.sortInfo = {field: f.name, direction: dir};
11811 if(!this.remoteSort){
11813 this.fireEvent("datachanged", this);
11815 this.load(this.lastOptions);
11820 * Calls the specified function for each of the Records in the cache.
11821 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11822 * Returning <em>false</em> aborts and exits the iteration.
11823 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11825 each : function(fn, scope){
11826 this.data.each(fn, scope);
11830 * Gets all records modified since the last commit. Modified records are persisted across load operations
11831 * (e.g., during paging).
11832 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11834 getModifiedRecords : function(){
11835 return this.modified;
11839 createFilterFn : function(property, value, anyMatch){
11840 if(!value.exec){ // not a regex
11841 value = String(value);
11842 if(value.length == 0){
11845 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11847 return function(r){
11848 return value.test(r.data[property]);
11853 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11854 * @param {String} property A field on your records
11855 * @param {Number} start The record index to start at (defaults to 0)
11856 * @param {Number} end The last record index to include (defaults to length - 1)
11857 * @return {Number} The sum
11859 sum : function(property, start, end){
11860 var rs = this.data.items, v = 0;
11861 start = start || 0;
11862 end = (end || end === 0) ? end : rs.length-1;
11864 for(var i = start; i <= end; i++){
11865 v += (rs[i].data[property] || 0);
11871 * Filter the records by a specified property.
11872 * @param {String} field A field on your records
11873 * @param {String/RegExp} value Either a string that the field
11874 * should start with or a RegExp to test against the field
11875 * @param {Boolean} anyMatch True to match any part not just the beginning
11877 filter : function(property, value, anyMatch){
11878 var fn = this.createFilterFn(property, value, anyMatch);
11879 return fn ? this.filterBy(fn) : this.clearFilter();
11883 * Filter by a function. The specified function will be called with each
11884 * record in this data source. If the function returns true the record is included,
11885 * otherwise it is filtered.
11886 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11887 * @param {Object} scope (optional) The scope of the function (defaults to this)
11889 filterBy : function(fn, scope){
11890 this.snapshot = this.snapshot || this.data;
11891 this.data = this.queryBy(fn, scope||this);
11892 this.fireEvent("datachanged", this);
11896 * Query the records by a specified property.
11897 * @param {String} field A field on your records
11898 * @param {String/RegExp} value Either a string that the field
11899 * should start with or a RegExp to test against the field
11900 * @param {Boolean} anyMatch True to match any part not just the beginning
11901 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11903 query : function(property, value, anyMatch){
11904 var fn = this.createFilterFn(property, value, anyMatch);
11905 return fn ? this.queryBy(fn) : this.data.clone();
11909 * Query by a function. The specified function will be called with each
11910 * record in this data source. If the function returns true the record is included
11912 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11913 * @param {Object} scope (optional) The scope of the function (defaults to this)
11914 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11916 queryBy : function(fn, scope){
11917 var data = this.snapshot || this.data;
11918 return data.filterBy(fn, scope||this);
11922 * Collects unique values for a particular dataIndex from this store.
11923 * @param {String} dataIndex The property to collect
11924 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11925 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11926 * @return {Array} An array of the unique values
11928 collect : function(dataIndex, allowNull, bypassFilter){
11929 var d = (bypassFilter === true && this.snapshot) ?
11930 this.snapshot.items : this.data.items;
11931 var v, sv, r = [], l = {};
11932 for(var i = 0, len = d.length; i < len; i++){
11933 v = d[i].data[dataIndex];
11935 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11944 * Revert to a view of the Record cache with no filtering applied.
11945 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11947 clearFilter : function(suppressEvent){
11948 if(this.snapshot && this.snapshot != this.data){
11949 this.data = this.snapshot;
11950 delete this.snapshot;
11951 if(suppressEvent !== true){
11952 this.fireEvent("datachanged", this);
11958 afterEdit : function(record){
11959 if(this.modified.indexOf(record) == -1){
11960 this.modified.push(record);
11962 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11966 afterReject : function(record){
11967 this.modified.remove(record);
11968 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11972 afterCommit : function(record){
11973 this.modified.remove(record);
11974 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11978 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11979 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11981 commitChanges : function(){
11982 var m = this.modified.slice(0);
11983 this.modified = [];
11984 for(var i = 0, len = m.length; i < len; i++){
11990 * Cancel outstanding changes on all changed records.
11992 rejectChanges : function(){
11993 var m = this.modified.slice(0);
11994 this.modified = [];
11995 for(var i = 0, len = m.length; i < len; i++){
12000 onMetaChange : function(meta, rtype, o){
12001 this.recordType = rtype;
12002 this.fields = rtype.prototype.fields;
12003 delete this.snapshot;
12004 this.sortInfo = meta.sortInfo || this.sortInfo;
12005 this.modified = [];
12006 this.fireEvent('metachange', this, this.reader.meta);
12009 moveIndex : function(data, type)
12011 var index = this.indexOf(data);
12013 var newIndex = index + type;
12017 this.insert(newIndex, data);
12022 * Ext JS Library 1.1.1
12023 * Copyright(c) 2006-2007, Ext JS, LLC.
12025 * Originally Released Under LGPL - original licence link has changed is not relivant.
12028 * <script type="text/javascript">
12032 * @class Roo.data.SimpleStore
12033 * @extends Roo.data.Store
12034 * Small helper class to make creating Stores from Array data easier.
12035 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12036 * @cfg {Array} fields An array of field definition objects, or field name strings.
12037 * @cfg {Array} data The multi-dimensional array of data
12039 * @param {Object} config
12041 Roo.data.SimpleStore = function(config){
12042 Roo.data.SimpleStore.superclass.constructor.call(this, {
12044 reader: new Roo.data.ArrayReader({
12047 Roo.data.Record.create(config.fields)
12049 proxy : new Roo.data.MemoryProxy(config.data)
12053 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12055 * Ext JS Library 1.1.1
12056 * Copyright(c) 2006-2007, Ext JS, LLC.
12058 * Originally Released Under LGPL - original licence link has changed is not relivant.
12061 * <script type="text/javascript">
12066 * @extends Roo.data.Store
12067 * @class Roo.data.JsonStore
12068 * Small helper class to make creating Stores for JSON data easier. <br/>
12070 var store = new Roo.data.JsonStore({
12071 url: 'get-images.php',
12073 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12076 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12077 * JsonReader and HttpProxy (unless inline data is provided).</b>
12078 * @cfg {Array} fields An array of field definition objects, or field name strings.
12080 * @param {Object} config
12082 Roo.data.JsonStore = function(c){
12083 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12084 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12085 reader: new Roo.data.JsonReader(c, c.fields)
12088 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12090 * Ext JS Library 1.1.1
12091 * Copyright(c) 2006-2007, Ext JS, LLC.
12093 * Originally Released Under LGPL - original licence link has changed is not relivant.
12096 * <script type="text/javascript">
12100 Roo.data.Field = function(config){
12101 if(typeof config == "string"){
12102 config = {name: config};
12104 Roo.apply(this, config);
12107 this.type = "auto";
12110 var st = Roo.data.SortTypes;
12111 // named sortTypes are supported, here we look them up
12112 if(typeof this.sortType == "string"){
12113 this.sortType = st[this.sortType];
12116 // set default sortType for strings and dates
12117 if(!this.sortType){
12120 this.sortType = st.asUCString;
12123 this.sortType = st.asDate;
12126 this.sortType = st.none;
12131 var stripRe = /[\$,%]/g;
12133 // prebuilt conversion function for this field, instead of
12134 // switching every time we're reading a value
12136 var cv, dateFormat = this.dateFormat;
12141 cv = function(v){ return v; };
12144 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12148 return v !== undefined && v !== null && v !== '' ?
12149 parseInt(String(v).replace(stripRe, ""), 10) : '';
12154 return v !== undefined && v !== null && v !== '' ?
12155 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12160 cv = function(v){ return v === true || v === "true" || v == 1; };
12167 if(v instanceof Date){
12171 if(dateFormat == "timestamp"){
12172 return new Date(v*1000);
12174 return Date.parseDate(v, dateFormat);
12176 var parsed = Date.parse(v);
12177 return parsed ? new Date(parsed) : null;
12186 Roo.data.Field.prototype = {
12194 * Ext JS Library 1.1.1
12195 * Copyright(c) 2006-2007, Ext JS, LLC.
12197 * Originally Released Under LGPL - original licence link has changed is not relivant.
12200 * <script type="text/javascript">
12203 // Base class for reading structured data from a data source. This class is intended to be
12204 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12207 * @class Roo.data.DataReader
12208 * Base class for reading structured data from a data source. This class is intended to be
12209 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12212 Roo.data.DataReader = function(meta, recordType){
12216 this.recordType = recordType instanceof Array ?
12217 Roo.data.Record.create(recordType) : recordType;
12220 Roo.data.DataReader.prototype = {
12222 * Create an empty record
12223 * @param {Object} data (optional) - overlay some values
12224 * @return {Roo.data.Record} record created.
12226 newRow : function(d) {
12228 this.recordType.prototype.fields.each(function(c) {
12230 case 'int' : da[c.name] = 0; break;
12231 case 'date' : da[c.name] = new Date(); break;
12232 case 'float' : da[c.name] = 0.0; break;
12233 case 'boolean' : da[c.name] = false; break;
12234 default : da[c.name] = ""; break;
12238 return new this.recordType(Roo.apply(da, d));
12243 * Ext JS Library 1.1.1
12244 * Copyright(c) 2006-2007, Ext JS, LLC.
12246 * Originally Released Under LGPL - original licence link has changed is not relivant.
12249 * <script type="text/javascript">
12253 * @class Roo.data.DataProxy
12254 * @extends Roo.data.Observable
12255 * This class is an abstract base class for implementations which provide retrieval of
12256 * unformatted data objects.<br>
12258 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12259 * (of the appropriate type which knows how to parse the data object) to provide a block of
12260 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12262 * Custom implementations must implement the load method as described in
12263 * {@link Roo.data.HttpProxy#load}.
12265 Roo.data.DataProxy = function(){
12268 * @event beforeload
12269 * Fires before a network request is made to retrieve a data object.
12270 * @param {Object} This DataProxy object.
12271 * @param {Object} params The params parameter to the load function.
12276 * Fires before the load method's callback is called.
12277 * @param {Object} This DataProxy object.
12278 * @param {Object} o The data object.
12279 * @param {Object} arg The callback argument object passed to the load function.
12283 * @event loadexception
12284 * Fires if an Exception occurs during data retrieval.
12285 * @param {Object} This DataProxy object.
12286 * @param {Object} o The data object.
12287 * @param {Object} arg The callback argument object passed to the load function.
12288 * @param {Object} e The Exception.
12290 loadexception : true
12292 Roo.data.DataProxy.superclass.constructor.call(this);
12295 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12298 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12302 * Ext JS Library 1.1.1
12303 * Copyright(c) 2006-2007, Ext JS, LLC.
12305 * Originally Released Under LGPL - original licence link has changed is not relivant.
12308 * <script type="text/javascript">
12311 * @class Roo.data.MemoryProxy
12312 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12313 * to the Reader when its load method is called.
12315 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12317 Roo.data.MemoryProxy = function(data){
12321 Roo.data.MemoryProxy.superclass.constructor.call(this);
12325 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12328 * Load data from the requested source (in this case an in-memory
12329 * data object passed to the constructor), read the data object into
12330 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12331 * process that block using the passed callback.
12332 * @param {Object} params This parameter is not used by the MemoryProxy class.
12333 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12334 * object into a block of Roo.data.Records.
12335 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12336 * The function must be passed <ul>
12337 * <li>The Record block object</li>
12338 * <li>The "arg" argument from the load function</li>
12339 * <li>A boolean success indicator</li>
12341 * @param {Object} scope The scope in which to call the callback
12342 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12344 load : function(params, reader, callback, scope, arg){
12345 params = params || {};
12348 result = reader.readRecords(this.data);
12350 this.fireEvent("loadexception", this, arg, null, e);
12351 callback.call(scope, null, arg, false);
12354 callback.call(scope, result, arg, true);
12358 update : function(params, records){
12363 * Ext JS Library 1.1.1
12364 * Copyright(c) 2006-2007, Ext JS, LLC.
12366 * Originally Released Under LGPL - original licence link has changed is not relivant.
12369 * <script type="text/javascript">
12372 * @class Roo.data.HttpProxy
12373 * @extends Roo.data.DataProxy
12374 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12375 * configured to reference a certain URL.<br><br>
12377 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12378 * from which the running page was served.<br><br>
12380 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12382 * Be aware that to enable the browser to parse an XML document, the server must set
12383 * the Content-Type header in the HTTP response to "text/xml".
12385 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12386 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12387 * will be used to make the request.
12389 Roo.data.HttpProxy = function(conn){
12390 Roo.data.HttpProxy.superclass.constructor.call(this);
12391 // is conn a conn config or a real conn?
12393 this.useAjax = !conn || !conn.events;
12397 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12398 // thse are take from connection...
12401 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12404 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12405 * extra parameters to each request made by this object. (defaults to undefined)
12408 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12409 * to each request made by this object. (defaults to undefined)
12412 * @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)
12415 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12418 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12424 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12428 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12429 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12430 * a finer-grained basis than the DataProxy events.
12432 getConnection : function(){
12433 return this.useAjax ? Roo.Ajax : this.conn;
12437 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12438 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12439 * process that block using the passed callback.
12440 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12441 * for the request to the remote server.
12442 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12443 * object into a block of Roo.data.Records.
12444 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12445 * The function must be passed <ul>
12446 * <li>The Record block object</li>
12447 * <li>The "arg" argument from the load function</li>
12448 * <li>A boolean success indicator</li>
12450 * @param {Object} scope The scope in which to call the callback
12451 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12453 load : function(params, reader, callback, scope, arg){
12454 if(this.fireEvent("beforeload", this, params) !== false){
12456 params : params || {},
12458 callback : callback,
12463 callback : this.loadResponse,
12467 Roo.applyIf(o, this.conn);
12468 if(this.activeRequest){
12469 Roo.Ajax.abort(this.activeRequest);
12471 this.activeRequest = Roo.Ajax.request(o);
12473 this.conn.request(o);
12476 callback.call(scope||this, null, arg, false);
12481 loadResponse : function(o, success, response){
12482 delete this.activeRequest;
12484 this.fireEvent("loadexception", this, o, response);
12485 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12490 result = o.reader.read(response);
12492 this.fireEvent("loadexception", this, o, response, e);
12493 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12497 this.fireEvent("load", this, o, o.request.arg);
12498 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12502 update : function(dataSet){
12507 updateResponse : function(dataSet){
12512 * Ext JS Library 1.1.1
12513 * Copyright(c) 2006-2007, Ext JS, LLC.
12515 * Originally Released Under LGPL - original licence link has changed is not relivant.
12518 * <script type="text/javascript">
12522 * @class Roo.data.ScriptTagProxy
12523 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12524 * other than the originating domain of the running page.<br><br>
12526 * <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
12527 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12529 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12530 * source code that is used as the source inside a <script> tag.<br><br>
12532 * In order for the browser to process the returned data, the server must wrap the data object
12533 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12534 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12535 * depending on whether the callback name was passed:
12538 boolean scriptTag = false;
12539 String cb = request.getParameter("callback");
12542 response.setContentType("text/javascript");
12544 response.setContentType("application/x-json");
12546 Writer out = response.getWriter();
12548 out.write(cb + "(");
12550 out.print(dataBlock.toJsonString());
12557 * @param {Object} config A configuration object.
12559 Roo.data.ScriptTagProxy = function(config){
12560 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12561 Roo.apply(this, config);
12562 this.head = document.getElementsByTagName("head")[0];
12565 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12567 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12569 * @cfg {String} url The URL from which to request the data object.
12572 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12576 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12577 * the server the name of the callback function set up by the load call to process the returned data object.
12578 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12579 * javascript output which calls this named function passing the data object as its only parameter.
12581 callbackParam : "callback",
12583 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12584 * name to the request.
12589 * Load data from the configured URL, read the data object into
12590 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12591 * process that block using the passed callback.
12592 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12593 * for the request to the remote server.
12594 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12595 * object into a block of Roo.data.Records.
12596 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12597 * The function must be passed <ul>
12598 * <li>The Record block object</li>
12599 * <li>The "arg" argument from the load function</li>
12600 * <li>A boolean success indicator</li>
12602 * @param {Object} scope The scope in which to call the callback
12603 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12605 load : function(params, reader, callback, scope, arg){
12606 if(this.fireEvent("beforeload", this, params) !== false){
12608 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12610 var url = this.url;
12611 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12613 url += "&_dc=" + (new Date().getTime());
12615 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12618 cb : "stcCallback"+transId,
12619 scriptId : "stcScript"+transId,
12623 callback : callback,
12629 window[trans.cb] = function(o){
12630 conn.handleResponse(o, trans);
12633 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12635 if(this.autoAbort !== false){
12639 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12641 var script = document.createElement("script");
12642 script.setAttribute("src", url);
12643 script.setAttribute("type", "text/javascript");
12644 script.setAttribute("id", trans.scriptId);
12645 this.head.appendChild(script);
12647 this.trans = trans;
12649 callback.call(scope||this, null, arg, false);
12654 isLoading : function(){
12655 return this.trans ? true : false;
12659 * Abort the current server request.
12661 abort : function(){
12662 if(this.isLoading()){
12663 this.destroyTrans(this.trans);
12668 destroyTrans : function(trans, isLoaded){
12669 this.head.removeChild(document.getElementById(trans.scriptId));
12670 clearTimeout(trans.timeoutId);
12672 window[trans.cb] = undefined;
12674 delete window[trans.cb];
12677 // if hasn't been loaded, wait for load to remove it to prevent script error
12678 window[trans.cb] = function(){
12679 window[trans.cb] = undefined;
12681 delete window[trans.cb];
12688 handleResponse : function(o, trans){
12689 this.trans = false;
12690 this.destroyTrans(trans, true);
12693 result = trans.reader.readRecords(o);
12695 this.fireEvent("loadexception", this, o, trans.arg, e);
12696 trans.callback.call(trans.scope||window, null, trans.arg, false);
12699 this.fireEvent("load", this, o, trans.arg);
12700 trans.callback.call(trans.scope||window, result, trans.arg, true);
12704 handleFailure : function(trans){
12705 this.trans = false;
12706 this.destroyTrans(trans, false);
12707 this.fireEvent("loadexception", this, null, trans.arg);
12708 trans.callback.call(trans.scope||window, null, trans.arg, false);
12712 * Ext JS Library 1.1.1
12713 * Copyright(c) 2006-2007, Ext JS, LLC.
12715 * Originally Released Under LGPL - original licence link has changed is not relivant.
12718 * <script type="text/javascript">
12722 * @class Roo.data.JsonReader
12723 * @extends Roo.data.DataReader
12724 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12725 * based on mappings in a provided Roo.data.Record constructor.
12727 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12728 * in the reply previously.
12733 var RecordDef = Roo.data.Record.create([
12734 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12735 {name: 'occupation'} // This field will use "occupation" as the mapping.
12737 var myReader = new Roo.data.JsonReader({
12738 totalProperty: "results", // The property which contains the total dataset size (optional)
12739 root: "rows", // The property which contains an Array of row objects
12740 id: "id" // The property within each row object that provides an ID for the record (optional)
12744 * This would consume a JSON file like this:
12746 { 'results': 2, 'rows': [
12747 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12748 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12751 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12752 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12753 * paged from the remote server.
12754 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12755 * @cfg {String} root name of the property which contains the Array of row objects.
12756 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12757 * @cfg {Array} fields Array of field definition objects
12759 * Create a new JsonReader
12760 * @param {Object} meta Metadata configuration options
12761 * @param {Object} recordType Either an Array of field definition objects,
12762 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12764 Roo.data.JsonReader = function(meta, recordType){
12767 // set some defaults:
12768 Roo.applyIf(meta, {
12769 totalProperty: 'total',
12770 successProperty : 'success',
12775 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12777 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12780 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12781 * Used by Store query builder to append _requestMeta to params.
12784 metaFromRemote : false,
12786 * This method is only used by a DataProxy which has retrieved data from a remote server.
12787 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12788 * @return {Object} data A data block which is used by an Roo.data.Store object as
12789 * a cache of Roo.data.Records.
12791 read : function(response){
12792 var json = response.responseText;
12794 var o = /* eval:var:o */ eval("("+json+")");
12796 throw {message: "JsonReader.read: Json object not found"};
12802 this.metaFromRemote = true;
12803 this.meta = o.metaData;
12804 this.recordType = Roo.data.Record.create(o.metaData.fields);
12805 this.onMetaChange(this.meta, this.recordType, o);
12807 return this.readRecords(o);
12810 // private function a store will implement
12811 onMetaChange : function(meta, recordType, o){
12818 simpleAccess: function(obj, subsc) {
12825 getJsonAccessor: function(){
12827 return function(expr) {
12829 return(re.test(expr))
12830 ? new Function("obj", "return obj." + expr)
12835 return Roo.emptyFn;
12840 * Create a data block containing Roo.data.Records from an XML document.
12841 * @param {Object} o An object which contains an Array of row objects in the property specified
12842 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12843 * which contains the total size of the dataset.
12844 * @return {Object} data A data block which is used by an Roo.data.Store object as
12845 * a cache of Roo.data.Records.
12847 readRecords : function(o){
12849 * After any data loads, the raw JSON data is available for further custom processing.
12853 var s = this.meta, Record = this.recordType,
12854 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12856 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12858 if(s.totalProperty) {
12859 this.getTotal = this.getJsonAccessor(s.totalProperty);
12861 if(s.successProperty) {
12862 this.getSuccess = this.getJsonAccessor(s.successProperty);
12864 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12866 var g = this.getJsonAccessor(s.id);
12867 this.getId = function(rec) {
12869 return (r === undefined || r === "") ? null : r;
12872 this.getId = function(){return null;};
12875 for(var jj = 0; jj < fl; jj++){
12877 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12878 this.ef[jj] = this.getJsonAccessor(map);
12882 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12883 if(s.totalProperty){
12884 var vt = parseInt(this.getTotal(o), 10);
12889 if(s.successProperty){
12890 var vs = this.getSuccess(o);
12891 if(vs === false || vs === 'false'){
12896 for(var i = 0; i < c; i++){
12899 var id = this.getId(n);
12900 for(var j = 0; j < fl; j++){
12902 var v = this.ef[j](n);
12904 Roo.log('missing convert for ' + f.name);
12908 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12910 var record = new Record(values, id);
12912 records[i] = record;
12918 totalRecords : totalRecords
12923 * Ext JS Library 1.1.1
12924 * Copyright(c) 2006-2007, Ext JS, LLC.
12926 * Originally Released Under LGPL - original licence link has changed is not relivant.
12929 * <script type="text/javascript">
12933 * @class Roo.data.ArrayReader
12934 * @extends Roo.data.DataReader
12935 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12936 * Each element of that Array represents a row of data fields. The
12937 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12938 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12942 var RecordDef = Roo.data.Record.create([
12943 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12944 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12946 var myReader = new Roo.data.ArrayReader({
12947 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12951 * This would consume an Array like this:
12953 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12955 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12957 * Create a new JsonReader
12958 * @param {Object} meta Metadata configuration options.
12959 * @param {Object} recordType Either an Array of field definition objects
12960 * as specified to {@link Roo.data.Record#create},
12961 * or an {@link Roo.data.Record} object
12962 * created using {@link Roo.data.Record#create}.
12964 Roo.data.ArrayReader = function(meta, recordType){
12965 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12968 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12970 * Create a data block containing Roo.data.Records from an XML document.
12971 * @param {Object} o An Array of row objects which represents the dataset.
12972 * @return {Object} data A data block which is used by an Roo.data.Store object as
12973 * a cache of Roo.data.Records.
12975 readRecords : function(o){
12976 var sid = this.meta ? this.meta.id : null;
12977 var recordType = this.recordType, fields = recordType.prototype.fields;
12980 for(var i = 0; i < root.length; i++){
12983 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12984 for(var j = 0, jlen = fields.length; j < jlen; j++){
12985 var f = fields.items[j];
12986 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12987 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12989 values[f.name] = v;
12991 var record = new recordType(values, id);
12993 records[records.length] = record;
12997 totalRecords : records.length
13006 * @class Roo.bootstrap.ComboBox
13007 * @extends Roo.bootstrap.TriggerField
13008 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13009 * @cfg {Boolean} append (true|false) default false
13010 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13011 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13012 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13013 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13014 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13015 * @cfg {Boolean} animate default true
13016 * @cfg {Boolean} emptyResultText only for touch device
13017 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13018 * @cfg {String} emptyTitle default ''
13020 * Create a new ComboBox.
13021 * @param {Object} config Configuration options
13023 Roo.bootstrap.ComboBox = function(config){
13024 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13028 * Fires when the dropdown list is expanded
13029 * @param {Roo.bootstrap.ComboBox} combo This combo box
13034 * Fires when the dropdown list is collapsed
13035 * @param {Roo.bootstrap.ComboBox} combo This combo box
13039 * @event beforeselect
13040 * Fires before a list item is selected. Return false to cancel the selection.
13041 * @param {Roo.bootstrap.ComboBox} combo This combo box
13042 * @param {Roo.data.Record} record The data record returned from the underlying store
13043 * @param {Number} index The index of the selected item in the dropdown list
13045 'beforeselect' : true,
13048 * Fires when a list item is selected
13049 * @param {Roo.bootstrap.ComboBox} combo This combo box
13050 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13051 * @param {Number} index The index of the selected item in the dropdown list
13055 * @event beforequery
13056 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13057 * The event object passed has these properties:
13058 * @param {Roo.bootstrap.ComboBox} combo This combo box
13059 * @param {String} query The query
13060 * @param {Boolean} forceAll true to force "all" query
13061 * @param {Boolean} cancel true to cancel the query
13062 * @param {Object} e The query event object
13064 'beforequery': true,
13067 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13068 * @param {Roo.bootstrap.ComboBox} combo This combo box
13073 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13074 * @param {Roo.bootstrap.ComboBox} combo This combo box
13075 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13080 * Fires when the remove value from the combobox array
13081 * @param {Roo.bootstrap.ComboBox} combo This combo box
13085 * @event afterremove
13086 * Fires when the remove value from the combobox array
13087 * @param {Roo.bootstrap.ComboBox} combo This combo box
13089 'afterremove' : true,
13091 * @event specialfilter
13092 * Fires when specialfilter
13093 * @param {Roo.bootstrap.ComboBox} combo This combo box
13095 'specialfilter' : true,
13098 * Fires when tick the element
13099 * @param {Roo.bootstrap.ComboBox} combo This combo box
13103 * @event touchviewdisplay
13104 * Fires when touch view require special display (default is using displayField)
13105 * @param {Roo.bootstrap.ComboBox} combo This combo box
13106 * @param {Object} cfg set html .
13108 'touchviewdisplay' : true
13113 this.tickItems = [];
13115 this.selectedIndex = -1;
13116 if(this.mode == 'local'){
13117 if(config.queryDelay === undefined){
13118 this.queryDelay = 10;
13120 if(config.minChars === undefined){
13126 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13129 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13130 * rendering into an Roo.Editor, defaults to false)
13133 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13134 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13137 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13140 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13141 * the dropdown list (defaults to undefined, with no header element)
13145 * @cfg {String/Roo.Template} tpl The template to use to render the output
13149 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13151 listWidth: undefined,
13153 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13154 * mode = 'remote' or 'text' if mode = 'local')
13156 displayField: undefined,
13159 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13160 * mode = 'remote' or 'value' if mode = 'local').
13161 * Note: use of a valueField requires the user make a selection
13162 * in order for a value to be mapped.
13164 valueField: undefined,
13166 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13171 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13172 * field's data value (defaults to the underlying DOM element's name)
13174 hiddenName: undefined,
13176 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13180 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13182 selectedClass: 'active',
13185 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13189 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13190 * anchor positions (defaults to 'tl-bl')
13192 listAlign: 'tl-bl?',
13194 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13198 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13199 * query specified by the allQuery config option (defaults to 'query')
13201 triggerAction: 'query',
13203 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13204 * (defaults to 4, does not apply if editable = false)
13208 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13209 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13213 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13214 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13218 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13219 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13223 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13224 * when editable = true (defaults to false)
13226 selectOnFocus:false,
13228 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13230 queryParam: 'query',
13232 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13233 * when mode = 'remote' (defaults to 'Loading...')
13235 loadingText: 'Loading...',
13237 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13241 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13245 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13246 * traditional select (defaults to true)
13250 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13254 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13258 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13259 * listWidth has a higher value)
13263 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13264 * allow the user to set arbitrary text into the field (defaults to false)
13266 forceSelection:false,
13268 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13269 * if typeAhead = true (defaults to 250)
13271 typeAheadDelay : 250,
13273 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13274 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13276 valueNotFoundText : undefined,
13278 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13280 blockFocus : false,
13283 * @cfg {Boolean} disableClear Disable showing of clear button.
13285 disableClear : false,
13287 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13289 alwaysQuery : false,
13292 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13297 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13299 invalidClass : "has-warning",
13302 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13304 validClass : "has-success",
13307 * @cfg {Boolean} specialFilter (true|false) special filter default false
13309 specialFilter : false,
13312 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13314 mobileTouchView : true,
13317 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13319 useNativeIOS : false,
13322 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13324 mobile_restrict_height : false,
13326 ios_options : false,
13338 btnPosition : 'right',
13339 triggerList : true,
13340 showToggleBtn : true,
13342 emptyResultText: 'Empty',
13343 triggerText : 'Select',
13346 // element that contains real text value.. (when hidden is used..)
13348 getAutoCreate : function()
13353 * Render classic select for iso
13356 if(Roo.isIOS && this.useNativeIOS){
13357 cfg = this.getAutoCreateNativeIOS();
13365 if(Roo.isTouch && this.mobileTouchView){
13366 cfg = this.getAutoCreateTouchView();
13373 if(!this.tickable){
13374 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13379 * ComboBox with tickable selections
13382 var align = this.labelAlign || this.parentLabelAlign();
13385 cls : 'form-group roo-combobox-tickable' //input-group
13388 var btn_text_select = '';
13389 var btn_text_done = '';
13390 var btn_text_cancel = '';
13392 if (this.btn_text_show) {
13393 btn_text_select = 'Select';
13394 btn_text_done = 'Done';
13395 btn_text_cancel = 'Cancel';
13400 cls : 'tickable-buttons',
13405 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13406 //html : this.triggerText
13407 html: btn_text_select
13413 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13415 html: btn_text_done
13421 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13423 html: btn_text_cancel
13429 buttons.cn.unshift({
13431 cls: 'roo-select2-search-field-input'
13437 Roo.each(buttons.cn, function(c){
13439 c.cls += ' btn-' + _this.size;
13442 if (_this.disabled) {
13449 style : 'display: contents',
13454 cls: 'form-hidden-field'
13458 cls: 'roo-select2-choices',
13462 cls: 'roo-select2-search-field',
13473 cls: 'roo-select2-container input-group roo-select2-container-multi',
13479 // cls: 'typeahead typeahead-long dropdown-menu',
13480 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13485 if(this.hasFeedback && !this.allowBlank){
13489 cls: 'glyphicon form-control-feedback'
13492 combobox.cn.push(feedback);
13497 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13498 tooltip : 'This field is required'
13500 if (Roo.bootstrap.version == 4) {
13503 style : 'display:none'
13506 if (align ==='left' && this.fieldLabel.length) {
13508 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13515 cls : 'control-label col-form-label',
13516 html : this.fieldLabel
13528 var labelCfg = cfg.cn[1];
13529 var contentCfg = cfg.cn[2];
13532 if(this.indicatorpos == 'right'){
13538 cls : 'control-label col-form-label',
13542 html : this.fieldLabel
13558 labelCfg = cfg.cn[0];
13559 contentCfg = cfg.cn[1];
13563 if(this.labelWidth > 12){
13564 labelCfg.style = "width: " + this.labelWidth + 'px';
13567 if(this.labelWidth < 13 && this.labelmd == 0){
13568 this.labelmd = this.labelWidth;
13571 if(this.labellg > 0){
13572 labelCfg.cls += ' col-lg-' + this.labellg;
13573 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13576 if(this.labelmd > 0){
13577 labelCfg.cls += ' col-md-' + this.labelmd;
13578 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13581 if(this.labelsm > 0){
13582 labelCfg.cls += ' col-sm-' + this.labelsm;
13583 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13586 if(this.labelxs > 0){
13587 labelCfg.cls += ' col-xs-' + this.labelxs;
13588 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13592 } else if ( this.fieldLabel.length) {
13593 // Roo.log(" label");
13598 //cls : 'input-group-addon',
13599 html : this.fieldLabel
13604 if(this.indicatorpos == 'right'){
13608 //cls : 'input-group-addon',
13609 html : this.fieldLabel
13619 // Roo.log(" no label && no align");
13626 ['xs','sm','md','lg'].map(function(size){
13627 if (settings[size]) {
13628 cfg.cls += ' col-' + size + '-' + settings[size];
13636 _initEventsCalled : false,
13639 initEvents: function()
13641 if (this._initEventsCalled) { // as we call render... prevent looping...
13644 this._initEventsCalled = true;
13647 throw "can not find store for combo";
13650 this.indicator = this.indicatorEl();
13652 this.store = Roo.factory(this.store, Roo.data);
13653 this.store.parent = this;
13655 // if we are building from html. then this element is so complex, that we can not really
13656 // use the rendered HTML.
13657 // so we have to trash and replace the previous code.
13658 if (Roo.XComponent.build_from_html) {
13659 // remove this element....
13660 var e = this.el.dom, k=0;
13661 while (e ) { e = e.previousSibling; ++k;}
13666 this.rendered = false;
13668 this.render(this.parent().getChildContainer(true), k);
13671 if(Roo.isIOS && this.useNativeIOS){
13672 this.initIOSView();
13680 if(Roo.isTouch && this.mobileTouchView){
13681 this.initTouchView();
13686 this.initTickableEvents();
13690 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13692 if(this.hiddenName){
13694 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13696 this.hiddenField.dom.value =
13697 this.hiddenValue !== undefined ? this.hiddenValue :
13698 this.value !== undefined ? this.value : '';
13700 // prevent input submission
13701 this.el.dom.removeAttribute('name');
13702 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13707 // this.el.dom.setAttribute('autocomplete', 'off');
13710 var cls = 'x-combo-list';
13712 //this.list = new Roo.Layer({
13713 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13719 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13720 _this.list.setWidth(lw);
13723 this.list.on('mouseover', this.onViewOver, this);
13724 this.list.on('mousemove', this.onViewMove, this);
13725 this.list.on('scroll', this.onViewScroll, this);
13728 this.list.swallowEvent('mousewheel');
13729 this.assetHeight = 0;
13732 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13733 this.assetHeight += this.header.getHeight();
13736 this.innerList = this.list.createChild({cls:cls+'-inner'});
13737 this.innerList.on('mouseover', this.onViewOver, this);
13738 this.innerList.on('mousemove', this.onViewMove, this);
13739 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13741 if(this.allowBlank && !this.pageSize && !this.disableClear){
13742 this.footer = this.list.createChild({cls:cls+'-ft'});
13743 this.pageTb = new Roo.Toolbar(this.footer);
13747 this.footer = this.list.createChild({cls:cls+'-ft'});
13748 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13749 {pageSize: this.pageSize});
13753 if (this.pageTb && this.allowBlank && !this.disableClear) {
13755 this.pageTb.add(new Roo.Toolbar.Fill(), {
13756 cls: 'x-btn-icon x-btn-clear',
13758 handler: function()
13761 _this.clearValue();
13762 _this.onSelect(false, -1);
13767 this.assetHeight += this.footer.getHeight();
13772 this.tpl = Roo.bootstrap.version == 4 ?
13773 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13774 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13777 this.view = new Roo.View(this.list, this.tpl, {
13778 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13780 //this.view.wrapEl.setDisplayed(false);
13781 this.view.on('click', this.onViewClick, this);
13784 this.store.on('beforeload', this.onBeforeLoad, this);
13785 this.store.on('load', this.onLoad, this);
13786 this.store.on('loadexception', this.onLoadException, this);
13788 if(this.resizable){
13789 this.resizer = new Roo.Resizable(this.list, {
13790 pinned:true, handles:'se'
13792 this.resizer.on('resize', function(r, w, h){
13793 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13794 this.listWidth = w;
13795 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13796 this.restrictHeight();
13798 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13801 if(!this.editable){
13802 this.editable = true;
13803 this.setEditable(false);
13808 if (typeof(this.events.add.listeners) != 'undefined') {
13810 this.addicon = this.wrap.createChild(
13811 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13813 this.addicon.on('click', function(e) {
13814 this.fireEvent('add', this);
13817 if (typeof(this.events.edit.listeners) != 'undefined') {
13819 this.editicon = this.wrap.createChild(
13820 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13821 if (this.addicon) {
13822 this.editicon.setStyle('margin-left', '40px');
13824 this.editicon.on('click', function(e) {
13826 // we fire even if inothing is selected..
13827 this.fireEvent('edit', this, this.lastData );
13833 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13834 "up" : function(e){
13835 this.inKeyMode = true;
13839 "down" : function(e){
13840 if(!this.isExpanded()){
13841 this.onTriggerClick();
13843 this.inKeyMode = true;
13848 "enter" : function(e){
13849 // this.onViewClick();
13853 if(this.fireEvent("specialkey", this, e)){
13854 this.onViewClick(false);
13860 "esc" : function(e){
13864 "tab" : function(e){
13867 if(this.fireEvent("specialkey", this, e)){
13868 this.onViewClick(false);
13876 doRelay : function(foo, bar, hname){
13877 if(hname == 'down' || this.scope.isExpanded()){
13878 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13887 this.queryDelay = Math.max(this.queryDelay || 10,
13888 this.mode == 'local' ? 10 : 250);
13891 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13893 if(this.typeAhead){
13894 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13896 if(this.editable !== false){
13897 this.inputEl().on("keyup", this.onKeyUp, this);
13899 if(this.forceSelection){
13900 this.inputEl().on('blur', this.doForce, this);
13904 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13905 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13909 initTickableEvents: function()
13913 if(this.hiddenName){
13915 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13917 this.hiddenField.dom.value =
13918 this.hiddenValue !== undefined ? this.hiddenValue :
13919 this.value !== undefined ? this.value : '';
13921 // prevent input submission
13922 this.el.dom.removeAttribute('name');
13923 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13928 // this.list = this.el.select('ul.dropdown-menu',true).first();
13930 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13931 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13932 if(this.triggerList){
13933 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13936 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13937 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13939 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13940 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13942 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13943 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13945 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13946 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13947 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13950 this.cancelBtn.hide();
13955 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13956 _this.list.setWidth(lw);
13959 this.list.on('mouseover', this.onViewOver, this);
13960 this.list.on('mousemove', this.onViewMove, this);
13962 this.list.on('scroll', this.onViewScroll, this);
13965 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
13966 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13969 this.view = new Roo.View(this.list, this.tpl, {
13974 selectedClass: this.selectedClass
13977 //this.view.wrapEl.setDisplayed(false);
13978 this.view.on('click', this.onViewClick, this);
13982 this.store.on('beforeload', this.onBeforeLoad, this);
13983 this.store.on('load', this.onLoad, this);
13984 this.store.on('loadexception', this.onLoadException, this);
13987 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13988 "up" : function(e){
13989 this.inKeyMode = true;
13993 "down" : function(e){
13994 this.inKeyMode = true;
13998 "enter" : function(e){
13999 if(this.fireEvent("specialkey", this, e)){
14000 this.onViewClick(false);
14006 "esc" : function(e){
14007 this.onTickableFooterButtonClick(e, false, false);
14010 "tab" : function(e){
14011 this.fireEvent("specialkey", this, e);
14013 this.onTickableFooterButtonClick(e, false, false);
14020 doRelay : function(e, fn, key){
14021 if(this.scope.isExpanded()){
14022 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14031 this.queryDelay = Math.max(this.queryDelay || 10,
14032 this.mode == 'local' ? 10 : 250);
14035 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14037 if(this.typeAhead){
14038 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14041 if(this.editable !== false){
14042 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14045 this.indicator = this.indicatorEl();
14047 if(this.indicator){
14048 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14049 this.indicator.hide();
14054 onDestroy : function(){
14056 this.view.setStore(null);
14057 this.view.el.removeAllListeners();
14058 this.view.el.remove();
14059 this.view.purgeListeners();
14062 this.list.dom.innerHTML = '';
14066 this.store.un('beforeload', this.onBeforeLoad, this);
14067 this.store.un('load', this.onLoad, this);
14068 this.store.un('loadexception', this.onLoadException, this);
14070 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14074 fireKey : function(e){
14075 if(e.isNavKeyPress() && !this.list.isVisible()){
14076 this.fireEvent("specialkey", this, e);
14081 onResize: function(w, h){
14082 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14084 // if(typeof w != 'number'){
14085 // // we do not handle it!?!?
14088 // var tw = this.trigger.getWidth();
14089 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14090 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14092 // this.inputEl().setWidth( this.adjustWidth('input', x));
14094 // //this.trigger.setStyle('left', x+'px');
14096 // if(this.list && this.listWidth === undefined){
14097 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14098 // this.list.setWidth(lw);
14099 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14107 * Allow or prevent the user from directly editing the field text. If false is passed,
14108 * the user will only be able to select from the items defined in the dropdown list. This method
14109 * is the runtime equivalent of setting the 'editable' config option at config time.
14110 * @param {Boolean} value True to allow the user to directly edit the field text
14112 setEditable : function(value){
14113 if(value == this.editable){
14116 this.editable = value;
14118 this.inputEl().dom.setAttribute('readOnly', true);
14119 this.inputEl().on('mousedown', this.onTriggerClick, this);
14120 this.inputEl().addClass('x-combo-noedit');
14122 this.inputEl().dom.setAttribute('readOnly', false);
14123 this.inputEl().un('mousedown', this.onTriggerClick, this);
14124 this.inputEl().removeClass('x-combo-noedit');
14130 onBeforeLoad : function(combo,opts){
14131 if(!this.hasFocus){
14135 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14137 this.restrictHeight();
14138 this.selectedIndex = -1;
14142 onLoad : function(){
14144 this.hasQuery = false;
14146 if(!this.hasFocus){
14150 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14151 this.loading.hide();
14154 if(this.store.getCount() > 0){
14157 this.restrictHeight();
14158 if(this.lastQuery == this.allQuery){
14159 if(this.editable && !this.tickable){
14160 this.inputEl().dom.select();
14164 !this.selectByValue(this.value, true) &&
14167 !this.store.lastOptions ||
14168 typeof(this.store.lastOptions.add) == 'undefined' ||
14169 this.store.lastOptions.add != true
14172 this.select(0, true);
14175 if(this.autoFocus){
14178 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14179 this.taTask.delay(this.typeAheadDelay);
14183 this.onEmptyResults();
14189 onLoadException : function()
14191 this.hasQuery = false;
14193 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14194 this.loading.hide();
14197 if(this.tickable && this.editable){
14202 // only causes errors at present
14203 //Roo.log(this.store.reader.jsonData);
14204 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14206 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14212 onTypeAhead : function(){
14213 if(this.store.getCount() > 0){
14214 var r = this.store.getAt(0);
14215 var newValue = r.data[this.displayField];
14216 var len = newValue.length;
14217 var selStart = this.getRawValue().length;
14219 if(selStart != len){
14220 this.setRawValue(newValue);
14221 this.selectText(selStart, newValue.length);
14227 onSelect : function(record, index){
14229 if(this.fireEvent('beforeselect', this, record, index) !== false){
14231 this.setFromData(index > -1 ? record.data : false);
14234 this.fireEvent('select', this, record, index);
14239 * Returns the currently selected field value or empty string if no value is set.
14240 * @return {String} value The selected value
14242 getValue : function()
14244 if(Roo.isIOS && this.useNativeIOS){
14245 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14249 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14252 if(this.valueField){
14253 return typeof this.value != 'undefined' ? this.value : '';
14255 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14259 getRawValue : function()
14261 if(Roo.isIOS && this.useNativeIOS){
14262 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14265 var v = this.inputEl().getValue();
14271 * Clears any text/value currently set in the field
14273 clearValue : function(){
14275 if(this.hiddenField){
14276 this.hiddenField.dom.value = '';
14279 this.setRawValue('');
14280 this.lastSelectionText = '';
14281 this.lastData = false;
14283 var close = this.closeTriggerEl();
14294 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14295 * will be displayed in the field. If the value does not match the data value of an existing item,
14296 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14297 * Otherwise the field will be blank (although the value will still be set).
14298 * @param {String} value The value to match
14300 setValue : function(v)
14302 if(Roo.isIOS && this.useNativeIOS){
14303 this.setIOSValue(v);
14313 if(this.valueField){
14314 var r = this.findRecord(this.valueField, v);
14316 text = r.data[this.displayField];
14317 }else if(this.valueNotFoundText !== undefined){
14318 text = this.valueNotFoundText;
14321 this.lastSelectionText = text;
14322 if(this.hiddenField){
14323 this.hiddenField.dom.value = v;
14325 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14328 var close = this.closeTriggerEl();
14331 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14337 * @property {Object} the last set data for the element
14342 * Sets the value of the field based on a object which is related to the record format for the store.
14343 * @param {Object} value the value to set as. or false on reset?
14345 setFromData : function(o){
14352 var dv = ''; // display value
14353 var vv = ''; // value value..
14355 if (this.displayField) {
14356 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14358 // this is an error condition!!!
14359 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14362 if(this.valueField){
14363 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14366 var close = this.closeTriggerEl();
14369 if(dv.length || vv * 1 > 0){
14371 this.blockFocus=true;
14377 if(this.hiddenField){
14378 this.hiddenField.dom.value = vv;
14380 this.lastSelectionText = dv;
14381 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14385 // no hidden field.. - we store the value in 'value', but still display
14386 // display field!!!!
14387 this.lastSelectionText = dv;
14388 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14395 reset : function(){
14396 // overridden so that last data is reset..
14403 this.setValue(this.originalValue);
14404 //this.clearInvalid();
14405 this.lastData = false;
14407 this.view.clearSelections();
14413 findRecord : function(prop, value){
14415 if(this.store.getCount() > 0){
14416 this.store.each(function(r){
14417 if(r.data[prop] == value){
14427 getName: function()
14429 // returns hidden if it's set..
14430 if (!this.rendered) {return ''};
14431 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14435 onViewMove : function(e, t){
14436 this.inKeyMode = false;
14440 onViewOver : function(e, t){
14441 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14444 var item = this.view.findItemFromChild(t);
14447 var index = this.view.indexOf(item);
14448 this.select(index, false);
14453 onViewClick : function(view, doFocus, el, e)
14455 var index = this.view.getSelectedIndexes()[0];
14457 var r = this.store.getAt(index);
14461 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14468 Roo.each(this.tickItems, function(v,k){
14470 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14472 _this.tickItems.splice(k, 1);
14474 if(typeof(e) == 'undefined' && view == false){
14475 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14487 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14488 this.tickItems.push(r.data);
14491 if(typeof(e) == 'undefined' && view == false){
14492 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14499 this.onSelect(r, index);
14501 if(doFocus !== false && !this.blockFocus){
14502 this.inputEl().focus();
14507 restrictHeight : function(){
14508 //this.innerList.dom.style.height = '';
14509 //var inner = this.innerList.dom;
14510 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14511 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14512 //this.list.beginUpdate();
14513 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14514 this.list.alignTo(this.inputEl(), this.listAlign);
14515 this.list.alignTo(this.inputEl(), this.listAlign);
14516 //this.list.endUpdate();
14520 onEmptyResults : function(){
14522 if(this.tickable && this.editable){
14523 this.hasFocus = false;
14524 this.restrictHeight();
14532 * Returns true if the dropdown list is expanded, else false.
14534 isExpanded : function(){
14535 return this.list.isVisible();
14539 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14540 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14541 * @param {String} value The data value of the item to select
14542 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14543 * selected item if it is not currently in view (defaults to true)
14544 * @return {Boolean} True if the value matched an item in the list, else false
14546 selectByValue : function(v, scrollIntoView){
14547 if(v !== undefined && v !== null){
14548 var r = this.findRecord(this.valueField || this.displayField, v);
14550 this.select(this.store.indexOf(r), scrollIntoView);
14558 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14559 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14560 * @param {Number} index The zero-based index of the list item to select
14561 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14562 * selected item if it is not currently in view (defaults to true)
14564 select : function(index, scrollIntoView){
14565 this.selectedIndex = index;
14566 this.view.select(index);
14567 if(scrollIntoView !== false){
14568 var el = this.view.getNode(index);
14570 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14573 this.list.scrollChildIntoView(el, false);
14579 selectNext : function(){
14580 var ct = this.store.getCount();
14582 if(this.selectedIndex == -1){
14584 }else if(this.selectedIndex < ct-1){
14585 this.select(this.selectedIndex+1);
14591 selectPrev : function(){
14592 var ct = this.store.getCount();
14594 if(this.selectedIndex == -1){
14596 }else if(this.selectedIndex != 0){
14597 this.select(this.selectedIndex-1);
14603 onKeyUp : function(e){
14604 if(this.editable !== false && !e.isSpecialKey()){
14605 this.lastKey = e.getKey();
14606 this.dqTask.delay(this.queryDelay);
14611 validateBlur : function(){
14612 return !this.list || !this.list.isVisible();
14616 initQuery : function(){
14618 var v = this.getRawValue();
14620 if(this.tickable && this.editable){
14621 v = this.tickableInputEl().getValue();
14628 doForce : function(){
14629 if(this.inputEl().dom.value.length > 0){
14630 this.inputEl().dom.value =
14631 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14637 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14638 * query allowing the query action to be canceled if needed.
14639 * @param {String} query The SQL query to execute
14640 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14641 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14642 * saved in the current store (defaults to false)
14644 doQuery : function(q, forceAll){
14646 if(q === undefined || q === null){
14651 forceAll: forceAll,
14655 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14660 forceAll = qe.forceAll;
14661 if(forceAll === true || (q.length >= this.minChars)){
14663 this.hasQuery = true;
14665 if(this.lastQuery != q || this.alwaysQuery){
14666 this.lastQuery = q;
14667 if(this.mode == 'local'){
14668 this.selectedIndex = -1;
14670 this.store.clearFilter();
14673 if(this.specialFilter){
14674 this.fireEvent('specialfilter', this);
14679 this.store.filter(this.displayField, q);
14682 this.store.fireEvent("datachanged", this.store);
14689 this.store.baseParams[this.queryParam] = q;
14691 var options = {params : this.getParams(q)};
14694 options.add = true;
14695 options.params.start = this.page * this.pageSize;
14698 this.store.load(options);
14701 * this code will make the page width larger, at the beginning, the list not align correctly,
14702 * we should expand the list on onLoad
14703 * so command out it
14708 this.selectedIndex = -1;
14713 this.loadNext = false;
14717 getParams : function(q){
14719 //p[this.queryParam] = q;
14723 p.limit = this.pageSize;
14729 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14731 collapse : function(){
14732 if(!this.isExpanded()){
14738 this.hasFocus = false;
14742 this.cancelBtn.hide();
14743 this.trigger.show();
14746 this.tickableInputEl().dom.value = '';
14747 this.tickableInputEl().blur();
14752 Roo.get(document).un('mousedown', this.collapseIf, this);
14753 Roo.get(document).un('mousewheel', this.collapseIf, this);
14754 if (!this.editable) {
14755 Roo.get(document).un('keydown', this.listKeyPress, this);
14757 this.fireEvent('collapse', this);
14763 collapseIf : function(e){
14764 var in_combo = e.within(this.el);
14765 var in_list = e.within(this.list);
14766 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14768 if (in_combo || in_list || is_list) {
14769 //e.stopPropagation();
14774 this.onTickableFooterButtonClick(e, false, false);
14782 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14784 expand : function(){
14786 if(this.isExpanded() || !this.hasFocus){
14790 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14791 this.list.setWidth(lw);
14797 this.restrictHeight();
14801 this.tickItems = Roo.apply([], this.item);
14804 this.cancelBtn.show();
14805 this.trigger.hide();
14808 this.tickableInputEl().focus();
14813 Roo.get(document).on('mousedown', this.collapseIf, this);
14814 Roo.get(document).on('mousewheel', this.collapseIf, this);
14815 if (!this.editable) {
14816 Roo.get(document).on('keydown', this.listKeyPress, this);
14819 this.fireEvent('expand', this);
14823 // Implements the default empty TriggerField.onTriggerClick function
14824 onTriggerClick : function(e)
14826 Roo.log('trigger click');
14828 if(this.disabled || !this.triggerList){
14833 this.loadNext = false;
14835 if(this.isExpanded()){
14837 if (!this.blockFocus) {
14838 this.inputEl().focus();
14842 this.hasFocus = true;
14843 if(this.triggerAction == 'all') {
14844 this.doQuery(this.allQuery, true);
14846 this.doQuery(this.getRawValue());
14848 if (!this.blockFocus) {
14849 this.inputEl().focus();
14854 onTickableTriggerClick : function(e)
14861 this.loadNext = false;
14862 this.hasFocus = true;
14864 if(this.triggerAction == 'all') {
14865 this.doQuery(this.allQuery, true);
14867 this.doQuery(this.getRawValue());
14871 onSearchFieldClick : function(e)
14873 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14874 this.onTickableFooterButtonClick(e, false, false);
14878 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14883 this.loadNext = false;
14884 this.hasFocus = true;
14886 if(this.triggerAction == 'all') {
14887 this.doQuery(this.allQuery, true);
14889 this.doQuery(this.getRawValue());
14893 listKeyPress : function(e)
14895 //Roo.log('listkeypress');
14896 // scroll to first matching element based on key pres..
14897 if (e.isSpecialKey()) {
14900 var k = String.fromCharCode(e.getKey()).toUpperCase();
14903 var csel = this.view.getSelectedNodes();
14904 var cselitem = false;
14906 var ix = this.view.indexOf(csel[0]);
14907 cselitem = this.store.getAt(ix);
14908 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14914 this.store.each(function(v) {
14916 // start at existing selection.
14917 if (cselitem.id == v.id) {
14923 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14924 match = this.store.indexOf(v);
14930 if (match === false) {
14931 return true; // no more action?
14934 this.view.select(match);
14935 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14936 sn.scrollIntoView(sn.dom.parentNode, false);
14939 onViewScroll : function(e, t){
14941 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){
14945 this.hasQuery = true;
14947 this.loading = this.list.select('.loading', true).first();
14949 if(this.loading === null){
14950 this.list.createChild({
14952 cls: 'loading roo-select2-more-results roo-select2-active',
14953 html: 'Loading more results...'
14956 this.loading = this.list.select('.loading', true).first();
14958 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14960 this.loading.hide();
14963 this.loading.show();
14968 this.loadNext = true;
14970 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14975 addItem : function(o)
14977 var dv = ''; // display value
14979 if (this.displayField) {
14980 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14982 // this is an error condition!!!
14983 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14990 var choice = this.choices.createChild({
14992 cls: 'roo-select2-search-choice',
15001 cls: 'roo-select2-search-choice-close fa fa-times',
15006 }, this.searchField);
15008 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15010 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15018 this.inputEl().dom.value = '';
15023 onRemoveItem : function(e, _self, o)
15025 e.preventDefault();
15027 this.lastItem = Roo.apply([], this.item);
15029 var index = this.item.indexOf(o.data) * 1;
15032 Roo.log('not this item?!');
15036 this.item.splice(index, 1);
15041 this.fireEvent('remove', this, e);
15047 syncValue : function()
15049 if(!this.item.length){
15056 Roo.each(this.item, function(i){
15057 if(_this.valueField){
15058 value.push(i[_this.valueField]);
15065 this.value = value.join(',');
15067 if(this.hiddenField){
15068 this.hiddenField.dom.value = this.value;
15071 this.store.fireEvent("datachanged", this.store);
15076 clearItem : function()
15078 if(!this.multiple){
15084 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15092 if(this.tickable && !Roo.isTouch){
15093 this.view.refresh();
15097 inputEl: function ()
15099 if(Roo.isIOS && this.useNativeIOS){
15100 return this.el.select('select.roo-ios-select', true).first();
15103 if(Roo.isTouch && this.mobileTouchView){
15104 return this.el.select('input.form-control',true).first();
15108 return this.searchField;
15111 return this.el.select('input.form-control',true).first();
15114 onTickableFooterButtonClick : function(e, btn, el)
15116 e.preventDefault();
15118 this.lastItem = Roo.apply([], this.item);
15120 if(btn && btn.name == 'cancel'){
15121 this.tickItems = Roo.apply([], this.item);
15130 Roo.each(this.tickItems, function(o){
15138 validate : function()
15140 if(this.getVisibilityEl().hasClass('hidden')){
15144 var v = this.getRawValue();
15147 v = this.getValue();
15150 if(this.disabled || this.allowBlank || v.length){
15155 this.markInvalid();
15159 tickableInputEl : function()
15161 if(!this.tickable || !this.editable){
15162 return this.inputEl();
15165 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15169 getAutoCreateTouchView : function()
15174 cls: 'form-group' //input-group
15180 type : this.inputType,
15181 cls : 'form-control x-combo-noedit',
15182 autocomplete: 'new-password',
15183 placeholder : this.placeholder || '',
15188 input.name = this.name;
15192 input.cls += ' input-' + this.size;
15195 if (this.disabled) {
15196 input.disabled = true;
15207 inputblock.cls += ' input-group';
15209 inputblock.cn.unshift({
15211 cls : 'input-group-addon input-group-prepend input-group-text',
15216 if(this.removable && !this.multiple){
15217 inputblock.cls += ' roo-removable';
15219 inputblock.cn.push({
15222 cls : 'roo-combo-removable-btn close'
15226 if(this.hasFeedback && !this.allowBlank){
15228 inputblock.cls += ' has-feedback';
15230 inputblock.cn.push({
15232 cls: 'glyphicon form-control-feedback'
15239 inputblock.cls += (this.before) ? '' : ' input-group';
15241 inputblock.cn.push({
15243 cls : 'input-group-addon input-group-append input-group-text',
15249 var ibwrap = inputblock;
15254 cls: 'roo-select2-choices',
15258 cls: 'roo-select2-search-field',
15271 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15276 cls: 'form-hidden-field'
15282 if(!this.multiple && this.showToggleBtn){
15289 if (this.caret != false) {
15292 cls: 'fa fa-' + this.caret
15299 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15304 cls: 'combobox-clear',
15318 combobox.cls += ' roo-select2-container-multi';
15321 var align = this.labelAlign || this.parentLabelAlign();
15323 if (align ==='left' && this.fieldLabel.length) {
15328 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15329 tooltip : 'This field is required'
15333 cls : 'control-label col-form-label',
15334 html : this.fieldLabel
15345 var labelCfg = cfg.cn[1];
15346 var contentCfg = cfg.cn[2];
15349 if(this.indicatorpos == 'right'){
15354 cls : 'control-label col-form-label',
15358 html : this.fieldLabel
15362 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15363 tooltip : 'This field is required'
15376 labelCfg = cfg.cn[0];
15377 contentCfg = cfg.cn[1];
15382 if(this.labelWidth > 12){
15383 labelCfg.style = "width: " + this.labelWidth + 'px';
15386 if(this.labelWidth < 13 && this.labelmd == 0){
15387 this.labelmd = this.labelWidth;
15390 if(this.labellg > 0){
15391 labelCfg.cls += ' col-lg-' + this.labellg;
15392 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15395 if(this.labelmd > 0){
15396 labelCfg.cls += ' col-md-' + this.labelmd;
15397 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15400 if(this.labelsm > 0){
15401 labelCfg.cls += ' col-sm-' + this.labelsm;
15402 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15405 if(this.labelxs > 0){
15406 labelCfg.cls += ' col-xs-' + this.labelxs;
15407 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15411 } else if ( this.fieldLabel.length) {
15415 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15416 tooltip : 'This field is required'
15420 cls : 'control-label',
15421 html : this.fieldLabel
15432 if(this.indicatorpos == 'right'){
15436 cls : 'control-label',
15437 html : this.fieldLabel,
15441 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15442 tooltip : 'This field is required'
15459 var settings = this;
15461 ['xs','sm','md','lg'].map(function(size){
15462 if (settings[size]) {
15463 cfg.cls += ' col-' + size + '-' + settings[size];
15470 initTouchView : function()
15472 this.renderTouchView();
15474 this.touchViewEl.on('scroll', function(){
15475 this.el.dom.scrollTop = 0;
15478 this.originalValue = this.getValue();
15480 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15482 this.inputEl().on("click", this.showTouchView, this);
15483 if (this.triggerEl) {
15484 this.triggerEl.on("click", this.showTouchView, this);
15488 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15489 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15491 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15493 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15494 this.store.on('load', this.onTouchViewLoad, this);
15495 this.store.on('loadexception', this.onTouchViewLoadException, this);
15497 if(this.hiddenName){
15499 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15501 this.hiddenField.dom.value =
15502 this.hiddenValue !== undefined ? this.hiddenValue :
15503 this.value !== undefined ? this.value : '';
15505 this.el.dom.removeAttribute('name');
15506 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15510 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15511 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15514 if(this.removable && !this.multiple){
15515 var close = this.closeTriggerEl();
15517 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15518 close.on('click', this.removeBtnClick, this, close);
15522 * fix the bug in Safari iOS8
15524 this.inputEl().on("focus", function(e){
15525 document.activeElement.blur();
15528 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15535 renderTouchView : function()
15537 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15538 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15540 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15541 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15543 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15544 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15545 this.touchViewBodyEl.setStyle('overflow', 'auto');
15547 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15548 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15550 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15551 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15555 showTouchView : function()
15561 this.touchViewHeaderEl.hide();
15563 if(this.modalTitle.length){
15564 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15565 this.touchViewHeaderEl.show();
15568 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15569 this.touchViewEl.show();
15571 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15573 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15574 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15576 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15578 if(this.modalTitle.length){
15579 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15582 this.touchViewBodyEl.setHeight(bodyHeight);
15586 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15588 this.touchViewEl.addClass('in');
15591 if(this._touchViewMask){
15592 Roo.get(document.body).addClass("x-body-masked");
15593 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15594 this._touchViewMask.setStyle('z-index', 10000);
15595 this._touchViewMask.addClass('show');
15598 this.doTouchViewQuery();
15602 hideTouchView : function()
15604 this.touchViewEl.removeClass('in');
15608 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15610 this.touchViewEl.setStyle('display', 'none');
15613 if(this._touchViewMask){
15614 this._touchViewMask.removeClass('show');
15615 Roo.get(document.body).removeClass("x-body-masked");
15619 setTouchViewValue : function()
15626 Roo.each(this.tickItems, function(o){
15631 this.hideTouchView();
15634 doTouchViewQuery : function()
15643 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15647 if(!this.alwaysQuery || this.mode == 'local'){
15648 this.onTouchViewLoad();
15655 onTouchViewBeforeLoad : function(combo,opts)
15661 onTouchViewLoad : function()
15663 if(this.store.getCount() < 1){
15664 this.onTouchViewEmptyResults();
15668 this.clearTouchView();
15670 var rawValue = this.getRawValue();
15672 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15674 this.tickItems = [];
15676 this.store.data.each(function(d, rowIndex){
15677 var row = this.touchViewListGroup.createChild(template);
15679 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15680 row.addClass(d.data.cls);
15683 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15686 html : d.data[this.displayField]
15689 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15690 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15693 row.removeClass('selected');
15694 if(!this.multiple && this.valueField &&
15695 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15698 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15699 row.addClass('selected');
15702 if(this.multiple && this.valueField &&
15703 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15707 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15708 this.tickItems.push(d.data);
15711 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15715 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15717 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15719 if(this.modalTitle.length){
15720 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15723 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15725 if(this.mobile_restrict_height && listHeight < bodyHeight){
15726 this.touchViewBodyEl.setHeight(listHeight);
15731 if(firstChecked && listHeight > bodyHeight){
15732 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15737 onTouchViewLoadException : function()
15739 this.hideTouchView();
15742 onTouchViewEmptyResults : function()
15744 this.clearTouchView();
15746 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15748 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15752 clearTouchView : function()
15754 this.touchViewListGroup.dom.innerHTML = '';
15757 onTouchViewClick : function(e, el, o)
15759 e.preventDefault();
15762 var rowIndex = o.rowIndex;
15764 var r = this.store.getAt(rowIndex);
15766 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15768 if(!this.multiple){
15769 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15770 c.dom.removeAttribute('checked');
15773 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15775 this.setFromData(r.data);
15777 var close = this.closeTriggerEl();
15783 this.hideTouchView();
15785 this.fireEvent('select', this, r, rowIndex);
15790 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15791 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15792 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15796 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15797 this.addItem(r.data);
15798 this.tickItems.push(r.data);
15802 getAutoCreateNativeIOS : function()
15805 cls: 'form-group' //input-group,
15810 cls : 'roo-ios-select'
15814 combobox.name = this.name;
15817 if (this.disabled) {
15818 combobox.disabled = true;
15821 var settings = this;
15823 ['xs','sm','md','lg'].map(function(size){
15824 if (settings[size]) {
15825 cfg.cls += ' col-' + size + '-' + settings[size];
15835 initIOSView : function()
15837 this.store.on('load', this.onIOSViewLoad, this);
15842 onIOSViewLoad : function()
15844 if(this.store.getCount() < 1){
15848 this.clearIOSView();
15850 if(this.allowBlank) {
15852 var default_text = '-- SELECT --';
15854 if(this.placeholder.length){
15855 default_text = this.placeholder;
15858 if(this.emptyTitle.length){
15859 default_text += ' - ' + this.emptyTitle + ' -';
15862 var opt = this.inputEl().createChild({
15865 html : default_text
15869 o[this.valueField] = 0;
15870 o[this.displayField] = default_text;
15872 this.ios_options.push({
15879 this.store.data.each(function(d, rowIndex){
15883 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15884 html = d.data[this.displayField];
15889 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15890 value = d.data[this.valueField];
15899 if(this.value == d.data[this.valueField]){
15900 option['selected'] = true;
15903 var opt = this.inputEl().createChild(option);
15905 this.ios_options.push({
15912 this.inputEl().on('change', function(){
15913 this.fireEvent('select', this);
15918 clearIOSView: function()
15920 this.inputEl().dom.innerHTML = '';
15922 this.ios_options = [];
15925 setIOSValue: function(v)
15929 if(!this.ios_options){
15933 Roo.each(this.ios_options, function(opts){
15935 opts.el.dom.removeAttribute('selected');
15937 if(opts.data[this.valueField] != v){
15941 opts.el.dom.setAttribute('selected', true);
15947 * @cfg {Boolean} grow
15951 * @cfg {Number} growMin
15955 * @cfg {Number} growMax
15964 Roo.apply(Roo.bootstrap.ComboBox, {
15968 cls: 'modal-header',
15990 cls: 'list-group-item',
15994 cls: 'roo-combobox-list-group-item-value'
15998 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16012 listItemCheckbox : {
16014 cls: 'list-group-item',
16018 cls: 'roo-combobox-list-group-item-value'
16022 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16038 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16043 cls: 'modal-footer',
16051 cls: 'col-xs-6 text-left',
16054 cls: 'btn btn-danger roo-touch-view-cancel',
16060 cls: 'col-xs-6 text-right',
16063 cls: 'btn btn-success roo-touch-view-ok',
16074 Roo.apply(Roo.bootstrap.ComboBox, {
16076 touchViewTemplate : {
16078 cls: 'modal fade roo-combobox-touch-view',
16082 cls: 'modal-dialog',
16083 style : 'position:fixed', // we have to fix position....
16087 cls: 'modal-content',
16089 Roo.bootstrap.ComboBox.header,
16090 Roo.bootstrap.ComboBox.body,
16091 Roo.bootstrap.ComboBox.footer
16100 * Ext JS Library 1.1.1
16101 * Copyright(c) 2006-2007, Ext JS, LLC.
16103 * Originally Released Under LGPL - original licence link has changed is not relivant.
16106 * <script type="text/javascript">
16111 * @extends Roo.util.Observable
16112 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16113 * This class also supports single and multi selection modes. <br>
16114 * Create a data model bound view:
16116 var store = new Roo.data.Store(...);
16118 var view = new Roo.View({
16120 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16122 singleSelect: true,
16123 selectedClass: "ydataview-selected",
16127 // listen for node click?
16128 view.on("click", function(vw, index, node, e){
16129 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16133 dataModel.load("foobar.xml");
16135 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16137 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16138 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16140 * Note: old style constructor is still suported (container, template, config)
16143 * Create a new View
16144 * @param {Object} config The config object
16147 Roo.View = function(config, depreciated_tpl, depreciated_config){
16149 this.parent = false;
16151 if (typeof(depreciated_tpl) == 'undefined') {
16152 // new way.. - universal constructor.
16153 Roo.apply(this, config);
16154 this.el = Roo.get(this.el);
16157 this.el = Roo.get(config);
16158 this.tpl = depreciated_tpl;
16159 Roo.apply(this, depreciated_config);
16161 this.wrapEl = this.el.wrap().wrap();
16162 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16165 if(typeof(this.tpl) == "string"){
16166 this.tpl = new Roo.Template(this.tpl);
16168 // support xtype ctors..
16169 this.tpl = new Roo.factory(this.tpl, Roo);
16173 this.tpl.compile();
16178 * @event beforeclick
16179 * Fires before a click is processed. Returns false to cancel the default action.
16180 * @param {Roo.View} this
16181 * @param {Number} index The index of the target node
16182 * @param {HTMLElement} node The target node
16183 * @param {Roo.EventObject} e The raw event object
16185 "beforeclick" : true,
16188 * Fires when a template node is clicked.
16189 * @param {Roo.View} this
16190 * @param {Number} index The index of the target node
16191 * @param {HTMLElement} node The target node
16192 * @param {Roo.EventObject} e The raw event object
16197 * Fires when a template node is double clicked.
16198 * @param {Roo.View} this
16199 * @param {Number} index The index of the target node
16200 * @param {HTMLElement} node The target node
16201 * @param {Roo.EventObject} e The raw event object
16205 * @event contextmenu
16206 * Fires when a template node is right clicked.
16207 * @param {Roo.View} this
16208 * @param {Number} index The index of the target node
16209 * @param {HTMLElement} node The target node
16210 * @param {Roo.EventObject} e The raw event object
16212 "contextmenu" : true,
16214 * @event selectionchange
16215 * Fires when the selected nodes change.
16216 * @param {Roo.View} this
16217 * @param {Array} selections Array of the selected nodes
16219 "selectionchange" : true,
16222 * @event beforeselect
16223 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16224 * @param {Roo.View} this
16225 * @param {HTMLElement} node The node to be selected
16226 * @param {Array} selections Array of currently selected nodes
16228 "beforeselect" : true,
16230 * @event preparedata
16231 * Fires on every row to render, to allow you to change the data.
16232 * @param {Roo.View} this
16233 * @param {Object} data to be rendered (change this)
16235 "preparedata" : true
16243 "click": this.onClick,
16244 "dblclick": this.onDblClick,
16245 "contextmenu": this.onContextMenu,
16249 this.selections = [];
16251 this.cmp = new Roo.CompositeElementLite([]);
16253 this.store = Roo.factory(this.store, Roo.data);
16254 this.setStore(this.store, true);
16257 if ( this.footer && this.footer.xtype) {
16259 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16261 this.footer.dataSource = this.store;
16262 this.footer.container = fctr;
16263 this.footer = Roo.factory(this.footer, Roo);
16264 fctr.insertFirst(this.el);
16266 // this is a bit insane - as the paging toolbar seems to detach the el..
16267 // dom.parentNode.parentNode.parentNode
16268 // they get detached?
16272 Roo.View.superclass.constructor.call(this);
16277 Roo.extend(Roo.View, Roo.util.Observable, {
16280 * @cfg {Roo.data.Store} store Data store to load data from.
16285 * @cfg {String|Roo.Element} el The container element.
16290 * @cfg {String|Roo.Template} tpl The template used by this View
16294 * @cfg {String} dataName the named area of the template to use as the data area
16295 * Works with domtemplates roo-name="name"
16299 * @cfg {String} selectedClass The css class to add to selected nodes
16301 selectedClass : "x-view-selected",
16303 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16308 * @cfg {String} text to display on mask (default Loading)
16312 * @cfg {Boolean} multiSelect Allow multiple selection
16314 multiSelect : false,
16316 * @cfg {Boolean} singleSelect Allow single selection
16318 singleSelect: false,
16321 * @cfg {Boolean} toggleSelect - selecting
16323 toggleSelect : false,
16326 * @cfg {Boolean} tickable - selecting
16331 * Returns the element this view is bound to.
16332 * @return {Roo.Element}
16334 getEl : function(){
16335 return this.wrapEl;
16341 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16343 refresh : function(){
16344 //Roo.log('refresh');
16347 // if we are using something like 'domtemplate', then
16348 // the what gets used is:
16349 // t.applySubtemplate(NAME, data, wrapping data..)
16350 // the outer template then get' applied with
16351 // the store 'extra data'
16352 // and the body get's added to the
16353 // roo-name="data" node?
16354 // <span class='roo-tpl-{name}'></span> ?????
16358 this.clearSelections();
16359 this.el.update("");
16361 var records = this.store.getRange();
16362 if(records.length < 1) {
16364 // is this valid?? = should it render a template??
16366 this.el.update(this.emptyText);
16370 if (this.dataName) {
16371 this.el.update(t.apply(this.store.meta)); //????
16372 el = this.el.child('.roo-tpl-' + this.dataName);
16375 for(var i = 0, len = records.length; i < len; i++){
16376 var data = this.prepareData(records[i].data, i, records[i]);
16377 this.fireEvent("preparedata", this, data, i, records[i]);
16379 var d = Roo.apply({}, data);
16382 Roo.apply(d, {'roo-id' : Roo.id()});
16386 Roo.each(this.parent.item, function(item){
16387 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16390 Roo.apply(d, {'roo-data-checked' : 'checked'});
16394 html[html.length] = Roo.util.Format.trim(
16396 t.applySubtemplate(this.dataName, d, this.store.meta) :
16403 el.update(html.join(""));
16404 this.nodes = el.dom.childNodes;
16405 this.updateIndexes(0);
16410 * Function to override to reformat the data that is sent to
16411 * the template for each node.
16412 * DEPRICATED - use the preparedata event handler.
16413 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16414 * a JSON object for an UpdateManager bound view).
16416 prepareData : function(data, index, record)
16418 this.fireEvent("preparedata", this, data, index, record);
16422 onUpdate : function(ds, record){
16423 // Roo.log('on update');
16424 this.clearSelections();
16425 var index = this.store.indexOf(record);
16426 var n = this.nodes[index];
16427 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16428 n.parentNode.removeChild(n);
16429 this.updateIndexes(index, index);
16435 onAdd : function(ds, records, index)
16437 //Roo.log(['on Add', ds, records, index] );
16438 this.clearSelections();
16439 if(this.nodes.length == 0){
16443 var n = this.nodes[index];
16444 for(var i = 0, len = records.length; i < len; i++){
16445 var d = this.prepareData(records[i].data, i, records[i]);
16447 this.tpl.insertBefore(n, d);
16450 this.tpl.append(this.el, d);
16453 this.updateIndexes(index);
16456 onRemove : function(ds, record, index){
16457 // Roo.log('onRemove');
16458 this.clearSelections();
16459 var el = this.dataName ?
16460 this.el.child('.roo-tpl-' + this.dataName) :
16463 el.dom.removeChild(this.nodes[index]);
16464 this.updateIndexes(index);
16468 * Refresh an individual node.
16469 * @param {Number} index
16471 refreshNode : function(index){
16472 this.onUpdate(this.store, this.store.getAt(index));
16475 updateIndexes : function(startIndex, endIndex){
16476 var ns = this.nodes;
16477 startIndex = startIndex || 0;
16478 endIndex = endIndex || ns.length - 1;
16479 for(var i = startIndex; i <= endIndex; i++){
16480 ns[i].nodeIndex = i;
16485 * Changes the data store this view uses and refresh the view.
16486 * @param {Store} store
16488 setStore : function(store, initial){
16489 if(!initial && this.store){
16490 this.store.un("datachanged", this.refresh);
16491 this.store.un("add", this.onAdd);
16492 this.store.un("remove", this.onRemove);
16493 this.store.un("update", this.onUpdate);
16494 this.store.un("clear", this.refresh);
16495 this.store.un("beforeload", this.onBeforeLoad);
16496 this.store.un("load", this.onLoad);
16497 this.store.un("loadexception", this.onLoad);
16501 store.on("datachanged", this.refresh, this);
16502 store.on("add", this.onAdd, this);
16503 store.on("remove", this.onRemove, this);
16504 store.on("update", this.onUpdate, this);
16505 store.on("clear", this.refresh, this);
16506 store.on("beforeload", this.onBeforeLoad, this);
16507 store.on("load", this.onLoad, this);
16508 store.on("loadexception", this.onLoad, this);
16516 * onbeforeLoad - masks the loading area.
16519 onBeforeLoad : function(store,opts)
16521 //Roo.log('onBeforeLoad');
16523 this.el.update("");
16525 this.el.mask(this.mask ? this.mask : "Loading" );
16527 onLoad : function ()
16534 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16535 * @param {HTMLElement} node
16536 * @return {HTMLElement} The template node
16538 findItemFromChild : function(node){
16539 var el = this.dataName ?
16540 this.el.child('.roo-tpl-' + this.dataName,true) :
16543 if(!node || node.parentNode == el){
16546 var p = node.parentNode;
16547 while(p && p != el){
16548 if(p.parentNode == el){
16557 onClick : function(e){
16558 var item = this.findItemFromChild(e.getTarget());
16560 var index = this.indexOf(item);
16561 if(this.onItemClick(item, index, e) !== false){
16562 this.fireEvent("click", this, index, item, e);
16565 this.clearSelections();
16570 onContextMenu : function(e){
16571 var item = this.findItemFromChild(e.getTarget());
16573 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16578 onDblClick : function(e){
16579 var item = this.findItemFromChild(e.getTarget());
16581 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16585 onItemClick : function(item, index, e)
16587 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16590 if (this.toggleSelect) {
16591 var m = this.isSelected(item) ? 'unselect' : 'select';
16594 _t[m](item, true, false);
16597 if(this.multiSelect || this.singleSelect){
16598 if(this.multiSelect && e.shiftKey && this.lastSelection){
16599 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16601 this.select(item, this.multiSelect && e.ctrlKey);
16602 this.lastSelection = item;
16605 if(!this.tickable){
16606 e.preventDefault();
16614 * Get the number of selected nodes.
16617 getSelectionCount : function(){
16618 return this.selections.length;
16622 * Get the currently selected nodes.
16623 * @return {Array} An array of HTMLElements
16625 getSelectedNodes : function(){
16626 return this.selections;
16630 * Get the indexes of the selected nodes.
16633 getSelectedIndexes : function(){
16634 var indexes = [], s = this.selections;
16635 for(var i = 0, len = s.length; i < len; i++){
16636 indexes.push(s[i].nodeIndex);
16642 * Clear all selections
16643 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16645 clearSelections : function(suppressEvent){
16646 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16647 this.cmp.elements = this.selections;
16648 this.cmp.removeClass(this.selectedClass);
16649 this.selections = [];
16650 if(!suppressEvent){
16651 this.fireEvent("selectionchange", this, this.selections);
16657 * Returns true if the passed node is selected
16658 * @param {HTMLElement/Number} node The node or node index
16659 * @return {Boolean}
16661 isSelected : function(node){
16662 var s = this.selections;
16666 node = this.getNode(node);
16667 return s.indexOf(node) !== -1;
16672 * @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
16673 * @param {Boolean} keepExisting (optional) true to keep existing selections
16674 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16676 select : function(nodeInfo, keepExisting, suppressEvent){
16677 if(nodeInfo instanceof Array){
16679 this.clearSelections(true);
16681 for(var i = 0, len = nodeInfo.length; i < len; i++){
16682 this.select(nodeInfo[i], true, true);
16686 var node = this.getNode(nodeInfo);
16687 if(!node || this.isSelected(node)){
16688 return; // already selected.
16691 this.clearSelections(true);
16694 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16695 Roo.fly(node).addClass(this.selectedClass);
16696 this.selections.push(node);
16697 if(!suppressEvent){
16698 this.fireEvent("selectionchange", this, this.selections);
16706 * @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
16707 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16708 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16710 unselect : function(nodeInfo, keepExisting, suppressEvent)
16712 if(nodeInfo instanceof Array){
16713 Roo.each(this.selections, function(s) {
16714 this.unselect(s, nodeInfo);
16718 var node = this.getNode(nodeInfo);
16719 if(!node || !this.isSelected(node)){
16720 //Roo.log("not selected");
16721 return; // not selected.
16725 Roo.each(this.selections, function(s) {
16727 Roo.fly(node).removeClass(this.selectedClass);
16734 this.selections= ns;
16735 this.fireEvent("selectionchange", this, this.selections);
16739 * Gets a template node.
16740 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16741 * @return {HTMLElement} The node or null if it wasn't found
16743 getNode : function(nodeInfo){
16744 if(typeof nodeInfo == "string"){
16745 return document.getElementById(nodeInfo);
16746 }else if(typeof nodeInfo == "number"){
16747 return this.nodes[nodeInfo];
16753 * Gets a range template nodes.
16754 * @param {Number} startIndex
16755 * @param {Number} endIndex
16756 * @return {Array} An array of nodes
16758 getNodes : function(start, end){
16759 var ns = this.nodes;
16760 start = start || 0;
16761 end = typeof end == "undefined" ? ns.length - 1 : end;
16764 for(var i = start; i <= end; i++){
16768 for(var i = start; i >= end; i--){
16776 * Finds the index of the passed node
16777 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16778 * @return {Number} The index of the node or -1
16780 indexOf : function(node){
16781 node = this.getNode(node);
16782 if(typeof node.nodeIndex == "number"){
16783 return node.nodeIndex;
16785 var ns = this.nodes;
16786 for(var i = 0, len = ns.length; i < len; i++){
16797 * based on jquery fullcalendar
16801 Roo.bootstrap = Roo.bootstrap || {};
16803 * @class Roo.bootstrap.Calendar
16804 * @extends Roo.bootstrap.Component
16805 * Bootstrap Calendar class
16806 * @cfg {Boolean} loadMask (true|false) default false
16807 * @cfg {Object} header generate the user specific header of the calendar, default false
16810 * Create a new Container
16811 * @param {Object} config The config object
16816 Roo.bootstrap.Calendar = function(config){
16817 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16821 * Fires when a date is selected
16822 * @param {DatePicker} this
16823 * @param {Date} date The selected date
16827 * @event monthchange
16828 * Fires when the displayed month changes
16829 * @param {DatePicker} this
16830 * @param {Date} date The selected month
16832 'monthchange': true,
16834 * @event evententer
16835 * Fires when mouse over an event
16836 * @param {Calendar} this
16837 * @param {event} Event
16839 'evententer': true,
16841 * @event eventleave
16842 * Fires when the mouse leaves an
16843 * @param {Calendar} this
16846 'eventleave': true,
16848 * @event eventclick
16849 * Fires when the mouse click an
16850 * @param {Calendar} this
16859 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16862 * @cfg {Number} startDay
16863 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16871 getAutoCreate : function(){
16874 var fc_button = function(name, corner, style, content ) {
16875 return Roo.apply({},{
16877 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16879 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16882 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16893 style : 'width:100%',
16900 cls : 'fc-header-left',
16902 fc_button('prev', 'left', 'arrow', '‹' ),
16903 fc_button('next', 'right', 'arrow', '›' ),
16904 { tag: 'span', cls: 'fc-header-space' },
16905 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16913 cls : 'fc-header-center',
16917 cls: 'fc-header-title',
16920 html : 'month / year'
16928 cls : 'fc-header-right',
16930 /* fc_button('month', 'left', '', 'month' ),
16931 fc_button('week', '', '', 'week' ),
16932 fc_button('day', 'right', '', 'day' )
16944 header = this.header;
16947 var cal_heads = function() {
16949 // fixme - handle this.
16951 for (var i =0; i < Date.dayNames.length; i++) {
16952 var d = Date.dayNames[i];
16955 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16956 html : d.substring(0,3)
16960 ret[0].cls += ' fc-first';
16961 ret[6].cls += ' fc-last';
16964 var cal_cell = function(n) {
16967 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16972 cls: 'fc-day-number',
16976 cls: 'fc-day-content',
16980 style: 'position: relative;' // height: 17px;
16992 var cal_rows = function() {
16995 for (var r = 0; r < 6; r++) {
17002 for (var i =0; i < Date.dayNames.length; i++) {
17003 var d = Date.dayNames[i];
17004 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17007 row.cn[0].cls+=' fc-first';
17008 row.cn[0].cn[0].style = 'min-height:90px';
17009 row.cn[6].cls+=' fc-last';
17013 ret[0].cls += ' fc-first';
17014 ret[4].cls += ' fc-prev-last';
17015 ret[5].cls += ' fc-last';
17022 cls: 'fc-border-separate',
17023 style : 'width:100%',
17031 cls : 'fc-first fc-last',
17049 cls : 'fc-content',
17050 style : "position: relative;",
17053 cls : 'fc-view fc-view-month fc-grid',
17054 style : 'position: relative',
17055 unselectable : 'on',
17058 cls : 'fc-event-container',
17059 style : 'position:absolute;z-index:8;top:0;left:0;'
17077 initEvents : function()
17080 throw "can not find store for calendar";
17086 style: "text-align:center",
17090 style: "background-color:white;width:50%;margin:250 auto",
17094 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17105 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17107 var size = this.el.select('.fc-content', true).first().getSize();
17108 this.maskEl.setSize(size.width, size.height);
17109 this.maskEl.enableDisplayMode("block");
17110 if(!this.loadMask){
17111 this.maskEl.hide();
17114 this.store = Roo.factory(this.store, Roo.data);
17115 this.store.on('load', this.onLoad, this);
17116 this.store.on('beforeload', this.onBeforeLoad, this);
17120 this.cells = this.el.select('.fc-day',true);
17121 //Roo.log(this.cells);
17122 this.textNodes = this.el.query('.fc-day-number');
17123 this.cells.addClassOnOver('fc-state-hover');
17125 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17126 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17127 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17128 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17130 this.on('monthchange', this.onMonthChange, this);
17132 this.update(new Date().clearTime());
17135 resize : function() {
17136 var sz = this.el.getSize();
17138 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17139 this.el.select('.fc-day-content div',true).setHeight(34);
17144 showPrevMonth : function(e){
17145 this.update(this.activeDate.add("mo", -1));
17147 showToday : function(e){
17148 this.update(new Date().clearTime());
17151 showNextMonth : function(e){
17152 this.update(this.activeDate.add("mo", 1));
17156 showPrevYear : function(){
17157 this.update(this.activeDate.add("y", -1));
17161 showNextYear : function(){
17162 this.update(this.activeDate.add("y", 1));
17167 update : function(date)
17169 var vd = this.activeDate;
17170 this.activeDate = date;
17171 // if(vd && this.el){
17172 // var t = date.getTime();
17173 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17174 // Roo.log('using add remove');
17176 // this.fireEvent('monthchange', this, date);
17178 // this.cells.removeClass("fc-state-highlight");
17179 // this.cells.each(function(c){
17180 // if(c.dateValue == t){
17181 // c.addClass("fc-state-highlight");
17182 // setTimeout(function(){
17183 // try{c.dom.firstChild.focus();}catch(e){}
17193 var days = date.getDaysInMonth();
17195 var firstOfMonth = date.getFirstDateOfMonth();
17196 var startingPos = firstOfMonth.getDay()-this.startDay;
17198 if(startingPos < this.startDay){
17202 var pm = date.add(Date.MONTH, -1);
17203 var prevStart = pm.getDaysInMonth()-startingPos;
17205 this.cells = this.el.select('.fc-day',true);
17206 this.textNodes = this.el.query('.fc-day-number');
17207 this.cells.addClassOnOver('fc-state-hover');
17209 var cells = this.cells.elements;
17210 var textEls = this.textNodes;
17212 Roo.each(cells, function(cell){
17213 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17216 days += startingPos;
17218 // convert everything to numbers so it's fast
17219 var day = 86400000;
17220 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17223 //Roo.log(prevStart);
17225 var today = new Date().clearTime().getTime();
17226 var sel = date.clearTime().getTime();
17227 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17228 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17229 var ddMatch = this.disabledDatesRE;
17230 var ddText = this.disabledDatesText;
17231 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17232 var ddaysText = this.disabledDaysText;
17233 var format = this.format;
17235 var setCellClass = function(cal, cell){
17239 //Roo.log('set Cell Class');
17241 var t = d.getTime();
17245 cell.dateValue = t;
17247 cell.className += " fc-today";
17248 cell.className += " fc-state-highlight";
17249 cell.title = cal.todayText;
17252 // disable highlight in other month..
17253 //cell.className += " fc-state-highlight";
17258 cell.className = " fc-state-disabled";
17259 cell.title = cal.minText;
17263 cell.className = " fc-state-disabled";
17264 cell.title = cal.maxText;
17268 if(ddays.indexOf(d.getDay()) != -1){
17269 cell.title = ddaysText;
17270 cell.className = " fc-state-disabled";
17273 if(ddMatch && format){
17274 var fvalue = d.dateFormat(format);
17275 if(ddMatch.test(fvalue)){
17276 cell.title = ddText.replace("%0", fvalue);
17277 cell.className = " fc-state-disabled";
17281 if (!cell.initialClassName) {
17282 cell.initialClassName = cell.dom.className;
17285 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17290 for(; i < startingPos; i++) {
17291 textEls[i].innerHTML = (++prevStart);
17292 d.setDate(d.getDate()+1);
17294 cells[i].className = "fc-past fc-other-month";
17295 setCellClass(this, cells[i]);
17300 for(; i < days; i++){
17301 intDay = i - startingPos + 1;
17302 textEls[i].innerHTML = (intDay);
17303 d.setDate(d.getDate()+1);
17305 cells[i].className = ''; // "x-date-active";
17306 setCellClass(this, cells[i]);
17310 for(; i < 42; i++) {
17311 textEls[i].innerHTML = (++extraDays);
17312 d.setDate(d.getDate()+1);
17314 cells[i].className = "fc-future fc-other-month";
17315 setCellClass(this, cells[i]);
17318 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17320 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17322 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17323 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17325 if(totalRows != 6){
17326 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17327 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17330 this.fireEvent('monthchange', this, date);
17334 if(!this.internalRender){
17335 var main = this.el.dom.firstChild;
17336 var w = main.offsetWidth;
17337 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17338 Roo.fly(main).setWidth(w);
17339 this.internalRender = true;
17340 // opera does not respect the auto grow header center column
17341 // then, after it gets a width opera refuses to recalculate
17342 // without a second pass
17343 if(Roo.isOpera && !this.secondPass){
17344 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17345 this.secondPass = true;
17346 this.update.defer(10, this, [date]);
17353 findCell : function(dt) {
17354 dt = dt.clearTime().getTime();
17356 this.cells.each(function(c){
17357 //Roo.log("check " +c.dateValue + '?=' + dt);
17358 if(c.dateValue == dt){
17368 findCells : function(ev) {
17369 var s = ev.start.clone().clearTime().getTime();
17371 var e= ev.end.clone().clearTime().getTime();
17374 this.cells.each(function(c){
17375 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17377 if(c.dateValue > e){
17380 if(c.dateValue < s){
17389 // findBestRow: function(cells)
17393 // for (var i =0 ; i < cells.length;i++) {
17394 // ret = Math.max(cells[i].rows || 0,ret);
17401 addItem : function(ev)
17403 // look for vertical location slot in
17404 var cells = this.findCells(ev);
17406 // ev.row = this.findBestRow(cells);
17408 // work out the location.
17412 for(var i =0; i < cells.length; i++) {
17414 cells[i].row = cells[0].row;
17417 cells[i].row = cells[i].row + 1;
17427 if (crow.start.getY() == cells[i].getY()) {
17429 crow.end = cells[i];
17446 cells[0].events.push(ev);
17448 this.calevents.push(ev);
17451 clearEvents: function() {
17453 if(!this.calevents){
17457 Roo.each(this.cells.elements, function(c){
17463 Roo.each(this.calevents, function(e) {
17464 Roo.each(e.els, function(el) {
17465 el.un('mouseenter' ,this.onEventEnter, this);
17466 el.un('mouseleave' ,this.onEventLeave, this);
17471 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17477 renderEvents: function()
17481 this.cells.each(function(c) {
17490 if(c.row != c.events.length){
17491 r = 4 - (4 - (c.row - c.events.length));
17494 c.events = ev.slice(0, r);
17495 c.more = ev.slice(r);
17497 if(c.more.length && c.more.length == 1){
17498 c.events.push(c.more.pop());
17501 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17505 this.cells.each(function(c) {
17507 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17510 for (var e = 0; e < c.events.length; e++){
17511 var ev = c.events[e];
17512 var rows = ev.rows;
17514 for(var i = 0; i < rows.length; i++) {
17516 // how many rows should it span..
17519 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17520 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17522 unselectable : "on",
17525 cls: 'fc-event-inner',
17529 // cls: 'fc-event-time',
17530 // html : cells.length > 1 ? '' : ev.time
17534 cls: 'fc-event-title',
17535 html : String.format('{0}', ev.title)
17542 cls: 'ui-resizable-handle ui-resizable-e',
17543 html : '  '
17550 cfg.cls += ' fc-event-start';
17552 if ((i+1) == rows.length) {
17553 cfg.cls += ' fc-event-end';
17556 var ctr = _this.el.select('.fc-event-container',true).first();
17557 var cg = ctr.createChild(cfg);
17559 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17560 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17562 var r = (c.more.length) ? 1 : 0;
17563 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17564 cg.setWidth(ebox.right - sbox.x -2);
17566 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17567 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17568 cg.on('click', _this.onEventClick, _this, ev);
17579 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17580 style : 'position: absolute',
17581 unselectable : "on",
17584 cls: 'fc-event-inner',
17588 cls: 'fc-event-title',
17596 cls: 'ui-resizable-handle ui-resizable-e',
17597 html : '  '
17603 var ctr = _this.el.select('.fc-event-container',true).first();
17604 var cg = ctr.createChild(cfg);
17606 var sbox = c.select('.fc-day-content',true).first().getBox();
17607 var ebox = c.select('.fc-day-content',true).first().getBox();
17609 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17610 cg.setWidth(ebox.right - sbox.x -2);
17612 cg.on('click', _this.onMoreEventClick, _this, c.more);
17622 onEventEnter: function (e, el,event,d) {
17623 this.fireEvent('evententer', this, el, event);
17626 onEventLeave: function (e, el,event,d) {
17627 this.fireEvent('eventleave', this, el, event);
17630 onEventClick: function (e, el,event,d) {
17631 this.fireEvent('eventclick', this, el, event);
17634 onMonthChange: function () {
17638 onMoreEventClick: function(e, el, more)
17642 this.calpopover.placement = 'right';
17643 this.calpopover.setTitle('More');
17645 this.calpopover.setContent('');
17647 var ctr = this.calpopover.el.select('.popover-content', true).first();
17649 Roo.each(more, function(m){
17651 cls : 'fc-event-hori fc-event-draggable',
17654 var cg = ctr.createChild(cfg);
17656 cg.on('click', _this.onEventClick, _this, m);
17659 this.calpopover.show(el);
17664 onLoad: function ()
17666 this.calevents = [];
17669 if(this.store.getCount() > 0){
17670 this.store.data.each(function(d){
17673 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17674 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17675 time : d.data.start_time,
17676 title : d.data.title,
17677 description : d.data.description,
17678 venue : d.data.venue
17683 this.renderEvents();
17685 if(this.calevents.length && this.loadMask){
17686 this.maskEl.hide();
17690 onBeforeLoad: function()
17692 this.clearEvents();
17694 this.maskEl.show();
17708 * @class Roo.bootstrap.Popover
17709 * @extends Roo.bootstrap.Component
17710 * Bootstrap Popover class
17711 * @cfg {String} html contents of the popover (or false to use children..)
17712 * @cfg {String} title of popover (or false to hide)
17713 * @cfg {String} placement how it is placed
17714 * @cfg {String} trigger click || hover (or false to trigger manually)
17715 * @cfg {String} over what (parent or false to trigger manually.)
17716 * @cfg {Number} delay - delay before showing
17719 * Create a new Popover
17720 * @param {Object} config The config object
17723 Roo.bootstrap.Popover = function(config){
17724 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17730 * After the popover show
17732 * @param {Roo.bootstrap.Popover} this
17737 * After the popover hide
17739 * @param {Roo.bootstrap.Popover} this
17745 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17747 title: 'Fill in a title',
17750 placement : 'right',
17751 trigger : 'hover', // hover
17757 can_build_overlaid : false,
17759 getChildContainer : function()
17761 return this.el.select('.popover-content',true).first();
17764 getAutoCreate : function(){
17767 cls : 'popover roo-dynamic',
17768 style: 'display:block',
17774 cls : 'popover-inner',
17778 cls: 'popover-title popover-header',
17782 cls : 'popover-content popover-body',
17793 setTitle: function(str)
17796 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17798 setContent: function(str)
17801 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17803 // as it get's added to the bottom of the page.
17804 onRender : function(ct, position)
17806 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17808 var cfg = Roo.apply({}, this.getAutoCreate());
17812 cfg.cls += ' ' + this.cls;
17815 cfg.style = this.style;
17817 //Roo.log("adding to ");
17818 this.el = Roo.get(document.body).createChild(cfg, position);
17819 // Roo.log(this.el);
17824 initEvents : function()
17826 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17827 this.el.enableDisplayMode('block');
17829 if (this.over === false) {
17832 if (this.triggers === false) {
17835 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17836 var triggers = this.trigger ? this.trigger.split(' ') : [];
17837 Roo.each(triggers, function(trigger) {
17839 if (trigger == 'click') {
17840 on_el.on('click', this.toggle, this);
17841 } else if (trigger != 'manual') {
17842 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17843 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17845 on_el.on(eventIn ,this.enter, this);
17846 on_el.on(eventOut, this.leave, this);
17857 toggle : function () {
17858 this.hoverState == 'in' ? this.leave() : this.enter();
17861 enter : function () {
17863 clearTimeout(this.timeout);
17865 this.hoverState = 'in';
17867 if (!this.delay || !this.delay.show) {
17872 this.timeout = setTimeout(function () {
17873 if (_t.hoverState == 'in') {
17876 }, this.delay.show)
17879 leave : function() {
17880 clearTimeout(this.timeout);
17882 this.hoverState = 'out';
17884 if (!this.delay || !this.delay.hide) {
17889 this.timeout = setTimeout(function () {
17890 if (_t.hoverState == 'out') {
17893 }, this.delay.hide)
17896 show : function (on_el)
17899 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17903 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17904 if (this.html !== false) {
17905 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17907 this.el.removeClass([
17908 'fade','top','bottom', 'left', 'right','in',
17909 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17911 if (!this.title.length) {
17912 this.el.select('.popover-title',true).hide();
17915 var placement = typeof this.placement == 'function' ?
17916 this.placement.call(this, this.el, on_el) :
17919 var autoToken = /\s?auto?\s?/i;
17920 var autoPlace = autoToken.test(placement);
17922 placement = placement.replace(autoToken, '') || 'top';
17926 //this.el.setXY([0,0]);
17928 this.el.dom.style.display='block';
17929 this.el.addClass(placement);
17931 //this.el.appendTo(on_el);
17933 var p = this.getPosition();
17934 var box = this.el.getBox();
17939 var align = Roo.bootstrap.Popover.alignment[placement];
17942 this.el.alignTo(on_el, align[0],align[1]);
17943 //var arrow = this.el.select('.arrow',true).first();
17944 //arrow.set(align[2],
17946 this.el.addClass('in');
17949 if (this.el.hasClass('fade')) {
17953 this.hoverState = 'in';
17955 this.fireEvent('show', this);
17960 this.el.setXY([0,0]);
17961 this.el.removeClass('in');
17963 this.hoverState = null;
17965 this.fireEvent('hide', this);
17970 Roo.bootstrap.Popover.alignment = {
17971 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
17972 'right' : ['l-r', [10,0], 'left bs-popover-left'],
17973 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
17974 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
17985 * @class Roo.bootstrap.Progress
17986 * @extends Roo.bootstrap.Component
17987 * Bootstrap Progress class
17988 * @cfg {Boolean} striped striped of the progress bar
17989 * @cfg {Boolean} active animated of the progress bar
17993 * Create a new Progress
17994 * @param {Object} config The config object
17997 Roo.bootstrap.Progress = function(config){
17998 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18001 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18006 getAutoCreate : function(){
18014 cfg.cls += ' progress-striped';
18018 cfg.cls += ' active';
18037 * @class Roo.bootstrap.ProgressBar
18038 * @extends Roo.bootstrap.Component
18039 * Bootstrap ProgressBar class
18040 * @cfg {Number} aria_valuenow aria-value now
18041 * @cfg {Number} aria_valuemin aria-value min
18042 * @cfg {Number} aria_valuemax aria-value max
18043 * @cfg {String} label label for the progress bar
18044 * @cfg {String} panel (success | info | warning | danger )
18045 * @cfg {String} role role of the progress bar
18046 * @cfg {String} sr_only text
18050 * Create a new ProgressBar
18051 * @param {Object} config The config object
18054 Roo.bootstrap.ProgressBar = function(config){
18055 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18058 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18062 aria_valuemax : 100,
18068 getAutoCreate : function()
18073 cls: 'progress-bar',
18074 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18086 cfg.role = this.role;
18089 if(this.aria_valuenow){
18090 cfg['aria-valuenow'] = this.aria_valuenow;
18093 if(this.aria_valuemin){
18094 cfg['aria-valuemin'] = this.aria_valuemin;
18097 if(this.aria_valuemax){
18098 cfg['aria-valuemax'] = this.aria_valuemax;
18101 if(this.label && !this.sr_only){
18102 cfg.html = this.label;
18106 cfg.cls += ' progress-bar-' + this.panel;
18112 update : function(aria_valuenow)
18114 this.aria_valuenow = aria_valuenow;
18116 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18131 * @class Roo.bootstrap.TabGroup
18132 * @extends Roo.bootstrap.Column
18133 * Bootstrap Column class
18134 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18135 * @cfg {Boolean} carousel true to make the group behave like a carousel
18136 * @cfg {Boolean} bullets show bullets for the panels
18137 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18138 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18139 * @cfg {Boolean} showarrow (true|false) show arrow default true
18142 * Create a new TabGroup
18143 * @param {Object} config The config object
18146 Roo.bootstrap.TabGroup = function(config){
18147 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18149 this.navId = Roo.id();
18152 Roo.bootstrap.TabGroup.register(this);
18156 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18159 transition : false,
18164 slideOnTouch : false,
18167 getAutoCreate : function()
18169 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18171 cfg.cls += ' tab-content';
18173 if (this.carousel) {
18174 cfg.cls += ' carousel slide';
18177 cls : 'carousel-inner',
18181 if(this.bullets && !Roo.isTouch){
18184 cls : 'carousel-bullets',
18188 if(this.bullets_cls){
18189 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18196 cfg.cn[0].cn.push(bullets);
18199 if(this.showarrow){
18200 cfg.cn[0].cn.push({
18202 class : 'carousel-arrow',
18206 class : 'carousel-prev',
18210 class : 'fa fa-chevron-left'
18216 class : 'carousel-next',
18220 class : 'fa fa-chevron-right'
18233 initEvents: function()
18235 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18236 // this.el.on("touchstart", this.onTouchStart, this);
18239 if(this.autoslide){
18242 this.slideFn = window.setInterval(function() {
18243 _this.showPanelNext();
18247 if(this.showarrow){
18248 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18249 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18255 // onTouchStart : function(e, el, o)
18257 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18261 // this.showPanelNext();
18265 getChildContainer : function()
18267 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18271 * register a Navigation item
18272 * @param {Roo.bootstrap.NavItem} the navitem to add
18274 register : function(item)
18276 this.tabs.push( item);
18277 item.navId = this.navId; // not really needed..
18282 getActivePanel : function()
18285 Roo.each(this.tabs, function(t) {
18295 getPanelByName : function(n)
18298 Roo.each(this.tabs, function(t) {
18299 if (t.tabId == n) {
18307 indexOfPanel : function(p)
18310 Roo.each(this.tabs, function(t,i) {
18311 if (t.tabId == p.tabId) {
18320 * show a specific panel
18321 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18322 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18324 showPanel : function (pan)
18326 if(this.transition || typeof(pan) == 'undefined'){
18327 Roo.log("waiting for the transitionend");
18331 if (typeof(pan) == 'number') {
18332 pan = this.tabs[pan];
18335 if (typeof(pan) == 'string') {
18336 pan = this.getPanelByName(pan);
18339 var cur = this.getActivePanel();
18342 Roo.log('pan or acitve pan is undefined');
18346 if (pan.tabId == this.getActivePanel().tabId) {
18350 if (false === cur.fireEvent('beforedeactivate')) {
18354 if(this.bullets > 0 && !Roo.isTouch){
18355 this.setActiveBullet(this.indexOfPanel(pan));
18358 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18360 //class="carousel-item carousel-item-next carousel-item-left"
18362 this.transition = true;
18363 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18364 var lr = dir == 'next' ? 'left' : 'right';
18365 pan.el.addClass(dir); // or prev
18366 pan.el.addClass('carousel-item-' + dir); // or prev
18367 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18368 cur.el.addClass(lr); // or right
18369 pan.el.addClass(lr);
18370 cur.el.addClass('carousel-item-' +lr); // or right
18371 pan.el.addClass('carousel-item-' +lr);
18375 cur.el.on('transitionend', function() {
18376 Roo.log("trans end?");
18378 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18379 pan.setActive(true);
18381 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18382 cur.setActive(false);
18384 _this.transition = false;
18386 }, this, { single: true } );
18391 cur.setActive(false);
18392 pan.setActive(true);
18397 showPanelNext : function()
18399 var i = this.indexOfPanel(this.getActivePanel());
18401 if (i >= this.tabs.length - 1 && !this.autoslide) {
18405 if (i >= this.tabs.length - 1 && this.autoslide) {
18409 this.showPanel(this.tabs[i+1]);
18412 showPanelPrev : function()
18414 var i = this.indexOfPanel(this.getActivePanel());
18416 if (i < 1 && !this.autoslide) {
18420 if (i < 1 && this.autoslide) {
18421 i = this.tabs.length;
18424 this.showPanel(this.tabs[i-1]);
18428 addBullet: function()
18430 if(!this.bullets || Roo.isTouch){
18433 var ctr = this.el.select('.carousel-bullets',true).first();
18434 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18435 var bullet = ctr.createChild({
18436 cls : 'bullet bullet-' + i
18437 },ctr.dom.lastChild);
18442 bullet.on('click', (function(e, el, o, ii, t){
18444 e.preventDefault();
18446 this.showPanel(ii);
18448 if(this.autoslide && this.slideFn){
18449 clearInterval(this.slideFn);
18450 this.slideFn = window.setInterval(function() {
18451 _this.showPanelNext();
18455 }).createDelegate(this, [i, bullet], true));
18460 setActiveBullet : function(i)
18466 Roo.each(this.el.select('.bullet', true).elements, function(el){
18467 el.removeClass('selected');
18470 var bullet = this.el.select('.bullet-' + i, true).first();
18476 bullet.addClass('selected');
18487 Roo.apply(Roo.bootstrap.TabGroup, {
18491 * register a Navigation Group
18492 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18494 register : function(navgrp)
18496 this.groups[navgrp.navId] = navgrp;
18500 * fetch a Navigation Group based on the navigation ID
18501 * if one does not exist , it will get created.
18502 * @param {string} the navgroup to add
18503 * @returns {Roo.bootstrap.NavGroup} the navgroup
18505 get: function(navId) {
18506 if (typeof(this.groups[navId]) == 'undefined') {
18507 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18509 return this.groups[navId] ;
18524 * @class Roo.bootstrap.TabPanel
18525 * @extends Roo.bootstrap.Component
18526 * Bootstrap TabPanel class
18527 * @cfg {Boolean} active panel active
18528 * @cfg {String} html panel content
18529 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18530 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18531 * @cfg {String} href click to link..
18535 * Create a new TabPanel
18536 * @param {Object} config The config object
18539 Roo.bootstrap.TabPanel = function(config){
18540 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18544 * Fires when the active status changes
18545 * @param {Roo.bootstrap.TabPanel} this
18546 * @param {Boolean} state the new state
18551 * @event beforedeactivate
18552 * Fires before a tab is de-activated - can be used to do validation on a form.
18553 * @param {Roo.bootstrap.TabPanel} this
18554 * @return {Boolean} false if there is an error
18557 'beforedeactivate': true
18560 this.tabId = this.tabId || Roo.id();
18564 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18572 getAutoCreate : function(){
18575 // item is needed for carousel - not sure if it has any effect otherwise
18576 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18577 html: this.html || ''
18581 cfg.cls += ' active';
18585 cfg.tabId = this.tabId;
18592 initEvents: function()
18594 var p = this.parent();
18596 this.navId = this.navId || p.navId;
18598 if (typeof(this.navId) != 'undefined') {
18599 // not really needed.. but just in case.. parent should be a NavGroup.
18600 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18604 var i = tg.tabs.length - 1;
18606 if(this.active && tg.bullets > 0 && i < tg.bullets){
18607 tg.setActiveBullet(i);
18611 this.el.on('click', this.onClick, this);
18614 this.el.on("touchstart", this.onTouchStart, this);
18615 this.el.on("touchmove", this.onTouchMove, this);
18616 this.el.on("touchend", this.onTouchEnd, this);
18621 onRender : function(ct, position)
18623 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18626 setActive : function(state)
18628 Roo.log("panel - set active " + this.tabId + "=" + state);
18630 this.active = state;
18632 this.el.removeClass('active');
18634 } else if (!this.el.hasClass('active')) {
18635 this.el.addClass('active');
18638 this.fireEvent('changed', this, state);
18641 onClick : function(e)
18643 e.preventDefault();
18645 if(!this.href.length){
18649 window.location.href = this.href;
18658 onTouchStart : function(e)
18660 this.swiping = false;
18662 this.startX = e.browserEvent.touches[0].clientX;
18663 this.startY = e.browserEvent.touches[0].clientY;
18666 onTouchMove : function(e)
18668 this.swiping = true;
18670 this.endX = e.browserEvent.touches[0].clientX;
18671 this.endY = e.browserEvent.touches[0].clientY;
18674 onTouchEnd : function(e)
18681 var tabGroup = this.parent();
18683 if(this.endX > this.startX){ // swiping right
18684 tabGroup.showPanelPrev();
18688 if(this.startX > this.endX){ // swiping left
18689 tabGroup.showPanelNext();
18708 * @class Roo.bootstrap.DateField
18709 * @extends Roo.bootstrap.Input
18710 * Bootstrap DateField class
18711 * @cfg {Number} weekStart default 0
18712 * @cfg {String} viewMode default empty, (months|years)
18713 * @cfg {String} minViewMode default empty, (months|years)
18714 * @cfg {Number} startDate default -Infinity
18715 * @cfg {Number} endDate default Infinity
18716 * @cfg {Boolean} todayHighlight default false
18717 * @cfg {Boolean} todayBtn default false
18718 * @cfg {Boolean} calendarWeeks default false
18719 * @cfg {Object} daysOfWeekDisabled default empty
18720 * @cfg {Boolean} singleMode default false (true | false)
18722 * @cfg {Boolean} keyboardNavigation default true
18723 * @cfg {String} language default en
18726 * Create a new DateField
18727 * @param {Object} config The config object
18730 Roo.bootstrap.DateField = function(config){
18731 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18735 * Fires when this field show.
18736 * @param {Roo.bootstrap.DateField} this
18737 * @param {Mixed} date The date value
18742 * Fires when this field hide.
18743 * @param {Roo.bootstrap.DateField} this
18744 * @param {Mixed} date The date value
18749 * Fires when select a date.
18750 * @param {Roo.bootstrap.DateField} this
18751 * @param {Mixed} date The date value
18755 * @event beforeselect
18756 * Fires when before select a date.
18757 * @param {Roo.bootstrap.DateField} this
18758 * @param {Mixed} date The date value
18760 beforeselect : true
18764 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18767 * @cfg {String} format
18768 * The default date format string which can be overriden for localization support. The format must be
18769 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18773 * @cfg {String} altFormats
18774 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18775 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18777 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18785 todayHighlight : false,
18791 keyboardNavigation: true,
18793 calendarWeeks: false,
18795 startDate: -Infinity,
18799 daysOfWeekDisabled: [],
18803 singleMode : false,
18805 UTCDate: function()
18807 return new Date(Date.UTC.apply(Date, arguments));
18810 UTCToday: function()
18812 var today = new Date();
18813 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18816 getDate: function() {
18817 var d = this.getUTCDate();
18818 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18821 getUTCDate: function() {
18825 setDate: function(d) {
18826 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18829 setUTCDate: function(d) {
18831 this.setValue(this.formatDate(this.date));
18834 onRender: function(ct, position)
18837 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18839 this.language = this.language || 'en';
18840 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18841 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18843 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18844 this.format = this.format || 'm/d/y';
18845 this.isInline = false;
18846 this.isInput = true;
18847 this.component = this.el.select('.add-on', true).first() || false;
18848 this.component = (this.component && this.component.length === 0) ? false : this.component;
18849 this.hasInput = this.component && this.inputEl().length;
18851 if (typeof(this.minViewMode === 'string')) {
18852 switch (this.minViewMode) {
18854 this.minViewMode = 1;
18857 this.minViewMode = 2;
18860 this.minViewMode = 0;
18865 if (typeof(this.viewMode === 'string')) {
18866 switch (this.viewMode) {
18879 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18881 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18883 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18885 this.picker().on('mousedown', this.onMousedown, this);
18886 this.picker().on('click', this.onClick, this);
18888 this.picker().addClass('datepicker-dropdown');
18890 this.startViewMode = this.viewMode;
18892 if(this.singleMode){
18893 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18894 v.setVisibilityMode(Roo.Element.DISPLAY);
18898 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18899 v.setStyle('width', '189px');
18903 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18904 if(!this.calendarWeeks){
18909 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18910 v.attr('colspan', function(i, val){
18911 return parseInt(val) + 1;
18916 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18918 this.setStartDate(this.startDate);
18919 this.setEndDate(this.endDate);
18921 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18928 if(this.isInline) {
18933 picker : function()
18935 return this.pickerEl;
18936 // return this.el.select('.datepicker', true).first();
18939 fillDow: function()
18941 var dowCnt = this.weekStart;
18950 if(this.calendarWeeks){
18958 while (dowCnt < this.weekStart + 7) {
18962 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18966 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18969 fillMonths: function()
18972 var months = this.picker().select('>.datepicker-months td', true).first();
18974 months.dom.innerHTML = '';
18980 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18983 months.createChild(month);
18990 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;
18992 if (this.date < this.startDate) {
18993 this.viewDate = new Date(this.startDate);
18994 } else if (this.date > this.endDate) {
18995 this.viewDate = new Date(this.endDate);
18997 this.viewDate = new Date(this.date);
19005 var d = new Date(this.viewDate),
19006 year = d.getUTCFullYear(),
19007 month = d.getUTCMonth(),
19008 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19009 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19010 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19011 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19012 currentDate = this.date && this.date.valueOf(),
19013 today = this.UTCToday();
19015 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19017 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19019 // this.picker.select('>tfoot th.today').
19020 // .text(dates[this.language].today)
19021 // .toggle(this.todayBtn !== false);
19023 this.updateNavArrows();
19026 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19028 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19030 prevMonth.setUTCDate(day);
19032 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19034 var nextMonth = new Date(prevMonth);
19036 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19038 nextMonth = nextMonth.valueOf();
19040 var fillMonths = false;
19042 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19044 while(prevMonth.valueOf() <= nextMonth) {
19047 if (prevMonth.getUTCDay() === this.weekStart) {
19049 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19057 if(this.calendarWeeks){
19058 // ISO 8601: First week contains first thursday.
19059 // ISO also states week starts on Monday, but we can be more abstract here.
19061 // Start of current week: based on weekstart/current date
19062 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19063 // Thursday of this week
19064 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19065 // First Thursday of year, year from thursday
19066 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19067 // Calendar week: ms between thursdays, div ms per day, div 7 days
19068 calWeek = (th - yth) / 864e5 / 7 + 1;
19070 fillMonths.cn.push({
19078 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19080 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19083 if (this.todayHighlight &&
19084 prevMonth.getUTCFullYear() == today.getFullYear() &&
19085 prevMonth.getUTCMonth() == today.getMonth() &&
19086 prevMonth.getUTCDate() == today.getDate()) {
19087 clsName += ' today';
19090 if (currentDate && prevMonth.valueOf() === currentDate) {
19091 clsName += ' active';
19094 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19095 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19096 clsName += ' disabled';
19099 fillMonths.cn.push({
19101 cls: 'day ' + clsName,
19102 html: prevMonth.getDate()
19105 prevMonth.setDate(prevMonth.getDate()+1);
19108 var currentYear = this.date && this.date.getUTCFullYear();
19109 var currentMonth = this.date && this.date.getUTCMonth();
19111 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19113 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19114 v.removeClass('active');
19116 if(currentYear === year && k === currentMonth){
19117 v.addClass('active');
19120 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19121 v.addClass('disabled');
19127 year = parseInt(year/10, 10) * 10;
19129 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19131 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19134 for (var i = -1; i < 11; i++) {
19135 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19137 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19145 showMode: function(dir)
19148 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19151 Roo.each(this.picker().select('>div',true).elements, function(v){
19152 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19155 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19160 if(this.isInline) {
19164 this.picker().removeClass(['bottom', 'top']);
19166 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19168 * place to the top of element!
19172 this.picker().addClass('top');
19173 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19178 this.picker().addClass('bottom');
19180 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19183 parseDate : function(value)
19185 if(!value || value instanceof Date){
19188 var v = Date.parseDate(value, this.format);
19189 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19190 v = Date.parseDate(value, 'Y-m-d');
19192 if(!v && this.altFormats){
19193 if(!this.altFormatsArray){
19194 this.altFormatsArray = this.altFormats.split("|");
19196 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19197 v = Date.parseDate(value, this.altFormatsArray[i]);
19203 formatDate : function(date, fmt)
19205 return (!date || !(date instanceof Date)) ?
19206 date : date.dateFormat(fmt || this.format);
19209 onFocus : function()
19211 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19215 onBlur : function()
19217 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19219 var d = this.inputEl().getValue();
19226 showPopup : function()
19228 this.picker().show();
19232 this.fireEvent('showpopup', this, this.date);
19235 hidePopup : function()
19237 if(this.isInline) {
19240 this.picker().hide();
19241 this.viewMode = this.startViewMode;
19244 this.fireEvent('hidepopup', this, this.date);
19248 onMousedown: function(e)
19250 e.stopPropagation();
19251 e.preventDefault();
19256 Roo.bootstrap.DateField.superclass.keyup.call(this);
19260 setValue: function(v)
19262 if(this.fireEvent('beforeselect', this, v) !== false){
19263 var d = new Date(this.parseDate(v) ).clearTime();
19265 if(isNaN(d.getTime())){
19266 this.date = this.viewDate = '';
19267 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19271 v = this.formatDate(d);
19273 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19275 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19279 this.fireEvent('select', this, this.date);
19283 getValue: function()
19285 return this.formatDate(this.date);
19288 fireKey: function(e)
19290 if (!this.picker().isVisible()){
19291 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19297 var dateChanged = false,
19299 newDate, newViewDate;
19304 e.preventDefault();
19308 if (!this.keyboardNavigation) {
19311 dir = e.keyCode == 37 ? -1 : 1;
19314 newDate = this.moveYear(this.date, dir);
19315 newViewDate = this.moveYear(this.viewDate, dir);
19316 } else if (e.shiftKey){
19317 newDate = this.moveMonth(this.date, dir);
19318 newViewDate = this.moveMonth(this.viewDate, dir);
19320 newDate = new Date(this.date);
19321 newDate.setUTCDate(this.date.getUTCDate() + dir);
19322 newViewDate = new Date(this.viewDate);
19323 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19325 if (this.dateWithinRange(newDate)){
19326 this.date = newDate;
19327 this.viewDate = newViewDate;
19328 this.setValue(this.formatDate(this.date));
19330 e.preventDefault();
19331 dateChanged = true;
19336 if (!this.keyboardNavigation) {
19339 dir = e.keyCode == 38 ? -1 : 1;
19341 newDate = this.moveYear(this.date, dir);
19342 newViewDate = this.moveYear(this.viewDate, dir);
19343 } else if (e.shiftKey){
19344 newDate = this.moveMonth(this.date, dir);
19345 newViewDate = this.moveMonth(this.viewDate, dir);
19347 newDate = new Date(this.date);
19348 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19349 newViewDate = new Date(this.viewDate);
19350 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19352 if (this.dateWithinRange(newDate)){
19353 this.date = newDate;
19354 this.viewDate = newViewDate;
19355 this.setValue(this.formatDate(this.date));
19357 e.preventDefault();
19358 dateChanged = true;
19362 this.setValue(this.formatDate(this.date));
19364 e.preventDefault();
19367 this.setValue(this.formatDate(this.date));
19381 onClick: function(e)
19383 e.stopPropagation();
19384 e.preventDefault();
19386 var target = e.getTarget();
19388 if(target.nodeName.toLowerCase() === 'i'){
19389 target = Roo.get(target).dom.parentNode;
19392 var nodeName = target.nodeName;
19393 var className = target.className;
19394 var html = target.innerHTML;
19395 //Roo.log(nodeName);
19397 switch(nodeName.toLowerCase()) {
19399 switch(className) {
19405 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19406 switch(this.viewMode){
19408 this.viewDate = this.moveMonth(this.viewDate, dir);
19412 this.viewDate = this.moveYear(this.viewDate, dir);
19418 var date = new Date();
19419 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19421 this.setValue(this.formatDate(this.date));
19428 if (className.indexOf('disabled') < 0) {
19429 this.viewDate.setUTCDate(1);
19430 if (className.indexOf('month') > -1) {
19431 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19433 var year = parseInt(html, 10) || 0;
19434 this.viewDate.setUTCFullYear(year);
19438 if(this.singleMode){
19439 this.setValue(this.formatDate(this.viewDate));
19450 //Roo.log(className);
19451 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19452 var day = parseInt(html, 10) || 1;
19453 var year = this.viewDate.getUTCFullYear(),
19454 month = this.viewDate.getUTCMonth();
19456 if (className.indexOf('old') > -1) {
19463 } else if (className.indexOf('new') > -1) {
19471 //Roo.log([year,month,day]);
19472 this.date = this.UTCDate(year, month, day,0,0,0,0);
19473 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19475 //Roo.log(this.formatDate(this.date));
19476 this.setValue(this.formatDate(this.date));
19483 setStartDate: function(startDate)
19485 this.startDate = startDate || -Infinity;
19486 if (this.startDate !== -Infinity) {
19487 this.startDate = this.parseDate(this.startDate);
19490 this.updateNavArrows();
19493 setEndDate: function(endDate)
19495 this.endDate = endDate || Infinity;
19496 if (this.endDate !== Infinity) {
19497 this.endDate = this.parseDate(this.endDate);
19500 this.updateNavArrows();
19503 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19505 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19506 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19507 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19509 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19510 return parseInt(d, 10);
19513 this.updateNavArrows();
19516 updateNavArrows: function()
19518 if(this.singleMode){
19522 var d = new Date(this.viewDate),
19523 year = d.getUTCFullYear(),
19524 month = d.getUTCMonth();
19526 Roo.each(this.picker().select('.prev', true).elements, function(v){
19528 switch (this.viewMode) {
19531 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19537 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19544 Roo.each(this.picker().select('.next', true).elements, function(v){
19546 switch (this.viewMode) {
19549 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19555 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19563 moveMonth: function(date, dir)
19568 var new_date = new Date(date.valueOf()),
19569 day = new_date.getUTCDate(),
19570 month = new_date.getUTCMonth(),
19571 mag = Math.abs(dir),
19573 dir = dir > 0 ? 1 : -1;
19576 // If going back one month, make sure month is not current month
19577 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19579 return new_date.getUTCMonth() == month;
19581 // If going forward one month, make sure month is as expected
19582 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19584 return new_date.getUTCMonth() != new_month;
19586 new_month = month + dir;
19587 new_date.setUTCMonth(new_month);
19588 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19589 if (new_month < 0 || new_month > 11) {
19590 new_month = (new_month + 12) % 12;
19593 // For magnitudes >1, move one month at a time...
19594 for (var i=0; i<mag; i++) {
19595 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19596 new_date = this.moveMonth(new_date, dir);
19598 // ...then reset the day, keeping it in the new month
19599 new_month = new_date.getUTCMonth();
19600 new_date.setUTCDate(day);
19602 return new_month != new_date.getUTCMonth();
19605 // Common date-resetting loop -- if date is beyond end of month, make it
19608 new_date.setUTCDate(--day);
19609 new_date.setUTCMonth(new_month);
19614 moveYear: function(date, dir)
19616 return this.moveMonth(date, dir*12);
19619 dateWithinRange: function(date)
19621 return date >= this.startDate && date <= this.endDate;
19627 this.picker().remove();
19630 validateValue : function(value)
19632 if(this.getVisibilityEl().hasClass('hidden')){
19636 if(value.length < 1) {
19637 if(this.allowBlank){
19643 if(value.length < this.minLength){
19646 if(value.length > this.maxLength){
19650 var vt = Roo.form.VTypes;
19651 if(!vt[this.vtype](value, this)){
19655 if(typeof this.validator == "function"){
19656 var msg = this.validator(value);
19662 if(this.regex && !this.regex.test(value)){
19666 if(typeof(this.parseDate(value)) == 'undefined'){
19670 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19674 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19684 this.date = this.viewDate = '';
19686 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19691 Roo.apply(Roo.bootstrap.DateField, {
19702 html: '<i class="fa fa-arrow-left"/>'
19712 html: '<i class="fa fa-arrow-right"/>'
19754 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19755 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19756 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19757 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19758 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19771 navFnc: 'FullYear',
19776 navFnc: 'FullYear',
19781 Roo.apply(Roo.bootstrap.DateField, {
19785 cls: 'datepicker dropdown-menu roo-dynamic',
19789 cls: 'datepicker-days',
19793 cls: 'table-condensed',
19795 Roo.bootstrap.DateField.head,
19799 Roo.bootstrap.DateField.footer
19806 cls: 'datepicker-months',
19810 cls: 'table-condensed',
19812 Roo.bootstrap.DateField.head,
19813 Roo.bootstrap.DateField.content,
19814 Roo.bootstrap.DateField.footer
19821 cls: 'datepicker-years',
19825 cls: 'table-condensed',
19827 Roo.bootstrap.DateField.head,
19828 Roo.bootstrap.DateField.content,
19829 Roo.bootstrap.DateField.footer
19848 * @class Roo.bootstrap.TimeField
19849 * @extends Roo.bootstrap.Input
19850 * Bootstrap DateField class
19854 * Create a new TimeField
19855 * @param {Object} config The config object
19858 Roo.bootstrap.TimeField = function(config){
19859 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19863 * Fires when this field show.
19864 * @param {Roo.bootstrap.DateField} thisthis
19865 * @param {Mixed} date The date value
19870 * Fires when this field hide.
19871 * @param {Roo.bootstrap.DateField} this
19872 * @param {Mixed} date The date value
19877 * Fires when select a date.
19878 * @param {Roo.bootstrap.DateField} this
19879 * @param {Mixed} date The date value
19885 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19888 * @cfg {String} format
19889 * The default time format string which can be overriden for localization support. The format must be
19890 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19894 onRender: function(ct, position)
19897 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19899 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19901 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19903 this.pop = this.picker().select('>.datepicker-time',true).first();
19904 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19906 this.picker().on('mousedown', this.onMousedown, this);
19907 this.picker().on('click', this.onClick, this);
19909 this.picker().addClass('datepicker-dropdown');
19914 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19915 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19916 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19917 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19918 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19919 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19923 fireKey: function(e){
19924 if (!this.picker().isVisible()){
19925 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19931 e.preventDefault();
19939 this.onTogglePeriod();
19942 this.onIncrementMinutes();
19945 this.onDecrementMinutes();
19954 onClick: function(e) {
19955 e.stopPropagation();
19956 e.preventDefault();
19959 picker : function()
19961 return this.el.select('.datepicker', true).first();
19964 fillTime: function()
19966 var time = this.pop.select('tbody', true).first();
19968 time.dom.innerHTML = '';
19983 cls: 'hours-up glyphicon glyphicon-chevron-up'
20003 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20024 cls: 'timepicker-hour',
20039 cls: 'timepicker-minute',
20054 cls: 'btn btn-primary period',
20076 cls: 'hours-down glyphicon glyphicon-chevron-down'
20096 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20114 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20121 var hours = this.time.getHours();
20122 var minutes = this.time.getMinutes();
20135 hours = hours - 12;
20139 hours = '0' + hours;
20143 minutes = '0' + minutes;
20146 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20147 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20148 this.pop.select('button', true).first().dom.innerHTML = period;
20154 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20156 var cls = ['bottom'];
20158 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20165 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20170 this.picker().addClass(cls.join('-'));
20174 Roo.each(cls, function(c){
20176 _this.picker().setTop(_this.inputEl().getHeight());
20180 _this.picker().setTop(0 - _this.picker().getHeight());
20185 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20189 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20196 onFocus : function()
20198 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20202 onBlur : function()
20204 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20210 this.picker().show();
20215 this.fireEvent('show', this, this.date);
20220 this.picker().hide();
20223 this.fireEvent('hide', this, this.date);
20226 setTime : function()
20229 this.setValue(this.time.format(this.format));
20231 this.fireEvent('select', this, this.date);
20236 onMousedown: function(e){
20237 e.stopPropagation();
20238 e.preventDefault();
20241 onIncrementHours: function()
20243 Roo.log('onIncrementHours');
20244 this.time = this.time.add(Date.HOUR, 1);
20249 onDecrementHours: function()
20251 Roo.log('onDecrementHours');
20252 this.time = this.time.add(Date.HOUR, -1);
20256 onIncrementMinutes: function()
20258 Roo.log('onIncrementMinutes');
20259 this.time = this.time.add(Date.MINUTE, 1);
20263 onDecrementMinutes: function()
20265 Roo.log('onDecrementMinutes');
20266 this.time = this.time.add(Date.MINUTE, -1);
20270 onTogglePeriod: function()
20272 Roo.log('onTogglePeriod');
20273 this.time = this.time.add(Date.HOUR, 12);
20280 Roo.apply(Roo.bootstrap.TimeField, {
20310 cls: 'btn btn-info ok',
20322 Roo.apply(Roo.bootstrap.TimeField, {
20326 cls: 'datepicker dropdown-menu',
20330 cls: 'datepicker-time',
20334 cls: 'table-condensed',
20336 Roo.bootstrap.TimeField.content,
20337 Roo.bootstrap.TimeField.footer
20356 * @class Roo.bootstrap.MonthField
20357 * @extends Roo.bootstrap.Input
20358 * Bootstrap MonthField class
20360 * @cfg {String} language default en
20363 * Create a new MonthField
20364 * @param {Object} config The config object
20367 Roo.bootstrap.MonthField = function(config){
20368 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20373 * Fires when this field show.
20374 * @param {Roo.bootstrap.MonthField} this
20375 * @param {Mixed} date The date value
20380 * Fires when this field hide.
20381 * @param {Roo.bootstrap.MonthField} this
20382 * @param {Mixed} date The date value
20387 * Fires when select a date.
20388 * @param {Roo.bootstrap.MonthField} this
20389 * @param {String} oldvalue The old value
20390 * @param {String} newvalue The new value
20396 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20398 onRender: function(ct, position)
20401 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20403 this.language = this.language || 'en';
20404 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20405 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20407 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20408 this.isInline = false;
20409 this.isInput = true;
20410 this.component = this.el.select('.add-on', true).first() || false;
20411 this.component = (this.component && this.component.length === 0) ? false : this.component;
20412 this.hasInput = this.component && this.inputEL().length;
20414 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20416 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20418 this.picker().on('mousedown', this.onMousedown, this);
20419 this.picker().on('click', this.onClick, this);
20421 this.picker().addClass('datepicker-dropdown');
20423 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20424 v.setStyle('width', '189px');
20431 if(this.isInline) {
20437 setValue: function(v, suppressEvent)
20439 var o = this.getValue();
20441 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20445 if(suppressEvent !== true){
20446 this.fireEvent('select', this, o, v);
20451 getValue: function()
20456 onClick: function(e)
20458 e.stopPropagation();
20459 e.preventDefault();
20461 var target = e.getTarget();
20463 if(target.nodeName.toLowerCase() === 'i'){
20464 target = Roo.get(target).dom.parentNode;
20467 var nodeName = target.nodeName;
20468 var className = target.className;
20469 var html = target.innerHTML;
20471 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20475 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20477 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20483 picker : function()
20485 return this.pickerEl;
20488 fillMonths: function()
20491 var months = this.picker().select('>.datepicker-months td', true).first();
20493 months.dom.innerHTML = '';
20499 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20502 months.createChild(month);
20511 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20512 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20515 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20516 e.removeClass('active');
20518 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20519 e.addClass('active');
20526 if(this.isInline) {
20530 this.picker().removeClass(['bottom', 'top']);
20532 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20534 * place to the top of element!
20538 this.picker().addClass('top');
20539 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20544 this.picker().addClass('bottom');
20546 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20549 onFocus : function()
20551 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20555 onBlur : function()
20557 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20559 var d = this.inputEl().getValue();
20568 this.picker().show();
20569 this.picker().select('>.datepicker-months', true).first().show();
20573 this.fireEvent('show', this, this.date);
20578 if(this.isInline) {
20581 this.picker().hide();
20582 this.fireEvent('hide', this, this.date);
20586 onMousedown: function(e)
20588 e.stopPropagation();
20589 e.preventDefault();
20594 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20598 fireKey: function(e)
20600 if (!this.picker().isVisible()){
20601 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20612 e.preventDefault();
20616 dir = e.keyCode == 37 ? -1 : 1;
20618 this.vIndex = this.vIndex + dir;
20620 if(this.vIndex < 0){
20624 if(this.vIndex > 11){
20628 if(isNaN(this.vIndex)){
20632 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20638 dir = e.keyCode == 38 ? -1 : 1;
20640 this.vIndex = this.vIndex + dir * 4;
20642 if(this.vIndex < 0){
20646 if(this.vIndex > 11){
20650 if(isNaN(this.vIndex)){
20654 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20659 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20660 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20664 e.preventDefault();
20667 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20668 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20684 this.picker().remove();
20689 Roo.apply(Roo.bootstrap.MonthField, {
20708 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20709 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20714 Roo.apply(Roo.bootstrap.MonthField, {
20718 cls: 'datepicker dropdown-menu roo-dynamic',
20722 cls: 'datepicker-months',
20726 cls: 'table-condensed',
20728 Roo.bootstrap.DateField.content
20748 * @class Roo.bootstrap.CheckBox
20749 * @extends Roo.bootstrap.Input
20750 * Bootstrap CheckBox class
20752 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20753 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20754 * @cfg {String} boxLabel The text that appears beside the checkbox
20755 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20756 * @cfg {Boolean} checked initnal the element
20757 * @cfg {Boolean} inline inline the element (default false)
20758 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20759 * @cfg {String} tooltip label tooltip
20762 * Create a new CheckBox
20763 * @param {Object} config The config object
20766 Roo.bootstrap.CheckBox = function(config){
20767 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20772 * Fires when the element is checked or unchecked.
20773 * @param {Roo.bootstrap.CheckBox} this This input
20774 * @param {Boolean} checked The new checked value
20779 * Fires when the element is click.
20780 * @param {Roo.bootstrap.CheckBox} this This input
20787 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20789 inputType: 'checkbox',
20798 getAutoCreate : function()
20800 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20806 cfg.cls = 'form-group ' + this.inputType; //input-group
20809 cfg.cls += ' ' + this.inputType + '-inline';
20815 type : this.inputType,
20816 value : this.inputValue,
20817 cls : 'roo-' + this.inputType, //'form-box',
20818 placeholder : this.placeholder || ''
20822 if(this.inputType != 'radio'){
20826 cls : 'roo-hidden-value',
20827 value : this.checked ? this.inputValue : this.valueOff
20832 if (this.weight) { // Validity check?
20833 cfg.cls += " " + this.inputType + "-" + this.weight;
20836 if (this.disabled) {
20837 input.disabled=true;
20841 input.checked = this.checked;
20846 input.name = this.name;
20848 if(this.inputType != 'radio'){
20849 hidden.name = this.name;
20850 input.name = '_hidden_' + this.name;
20855 input.cls += ' input-' + this.size;
20860 ['xs','sm','md','lg'].map(function(size){
20861 if (settings[size]) {
20862 cfg.cls += ' col-' + size + '-' + settings[size];
20866 var inputblock = input;
20868 if (this.before || this.after) {
20871 cls : 'input-group',
20876 inputblock.cn.push({
20878 cls : 'input-group-addon',
20883 inputblock.cn.push(input);
20885 if(this.inputType != 'radio'){
20886 inputblock.cn.push(hidden);
20890 inputblock.cn.push({
20892 cls : 'input-group-addon',
20899 if (align ==='left' && this.fieldLabel.length) {
20900 // Roo.log("left and has label");
20905 cls : 'control-label',
20906 html : this.fieldLabel
20916 if(this.labelWidth > 12){
20917 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20920 if(this.labelWidth < 13 && this.labelmd == 0){
20921 this.labelmd = this.labelWidth;
20924 if(this.labellg > 0){
20925 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20926 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20929 if(this.labelmd > 0){
20930 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20931 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20934 if(this.labelsm > 0){
20935 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20936 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20939 if(this.labelxs > 0){
20940 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20941 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20944 } else if ( this.fieldLabel.length) {
20945 // Roo.log(" label");
20949 tag: this.boxLabel ? 'span' : 'label',
20951 cls: 'control-label box-input-label',
20952 //cls : 'input-group-addon',
20953 html : this.fieldLabel
20962 // Roo.log(" no label && no align");
20963 cfg.cn = [ inputblock ] ;
20969 var boxLabelCfg = {
20971 //'for': id, // box label is handled by onclick - so no for...
20973 html: this.boxLabel
20977 boxLabelCfg.tooltip = this.tooltip;
20980 cfg.cn.push(boxLabelCfg);
20983 if(this.inputType != 'radio'){
20984 cfg.cn.push(hidden);
20992 * return the real input element.
20994 inputEl: function ()
20996 return this.el.select('input.roo-' + this.inputType,true).first();
20998 hiddenEl: function ()
21000 return this.el.select('input.roo-hidden-value',true).first();
21003 labelEl: function()
21005 return this.el.select('label.control-label',true).first();
21007 /* depricated... */
21011 return this.labelEl();
21014 boxLabelEl: function()
21016 return this.el.select('label.box-label',true).first();
21019 initEvents : function()
21021 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21023 this.inputEl().on('click', this.onClick, this);
21025 if (this.boxLabel) {
21026 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21029 this.startValue = this.getValue();
21032 Roo.bootstrap.CheckBox.register(this);
21036 onClick : function(e)
21038 if(this.fireEvent('click', this, e) !== false){
21039 this.setChecked(!this.checked);
21044 setChecked : function(state,suppressEvent)
21046 this.startValue = this.getValue();
21048 if(this.inputType == 'radio'){
21050 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21051 e.dom.checked = false;
21054 this.inputEl().dom.checked = true;
21056 this.inputEl().dom.value = this.inputValue;
21058 if(suppressEvent !== true){
21059 this.fireEvent('check', this, true);
21067 this.checked = state;
21069 this.inputEl().dom.checked = state;
21072 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21074 if(suppressEvent !== true){
21075 this.fireEvent('check', this, state);
21081 getValue : function()
21083 if(this.inputType == 'radio'){
21084 return this.getGroupValue();
21087 return this.hiddenEl().dom.value;
21091 getGroupValue : function()
21093 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21097 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21100 setValue : function(v,suppressEvent)
21102 if(this.inputType == 'radio'){
21103 this.setGroupValue(v, suppressEvent);
21107 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21112 setGroupValue : function(v, suppressEvent)
21114 this.startValue = this.getValue();
21116 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21117 e.dom.checked = false;
21119 if(e.dom.value == v){
21120 e.dom.checked = true;
21124 if(suppressEvent !== true){
21125 this.fireEvent('check', this, true);
21133 validate : function()
21135 if(this.getVisibilityEl().hasClass('hidden')){
21141 (this.inputType == 'radio' && this.validateRadio()) ||
21142 (this.inputType == 'checkbox' && this.validateCheckbox())
21148 this.markInvalid();
21152 validateRadio : function()
21154 if(this.getVisibilityEl().hasClass('hidden')){
21158 if(this.allowBlank){
21164 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21165 if(!e.dom.checked){
21177 validateCheckbox : function()
21180 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21181 //return (this.getValue() == this.inputValue) ? true : false;
21184 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21192 for(var i in group){
21193 if(group[i].el.isVisible(true)){
21201 for(var i in group){
21206 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21213 * Mark this field as valid
21215 markValid : function()
21219 this.fireEvent('valid', this);
21221 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21224 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21231 if(this.inputType == 'radio'){
21232 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21233 var fg = e.findParent('.form-group', false, true);
21234 if (Roo.bootstrap.version == 3) {
21235 fg.removeClass([_this.invalidClass, _this.validClass]);
21236 fg.addClass(_this.validClass);
21238 fg.removeClass(['is-valid', 'is-invalid']);
21239 fg.addClass('is-valid');
21247 var fg = this.el.findParent('.form-group', false, true);
21248 if (Roo.bootstrap.version == 3) {
21249 fg.removeClass([this.invalidClass, this.validClass]);
21250 fg.addClass(this.validClass);
21252 fg.removeClass(['is-valid', 'is-invalid']);
21253 fg.addClass('is-valid');
21258 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21264 for(var i in group){
21265 var fg = group[i].el.findParent('.form-group', false, true);
21266 if (Roo.bootstrap.version == 3) {
21267 fg.removeClass([this.invalidClass, this.validClass]);
21268 fg.addClass(this.validClass);
21270 fg.removeClass(['is-valid', 'is-invalid']);
21271 fg.addClass('is-valid');
21277 * Mark this field as invalid
21278 * @param {String} msg The validation message
21280 markInvalid : function(msg)
21282 if(this.allowBlank){
21288 this.fireEvent('invalid', this, msg);
21290 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21293 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21297 label.markInvalid();
21300 if(this.inputType == 'radio'){
21302 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21303 var fg = e.findParent('.form-group', false, true);
21304 if (Roo.bootstrap.version == 3) {
21305 fg.removeClass([_this.invalidClass, _this.validClass]);
21306 fg.addClass(_this.invalidClass);
21308 fg.removeClass(['is-invalid', 'is-valid']);
21309 fg.addClass('is-invalid');
21317 var fg = this.el.findParent('.form-group', false, true);
21318 if (Roo.bootstrap.version == 3) {
21319 fg.removeClass([_this.invalidClass, _this.validClass]);
21320 fg.addClass(_this.invalidClass);
21322 fg.removeClass(['is-invalid', 'is-valid']);
21323 fg.addClass('is-invalid');
21328 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21334 for(var i in group){
21335 var fg = group[i].el.findParent('.form-group', false, true);
21336 if (Roo.bootstrap.version == 3) {
21337 fg.removeClass([_this.invalidClass, _this.validClass]);
21338 fg.addClass(_this.invalidClass);
21340 fg.removeClass(['is-invalid', 'is-valid']);
21341 fg.addClass('is-invalid');
21347 clearInvalid : function()
21349 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21351 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21353 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21355 if (label && label.iconEl) {
21356 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21357 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21361 disable : function()
21363 if(this.inputType != 'radio'){
21364 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21371 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21372 _this.getActionEl().addClass(this.disabledClass);
21373 e.dom.disabled = true;
21377 this.disabled = true;
21378 this.fireEvent("disable", this);
21382 enable : function()
21384 if(this.inputType != 'radio'){
21385 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21392 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21393 _this.getActionEl().removeClass(this.disabledClass);
21394 e.dom.disabled = false;
21398 this.disabled = false;
21399 this.fireEvent("enable", this);
21403 setBoxLabel : function(v)
21408 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21414 Roo.apply(Roo.bootstrap.CheckBox, {
21419 * register a CheckBox Group
21420 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21422 register : function(checkbox)
21424 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21425 this.groups[checkbox.groupId] = {};
21428 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21432 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21436 * fetch a CheckBox Group based on the group ID
21437 * @param {string} the group ID
21438 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21440 get: function(groupId) {
21441 if (typeof(this.groups[groupId]) == 'undefined') {
21445 return this.groups[groupId] ;
21458 * @class Roo.bootstrap.Radio
21459 * @extends Roo.bootstrap.Component
21460 * Bootstrap Radio class
21461 * @cfg {String} boxLabel - the label associated
21462 * @cfg {String} value - the value of radio
21465 * Create a new Radio
21466 * @param {Object} config The config object
21468 Roo.bootstrap.Radio = function(config){
21469 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21473 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21479 getAutoCreate : function()
21483 cls : 'form-group radio',
21488 html : this.boxLabel
21496 initEvents : function()
21498 this.parent().register(this);
21500 this.el.on('click', this.onClick, this);
21504 onClick : function(e)
21506 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21507 this.setChecked(true);
21511 setChecked : function(state, suppressEvent)
21513 this.parent().setValue(this.value, suppressEvent);
21517 setBoxLabel : function(v)
21522 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21537 * @class Roo.bootstrap.SecurePass
21538 * @extends Roo.bootstrap.Input
21539 * Bootstrap SecurePass class
21543 * Create a new SecurePass
21544 * @param {Object} config The config object
21547 Roo.bootstrap.SecurePass = function (config) {
21548 // these go here, so the translation tool can replace them..
21550 PwdEmpty: "Please type a password, and then retype it to confirm.",
21551 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21552 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21553 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21554 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21555 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21556 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21557 TooWeak: "Your password is Too Weak."
21559 this.meterLabel = "Password strength:";
21560 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21561 this.meterClass = [
21562 "roo-password-meter-tooweak",
21563 "roo-password-meter-weak",
21564 "roo-password-meter-medium",
21565 "roo-password-meter-strong",
21566 "roo-password-meter-grey"
21571 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21574 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21576 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21578 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21579 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21580 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21581 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21582 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21583 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21584 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21594 * @cfg {String/Object} Label for the strength meter (defaults to
21595 * 'Password strength:')
21600 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21601 * ['Weak', 'Medium', 'Strong'])
21604 pwdStrengths: false,
21617 initEvents: function ()
21619 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21621 if (this.el.is('input[type=password]') && Roo.isSafari) {
21622 this.el.on('keydown', this.SafariOnKeyDown, this);
21625 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21628 onRender: function (ct, position)
21630 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21631 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21632 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21634 this.trigger.createChild({
21639 cls: 'roo-password-meter-grey col-xs-12',
21642 //width: this.meterWidth + 'px'
21646 cls: 'roo-password-meter-text'
21652 if (this.hideTrigger) {
21653 this.trigger.setDisplayed(false);
21655 this.setSize(this.width || '', this.height || '');
21658 onDestroy: function ()
21660 if (this.trigger) {
21661 this.trigger.removeAllListeners();
21662 this.trigger.remove();
21665 this.wrap.remove();
21667 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21670 checkStrength: function ()
21672 var pwd = this.inputEl().getValue();
21673 if (pwd == this._lastPwd) {
21678 if (this.ClientSideStrongPassword(pwd)) {
21680 } else if (this.ClientSideMediumPassword(pwd)) {
21682 } else if (this.ClientSideWeakPassword(pwd)) {
21688 Roo.log('strength1: ' + strength);
21690 //var pm = this.trigger.child('div/div/div').dom;
21691 var pm = this.trigger.child('div/div');
21692 pm.removeClass(this.meterClass);
21693 pm.addClass(this.meterClass[strength]);
21696 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21698 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21700 this._lastPwd = pwd;
21704 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21706 this._lastPwd = '';
21708 var pm = this.trigger.child('div/div');
21709 pm.removeClass(this.meterClass);
21710 pm.addClass('roo-password-meter-grey');
21713 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21716 this.inputEl().dom.type='password';
21719 validateValue: function (value)
21722 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21725 if (value.length == 0) {
21726 if (this.allowBlank) {
21727 this.clearInvalid();
21731 this.markInvalid(this.errors.PwdEmpty);
21732 this.errorMsg = this.errors.PwdEmpty;
21740 if ('[\x21-\x7e]*'.match(value)) {
21741 this.markInvalid(this.errors.PwdBadChar);
21742 this.errorMsg = this.errors.PwdBadChar;
21745 if (value.length < 6) {
21746 this.markInvalid(this.errors.PwdShort);
21747 this.errorMsg = this.errors.PwdShort;
21750 if (value.length > 16) {
21751 this.markInvalid(this.errors.PwdLong);
21752 this.errorMsg = this.errors.PwdLong;
21756 if (this.ClientSideStrongPassword(value)) {
21758 } else if (this.ClientSideMediumPassword(value)) {
21760 } else if (this.ClientSideWeakPassword(value)) {
21767 if (strength < 2) {
21768 //this.markInvalid(this.errors.TooWeak);
21769 this.errorMsg = this.errors.TooWeak;
21774 console.log('strength2: ' + strength);
21776 //var pm = this.trigger.child('div/div/div').dom;
21778 var pm = this.trigger.child('div/div');
21779 pm.removeClass(this.meterClass);
21780 pm.addClass(this.meterClass[strength]);
21782 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21784 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21786 this.errorMsg = '';
21790 CharacterSetChecks: function (type)
21793 this.fResult = false;
21796 isctype: function (character, type)
21799 case this.kCapitalLetter:
21800 if (character >= 'A' && character <= 'Z') {
21805 case this.kSmallLetter:
21806 if (character >= 'a' && character <= 'z') {
21812 if (character >= '0' && character <= '9') {
21817 case this.kPunctuation:
21818 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21829 IsLongEnough: function (pwd, size)
21831 return !(pwd == null || isNaN(size) || pwd.length < size);
21834 SpansEnoughCharacterSets: function (word, nb)
21836 if (!this.IsLongEnough(word, nb))
21841 var characterSetChecks = new Array(
21842 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21843 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21846 for (var index = 0; index < word.length; ++index) {
21847 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21848 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21849 characterSetChecks[nCharSet].fResult = true;
21856 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21857 if (characterSetChecks[nCharSet].fResult) {
21862 if (nCharSets < nb) {
21868 ClientSideStrongPassword: function (pwd)
21870 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21873 ClientSideMediumPassword: function (pwd)
21875 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21878 ClientSideWeakPassword: function (pwd)
21880 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21883 })//<script type="text/javascript">
21886 * Based Ext JS Library 1.1.1
21887 * Copyright(c) 2006-2007, Ext JS, LLC.
21893 * @class Roo.HtmlEditorCore
21894 * @extends Roo.Component
21895 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21897 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21900 Roo.HtmlEditorCore = function(config){
21903 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21908 * @event initialize
21909 * Fires when the editor is fully initialized (including the iframe)
21910 * @param {Roo.HtmlEditorCore} this
21915 * Fires when the editor is first receives the focus. Any insertion must wait
21916 * until after this event.
21917 * @param {Roo.HtmlEditorCore} this
21921 * @event beforesync
21922 * Fires before the textarea is updated with content from the editor iframe. Return false
21923 * to cancel the sync.
21924 * @param {Roo.HtmlEditorCore} this
21925 * @param {String} html
21929 * @event beforepush
21930 * Fires before the iframe editor is updated with content from the textarea. Return false
21931 * to cancel the push.
21932 * @param {Roo.HtmlEditorCore} this
21933 * @param {String} html
21938 * Fires when the textarea is updated with content from the editor iframe.
21939 * @param {Roo.HtmlEditorCore} this
21940 * @param {String} html
21945 * Fires when the iframe editor is updated with content from the textarea.
21946 * @param {Roo.HtmlEditorCore} this
21947 * @param {String} html
21952 * @event editorevent
21953 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21954 * @param {Roo.HtmlEditorCore} this
21960 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21962 // defaults : white / black...
21963 this.applyBlacklists();
21970 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21974 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21980 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21985 * @cfg {Number} height (in pixels)
21989 * @cfg {Number} width (in pixels)
21994 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21997 stylesheets: false,
22002 // private properties
22003 validationEvent : false,
22005 initialized : false,
22007 sourceEditMode : false,
22008 onFocus : Roo.emptyFn,
22010 hideMode:'offsets',
22014 // blacklist + whitelisted elements..
22021 * Protected method that will not generally be called directly. It
22022 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22023 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22025 getDocMarkup : function(){
22029 // inherit styels from page...??
22030 if (this.stylesheets === false) {
22032 Roo.get(document.head).select('style').each(function(node) {
22033 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22036 Roo.get(document.head).select('link').each(function(node) {
22037 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22040 } else if (!this.stylesheets.length) {
22042 st = '<style type="text/css">' +
22043 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22046 st = '<style type="text/css">' +
22051 st += '<style type="text/css">' +
22052 'IMG { cursor: pointer } ' +
22055 var cls = 'roo-htmleditor-body';
22057 if(this.bodyCls.length){
22058 cls += ' ' + this.bodyCls;
22061 return '<html><head>' + st +
22062 //<style type="text/css">' +
22063 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22065 ' </head><body class="' + cls + '"></body></html>';
22069 onRender : function(ct, position)
22072 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22073 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22076 this.el.dom.style.border = '0 none';
22077 this.el.dom.setAttribute('tabIndex', -1);
22078 this.el.addClass('x-hidden hide');
22082 if(Roo.isIE){ // fix IE 1px bogus margin
22083 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22087 this.frameId = Roo.id();
22091 var iframe = this.owner.wrap.createChild({
22093 cls: 'form-control', // bootstrap..
22095 name: this.frameId,
22096 frameBorder : 'no',
22097 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22102 this.iframe = iframe.dom;
22104 this.assignDocWin();
22106 this.doc.designMode = 'on';
22109 this.doc.write(this.getDocMarkup());
22113 var task = { // must defer to wait for browser to be ready
22115 //console.log("run task?" + this.doc.readyState);
22116 this.assignDocWin();
22117 if(this.doc.body || this.doc.readyState == 'complete'){
22119 this.doc.designMode="on";
22123 Roo.TaskMgr.stop(task);
22124 this.initEditor.defer(10, this);
22131 Roo.TaskMgr.start(task);
22136 onResize : function(w, h)
22138 Roo.log('resize: ' +w + ',' + h );
22139 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22143 if(typeof w == 'number'){
22145 this.iframe.style.width = w + 'px';
22147 if(typeof h == 'number'){
22149 this.iframe.style.height = h + 'px';
22151 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22158 * Toggles the editor between standard and source edit mode.
22159 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22161 toggleSourceEdit : function(sourceEditMode){
22163 this.sourceEditMode = sourceEditMode === true;
22165 if(this.sourceEditMode){
22167 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22170 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22171 //this.iframe.className = '';
22174 //this.setSize(this.owner.wrap.getSize());
22175 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22182 * Protected method that will not generally be called directly. If you need/want
22183 * custom HTML cleanup, this is the method you should override.
22184 * @param {String} html The HTML to be cleaned
22185 * return {String} The cleaned HTML
22187 cleanHtml : function(html){
22188 html = String(html);
22189 if(html.length > 5){
22190 if(Roo.isSafari){ // strip safari nonsense
22191 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22194 if(html == ' '){
22201 * HTML Editor -> Textarea
22202 * Protected method that will not generally be called directly. Syncs the contents
22203 * of the editor iframe with the textarea.
22205 syncValue : function(){
22206 if(this.initialized){
22207 var bd = (this.doc.body || this.doc.documentElement);
22208 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22209 var html = bd.innerHTML;
22211 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22212 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22214 html = '<div style="'+m[0]+'">' + html + '</div>';
22217 html = this.cleanHtml(html);
22218 // fix up the special chars.. normaly like back quotes in word...
22219 // however we do not want to do this with chinese..
22220 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22221 var cc = b.charCodeAt();
22223 (cc >= 0x4E00 && cc < 0xA000 ) ||
22224 (cc >= 0x3400 && cc < 0x4E00 ) ||
22225 (cc >= 0xf900 && cc < 0xfb00 )
22231 if(this.owner.fireEvent('beforesync', this, html) !== false){
22232 this.el.dom.value = html;
22233 this.owner.fireEvent('sync', this, html);
22239 * Protected method that will not generally be called directly. Pushes the value of the textarea
22240 * into the iframe editor.
22242 pushValue : function(){
22243 if(this.initialized){
22244 var v = this.el.dom.value.trim();
22246 // if(v.length < 1){
22250 if(this.owner.fireEvent('beforepush', this, v) !== false){
22251 var d = (this.doc.body || this.doc.documentElement);
22253 this.cleanUpPaste();
22254 this.el.dom.value = d.innerHTML;
22255 this.owner.fireEvent('push', this, v);
22261 deferFocus : function(){
22262 this.focus.defer(10, this);
22266 focus : function(){
22267 if(this.win && !this.sourceEditMode){
22274 assignDocWin: function()
22276 var iframe = this.iframe;
22279 this.doc = iframe.contentWindow.document;
22280 this.win = iframe.contentWindow;
22282 // if (!Roo.get(this.frameId)) {
22285 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22286 // this.win = Roo.get(this.frameId).dom.contentWindow;
22288 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22292 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22293 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22298 initEditor : function(){
22299 //console.log("INIT EDITOR");
22300 this.assignDocWin();
22304 this.doc.designMode="on";
22306 this.doc.write(this.getDocMarkup());
22309 var dbody = (this.doc.body || this.doc.documentElement);
22310 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22311 // this copies styles from the containing element into thsi one..
22312 // not sure why we need all of this..
22313 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22315 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22316 //ss['background-attachment'] = 'fixed'; // w3c
22317 dbody.bgProperties = 'fixed'; // ie
22318 //Roo.DomHelper.applyStyles(dbody, ss);
22319 Roo.EventManager.on(this.doc, {
22320 //'mousedown': this.onEditorEvent,
22321 'mouseup': this.onEditorEvent,
22322 'dblclick': this.onEditorEvent,
22323 'click': this.onEditorEvent,
22324 'keyup': this.onEditorEvent,
22329 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22331 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22332 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22334 this.initialized = true;
22336 this.owner.fireEvent('initialize', this);
22341 onDestroy : function(){
22347 //for (var i =0; i < this.toolbars.length;i++) {
22348 // // fixme - ask toolbars for heights?
22349 // this.toolbars[i].onDestroy();
22352 //this.wrap.dom.innerHTML = '';
22353 //this.wrap.remove();
22358 onFirstFocus : function(){
22360 this.assignDocWin();
22363 this.activated = true;
22366 if(Roo.isGecko){ // prevent silly gecko errors
22368 var s = this.win.getSelection();
22369 if(!s.focusNode || s.focusNode.nodeType != 3){
22370 var r = s.getRangeAt(0);
22371 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22376 this.execCmd('useCSS', true);
22377 this.execCmd('styleWithCSS', false);
22380 this.owner.fireEvent('activate', this);
22384 adjustFont: function(btn){
22385 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22386 //if(Roo.isSafari){ // safari
22389 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22390 if(Roo.isSafari){ // safari
22391 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22392 v = (v < 10) ? 10 : v;
22393 v = (v > 48) ? 48 : v;
22394 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22399 v = Math.max(1, v+adjust);
22401 this.execCmd('FontSize', v );
22404 onEditorEvent : function(e)
22406 this.owner.fireEvent('editorevent', this, e);
22407 // this.updateToolbar();
22408 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22411 insertTag : function(tg)
22413 // could be a bit smarter... -> wrap the current selected tRoo..
22414 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22416 range = this.createRange(this.getSelection());
22417 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22418 wrappingNode.appendChild(range.extractContents());
22419 range.insertNode(wrappingNode);
22426 this.execCmd("formatblock", tg);
22430 insertText : function(txt)
22434 var range = this.createRange();
22435 range.deleteContents();
22436 //alert(Sender.getAttribute('label'));
22438 range.insertNode(this.doc.createTextNode(txt));
22444 * Executes a Midas editor command on the editor document and performs necessary focus and
22445 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22446 * @param {String} cmd The Midas command
22447 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22449 relayCmd : function(cmd, value){
22451 this.execCmd(cmd, value);
22452 this.owner.fireEvent('editorevent', this);
22453 //this.updateToolbar();
22454 this.owner.deferFocus();
22458 * Executes a Midas editor command directly on the editor document.
22459 * For visual commands, you should use {@link #relayCmd} instead.
22460 * <b>This should only be called after the editor is initialized.</b>
22461 * @param {String} cmd The Midas command
22462 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22464 execCmd : function(cmd, value){
22465 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22472 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22474 * @param {String} text | dom node..
22476 insertAtCursor : function(text)
22479 if(!this.activated){
22485 var r = this.doc.selection.createRange();
22496 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22500 // from jquery ui (MIT licenced)
22502 var win = this.win;
22504 if (win.getSelection && win.getSelection().getRangeAt) {
22505 range = win.getSelection().getRangeAt(0);
22506 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22507 range.insertNode(node);
22508 } else if (win.document.selection && win.document.selection.createRange) {
22509 // no firefox support
22510 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22511 win.document.selection.createRange().pasteHTML(txt);
22513 // no firefox support
22514 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22515 this.execCmd('InsertHTML', txt);
22524 mozKeyPress : function(e){
22526 var c = e.getCharCode(), cmd;
22529 c = String.fromCharCode(c).toLowerCase();
22543 this.cleanUpPaste.defer(100, this);
22551 e.preventDefault();
22559 fixKeys : function(){ // load time branching for fastest keydown performance
22561 return function(e){
22562 var k = e.getKey(), r;
22565 r = this.doc.selection.createRange();
22568 r.pasteHTML('    ');
22575 r = this.doc.selection.createRange();
22577 var target = r.parentElement();
22578 if(!target || target.tagName.toLowerCase() != 'li'){
22580 r.pasteHTML('<br />');
22586 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22587 this.cleanUpPaste.defer(100, this);
22593 }else if(Roo.isOpera){
22594 return function(e){
22595 var k = e.getKey();
22599 this.execCmd('InsertHTML','    ');
22602 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22603 this.cleanUpPaste.defer(100, this);
22608 }else if(Roo.isSafari){
22609 return function(e){
22610 var k = e.getKey();
22614 this.execCmd('InsertText','\t');
22618 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22619 this.cleanUpPaste.defer(100, this);
22627 getAllAncestors: function()
22629 var p = this.getSelectedNode();
22632 a.push(p); // push blank onto stack..
22633 p = this.getParentElement();
22637 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22641 a.push(this.doc.body);
22645 lastSelNode : false,
22648 getSelection : function()
22650 this.assignDocWin();
22651 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22654 getSelectedNode: function()
22656 // this may only work on Gecko!!!
22658 // should we cache this!!!!
22663 var range = this.createRange(this.getSelection()).cloneRange();
22666 var parent = range.parentElement();
22668 var testRange = range.duplicate();
22669 testRange.moveToElementText(parent);
22670 if (testRange.inRange(range)) {
22673 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22676 parent = parent.parentElement;
22681 // is ancestor a text element.
22682 var ac = range.commonAncestorContainer;
22683 if (ac.nodeType == 3) {
22684 ac = ac.parentNode;
22687 var ar = ac.childNodes;
22690 var other_nodes = [];
22691 var has_other_nodes = false;
22692 for (var i=0;i<ar.length;i++) {
22693 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22696 // fullly contained node.
22698 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22703 // probably selected..
22704 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22705 other_nodes.push(ar[i]);
22709 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22714 has_other_nodes = true;
22716 if (!nodes.length && other_nodes.length) {
22717 nodes= other_nodes;
22719 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22725 createRange: function(sel)
22727 // this has strange effects when using with
22728 // top toolbar - not sure if it's a great idea.
22729 //this.editor.contentWindow.focus();
22730 if (typeof sel != "undefined") {
22732 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22734 return this.doc.createRange();
22737 return this.doc.createRange();
22740 getParentElement: function()
22743 this.assignDocWin();
22744 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22746 var range = this.createRange(sel);
22749 var p = range.commonAncestorContainer;
22750 while (p.nodeType == 3) { // text node
22761 * Range intersection.. the hard stuff...
22765 * [ -- selected range --- ]
22769 * if end is before start or hits it. fail.
22770 * if start is after end or hits it fail.
22772 * if either hits (but other is outside. - then it's not
22778 // @see http://www.thismuchiknow.co.uk/?p=64.
22779 rangeIntersectsNode : function(range, node)
22781 var nodeRange = node.ownerDocument.createRange();
22783 nodeRange.selectNode(node);
22785 nodeRange.selectNodeContents(node);
22788 var rangeStartRange = range.cloneRange();
22789 rangeStartRange.collapse(true);
22791 var rangeEndRange = range.cloneRange();
22792 rangeEndRange.collapse(false);
22794 var nodeStartRange = nodeRange.cloneRange();
22795 nodeStartRange.collapse(true);
22797 var nodeEndRange = nodeRange.cloneRange();
22798 nodeEndRange.collapse(false);
22800 return rangeStartRange.compareBoundaryPoints(
22801 Range.START_TO_START, nodeEndRange) == -1 &&
22802 rangeEndRange.compareBoundaryPoints(
22803 Range.START_TO_START, nodeStartRange) == 1;
22807 rangeCompareNode : function(range, node)
22809 var nodeRange = node.ownerDocument.createRange();
22811 nodeRange.selectNode(node);
22813 nodeRange.selectNodeContents(node);
22817 range.collapse(true);
22819 nodeRange.collapse(true);
22821 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22822 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22824 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22826 var nodeIsBefore = ss == 1;
22827 var nodeIsAfter = ee == -1;
22829 if (nodeIsBefore && nodeIsAfter) {
22832 if (!nodeIsBefore && nodeIsAfter) {
22833 return 1; //right trailed.
22836 if (nodeIsBefore && !nodeIsAfter) {
22837 return 2; // left trailed.
22843 // private? - in a new class?
22844 cleanUpPaste : function()
22846 // cleans up the whole document..
22847 Roo.log('cleanuppaste');
22849 this.cleanUpChildren(this.doc.body);
22850 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22851 if (clean != this.doc.body.innerHTML) {
22852 this.doc.body.innerHTML = clean;
22857 cleanWordChars : function(input) {// change the chars to hex code
22858 var he = Roo.HtmlEditorCore;
22860 var output = input;
22861 Roo.each(he.swapCodes, function(sw) {
22862 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22864 output = output.replace(swapper, sw[1]);
22871 cleanUpChildren : function (n)
22873 if (!n.childNodes.length) {
22876 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22877 this.cleanUpChild(n.childNodes[i]);
22884 cleanUpChild : function (node)
22887 //console.log(node);
22888 if (node.nodeName == "#text") {
22889 // clean up silly Windows -- stuff?
22892 if (node.nodeName == "#comment") {
22893 node.parentNode.removeChild(node);
22894 // clean up silly Windows -- stuff?
22897 var lcname = node.tagName.toLowerCase();
22898 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22899 // whitelist of tags..
22901 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22903 node.parentNode.removeChild(node);
22908 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22910 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22911 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22913 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22914 // remove_keep_children = true;
22917 if (remove_keep_children) {
22918 this.cleanUpChildren(node);
22919 // inserts everything just before this node...
22920 while (node.childNodes.length) {
22921 var cn = node.childNodes[0];
22922 node.removeChild(cn);
22923 node.parentNode.insertBefore(cn, node);
22925 node.parentNode.removeChild(node);
22929 if (!node.attributes || !node.attributes.length) {
22930 this.cleanUpChildren(node);
22934 function cleanAttr(n,v)
22937 if (v.match(/^\./) || v.match(/^\//)) {
22940 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22943 if (v.match(/^#/)) {
22946 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22947 node.removeAttribute(n);
22951 var cwhite = this.cwhite;
22952 var cblack = this.cblack;
22954 function cleanStyle(n,v)
22956 if (v.match(/expression/)) { //XSS?? should we even bother..
22957 node.removeAttribute(n);
22961 var parts = v.split(/;/);
22964 Roo.each(parts, function(p) {
22965 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22969 var l = p.split(':').shift().replace(/\s+/g,'');
22970 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22972 if ( cwhite.length && cblack.indexOf(l) > -1) {
22973 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22974 //node.removeAttribute(n);
22978 // only allow 'c whitelisted system attributes'
22979 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22980 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22981 //node.removeAttribute(n);
22991 if (clean.length) {
22992 node.setAttribute(n, clean.join(';'));
22994 node.removeAttribute(n);
23000 for (var i = node.attributes.length-1; i > -1 ; i--) {
23001 var a = node.attributes[i];
23004 if (a.name.toLowerCase().substr(0,2)=='on') {
23005 node.removeAttribute(a.name);
23008 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23009 node.removeAttribute(a.name);
23012 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23013 cleanAttr(a.name,a.value); // fixme..
23016 if (a.name == 'style') {
23017 cleanStyle(a.name,a.value);
23020 /// clean up MS crap..
23021 // tecnically this should be a list of valid class'es..
23024 if (a.name == 'class') {
23025 if (a.value.match(/^Mso/)) {
23026 node.className = '';
23029 if (a.value.match(/^body$/)) {
23030 node.className = '';
23041 this.cleanUpChildren(node);
23047 * Clean up MS wordisms...
23049 cleanWord : function(node)
23054 this.cleanWord(this.doc.body);
23057 if (node.nodeName == "#text") {
23058 // clean up silly Windows -- stuff?
23061 if (node.nodeName == "#comment") {
23062 node.parentNode.removeChild(node);
23063 // clean up silly Windows -- stuff?
23067 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23068 node.parentNode.removeChild(node);
23072 // remove - but keep children..
23073 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23074 while (node.childNodes.length) {
23075 var cn = node.childNodes[0];
23076 node.removeChild(cn);
23077 node.parentNode.insertBefore(cn, node);
23079 node.parentNode.removeChild(node);
23080 this.iterateChildren(node, this.cleanWord);
23084 if (node.className.length) {
23086 var cn = node.className.split(/\W+/);
23088 Roo.each(cn, function(cls) {
23089 if (cls.match(/Mso[a-zA-Z]+/)) {
23094 node.className = cna.length ? cna.join(' ') : '';
23096 node.removeAttribute("class");
23100 if (node.hasAttribute("lang")) {
23101 node.removeAttribute("lang");
23104 if (node.hasAttribute("style")) {
23106 var styles = node.getAttribute("style").split(";");
23108 Roo.each(styles, function(s) {
23109 if (!s.match(/:/)) {
23112 var kv = s.split(":");
23113 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23116 // what ever is left... we allow.
23119 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23120 if (!nstyle.length) {
23121 node.removeAttribute('style');
23124 this.iterateChildren(node, this.cleanWord);
23130 * iterateChildren of a Node, calling fn each time, using this as the scole..
23131 * @param {DomNode} node node to iterate children of.
23132 * @param {Function} fn method of this class to call on each item.
23134 iterateChildren : function(node, fn)
23136 if (!node.childNodes.length) {
23139 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23140 fn.call(this, node.childNodes[i])
23146 * cleanTableWidths.
23148 * Quite often pasting from word etc.. results in tables with column and widths.
23149 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23152 cleanTableWidths : function(node)
23157 this.cleanTableWidths(this.doc.body);
23162 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23165 Roo.log(node.tagName);
23166 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23167 this.iterateChildren(node, this.cleanTableWidths);
23170 if (node.hasAttribute('width')) {
23171 node.removeAttribute('width');
23175 if (node.hasAttribute("style")) {
23178 var styles = node.getAttribute("style").split(";");
23180 Roo.each(styles, function(s) {
23181 if (!s.match(/:/)) {
23184 var kv = s.split(":");
23185 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23188 // what ever is left... we allow.
23191 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23192 if (!nstyle.length) {
23193 node.removeAttribute('style');
23197 this.iterateChildren(node, this.cleanTableWidths);
23205 domToHTML : function(currentElement, depth, nopadtext) {
23207 depth = depth || 0;
23208 nopadtext = nopadtext || false;
23210 if (!currentElement) {
23211 return this.domToHTML(this.doc.body);
23214 //Roo.log(currentElement);
23216 var allText = false;
23217 var nodeName = currentElement.nodeName;
23218 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23220 if (nodeName == '#text') {
23222 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23227 if (nodeName != 'BODY') {
23230 // Prints the node tagName, such as <A>, <IMG>, etc
23233 for(i = 0; i < currentElement.attributes.length;i++) {
23235 var aname = currentElement.attributes.item(i).name;
23236 if (!currentElement.attributes.item(i).value.length) {
23239 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23242 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23251 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23254 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23259 // Traverse the tree
23261 var currentElementChild = currentElement.childNodes.item(i);
23262 var allText = true;
23263 var innerHTML = '';
23265 while (currentElementChild) {
23266 // Formatting code (indent the tree so it looks nice on the screen)
23267 var nopad = nopadtext;
23268 if (lastnode == 'SPAN') {
23272 if (currentElementChild.nodeName == '#text') {
23273 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23274 toadd = nopadtext ? toadd : toadd.trim();
23275 if (!nopad && toadd.length > 80) {
23276 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23278 innerHTML += toadd;
23281 currentElementChild = currentElement.childNodes.item(i);
23287 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23289 // Recursively traverse the tree structure of the child node
23290 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23291 lastnode = currentElementChild.nodeName;
23293 currentElementChild=currentElement.childNodes.item(i);
23299 // The remaining code is mostly for formatting the tree
23300 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23305 ret+= "</"+tagName+">";
23311 applyBlacklists : function()
23313 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23314 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23318 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23319 if (b.indexOf(tag) > -1) {
23322 this.white.push(tag);
23326 Roo.each(w, function(tag) {
23327 if (b.indexOf(tag) > -1) {
23330 if (this.white.indexOf(tag) > -1) {
23333 this.white.push(tag);
23338 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23339 if (w.indexOf(tag) > -1) {
23342 this.black.push(tag);
23346 Roo.each(b, function(tag) {
23347 if (w.indexOf(tag) > -1) {
23350 if (this.black.indexOf(tag) > -1) {
23353 this.black.push(tag);
23358 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23359 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23363 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23364 if (b.indexOf(tag) > -1) {
23367 this.cwhite.push(tag);
23371 Roo.each(w, function(tag) {
23372 if (b.indexOf(tag) > -1) {
23375 if (this.cwhite.indexOf(tag) > -1) {
23378 this.cwhite.push(tag);
23383 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23384 if (w.indexOf(tag) > -1) {
23387 this.cblack.push(tag);
23391 Roo.each(b, function(tag) {
23392 if (w.indexOf(tag) > -1) {
23395 if (this.cblack.indexOf(tag) > -1) {
23398 this.cblack.push(tag);
23403 setStylesheets : function(stylesheets)
23405 if(typeof(stylesheets) == 'string'){
23406 Roo.get(this.iframe.contentDocument.head).createChild({
23408 rel : 'stylesheet',
23417 Roo.each(stylesheets, function(s) {
23422 Roo.get(_this.iframe.contentDocument.head).createChild({
23424 rel : 'stylesheet',
23433 removeStylesheets : function()
23437 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23442 setStyle : function(style)
23444 Roo.get(this.iframe.contentDocument.head).createChild({
23453 // hide stuff that is not compatible
23467 * @event specialkey
23471 * @cfg {String} fieldClass @hide
23474 * @cfg {String} focusClass @hide
23477 * @cfg {String} autoCreate @hide
23480 * @cfg {String} inputType @hide
23483 * @cfg {String} invalidClass @hide
23486 * @cfg {String} invalidText @hide
23489 * @cfg {String} msgFx @hide
23492 * @cfg {String} validateOnBlur @hide
23496 Roo.HtmlEditorCore.white = [
23497 'area', 'br', 'img', 'input', 'hr', 'wbr',
23499 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23500 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23501 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23502 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23503 'table', 'ul', 'xmp',
23505 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23508 'dir', 'menu', 'ol', 'ul', 'dl',
23514 Roo.HtmlEditorCore.black = [
23515 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23517 'base', 'basefont', 'bgsound', 'blink', 'body',
23518 'frame', 'frameset', 'head', 'html', 'ilayer',
23519 'iframe', 'layer', 'link', 'meta', 'object',
23520 'script', 'style' ,'title', 'xml' // clean later..
23522 Roo.HtmlEditorCore.clean = [
23523 'script', 'style', 'title', 'xml'
23525 Roo.HtmlEditorCore.remove = [
23530 Roo.HtmlEditorCore.ablack = [
23534 Roo.HtmlEditorCore.aclean = [
23535 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23539 Roo.HtmlEditorCore.pwhite= [
23540 'http', 'https', 'mailto'
23543 // white listed style attributes.
23544 Roo.HtmlEditorCore.cwhite= [
23545 // 'text-align', /// default is to allow most things..
23551 // black listed style attributes.
23552 Roo.HtmlEditorCore.cblack= [
23553 // 'font-size' -- this can be set by the project
23557 Roo.HtmlEditorCore.swapCodes =[
23576 * @class Roo.bootstrap.HtmlEditor
23577 * @extends Roo.bootstrap.TextArea
23578 * Bootstrap HtmlEditor class
23581 * Create a new HtmlEditor
23582 * @param {Object} config The config object
23585 Roo.bootstrap.HtmlEditor = function(config){
23586 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23587 if (!this.toolbars) {
23588 this.toolbars = [];
23591 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23594 * @event initialize
23595 * Fires when the editor is fully initialized (including the iframe)
23596 * @param {HtmlEditor} this
23601 * Fires when the editor is first receives the focus. Any insertion must wait
23602 * until after this event.
23603 * @param {HtmlEditor} this
23607 * @event beforesync
23608 * Fires before the textarea is updated with content from the editor iframe. Return false
23609 * to cancel the sync.
23610 * @param {HtmlEditor} this
23611 * @param {String} html
23615 * @event beforepush
23616 * Fires before the iframe editor is updated with content from the textarea. Return false
23617 * to cancel the push.
23618 * @param {HtmlEditor} this
23619 * @param {String} html
23624 * Fires when the textarea is updated with content from the editor iframe.
23625 * @param {HtmlEditor} this
23626 * @param {String} html
23631 * Fires when the iframe editor is updated with content from the textarea.
23632 * @param {HtmlEditor} this
23633 * @param {String} html
23637 * @event editmodechange
23638 * Fires when the editor switches edit modes
23639 * @param {HtmlEditor} this
23640 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23642 editmodechange: true,
23644 * @event editorevent
23645 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23646 * @param {HtmlEditor} this
23650 * @event firstfocus
23651 * Fires when on first focus - needed by toolbars..
23652 * @param {HtmlEditor} this
23657 * Auto save the htmlEditor value as a file into Events
23658 * @param {HtmlEditor} this
23662 * @event savedpreview
23663 * preview the saved version of htmlEditor
23664 * @param {HtmlEditor} this
23671 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23675 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23680 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23685 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23690 * @cfg {Number} height (in pixels)
23694 * @cfg {Number} width (in pixels)
23699 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23702 stylesheets: false,
23707 // private properties
23708 validationEvent : false,
23710 initialized : false,
23713 onFocus : Roo.emptyFn,
23715 hideMode:'offsets',
23717 tbContainer : false,
23721 toolbarContainer :function() {
23722 return this.wrap.select('.x-html-editor-tb',true).first();
23726 * Protected method that will not generally be called directly. It
23727 * is called when the editor creates its toolbar. Override this method if you need to
23728 * add custom toolbar buttons.
23729 * @param {HtmlEditor} editor
23731 createToolbar : function(){
23732 Roo.log('renewing');
23733 Roo.log("create toolbars");
23735 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23736 this.toolbars[0].render(this.toolbarContainer());
23740 // if (!editor.toolbars || !editor.toolbars.length) {
23741 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23744 // for (var i =0 ; i < editor.toolbars.length;i++) {
23745 // editor.toolbars[i] = Roo.factory(
23746 // typeof(editor.toolbars[i]) == 'string' ?
23747 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23748 // Roo.bootstrap.HtmlEditor);
23749 // editor.toolbars[i].init(editor);
23755 onRender : function(ct, position)
23757 // Roo.log("Call onRender: " + this.xtype);
23759 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23761 this.wrap = this.inputEl().wrap({
23762 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23765 this.editorcore.onRender(ct, position);
23767 if (this.resizable) {
23768 this.resizeEl = new Roo.Resizable(this.wrap, {
23772 minHeight : this.height,
23773 height: this.height,
23774 handles : this.resizable,
23777 resize : function(r, w, h) {
23778 _t.onResize(w,h); // -something
23784 this.createToolbar(this);
23787 if(!this.width && this.resizable){
23788 this.setSize(this.wrap.getSize());
23790 if (this.resizeEl) {
23791 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23792 // should trigger onReize..
23798 onResize : function(w, h)
23800 Roo.log('resize: ' +w + ',' + h );
23801 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23805 if(this.inputEl() ){
23806 if(typeof w == 'number'){
23807 var aw = w - this.wrap.getFrameWidth('lr');
23808 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23811 if(typeof h == 'number'){
23812 var tbh = -11; // fixme it needs to tool bar size!
23813 for (var i =0; i < this.toolbars.length;i++) {
23814 // fixme - ask toolbars for heights?
23815 tbh += this.toolbars[i].el.getHeight();
23816 //if (this.toolbars[i].footer) {
23817 // tbh += this.toolbars[i].footer.el.getHeight();
23825 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23826 ah -= 5; // knock a few pixes off for look..
23827 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23831 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23832 this.editorcore.onResize(ew,eh);
23837 * Toggles the editor between standard and source edit mode.
23838 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23840 toggleSourceEdit : function(sourceEditMode)
23842 this.editorcore.toggleSourceEdit(sourceEditMode);
23844 if(this.editorcore.sourceEditMode){
23845 Roo.log('editor - showing textarea');
23848 // Roo.log(this.syncValue());
23850 this.inputEl().removeClass(['hide', 'x-hidden']);
23851 this.inputEl().dom.removeAttribute('tabIndex');
23852 this.inputEl().focus();
23854 Roo.log('editor - hiding textarea');
23856 // Roo.log(this.pushValue());
23859 this.inputEl().addClass(['hide', 'x-hidden']);
23860 this.inputEl().dom.setAttribute('tabIndex', -1);
23861 //this.deferFocus();
23864 if(this.resizable){
23865 this.setSize(this.wrap.getSize());
23868 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23871 // private (for BoxComponent)
23872 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23874 // private (for BoxComponent)
23875 getResizeEl : function(){
23879 // private (for BoxComponent)
23880 getPositionEl : function(){
23885 initEvents : function(){
23886 this.originalValue = this.getValue();
23890 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23893 // markInvalid : Roo.emptyFn,
23895 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23898 // clearInvalid : Roo.emptyFn,
23900 setValue : function(v){
23901 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23902 this.editorcore.pushValue();
23907 deferFocus : function(){
23908 this.focus.defer(10, this);
23912 focus : function(){
23913 this.editorcore.focus();
23919 onDestroy : function(){
23925 for (var i =0; i < this.toolbars.length;i++) {
23926 // fixme - ask toolbars for heights?
23927 this.toolbars[i].onDestroy();
23930 this.wrap.dom.innerHTML = '';
23931 this.wrap.remove();
23936 onFirstFocus : function(){
23937 //Roo.log("onFirstFocus");
23938 this.editorcore.onFirstFocus();
23939 for (var i =0; i < this.toolbars.length;i++) {
23940 this.toolbars[i].onFirstFocus();
23946 syncValue : function()
23948 this.editorcore.syncValue();
23951 pushValue : function()
23953 this.editorcore.pushValue();
23957 // hide stuff that is not compatible
23971 * @event specialkey
23975 * @cfg {String} fieldClass @hide
23978 * @cfg {String} focusClass @hide
23981 * @cfg {String} autoCreate @hide
23984 * @cfg {String} inputType @hide
23988 * @cfg {String} invalidText @hide
23991 * @cfg {String} msgFx @hide
23994 * @cfg {String} validateOnBlur @hide
24003 Roo.namespace('Roo.bootstrap.htmleditor');
24005 * @class Roo.bootstrap.HtmlEditorToolbar1
24010 new Roo.bootstrap.HtmlEditor({
24013 new Roo.bootstrap.HtmlEditorToolbar1({
24014 disable : { fonts: 1 , format: 1, ..., ... , ...],
24020 * @cfg {Object} disable List of elements to disable..
24021 * @cfg {Array} btns List of additional buttons.
24025 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24028 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24031 Roo.apply(this, config);
24033 // default disabled, based on 'good practice'..
24034 this.disable = this.disable || {};
24035 Roo.applyIf(this.disable, {
24038 specialElements : true
24040 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24042 this.editor = config.editor;
24043 this.editorcore = config.editor.editorcore;
24045 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24047 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24048 // dont call parent... till later.
24050 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24055 editorcore : false,
24060 "h1","h2","h3","h4","h5","h6",
24062 "abbr", "acronym", "address", "cite", "samp", "var",
24066 onRender : function(ct, position)
24068 // Roo.log("Call onRender: " + this.xtype);
24070 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24072 this.el.dom.style.marginBottom = '0';
24074 var editorcore = this.editorcore;
24075 var editor= this.editor;
24078 var btn = function(id,cmd , toggle, handler, html){
24080 var event = toggle ? 'toggle' : 'click';
24085 xns: Roo.bootstrap,
24089 enableToggle:toggle !== false,
24091 pressed : toggle ? false : null,
24094 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24095 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24101 // var cb_box = function...
24106 xns: Roo.bootstrap,
24111 xns: Roo.bootstrap,
24115 Roo.each(this.formats, function(f) {
24116 style.menu.items.push({
24118 xns: Roo.bootstrap,
24119 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24124 editorcore.insertTag(this.tagname);
24131 children.push(style);
24133 btn('bold',false,true);
24134 btn('italic',false,true);
24135 btn('align-left', 'justifyleft',true);
24136 btn('align-center', 'justifycenter',true);
24137 btn('align-right' , 'justifyright',true);
24138 btn('link', false, false, function(btn) {
24139 //Roo.log("create link?");
24140 var url = prompt(this.createLinkText, this.defaultLinkValue);
24141 if(url && url != 'http:/'+'/'){
24142 this.editorcore.relayCmd('createlink', url);
24145 btn('list','insertunorderedlist',true);
24146 btn('pencil', false,true, function(btn){
24148 this.toggleSourceEdit(btn.pressed);
24151 if (this.editor.btns.length > 0) {
24152 for (var i = 0; i<this.editor.btns.length; i++) {
24153 children.push(this.editor.btns[i]);
24161 xns: Roo.bootstrap,
24166 xns: Roo.bootstrap,
24171 cog.menu.items.push({
24173 xns: Roo.bootstrap,
24174 html : Clean styles,
24179 editorcore.insertTag(this.tagname);
24188 this.xtype = 'NavSimplebar';
24190 for(var i=0;i< children.length;i++) {
24192 this.buttons.add(this.addxtypeChild(children[i]));
24196 editor.on('editorevent', this.updateToolbar, this);
24198 onBtnClick : function(id)
24200 this.editorcore.relayCmd(id);
24201 this.editorcore.focus();
24205 * Protected method that will not generally be called directly. It triggers
24206 * a toolbar update by reading the markup state of the current selection in the editor.
24208 updateToolbar: function(){
24210 if(!this.editorcore.activated){
24211 this.editor.onFirstFocus(); // is this neeed?
24215 var btns = this.buttons;
24216 var doc = this.editorcore.doc;
24217 btns.get('bold').setActive(doc.queryCommandState('bold'));
24218 btns.get('italic').setActive(doc.queryCommandState('italic'));
24219 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24221 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24222 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24223 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24225 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24226 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24229 var ans = this.editorcore.getAllAncestors();
24230 if (this.formatCombo) {
24233 var store = this.formatCombo.store;
24234 this.formatCombo.setValue("");
24235 for (var i =0; i < ans.length;i++) {
24236 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24238 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24246 // hides menus... - so this cant be on a menu...
24247 Roo.bootstrap.MenuMgr.hideAll();
24249 Roo.bootstrap.MenuMgr.hideAll();
24250 //this.editorsyncValue();
24252 onFirstFocus: function() {
24253 this.buttons.each(function(item){
24257 toggleSourceEdit : function(sourceEditMode){
24260 if(sourceEditMode){
24261 Roo.log("disabling buttons");
24262 this.buttons.each( function(item){
24263 if(item.cmd != 'pencil'){
24269 Roo.log("enabling buttons");
24270 if(this.editorcore.initialized){
24271 this.buttons.each( function(item){
24277 Roo.log("calling toggole on editor");
24278 // tell the editor that it's been pressed..
24279 this.editor.toggleSourceEdit(sourceEditMode);
24289 * @class Roo.bootstrap.Table.AbstractSelectionModel
24290 * @extends Roo.util.Observable
24291 * Abstract base class for grid SelectionModels. It provides the interface that should be
24292 * implemented by descendant classes. This class should not be directly instantiated.
24295 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24296 this.locked = false;
24297 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24301 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24302 /** @ignore Called by the grid automatically. Do not call directly. */
24303 init : function(grid){
24309 * Locks the selections.
24312 this.locked = true;
24316 * Unlocks the selections.
24318 unlock : function(){
24319 this.locked = false;
24323 * Returns true if the selections are locked.
24324 * @return {Boolean}
24326 isLocked : function(){
24327 return this.locked;
24331 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24332 * @class Roo.bootstrap.Table.RowSelectionModel
24333 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24334 * It supports multiple selections and keyboard selection/navigation.
24336 * @param {Object} config
24339 Roo.bootstrap.Table.RowSelectionModel = function(config){
24340 Roo.apply(this, config);
24341 this.selections = new Roo.util.MixedCollection(false, function(o){
24346 this.lastActive = false;
24350 * @event selectionchange
24351 * Fires when the selection changes
24352 * @param {SelectionModel} this
24354 "selectionchange" : true,
24356 * @event afterselectionchange
24357 * Fires after the selection changes (eg. by key press or clicking)
24358 * @param {SelectionModel} this
24360 "afterselectionchange" : true,
24362 * @event beforerowselect
24363 * Fires when a row is selected being selected, return false to cancel.
24364 * @param {SelectionModel} this
24365 * @param {Number} rowIndex The selected index
24366 * @param {Boolean} keepExisting False if other selections will be cleared
24368 "beforerowselect" : true,
24371 * Fires when a row is selected.
24372 * @param {SelectionModel} this
24373 * @param {Number} rowIndex The selected index
24374 * @param {Roo.data.Record} r The record
24376 "rowselect" : true,
24378 * @event rowdeselect
24379 * Fires when a row is deselected.
24380 * @param {SelectionModel} this
24381 * @param {Number} rowIndex The selected index
24383 "rowdeselect" : true
24385 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24386 this.locked = false;
24389 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24391 * @cfg {Boolean} singleSelect
24392 * True to allow selection of only one row at a time (defaults to false)
24394 singleSelect : false,
24397 initEvents : function()
24400 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24401 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24402 //}else{ // allow click to work like normal
24403 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24405 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24406 this.grid.on("rowclick", this.handleMouseDown, this);
24408 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24409 "up" : function(e){
24411 this.selectPrevious(e.shiftKey);
24412 }else if(this.last !== false && this.lastActive !== false){
24413 var last = this.last;
24414 this.selectRange(this.last, this.lastActive-1);
24415 this.grid.getView().focusRow(this.lastActive);
24416 if(last !== false){
24420 this.selectFirstRow();
24422 this.fireEvent("afterselectionchange", this);
24424 "down" : function(e){
24426 this.selectNext(e.shiftKey);
24427 }else if(this.last !== false && this.lastActive !== false){
24428 var last = this.last;
24429 this.selectRange(this.last, this.lastActive+1);
24430 this.grid.getView().focusRow(this.lastActive);
24431 if(last !== false){
24435 this.selectFirstRow();
24437 this.fireEvent("afterselectionchange", this);
24441 this.grid.store.on('load', function(){
24442 this.selections.clear();
24445 var view = this.grid.view;
24446 view.on("refresh", this.onRefresh, this);
24447 view.on("rowupdated", this.onRowUpdated, this);
24448 view.on("rowremoved", this.onRemove, this);
24453 onRefresh : function()
24455 var ds = this.grid.store, i, v = this.grid.view;
24456 var s = this.selections;
24457 s.each(function(r){
24458 if((i = ds.indexOfId(r.id)) != -1){
24467 onRemove : function(v, index, r){
24468 this.selections.remove(r);
24472 onRowUpdated : function(v, index, r){
24473 if(this.isSelected(r)){
24474 v.onRowSelect(index);
24480 * @param {Array} records The records to select
24481 * @param {Boolean} keepExisting (optional) True to keep existing selections
24483 selectRecords : function(records, keepExisting)
24486 this.clearSelections();
24488 var ds = this.grid.store;
24489 for(var i = 0, len = records.length; i < len; i++){
24490 this.selectRow(ds.indexOf(records[i]), true);
24495 * Gets the number of selected rows.
24498 getCount : function(){
24499 return this.selections.length;
24503 * Selects the first row in the grid.
24505 selectFirstRow : function(){
24510 * Select the last row.
24511 * @param {Boolean} keepExisting (optional) True to keep existing selections
24513 selectLastRow : function(keepExisting){
24514 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24515 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24519 * Selects the row immediately following the last selected row.
24520 * @param {Boolean} keepExisting (optional) True to keep existing selections
24522 selectNext : function(keepExisting)
24524 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24525 this.selectRow(this.last+1, keepExisting);
24526 this.grid.getView().focusRow(this.last);
24531 * Selects the row that precedes the last selected row.
24532 * @param {Boolean} keepExisting (optional) True to keep existing selections
24534 selectPrevious : function(keepExisting){
24536 this.selectRow(this.last-1, keepExisting);
24537 this.grid.getView().focusRow(this.last);
24542 * Returns the selected records
24543 * @return {Array} Array of selected records
24545 getSelections : function(){
24546 return [].concat(this.selections.items);
24550 * Returns the first selected record.
24553 getSelected : function(){
24554 return this.selections.itemAt(0);
24559 * Clears all selections.
24561 clearSelections : function(fast)
24567 var ds = this.grid.store;
24568 var s = this.selections;
24569 s.each(function(r){
24570 this.deselectRow(ds.indexOfId(r.id));
24574 this.selections.clear();
24581 * Selects all rows.
24583 selectAll : function(){
24587 this.selections.clear();
24588 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24589 this.selectRow(i, true);
24594 * Returns True if there is a selection.
24595 * @return {Boolean}
24597 hasSelection : function(){
24598 return this.selections.length > 0;
24602 * Returns True if the specified row is selected.
24603 * @param {Number/Record} record The record or index of the record to check
24604 * @return {Boolean}
24606 isSelected : function(index){
24607 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24608 return (r && this.selections.key(r.id) ? true : false);
24612 * Returns True if the specified record id is selected.
24613 * @param {String} id The id of record to check
24614 * @return {Boolean}
24616 isIdSelected : function(id){
24617 return (this.selections.key(id) ? true : false);
24622 handleMouseDBClick : function(e, t){
24626 handleMouseDown : function(e, t)
24628 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24629 if(this.isLocked() || rowIndex < 0 ){
24632 if(e.shiftKey && this.last !== false){
24633 var last = this.last;
24634 this.selectRange(last, rowIndex, e.ctrlKey);
24635 this.last = last; // reset the last
24639 var isSelected = this.isSelected(rowIndex);
24640 //Roo.log("select row:" + rowIndex);
24642 this.deselectRow(rowIndex);
24644 this.selectRow(rowIndex, true);
24648 if(e.button !== 0 && isSelected){
24649 alert('rowIndex 2: ' + rowIndex);
24650 view.focusRow(rowIndex);
24651 }else if(e.ctrlKey && isSelected){
24652 this.deselectRow(rowIndex);
24653 }else if(!isSelected){
24654 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24655 view.focusRow(rowIndex);
24659 this.fireEvent("afterselectionchange", this);
24662 handleDragableRowClick : function(grid, rowIndex, e)
24664 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24665 this.selectRow(rowIndex, false);
24666 grid.view.focusRow(rowIndex);
24667 this.fireEvent("afterselectionchange", this);
24672 * Selects multiple rows.
24673 * @param {Array} rows Array of the indexes of the row to select
24674 * @param {Boolean} keepExisting (optional) True to keep existing selections
24676 selectRows : function(rows, keepExisting){
24678 this.clearSelections();
24680 for(var i = 0, len = rows.length; i < len; i++){
24681 this.selectRow(rows[i], true);
24686 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24687 * @param {Number} startRow The index of the first row in the range
24688 * @param {Number} endRow The index of the last row in the range
24689 * @param {Boolean} keepExisting (optional) True to retain existing selections
24691 selectRange : function(startRow, endRow, keepExisting){
24696 this.clearSelections();
24698 if(startRow <= endRow){
24699 for(var i = startRow; i <= endRow; i++){
24700 this.selectRow(i, true);
24703 for(var i = startRow; i >= endRow; i--){
24704 this.selectRow(i, true);
24710 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24711 * @param {Number} startRow The index of the first row in the range
24712 * @param {Number} endRow The index of the last row in the range
24714 deselectRange : function(startRow, endRow, preventViewNotify){
24718 for(var i = startRow; i <= endRow; i++){
24719 this.deselectRow(i, preventViewNotify);
24725 * @param {Number} row The index of the row to select
24726 * @param {Boolean} keepExisting (optional) True to keep existing selections
24728 selectRow : function(index, keepExisting, preventViewNotify)
24730 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24733 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24734 if(!keepExisting || this.singleSelect){
24735 this.clearSelections();
24738 var r = this.grid.store.getAt(index);
24739 //console.log('selectRow - record id :' + r.id);
24741 this.selections.add(r);
24742 this.last = this.lastActive = index;
24743 if(!preventViewNotify){
24744 var proxy = new Roo.Element(
24745 this.grid.getRowDom(index)
24747 proxy.addClass('bg-info info');
24749 this.fireEvent("rowselect", this, index, r);
24750 this.fireEvent("selectionchange", this);
24756 * @param {Number} row The index of the row to deselect
24758 deselectRow : function(index, preventViewNotify)
24763 if(this.last == index){
24766 if(this.lastActive == index){
24767 this.lastActive = false;
24770 var r = this.grid.store.getAt(index);
24775 this.selections.remove(r);
24776 //.console.log('deselectRow - record id :' + r.id);
24777 if(!preventViewNotify){
24779 var proxy = new Roo.Element(
24780 this.grid.getRowDom(index)
24782 proxy.removeClass('bg-info info');
24784 this.fireEvent("rowdeselect", this, index);
24785 this.fireEvent("selectionchange", this);
24789 restoreLast : function(){
24791 this.last = this._last;
24796 acceptsNav : function(row, col, cm){
24797 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24801 onEditorKey : function(field, e){
24802 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24807 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24809 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24811 }else if(k == e.ENTER && !e.ctrlKey){
24815 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24817 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24819 }else if(k == e.ESC){
24823 g.startEditing(newCell[0], newCell[1]);
24829 * Ext JS Library 1.1.1
24830 * Copyright(c) 2006-2007, Ext JS, LLC.
24832 * Originally Released Under LGPL - original licence link has changed is not relivant.
24835 * <script type="text/javascript">
24839 * @class Roo.bootstrap.PagingToolbar
24840 * @extends Roo.bootstrap.NavSimplebar
24841 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24843 * Create a new PagingToolbar
24844 * @param {Object} config The config object
24845 * @param {Roo.data.Store} store
24847 Roo.bootstrap.PagingToolbar = function(config)
24849 // old args format still supported... - xtype is prefered..
24850 // created from xtype...
24852 this.ds = config.dataSource;
24854 if (config.store && !this.ds) {
24855 this.store= Roo.factory(config.store, Roo.data);
24856 this.ds = this.store;
24857 this.ds.xmodule = this.xmodule || false;
24860 this.toolbarItems = [];
24861 if (config.items) {
24862 this.toolbarItems = config.items;
24865 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24870 this.bind(this.ds);
24873 if (Roo.bootstrap.version == 4) {
24874 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24876 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24881 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24883 * @cfg {Roo.data.Store} dataSource
24884 * The underlying data store providing the paged data
24887 * @cfg {String/HTMLElement/Element} container
24888 * container The id or element that will contain the toolbar
24891 * @cfg {Boolean} displayInfo
24892 * True to display the displayMsg (defaults to false)
24895 * @cfg {Number} pageSize
24896 * The number of records to display per page (defaults to 20)
24900 * @cfg {String} displayMsg
24901 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24903 displayMsg : 'Displaying {0} - {1} of {2}',
24905 * @cfg {String} emptyMsg
24906 * The message to display when no records are found (defaults to "No data to display")
24908 emptyMsg : 'No data to display',
24910 * Customizable piece of the default paging text (defaults to "Page")
24913 beforePageText : "Page",
24915 * Customizable piece of the default paging text (defaults to "of %0")
24918 afterPageText : "of {0}",
24920 * Customizable piece of the default paging text (defaults to "First Page")
24923 firstText : "First Page",
24925 * Customizable piece of the default paging text (defaults to "Previous Page")
24928 prevText : "Previous Page",
24930 * Customizable piece of the default paging text (defaults to "Next Page")
24933 nextText : "Next Page",
24935 * Customizable piece of the default paging text (defaults to "Last Page")
24938 lastText : "Last Page",
24940 * Customizable piece of the default paging text (defaults to "Refresh")
24943 refreshText : "Refresh",
24947 onRender : function(ct, position)
24949 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24950 this.navgroup.parentId = this.id;
24951 this.navgroup.onRender(this.el, null);
24952 // add the buttons to the navgroup
24954 if(this.displayInfo){
24955 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24956 this.displayEl = this.el.select('.x-paging-info', true).first();
24957 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24958 // this.displayEl = navel.el.select('span',true).first();
24964 Roo.each(_this.buttons, function(e){ // this might need to use render????
24965 Roo.factory(e).render(_this.el);
24969 Roo.each(_this.toolbarItems, function(e) {
24970 _this.navgroup.addItem(e);
24974 this.first = this.navgroup.addItem({
24975 tooltip: this.firstText,
24976 cls: "prev btn-outline-secondary",
24977 html : ' <i class="fa fa-step-backward"></i>',
24979 preventDefault: true,
24980 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24983 this.prev = this.navgroup.addItem({
24984 tooltip: this.prevText,
24985 cls: "prev btn-outline-secondary",
24986 html : ' <i class="fa fa-backward"></i>',
24988 preventDefault: true,
24989 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24991 //this.addSeparator();
24994 var field = this.navgroup.addItem( {
24996 cls : 'x-paging-position btn-outline-secondary',
24998 html : this.beforePageText +
24999 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25000 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25003 this.field = field.el.select('input', true).first();
25004 this.field.on("keydown", this.onPagingKeydown, this);
25005 this.field.on("focus", function(){this.dom.select();});
25008 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25009 //this.field.setHeight(18);
25010 //this.addSeparator();
25011 this.next = this.navgroup.addItem({
25012 tooltip: this.nextText,
25013 cls: "next btn-outline-secondary",
25014 html : ' <i class="fa fa-forward"></i>',
25016 preventDefault: true,
25017 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25019 this.last = this.navgroup.addItem({
25020 tooltip: this.lastText,
25021 html : ' <i class="fa fa-step-forward"></i>',
25022 cls: "next btn-outline-secondary",
25024 preventDefault: true,
25025 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25027 //this.addSeparator();
25028 this.loading = this.navgroup.addItem({
25029 tooltip: this.refreshText,
25030 cls: "btn-outline-secondary",
25031 html : ' <i class="fa fa-refresh"></i>',
25032 preventDefault: true,
25033 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25039 updateInfo : function(){
25040 if(this.displayEl){
25041 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25042 var msg = count == 0 ?
25046 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25048 this.displayEl.update(msg);
25053 onLoad : function(ds, r, o)
25055 this.cursor = o.params.start ? o.params.start : 0;
25057 var d = this.getPageData(),
25062 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25063 this.field.dom.value = ap;
25064 this.first.setDisabled(ap == 1);
25065 this.prev.setDisabled(ap == 1);
25066 this.next.setDisabled(ap == ps);
25067 this.last.setDisabled(ap == ps);
25068 this.loading.enable();
25073 getPageData : function(){
25074 var total = this.ds.getTotalCount();
25077 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25078 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25083 onLoadError : function(){
25084 this.loading.enable();
25088 onPagingKeydown : function(e){
25089 var k = e.getKey();
25090 var d = this.getPageData();
25092 var v = this.field.dom.value, pageNum;
25093 if(!v || isNaN(pageNum = parseInt(v, 10))){
25094 this.field.dom.value = d.activePage;
25097 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25098 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25101 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))
25103 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25104 this.field.dom.value = pageNum;
25105 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25108 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25110 var v = this.field.dom.value, pageNum;
25111 var increment = (e.shiftKey) ? 10 : 1;
25112 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25115 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25116 this.field.dom.value = d.activePage;
25119 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25121 this.field.dom.value = parseInt(v, 10) + increment;
25122 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25123 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25130 beforeLoad : function(){
25132 this.loading.disable();
25137 onClick : function(which){
25146 ds.load({params:{start: 0, limit: this.pageSize}});
25149 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25152 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25155 var total = ds.getTotalCount();
25156 var extra = total % this.pageSize;
25157 var lastStart = extra ? (total - extra) : total-this.pageSize;
25158 ds.load({params:{start: lastStart, limit: this.pageSize}});
25161 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25167 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25168 * @param {Roo.data.Store} store The data store to unbind
25170 unbind : function(ds){
25171 ds.un("beforeload", this.beforeLoad, this);
25172 ds.un("load", this.onLoad, this);
25173 ds.un("loadexception", this.onLoadError, this);
25174 ds.un("remove", this.updateInfo, this);
25175 ds.un("add", this.updateInfo, this);
25176 this.ds = undefined;
25180 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25181 * @param {Roo.data.Store} store The data store to bind
25183 bind : function(ds){
25184 ds.on("beforeload", this.beforeLoad, this);
25185 ds.on("load", this.onLoad, this);
25186 ds.on("loadexception", this.onLoadError, this);
25187 ds.on("remove", this.updateInfo, this);
25188 ds.on("add", this.updateInfo, this);
25199 * @class Roo.bootstrap.MessageBar
25200 * @extends Roo.bootstrap.Component
25201 * Bootstrap MessageBar class
25202 * @cfg {String} html contents of the MessageBar
25203 * @cfg {String} weight (info | success | warning | danger) default info
25204 * @cfg {String} beforeClass insert the bar before the given class
25205 * @cfg {Boolean} closable (true | false) default false
25206 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25209 * Create a new Element
25210 * @param {Object} config The config object
25213 Roo.bootstrap.MessageBar = function(config){
25214 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25217 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25223 beforeClass: 'bootstrap-sticky-wrap',
25225 getAutoCreate : function(){
25229 cls: 'alert alert-dismissable alert-' + this.weight,
25234 html: this.html || ''
25240 cfg.cls += ' alert-messages-fixed';
25254 onRender : function(ct, position)
25256 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25259 var cfg = Roo.apply({}, this.getAutoCreate());
25263 cfg.cls += ' ' + this.cls;
25266 cfg.style = this.style;
25268 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25270 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25273 this.el.select('>button.close').on('click', this.hide, this);
25279 if (!this.rendered) {
25285 this.fireEvent('show', this);
25291 if (!this.rendered) {
25297 this.fireEvent('hide', this);
25300 update : function()
25302 // var e = this.el.dom.firstChild;
25304 // if(this.closable){
25305 // e = e.nextSibling;
25308 // e.data = this.html || '';
25310 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25326 * @class Roo.bootstrap.Graph
25327 * @extends Roo.bootstrap.Component
25328 * Bootstrap Graph class
25332 @cfg {String} graphtype bar | vbar | pie
25333 @cfg {number} g_x coodinator | centre x (pie)
25334 @cfg {number} g_y coodinator | centre y (pie)
25335 @cfg {number} g_r radius (pie)
25336 @cfg {number} g_height height of the chart (respected by all elements in the set)
25337 @cfg {number} g_width width of the chart (respected by all elements in the set)
25338 @cfg {Object} title The title of the chart
25341 -opts (object) options for the chart
25343 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25344 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25346 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.
25347 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25349 o stretch (boolean)
25351 -opts (object) options for the pie
25354 o startAngle (number)
25355 o endAngle (number)
25359 * Create a new Input
25360 * @param {Object} config The config object
25363 Roo.bootstrap.Graph = function(config){
25364 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25370 * The img click event for the img.
25371 * @param {Roo.EventObject} e
25377 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25388 //g_colors: this.colors,
25395 getAutoCreate : function(){
25406 onRender : function(ct,position){
25409 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25411 if (typeof(Raphael) == 'undefined') {
25412 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25416 this.raphael = Raphael(this.el.dom);
25418 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25419 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25420 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25421 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25423 r.text(160, 10, "Single Series Chart").attr(txtattr);
25424 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25425 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25426 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25428 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25429 r.barchart(330, 10, 300, 220, data1);
25430 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25431 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25434 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25435 // r.barchart(30, 30, 560, 250, xdata, {
25436 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25437 // axis : "0 0 1 1",
25438 // axisxlabels : xdata
25439 // //yvalues : cols,
25442 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25444 // this.load(null,xdata,{
25445 // axis : "0 0 1 1",
25446 // axisxlabels : xdata
25451 load : function(graphtype,xdata,opts)
25453 this.raphael.clear();
25455 graphtype = this.graphtype;
25460 var r = this.raphael,
25461 fin = function () {
25462 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25464 fout = function () {
25465 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25467 pfin = function() {
25468 this.sector.stop();
25469 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25472 this.label[0].stop();
25473 this.label[0].attr({ r: 7.5 });
25474 this.label[1].attr({ "font-weight": 800 });
25477 pfout = function() {
25478 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25481 this.label[0].animate({ r: 5 }, 500, "bounce");
25482 this.label[1].attr({ "font-weight": 400 });
25488 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25491 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25494 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25495 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25497 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25504 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25509 setTitle: function(o)
25514 initEvents: function() {
25517 this.el.on('click', this.onClick, this);
25521 onClick : function(e)
25523 Roo.log('img onclick');
25524 this.fireEvent('click', this, e);
25536 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25539 * @class Roo.bootstrap.dash.NumberBox
25540 * @extends Roo.bootstrap.Component
25541 * Bootstrap NumberBox class
25542 * @cfg {String} headline Box headline
25543 * @cfg {String} content Box content
25544 * @cfg {String} icon Box icon
25545 * @cfg {String} footer Footer text
25546 * @cfg {String} fhref Footer href
25549 * Create a new NumberBox
25550 * @param {Object} config The config object
25554 Roo.bootstrap.dash.NumberBox = function(config){
25555 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25559 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25568 getAutoCreate : function(){
25572 cls : 'small-box ',
25580 cls : 'roo-headline',
25581 html : this.headline
25585 cls : 'roo-content',
25586 html : this.content
25600 cls : 'ion ' + this.icon
25609 cls : 'small-box-footer',
25610 href : this.fhref || '#',
25614 cfg.cn.push(footer);
25621 onRender : function(ct,position){
25622 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25629 setHeadline: function (value)
25631 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25634 setFooter: function (value, href)
25636 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25639 this.el.select('a.small-box-footer',true).first().attr('href', href);
25644 setContent: function (value)
25646 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25649 initEvents: function()
25663 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25666 * @class Roo.bootstrap.dash.TabBox
25667 * @extends Roo.bootstrap.Component
25668 * Bootstrap TabBox class
25669 * @cfg {String} title Title of the TabBox
25670 * @cfg {String} icon Icon of the TabBox
25671 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25672 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25675 * Create a new TabBox
25676 * @param {Object} config The config object
25680 Roo.bootstrap.dash.TabBox = function(config){
25681 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25686 * When a pane is added
25687 * @param {Roo.bootstrap.dash.TabPane} pane
25691 * @event activatepane
25692 * When a pane is activated
25693 * @param {Roo.bootstrap.dash.TabPane} pane
25695 "activatepane" : true
25703 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25708 tabScrollable : false,
25710 getChildContainer : function()
25712 return this.el.select('.tab-content', true).first();
25715 getAutoCreate : function(){
25719 cls: 'pull-left header',
25727 cls: 'fa ' + this.icon
25733 cls: 'nav nav-tabs pull-right',
25739 if(this.tabScrollable){
25746 cls: 'nav nav-tabs pull-right',
25757 cls: 'nav-tabs-custom',
25762 cls: 'tab-content no-padding',
25770 initEvents : function()
25772 //Roo.log('add add pane handler');
25773 this.on('addpane', this.onAddPane, this);
25776 * Updates the box title
25777 * @param {String} html to set the title to.
25779 setTitle : function(value)
25781 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25783 onAddPane : function(pane)
25785 this.panes.push(pane);
25786 //Roo.log('addpane');
25788 // tabs are rendere left to right..
25789 if(!this.showtabs){
25793 var ctr = this.el.select('.nav-tabs', true).first();
25796 var existing = ctr.select('.nav-tab',true);
25797 var qty = existing.getCount();;
25800 var tab = ctr.createChild({
25802 cls : 'nav-tab' + (qty ? '' : ' active'),
25810 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25813 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25815 pane.el.addClass('active');
25820 onTabClick : function(ev,un,ob,pane)
25822 //Roo.log('tab - prev default');
25823 ev.preventDefault();
25826 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25827 pane.tab.addClass('active');
25828 //Roo.log(pane.title);
25829 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25830 // technically we should have a deactivate event.. but maybe add later.
25831 // and it should not de-activate the selected tab...
25832 this.fireEvent('activatepane', pane);
25833 pane.el.addClass('active');
25834 pane.fireEvent('activate');
25839 getActivePane : function()
25842 Roo.each(this.panes, function(p) {
25843 if(p.el.hasClass('active')){
25864 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25866 * @class Roo.bootstrap.TabPane
25867 * @extends Roo.bootstrap.Component
25868 * Bootstrap TabPane class
25869 * @cfg {Boolean} active (false | true) Default false
25870 * @cfg {String} title title of panel
25874 * Create a new TabPane
25875 * @param {Object} config The config object
25878 Roo.bootstrap.dash.TabPane = function(config){
25879 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25885 * When a pane is activated
25886 * @param {Roo.bootstrap.dash.TabPane} pane
25893 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25898 // the tabBox that this is attached to.
25901 getAutoCreate : function()
25909 cfg.cls += ' active';
25914 initEvents : function()
25916 //Roo.log('trigger add pane handler');
25917 this.parent().fireEvent('addpane', this)
25921 * Updates the tab title
25922 * @param {String} html to set the title to.
25924 setTitle: function(str)
25930 this.tab.select('a', true).first().dom.innerHTML = str;
25947 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25950 * @class Roo.bootstrap.menu.Menu
25951 * @extends Roo.bootstrap.Component
25952 * Bootstrap Menu class - container for Menu
25953 * @cfg {String} html Text of the menu
25954 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25955 * @cfg {String} icon Font awesome icon
25956 * @cfg {String} pos Menu align to (top | bottom) default bottom
25960 * Create a new Menu
25961 * @param {Object} config The config object
25965 Roo.bootstrap.menu.Menu = function(config){
25966 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25970 * @event beforeshow
25971 * Fires before this menu is displayed
25972 * @param {Roo.bootstrap.menu.Menu} this
25976 * @event beforehide
25977 * Fires before this menu is hidden
25978 * @param {Roo.bootstrap.menu.Menu} this
25983 * Fires after this menu is displayed
25984 * @param {Roo.bootstrap.menu.Menu} this
25989 * Fires after this menu is hidden
25990 * @param {Roo.bootstrap.menu.Menu} this
25995 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25996 * @param {Roo.bootstrap.menu.Menu} this
25997 * @param {Roo.EventObject} e
26004 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26008 weight : 'default',
26013 getChildContainer : function() {
26014 if(this.isSubMenu){
26018 return this.el.select('ul.dropdown-menu', true).first();
26021 getAutoCreate : function()
26026 cls : 'roo-menu-text',
26034 cls : 'fa ' + this.icon
26045 cls : 'dropdown-button btn btn-' + this.weight,
26050 cls : 'dropdown-toggle btn btn-' + this.weight,
26060 cls : 'dropdown-menu'
26066 if(this.pos == 'top'){
26067 cfg.cls += ' dropup';
26070 if(this.isSubMenu){
26073 cls : 'dropdown-menu'
26080 onRender : function(ct, position)
26082 this.isSubMenu = ct.hasClass('dropdown-submenu');
26084 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26087 initEvents : function()
26089 if(this.isSubMenu){
26093 this.hidden = true;
26095 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26096 this.triggerEl.on('click', this.onTriggerPress, this);
26098 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26099 this.buttonEl.on('click', this.onClick, this);
26105 if(this.isSubMenu){
26109 return this.el.select('ul.dropdown-menu', true).first();
26112 onClick : function(e)
26114 this.fireEvent("click", this, e);
26117 onTriggerPress : function(e)
26119 if (this.isVisible()) {
26126 isVisible : function(){
26127 return !this.hidden;
26132 this.fireEvent("beforeshow", this);
26134 this.hidden = false;
26135 this.el.addClass('open');
26137 Roo.get(document).on("mouseup", this.onMouseUp, this);
26139 this.fireEvent("show", this);
26146 this.fireEvent("beforehide", this);
26148 this.hidden = true;
26149 this.el.removeClass('open');
26151 Roo.get(document).un("mouseup", this.onMouseUp);
26153 this.fireEvent("hide", this);
26156 onMouseUp : function()
26170 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26173 * @class Roo.bootstrap.menu.Item
26174 * @extends Roo.bootstrap.Component
26175 * Bootstrap MenuItem class
26176 * @cfg {Boolean} submenu (true | false) default false
26177 * @cfg {String} html text of the item
26178 * @cfg {String} href the link
26179 * @cfg {Boolean} disable (true | false) default false
26180 * @cfg {Boolean} preventDefault (true | false) default true
26181 * @cfg {String} icon Font awesome icon
26182 * @cfg {String} pos Submenu align to (left | right) default right
26186 * Create a new Item
26187 * @param {Object} config The config object
26191 Roo.bootstrap.menu.Item = function(config){
26192 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26196 * Fires when the mouse is hovering over this menu
26197 * @param {Roo.bootstrap.menu.Item} this
26198 * @param {Roo.EventObject} e
26203 * Fires when the mouse exits this menu
26204 * @param {Roo.bootstrap.menu.Item} this
26205 * @param {Roo.EventObject} e
26211 * The raw click event for the entire grid.
26212 * @param {Roo.EventObject} e
26218 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26223 preventDefault: true,
26228 getAutoCreate : function()
26233 cls : 'roo-menu-item-text',
26241 cls : 'fa ' + this.icon
26250 href : this.href || '#',
26257 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26261 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26263 if(this.pos == 'left'){
26264 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26271 initEvents : function()
26273 this.el.on('mouseover', this.onMouseOver, this);
26274 this.el.on('mouseout', this.onMouseOut, this);
26276 this.el.select('a', true).first().on('click', this.onClick, this);
26280 onClick : function(e)
26282 if(this.preventDefault){
26283 e.preventDefault();
26286 this.fireEvent("click", this, e);
26289 onMouseOver : function(e)
26291 if(this.submenu && this.pos == 'left'){
26292 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26295 this.fireEvent("mouseover", this, e);
26298 onMouseOut : function(e)
26300 this.fireEvent("mouseout", this, e);
26312 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26315 * @class Roo.bootstrap.menu.Separator
26316 * @extends Roo.bootstrap.Component
26317 * Bootstrap Separator class
26320 * Create a new Separator
26321 * @param {Object} config The config object
26325 Roo.bootstrap.menu.Separator = function(config){
26326 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26329 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26331 getAutoCreate : function(){
26352 * @class Roo.bootstrap.Tooltip
26353 * Bootstrap Tooltip class
26354 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26355 * to determine which dom element triggers the tooltip.
26357 * It needs to add support for additional attributes like tooltip-position
26360 * Create a new Toolti
26361 * @param {Object} config The config object
26364 Roo.bootstrap.Tooltip = function(config){
26365 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26367 this.alignment = Roo.bootstrap.Tooltip.alignment;
26369 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26370 this.alignment = config.alignment;
26375 Roo.apply(Roo.bootstrap.Tooltip, {
26377 * @function init initialize tooltip monitoring.
26381 currentTip : false,
26382 currentRegion : false,
26388 Roo.get(document).on('mouseover', this.enter ,this);
26389 Roo.get(document).on('mouseout', this.leave, this);
26392 this.currentTip = new Roo.bootstrap.Tooltip();
26395 enter : function(ev)
26397 var dom = ev.getTarget();
26399 //Roo.log(['enter',dom]);
26400 var el = Roo.fly(dom);
26401 if (this.currentEl) {
26403 //Roo.log(this.currentEl);
26404 //Roo.log(this.currentEl.contains(dom));
26405 if (this.currentEl == el) {
26408 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26414 if (this.currentTip.el) {
26415 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26419 if(!el || el.dom == document){
26425 // you can not look for children, as if el is the body.. then everythign is the child..
26426 if (!el.attr('tooltip')) { //
26427 if (!el.select("[tooltip]").elements.length) {
26430 // is the mouse over this child...?
26431 bindEl = el.select("[tooltip]").first();
26432 var xy = ev.getXY();
26433 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26434 //Roo.log("not in region.");
26437 //Roo.log("child element over..");
26440 this.currentEl = bindEl;
26441 this.currentTip.bind(bindEl);
26442 this.currentRegion = Roo.lib.Region.getRegion(dom);
26443 this.currentTip.enter();
26446 leave : function(ev)
26448 var dom = ev.getTarget();
26449 //Roo.log(['leave',dom]);
26450 if (!this.currentEl) {
26455 if (dom != this.currentEl.dom) {
26458 var xy = ev.getXY();
26459 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26462 // only activate leave if mouse cursor is outside... bounding box..
26467 if (this.currentTip) {
26468 this.currentTip.leave();
26470 //Roo.log('clear currentEl');
26471 this.currentEl = false;
26476 'left' : ['r-l', [-2,0], 'right'],
26477 'right' : ['l-r', [2,0], 'left'],
26478 'bottom' : ['t-b', [0,2], 'top'],
26479 'top' : [ 'b-t', [0,-2], 'bottom']
26485 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26490 delay : null, // can be { show : 300 , hide: 500}
26494 hoverState : null, //???
26496 placement : 'bottom',
26500 getAutoCreate : function(){
26507 cls : 'tooltip-arrow'
26510 cls : 'tooltip-inner'
26517 bind : function(el)
26523 enter : function () {
26525 if (this.timeout != null) {
26526 clearTimeout(this.timeout);
26529 this.hoverState = 'in';
26530 //Roo.log("enter - show");
26531 if (!this.delay || !this.delay.show) {
26536 this.timeout = setTimeout(function () {
26537 if (_t.hoverState == 'in') {
26540 }, this.delay.show);
26544 clearTimeout(this.timeout);
26546 this.hoverState = 'out';
26547 if (!this.delay || !this.delay.hide) {
26553 this.timeout = setTimeout(function () {
26554 //Roo.log("leave - timeout");
26556 if (_t.hoverState == 'out') {
26558 Roo.bootstrap.Tooltip.currentEl = false;
26563 show : function (msg)
26566 this.render(document.body);
26569 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26571 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26573 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26575 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26577 var placement = typeof this.placement == 'function' ?
26578 this.placement.call(this, this.el, on_el) :
26581 var autoToken = /\s?auto?\s?/i;
26582 var autoPlace = autoToken.test(placement);
26584 placement = placement.replace(autoToken, '') || 'top';
26588 //this.el.setXY([0,0]);
26590 //this.el.dom.style.display='block';
26592 //this.el.appendTo(on_el);
26594 var p = this.getPosition();
26595 var box = this.el.getBox();
26601 var align = this.alignment[placement];
26603 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26605 if(placement == 'top' || placement == 'bottom'){
26607 placement = 'right';
26610 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26611 placement = 'left';
26614 var scroll = Roo.select('body', true).first().getScroll();
26616 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26620 align = this.alignment[placement];
26623 this.el.alignTo(this.bindEl, align[0],align[1]);
26624 //var arrow = this.el.select('.arrow',true).first();
26625 //arrow.set(align[2],
26627 this.el.addClass(placement);
26629 this.el.addClass('in fade');
26631 this.hoverState = null;
26633 if (this.el.hasClass('fade')) {
26644 //this.el.setXY([0,0]);
26645 this.el.removeClass('in');
26661 * @class Roo.bootstrap.LocationPicker
26662 * @extends Roo.bootstrap.Component
26663 * Bootstrap LocationPicker class
26664 * @cfg {Number} latitude Position when init default 0
26665 * @cfg {Number} longitude Position when init default 0
26666 * @cfg {Number} zoom default 15
26667 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26668 * @cfg {Boolean} mapTypeControl default false
26669 * @cfg {Boolean} disableDoubleClickZoom default false
26670 * @cfg {Boolean} scrollwheel default true
26671 * @cfg {Boolean} streetViewControl default false
26672 * @cfg {Number} radius default 0
26673 * @cfg {String} locationName
26674 * @cfg {Boolean} draggable default true
26675 * @cfg {Boolean} enableAutocomplete default false
26676 * @cfg {Boolean} enableReverseGeocode default true
26677 * @cfg {String} markerTitle
26680 * Create a new LocationPicker
26681 * @param {Object} config The config object
26685 Roo.bootstrap.LocationPicker = function(config){
26687 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26692 * Fires when the picker initialized.
26693 * @param {Roo.bootstrap.LocationPicker} this
26694 * @param {Google Location} location
26698 * @event positionchanged
26699 * Fires when the picker position changed.
26700 * @param {Roo.bootstrap.LocationPicker} this
26701 * @param {Google Location} location
26703 positionchanged : true,
26706 * Fires when the map resize.
26707 * @param {Roo.bootstrap.LocationPicker} this
26712 * Fires when the map show.
26713 * @param {Roo.bootstrap.LocationPicker} this
26718 * Fires when the map hide.
26719 * @param {Roo.bootstrap.LocationPicker} this
26724 * Fires when click the map.
26725 * @param {Roo.bootstrap.LocationPicker} this
26726 * @param {Map event} e
26730 * @event mapRightClick
26731 * Fires when right click the map.
26732 * @param {Roo.bootstrap.LocationPicker} this
26733 * @param {Map event} e
26735 mapRightClick : true,
26737 * @event markerClick
26738 * Fires when click the marker.
26739 * @param {Roo.bootstrap.LocationPicker} this
26740 * @param {Map event} e
26742 markerClick : true,
26744 * @event markerRightClick
26745 * Fires when right click the marker.
26746 * @param {Roo.bootstrap.LocationPicker} this
26747 * @param {Map event} e
26749 markerRightClick : true,
26751 * @event OverlayViewDraw
26752 * Fires when OverlayView Draw
26753 * @param {Roo.bootstrap.LocationPicker} this
26755 OverlayViewDraw : true,
26757 * @event OverlayViewOnAdd
26758 * Fires when OverlayView Draw
26759 * @param {Roo.bootstrap.LocationPicker} this
26761 OverlayViewOnAdd : true,
26763 * @event OverlayViewOnRemove
26764 * Fires when OverlayView Draw
26765 * @param {Roo.bootstrap.LocationPicker} this
26767 OverlayViewOnRemove : true,
26769 * @event OverlayViewShow
26770 * Fires when OverlayView Draw
26771 * @param {Roo.bootstrap.LocationPicker} this
26772 * @param {Pixel} cpx
26774 OverlayViewShow : true,
26776 * @event OverlayViewHide
26777 * Fires when OverlayView Draw
26778 * @param {Roo.bootstrap.LocationPicker} this
26780 OverlayViewHide : true,
26782 * @event loadexception
26783 * Fires when load google lib failed.
26784 * @param {Roo.bootstrap.LocationPicker} this
26786 loadexception : true
26791 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26793 gMapContext: false,
26799 mapTypeControl: false,
26800 disableDoubleClickZoom: false,
26802 streetViewControl: false,
26806 enableAutocomplete: false,
26807 enableReverseGeocode: true,
26810 getAutoCreate: function()
26815 cls: 'roo-location-picker'
26821 initEvents: function(ct, position)
26823 if(!this.el.getWidth() || this.isApplied()){
26827 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26832 initial: function()
26834 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26835 this.fireEvent('loadexception', this);
26839 if(!this.mapTypeId){
26840 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26843 this.gMapContext = this.GMapContext();
26845 this.initOverlayView();
26847 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26851 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26852 _this.setPosition(_this.gMapContext.marker.position);
26855 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26856 _this.fireEvent('mapClick', this, event);
26860 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26861 _this.fireEvent('mapRightClick', this, event);
26865 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26866 _this.fireEvent('markerClick', this, event);
26870 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26871 _this.fireEvent('markerRightClick', this, event);
26875 this.setPosition(this.gMapContext.location);
26877 this.fireEvent('initial', this, this.gMapContext.location);
26880 initOverlayView: function()
26884 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26888 _this.fireEvent('OverlayViewDraw', _this);
26893 _this.fireEvent('OverlayViewOnAdd', _this);
26896 onRemove: function()
26898 _this.fireEvent('OverlayViewOnRemove', _this);
26901 show: function(cpx)
26903 _this.fireEvent('OverlayViewShow', _this, cpx);
26908 _this.fireEvent('OverlayViewHide', _this);
26914 fromLatLngToContainerPixel: function(event)
26916 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26919 isApplied: function()
26921 return this.getGmapContext() == false ? false : true;
26924 getGmapContext: function()
26926 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26929 GMapContext: function()
26931 var position = new google.maps.LatLng(this.latitude, this.longitude);
26933 var _map = new google.maps.Map(this.el.dom, {
26936 mapTypeId: this.mapTypeId,
26937 mapTypeControl: this.mapTypeControl,
26938 disableDoubleClickZoom: this.disableDoubleClickZoom,
26939 scrollwheel: this.scrollwheel,
26940 streetViewControl: this.streetViewControl,
26941 locationName: this.locationName,
26942 draggable: this.draggable,
26943 enableAutocomplete: this.enableAutocomplete,
26944 enableReverseGeocode: this.enableReverseGeocode
26947 var _marker = new google.maps.Marker({
26948 position: position,
26950 title: this.markerTitle,
26951 draggable: this.draggable
26958 location: position,
26959 radius: this.radius,
26960 locationName: this.locationName,
26961 addressComponents: {
26962 formatted_address: null,
26963 addressLine1: null,
26964 addressLine2: null,
26966 streetNumber: null,
26970 stateOrProvince: null
26973 domContainer: this.el.dom,
26974 geodecoder: new google.maps.Geocoder()
26978 drawCircle: function(center, radius, options)
26980 if (this.gMapContext.circle != null) {
26981 this.gMapContext.circle.setMap(null);
26985 options = Roo.apply({}, options, {
26986 strokeColor: "#0000FF",
26987 strokeOpacity: .35,
26989 fillColor: "#0000FF",
26993 options.map = this.gMapContext.map;
26994 options.radius = radius;
26995 options.center = center;
26996 this.gMapContext.circle = new google.maps.Circle(options);
26997 return this.gMapContext.circle;
27003 setPosition: function(location)
27005 this.gMapContext.location = location;
27006 this.gMapContext.marker.setPosition(location);
27007 this.gMapContext.map.panTo(location);
27008 this.drawCircle(location, this.gMapContext.radius, {});
27012 if (this.gMapContext.settings.enableReverseGeocode) {
27013 this.gMapContext.geodecoder.geocode({
27014 latLng: this.gMapContext.location
27015 }, function(results, status) {
27017 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27018 _this.gMapContext.locationName = results[0].formatted_address;
27019 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27021 _this.fireEvent('positionchanged', this, location);
27028 this.fireEvent('positionchanged', this, location);
27033 google.maps.event.trigger(this.gMapContext.map, "resize");
27035 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27037 this.fireEvent('resize', this);
27040 setPositionByLatLng: function(latitude, longitude)
27042 this.setPosition(new google.maps.LatLng(latitude, longitude));
27045 getCurrentPosition: function()
27048 latitude: this.gMapContext.location.lat(),
27049 longitude: this.gMapContext.location.lng()
27053 getAddressName: function()
27055 return this.gMapContext.locationName;
27058 getAddressComponents: function()
27060 return this.gMapContext.addressComponents;
27063 address_component_from_google_geocode: function(address_components)
27067 for (var i = 0; i < address_components.length; i++) {
27068 var component = address_components[i];
27069 if (component.types.indexOf("postal_code") >= 0) {
27070 result.postalCode = component.short_name;
27071 } else if (component.types.indexOf("street_number") >= 0) {
27072 result.streetNumber = component.short_name;
27073 } else if (component.types.indexOf("route") >= 0) {
27074 result.streetName = component.short_name;
27075 } else if (component.types.indexOf("neighborhood") >= 0) {
27076 result.city = component.short_name;
27077 } else if (component.types.indexOf("locality") >= 0) {
27078 result.city = component.short_name;
27079 } else if (component.types.indexOf("sublocality") >= 0) {
27080 result.district = component.short_name;
27081 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27082 result.stateOrProvince = component.short_name;
27083 } else if (component.types.indexOf("country") >= 0) {
27084 result.country = component.short_name;
27088 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27089 result.addressLine2 = "";
27093 setZoomLevel: function(zoom)
27095 this.gMapContext.map.setZoom(zoom);
27108 this.fireEvent('show', this);
27119 this.fireEvent('hide', this);
27124 Roo.apply(Roo.bootstrap.LocationPicker, {
27126 OverlayView : function(map, options)
27128 options = options || {};
27142 * @class Roo.bootstrap.Alert
27143 * @extends Roo.bootstrap.Component
27144 * Bootstrap Alert class
27145 * @cfg {String} title The title of alert
27146 * @cfg {String} html The content of alert
27147 * @cfg {String} weight ( success | info | warning | danger )
27148 * @cfg {String} faicon font-awesomeicon
27151 * Create a new alert
27152 * @param {Object} config The config object
27156 Roo.bootstrap.Alert = function(config){
27157 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27161 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27168 getAutoCreate : function()
27177 cls : 'roo-alert-icon'
27182 cls : 'roo-alert-title',
27187 cls : 'roo-alert-text',
27194 cfg.cn[0].cls += ' fa ' + this.faicon;
27198 cfg.cls += ' alert-' + this.weight;
27204 initEvents: function()
27206 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27209 setTitle : function(str)
27211 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27214 setText : function(str)
27216 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27219 setWeight : function(weight)
27222 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27225 this.weight = weight;
27227 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27230 setIcon : function(icon)
27233 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27236 this.faicon = icon;
27238 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27259 * @class Roo.bootstrap.UploadCropbox
27260 * @extends Roo.bootstrap.Component
27261 * Bootstrap UploadCropbox class
27262 * @cfg {String} emptyText show when image has been loaded
27263 * @cfg {String} rotateNotify show when image too small to rotate
27264 * @cfg {Number} errorTimeout default 3000
27265 * @cfg {Number} minWidth default 300
27266 * @cfg {Number} minHeight default 300
27267 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27268 * @cfg {Boolean} isDocument (true|false) default false
27269 * @cfg {String} url action url
27270 * @cfg {String} paramName default 'imageUpload'
27271 * @cfg {String} method default POST
27272 * @cfg {Boolean} loadMask (true|false) default true
27273 * @cfg {Boolean} loadingText default 'Loading...'
27276 * Create a new UploadCropbox
27277 * @param {Object} config The config object
27280 Roo.bootstrap.UploadCropbox = function(config){
27281 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27285 * @event beforeselectfile
27286 * Fire before select file
27287 * @param {Roo.bootstrap.UploadCropbox} this
27289 "beforeselectfile" : true,
27292 * Fire after initEvent
27293 * @param {Roo.bootstrap.UploadCropbox} this
27298 * Fire after initEvent
27299 * @param {Roo.bootstrap.UploadCropbox} this
27300 * @param {String} data
27305 * Fire when preparing the file data
27306 * @param {Roo.bootstrap.UploadCropbox} this
27307 * @param {Object} file
27312 * Fire when get exception
27313 * @param {Roo.bootstrap.UploadCropbox} this
27314 * @param {XMLHttpRequest} xhr
27316 "exception" : true,
27318 * @event beforeloadcanvas
27319 * Fire before load the canvas
27320 * @param {Roo.bootstrap.UploadCropbox} this
27321 * @param {String} src
27323 "beforeloadcanvas" : true,
27326 * Fire when trash image
27327 * @param {Roo.bootstrap.UploadCropbox} this
27332 * Fire when download the image
27333 * @param {Roo.bootstrap.UploadCropbox} this
27337 * @event footerbuttonclick
27338 * Fire when footerbuttonclick
27339 * @param {Roo.bootstrap.UploadCropbox} this
27340 * @param {String} type
27342 "footerbuttonclick" : true,
27346 * @param {Roo.bootstrap.UploadCropbox} this
27351 * Fire when rotate the image
27352 * @param {Roo.bootstrap.UploadCropbox} this
27353 * @param {String} pos
27358 * Fire when inspect the file
27359 * @param {Roo.bootstrap.UploadCropbox} this
27360 * @param {Object} file
27365 * Fire when xhr upload the file
27366 * @param {Roo.bootstrap.UploadCropbox} this
27367 * @param {Object} data
27372 * Fire when arrange the file data
27373 * @param {Roo.bootstrap.UploadCropbox} this
27374 * @param {Object} formData
27379 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27382 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27384 emptyText : 'Click to upload image',
27385 rotateNotify : 'Image is too small to rotate',
27386 errorTimeout : 3000,
27400 cropType : 'image/jpeg',
27402 canvasLoaded : false,
27403 isDocument : false,
27405 paramName : 'imageUpload',
27407 loadingText : 'Loading...',
27410 getAutoCreate : function()
27414 cls : 'roo-upload-cropbox',
27418 cls : 'roo-upload-cropbox-selector',
27423 cls : 'roo-upload-cropbox-body',
27424 style : 'cursor:pointer',
27428 cls : 'roo-upload-cropbox-preview'
27432 cls : 'roo-upload-cropbox-thumb'
27436 cls : 'roo-upload-cropbox-empty-notify',
27437 html : this.emptyText
27441 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27442 html : this.rotateNotify
27448 cls : 'roo-upload-cropbox-footer',
27451 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27461 onRender : function(ct, position)
27463 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27465 if (this.buttons.length) {
27467 Roo.each(this.buttons, function(bb) {
27469 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27471 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27477 this.maskEl = this.el;
27481 initEvents : function()
27483 this.urlAPI = (window.createObjectURL && window) ||
27484 (window.URL && URL.revokeObjectURL && URL) ||
27485 (window.webkitURL && webkitURL);
27487 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27488 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27490 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27491 this.selectorEl.hide();
27493 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27494 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27496 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27497 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27498 this.thumbEl.hide();
27500 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27501 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27503 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27504 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27505 this.errorEl.hide();
27507 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27508 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27509 this.footerEl.hide();
27511 this.setThumbBoxSize();
27517 this.fireEvent('initial', this);
27524 window.addEventListener("resize", function() { _this.resize(); } );
27526 this.bodyEl.on('click', this.beforeSelectFile, this);
27529 this.bodyEl.on('touchstart', this.onTouchStart, this);
27530 this.bodyEl.on('touchmove', this.onTouchMove, this);
27531 this.bodyEl.on('touchend', this.onTouchEnd, this);
27535 this.bodyEl.on('mousedown', this.onMouseDown, this);
27536 this.bodyEl.on('mousemove', this.onMouseMove, this);
27537 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27538 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27539 Roo.get(document).on('mouseup', this.onMouseUp, this);
27542 this.selectorEl.on('change', this.onFileSelected, this);
27548 this.baseScale = 1;
27550 this.baseRotate = 1;
27551 this.dragable = false;
27552 this.pinching = false;
27555 this.cropData = false;
27556 this.notifyEl.dom.innerHTML = this.emptyText;
27558 this.selectorEl.dom.value = '';
27562 resize : function()
27564 if(this.fireEvent('resize', this) != false){
27565 this.setThumbBoxPosition();
27566 this.setCanvasPosition();
27570 onFooterButtonClick : function(e, el, o, type)
27573 case 'rotate-left' :
27574 this.onRotateLeft(e);
27576 case 'rotate-right' :
27577 this.onRotateRight(e);
27580 this.beforeSelectFile(e);
27595 this.fireEvent('footerbuttonclick', this, type);
27598 beforeSelectFile : function(e)
27600 e.preventDefault();
27602 if(this.fireEvent('beforeselectfile', this) != false){
27603 this.selectorEl.dom.click();
27607 onFileSelected : function(e)
27609 e.preventDefault();
27611 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27615 var file = this.selectorEl.dom.files[0];
27617 if(this.fireEvent('inspect', this, file) != false){
27618 this.prepare(file);
27623 trash : function(e)
27625 this.fireEvent('trash', this);
27628 download : function(e)
27630 this.fireEvent('download', this);
27633 loadCanvas : function(src)
27635 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27639 this.imageEl = document.createElement('img');
27643 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27645 this.imageEl.src = src;
27649 onLoadCanvas : function()
27651 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27652 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27654 this.bodyEl.un('click', this.beforeSelectFile, this);
27656 this.notifyEl.hide();
27657 this.thumbEl.show();
27658 this.footerEl.show();
27660 this.baseRotateLevel();
27662 if(this.isDocument){
27663 this.setThumbBoxSize();
27666 this.setThumbBoxPosition();
27668 this.baseScaleLevel();
27674 this.canvasLoaded = true;
27677 this.maskEl.unmask();
27682 setCanvasPosition : function()
27684 if(!this.canvasEl){
27688 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27689 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27691 this.previewEl.setLeft(pw);
27692 this.previewEl.setTop(ph);
27696 onMouseDown : function(e)
27700 this.dragable = true;
27701 this.pinching = false;
27703 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27704 this.dragable = false;
27708 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27709 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27713 onMouseMove : function(e)
27717 if(!this.canvasLoaded){
27721 if (!this.dragable){
27725 var minX = Math.ceil(this.thumbEl.getLeft(true));
27726 var minY = Math.ceil(this.thumbEl.getTop(true));
27728 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27729 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27731 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27732 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27734 x = x - this.mouseX;
27735 y = y - this.mouseY;
27737 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27738 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27740 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27741 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27743 this.previewEl.setLeft(bgX);
27744 this.previewEl.setTop(bgY);
27746 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27747 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27750 onMouseUp : function(e)
27754 this.dragable = false;
27757 onMouseWheel : function(e)
27761 this.startScale = this.scale;
27763 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27765 if(!this.zoomable()){
27766 this.scale = this.startScale;
27775 zoomable : function()
27777 var minScale = this.thumbEl.getWidth() / this.minWidth;
27779 if(this.minWidth < this.minHeight){
27780 minScale = this.thumbEl.getHeight() / this.minHeight;
27783 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27784 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27788 (this.rotate == 0 || this.rotate == 180) &&
27790 width > this.imageEl.OriginWidth ||
27791 height > this.imageEl.OriginHeight ||
27792 (width < this.minWidth && height < this.minHeight)
27800 (this.rotate == 90 || this.rotate == 270) &&
27802 width > this.imageEl.OriginWidth ||
27803 height > this.imageEl.OriginHeight ||
27804 (width < this.minHeight && height < this.minWidth)
27811 !this.isDocument &&
27812 (this.rotate == 0 || this.rotate == 180) &&
27814 width < this.minWidth ||
27815 width > this.imageEl.OriginWidth ||
27816 height < this.minHeight ||
27817 height > this.imageEl.OriginHeight
27824 !this.isDocument &&
27825 (this.rotate == 90 || this.rotate == 270) &&
27827 width < this.minHeight ||
27828 width > this.imageEl.OriginWidth ||
27829 height < this.minWidth ||
27830 height > this.imageEl.OriginHeight
27840 onRotateLeft : function(e)
27842 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27844 var minScale = this.thumbEl.getWidth() / this.minWidth;
27846 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27847 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27849 this.startScale = this.scale;
27851 while (this.getScaleLevel() < minScale){
27853 this.scale = this.scale + 1;
27855 if(!this.zoomable()){
27860 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27861 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27866 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27873 this.scale = this.startScale;
27875 this.onRotateFail();
27880 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27882 if(this.isDocument){
27883 this.setThumbBoxSize();
27884 this.setThumbBoxPosition();
27885 this.setCanvasPosition();
27890 this.fireEvent('rotate', this, 'left');
27894 onRotateRight : function(e)
27896 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27898 var minScale = this.thumbEl.getWidth() / this.minWidth;
27900 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27901 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27903 this.startScale = this.scale;
27905 while (this.getScaleLevel() < minScale){
27907 this.scale = this.scale + 1;
27909 if(!this.zoomable()){
27914 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27915 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27920 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27927 this.scale = this.startScale;
27929 this.onRotateFail();
27934 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27936 if(this.isDocument){
27937 this.setThumbBoxSize();
27938 this.setThumbBoxPosition();
27939 this.setCanvasPosition();
27944 this.fireEvent('rotate', this, 'right');
27947 onRotateFail : function()
27949 this.errorEl.show(true);
27953 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27958 this.previewEl.dom.innerHTML = '';
27960 var canvasEl = document.createElement("canvas");
27962 var contextEl = canvasEl.getContext("2d");
27964 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27965 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27966 var center = this.imageEl.OriginWidth / 2;
27968 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27969 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27970 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27971 center = this.imageEl.OriginHeight / 2;
27974 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27976 contextEl.translate(center, center);
27977 contextEl.rotate(this.rotate * Math.PI / 180);
27979 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27981 this.canvasEl = document.createElement("canvas");
27983 this.contextEl = this.canvasEl.getContext("2d");
27985 switch (this.rotate) {
27988 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27989 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27991 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27996 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27997 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27999 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28000 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);
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.OriginWidth * this.getScaleLevel();
28010 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28012 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28013 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);
28017 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);
28022 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28023 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28025 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28026 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28030 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);
28037 this.previewEl.appendChild(this.canvasEl);
28039 this.setCanvasPosition();
28044 if(!this.canvasLoaded){
28048 var imageCanvas = document.createElement("canvas");
28050 var imageContext = imageCanvas.getContext("2d");
28052 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28053 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28055 var center = imageCanvas.width / 2;
28057 imageContext.translate(center, center);
28059 imageContext.rotate(this.rotate * Math.PI / 180);
28061 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28063 var canvas = document.createElement("canvas");
28065 var context = canvas.getContext("2d");
28067 canvas.width = this.minWidth;
28068 canvas.height = this.minHeight;
28070 switch (this.rotate) {
28073 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28074 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28076 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28077 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28079 var targetWidth = this.minWidth - 2 * x;
28080 var targetHeight = this.minHeight - 2 * y;
28084 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28085 scale = targetWidth / width;
28088 if(x > 0 && y == 0){
28089 scale = targetHeight / height;
28092 if(x > 0 && y > 0){
28093 scale = targetWidth / width;
28095 if(width < height){
28096 scale = targetHeight / height;
28100 context.scale(scale, scale);
28102 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28103 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28105 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28106 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28108 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28113 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28114 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28116 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28117 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28119 var targetWidth = this.minWidth - 2 * x;
28120 var targetHeight = this.minHeight - 2 * y;
28124 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28125 scale = targetWidth / width;
28128 if(x > 0 && y == 0){
28129 scale = targetHeight / height;
28132 if(x > 0 && y > 0){
28133 scale = targetWidth / width;
28135 if(width < height){
28136 scale = targetHeight / height;
28140 context.scale(scale, scale);
28142 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28143 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28145 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28146 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28148 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28150 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28155 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28156 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28158 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28159 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28161 var targetWidth = this.minWidth - 2 * x;
28162 var targetHeight = this.minHeight - 2 * y;
28166 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28167 scale = targetWidth / width;
28170 if(x > 0 && y == 0){
28171 scale = targetHeight / height;
28174 if(x > 0 && y > 0){
28175 scale = targetWidth / width;
28177 if(width < height){
28178 scale = targetHeight / height;
28182 context.scale(scale, scale);
28184 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28185 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28187 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28188 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28190 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28191 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28193 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28198 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28199 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28201 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28202 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28204 var targetWidth = this.minWidth - 2 * x;
28205 var targetHeight = this.minHeight - 2 * y;
28209 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28210 scale = targetWidth / width;
28213 if(x > 0 && y == 0){
28214 scale = targetHeight / height;
28217 if(x > 0 && y > 0){
28218 scale = targetWidth / width;
28220 if(width < height){
28221 scale = targetHeight / height;
28225 context.scale(scale, scale);
28227 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28228 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28230 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28231 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28233 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28235 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28242 this.cropData = canvas.toDataURL(this.cropType);
28244 if(this.fireEvent('crop', this, this.cropData) !== false){
28245 this.process(this.file, this.cropData);
28252 setThumbBoxSize : function()
28256 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28257 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28258 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28260 this.minWidth = width;
28261 this.minHeight = height;
28263 if(this.rotate == 90 || this.rotate == 270){
28264 this.minWidth = height;
28265 this.minHeight = width;
28270 width = Math.ceil(this.minWidth * height / this.minHeight);
28272 if(this.minWidth > this.minHeight){
28274 height = Math.ceil(this.minHeight * width / this.minWidth);
28277 this.thumbEl.setStyle({
28278 width : width + 'px',
28279 height : height + 'px'
28286 setThumbBoxPosition : function()
28288 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28289 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28291 this.thumbEl.setLeft(x);
28292 this.thumbEl.setTop(y);
28296 baseRotateLevel : function()
28298 this.baseRotate = 1;
28301 typeof(this.exif) != 'undefined' &&
28302 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28303 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28305 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28308 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28312 baseScaleLevel : function()
28316 if(this.isDocument){
28318 if(this.baseRotate == 6 || this.baseRotate == 8){
28320 height = this.thumbEl.getHeight();
28321 this.baseScale = height / this.imageEl.OriginWidth;
28323 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28324 width = this.thumbEl.getWidth();
28325 this.baseScale = width / this.imageEl.OriginHeight;
28331 height = this.thumbEl.getHeight();
28332 this.baseScale = height / this.imageEl.OriginHeight;
28334 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28335 width = this.thumbEl.getWidth();
28336 this.baseScale = width / this.imageEl.OriginWidth;
28342 if(this.baseRotate == 6 || this.baseRotate == 8){
28344 width = this.thumbEl.getHeight();
28345 this.baseScale = width / this.imageEl.OriginHeight;
28347 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28348 height = this.thumbEl.getWidth();
28349 this.baseScale = height / this.imageEl.OriginHeight;
28352 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28353 height = this.thumbEl.getWidth();
28354 this.baseScale = height / this.imageEl.OriginHeight;
28356 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28357 width = this.thumbEl.getHeight();
28358 this.baseScale = width / this.imageEl.OriginWidth;
28365 width = this.thumbEl.getWidth();
28366 this.baseScale = width / this.imageEl.OriginWidth;
28368 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28369 height = this.thumbEl.getHeight();
28370 this.baseScale = height / this.imageEl.OriginHeight;
28373 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28375 height = this.thumbEl.getHeight();
28376 this.baseScale = height / this.imageEl.OriginHeight;
28378 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28379 width = this.thumbEl.getWidth();
28380 this.baseScale = width / this.imageEl.OriginWidth;
28388 getScaleLevel : function()
28390 return this.baseScale * Math.pow(1.1, this.scale);
28393 onTouchStart : function(e)
28395 if(!this.canvasLoaded){
28396 this.beforeSelectFile(e);
28400 var touches = e.browserEvent.touches;
28406 if(touches.length == 1){
28407 this.onMouseDown(e);
28411 if(touches.length != 2){
28417 for(var i = 0, finger; finger = touches[i]; i++){
28418 coords.push(finger.pageX, finger.pageY);
28421 var x = Math.pow(coords[0] - coords[2], 2);
28422 var y = Math.pow(coords[1] - coords[3], 2);
28424 this.startDistance = Math.sqrt(x + y);
28426 this.startScale = this.scale;
28428 this.pinching = true;
28429 this.dragable = false;
28433 onTouchMove : function(e)
28435 if(!this.pinching && !this.dragable){
28439 var touches = e.browserEvent.touches;
28446 this.onMouseMove(e);
28452 for(var i = 0, finger; finger = touches[i]; i++){
28453 coords.push(finger.pageX, finger.pageY);
28456 var x = Math.pow(coords[0] - coords[2], 2);
28457 var y = Math.pow(coords[1] - coords[3], 2);
28459 this.endDistance = Math.sqrt(x + y);
28461 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28463 if(!this.zoomable()){
28464 this.scale = this.startScale;
28472 onTouchEnd : function(e)
28474 this.pinching = false;
28475 this.dragable = false;
28479 process : function(file, crop)
28482 this.maskEl.mask(this.loadingText);
28485 this.xhr = new XMLHttpRequest();
28487 file.xhr = this.xhr;
28489 this.xhr.open(this.method, this.url, true);
28492 "Accept": "application/json",
28493 "Cache-Control": "no-cache",
28494 "X-Requested-With": "XMLHttpRequest"
28497 for (var headerName in headers) {
28498 var headerValue = headers[headerName];
28500 this.xhr.setRequestHeader(headerName, headerValue);
28506 this.xhr.onload = function()
28508 _this.xhrOnLoad(_this.xhr);
28511 this.xhr.onerror = function()
28513 _this.xhrOnError(_this.xhr);
28516 var formData = new FormData();
28518 formData.append('returnHTML', 'NO');
28521 formData.append('crop', crop);
28524 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28525 formData.append(this.paramName, file, file.name);
28528 if(typeof(file.filename) != 'undefined'){
28529 formData.append('filename', file.filename);
28532 if(typeof(file.mimetype) != 'undefined'){
28533 formData.append('mimetype', file.mimetype);
28536 if(this.fireEvent('arrange', this, formData) != false){
28537 this.xhr.send(formData);
28541 xhrOnLoad : function(xhr)
28544 this.maskEl.unmask();
28547 if (xhr.readyState !== 4) {
28548 this.fireEvent('exception', this, xhr);
28552 var response = Roo.decode(xhr.responseText);
28554 if(!response.success){
28555 this.fireEvent('exception', this, xhr);
28559 var response = Roo.decode(xhr.responseText);
28561 this.fireEvent('upload', this, response);
28565 xhrOnError : function()
28568 this.maskEl.unmask();
28571 Roo.log('xhr on error');
28573 var response = Roo.decode(xhr.responseText);
28579 prepare : function(file)
28582 this.maskEl.mask(this.loadingText);
28588 if(typeof(file) === 'string'){
28589 this.loadCanvas(file);
28593 if(!file || !this.urlAPI){
28598 this.cropType = file.type;
28602 if(this.fireEvent('prepare', this, this.file) != false){
28604 var reader = new FileReader();
28606 reader.onload = function (e) {
28607 if (e.target.error) {
28608 Roo.log(e.target.error);
28612 var buffer = e.target.result,
28613 dataView = new DataView(buffer),
28615 maxOffset = dataView.byteLength - 4,
28619 if (dataView.getUint16(0) === 0xffd8) {
28620 while (offset < maxOffset) {
28621 markerBytes = dataView.getUint16(offset);
28623 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28624 markerLength = dataView.getUint16(offset + 2) + 2;
28625 if (offset + markerLength > dataView.byteLength) {
28626 Roo.log('Invalid meta data: Invalid segment size.');
28630 if(markerBytes == 0xffe1){
28631 _this.parseExifData(
28638 offset += markerLength;
28648 var url = _this.urlAPI.createObjectURL(_this.file);
28650 _this.loadCanvas(url);
28655 reader.readAsArrayBuffer(this.file);
28661 parseExifData : function(dataView, offset, length)
28663 var tiffOffset = offset + 10,
28667 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28668 // No Exif data, might be XMP data instead
28672 // Check for the ASCII code for "Exif" (0x45786966):
28673 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28674 // No Exif data, might be XMP data instead
28677 if (tiffOffset + 8 > dataView.byteLength) {
28678 Roo.log('Invalid Exif data: Invalid segment size.');
28681 // Check for the two null bytes:
28682 if (dataView.getUint16(offset + 8) !== 0x0000) {
28683 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28686 // Check the byte alignment:
28687 switch (dataView.getUint16(tiffOffset)) {
28689 littleEndian = true;
28692 littleEndian = false;
28695 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28698 // Check for the TIFF tag marker (0x002A):
28699 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28700 Roo.log('Invalid Exif data: Missing TIFF marker.');
28703 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28704 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28706 this.parseExifTags(
28709 tiffOffset + dirOffset,
28714 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28719 if (dirOffset + 6 > dataView.byteLength) {
28720 Roo.log('Invalid Exif data: Invalid directory offset.');
28723 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28724 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28725 if (dirEndOffset + 4 > dataView.byteLength) {
28726 Roo.log('Invalid Exif data: Invalid directory size.');
28729 for (i = 0; i < tagsNumber; i += 1) {
28733 dirOffset + 2 + 12 * i, // tag offset
28737 // Return the offset to the next directory:
28738 return dataView.getUint32(dirEndOffset, littleEndian);
28741 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28743 var tag = dataView.getUint16(offset, littleEndian);
28745 this.exif[tag] = this.getExifValue(
28749 dataView.getUint16(offset + 2, littleEndian), // tag type
28750 dataView.getUint32(offset + 4, littleEndian), // tag length
28755 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28757 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28766 Roo.log('Invalid Exif data: Invalid tag type.');
28770 tagSize = tagType.size * length;
28771 // Determine if the value is contained in the dataOffset bytes,
28772 // or if the value at the dataOffset is a pointer to the actual data:
28773 dataOffset = tagSize > 4 ?
28774 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28775 if (dataOffset + tagSize > dataView.byteLength) {
28776 Roo.log('Invalid Exif data: Invalid data offset.');
28779 if (length === 1) {
28780 return tagType.getValue(dataView, dataOffset, littleEndian);
28783 for (i = 0; i < length; i += 1) {
28784 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28787 if (tagType.ascii) {
28789 // Concatenate the chars:
28790 for (i = 0; i < values.length; i += 1) {
28792 // Ignore the terminating NULL byte(s):
28793 if (c === '\u0000') {
28805 Roo.apply(Roo.bootstrap.UploadCropbox, {
28807 'Orientation': 0x0112
28811 1: 0, //'top-left',
28813 3: 180, //'bottom-right',
28814 // 4: 'bottom-left',
28816 6: 90, //'right-top',
28817 // 7: 'right-bottom',
28818 8: 270 //'left-bottom'
28822 // byte, 8-bit unsigned int:
28824 getValue: function (dataView, dataOffset) {
28825 return dataView.getUint8(dataOffset);
28829 // ascii, 8-bit byte:
28831 getValue: function (dataView, dataOffset) {
28832 return String.fromCharCode(dataView.getUint8(dataOffset));
28837 // short, 16 bit int:
28839 getValue: function (dataView, dataOffset, littleEndian) {
28840 return dataView.getUint16(dataOffset, littleEndian);
28844 // long, 32 bit int:
28846 getValue: function (dataView, dataOffset, littleEndian) {
28847 return dataView.getUint32(dataOffset, littleEndian);
28851 // rational = two long values, first is numerator, second is denominator:
28853 getValue: function (dataView, dataOffset, littleEndian) {
28854 return dataView.getUint32(dataOffset, littleEndian) /
28855 dataView.getUint32(dataOffset + 4, littleEndian);
28859 // slong, 32 bit signed int:
28861 getValue: function (dataView, dataOffset, littleEndian) {
28862 return dataView.getInt32(dataOffset, littleEndian);
28866 // srational, two slongs, first is numerator, second is denominator:
28868 getValue: function (dataView, dataOffset, littleEndian) {
28869 return dataView.getInt32(dataOffset, littleEndian) /
28870 dataView.getInt32(dataOffset + 4, littleEndian);
28880 cls : 'btn-group roo-upload-cropbox-rotate-left',
28881 action : 'rotate-left',
28885 cls : 'btn btn-default',
28886 html : '<i class="fa fa-undo"></i>'
28892 cls : 'btn-group roo-upload-cropbox-picture',
28893 action : 'picture',
28897 cls : 'btn btn-default',
28898 html : '<i class="fa fa-picture-o"></i>'
28904 cls : 'btn-group roo-upload-cropbox-rotate-right',
28905 action : 'rotate-right',
28909 cls : 'btn btn-default',
28910 html : '<i class="fa fa-repeat"></i>'
28918 cls : 'btn-group roo-upload-cropbox-rotate-left',
28919 action : 'rotate-left',
28923 cls : 'btn btn-default',
28924 html : '<i class="fa fa-undo"></i>'
28930 cls : 'btn-group roo-upload-cropbox-download',
28931 action : 'download',
28935 cls : 'btn btn-default',
28936 html : '<i class="fa fa-download"></i>'
28942 cls : 'btn-group roo-upload-cropbox-crop',
28947 cls : 'btn btn-default',
28948 html : '<i class="fa fa-crop"></i>'
28954 cls : 'btn-group roo-upload-cropbox-trash',
28959 cls : 'btn btn-default',
28960 html : '<i class="fa fa-trash"></i>'
28966 cls : 'btn-group roo-upload-cropbox-rotate-right',
28967 action : 'rotate-right',
28971 cls : 'btn btn-default',
28972 html : '<i class="fa fa-repeat"></i>'
28980 cls : 'btn-group roo-upload-cropbox-rotate-left',
28981 action : 'rotate-left',
28985 cls : 'btn btn-default',
28986 html : '<i class="fa fa-undo"></i>'
28992 cls : 'btn-group roo-upload-cropbox-rotate-right',
28993 action : 'rotate-right',
28997 cls : 'btn btn-default',
28998 html : '<i class="fa fa-repeat"></i>'
29011 * @class Roo.bootstrap.DocumentManager
29012 * @extends Roo.bootstrap.Component
29013 * Bootstrap DocumentManager class
29014 * @cfg {String} paramName default 'imageUpload'
29015 * @cfg {String} toolTipName default 'filename'
29016 * @cfg {String} method default POST
29017 * @cfg {String} url action url
29018 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29019 * @cfg {Boolean} multiple multiple upload default true
29020 * @cfg {Number} thumbSize default 300
29021 * @cfg {String} fieldLabel
29022 * @cfg {Number} labelWidth default 4
29023 * @cfg {String} labelAlign (left|top) default left
29024 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29025 * @cfg {Number} labellg set the width of label (1-12)
29026 * @cfg {Number} labelmd set the width of label (1-12)
29027 * @cfg {Number} labelsm set the width of label (1-12)
29028 * @cfg {Number} labelxs set the width of label (1-12)
29031 * Create a new DocumentManager
29032 * @param {Object} config The config object
29035 Roo.bootstrap.DocumentManager = function(config){
29036 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29039 this.delegates = [];
29044 * Fire when initial the DocumentManager
29045 * @param {Roo.bootstrap.DocumentManager} this
29050 * inspect selected file
29051 * @param {Roo.bootstrap.DocumentManager} this
29052 * @param {File} file
29057 * Fire when xhr load exception
29058 * @param {Roo.bootstrap.DocumentManager} this
29059 * @param {XMLHttpRequest} xhr
29061 "exception" : true,
29063 * @event afterupload
29064 * Fire when xhr load exception
29065 * @param {Roo.bootstrap.DocumentManager} this
29066 * @param {XMLHttpRequest} xhr
29068 "afterupload" : true,
29071 * prepare the form data
29072 * @param {Roo.bootstrap.DocumentManager} this
29073 * @param {Object} formData
29078 * Fire when remove the file
29079 * @param {Roo.bootstrap.DocumentManager} this
29080 * @param {Object} file
29085 * Fire after refresh the file
29086 * @param {Roo.bootstrap.DocumentManager} this
29091 * Fire after click the image
29092 * @param {Roo.bootstrap.DocumentManager} this
29093 * @param {Object} file
29098 * Fire when upload a image and editable set to true
29099 * @param {Roo.bootstrap.DocumentManager} this
29100 * @param {Object} file
29104 * @event beforeselectfile
29105 * Fire before select file
29106 * @param {Roo.bootstrap.DocumentManager} this
29108 "beforeselectfile" : true,
29111 * Fire before process file
29112 * @param {Roo.bootstrap.DocumentManager} this
29113 * @param {Object} file
29117 * @event previewrendered
29118 * Fire when preview rendered
29119 * @param {Roo.bootstrap.DocumentManager} this
29120 * @param {Object} file
29122 "previewrendered" : true,
29125 "previewResize" : true
29130 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29139 paramName : 'imageUpload',
29140 toolTipName : 'filename',
29143 labelAlign : 'left',
29153 getAutoCreate : function()
29155 var managerWidget = {
29157 cls : 'roo-document-manager',
29161 cls : 'roo-document-manager-selector',
29166 cls : 'roo-document-manager-uploader',
29170 cls : 'roo-document-manager-upload-btn',
29171 html : '<i class="fa fa-plus"></i>'
29182 cls : 'column col-md-12',
29187 if(this.fieldLabel.length){
29192 cls : 'column col-md-12',
29193 html : this.fieldLabel
29197 cls : 'column col-md-12',
29202 if(this.labelAlign == 'left'){
29207 html : this.fieldLabel
29216 if(this.labelWidth > 12){
29217 content[0].style = "width: " + this.labelWidth + 'px';
29220 if(this.labelWidth < 13 && this.labelmd == 0){
29221 this.labelmd = this.labelWidth;
29224 if(this.labellg > 0){
29225 content[0].cls += ' col-lg-' + this.labellg;
29226 content[1].cls += ' col-lg-' + (12 - this.labellg);
29229 if(this.labelmd > 0){
29230 content[0].cls += ' col-md-' + this.labelmd;
29231 content[1].cls += ' col-md-' + (12 - this.labelmd);
29234 if(this.labelsm > 0){
29235 content[0].cls += ' col-sm-' + this.labelsm;
29236 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29239 if(this.labelxs > 0){
29240 content[0].cls += ' col-xs-' + this.labelxs;
29241 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29249 cls : 'row clearfix',
29257 initEvents : function()
29259 this.managerEl = this.el.select('.roo-document-manager', true).first();
29260 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29262 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29263 this.selectorEl.hide();
29266 this.selectorEl.attr('multiple', 'multiple');
29269 this.selectorEl.on('change', this.onFileSelected, this);
29271 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29272 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29274 this.uploader.on('click', this.onUploaderClick, this);
29276 this.renderProgressDialog();
29280 window.addEventListener("resize", function() { _this.refresh(); } );
29282 this.fireEvent('initial', this);
29285 renderProgressDialog : function()
29289 this.progressDialog = new Roo.bootstrap.Modal({
29290 cls : 'roo-document-manager-progress-dialog',
29291 allow_close : false,
29302 btnclick : function() {
29303 _this.uploadCancel();
29309 this.progressDialog.render(Roo.get(document.body));
29311 this.progress = new Roo.bootstrap.Progress({
29312 cls : 'roo-document-manager-progress',
29317 this.progress.render(this.progressDialog.getChildContainer());
29319 this.progressBar = new Roo.bootstrap.ProgressBar({
29320 cls : 'roo-document-manager-progress-bar',
29323 aria_valuemax : 12,
29327 this.progressBar.render(this.progress.getChildContainer());
29330 onUploaderClick : function(e)
29332 e.preventDefault();
29334 if(this.fireEvent('beforeselectfile', this) != false){
29335 this.selectorEl.dom.click();
29340 onFileSelected : function(e)
29342 e.preventDefault();
29344 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29348 Roo.each(this.selectorEl.dom.files, function(file){
29349 if(this.fireEvent('inspect', this, file) != false){
29350 this.files.push(file);
29360 this.selectorEl.dom.value = '';
29362 if(!this.files || !this.files.length){
29366 if(this.boxes > 0 && this.files.length > this.boxes){
29367 this.files = this.files.slice(0, this.boxes);
29370 this.uploader.show();
29372 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29373 this.uploader.hide();
29382 Roo.each(this.files, function(file){
29384 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29385 var f = this.renderPreview(file);
29390 if(file.type.indexOf('image') != -1){
29391 this.delegates.push(
29393 _this.process(file);
29394 }).createDelegate(this)
29402 _this.process(file);
29403 }).createDelegate(this)
29408 this.files = files;
29410 this.delegates = this.delegates.concat(docs);
29412 if(!this.delegates.length){
29417 this.progressBar.aria_valuemax = this.delegates.length;
29424 arrange : function()
29426 if(!this.delegates.length){
29427 this.progressDialog.hide();
29432 var delegate = this.delegates.shift();
29434 this.progressDialog.show();
29436 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29438 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29443 refresh : function()
29445 this.uploader.show();
29447 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29448 this.uploader.hide();
29451 Roo.isTouch ? this.closable(false) : this.closable(true);
29453 this.fireEvent('refresh', this);
29456 onRemove : function(e, el, o)
29458 e.preventDefault();
29460 this.fireEvent('remove', this, o);
29464 remove : function(o)
29468 Roo.each(this.files, function(file){
29469 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29478 this.files = files;
29485 Roo.each(this.files, function(file){
29490 file.target.remove();
29499 onClick : function(e, el, o)
29501 e.preventDefault();
29503 this.fireEvent('click', this, o);
29507 closable : function(closable)
29509 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29511 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29523 xhrOnLoad : function(xhr)
29525 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29529 if (xhr.readyState !== 4) {
29531 this.fireEvent('exception', this, xhr);
29535 var response = Roo.decode(xhr.responseText);
29537 if(!response.success){
29539 this.fireEvent('exception', this, xhr);
29543 var file = this.renderPreview(response.data);
29545 this.files.push(file);
29549 this.fireEvent('afterupload', this, xhr);
29553 xhrOnError : function(xhr)
29555 Roo.log('xhr on error');
29557 var response = Roo.decode(xhr.responseText);
29564 process : function(file)
29566 if(this.fireEvent('process', this, file) !== false){
29567 if(this.editable && file.type.indexOf('image') != -1){
29568 this.fireEvent('edit', this, file);
29572 this.uploadStart(file, false);
29579 uploadStart : function(file, crop)
29581 this.xhr = new XMLHttpRequest();
29583 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29588 file.xhr = this.xhr;
29590 this.managerEl.createChild({
29592 cls : 'roo-document-manager-loading',
29596 tooltip : file.name,
29597 cls : 'roo-document-manager-thumb',
29598 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29604 this.xhr.open(this.method, this.url, true);
29607 "Accept": "application/json",
29608 "Cache-Control": "no-cache",
29609 "X-Requested-With": "XMLHttpRequest"
29612 for (var headerName in headers) {
29613 var headerValue = headers[headerName];
29615 this.xhr.setRequestHeader(headerName, headerValue);
29621 this.xhr.onload = function()
29623 _this.xhrOnLoad(_this.xhr);
29626 this.xhr.onerror = function()
29628 _this.xhrOnError(_this.xhr);
29631 var formData = new FormData();
29633 formData.append('returnHTML', 'NO');
29636 formData.append('crop', crop);
29639 formData.append(this.paramName, file, file.name);
29646 if(this.fireEvent('prepare', this, formData, options) != false){
29648 if(options.manually){
29652 this.xhr.send(formData);
29656 this.uploadCancel();
29659 uploadCancel : function()
29665 this.delegates = [];
29667 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29674 renderPreview : function(file)
29676 if(typeof(file.target) != 'undefined' && file.target){
29680 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29682 var previewEl = this.managerEl.createChild({
29684 cls : 'roo-document-manager-preview',
29688 tooltip : file[this.toolTipName],
29689 cls : 'roo-document-manager-thumb',
29690 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29695 html : '<i class="fa fa-times-circle"></i>'
29700 var close = previewEl.select('button.close', true).first();
29702 close.on('click', this.onRemove, this, file);
29704 file.target = previewEl;
29706 var image = previewEl.select('img', true).first();
29710 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29712 image.on('click', this.onClick, this, file);
29714 this.fireEvent('previewrendered', this, file);
29720 onPreviewLoad : function(file, image)
29722 if(typeof(file.target) == 'undefined' || !file.target){
29726 var width = image.dom.naturalWidth || image.dom.width;
29727 var height = image.dom.naturalHeight || image.dom.height;
29729 if(!this.previewResize) {
29733 if(width > height){
29734 file.target.addClass('wide');
29738 file.target.addClass('tall');
29743 uploadFromSource : function(file, crop)
29745 this.xhr = new XMLHttpRequest();
29747 this.managerEl.createChild({
29749 cls : 'roo-document-manager-loading',
29753 tooltip : file.name,
29754 cls : 'roo-document-manager-thumb',
29755 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29761 this.xhr.open(this.method, this.url, true);
29764 "Accept": "application/json",
29765 "Cache-Control": "no-cache",
29766 "X-Requested-With": "XMLHttpRequest"
29769 for (var headerName in headers) {
29770 var headerValue = headers[headerName];
29772 this.xhr.setRequestHeader(headerName, headerValue);
29778 this.xhr.onload = function()
29780 _this.xhrOnLoad(_this.xhr);
29783 this.xhr.onerror = function()
29785 _this.xhrOnError(_this.xhr);
29788 var formData = new FormData();
29790 formData.append('returnHTML', 'NO');
29792 formData.append('crop', crop);
29794 if(typeof(file.filename) != 'undefined'){
29795 formData.append('filename', file.filename);
29798 if(typeof(file.mimetype) != 'undefined'){
29799 formData.append('mimetype', file.mimetype);
29804 if(this.fireEvent('prepare', this, formData) != false){
29805 this.xhr.send(formData);
29815 * @class Roo.bootstrap.DocumentViewer
29816 * @extends Roo.bootstrap.Component
29817 * Bootstrap DocumentViewer class
29818 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29819 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29822 * Create a new DocumentViewer
29823 * @param {Object} config The config object
29826 Roo.bootstrap.DocumentViewer = function(config){
29827 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29832 * Fire after initEvent
29833 * @param {Roo.bootstrap.DocumentViewer} this
29839 * @param {Roo.bootstrap.DocumentViewer} this
29844 * Fire after download button
29845 * @param {Roo.bootstrap.DocumentViewer} this
29850 * Fire after trash button
29851 * @param {Roo.bootstrap.DocumentViewer} this
29858 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29860 showDownload : true,
29864 getAutoCreate : function()
29868 cls : 'roo-document-viewer',
29872 cls : 'roo-document-viewer-body',
29876 cls : 'roo-document-viewer-thumb',
29880 cls : 'roo-document-viewer-image'
29888 cls : 'roo-document-viewer-footer',
29891 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29895 cls : 'btn-group roo-document-viewer-download',
29899 cls : 'btn btn-default',
29900 html : '<i class="fa fa-download"></i>'
29906 cls : 'btn-group roo-document-viewer-trash',
29910 cls : 'btn btn-default',
29911 html : '<i class="fa fa-trash"></i>'
29924 initEvents : function()
29926 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29927 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29929 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29930 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29932 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29933 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29935 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29936 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29938 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29939 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29941 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29942 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29944 this.bodyEl.on('click', this.onClick, this);
29945 this.downloadBtn.on('click', this.onDownload, this);
29946 this.trashBtn.on('click', this.onTrash, this);
29948 this.downloadBtn.hide();
29949 this.trashBtn.hide();
29951 if(this.showDownload){
29952 this.downloadBtn.show();
29955 if(this.showTrash){
29956 this.trashBtn.show();
29959 if(!this.showDownload && !this.showTrash) {
29960 this.footerEl.hide();
29965 initial : function()
29967 this.fireEvent('initial', this);
29971 onClick : function(e)
29973 e.preventDefault();
29975 this.fireEvent('click', this);
29978 onDownload : function(e)
29980 e.preventDefault();
29982 this.fireEvent('download', this);
29985 onTrash : function(e)
29987 e.preventDefault();
29989 this.fireEvent('trash', this);
30001 * @class Roo.bootstrap.NavProgressBar
30002 * @extends Roo.bootstrap.Component
30003 * Bootstrap NavProgressBar class
30006 * Create a new nav progress bar
30007 * @param {Object} config The config object
30010 Roo.bootstrap.NavProgressBar = function(config){
30011 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30013 this.bullets = this.bullets || [];
30015 // Roo.bootstrap.NavProgressBar.register(this);
30019 * Fires when the active item changes
30020 * @param {Roo.bootstrap.NavProgressBar} this
30021 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30022 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30029 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30034 getAutoCreate : function()
30036 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30040 cls : 'roo-navigation-bar-group',
30044 cls : 'roo-navigation-top-bar'
30048 cls : 'roo-navigation-bullets-bar',
30052 cls : 'roo-navigation-bar'
30059 cls : 'roo-navigation-bottom-bar'
30069 initEvents: function()
30074 onRender : function(ct, position)
30076 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30078 if(this.bullets.length){
30079 Roo.each(this.bullets, function(b){
30088 addItem : function(cfg)
30090 var item = new Roo.bootstrap.NavProgressItem(cfg);
30092 item.parentId = this.id;
30093 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30096 var top = new Roo.bootstrap.Element({
30098 cls : 'roo-navigation-bar-text'
30101 var bottom = new Roo.bootstrap.Element({
30103 cls : 'roo-navigation-bar-text'
30106 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30107 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30109 var topText = new Roo.bootstrap.Element({
30111 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30114 var bottomText = new Roo.bootstrap.Element({
30116 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30119 topText.onRender(top.el, null);
30120 bottomText.onRender(bottom.el, null);
30123 item.bottomEl = bottom;
30126 this.barItems.push(item);
30131 getActive : function()
30133 var active = false;
30135 Roo.each(this.barItems, function(v){
30137 if (!v.isActive()) {
30149 setActiveItem : function(item)
30153 Roo.each(this.barItems, function(v){
30154 if (v.rid == item.rid) {
30158 if (v.isActive()) {
30159 v.setActive(false);
30164 item.setActive(true);
30166 this.fireEvent('changed', this, item, prev);
30169 getBarItem: function(rid)
30173 Roo.each(this.barItems, function(e) {
30174 if (e.rid != rid) {
30185 indexOfItem : function(item)
30189 Roo.each(this.barItems, function(v, i){
30191 if (v.rid != item.rid) {
30202 setActiveNext : function()
30204 var i = this.indexOfItem(this.getActive());
30206 if (i > this.barItems.length) {
30210 this.setActiveItem(this.barItems[i+1]);
30213 setActivePrev : function()
30215 var i = this.indexOfItem(this.getActive());
30221 this.setActiveItem(this.barItems[i-1]);
30224 format : function()
30226 if(!this.barItems.length){
30230 var width = 100 / this.barItems.length;
30232 Roo.each(this.barItems, function(i){
30233 i.el.setStyle('width', width + '%');
30234 i.topEl.el.setStyle('width', width + '%');
30235 i.bottomEl.el.setStyle('width', width + '%');
30244 * Nav Progress Item
30249 * @class Roo.bootstrap.NavProgressItem
30250 * @extends Roo.bootstrap.Component
30251 * Bootstrap NavProgressItem class
30252 * @cfg {String} rid the reference id
30253 * @cfg {Boolean} active (true|false) Is item active default false
30254 * @cfg {Boolean} disabled (true|false) Is item active default false
30255 * @cfg {String} html
30256 * @cfg {String} position (top|bottom) text position default bottom
30257 * @cfg {String} icon show icon instead of number
30260 * Create a new NavProgressItem
30261 * @param {Object} config The config object
30263 Roo.bootstrap.NavProgressItem = function(config){
30264 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30269 * The raw click event for the entire grid.
30270 * @param {Roo.bootstrap.NavProgressItem} this
30271 * @param {Roo.EventObject} e
30278 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30284 position : 'bottom',
30287 getAutoCreate : function()
30289 var iconCls = 'roo-navigation-bar-item-icon';
30291 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30295 cls: 'roo-navigation-bar-item',
30305 cfg.cls += ' active';
30308 cfg.cls += ' disabled';
30314 disable : function()
30316 this.setDisabled(true);
30319 enable : function()
30321 this.setDisabled(false);
30324 initEvents: function()
30326 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30328 this.iconEl.on('click', this.onClick, this);
30331 onClick : function(e)
30333 e.preventDefault();
30339 if(this.fireEvent('click', this, e) === false){
30343 this.parent().setActiveItem(this);
30346 isActive: function ()
30348 return this.active;
30351 setActive : function(state)
30353 if(this.active == state){
30357 this.active = state;
30360 this.el.addClass('active');
30364 this.el.removeClass('active');
30369 setDisabled : function(state)
30371 if(this.disabled == state){
30375 this.disabled = state;
30378 this.el.addClass('disabled');
30382 this.el.removeClass('disabled');
30385 tooltipEl : function()
30387 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30400 * @class Roo.bootstrap.FieldLabel
30401 * @extends Roo.bootstrap.Component
30402 * Bootstrap FieldLabel class
30403 * @cfg {String} html contents of the element
30404 * @cfg {String} tag tag of the element default label
30405 * @cfg {String} cls class of the element
30406 * @cfg {String} target label target
30407 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30408 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30409 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30410 * @cfg {String} iconTooltip default "This field is required"
30411 * @cfg {String} indicatorpos (left|right) default left
30414 * Create a new FieldLabel
30415 * @param {Object} config The config object
30418 Roo.bootstrap.FieldLabel = function(config){
30419 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30424 * Fires after the field has been marked as invalid.
30425 * @param {Roo.form.FieldLabel} this
30426 * @param {String} msg The validation message
30431 * Fires after the field has been validated with no errors.
30432 * @param {Roo.form.FieldLabel} this
30438 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30445 invalidClass : 'has-warning',
30446 validClass : 'has-success',
30447 iconTooltip : 'This field is required',
30448 indicatorpos : 'left',
30450 getAutoCreate : function(){
30453 if (!this.allowBlank) {
30459 cls : 'roo-bootstrap-field-label ' + this.cls,
30464 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30465 tooltip : this.iconTooltip
30474 if(this.indicatorpos == 'right'){
30477 cls : 'roo-bootstrap-field-label ' + this.cls,
30486 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30487 tooltip : this.iconTooltip
30496 initEvents: function()
30498 Roo.bootstrap.Element.superclass.initEvents.call(this);
30500 this.indicator = this.indicatorEl();
30502 if(this.indicator){
30503 this.indicator.removeClass('visible');
30504 this.indicator.addClass('invisible');
30507 Roo.bootstrap.FieldLabel.register(this);
30510 indicatorEl : function()
30512 var indicator = this.el.select('i.roo-required-indicator',true).first();
30523 * Mark this field as valid
30525 markValid : function()
30527 if(this.indicator){
30528 this.indicator.removeClass('visible');
30529 this.indicator.addClass('invisible');
30531 if (Roo.bootstrap.version == 3) {
30532 this.el.removeClass(this.invalidClass);
30533 this.el.addClass(this.validClass);
30535 this.el.removeClass('is-invalid');
30536 this.el.addClass('is-valid');
30540 this.fireEvent('valid', this);
30544 * Mark this field as invalid
30545 * @param {String} msg The validation message
30547 markInvalid : function(msg)
30549 if(this.indicator){
30550 this.indicator.removeClass('invisible');
30551 this.indicator.addClass('visible');
30553 if (Roo.bootstrap.version == 3) {
30554 this.el.removeClass(this.validClass);
30555 this.el.addClass(this.invalidClass);
30557 this.el.removeClass('is-valid');
30558 this.el.addClass('is-invalid');
30562 this.fireEvent('invalid', this, msg);
30568 Roo.apply(Roo.bootstrap.FieldLabel, {
30573 * register a FieldLabel Group
30574 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30576 register : function(label)
30578 if(this.groups.hasOwnProperty(label.target)){
30582 this.groups[label.target] = label;
30586 * fetch a FieldLabel Group based on the target
30587 * @param {string} target
30588 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30590 get: function(target) {
30591 if (typeof(this.groups[target]) == 'undefined') {
30595 return this.groups[target] ;
30604 * page DateSplitField.
30610 * @class Roo.bootstrap.DateSplitField
30611 * @extends Roo.bootstrap.Component
30612 * Bootstrap DateSplitField class
30613 * @cfg {string} fieldLabel - the label associated
30614 * @cfg {Number} labelWidth set the width of label (0-12)
30615 * @cfg {String} labelAlign (top|left)
30616 * @cfg {Boolean} dayAllowBlank (true|false) default false
30617 * @cfg {Boolean} monthAllowBlank (true|false) default false
30618 * @cfg {Boolean} yearAllowBlank (true|false) default false
30619 * @cfg {string} dayPlaceholder
30620 * @cfg {string} monthPlaceholder
30621 * @cfg {string} yearPlaceholder
30622 * @cfg {string} dayFormat default 'd'
30623 * @cfg {string} monthFormat default 'm'
30624 * @cfg {string} yearFormat default 'Y'
30625 * @cfg {Number} labellg set the width of label (1-12)
30626 * @cfg {Number} labelmd set the width of label (1-12)
30627 * @cfg {Number} labelsm set the width of label (1-12)
30628 * @cfg {Number} labelxs set the width of label (1-12)
30632 * Create a new DateSplitField
30633 * @param {Object} config The config object
30636 Roo.bootstrap.DateSplitField = function(config){
30637 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30643 * getting the data of years
30644 * @param {Roo.bootstrap.DateSplitField} this
30645 * @param {Object} years
30650 * getting the data of days
30651 * @param {Roo.bootstrap.DateSplitField} this
30652 * @param {Object} days
30657 * Fires after the field has been marked as invalid.
30658 * @param {Roo.form.Field} this
30659 * @param {String} msg The validation message
30664 * Fires after the field has been validated with no errors.
30665 * @param {Roo.form.Field} this
30671 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30674 labelAlign : 'top',
30676 dayAllowBlank : false,
30677 monthAllowBlank : false,
30678 yearAllowBlank : false,
30679 dayPlaceholder : '',
30680 monthPlaceholder : '',
30681 yearPlaceholder : '',
30685 isFormField : true,
30691 getAutoCreate : function()
30695 cls : 'row roo-date-split-field-group',
30700 cls : 'form-hidden-field roo-date-split-field-group-value',
30706 var labelCls = 'col-md-12';
30707 var contentCls = 'col-md-4';
30709 if(this.fieldLabel){
30713 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30717 html : this.fieldLabel
30722 if(this.labelAlign == 'left'){
30724 if(this.labelWidth > 12){
30725 label.style = "width: " + this.labelWidth + 'px';
30728 if(this.labelWidth < 13 && this.labelmd == 0){
30729 this.labelmd = this.labelWidth;
30732 if(this.labellg > 0){
30733 labelCls = ' col-lg-' + this.labellg;
30734 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30737 if(this.labelmd > 0){
30738 labelCls = ' col-md-' + this.labelmd;
30739 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30742 if(this.labelsm > 0){
30743 labelCls = ' col-sm-' + this.labelsm;
30744 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30747 if(this.labelxs > 0){
30748 labelCls = ' col-xs-' + this.labelxs;
30749 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30753 label.cls += ' ' + labelCls;
30755 cfg.cn.push(label);
30758 Roo.each(['day', 'month', 'year'], function(t){
30761 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30768 inputEl: function ()
30770 return this.el.select('.roo-date-split-field-group-value', true).first();
30773 onRender : function(ct, position)
30777 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30779 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30781 this.dayField = new Roo.bootstrap.ComboBox({
30782 allowBlank : this.dayAllowBlank,
30783 alwaysQuery : true,
30784 displayField : 'value',
30787 forceSelection : true,
30789 placeholder : this.dayPlaceholder,
30790 selectOnFocus : true,
30791 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30792 triggerAction : 'all',
30794 valueField : 'value',
30795 store : new Roo.data.SimpleStore({
30796 data : (function() {
30798 _this.fireEvent('days', _this, days);
30801 fields : [ 'value' ]
30804 select : function (_self, record, index)
30806 _this.setValue(_this.getValue());
30811 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30813 this.monthField = new Roo.bootstrap.MonthField({
30814 after : '<i class=\"fa fa-calendar\"></i>',
30815 allowBlank : this.monthAllowBlank,
30816 placeholder : this.monthPlaceholder,
30819 render : function (_self)
30821 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30822 e.preventDefault();
30826 select : function (_self, oldvalue, newvalue)
30828 _this.setValue(_this.getValue());
30833 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30835 this.yearField = new Roo.bootstrap.ComboBox({
30836 allowBlank : this.yearAllowBlank,
30837 alwaysQuery : true,
30838 displayField : 'value',
30841 forceSelection : true,
30843 placeholder : this.yearPlaceholder,
30844 selectOnFocus : true,
30845 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30846 triggerAction : 'all',
30848 valueField : 'value',
30849 store : new Roo.data.SimpleStore({
30850 data : (function() {
30852 _this.fireEvent('years', _this, years);
30855 fields : [ 'value' ]
30858 select : function (_self, record, index)
30860 _this.setValue(_this.getValue());
30865 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30868 setValue : function(v, format)
30870 this.inputEl.dom.value = v;
30872 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30874 var d = Date.parseDate(v, f);
30881 this.setDay(d.format(this.dayFormat));
30882 this.setMonth(d.format(this.monthFormat));
30883 this.setYear(d.format(this.yearFormat));
30890 setDay : function(v)
30892 this.dayField.setValue(v);
30893 this.inputEl.dom.value = this.getValue();
30898 setMonth : function(v)
30900 this.monthField.setValue(v, true);
30901 this.inputEl.dom.value = this.getValue();
30906 setYear : function(v)
30908 this.yearField.setValue(v);
30909 this.inputEl.dom.value = this.getValue();
30914 getDay : function()
30916 return this.dayField.getValue();
30919 getMonth : function()
30921 return this.monthField.getValue();
30924 getYear : function()
30926 return this.yearField.getValue();
30929 getValue : function()
30931 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30933 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30943 this.inputEl.dom.value = '';
30948 validate : function()
30950 var d = this.dayField.validate();
30951 var m = this.monthField.validate();
30952 var y = this.yearField.validate();
30957 (!this.dayAllowBlank && !d) ||
30958 (!this.monthAllowBlank && !m) ||
30959 (!this.yearAllowBlank && !y)
30964 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30973 this.markInvalid();
30978 markValid : function()
30981 var label = this.el.select('label', true).first();
30982 var icon = this.el.select('i.fa-star', true).first();
30988 this.fireEvent('valid', this);
30992 * Mark this field as invalid
30993 * @param {String} msg The validation message
30995 markInvalid : function(msg)
30998 var label = this.el.select('label', true).first();
30999 var icon = this.el.select('i.fa-star', true).first();
31001 if(label && !icon){
31002 this.el.select('.roo-date-split-field-label', true).createChild({
31004 cls : 'text-danger fa fa-lg fa-star',
31005 tooltip : 'This field is required',
31006 style : 'margin-right:5px;'
31010 this.fireEvent('invalid', this, msg);
31013 clearInvalid : function()
31015 var label = this.el.select('label', true).first();
31016 var icon = this.el.select('i.fa-star', true).first();
31022 this.fireEvent('valid', this);
31025 getName: function()
31035 * http://masonry.desandro.com
31037 * The idea is to render all the bricks based on vertical width...
31039 * The original code extends 'outlayer' - we might need to use that....
31045 * @class Roo.bootstrap.LayoutMasonry
31046 * @extends Roo.bootstrap.Component
31047 * Bootstrap Layout Masonry class
31050 * Create a new Element
31051 * @param {Object} config The config object
31054 Roo.bootstrap.LayoutMasonry = function(config){
31056 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31060 Roo.bootstrap.LayoutMasonry.register(this);
31066 * Fire after layout the items
31067 * @param {Roo.bootstrap.LayoutMasonry} this
31068 * @param {Roo.EventObject} e
31075 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31078 * @cfg {Boolean} isLayoutInstant = no animation?
31080 isLayoutInstant : false, // needed?
31083 * @cfg {Number} boxWidth width of the columns
31088 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31093 * @cfg {Number} padWidth padding below box..
31098 * @cfg {Number} gutter gutter width..
31103 * @cfg {Number} maxCols maximum number of columns
31109 * @cfg {Boolean} isAutoInitial defalut true
31111 isAutoInitial : true,
31116 * @cfg {Boolean} isHorizontal defalut false
31118 isHorizontal : false,
31120 currentSize : null,
31126 bricks: null, //CompositeElement
31130 _isLayoutInited : false,
31132 // isAlternative : false, // only use for vertical layout...
31135 * @cfg {Number} alternativePadWidth padding below box..
31137 alternativePadWidth : 50,
31139 selectedBrick : [],
31141 getAutoCreate : function(){
31143 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31147 cls: 'blog-masonary-wrapper ' + this.cls,
31149 cls : 'mas-boxes masonary'
31156 getChildContainer: function( )
31158 if (this.boxesEl) {
31159 return this.boxesEl;
31162 this.boxesEl = this.el.select('.mas-boxes').first();
31164 return this.boxesEl;
31168 initEvents : function()
31172 if(this.isAutoInitial){
31173 Roo.log('hook children rendered');
31174 this.on('childrenrendered', function() {
31175 Roo.log('children rendered');
31181 initial : function()
31183 this.selectedBrick = [];
31185 this.currentSize = this.el.getBox(true);
31187 Roo.EventManager.onWindowResize(this.resize, this);
31189 if(!this.isAutoInitial){
31197 //this.layout.defer(500,this);
31201 resize : function()
31203 var cs = this.el.getBox(true);
31206 this.currentSize.width == cs.width &&
31207 this.currentSize.x == cs.x &&
31208 this.currentSize.height == cs.height &&
31209 this.currentSize.y == cs.y
31211 Roo.log("no change in with or X or Y");
31215 this.currentSize = cs;
31221 layout : function()
31223 this._resetLayout();
31225 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31227 this.layoutItems( isInstant );
31229 this._isLayoutInited = true;
31231 this.fireEvent('layout', this);
31235 _resetLayout : function()
31237 if(this.isHorizontal){
31238 this.horizontalMeasureColumns();
31242 this.verticalMeasureColumns();
31246 verticalMeasureColumns : function()
31248 this.getContainerWidth();
31250 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31251 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31255 var boxWidth = this.boxWidth + this.padWidth;
31257 if(this.containerWidth < this.boxWidth){
31258 boxWidth = this.containerWidth
31261 var containerWidth = this.containerWidth;
31263 var cols = Math.floor(containerWidth / boxWidth);
31265 this.cols = Math.max( cols, 1 );
31267 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31269 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31271 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31273 this.colWidth = boxWidth + avail - this.padWidth;
31275 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31276 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31279 horizontalMeasureColumns : function()
31281 this.getContainerWidth();
31283 var boxWidth = this.boxWidth;
31285 if(this.containerWidth < boxWidth){
31286 boxWidth = this.containerWidth;
31289 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31291 this.el.setHeight(boxWidth);
31295 getContainerWidth : function()
31297 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31300 layoutItems : function( isInstant )
31302 Roo.log(this.bricks);
31304 var items = Roo.apply([], this.bricks);
31306 if(this.isHorizontal){
31307 this._horizontalLayoutItems( items , isInstant );
31311 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31312 // this._verticalAlternativeLayoutItems( items , isInstant );
31316 this._verticalLayoutItems( items , isInstant );
31320 _verticalLayoutItems : function ( items , isInstant)
31322 if ( !items || !items.length ) {
31327 ['xs', 'xs', 'xs', 'tall'],
31328 ['xs', 'xs', 'tall'],
31329 ['xs', 'xs', 'sm'],
31330 ['xs', 'xs', 'xs'],
31336 ['sm', 'xs', 'xs'],
31340 ['tall', 'xs', 'xs', 'xs'],
31341 ['tall', 'xs', 'xs'],
31353 Roo.each(items, function(item, k){
31355 switch (item.size) {
31356 // these layouts take up a full box,
31367 boxes.push([item]);
31390 var filterPattern = function(box, length)
31398 var pattern = box.slice(0, length);
31402 Roo.each(pattern, function(i){
31403 format.push(i.size);
31406 Roo.each(standard, function(s){
31408 if(String(s) != String(format)){
31417 if(!match && length == 1){
31422 filterPattern(box, length - 1);
31426 queue.push(pattern);
31428 box = box.slice(length, box.length);
31430 filterPattern(box, 4);
31436 Roo.each(boxes, function(box, k){
31442 if(box.length == 1){
31447 filterPattern(box, 4);
31451 this._processVerticalLayoutQueue( queue, isInstant );
31455 // _verticalAlternativeLayoutItems : function( items , isInstant )
31457 // if ( !items || !items.length ) {
31461 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31465 _horizontalLayoutItems : function ( items , isInstant)
31467 if ( !items || !items.length || items.length < 3) {
31473 var eItems = items.slice(0, 3);
31475 items = items.slice(3, items.length);
31478 ['xs', 'xs', 'xs', 'wide'],
31479 ['xs', 'xs', 'wide'],
31480 ['xs', 'xs', 'sm'],
31481 ['xs', 'xs', 'xs'],
31487 ['sm', 'xs', 'xs'],
31491 ['wide', 'xs', 'xs', 'xs'],
31492 ['wide', 'xs', 'xs'],
31505 Roo.each(items, function(item, k){
31507 switch (item.size) {
31518 boxes.push([item]);
31542 var filterPattern = function(box, length)
31550 var pattern = box.slice(0, length);
31554 Roo.each(pattern, function(i){
31555 format.push(i.size);
31558 Roo.each(standard, function(s){
31560 if(String(s) != String(format)){
31569 if(!match && length == 1){
31574 filterPattern(box, length - 1);
31578 queue.push(pattern);
31580 box = box.slice(length, box.length);
31582 filterPattern(box, 4);
31588 Roo.each(boxes, function(box, k){
31594 if(box.length == 1){
31599 filterPattern(box, 4);
31606 var pos = this.el.getBox(true);
31610 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31612 var hit_end = false;
31614 Roo.each(queue, function(box){
31618 Roo.each(box, function(b){
31620 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31630 Roo.each(box, function(b){
31632 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31635 mx = Math.max(mx, b.x);
31639 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31643 Roo.each(box, function(b){
31645 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31659 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31662 /** Sets position of item in DOM
31663 * @param {Element} item
31664 * @param {Number} x - horizontal position
31665 * @param {Number} y - vertical position
31666 * @param {Boolean} isInstant - disables transitions
31668 _processVerticalLayoutQueue : function( queue, isInstant )
31670 var pos = this.el.getBox(true);
31675 for (var i = 0; i < this.cols; i++){
31679 Roo.each(queue, function(box, k){
31681 var col = k % this.cols;
31683 Roo.each(box, function(b,kk){
31685 b.el.position('absolute');
31687 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31688 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31690 if(b.size == 'md-left' || b.size == 'md-right'){
31691 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31692 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31695 b.el.setWidth(width);
31696 b.el.setHeight(height);
31698 b.el.select('iframe',true).setSize(width,height);
31702 for (var i = 0; i < this.cols; i++){
31704 if(maxY[i] < maxY[col]){
31709 col = Math.min(col, i);
31713 x = pos.x + col * (this.colWidth + this.padWidth);
31717 var positions = [];
31719 switch (box.length){
31721 positions = this.getVerticalOneBoxColPositions(x, y, box);
31724 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31727 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31730 positions = this.getVerticalFourBoxColPositions(x, y, box);
31736 Roo.each(box, function(b,kk){
31738 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31740 var sz = b.el.getSize();
31742 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31750 for (var i = 0; i < this.cols; i++){
31751 mY = Math.max(mY, maxY[i]);
31754 this.el.setHeight(mY - pos.y);
31758 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31760 // var pos = this.el.getBox(true);
31763 // var maxX = pos.right;
31765 // var maxHeight = 0;
31767 // Roo.each(items, function(item, k){
31771 // item.el.position('absolute');
31773 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31775 // item.el.setWidth(width);
31777 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31779 // item.el.setHeight(height);
31782 // item.el.setXY([x, y], isInstant ? false : true);
31784 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31787 // y = y + height + this.alternativePadWidth;
31789 // maxHeight = maxHeight + height + this.alternativePadWidth;
31793 // this.el.setHeight(maxHeight);
31797 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31799 var pos = this.el.getBox(true);
31804 var maxX = pos.right;
31806 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31808 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31810 Roo.each(queue, function(box, k){
31812 Roo.each(box, function(b, kk){
31814 b.el.position('absolute');
31816 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31817 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31819 if(b.size == 'md-left' || b.size == 'md-right'){
31820 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31821 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31824 b.el.setWidth(width);
31825 b.el.setHeight(height);
31833 var positions = [];
31835 switch (box.length){
31837 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31840 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31843 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31846 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31852 Roo.each(box, function(b,kk){
31854 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31856 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31864 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31866 Roo.each(eItems, function(b,k){
31868 b.size = (k == 0) ? 'sm' : 'xs';
31869 b.x = (k == 0) ? 2 : 1;
31870 b.y = (k == 0) ? 2 : 1;
31872 b.el.position('absolute');
31874 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31876 b.el.setWidth(width);
31878 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31880 b.el.setHeight(height);
31884 var positions = [];
31887 x : maxX - this.unitWidth * 2 - this.gutter,
31892 x : maxX - this.unitWidth,
31893 y : minY + (this.unitWidth + this.gutter) * 2
31897 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31901 Roo.each(eItems, function(b,k){
31903 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31909 getVerticalOneBoxColPositions : function(x, y, box)
31913 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31915 if(box[0].size == 'md-left'){
31919 if(box[0].size == 'md-right'){
31924 x : x + (this.unitWidth + this.gutter) * rand,
31931 getVerticalTwoBoxColPositions : function(x, y, box)
31935 if(box[0].size == 'xs'){
31939 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31943 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31957 x : x + (this.unitWidth + this.gutter) * 2,
31958 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31965 getVerticalThreeBoxColPositions : function(x, y, box)
31969 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31977 x : x + (this.unitWidth + this.gutter) * 1,
31982 x : x + (this.unitWidth + this.gutter) * 2,
31990 if(box[0].size == 'xs' && box[1].size == 'xs'){
31999 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32003 x : x + (this.unitWidth + this.gutter) * 1,
32017 x : x + (this.unitWidth + this.gutter) * 2,
32022 x : x + (this.unitWidth + this.gutter) * 2,
32023 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32030 getVerticalFourBoxColPositions : function(x, y, box)
32034 if(box[0].size == 'xs'){
32043 y : y + (this.unitHeight + this.gutter) * 1
32048 y : y + (this.unitHeight + this.gutter) * 2
32052 x : x + (this.unitWidth + this.gutter) * 1,
32066 x : x + (this.unitWidth + this.gutter) * 2,
32071 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32072 y : y + (this.unitHeight + this.gutter) * 1
32076 x : x + (this.unitWidth + this.gutter) * 2,
32077 y : y + (this.unitWidth + this.gutter) * 2
32084 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32088 if(box[0].size == 'md-left'){
32090 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32097 if(box[0].size == 'md-right'){
32099 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32100 y : minY + (this.unitWidth + this.gutter) * 1
32106 var rand = Math.floor(Math.random() * (4 - box[0].y));
32109 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32110 y : minY + (this.unitWidth + this.gutter) * rand
32117 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32121 if(box[0].size == 'xs'){
32124 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32129 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32130 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32138 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32143 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32144 y : minY + (this.unitWidth + this.gutter) * 2
32151 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32155 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32158 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32163 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32164 y : minY + (this.unitWidth + this.gutter) * 1
32168 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32169 y : minY + (this.unitWidth + this.gutter) * 2
32176 if(box[0].size == 'xs' && box[1].size == 'xs'){
32179 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32184 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32189 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32190 y : minY + (this.unitWidth + this.gutter) * 1
32198 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32203 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32204 y : minY + (this.unitWidth + this.gutter) * 2
32208 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32209 y : minY + (this.unitWidth + this.gutter) * 2
32216 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32220 if(box[0].size == 'xs'){
32223 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32228 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32233 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),
32238 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32239 y : minY + (this.unitWidth + this.gutter) * 1
32247 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32252 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32253 y : minY + (this.unitWidth + this.gutter) * 2
32257 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32258 y : minY + (this.unitWidth + this.gutter) * 2
32262 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),
32263 y : minY + (this.unitWidth + this.gutter) * 2
32271 * remove a Masonry Brick
32272 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32274 removeBrick : function(brick_id)
32280 for (var i = 0; i<this.bricks.length; i++) {
32281 if (this.bricks[i].id == brick_id) {
32282 this.bricks.splice(i,1);
32283 this.el.dom.removeChild(Roo.get(brick_id).dom);
32290 * adds a Masonry Brick
32291 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32293 addBrick : function(cfg)
32295 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32296 //this.register(cn);
32297 cn.parentId = this.id;
32298 cn.render(this.el);
32303 * register a Masonry Brick
32304 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32307 register : function(brick)
32309 this.bricks.push(brick);
32310 brick.masonryId = this.id;
32314 * clear all the Masonry Brick
32316 clearAll : function()
32319 //this.getChildContainer().dom.innerHTML = "";
32320 this.el.dom.innerHTML = '';
32323 getSelected : function()
32325 if (!this.selectedBrick) {
32329 return this.selectedBrick;
32333 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32337 * register a Masonry Layout
32338 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32341 register : function(layout)
32343 this.groups[layout.id] = layout;
32346 * fetch a Masonry Layout based on the masonry layout ID
32347 * @param {string} the masonry layout to add
32348 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32351 get: function(layout_id) {
32352 if (typeof(this.groups[layout_id]) == 'undefined') {
32355 return this.groups[layout_id] ;
32367 * http://masonry.desandro.com
32369 * The idea is to render all the bricks based on vertical width...
32371 * The original code extends 'outlayer' - we might need to use that....
32377 * @class Roo.bootstrap.LayoutMasonryAuto
32378 * @extends Roo.bootstrap.Component
32379 * Bootstrap Layout Masonry class
32382 * Create a new Element
32383 * @param {Object} config The config object
32386 Roo.bootstrap.LayoutMasonryAuto = function(config){
32387 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32390 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32393 * @cfg {Boolean} isFitWidth - resize the width..
32395 isFitWidth : false, // options..
32397 * @cfg {Boolean} isOriginLeft = left align?
32399 isOriginLeft : true,
32401 * @cfg {Boolean} isOriginTop = top align?
32403 isOriginTop : false,
32405 * @cfg {Boolean} isLayoutInstant = no animation?
32407 isLayoutInstant : false, // needed?
32409 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32411 isResizingContainer : true,
32413 * @cfg {Number} columnWidth width of the columns
32419 * @cfg {Number} maxCols maximum number of columns
32424 * @cfg {Number} padHeight padding below box..
32430 * @cfg {Boolean} isAutoInitial defalut true
32433 isAutoInitial : true,
32439 initialColumnWidth : 0,
32440 currentSize : null,
32442 colYs : null, // array.
32449 bricks: null, //CompositeElement
32450 cols : 0, // array?
32451 // element : null, // wrapped now this.el
32452 _isLayoutInited : null,
32455 getAutoCreate : function(){
32459 cls: 'blog-masonary-wrapper ' + this.cls,
32461 cls : 'mas-boxes masonary'
32468 getChildContainer: function( )
32470 if (this.boxesEl) {
32471 return this.boxesEl;
32474 this.boxesEl = this.el.select('.mas-boxes').first();
32476 return this.boxesEl;
32480 initEvents : function()
32484 if(this.isAutoInitial){
32485 Roo.log('hook children rendered');
32486 this.on('childrenrendered', function() {
32487 Roo.log('children rendered');
32494 initial : function()
32496 this.reloadItems();
32498 this.currentSize = this.el.getBox(true);
32500 /// was window resize... - let's see if this works..
32501 Roo.EventManager.onWindowResize(this.resize, this);
32503 if(!this.isAutoInitial){
32508 this.layout.defer(500,this);
32511 reloadItems: function()
32513 this.bricks = this.el.select('.masonry-brick', true);
32515 this.bricks.each(function(b) {
32516 //Roo.log(b.getSize());
32517 if (!b.attr('originalwidth')) {
32518 b.attr('originalwidth', b.getSize().width);
32523 Roo.log(this.bricks.elements.length);
32526 resize : function()
32529 var cs = this.el.getBox(true);
32531 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32532 Roo.log("no change in with or X");
32535 this.currentSize = cs;
32539 layout : function()
32542 this._resetLayout();
32543 //this._manageStamps();
32545 // don't animate first layout
32546 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32547 this.layoutItems( isInstant );
32549 // flag for initalized
32550 this._isLayoutInited = true;
32553 layoutItems : function( isInstant )
32555 //var items = this._getItemsForLayout( this.items );
32556 // original code supports filtering layout items.. we just ignore it..
32558 this._layoutItems( this.bricks , isInstant );
32560 this._postLayout();
32562 _layoutItems : function ( items , isInstant)
32564 //this.fireEvent( 'layout', this, items );
32567 if ( !items || !items.elements.length ) {
32568 // no items, emit event with empty array
32573 items.each(function(item) {
32574 Roo.log("layout item");
32576 // get x/y object from method
32577 var position = this._getItemLayoutPosition( item );
32579 position.item = item;
32580 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32581 queue.push( position );
32584 this._processLayoutQueue( queue );
32586 /** Sets position of item in DOM
32587 * @param {Element} item
32588 * @param {Number} x - horizontal position
32589 * @param {Number} y - vertical position
32590 * @param {Boolean} isInstant - disables transitions
32592 _processLayoutQueue : function( queue )
32594 for ( var i=0, len = queue.length; i < len; i++ ) {
32595 var obj = queue[i];
32596 obj.item.position('absolute');
32597 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32603 * Any logic you want to do after each layout,
32604 * i.e. size the container
32606 _postLayout : function()
32608 this.resizeContainer();
32611 resizeContainer : function()
32613 if ( !this.isResizingContainer ) {
32616 var size = this._getContainerSize();
32618 this.el.setSize(size.width,size.height);
32619 this.boxesEl.setSize(size.width,size.height);
32625 _resetLayout : function()
32627 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32628 this.colWidth = this.el.getWidth();
32629 //this.gutter = this.el.getWidth();
32631 this.measureColumns();
32637 this.colYs.push( 0 );
32643 measureColumns : function()
32645 this.getContainerWidth();
32646 // if columnWidth is 0, default to outerWidth of first item
32647 if ( !this.columnWidth ) {
32648 var firstItem = this.bricks.first();
32649 Roo.log(firstItem);
32650 this.columnWidth = this.containerWidth;
32651 if (firstItem && firstItem.attr('originalwidth') ) {
32652 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32654 // columnWidth fall back to item of first element
32655 Roo.log("set column width?");
32656 this.initialColumnWidth = this.columnWidth ;
32658 // if first elem has no width, default to size of container
32663 if (this.initialColumnWidth) {
32664 this.columnWidth = this.initialColumnWidth;
32669 // column width is fixed at the top - however if container width get's smaller we should
32672 // this bit calcs how man columns..
32674 var columnWidth = this.columnWidth += this.gutter;
32676 // calculate columns
32677 var containerWidth = this.containerWidth + this.gutter;
32679 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32680 // fix rounding errors, typically with gutters
32681 var excess = columnWidth - containerWidth % columnWidth;
32684 // if overshoot is less than a pixel, round up, otherwise floor it
32685 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32686 cols = Math[ mathMethod ]( cols );
32687 this.cols = Math.max( cols, 1 );
32688 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32690 // padding positioning..
32691 var totalColWidth = this.cols * this.columnWidth;
32692 var padavail = this.containerWidth - totalColWidth;
32693 // so for 2 columns - we need 3 'pads'
32695 var padNeeded = (1+this.cols) * this.padWidth;
32697 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32699 this.columnWidth += padExtra
32700 //this.padWidth = Math.floor(padavail / ( this.cols));
32702 // adjust colum width so that padding is fixed??
32704 // we have 3 columns ... total = width * 3
32705 // we have X left over... that should be used by
32707 //if (this.expandC) {
32715 getContainerWidth : function()
32717 /* // container is parent if fit width
32718 var container = this.isFitWidth ? this.element.parentNode : this.element;
32719 // check that this.size and size are there
32720 // IE8 triggers resize on body size change, so they might not be
32722 var size = getSize( container ); //FIXME
32723 this.containerWidth = size && size.innerWidth; //FIXME
32726 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32730 _getItemLayoutPosition : function( item ) // what is item?
32732 // we resize the item to our columnWidth..
32734 item.setWidth(this.columnWidth);
32735 item.autoBoxAdjust = false;
32737 var sz = item.getSize();
32739 // how many columns does this brick span
32740 var remainder = this.containerWidth % this.columnWidth;
32742 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32743 // round if off by 1 pixel, otherwise use ceil
32744 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32745 colSpan = Math.min( colSpan, this.cols );
32747 // normally this should be '1' as we dont' currently allow multi width columns..
32749 var colGroup = this._getColGroup( colSpan );
32750 // get the minimum Y value from the columns
32751 var minimumY = Math.min.apply( Math, colGroup );
32752 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32754 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32756 // position the brick
32758 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32759 y: this.currentSize.y + minimumY + this.padHeight
32763 // apply setHeight to necessary columns
32764 var setHeight = minimumY + sz.height + this.padHeight;
32765 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32767 var setSpan = this.cols + 1 - colGroup.length;
32768 for ( var i = 0; i < setSpan; i++ ) {
32769 this.colYs[ shortColIndex + i ] = setHeight ;
32776 * @param {Number} colSpan - number of columns the element spans
32777 * @returns {Array} colGroup
32779 _getColGroup : function( colSpan )
32781 if ( colSpan < 2 ) {
32782 // if brick spans only one column, use all the column Ys
32787 // how many different places could this brick fit horizontally
32788 var groupCount = this.cols + 1 - colSpan;
32789 // for each group potential horizontal position
32790 for ( var i = 0; i < groupCount; i++ ) {
32791 // make an array of colY values for that one group
32792 var groupColYs = this.colYs.slice( i, i + colSpan );
32793 // and get the max value of the array
32794 colGroup[i] = Math.max.apply( Math, groupColYs );
32799 _manageStamp : function( stamp )
32801 var stampSize = stamp.getSize();
32802 var offset = stamp.getBox();
32803 // get the columns that this stamp affects
32804 var firstX = this.isOriginLeft ? offset.x : offset.right;
32805 var lastX = firstX + stampSize.width;
32806 var firstCol = Math.floor( firstX / this.columnWidth );
32807 firstCol = Math.max( 0, firstCol );
32809 var lastCol = Math.floor( lastX / this.columnWidth );
32810 // lastCol should not go over if multiple of columnWidth #425
32811 lastCol -= lastX % this.columnWidth ? 0 : 1;
32812 lastCol = Math.min( this.cols - 1, lastCol );
32814 // set colYs to bottom of the stamp
32815 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32818 for ( var i = firstCol; i <= lastCol; i++ ) {
32819 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32824 _getContainerSize : function()
32826 this.maxY = Math.max.apply( Math, this.colYs );
32831 if ( this.isFitWidth ) {
32832 size.width = this._getContainerFitWidth();
32838 _getContainerFitWidth : function()
32840 var unusedCols = 0;
32841 // count unused columns
32844 if ( this.colYs[i] !== 0 ) {
32849 // fit container to columns that have been used
32850 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32853 needsResizeLayout : function()
32855 var previousWidth = this.containerWidth;
32856 this.getContainerWidth();
32857 return previousWidth !== this.containerWidth;
32872 * @class Roo.bootstrap.MasonryBrick
32873 * @extends Roo.bootstrap.Component
32874 * Bootstrap MasonryBrick class
32877 * Create a new MasonryBrick
32878 * @param {Object} config The config object
32881 Roo.bootstrap.MasonryBrick = function(config){
32883 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32885 Roo.bootstrap.MasonryBrick.register(this);
32891 * When a MasonryBrick is clcik
32892 * @param {Roo.bootstrap.MasonryBrick} this
32893 * @param {Roo.EventObject} e
32899 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32902 * @cfg {String} title
32906 * @cfg {String} html
32910 * @cfg {String} bgimage
32914 * @cfg {String} videourl
32918 * @cfg {String} cls
32922 * @cfg {String} href
32926 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32931 * @cfg {String} placetitle (center|bottom)
32936 * @cfg {Boolean} isFitContainer defalut true
32938 isFitContainer : true,
32941 * @cfg {Boolean} preventDefault defalut false
32943 preventDefault : false,
32946 * @cfg {Boolean} inverse defalut false
32948 maskInverse : false,
32950 getAutoCreate : function()
32952 if(!this.isFitContainer){
32953 return this.getSplitAutoCreate();
32956 var cls = 'masonry-brick masonry-brick-full';
32958 if(this.href.length){
32959 cls += ' masonry-brick-link';
32962 if(this.bgimage.length){
32963 cls += ' masonry-brick-image';
32966 if(this.maskInverse){
32967 cls += ' mask-inverse';
32970 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32971 cls += ' enable-mask';
32975 cls += ' masonry-' + this.size + '-brick';
32978 if(this.placetitle.length){
32980 switch (this.placetitle) {
32982 cls += ' masonry-center-title';
32985 cls += ' masonry-bottom-title';
32992 if(!this.html.length && !this.bgimage.length){
32993 cls += ' masonry-center-title';
32996 if(!this.html.length && this.bgimage.length){
32997 cls += ' masonry-bottom-title';
33002 cls += ' ' + this.cls;
33006 tag: (this.href.length) ? 'a' : 'div',
33011 cls: 'masonry-brick-mask'
33015 cls: 'masonry-brick-paragraph',
33021 if(this.href.length){
33022 cfg.href = this.href;
33025 var cn = cfg.cn[1].cn;
33027 if(this.title.length){
33030 cls: 'masonry-brick-title',
33035 if(this.html.length){
33038 cls: 'masonry-brick-text',
33043 if (!this.title.length && !this.html.length) {
33044 cfg.cn[1].cls += ' hide';
33047 if(this.bgimage.length){
33050 cls: 'masonry-brick-image-view',
33055 if(this.videourl.length){
33056 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33057 // youtube support only?
33060 cls: 'masonry-brick-image-view',
33063 allowfullscreen : true
33071 getSplitAutoCreate : function()
33073 var cls = 'masonry-brick masonry-brick-split';
33075 if(this.href.length){
33076 cls += ' masonry-brick-link';
33079 if(this.bgimage.length){
33080 cls += ' masonry-brick-image';
33084 cls += ' masonry-' + this.size + '-brick';
33087 switch (this.placetitle) {
33089 cls += ' masonry-center-title';
33092 cls += ' masonry-bottom-title';
33095 if(!this.bgimage.length){
33096 cls += ' masonry-center-title';
33099 if(this.bgimage.length){
33100 cls += ' masonry-bottom-title';
33106 cls += ' ' + this.cls;
33110 tag: (this.href.length) ? 'a' : 'div',
33115 cls: 'masonry-brick-split-head',
33119 cls: 'masonry-brick-paragraph',
33126 cls: 'masonry-brick-split-body',
33132 if(this.href.length){
33133 cfg.href = this.href;
33136 if(this.title.length){
33137 cfg.cn[0].cn[0].cn.push({
33139 cls: 'masonry-brick-title',
33144 if(this.html.length){
33145 cfg.cn[1].cn.push({
33147 cls: 'masonry-brick-text',
33152 if(this.bgimage.length){
33153 cfg.cn[0].cn.push({
33155 cls: 'masonry-brick-image-view',
33160 if(this.videourl.length){
33161 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33162 // youtube support only?
33163 cfg.cn[0].cn.cn.push({
33165 cls: 'masonry-brick-image-view',
33168 allowfullscreen : true
33175 initEvents: function()
33177 switch (this.size) {
33210 this.el.on('touchstart', this.onTouchStart, this);
33211 this.el.on('touchmove', this.onTouchMove, this);
33212 this.el.on('touchend', this.onTouchEnd, this);
33213 this.el.on('contextmenu', this.onContextMenu, this);
33215 this.el.on('mouseenter' ,this.enter, this);
33216 this.el.on('mouseleave', this.leave, this);
33217 this.el.on('click', this.onClick, this);
33220 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33221 this.parent().bricks.push(this);
33226 onClick: function(e, el)
33228 var time = this.endTimer - this.startTimer;
33229 // Roo.log(e.preventDefault());
33232 e.preventDefault();
33237 if(!this.preventDefault){
33241 e.preventDefault();
33243 if (this.activeClass != '') {
33244 this.selectBrick();
33247 this.fireEvent('click', this, e);
33250 enter: function(e, el)
33252 e.preventDefault();
33254 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33258 if(this.bgimage.length && this.html.length){
33259 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33263 leave: 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, true);
33276 onTouchStart: function(e, el)
33278 // e.preventDefault();
33280 this.touchmoved = false;
33282 if(!this.isFitContainer){
33286 if(!this.bgimage.length || !this.html.length){
33290 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33292 this.timer = new Date().getTime();
33296 onTouchMove: function(e, el)
33298 this.touchmoved = true;
33301 onContextMenu : function(e,el)
33303 e.preventDefault();
33304 e.stopPropagation();
33308 onTouchEnd: function(e, el)
33310 // e.preventDefault();
33312 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33319 if(!this.bgimage.length || !this.html.length){
33321 if(this.href.length){
33322 window.location.href = this.href;
33328 if(!this.isFitContainer){
33332 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33334 window.location.href = this.href;
33337 //selection on single brick only
33338 selectBrick : function() {
33340 if (!this.parentId) {
33344 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33345 var index = m.selectedBrick.indexOf(this.id);
33348 m.selectedBrick.splice(index,1);
33349 this.el.removeClass(this.activeClass);
33353 for(var i = 0; i < m.selectedBrick.length; i++) {
33354 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33355 b.el.removeClass(b.activeClass);
33358 m.selectedBrick = [];
33360 m.selectedBrick.push(this.id);
33361 this.el.addClass(this.activeClass);
33365 isSelected : function(){
33366 return this.el.hasClass(this.activeClass);
33371 Roo.apply(Roo.bootstrap.MasonryBrick, {
33374 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33376 * register a Masonry Brick
33377 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33380 register : function(brick)
33382 //this.groups[brick.id] = brick;
33383 this.groups.add(brick.id, brick);
33386 * fetch a masonry brick based on the masonry brick ID
33387 * @param {string} the masonry brick to add
33388 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33391 get: function(brick_id)
33393 // if (typeof(this.groups[brick_id]) == 'undefined') {
33396 // return this.groups[brick_id] ;
33398 if(this.groups.key(brick_id)) {
33399 return this.groups.key(brick_id);
33417 * @class Roo.bootstrap.Brick
33418 * @extends Roo.bootstrap.Component
33419 * Bootstrap Brick class
33422 * Create a new Brick
33423 * @param {Object} config The config object
33426 Roo.bootstrap.Brick = function(config){
33427 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33433 * When a Brick is click
33434 * @param {Roo.bootstrap.Brick} this
33435 * @param {Roo.EventObject} e
33441 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33444 * @cfg {String} title
33448 * @cfg {String} html
33452 * @cfg {String} bgimage
33456 * @cfg {String} cls
33460 * @cfg {String} href
33464 * @cfg {String} video
33468 * @cfg {Boolean} square
33472 getAutoCreate : function()
33474 var cls = 'roo-brick';
33476 if(this.href.length){
33477 cls += ' roo-brick-link';
33480 if(this.bgimage.length){
33481 cls += ' roo-brick-image';
33484 if(!this.html.length && !this.bgimage.length){
33485 cls += ' roo-brick-center-title';
33488 if(!this.html.length && this.bgimage.length){
33489 cls += ' roo-brick-bottom-title';
33493 cls += ' ' + this.cls;
33497 tag: (this.href.length) ? 'a' : 'div',
33502 cls: 'roo-brick-paragraph',
33508 if(this.href.length){
33509 cfg.href = this.href;
33512 var cn = cfg.cn[0].cn;
33514 if(this.title.length){
33517 cls: 'roo-brick-title',
33522 if(this.html.length){
33525 cls: 'roo-brick-text',
33532 if(this.bgimage.length){
33535 cls: 'roo-brick-image-view',
33543 initEvents: function()
33545 if(this.title.length || this.html.length){
33546 this.el.on('mouseenter' ,this.enter, this);
33547 this.el.on('mouseleave', this.leave, this);
33550 Roo.EventManager.onWindowResize(this.resize, this);
33552 if(this.bgimage.length){
33553 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33554 this.imageEl.on('load', this.onImageLoad, this);
33561 onImageLoad : function()
33566 resize : function()
33568 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33570 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33572 if(this.bgimage.length){
33573 var image = this.el.select('.roo-brick-image-view', true).first();
33575 image.setWidth(paragraph.getWidth());
33578 image.setHeight(paragraph.getWidth());
33581 this.el.setHeight(image.getHeight());
33582 paragraph.setHeight(image.getHeight());
33588 enter: function(e, el)
33590 e.preventDefault();
33592 if(this.bgimage.length){
33593 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33594 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33598 leave: function(e, el)
33600 e.preventDefault();
33602 if(this.bgimage.length){
33603 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33604 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33619 * @class Roo.bootstrap.NumberField
33620 * @extends Roo.bootstrap.Input
33621 * Bootstrap NumberField class
33627 * Create a new NumberField
33628 * @param {Object} config The config object
33631 Roo.bootstrap.NumberField = function(config){
33632 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33635 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33638 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33640 allowDecimals : true,
33642 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33644 decimalSeparator : ".",
33646 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33648 decimalPrecision : 2,
33650 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33652 allowNegative : true,
33655 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33659 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33661 minValue : Number.NEGATIVE_INFINITY,
33663 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33665 maxValue : Number.MAX_VALUE,
33667 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33669 minText : "The minimum value for this field is {0}",
33671 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33673 maxText : "The maximum value for this field is {0}",
33675 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33676 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33678 nanText : "{0} is not a valid number",
33680 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33682 thousandsDelimiter : false,
33684 * @cfg {String} valueAlign alignment of value
33686 valueAlign : "left",
33688 getAutoCreate : function()
33690 var hiddenInput = {
33694 cls: 'hidden-number-input'
33698 hiddenInput.name = this.name;
33703 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33705 this.name = hiddenInput.name;
33707 if(cfg.cn.length > 0) {
33708 cfg.cn.push(hiddenInput);
33715 initEvents : function()
33717 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33719 var allowed = "0123456789";
33721 if(this.allowDecimals){
33722 allowed += this.decimalSeparator;
33725 if(this.allowNegative){
33729 if(this.thousandsDelimiter) {
33733 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33735 var keyPress = function(e){
33737 var k = e.getKey();
33739 var c = e.getCharCode();
33742 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33743 allowed.indexOf(String.fromCharCode(c)) === -1
33749 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33753 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33758 this.el.on("keypress", keyPress, this);
33761 validateValue : function(value)
33764 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33768 var num = this.parseValue(value);
33771 this.markInvalid(String.format(this.nanText, value));
33775 if(num < this.minValue){
33776 this.markInvalid(String.format(this.minText, this.minValue));
33780 if(num > this.maxValue){
33781 this.markInvalid(String.format(this.maxText, this.maxValue));
33788 getValue : function()
33790 var v = this.hiddenEl().getValue();
33792 return this.fixPrecision(this.parseValue(v));
33795 parseValue : function(value)
33797 if(this.thousandsDelimiter) {
33799 r = new RegExp(",", "g");
33800 value = value.replace(r, "");
33803 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33804 return isNaN(value) ? '' : value;
33807 fixPrecision : function(value)
33809 if(this.thousandsDelimiter) {
33811 r = new RegExp(",", "g");
33812 value = value.replace(r, "");
33815 var nan = isNaN(value);
33817 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33818 return nan ? '' : value;
33820 return parseFloat(value).toFixed(this.decimalPrecision);
33823 setValue : function(v)
33825 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33831 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33833 this.inputEl().dom.value = (v == '') ? '' :
33834 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33836 if(!this.allowZero && v === '0') {
33837 this.hiddenEl().dom.value = '';
33838 this.inputEl().dom.value = '';
33845 decimalPrecisionFcn : function(v)
33847 return Math.floor(v);
33850 beforeBlur : function()
33852 var v = this.parseValue(this.getRawValue());
33854 if(v || v === 0 || v === ''){
33859 hiddenEl : function()
33861 return this.el.select('input.hidden-number-input',true).first();
33873 * @class Roo.bootstrap.DocumentSlider
33874 * @extends Roo.bootstrap.Component
33875 * Bootstrap DocumentSlider class
33878 * Create a new DocumentViewer
33879 * @param {Object} config The config object
33882 Roo.bootstrap.DocumentSlider = function(config){
33883 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33890 * Fire after initEvent
33891 * @param {Roo.bootstrap.DocumentSlider} this
33896 * Fire after update
33897 * @param {Roo.bootstrap.DocumentSlider} this
33903 * @param {Roo.bootstrap.DocumentSlider} this
33909 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33915 getAutoCreate : function()
33919 cls : 'roo-document-slider',
33923 cls : 'roo-document-slider-header',
33927 cls : 'roo-document-slider-header-title'
33933 cls : 'roo-document-slider-body',
33937 cls : 'roo-document-slider-prev',
33941 cls : 'fa fa-chevron-left'
33947 cls : 'roo-document-slider-thumb',
33951 cls : 'roo-document-slider-image'
33957 cls : 'roo-document-slider-next',
33961 cls : 'fa fa-chevron-right'
33973 initEvents : function()
33975 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33976 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33978 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33979 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33981 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33982 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33984 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33985 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33987 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33988 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33990 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33991 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33993 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33994 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33996 this.thumbEl.on('click', this.onClick, this);
33998 this.prevIndicator.on('click', this.prev, this);
34000 this.nextIndicator.on('click', this.next, this);
34004 initial : function()
34006 if(this.files.length){
34007 this.indicator = 1;
34011 this.fireEvent('initial', this);
34014 update : function()
34016 this.imageEl.attr('src', this.files[this.indicator - 1]);
34018 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34020 this.prevIndicator.show();
34022 if(this.indicator == 1){
34023 this.prevIndicator.hide();
34026 this.nextIndicator.show();
34028 if(this.indicator == this.files.length){
34029 this.nextIndicator.hide();
34032 this.thumbEl.scrollTo('top');
34034 this.fireEvent('update', this);
34037 onClick : function(e)
34039 e.preventDefault();
34041 this.fireEvent('click', this);
34046 e.preventDefault();
34048 this.indicator = Math.max(1, this.indicator - 1);
34055 e.preventDefault();
34057 this.indicator = Math.min(this.files.length, this.indicator + 1);
34071 * @class Roo.bootstrap.RadioSet
34072 * @extends Roo.bootstrap.Input
34073 * Bootstrap RadioSet class
34074 * @cfg {String} indicatorpos (left|right) default left
34075 * @cfg {Boolean} inline (true|false) inline the element (default true)
34076 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34078 * Create a new RadioSet
34079 * @param {Object} config The config object
34082 Roo.bootstrap.RadioSet = function(config){
34084 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34088 Roo.bootstrap.RadioSet.register(this);
34093 * Fires when the element is checked or unchecked.
34094 * @param {Roo.bootstrap.RadioSet} this This radio
34095 * @param {Roo.bootstrap.Radio} item The checked item
34100 * Fires when the element is click.
34101 * @param {Roo.bootstrap.RadioSet} this This radio set
34102 * @param {Roo.bootstrap.Radio} item The checked item
34103 * @param {Roo.EventObject} e The event object
34110 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34118 indicatorpos : 'left',
34120 getAutoCreate : function()
34124 cls : 'roo-radio-set-label',
34128 html : this.fieldLabel
34132 if (Roo.bootstrap.version == 3) {
34135 if(this.indicatorpos == 'left'){
34138 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34139 tooltip : 'This field is required'
34144 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34145 tooltip : 'This field is required'
34151 cls : 'roo-radio-set-items'
34154 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34156 if (align === 'left' && this.fieldLabel.length) {
34159 cls : "roo-radio-set-right",
34165 if(this.labelWidth > 12){
34166 label.style = "width: " + this.labelWidth + 'px';
34169 if(this.labelWidth < 13 && this.labelmd == 0){
34170 this.labelmd = this.labelWidth;
34173 if(this.labellg > 0){
34174 label.cls += ' col-lg-' + this.labellg;
34175 items.cls += ' col-lg-' + (12 - this.labellg);
34178 if(this.labelmd > 0){
34179 label.cls += ' col-md-' + this.labelmd;
34180 items.cls += ' col-md-' + (12 - this.labelmd);
34183 if(this.labelsm > 0){
34184 label.cls += ' col-sm-' + this.labelsm;
34185 items.cls += ' col-sm-' + (12 - this.labelsm);
34188 if(this.labelxs > 0){
34189 label.cls += ' col-xs-' + this.labelxs;
34190 items.cls += ' col-xs-' + (12 - this.labelxs);
34196 cls : 'roo-radio-set',
34200 cls : 'roo-radio-set-input',
34203 value : this.value ? this.value : ''
34210 if(this.weight.length){
34211 cfg.cls += ' roo-radio-' + this.weight;
34215 cfg.cls += ' roo-radio-set-inline';
34219 ['xs','sm','md','lg'].map(function(size){
34220 if (settings[size]) {
34221 cfg.cls += ' col-' + size + '-' + settings[size];
34229 initEvents : function()
34231 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34232 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34234 if(!this.fieldLabel.length){
34235 this.labelEl.hide();
34238 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34239 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34241 this.indicator = this.indicatorEl();
34243 if(this.indicator){
34244 this.indicator.addClass('invisible');
34247 this.originalValue = this.getValue();
34251 inputEl: function ()
34253 return this.el.select('.roo-radio-set-input', true).first();
34256 getChildContainer : function()
34258 return this.itemsEl;
34261 register : function(item)
34263 this.radioes.push(item);
34267 validate : function()
34269 if(this.getVisibilityEl().hasClass('hidden')){
34275 Roo.each(this.radioes, function(i){
34284 if(this.allowBlank) {
34288 if(this.disabled || valid){
34293 this.markInvalid();
34298 markValid : function()
34300 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34301 this.indicatorEl().removeClass('visible');
34302 this.indicatorEl().addClass('invisible');
34306 if (Roo.bootstrap.version == 3) {
34307 this.el.removeClass([this.invalidClass, this.validClass]);
34308 this.el.addClass(this.validClass);
34310 this.el.removeClass(['is-invalid','is-valid']);
34311 this.el.addClass(['is-valid']);
34313 this.fireEvent('valid', this);
34316 markInvalid : function(msg)
34318 if(this.allowBlank || this.disabled){
34322 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34323 this.indicatorEl().removeClass('invisible');
34324 this.indicatorEl().addClass('visible');
34326 if (Roo.bootstrap.version == 3) {
34327 this.el.removeClass([this.invalidClass, this.validClass]);
34328 this.el.addClass(this.invalidClass);
34330 this.el.removeClass(['is-invalid','is-valid']);
34331 this.el.addClass(['is-invalid']);
34334 this.fireEvent('invalid', this, msg);
34338 setValue : function(v, suppressEvent)
34340 if(this.value === v){
34347 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34350 Roo.each(this.radioes, function(i){
34352 i.el.removeClass('checked');
34355 Roo.each(this.radioes, function(i){
34357 if(i.value === v || i.value.toString() === v.toString()){
34359 i.el.addClass('checked');
34361 if(suppressEvent !== true){
34362 this.fireEvent('check', this, i);
34373 clearInvalid : function(){
34375 if(!this.el || this.preventMark){
34379 this.el.removeClass([this.invalidClass]);
34381 this.fireEvent('valid', this);
34386 Roo.apply(Roo.bootstrap.RadioSet, {
34390 register : function(set)
34392 this.groups[set.name] = set;
34395 get: function(name)
34397 if (typeof(this.groups[name]) == 'undefined') {
34401 return this.groups[name] ;
34407 * Ext JS Library 1.1.1
34408 * Copyright(c) 2006-2007, Ext JS, LLC.
34410 * Originally Released Under LGPL - original licence link has changed is not relivant.
34413 * <script type="text/javascript">
34418 * @class Roo.bootstrap.SplitBar
34419 * @extends Roo.util.Observable
34420 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34424 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34425 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34426 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34427 split.minSize = 100;
34428 split.maxSize = 600;
34429 split.animate = true;
34430 split.on('moved', splitterMoved);
34433 * Create a new SplitBar
34434 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34435 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34436 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34437 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34438 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34439 position of the SplitBar).
34441 Roo.bootstrap.SplitBar = function(cfg){
34446 // dragElement : elm
34447 // resizingElement: el,
34449 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34450 // placement : Roo.bootstrap.SplitBar.LEFT ,
34451 // existingProxy ???
34454 this.el = Roo.get(cfg.dragElement, true);
34455 this.el.dom.unselectable = "on";
34457 this.resizingEl = Roo.get(cfg.resizingElement, true);
34461 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34462 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34465 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34468 * The minimum size of the resizing element. (Defaults to 0)
34474 * The maximum size of the resizing element. (Defaults to 2000)
34477 this.maxSize = 2000;
34480 * Whether to animate the transition to the new size
34483 this.animate = false;
34486 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34489 this.useShim = false;
34494 if(!cfg.existingProxy){
34496 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34498 this.proxy = Roo.get(cfg.existingProxy).dom;
34501 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34504 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34507 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34510 this.dragSpecs = {};
34513 * @private The adapter to use to positon and resize elements
34515 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34516 this.adapter.init(this);
34518 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34520 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34521 this.el.addClass("roo-splitbar-h");
34524 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34525 this.el.addClass("roo-splitbar-v");
34531 * Fires when the splitter is moved (alias for {@link #event-moved})
34532 * @param {Roo.bootstrap.SplitBar} this
34533 * @param {Number} newSize the new width or height
34538 * Fires when the splitter is moved
34539 * @param {Roo.bootstrap.SplitBar} this
34540 * @param {Number} newSize the new width or height
34544 * @event beforeresize
34545 * Fires before the splitter is dragged
34546 * @param {Roo.bootstrap.SplitBar} this
34548 "beforeresize" : true,
34550 "beforeapply" : true
34553 Roo.util.Observable.call(this);
34556 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34557 onStartProxyDrag : function(x, y){
34558 this.fireEvent("beforeresize", this);
34560 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34562 o.enableDisplayMode("block");
34563 // all splitbars share the same overlay
34564 Roo.bootstrap.SplitBar.prototype.overlay = o;
34566 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34567 this.overlay.show();
34568 Roo.get(this.proxy).setDisplayed("block");
34569 var size = this.adapter.getElementSize(this);
34570 this.activeMinSize = this.getMinimumSize();;
34571 this.activeMaxSize = this.getMaximumSize();;
34572 var c1 = size - this.activeMinSize;
34573 var c2 = Math.max(this.activeMaxSize - size, 0);
34574 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34575 this.dd.resetConstraints();
34576 this.dd.setXConstraint(
34577 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34578 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34580 this.dd.setYConstraint(0, 0);
34582 this.dd.resetConstraints();
34583 this.dd.setXConstraint(0, 0);
34584 this.dd.setYConstraint(
34585 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34586 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34589 this.dragSpecs.startSize = size;
34590 this.dragSpecs.startPoint = [x, y];
34591 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34595 * @private Called after the drag operation by the DDProxy
34597 onEndProxyDrag : function(e){
34598 Roo.get(this.proxy).setDisplayed(false);
34599 var endPoint = Roo.lib.Event.getXY(e);
34601 this.overlay.hide();
34604 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34605 newSize = this.dragSpecs.startSize +
34606 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34607 endPoint[0] - this.dragSpecs.startPoint[0] :
34608 this.dragSpecs.startPoint[0] - endPoint[0]
34611 newSize = this.dragSpecs.startSize +
34612 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34613 endPoint[1] - this.dragSpecs.startPoint[1] :
34614 this.dragSpecs.startPoint[1] - endPoint[1]
34617 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34618 if(newSize != this.dragSpecs.startSize){
34619 if(this.fireEvent('beforeapply', this, newSize) !== false){
34620 this.adapter.setElementSize(this, newSize);
34621 this.fireEvent("moved", this, newSize);
34622 this.fireEvent("resize", this, newSize);
34628 * Get the adapter this SplitBar uses
34629 * @return The adapter object
34631 getAdapter : function(){
34632 return this.adapter;
34636 * Set the adapter this SplitBar uses
34637 * @param {Object} adapter A SplitBar adapter object
34639 setAdapter : function(adapter){
34640 this.adapter = adapter;
34641 this.adapter.init(this);
34645 * Gets the minimum size for the resizing element
34646 * @return {Number} The minimum size
34648 getMinimumSize : function(){
34649 return this.minSize;
34653 * Sets the minimum size for the resizing element
34654 * @param {Number} minSize The minimum size
34656 setMinimumSize : function(minSize){
34657 this.minSize = minSize;
34661 * Gets the maximum size for the resizing element
34662 * @return {Number} The maximum size
34664 getMaximumSize : function(){
34665 return this.maxSize;
34669 * Sets the maximum size for the resizing element
34670 * @param {Number} maxSize The maximum size
34672 setMaximumSize : function(maxSize){
34673 this.maxSize = maxSize;
34677 * Sets the initialize size for the resizing element
34678 * @param {Number} size The initial size
34680 setCurrentSize : function(size){
34681 var oldAnimate = this.animate;
34682 this.animate = false;
34683 this.adapter.setElementSize(this, size);
34684 this.animate = oldAnimate;
34688 * Destroy this splitbar.
34689 * @param {Boolean} removeEl True to remove the element
34691 destroy : function(removeEl){
34693 this.shim.remove();
34696 this.proxy.parentNode.removeChild(this.proxy);
34704 * @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.
34706 Roo.bootstrap.SplitBar.createProxy = function(dir){
34707 var proxy = new Roo.Element(document.createElement("div"));
34708 proxy.unselectable();
34709 var cls = 'roo-splitbar-proxy';
34710 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34711 document.body.appendChild(proxy.dom);
34716 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34717 * Default Adapter. It assumes the splitter and resizing element are not positioned
34718 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34720 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34723 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34724 // do nothing for now
34725 init : function(s){
34729 * Called before drag operations to get the current size of the resizing element.
34730 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34732 getElementSize : function(s){
34733 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34734 return s.resizingEl.getWidth();
34736 return s.resizingEl.getHeight();
34741 * Called after drag operations to set the size of the resizing element.
34742 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34743 * @param {Number} newSize The new size to set
34744 * @param {Function} onComplete A function to be invoked when resizing is complete
34746 setElementSize : function(s, newSize, onComplete){
34747 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34749 s.resizingEl.setWidth(newSize);
34751 onComplete(s, newSize);
34754 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34759 s.resizingEl.setHeight(newSize);
34761 onComplete(s, newSize);
34764 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34771 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34772 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34773 * Adapter that moves the splitter element to align with the resized sizing element.
34774 * Used with an absolute positioned SplitBar.
34775 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34776 * document.body, make sure you assign an id to the body element.
34778 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34779 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34780 this.container = Roo.get(container);
34783 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34784 init : function(s){
34785 this.basic.init(s);
34788 getElementSize : function(s){
34789 return this.basic.getElementSize(s);
34792 setElementSize : function(s, newSize, onComplete){
34793 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34796 moveSplitter : function(s){
34797 var yes = Roo.bootstrap.SplitBar;
34798 switch(s.placement){
34800 s.el.setX(s.resizingEl.getRight());
34803 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34806 s.el.setY(s.resizingEl.getBottom());
34809 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34816 * Orientation constant - Create a vertical SplitBar
34820 Roo.bootstrap.SplitBar.VERTICAL = 1;
34823 * Orientation constant - Create a horizontal SplitBar
34827 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34830 * Placement constant - The resizing element is to the left of the splitter element
34834 Roo.bootstrap.SplitBar.LEFT = 1;
34837 * Placement constant - The resizing element is to the right of the splitter element
34841 Roo.bootstrap.SplitBar.RIGHT = 2;
34844 * Placement constant - The resizing element is positioned above the splitter element
34848 Roo.bootstrap.SplitBar.TOP = 3;
34851 * Placement constant - The resizing element is positioned under splitter element
34855 Roo.bootstrap.SplitBar.BOTTOM = 4;
34856 Roo.namespace("Roo.bootstrap.layout");/*
34858 * Ext JS Library 1.1.1
34859 * Copyright(c) 2006-2007, Ext JS, LLC.
34861 * Originally Released Under LGPL - original licence link has changed is not relivant.
34864 * <script type="text/javascript">
34868 * @class Roo.bootstrap.layout.Manager
34869 * @extends Roo.bootstrap.Component
34870 * Base class for layout managers.
34872 Roo.bootstrap.layout.Manager = function(config)
34874 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34880 /** false to disable window resize monitoring @type Boolean */
34881 this.monitorWindowResize = true;
34886 * Fires when a layout is performed.
34887 * @param {Roo.LayoutManager} this
34891 * @event regionresized
34892 * Fires when the user resizes a region.
34893 * @param {Roo.LayoutRegion} region The resized region
34894 * @param {Number} newSize The new size (width for east/west, height for north/south)
34896 "regionresized" : true,
34898 * @event regioncollapsed
34899 * Fires when a region is collapsed.
34900 * @param {Roo.LayoutRegion} region The collapsed region
34902 "regioncollapsed" : true,
34904 * @event regionexpanded
34905 * Fires when a region is expanded.
34906 * @param {Roo.LayoutRegion} region The expanded region
34908 "regionexpanded" : true
34910 this.updating = false;
34913 this.el = Roo.get(config.el);
34919 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34924 monitorWindowResize : true,
34930 onRender : function(ct, position)
34933 this.el = Roo.get(ct);
34936 //this.fireEvent('render',this);
34940 initEvents: function()
34944 // ie scrollbar fix
34945 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34946 document.body.scroll = "no";
34947 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34948 this.el.position('relative');
34950 this.id = this.el.id;
34951 this.el.addClass("roo-layout-container");
34952 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34953 if(this.el.dom != document.body ) {
34954 this.el.on('resize', this.layout,this);
34955 this.el.on('show', this.layout,this);
34961 * Returns true if this layout is currently being updated
34962 * @return {Boolean}
34964 isUpdating : function(){
34965 return this.updating;
34969 * Suspend the LayoutManager from doing auto-layouts while
34970 * making multiple add or remove calls
34972 beginUpdate : function(){
34973 this.updating = true;
34977 * Restore auto-layouts and optionally disable the manager from performing a layout
34978 * @param {Boolean} noLayout true to disable a layout update
34980 endUpdate : function(noLayout){
34981 this.updating = false;
34987 layout: function(){
34991 onRegionResized : function(region, newSize){
34992 this.fireEvent("regionresized", region, newSize);
34996 onRegionCollapsed : function(region){
34997 this.fireEvent("regioncollapsed", region);
35000 onRegionExpanded : function(region){
35001 this.fireEvent("regionexpanded", region);
35005 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35006 * performs box-model adjustments.
35007 * @return {Object} The size as an object {width: (the width), height: (the height)}
35009 getViewSize : function()
35012 if(this.el.dom != document.body){
35013 size = this.el.getSize();
35015 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35017 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35018 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35023 * Returns the Element this layout is bound to.
35024 * @return {Roo.Element}
35026 getEl : function(){
35031 * Returns the specified region.
35032 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35033 * @return {Roo.LayoutRegion}
35035 getRegion : function(target){
35036 return this.regions[target.toLowerCase()];
35039 onWindowResize : function(){
35040 if(this.monitorWindowResize){
35047 * Ext JS Library 1.1.1
35048 * Copyright(c) 2006-2007, Ext JS, LLC.
35050 * Originally Released Under LGPL - original licence link has changed is not relivant.
35053 * <script type="text/javascript">
35056 * @class Roo.bootstrap.layout.Border
35057 * @extends Roo.bootstrap.layout.Manager
35058 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35059 * please see: examples/bootstrap/nested.html<br><br>
35061 <b>The container the layout is rendered into can be either the body element or any other element.
35062 If it is not the body element, the container needs to either be an absolute positioned element,
35063 or you will need to add "position:relative" to the css of the container. You will also need to specify
35064 the container size if it is not the body element.</b>
35067 * Create a new Border
35068 * @param {Object} config Configuration options
35070 Roo.bootstrap.layout.Border = function(config){
35071 config = config || {};
35072 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35076 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35077 if(config[region]){
35078 config[region].region = region;
35079 this.addRegion(config[region]);
35085 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35087 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35089 * Creates and adds a new region if it doesn't already exist.
35090 * @param {String} target The target region key (north, south, east, west or center).
35091 * @param {Object} config The regions config object
35092 * @return {BorderLayoutRegion} The new region
35094 addRegion : function(config)
35096 if(!this.regions[config.region]){
35097 var r = this.factory(config);
35098 this.bindRegion(r);
35100 return this.regions[config.region];
35104 bindRegion : function(r){
35105 this.regions[r.config.region] = r;
35107 r.on("visibilitychange", this.layout, this);
35108 r.on("paneladded", this.layout, this);
35109 r.on("panelremoved", this.layout, this);
35110 r.on("invalidated", this.layout, this);
35111 r.on("resized", this.onRegionResized, this);
35112 r.on("collapsed", this.onRegionCollapsed, this);
35113 r.on("expanded", this.onRegionExpanded, this);
35117 * Performs a layout update.
35119 layout : function()
35121 if(this.updating) {
35125 // render all the rebions if they have not been done alreayd?
35126 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35127 if(this.regions[region] && !this.regions[region].bodyEl){
35128 this.regions[region].onRender(this.el)
35132 var size = this.getViewSize();
35133 var w = size.width;
35134 var h = size.height;
35139 //var x = 0, y = 0;
35141 var rs = this.regions;
35142 var north = rs["north"];
35143 var south = rs["south"];
35144 var west = rs["west"];
35145 var east = rs["east"];
35146 var center = rs["center"];
35147 //if(this.hideOnLayout){ // not supported anymore
35148 //c.el.setStyle("display", "none");
35150 if(north && north.isVisible()){
35151 var b = north.getBox();
35152 var m = north.getMargins();
35153 b.width = w - (m.left+m.right);
35156 centerY = b.height + b.y + m.bottom;
35157 centerH -= centerY;
35158 north.updateBox(this.safeBox(b));
35160 if(south && south.isVisible()){
35161 var b = south.getBox();
35162 var m = south.getMargins();
35163 b.width = w - (m.left+m.right);
35165 var totalHeight = (b.height + m.top + m.bottom);
35166 b.y = h - totalHeight + m.top;
35167 centerH -= totalHeight;
35168 south.updateBox(this.safeBox(b));
35170 if(west && west.isVisible()){
35171 var b = west.getBox();
35172 var m = west.getMargins();
35173 b.height = centerH - (m.top+m.bottom);
35175 b.y = centerY + m.top;
35176 var totalWidth = (b.width + m.left + m.right);
35177 centerX += totalWidth;
35178 centerW -= totalWidth;
35179 west.updateBox(this.safeBox(b));
35181 if(east && east.isVisible()){
35182 var b = east.getBox();
35183 var m = east.getMargins();
35184 b.height = centerH - (m.top+m.bottom);
35185 var totalWidth = (b.width + m.left + m.right);
35186 b.x = w - totalWidth + m.left;
35187 b.y = centerY + m.top;
35188 centerW -= totalWidth;
35189 east.updateBox(this.safeBox(b));
35192 var m = center.getMargins();
35194 x: centerX + m.left,
35195 y: centerY + m.top,
35196 width: centerW - (m.left+m.right),
35197 height: centerH - (m.top+m.bottom)
35199 //if(this.hideOnLayout){
35200 //center.el.setStyle("display", "block");
35202 center.updateBox(this.safeBox(centerBox));
35205 this.fireEvent("layout", this);
35209 safeBox : function(box){
35210 box.width = Math.max(0, box.width);
35211 box.height = Math.max(0, box.height);
35216 * Adds a ContentPanel (or subclass) to this layout.
35217 * @param {String} target The target region key (north, south, east, west or center).
35218 * @param {Roo.ContentPanel} panel The panel to add
35219 * @return {Roo.ContentPanel} The added panel
35221 add : function(target, panel){
35223 target = target.toLowerCase();
35224 return this.regions[target].add(panel);
35228 * Remove a ContentPanel (or subclass) to this layout.
35229 * @param {String} target The target region key (north, south, east, west or center).
35230 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35231 * @return {Roo.ContentPanel} The removed panel
35233 remove : function(target, panel){
35234 target = target.toLowerCase();
35235 return this.regions[target].remove(panel);
35239 * Searches all regions for a panel with the specified id
35240 * @param {String} panelId
35241 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35243 findPanel : function(panelId){
35244 var rs = this.regions;
35245 for(var target in rs){
35246 if(typeof rs[target] != "function"){
35247 var p = rs[target].getPanel(panelId);
35257 * Searches all regions for a panel with the specified id and activates (shows) it.
35258 * @param {String/ContentPanel} panelId The panels id or the panel itself
35259 * @return {Roo.ContentPanel} The shown panel or null
35261 showPanel : function(panelId) {
35262 var rs = this.regions;
35263 for(var target in rs){
35264 var r = rs[target];
35265 if(typeof r != "function"){
35266 if(r.hasPanel(panelId)){
35267 return r.showPanel(panelId);
35275 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35276 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35279 restoreState : function(provider){
35281 provider = Roo.state.Manager;
35283 var sm = new Roo.LayoutStateManager();
35284 sm.init(this, provider);
35290 * Adds a xtype elements to the layout.
35294 xtype : 'ContentPanel',
35301 xtype : 'NestedLayoutPanel',
35307 items : [ ... list of content panels or nested layout panels.. ]
35311 * @param {Object} cfg Xtype definition of item to add.
35313 addxtype : function(cfg)
35315 // basically accepts a pannel...
35316 // can accept a layout region..!?!?
35317 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35320 // theory? children can only be panels??
35322 //if (!cfg.xtype.match(/Panel$/)) {
35327 if (typeof(cfg.region) == 'undefined') {
35328 Roo.log("Failed to add Panel, region was not set");
35332 var region = cfg.region;
35338 xitems = cfg.items;
35345 case 'Content': // ContentPanel (el, cfg)
35346 case 'Scroll': // ContentPanel (el, cfg)
35348 cfg.autoCreate = true;
35349 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35351 // var el = this.el.createChild();
35352 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35355 this.add(region, ret);
35359 case 'TreePanel': // our new panel!
35360 cfg.el = this.el.createChild();
35361 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35362 this.add(region, ret);
35367 // create a new Layout (which is a Border Layout...
35369 var clayout = cfg.layout;
35370 clayout.el = this.el.createChild();
35371 clayout.items = clayout.items || [];
35375 // replace this exitems with the clayout ones..
35376 xitems = clayout.items;
35378 // force background off if it's in center...
35379 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35380 cfg.background = false;
35382 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35385 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35386 //console.log('adding nested layout panel ' + cfg.toSource());
35387 this.add(region, ret);
35388 nb = {}; /// find first...
35393 // needs grid and region
35395 //var el = this.getRegion(region).el.createChild();
35397 *var el = this.el.createChild();
35398 // create the grid first...
35399 cfg.grid.container = el;
35400 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35403 if (region == 'center' && this.active ) {
35404 cfg.background = false;
35407 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35409 this.add(region, ret);
35411 if (cfg.background) {
35412 // render grid on panel activation (if panel background)
35413 ret.on('activate', function(gp) {
35414 if (!gp.grid.rendered) {
35415 // gp.grid.render(el);
35419 // cfg.grid.render(el);
35425 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35426 // it was the old xcomponent building that caused this before.
35427 // espeically if border is the top element in the tree.
35437 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35439 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35440 this.add(region, ret);
35444 throw "Can not add '" + cfg.xtype + "' to Border";
35450 this.beginUpdate();
35454 Roo.each(xitems, function(i) {
35455 region = nb && i.region ? i.region : false;
35457 var add = ret.addxtype(i);
35460 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35461 if (!i.background) {
35462 abn[region] = nb[region] ;
35469 // make the last non-background panel active..
35470 //if (nb) { Roo.log(abn); }
35473 for(var r in abn) {
35474 region = this.getRegion(r);
35476 // tried using nb[r], but it does not work..
35478 region.showPanel(abn[r]);
35489 factory : function(cfg)
35492 var validRegions = Roo.bootstrap.layout.Border.regions;
35494 var target = cfg.region;
35497 var r = Roo.bootstrap.layout;
35501 return new r.North(cfg);
35503 return new r.South(cfg);
35505 return new r.East(cfg);
35507 return new r.West(cfg);
35509 return new r.Center(cfg);
35511 throw 'Layout region "'+target+'" not supported.';
35518 * Ext JS Library 1.1.1
35519 * Copyright(c) 2006-2007, Ext JS, LLC.
35521 * Originally Released Under LGPL - original licence link has changed is not relivant.
35524 * <script type="text/javascript">
35528 * @class Roo.bootstrap.layout.Basic
35529 * @extends Roo.util.Observable
35530 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35531 * and does not have a titlebar, tabs or any other features. All it does is size and position
35532 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35533 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35534 * @cfg {string} region the region that it inhabits..
35535 * @cfg {bool} skipConfig skip config?
35539 Roo.bootstrap.layout.Basic = function(config){
35541 this.mgr = config.mgr;
35543 this.position = config.region;
35545 var skipConfig = config.skipConfig;
35549 * @scope Roo.BasicLayoutRegion
35553 * @event beforeremove
35554 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35555 * @param {Roo.LayoutRegion} this
35556 * @param {Roo.ContentPanel} panel The panel
35557 * @param {Object} e The cancel event object
35559 "beforeremove" : true,
35561 * @event invalidated
35562 * Fires when the layout for this region is changed.
35563 * @param {Roo.LayoutRegion} this
35565 "invalidated" : true,
35567 * @event visibilitychange
35568 * Fires when this region is shown or hidden
35569 * @param {Roo.LayoutRegion} this
35570 * @param {Boolean} visibility true or false
35572 "visibilitychange" : true,
35574 * @event paneladded
35575 * Fires when a panel is added.
35576 * @param {Roo.LayoutRegion} this
35577 * @param {Roo.ContentPanel} panel The panel
35579 "paneladded" : true,
35581 * @event panelremoved
35582 * Fires when a panel is removed.
35583 * @param {Roo.LayoutRegion} this
35584 * @param {Roo.ContentPanel} panel The panel
35586 "panelremoved" : true,
35588 * @event beforecollapse
35589 * Fires when this region before collapse.
35590 * @param {Roo.LayoutRegion} this
35592 "beforecollapse" : true,
35595 * Fires when this region is collapsed.
35596 * @param {Roo.LayoutRegion} this
35598 "collapsed" : true,
35601 * Fires when this region is expanded.
35602 * @param {Roo.LayoutRegion} this
35607 * Fires when this region is slid into view.
35608 * @param {Roo.LayoutRegion} this
35610 "slideshow" : true,
35613 * Fires when this region slides out of view.
35614 * @param {Roo.LayoutRegion} this
35616 "slidehide" : true,
35618 * @event panelactivated
35619 * Fires when a panel is activated.
35620 * @param {Roo.LayoutRegion} this
35621 * @param {Roo.ContentPanel} panel The activated panel
35623 "panelactivated" : true,
35626 * Fires when the user resizes this region.
35627 * @param {Roo.LayoutRegion} this
35628 * @param {Number} newSize The new size (width for east/west, height for north/south)
35632 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35633 this.panels = new Roo.util.MixedCollection();
35634 this.panels.getKey = this.getPanelId.createDelegate(this);
35636 this.activePanel = null;
35637 // ensure listeners are added...
35639 if (config.listeners || config.events) {
35640 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35641 listeners : config.listeners || {},
35642 events : config.events || {}
35646 if(skipConfig !== true){
35647 this.applyConfig(config);
35651 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35653 getPanelId : function(p){
35657 applyConfig : function(config){
35658 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35659 this.config = config;
35664 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35665 * the width, for horizontal (north, south) the height.
35666 * @param {Number} newSize The new width or height
35668 resizeTo : function(newSize){
35669 var el = this.el ? this.el :
35670 (this.activePanel ? this.activePanel.getEl() : null);
35672 switch(this.position){
35675 el.setWidth(newSize);
35676 this.fireEvent("resized", this, newSize);
35680 el.setHeight(newSize);
35681 this.fireEvent("resized", this, newSize);
35687 getBox : function(){
35688 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35691 getMargins : function(){
35692 return this.margins;
35695 updateBox : function(box){
35697 var el = this.activePanel.getEl();
35698 el.dom.style.left = box.x + "px";
35699 el.dom.style.top = box.y + "px";
35700 this.activePanel.setSize(box.width, box.height);
35704 * Returns the container element for this region.
35705 * @return {Roo.Element}
35707 getEl : function(){
35708 return this.activePanel;
35712 * Returns true if this region is currently visible.
35713 * @return {Boolean}
35715 isVisible : function(){
35716 return this.activePanel ? true : false;
35719 setActivePanel : function(panel){
35720 panel = this.getPanel(panel);
35721 if(this.activePanel && this.activePanel != panel){
35722 this.activePanel.setActiveState(false);
35723 this.activePanel.getEl().setLeftTop(-10000,-10000);
35725 this.activePanel = panel;
35726 panel.setActiveState(true);
35728 panel.setSize(this.box.width, this.box.height);
35730 this.fireEvent("panelactivated", this, panel);
35731 this.fireEvent("invalidated");
35735 * Show the specified panel.
35736 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35737 * @return {Roo.ContentPanel} The shown panel or null
35739 showPanel : function(panel){
35740 panel = this.getPanel(panel);
35742 this.setActivePanel(panel);
35748 * Get the active panel for this region.
35749 * @return {Roo.ContentPanel} The active panel or null
35751 getActivePanel : function(){
35752 return this.activePanel;
35756 * Add the passed ContentPanel(s)
35757 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35758 * @return {Roo.ContentPanel} The panel added (if only one was added)
35760 add : function(panel){
35761 if(arguments.length > 1){
35762 for(var i = 0, len = arguments.length; i < len; i++) {
35763 this.add(arguments[i]);
35767 if(this.hasPanel(panel)){
35768 this.showPanel(panel);
35771 var el = panel.getEl();
35772 if(el.dom.parentNode != this.mgr.el.dom){
35773 this.mgr.el.dom.appendChild(el.dom);
35775 if(panel.setRegion){
35776 panel.setRegion(this);
35778 this.panels.add(panel);
35779 el.setStyle("position", "absolute");
35780 if(!panel.background){
35781 this.setActivePanel(panel);
35782 if(this.config.initialSize && this.panels.getCount()==1){
35783 this.resizeTo(this.config.initialSize);
35786 this.fireEvent("paneladded", this, panel);
35791 * Returns true if the panel is in this region.
35792 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35793 * @return {Boolean}
35795 hasPanel : function(panel){
35796 if(typeof panel == "object"){ // must be panel obj
35797 panel = panel.getId();
35799 return this.getPanel(panel) ? true : false;
35803 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35804 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35805 * @param {Boolean} preservePanel Overrides the config preservePanel option
35806 * @return {Roo.ContentPanel} The panel that was removed
35808 remove : function(panel, preservePanel){
35809 panel = this.getPanel(panel);
35814 this.fireEvent("beforeremove", this, panel, e);
35815 if(e.cancel === true){
35818 var panelId = panel.getId();
35819 this.panels.removeKey(panelId);
35824 * Returns the panel specified or null if it's not in this region.
35825 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35826 * @return {Roo.ContentPanel}
35828 getPanel : function(id){
35829 if(typeof id == "object"){ // must be panel obj
35832 return this.panels.get(id);
35836 * Returns this regions position (north/south/east/west/center).
35839 getPosition: function(){
35840 return this.position;
35844 * Ext JS Library 1.1.1
35845 * Copyright(c) 2006-2007, Ext JS, LLC.
35847 * Originally Released Under LGPL - original licence link has changed is not relivant.
35850 * <script type="text/javascript">
35854 * @class Roo.bootstrap.layout.Region
35855 * @extends Roo.bootstrap.layout.Basic
35856 * This class represents a region in a layout manager.
35858 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35859 * @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})
35860 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35861 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35862 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35863 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35864 * @cfg {String} title The title for the region (overrides panel titles)
35865 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35866 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35867 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35868 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35869 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35870 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35871 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35872 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35873 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35874 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35876 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35877 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35878 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35879 * @cfg {Number} width For East/West panels
35880 * @cfg {Number} height For North/South panels
35881 * @cfg {Boolean} split To show the splitter
35882 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35884 * @cfg {string} cls Extra CSS classes to add to region
35886 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35887 * @cfg {string} region the region that it inhabits..
35890 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35891 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35893 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35894 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35895 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35897 Roo.bootstrap.layout.Region = function(config)
35899 this.applyConfig(config);
35901 var mgr = config.mgr;
35902 var pos = config.region;
35903 config.skipConfig = true;
35904 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35907 this.onRender(mgr.el);
35910 this.visible = true;
35911 this.collapsed = false;
35912 this.unrendered_panels = [];
35915 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35917 position: '', // set by wrapper (eg. north/south etc..)
35918 unrendered_panels : null, // unrendered panels.
35919 createBody : function(){
35920 /** This region's body element
35921 * @type Roo.Element */
35922 this.bodyEl = this.el.createChild({
35924 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35928 onRender: function(ctr, pos)
35930 var dh = Roo.DomHelper;
35931 /** This region's container element
35932 * @type Roo.Element */
35933 this.el = dh.append(ctr.dom, {
35935 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35937 /** This region's title element
35938 * @type Roo.Element */
35940 this.titleEl = dh.append(this.el.dom,
35943 unselectable: "on",
35944 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35946 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35947 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35950 this.titleEl.enableDisplayMode();
35951 /** This region's title text element
35952 * @type HTMLElement */
35953 this.titleTextEl = this.titleEl.dom.firstChild;
35954 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35956 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35957 this.closeBtn.enableDisplayMode();
35958 this.closeBtn.on("click", this.closeClicked, this);
35959 this.closeBtn.hide();
35961 this.createBody(this.config);
35962 if(this.config.hideWhenEmpty){
35964 this.on("paneladded", this.validateVisibility, this);
35965 this.on("panelremoved", this.validateVisibility, this);
35967 if(this.autoScroll){
35968 this.bodyEl.setStyle("overflow", "auto");
35970 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35972 //if(c.titlebar !== false){
35973 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35974 this.titleEl.hide();
35976 this.titleEl.show();
35977 if(this.config.title){
35978 this.titleTextEl.innerHTML = this.config.title;
35982 if(this.config.collapsed){
35983 this.collapse(true);
35985 if(this.config.hidden){
35989 if (this.unrendered_panels && this.unrendered_panels.length) {
35990 for (var i =0;i< this.unrendered_panels.length; i++) {
35991 this.add(this.unrendered_panels[i]);
35993 this.unrendered_panels = null;
35999 applyConfig : function(c)
36002 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36003 var dh = Roo.DomHelper;
36004 if(c.titlebar !== false){
36005 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36006 this.collapseBtn.on("click", this.collapse, this);
36007 this.collapseBtn.enableDisplayMode();
36009 if(c.showPin === true || this.showPin){
36010 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36011 this.stickBtn.enableDisplayMode();
36012 this.stickBtn.on("click", this.expand, this);
36013 this.stickBtn.hide();
36018 /** This region's collapsed element
36019 * @type Roo.Element */
36022 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36023 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36026 if(c.floatable !== false){
36027 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36028 this.collapsedEl.on("click", this.collapseClick, this);
36031 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36032 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36033 id: "message", unselectable: "on", style:{"float":"left"}});
36034 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36036 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36037 this.expandBtn.on("click", this.expand, this);
36041 if(this.collapseBtn){
36042 this.collapseBtn.setVisible(c.collapsible == true);
36045 this.cmargins = c.cmargins || this.cmargins ||
36046 (this.position == "west" || this.position == "east" ?
36047 {top: 0, left: 2, right:2, bottom: 0} :
36048 {top: 2, left: 0, right:0, bottom: 2});
36050 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36053 this.bottomTabs = c.tabPosition != "top";
36055 this.autoScroll = c.autoScroll || false;
36060 this.duration = c.duration || .30;
36061 this.slideDuration = c.slideDuration || .45;
36066 * Returns true if this region is currently visible.
36067 * @return {Boolean}
36069 isVisible : function(){
36070 return this.visible;
36074 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36075 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36077 //setCollapsedTitle : function(title){
36078 // title = title || " ";
36079 // if(this.collapsedTitleTextEl){
36080 // this.collapsedTitleTextEl.innerHTML = title;
36084 getBox : function(){
36086 // if(!this.collapsed){
36087 b = this.el.getBox(false, true);
36089 // b = this.collapsedEl.getBox(false, true);
36094 getMargins : function(){
36095 return this.margins;
36096 //return this.collapsed ? this.cmargins : this.margins;
36099 highlight : function(){
36100 this.el.addClass("x-layout-panel-dragover");
36103 unhighlight : function(){
36104 this.el.removeClass("x-layout-panel-dragover");
36107 updateBox : function(box)
36109 if (!this.bodyEl) {
36110 return; // not rendered yet..
36114 if(!this.collapsed){
36115 this.el.dom.style.left = box.x + "px";
36116 this.el.dom.style.top = box.y + "px";
36117 this.updateBody(box.width, box.height);
36119 this.collapsedEl.dom.style.left = box.x + "px";
36120 this.collapsedEl.dom.style.top = box.y + "px";
36121 this.collapsedEl.setSize(box.width, box.height);
36124 this.tabs.autoSizeTabs();
36128 updateBody : function(w, h)
36131 this.el.setWidth(w);
36132 w -= this.el.getBorderWidth("rl");
36133 if(this.config.adjustments){
36134 w += this.config.adjustments[0];
36137 if(h !== null && h > 0){
36138 this.el.setHeight(h);
36139 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36140 h -= this.el.getBorderWidth("tb");
36141 if(this.config.adjustments){
36142 h += this.config.adjustments[1];
36144 this.bodyEl.setHeight(h);
36146 h = this.tabs.syncHeight(h);
36149 if(this.panelSize){
36150 w = w !== null ? w : this.panelSize.width;
36151 h = h !== null ? h : this.panelSize.height;
36153 if(this.activePanel){
36154 var el = this.activePanel.getEl();
36155 w = w !== null ? w : el.getWidth();
36156 h = h !== null ? h : el.getHeight();
36157 this.panelSize = {width: w, height: h};
36158 this.activePanel.setSize(w, h);
36160 if(Roo.isIE && this.tabs){
36161 this.tabs.el.repaint();
36166 * Returns the container element for this region.
36167 * @return {Roo.Element}
36169 getEl : function(){
36174 * Hides this region.
36177 //if(!this.collapsed){
36178 this.el.dom.style.left = "-2000px";
36181 // this.collapsedEl.dom.style.left = "-2000px";
36182 // this.collapsedEl.hide();
36184 this.visible = false;
36185 this.fireEvent("visibilitychange", this, false);
36189 * Shows this region if it was previously hidden.
36192 //if(!this.collapsed){
36195 // this.collapsedEl.show();
36197 this.visible = true;
36198 this.fireEvent("visibilitychange", this, true);
36201 closeClicked : function(){
36202 if(this.activePanel){
36203 this.remove(this.activePanel);
36207 collapseClick : function(e){
36209 e.stopPropagation();
36212 e.stopPropagation();
36218 * Collapses this region.
36219 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36222 collapse : function(skipAnim, skipCheck = false){
36223 if(this.collapsed) {
36227 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36229 this.collapsed = true;
36231 this.split.el.hide();
36233 if(this.config.animate && skipAnim !== true){
36234 this.fireEvent("invalidated", this);
36235 this.animateCollapse();
36237 this.el.setLocation(-20000,-20000);
36239 this.collapsedEl.show();
36240 this.fireEvent("collapsed", this);
36241 this.fireEvent("invalidated", this);
36247 animateCollapse : function(){
36252 * Expands this region if it was previously collapsed.
36253 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36254 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36257 expand : function(e, skipAnim){
36259 e.stopPropagation();
36261 if(!this.collapsed || this.el.hasActiveFx()) {
36265 this.afterSlideIn();
36268 this.collapsed = false;
36269 if(this.config.animate && skipAnim !== true){
36270 this.animateExpand();
36274 this.split.el.show();
36276 this.collapsedEl.setLocation(-2000,-2000);
36277 this.collapsedEl.hide();
36278 this.fireEvent("invalidated", this);
36279 this.fireEvent("expanded", this);
36283 animateExpand : function(){
36287 initTabs : function()
36289 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36291 var ts = new Roo.bootstrap.panel.Tabs({
36292 el: this.bodyEl.dom,
36293 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36294 disableTooltips: this.config.disableTabTips,
36295 toolbar : this.config.toolbar
36298 if(this.config.hideTabs){
36299 ts.stripWrap.setDisplayed(false);
36302 ts.resizeTabs = this.config.resizeTabs === true;
36303 ts.minTabWidth = this.config.minTabWidth || 40;
36304 ts.maxTabWidth = this.config.maxTabWidth || 250;
36305 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36306 ts.monitorResize = false;
36307 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36308 ts.bodyEl.addClass('roo-layout-tabs-body');
36309 this.panels.each(this.initPanelAsTab, this);
36312 initPanelAsTab : function(panel){
36313 var ti = this.tabs.addTab(
36317 this.config.closeOnTab && panel.isClosable(),
36320 if(panel.tabTip !== undefined){
36321 ti.setTooltip(panel.tabTip);
36323 ti.on("activate", function(){
36324 this.setActivePanel(panel);
36327 if(this.config.closeOnTab){
36328 ti.on("beforeclose", function(t, e){
36330 this.remove(panel);
36334 panel.tabItem = ti;
36339 updatePanelTitle : function(panel, title)
36341 if(this.activePanel == panel){
36342 this.updateTitle(title);
36345 var ti = this.tabs.getTab(panel.getEl().id);
36347 if(panel.tabTip !== undefined){
36348 ti.setTooltip(panel.tabTip);
36353 updateTitle : function(title){
36354 if(this.titleTextEl && !this.config.title){
36355 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36359 setActivePanel : function(panel)
36361 panel = this.getPanel(panel);
36362 if(this.activePanel && this.activePanel != panel){
36363 if(this.activePanel.setActiveState(false) === false){
36367 this.activePanel = panel;
36368 panel.setActiveState(true);
36369 if(this.panelSize){
36370 panel.setSize(this.panelSize.width, this.panelSize.height);
36373 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36375 this.updateTitle(panel.getTitle());
36377 this.fireEvent("invalidated", this);
36379 this.fireEvent("panelactivated", this, panel);
36383 * Shows the specified panel.
36384 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36385 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36387 showPanel : function(panel)
36389 panel = this.getPanel(panel);
36392 var tab = this.tabs.getTab(panel.getEl().id);
36393 if(tab.isHidden()){
36394 this.tabs.unhideTab(tab.id);
36398 this.setActivePanel(panel);
36405 * Get the active panel for this region.
36406 * @return {Roo.ContentPanel} The active panel or null
36408 getActivePanel : function(){
36409 return this.activePanel;
36412 validateVisibility : function(){
36413 if(this.panels.getCount() < 1){
36414 this.updateTitle(" ");
36415 this.closeBtn.hide();
36418 if(!this.isVisible()){
36425 * Adds the passed ContentPanel(s) to this region.
36426 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36427 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36429 add : function(panel)
36431 if(arguments.length > 1){
36432 for(var i = 0, len = arguments.length; i < len; i++) {
36433 this.add(arguments[i]);
36438 // if we have not been rendered yet, then we can not really do much of this..
36439 if (!this.bodyEl) {
36440 this.unrendered_panels.push(panel);
36447 if(this.hasPanel(panel)){
36448 this.showPanel(panel);
36451 panel.setRegion(this);
36452 this.panels.add(panel);
36453 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36454 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36455 // and hide them... ???
36456 this.bodyEl.dom.appendChild(panel.getEl().dom);
36457 if(panel.background !== true){
36458 this.setActivePanel(panel);
36460 this.fireEvent("paneladded", this, panel);
36467 this.initPanelAsTab(panel);
36471 if(panel.background !== true){
36472 this.tabs.activate(panel.getEl().id);
36474 this.fireEvent("paneladded", this, panel);
36479 * Hides the tab for the specified panel.
36480 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36482 hidePanel : function(panel){
36483 if(this.tabs && (panel = this.getPanel(panel))){
36484 this.tabs.hideTab(panel.getEl().id);
36489 * Unhides the tab for a previously hidden panel.
36490 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36492 unhidePanel : function(panel){
36493 if(this.tabs && (panel = this.getPanel(panel))){
36494 this.tabs.unhideTab(panel.getEl().id);
36498 clearPanels : function(){
36499 while(this.panels.getCount() > 0){
36500 this.remove(this.panels.first());
36505 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36506 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36507 * @param {Boolean} preservePanel Overrides the config preservePanel option
36508 * @return {Roo.ContentPanel} The panel that was removed
36510 remove : function(panel, preservePanel)
36512 panel = this.getPanel(panel);
36517 this.fireEvent("beforeremove", this, panel, e);
36518 if(e.cancel === true){
36521 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36522 var panelId = panel.getId();
36523 this.panels.removeKey(panelId);
36525 document.body.appendChild(panel.getEl().dom);
36528 this.tabs.removeTab(panel.getEl().id);
36529 }else if (!preservePanel){
36530 this.bodyEl.dom.removeChild(panel.getEl().dom);
36532 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36533 var p = this.panels.first();
36534 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36535 tempEl.appendChild(p.getEl().dom);
36536 this.bodyEl.update("");
36537 this.bodyEl.dom.appendChild(p.getEl().dom);
36539 this.updateTitle(p.getTitle());
36541 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36542 this.setActivePanel(p);
36544 panel.setRegion(null);
36545 if(this.activePanel == panel){
36546 this.activePanel = null;
36548 if(this.config.autoDestroy !== false && preservePanel !== true){
36549 try{panel.destroy();}catch(e){}
36551 this.fireEvent("panelremoved", this, panel);
36556 * Returns the TabPanel component used by this region
36557 * @return {Roo.TabPanel}
36559 getTabs : function(){
36563 createTool : function(parentEl, className){
36564 var btn = Roo.DomHelper.append(parentEl, {
36566 cls: "x-layout-tools-button",
36569 cls: "roo-layout-tools-button-inner " + className,
36573 btn.addClassOnOver("roo-layout-tools-button-over");
36578 * Ext JS Library 1.1.1
36579 * Copyright(c) 2006-2007, Ext JS, LLC.
36581 * Originally Released Under LGPL - original licence link has changed is not relivant.
36584 * <script type="text/javascript">
36590 * @class Roo.SplitLayoutRegion
36591 * @extends Roo.LayoutRegion
36592 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36594 Roo.bootstrap.layout.Split = function(config){
36595 this.cursor = config.cursor;
36596 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36599 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36601 splitTip : "Drag to resize.",
36602 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36603 useSplitTips : false,
36605 applyConfig : function(config){
36606 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36609 onRender : function(ctr,pos) {
36611 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36612 if(!this.config.split){
36617 var splitEl = Roo.DomHelper.append(ctr.dom, {
36619 id: this.el.id + "-split",
36620 cls: "roo-layout-split roo-layout-split-"+this.position,
36623 /** The SplitBar for this region
36624 * @type Roo.SplitBar */
36625 // does not exist yet...
36626 Roo.log([this.position, this.orientation]);
36628 this.split = new Roo.bootstrap.SplitBar({
36629 dragElement : splitEl,
36630 resizingElement: this.el,
36631 orientation : this.orientation
36634 this.split.on("moved", this.onSplitMove, this);
36635 this.split.useShim = this.config.useShim === true;
36636 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36637 if(this.useSplitTips){
36638 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36640 //if(config.collapsible){
36641 // this.split.el.on("dblclick", this.collapse, this);
36644 if(typeof this.config.minSize != "undefined"){
36645 this.split.minSize = this.config.minSize;
36647 if(typeof this.config.maxSize != "undefined"){
36648 this.split.maxSize = this.config.maxSize;
36650 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36651 this.hideSplitter();
36656 getHMaxSize : function(){
36657 var cmax = this.config.maxSize || 10000;
36658 var center = this.mgr.getRegion("center");
36659 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36662 getVMaxSize : function(){
36663 var cmax = this.config.maxSize || 10000;
36664 var center = this.mgr.getRegion("center");
36665 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36668 onSplitMove : function(split, newSize){
36669 this.fireEvent("resized", this, newSize);
36673 * Returns the {@link Roo.SplitBar} for this region.
36674 * @return {Roo.SplitBar}
36676 getSplitBar : function(){
36681 this.hideSplitter();
36682 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36685 hideSplitter : function(){
36687 this.split.el.setLocation(-2000,-2000);
36688 this.split.el.hide();
36694 this.split.el.show();
36696 Roo.bootstrap.layout.Split.superclass.show.call(this);
36699 beforeSlide: function(){
36700 if(Roo.isGecko){// firefox overflow auto bug workaround
36701 this.bodyEl.clip();
36703 this.tabs.bodyEl.clip();
36705 if(this.activePanel){
36706 this.activePanel.getEl().clip();
36708 if(this.activePanel.beforeSlide){
36709 this.activePanel.beforeSlide();
36715 afterSlide : function(){
36716 if(Roo.isGecko){// firefox overflow auto bug workaround
36717 this.bodyEl.unclip();
36719 this.tabs.bodyEl.unclip();
36721 if(this.activePanel){
36722 this.activePanel.getEl().unclip();
36723 if(this.activePanel.afterSlide){
36724 this.activePanel.afterSlide();
36730 initAutoHide : function(){
36731 if(this.autoHide !== false){
36732 if(!this.autoHideHd){
36733 var st = new Roo.util.DelayedTask(this.slideIn, this);
36734 this.autoHideHd = {
36735 "mouseout": function(e){
36736 if(!e.within(this.el, true)){
36740 "mouseover" : function(e){
36746 this.el.on(this.autoHideHd);
36750 clearAutoHide : function(){
36751 if(this.autoHide !== false){
36752 this.el.un("mouseout", this.autoHideHd.mouseout);
36753 this.el.un("mouseover", this.autoHideHd.mouseover);
36757 clearMonitor : function(){
36758 Roo.get(document).un("click", this.slideInIf, this);
36761 // these names are backwards but not changed for compat
36762 slideOut : function(){
36763 if(this.isSlid || this.el.hasActiveFx()){
36766 this.isSlid = true;
36767 if(this.collapseBtn){
36768 this.collapseBtn.hide();
36770 this.closeBtnState = this.closeBtn.getStyle('display');
36771 this.closeBtn.hide();
36773 this.stickBtn.show();
36776 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36777 this.beforeSlide();
36778 this.el.setStyle("z-index", 10001);
36779 this.el.slideIn(this.getSlideAnchor(), {
36780 callback: function(){
36782 this.initAutoHide();
36783 Roo.get(document).on("click", this.slideInIf, this);
36784 this.fireEvent("slideshow", this);
36791 afterSlideIn : function(){
36792 this.clearAutoHide();
36793 this.isSlid = false;
36794 this.clearMonitor();
36795 this.el.setStyle("z-index", "");
36796 if(this.collapseBtn){
36797 this.collapseBtn.show();
36799 this.closeBtn.setStyle('display', this.closeBtnState);
36801 this.stickBtn.hide();
36803 this.fireEvent("slidehide", this);
36806 slideIn : function(cb){
36807 if(!this.isSlid || this.el.hasActiveFx()){
36811 this.isSlid = false;
36812 this.beforeSlide();
36813 this.el.slideOut(this.getSlideAnchor(), {
36814 callback: function(){
36815 this.el.setLeftTop(-10000, -10000);
36817 this.afterSlideIn();
36825 slideInIf : function(e){
36826 if(!e.within(this.el)){
36831 animateCollapse : function(){
36832 this.beforeSlide();
36833 this.el.setStyle("z-index", 20000);
36834 var anchor = this.getSlideAnchor();
36835 this.el.slideOut(anchor, {
36836 callback : function(){
36837 this.el.setStyle("z-index", "");
36838 this.collapsedEl.slideIn(anchor, {duration:.3});
36840 this.el.setLocation(-10000,-10000);
36842 this.fireEvent("collapsed", this);
36849 animateExpand : function(){
36850 this.beforeSlide();
36851 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36852 this.el.setStyle("z-index", 20000);
36853 this.collapsedEl.hide({
36856 this.el.slideIn(this.getSlideAnchor(), {
36857 callback : function(){
36858 this.el.setStyle("z-index", "");
36861 this.split.el.show();
36863 this.fireEvent("invalidated", this);
36864 this.fireEvent("expanded", this);
36892 getAnchor : function(){
36893 return this.anchors[this.position];
36896 getCollapseAnchor : function(){
36897 return this.canchors[this.position];
36900 getSlideAnchor : function(){
36901 return this.sanchors[this.position];
36904 getAlignAdj : function(){
36905 var cm = this.cmargins;
36906 switch(this.position){
36922 getExpandAdj : function(){
36923 var c = this.collapsedEl, cm = this.cmargins;
36924 switch(this.position){
36926 return [-(cm.right+c.getWidth()+cm.left), 0];
36929 return [cm.right+c.getWidth()+cm.left, 0];
36932 return [0, -(cm.top+cm.bottom+c.getHeight())];
36935 return [0, cm.top+cm.bottom+c.getHeight()];
36941 * Ext JS Library 1.1.1
36942 * Copyright(c) 2006-2007, Ext JS, LLC.
36944 * Originally Released Under LGPL - original licence link has changed is not relivant.
36947 * <script type="text/javascript">
36950 * These classes are private internal classes
36952 Roo.bootstrap.layout.Center = function(config){
36953 config.region = "center";
36954 Roo.bootstrap.layout.Region.call(this, config);
36955 this.visible = true;
36956 this.minWidth = config.minWidth || 20;
36957 this.minHeight = config.minHeight || 20;
36960 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36962 // center panel can't be hidden
36966 // center panel can't be hidden
36969 getMinWidth: function(){
36970 return this.minWidth;
36973 getMinHeight: function(){
36974 return this.minHeight;
36987 Roo.bootstrap.layout.North = function(config)
36989 config.region = 'north';
36990 config.cursor = 'n-resize';
36992 Roo.bootstrap.layout.Split.call(this, config);
36996 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36997 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36998 this.split.el.addClass("roo-layout-split-v");
37000 var size = config.initialSize || config.height;
37001 if(typeof size != "undefined"){
37002 this.el.setHeight(size);
37005 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37007 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37011 getBox : function(){
37012 if(this.collapsed){
37013 return this.collapsedEl.getBox();
37015 var box = this.el.getBox();
37017 box.height += this.split.el.getHeight();
37022 updateBox : function(box){
37023 if(this.split && !this.collapsed){
37024 box.height -= this.split.el.getHeight();
37025 this.split.el.setLeft(box.x);
37026 this.split.el.setTop(box.y+box.height);
37027 this.split.el.setWidth(box.width);
37029 if(this.collapsed){
37030 this.updateBody(box.width, null);
37032 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37040 Roo.bootstrap.layout.South = function(config){
37041 config.region = 'south';
37042 config.cursor = 's-resize';
37043 Roo.bootstrap.layout.Split.call(this, config);
37045 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37046 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37047 this.split.el.addClass("roo-layout-split-v");
37049 var size = config.initialSize || config.height;
37050 if(typeof size != "undefined"){
37051 this.el.setHeight(size);
37055 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37056 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37057 getBox : function(){
37058 if(this.collapsed){
37059 return this.collapsedEl.getBox();
37061 var box = this.el.getBox();
37063 var sh = this.split.el.getHeight();
37070 updateBox : function(box){
37071 if(this.split && !this.collapsed){
37072 var sh = this.split.el.getHeight();
37075 this.split.el.setLeft(box.x);
37076 this.split.el.setTop(box.y-sh);
37077 this.split.el.setWidth(box.width);
37079 if(this.collapsed){
37080 this.updateBody(box.width, null);
37082 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37086 Roo.bootstrap.layout.East = function(config){
37087 config.region = "east";
37088 config.cursor = "e-resize";
37089 Roo.bootstrap.layout.Split.call(this, config);
37091 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37092 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37093 this.split.el.addClass("roo-layout-split-h");
37095 var size = config.initialSize || config.width;
37096 if(typeof size != "undefined"){
37097 this.el.setWidth(size);
37100 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37101 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37102 getBox : function(){
37103 if(this.collapsed){
37104 return this.collapsedEl.getBox();
37106 var box = this.el.getBox();
37108 var sw = this.split.el.getWidth();
37115 updateBox : function(box){
37116 if(this.split && !this.collapsed){
37117 var sw = this.split.el.getWidth();
37119 this.split.el.setLeft(box.x);
37120 this.split.el.setTop(box.y);
37121 this.split.el.setHeight(box.height);
37124 if(this.collapsed){
37125 this.updateBody(null, box.height);
37127 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37131 Roo.bootstrap.layout.West = function(config){
37132 config.region = "west";
37133 config.cursor = "w-resize";
37135 Roo.bootstrap.layout.Split.call(this, config);
37137 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37138 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37139 this.split.el.addClass("roo-layout-split-h");
37143 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37144 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37146 onRender: function(ctr, pos)
37148 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37149 var size = this.config.initialSize || this.config.width;
37150 if(typeof size != "undefined"){
37151 this.el.setWidth(size);
37155 getBox : function(){
37156 if(this.collapsed){
37157 return this.collapsedEl.getBox();
37159 var box = this.el.getBox();
37161 box.width += this.split.el.getWidth();
37166 updateBox : function(box){
37167 if(this.split && !this.collapsed){
37168 var sw = this.split.el.getWidth();
37170 this.split.el.setLeft(box.x+box.width);
37171 this.split.el.setTop(box.y);
37172 this.split.el.setHeight(box.height);
37174 if(this.collapsed){
37175 this.updateBody(null, box.height);
37177 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37180 Roo.namespace("Roo.bootstrap.panel");/*
37182 * Ext JS Library 1.1.1
37183 * Copyright(c) 2006-2007, Ext JS, LLC.
37185 * Originally Released Under LGPL - original licence link has changed is not relivant.
37188 * <script type="text/javascript">
37191 * @class Roo.ContentPanel
37192 * @extends Roo.util.Observable
37193 * A basic ContentPanel element.
37194 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37195 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37196 * @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
37197 * @cfg {Boolean} closable True if the panel can be closed/removed
37198 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37199 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37200 * @cfg {Toolbar} toolbar A toolbar for this panel
37201 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37202 * @cfg {String} title The title for this panel
37203 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37204 * @cfg {String} url Calls {@link #setUrl} with this value
37205 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37206 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37207 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37208 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37209 * @cfg {Boolean} badges render the badges
37212 * Create a new ContentPanel.
37213 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37214 * @param {String/Object} config A string to set only the title or a config object
37215 * @param {String} content (optional) Set the HTML content for this panel
37216 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37218 Roo.bootstrap.panel.Content = function( config){
37220 this.tpl = config.tpl || false;
37222 var el = config.el;
37223 var content = config.content;
37225 if(config.autoCreate){ // xtype is available if this is called from factory
37228 this.el = Roo.get(el);
37229 if(!this.el && config && config.autoCreate){
37230 if(typeof config.autoCreate == "object"){
37231 if(!config.autoCreate.id){
37232 config.autoCreate.id = config.id||el;
37234 this.el = Roo.DomHelper.append(document.body,
37235 config.autoCreate, true);
37237 var elcfg = { tag: "div",
37238 cls: "roo-layout-inactive-content",
37242 elcfg.html = config.html;
37246 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37249 this.closable = false;
37250 this.loaded = false;
37251 this.active = false;
37254 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37256 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37258 this.wrapEl = this.el; //this.el.wrap();
37260 if (config.toolbar.items) {
37261 ti = config.toolbar.items ;
37262 delete config.toolbar.items ;
37266 this.toolbar.render(this.wrapEl, 'before');
37267 for(var i =0;i < ti.length;i++) {
37268 // Roo.log(['add child', items[i]]);
37269 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37271 this.toolbar.items = nitems;
37272 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37273 delete config.toolbar;
37277 // xtype created footer. - not sure if will work as we normally have to render first..
37278 if (this.footer && !this.footer.el && this.footer.xtype) {
37279 if (!this.wrapEl) {
37280 this.wrapEl = this.el.wrap();
37283 this.footer.container = this.wrapEl.createChild();
37285 this.footer = Roo.factory(this.footer, Roo);
37290 if(typeof config == "string"){
37291 this.title = config;
37293 Roo.apply(this, config);
37297 this.resizeEl = Roo.get(this.resizeEl, true);
37299 this.resizeEl = this.el;
37301 // handle view.xtype
37309 * Fires when this panel is activated.
37310 * @param {Roo.ContentPanel} this
37314 * @event deactivate
37315 * Fires when this panel is activated.
37316 * @param {Roo.ContentPanel} this
37318 "deactivate" : true,
37322 * Fires when this panel is resized if fitToFrame is true.
37323 * @param {Roo.ContentPanel} this
37324 * @param {Number} width The width after any component adjustments
37325 * @param {Number} height The height after any component adjustments
37331 * Fires when this tab is created
37332 * @param {Roo.ContentPanel} this
37343 if(this.autoScroll){
37344 this.resizeEl.setStyle("overflow", "auto");
37346 // fix randome scrolling
37347 //this.el.on('scroll', function() {
37348 // Roo.log('fix random scolling');
37349 // this.scrollTo('top',0);
37352 content = content || this.content;
37354 this.setContent(content);
37356 if(config && config.url){
37357 this.setUrl(this.url, this.params, this.loadOnce);
37362 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37364 if (this.view && typeof(this.view.xtype) != 'undefined') {
37365 this.view.el = this.el.appendChild(document.createElement("div"));
37366 this.view = Roo.factory(this.view);
37367 this.view.render && this.view.render(false, '');
37371 this.fireEvent('render', this);
37374 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37378 setRegion : function(region){
37379 this.region = region;
37380 this.setActiveClass(region && !this.background);
37384 setActiveClass: function(state)
37387 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37388 this.el.setStyle('position','relative');
37390 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37391 this.el.setStyle('position', 'absolute');
37396 * Returns the toolbar for this Panel if one was configured.
37397 * @return {Roo.Toolbar}
37399 getToolbar : function(){
37400 return this.toolbar;
37403 setActiveState : function(active)
37405 this.active = active;
37406 this.setActiveClass(active);
37408 if(this.fireEvent("deactivate", this) === false){
37413 this.fireEvent("activate", this);
37417 * Updates this panel's element
37418 * @param {String} content The new content
37419 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37421 setContent : function(content, loadScripts){
37422 this.el.update(content, loadScripts);
37425 ignoreResize : function(w, h){
37426 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37429 this.lastSize = {width: w, height: h};
37434 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37435 * @return {Roo.UpdateManager} The UpdateManager
37437 getUpdateManager : function(){
37438 return this.el.getUpdateManager();
37441 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37442 * @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:
37445 url: "your-url.php",
37446 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37447 callback: yourFunction,
37448 scope: yourObject, //(optional scope)
37451 text: "Loading...",
37456 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37457 * 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.
37458 * @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}
37459 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37460 * @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.
37461 * @return {Roo.ContentPanel} this
37464 var um = this.el.getUpdateManager();
37465 um.update.apply(um, arguments);
37471 * 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.
37472 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37473 * @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)
37474 * @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)
37475 * @return {Roo.UpdateManager} The UpdateManager
37477 setUrl : function(url, params, loadOnce){
37478 if(this.refreshDelegate){
37479 this.removeListener("activate", this.refreshDelegate);
37481 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37482 this.on("activate", this.refreshDelegate);
37483 return this.el.getUpdateManager();
37486 _handleRefresh : function(url, params, loadOnce){
37487 if(!loadOnce || !this.loaded){
37488 var updater = this.el.getUpdateManager();
37489 updater.update(url, params, this._setLoaded.createDelegate(this));
37493 _setLoaded : function(){
37494 this.loaded = true;
37498 * Returns this panel's id
37501 getId : function(){
37506 * Returns this panel's element - used by regiosn to add.
37507 * @return {Roo.Element}
37509 getEl : function(){
37510 return this.wrapEl || this.el;
37515 adjustForComponents : function(width, height)
37517 //Roo.log('adjustForComponents ');
37518 if(this.resizeEl != this.el){
37519 width -= this.el.getFrameWidth('lr');
37520 height -= this.el.getFrameWidth('tb');
37523 var te = this.toolbar.getEl();
37524 te.setWidth(width);
37525 height -= te.getHeight();
37528 var te = this.footer.getEl();
37529 te.setWidth(width);
37530 height -= te.getHeight();
37534 if(this.adjustments){
37535 width += this.adjustments[0];
37536 height += this.adjustments[1];
37538 return {"width": width, "height": height};
37541 setSize : function(width, height){
37542 if(this.fitToFrame && !this.ignoreResize(width, height)){
37543 if(this.fitContainer && this.resizeEl != this.el){
37544 this.el.setSize(width, height);
37546 var size = this.adjustForComponents(width, height);
37547 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37548 this.fireEvent('resize', this, size.width, size.height);
37553 * Returns this panel's title
37556 getTitle : function(){
37558 if (typeof(this.title) != 'object') {
37563 for (var k in this.title) {
37564 if (!this.title.hasOwnProperty(k)) {
37568 if (k.indexOf('-') >= 0) {
37569 var s = k.split('-');
37570 for (var i = 0; i<s.length; i++) {
37571 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37574 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37581 * Set this panel's title
37582 * @param {String} title
37584 setTitle : function(title){
37585 this.title = title;
37587 this.region.updatePanelTitle(this, title);
37592 * Returns true is this panel was configured to be closable
37593 * @return {Boolean}
37595 isClosable : function(){
37596 return this.closable;
37599 beforeSlide : function(){
37601 this.resizeEl.clip();
37604 afterSlide : function(){
37606 this.resizeEl.unclip();
37610 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37611 * Will fail silently if the {@link #setUrl} method has not been called.
37612 * This does not activate the panel, just updates its content.
37614 refresh : function(){
37615 if(this.refreshDelegate){
37616 this.loaded = false;
37617 this.refreshDelegate();
37622 * Destroys this panel
37624 destroy : function(){
37625 this.el.removeAllListeners();
37626 var tempEl = document.createElement("span");
37627 tempEl.appendChild(this.el.dom);
37628 tempEl.innerHTML = "";
37634 * form - if the content panel contains a form - this is a reference to it.
37635 * @type {Roo.form.Form}
37639 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37640 * This contains a reference to it.
37646 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37656 * @param {Object} cfg Xtype definition of item to add.
37660 getChildContainer: function () {
37661 return this.getEl();
37666 var ret = new Roo.factory(cfg);
37671 if (cfg.xtype.match(/^Form$/)) {
37674 //if (this.footer) {
37675 // el = this.footer.container.insertSibling(false, 'before');
37677 el = this.el.createChild();
37680 this.form = new Roo.form.Form(cfg);
37683 if ( this.form.allItems.length) {
37684 this.form.render(el.dom);
37688 // should only have one of theses..
37689 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37690 // views.. should not be just added - used named prop 'view''
37692 cfg.el = this.el.appendChild(document.createElement("div"));
37695 var ret = new Roo.factory(cfg);
37697 ret.render && ret.render(false, ''); // render blank..
37707 * @class Roo.bootstrap.panel.Grid
37708 * @extends Roo.bootstrap.panel.Content
37710 * Create a new GridPanel.
37711 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37712 * @param {Object} config A the config object
37718 Roo.bootstrap.panel.Grid = function(config)
37722 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37723 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37725 config.el = this.wrapper;
37726 //this.el = this.wrapper;
37728 if (config.container) {
37729 // ctor'ed from a Border/panel.grid
37732 this.wrapper.setStyle("overflow", "hidden");
37733 this.wrapper.addClass('roo-grid-container');
37738 if(config.toolbar){
37739 var tool_el = this.wrapper.createChild();
37740 this.toolbar = Roo.factory(config.toolbar);
37742 if (config.toolbar.items) {
37743 ti = config.toolbar.items ;
37744 delete config.toolbar.items ;
37748 this.toolbar.render(tool_el);
37749 for(var i =0;i < ti.length;i++) {
37750 // Roo.log(['add child', items[i]]);
37751 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37753 this.toolbar.items = nitems;
37755 delete config.toolbar;
37758 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37759 config.grid.scrollBody = true;;
37760 config.grid.monitorWindowResize = false; // turn off autosizing
37761 config.grid.autoHeight = false;
37762 config.grid.autoWidth = false;
37764 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37766 if (config.background) {
37767 // render grid on panel activation (if panel background)
37768 this.on('activate', function(gp) {
37769 if (!gp.grid.rendered) {
37770 gp.grid.render(this.wrapper);
37771 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37776 this.grid.render(this.wrapper);
37777 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37780 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37781 // ??? needed ??? config.el = this.wrapper;
37786 // xtype created footer. - not sure if will work as we normally have to render first..
37787 if (this.footer && !this.footer.el && this.footer.xtype) {
37789 var ctr = this.grid.getView().getFooterPanel(true);
37790 this.footer.dataSource = this.grid.dataSource;
37791 this.footer = Roo.factory(this.footer, Roo);
37792 this.footer.render(ctr);
37802 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37803 getId : function(){
37804 return this.grid.id;
37808 * Returns the grid for this panel
37809 * @return {Roo.bootstrap.Table}
37811 getGrid : function(){
37815 setSize : function(width, height){
37816 if(!this.ignoreResize(width, height)){
37817 var grid = this.grid;
37818 var size = this.adjustForComponents(width, height);
37819 var gridel = grid.getGridEl();
37820 gridel.setSize(size.width, size.height);
37822 var thd = grid.getGridEl().select('thead',true).first();
37823 var tbd = grid.getGridEl().select('tbody', true).first();
37825 tbd.setSize(width, height - thd.getHeight());
37834 beforeSlide : function(){
37835 this.grid.getView().scroller.clip();
37838 afterSlide : function(){
37839 this.grid.getView().scroller.unclip();
37842 destroy : function(){
37843 this.grid.destroy();
37845 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37850 * @class Roo.bootstrap.panel.Nest
37851 * @extends Roo.bootstrap.panel.Content
37853 * Create a new Panel, that can contain a layout.Border.
37856 * @param {Roo.BorderLayout} layout The layout for this panel
37857 * @param {String/Object} config A string to set only the title or a config object
37859 Roo.bootstrap.panel.Nest = function(config)
37861 // construct with only one argument..
37862 /* FIXME - implement nicer consturctors
37863 if (layout.layout) {
37865 layout = config.layout;
37866 delete config.layout;
37868 if (layout.xtype && !layout.getEl) {
37869 // then layout needs constructing..
37870 layout = Roo.factory(layout, Roo);
37874 config.el = config.layout.getEl();
37876 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37878 config.layout.monitorWindowResize = false; // turn off autosizing
37879 this.layout = config.layout;
37880 this.layout.getEl().addClass("roo-layout-nested-layout");
37887 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37889 setSize : function(width, height){
37890 if(!this.ignoreResize(width, height)){
37891 var size = this.adjustForComponents(width, height);
37892 var el = this.layout.getEl();
37893 if (size.height < 1) {
37894 el.setWidth(size.width);
37896 el.setSize(size.width, size.height);
37898 var touch = el.dom.offsetWidth;
37899 this.layout.layout();
37900 // ie requires a double layout on the first pass
37901 if(Roo.isIE && !this.initialized){
37902 this.initialized = true;
37903 this.layout.layout();
37908 // activate all subpanels if not currently active..
37910 setActiveState : function(active){
37911 this.active = active;
37912 this.setActiveClass(active);
37915 this.fireEvent("deactivate", this);
37919 this.fireEvent("activate", this);
37920 // not sure if this should happen before or after..
37921 if (!this.layout) {
37922 return; // should not happen..
37925 for (var r in this.layout.regions) {
37926 reg = this.layout.getRegion(r);
37927 if (reg.getActivePanel()) {
37928 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37929 reg.setActivePanel(reg.getActivePanel());
37932 if (!reg.panels.length) {
37935 reg.showPanel(reg.getPanel(0));
37944 * Returns the nested BorderLayout for this panel
37945 * @return {Roo.BorderLayout}
37947 getLayout : function(){
37948 return this.layout;
37952 * Adds a xtype elements to the layout of the nested panel
37956 xtype : 'ContentPanel',
37963 xtype : 'NestedLayoutPanel',
37969 items : [ ... list of content panels or nested layout panels.. ]
37973 * @param {Object} cfg Xtype definition of item to add.
37975 addxtype : function(cfg) {
37976 return this.layout.addxtype(cfg);
37981 * Ext JS Library 1.1.1
37982 * Copyright(c) 2006-2007, Ext JS, LLC.
37984 * Originally Released Under LGPL - original licence link has changed is not relivant.
37987 * <script type="text/javascript">
37990 * @class Roo.TabPanel
37991 * @extends Roo.util.Observable
37992 * A lightweight tab container.
37996 // basic tabs 1, built from existing content
37997 var tabs = new Roo.TabPanel("tabs1");
37998 tabs.addTab("script", "View Script");
37999 tabs.addTab("markup", "View Markup");
38000 tabs.activate("script");
38002 // more advanced tabs, built from javascript
38003 var jtabs = new Roo.TabPanel("jtabs");
38004 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38006 // set up the UpdateManager
38007 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38008 var updater = tab2.getUpdateManager();
38009 updater.setDefaultUrl("ajax1.htm");
38010 tab2.on('activate', updater.refresh, updater, true);
38012 // Use setUrl for Ajax loading
38013 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38014 tab3.setUrl("ajax2.htm", null, true);
38017 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38020 jtabs.activate("jtabs-1");
38023 * Create a new TabPanel.
38024 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38025 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38027 Roo.bootstrap.panel.Tabs = function(config){
38029 * The container element for this TabPanel.
38030 * @type Roo.Element
38032 this.el = Roo.get(config.el);
38035 if(typeof config == "boolean"){
38036 this.tabPosition = config ? "bottom" : "top";
38038 Roo.apply(this, config);
38042 if(this.tabPosition == "bottom"){
38043 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38044 this.el.addClass("roo-tabs-bottom");
38046 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38047 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38048 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38049 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38051 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38053 if(this.tabPosition != "bottom"){
38054 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38055 * @type Roo.Element
38057 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38058 this.el.addClass("roo-tabs-top");
38062 this.bodyEl.setStyle("position", "relative");
38064 this.active = null;
38065 this.activateDelegate = this.activate.createDelegate(this);
38070 * Fires when the active tab changes
38071 * @param {Roo.TabPanel} this
38072 * @param {Roo.TabPanelItem} activePanel The new active tab
38076 * @event beforetabchange
38077 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38078 * @param {Roo.TabPanel} this
38079 * @param {Object} e Set cancel to true on this object to cancel the tab change
38080 * @param {Roo.TabPanelItem} tab The tab being changed to
38082 "beforetabchange" : true
38085 Roo.EventManager.onWindowResize(this.onResize, this);
38086 this.cpad = this.el.getPadding("lr");
38087 this.hiddenCount = 0;
38090 // toolbar on the tabbar support...
38091 if (this.toolbar) {
38092 alert("no toolbar support yet");
38093 this.toolbar = false;
38095 var tcfg = this.toolbar;
38096 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38097 this.toolbar = new Roo.Toolbar(tcfg);
38098 if (Roo.isSafari) {
38099 var tbl = tcfg.container.child('table', true);
38100 tbl.setAttribute('width', '100%');
38108 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38111 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38113 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38115 tabPosition : "top",
38117 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38119 currentTabWidth : 0,
38121 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38125 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38129 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38131 preferredTabWidth : 175,
38133 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38135 resizeTabs : false,
38137 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38139 monitorResize : true,
38141 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38146 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38147 * @param {String} id The id of the div to use <b>or create</b>
38148 * @param {String} text The text for the tab
38149 * @param {String} content (optional) Content to put in the TabPanelItem body
38150 * @param {Boolean} closable (optional) True to create a close icon on the tab
38151 * @return {Roo.TabPanelItem} The created TabPanelItem
38153 addTab : function(id, text, content, closable, tpl)
38155 var item = new Roo.bootstrap.panel.TabItem({
38159 closable : closable,
38162 this.addTabItem(item);
38164 item.setContent(content);
38170 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38171 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38172 * @return {Roo.TabPanelItem}
38174 getTab : function(id){
38175 return this.items[id];
38179 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38180 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38182 hideTab : function(id){
38183 var t = this.items[id];
38186 this.hiddenCount++;
38187 this.autoSizeTabs();
38192 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38193 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38195 unhideTab : function(id){
38196 var t = this.items[id];
38198 t.setHidden(false);
38199 this.hiddenCount--;
38200 this.autoSizeTabs();
38205 * Adds an existing {@link Roo.TabPanelItem}.
38206 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38208 addTabItem : function(item)
38210 this.items[item.id] = item;
38211 this.items.push(item);
38212 this.autoSizeTabs();
38213 // if(this.resizeTabs){
38214 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38215 // this.autoSizeTabs();
38217 // item.autoSize();
38222 * Removes a {@link Roo.TabPanelItem}.
38223 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38225 removeTab : function(id){
38226 var items = this.items;
38227 var tab = items[id];
38228 if(!tab) { return; }
38229 var index = items.indexOf(tab);
38230 if(this.active == tab && items.length > 1){
38231 var newTab = this.getNextAvailable(index);
38236 this.stripEl.dom.removeChild(tab.pnode.dom);
38237 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38238 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38240 items.splice(index, 1);
38241 delete this.items[tab.id];
38242 tab.fireEvent("close", tab);
38243 tab.purgeListeners();
38244 this.autoSizeTabs();
38247 getNextAvailable : function(start){
38248 var items = this.items;
38250 // look for a next tab that will slide over to
38251 // replace the one being removed
38252 while(index < items.length){
38253 var item = items[++index];
38254 if(item && !item.isHidden()){
38258 // if one isn't found select the previous tab (on the left)
38261 var item = items[--index];
38262 if(item && !item.isHidden()){
38270 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38271 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38273 disableTab : function(id){
38274 var tab = this.items[id];
38275 if(tab && this.active != tab){
38281 * Enables a {@link Roo.TabPanelItem} that is disabled.
38282 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38284 enableTab : function(id){
38285 var tab = this.items[id];
38290 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38291 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38292 * @return {Roo.TabPanelItem} The TabPanelItem.
38294 activate : function(id)
38296 var tab = this.items[id];
38300 if(tab == this.active || tab.disabled){
38304 this.fireEvent("beforetabchange", this, e, tab);
38305 if(e.cancel !== true && !tab.disabled){
38307 this.active.hide();
38309 this.active = this.items[id];
38310 this.active.show();
38311 this.fireEvent("tabchange", this, this.active);
38317 * Gets the active {@link Roo.TabPanelItem}.
38318 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38320 getActiveTab : function(){
38321 return this.active;
38325 * Updates the tab body element to fit the height of the container element
38326 * for overflow scrolling
38327 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38329 syncHeight : function(targetHeight){
38330 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38331 var bm = this.bodyEl.getMargins();
38332 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38333 this.bodyEl.setHeight(newHeight);
38337 onResize : function(){
38338 if(this.monitorResize){
38339 this.autoSizeTabs();
38344 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38346 beginUpdate : function(){
38347 this.updating = true;
38351 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38353 endUpdate : function(){
38354 this.updating = false;
38355 this.autoSizeTabs();
38359 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38361 autoSizeTabs : function()
38363 var count = this.items.length;
38364 var vcount = count - this.hiddenCount;
38367 this.stripEl.hide();
38369 this.stripEl.show();
38372 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38377 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38378 var availWidth = Math.floor(w / vcount);
38379 var b = this.stripBody;
38380 if(b.getWidth() > w){
38381 var tabs = this.items;
38382 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38383 if(availWidth < this.minTabWidth){
38384 /*if(!this.sleft){ // incomplete scrolling code
38385 this.createScrollButtons();
38388 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38391 if(this.currentTabWidth < this.preferredTabWidth){
38392 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38398 * Returns the number of tabs in this TabPanel.
38401 getCount : function(){
38402 return this.items.length;
38406 * Resizes all the tabs to the passed width
38407 * @param {Number} The new width
38409 setTabWidth : function(width){
38410 this.currentTabWidth = width;
38411 for(var i = 0, len = this.items.length; i < len; i++) {
38412 if(!this.items[i].isHidden()) {
38413 this.items[i].setWidth(width);
38419 * Destroys this TabPanel
38420 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38422 destroy : function(removeEl){
38423 Roo.EventManager.removeResizeListener(this.onResize, this);
38424 for(var i = 0, len = this.items.length; i < len; i++){
38425 this.items[i].purgeListeners();
38427 if(removeEl === true){
38428 this.el.update("");
38433 createStrip : function(container)
38435 var strip = document.createElement("nav");
38436 strip.className = Roo.bootstrap.version == 4 ?
38437 "navbar-light bg-light" :
38438 "navbar navbar-default"; //"x-tabs-wrap";
38439 container.appendChild(strip);
38443 createStripList : function(strip)
38445 // div wrapper for retard IE
38446 // returns the "tr" element.
38447 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38448 //'<div class="x-tabs-strip-wrap">'+
38449 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38450 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38451 return strip.firstChild; //.firstChild.firstChild.firstChild;
38453 createBody : function(container)
38455 var body = document.createElement("div");
38456 Roo.id(body, "tab-body");
38457 //Roo.fly(body).addClass("x-tabs-body");
38458 Roo.fly(body).addClass("tab-content");
38459 container.appendChild(body);
38462 createItemBody :function(bodyEl, id){
38463 var body = Roo.getDom(id);
38465 body = document.createElement("div");
38468 //Roo.fly(body).addClass("x-tabs-item-body");
38469 Roo.fly(body).addClass("tab-pane");
38470 bodyEl.insertBefore(body, bodyEl.firstChild);
38474 createStripElements : function(stripEl, text, closable, tpl)
38476 var td = document.createElement("li"); // was td..
38477 td.className = 'nav-item';
38479 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38482 stripEl.appendChild(td);
38484 td.className = "x-tabs-closable";
38485 if(!this.closeTpl){
38486 this.closeTpl = new Roo.Template(
38487 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38488 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38489 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38492 var el = this.closeTpl.overwrite(td, {"text": text});
38493 var close = el.getElementsByTagName("div")[0];
38494 var inner = el.getElementsByTagName("em")[0];
38495 return {"el": el, "close": close, "inner": inner};
38498 // not sure what this is..
38499 // if(!this.tabTpl){
38500 //this.tabTpl = new Roo.Template(
38501 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38502 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38504 // this.tabTpl = new Roo.Template(
38505 // '<a href="#">' +
38506 // '<span unselectable="on"' +
38507 // (this.disableTooltips ? '' : ' title="{text}"') +
38508 // ' >{text}</span></a>'
38514 var template = tpl || this.tabTpl || false;
38517 template = new Roo.Template(
38518 Roo.bootstrap.version == 4 ?
38520 '<a class="nav-link" href="#" unselectable="on"' +
38521 (this.disableTooltips ? '' : ' title="{text}"') +
38524 '<a class="nav-link" href="#">' +
38525 '<span unselectable="on"' +
38526 (this.disableTooltips ? '' : ' title="{text}"') +
38527 ' >{text}</span></a>'
38532 switch (typeof(template)) {
38536 template = new Roo.Template(template);
38542 var el = template.overwrite(td, {"text": text});
38544 var inner = el.getElementsByTagName("span")[0];
38546 return {"el": el, "inner": inner};
38554 * @class Roo.TabPanelItem
38555 * @extends Roo.util.Observable
38556 * Represents an individual item (tab plus body) in a TabPanel.
38557 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38558 * @param {String} id The id of this TabPanelItem
38559 * @param {String} text The text for the tab of this TabPanelItem
38560 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38562 Roo.bootstrap.panel.TabItem = function(config){
38564 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38565 * @type Roo.TabPanel
38567 this.tabPanel = config.panel;
38569 * The id for this TabPanelItem
38572 this.id = config.id;
38574 this.disabled = false;
38576 this.text = config.text;
38578 this.loaded = false;
38579 this.closable = config.closable;
38582 * The body element for this TabPanelItem.
38583 * @type Roo.Element
38585 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38586 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38587 this.bodyEl.setStyle("display", "block");
38588 this.bodyEl.setStyle("zoom", "1");
38589 //this.hideAction();
38591 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38593 this.el = Roo.get(els.el);
38594 this.inner = Roo.get(els.inner, true);
38595 this.textEl = Roo.bootstrap.version == 4 ?
38596 this.el : Roo.get(this.el.dom.firstChild, true);
38598 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38599 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38602 // this.el.on("mousedown", this.onTabMouseDown, this);
38603 this.el.on("click", this.onTabClick, this);
38605 if(config.closable){
38606 var c = Roo.get(els.close, true);
38607 c.dom.title = this.closeText;
38608 c.addClassOnOver("close-over");
38609 c.on("click", this.closeClick, this);
38615 * Fires when this tab becomes the active tab.
38616 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38617 * @param {Roo.TabPanelItem} this
38621 * @event beforeclose
38622 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38623 * @param {Roo.TabPanelItem} this
38624 * @param {Object} e Set cancel to true on this object to cancel the close.
38626 "beforeclose": true,
38629 * Fires when this tab is closed.
38630 * @param {Roo.TabPanelItem} this
38634 * @event deactivate
38635 * Fires when this tab is no longer the active tab.
38636 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38637 * @param {Roo.TabPanelItem} this
38639 "deactivate" : true
38641 this.hidden = false;
38643 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38646 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38648 purgeListeners : function(){
38649 Roo.util.Observable.prototype.purgeListeners.call(this);
38650 this.el.removeAllListeners();
38653 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38656 this.status_node.addClass("active");
38659 this.tabPanel.stripWrap.repaint();
38661 this.fireEvent("activate", this.tabPanel, this);
38665 * Returns true if this tab is the active tab.
38666 * @return {Boolean}
38668 isActive : function(){
38669 return this.tabPanel.getActiveTab() == this;
38673 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38676 this.status_node.removeClass("active");
38678 this.fireEvent("deactivate", this.tabPanel, this);
38681 hideAction : function(){
38682 this.bodyEl.hide();
38683 this.bodyEl.setStyle("position", "absolute");
38684 this.bodyEl.setLeft("-20000px");
38685 this.bodyEl.setTop("-20000px");
38688 showAction : function(){
38689 this.bodyEl.setStyle("position", "relative");
38690 this.bodyEl.setTop("");
38691 this.bodyEl.setLeft("");
38692 this.bodyEl.show();
38696 * Set the tooltip for the tab.
38697 * @param {String} tooltip The tab's tooltip
38699 setTooltip : function(text){
38700 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38701 this.textEl.dom.qtip = text;
38702 this.textEl.dom.removeAttribute('title');
38704 this.textEl.dom.title = text;
38708 onTabClick : function(e){
38709 e.preventDefault();
38710 this.tabPanel.activate(this.id);
38713 onTabMouseDown : function(e){
38714 e.preventDefault();
38715 this.tabPanel.activate(this.id);
38718 getWidth : function(){
38719 return this.inner.getWidth();
38722 setWidth : function(width){
38723 var iwidth = width - this.linode.getPadding("lr");
38724 this.inner.setWidth(iwidth);
38725 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38726 this.linode.setWidth(width);
38730 * Show or hide the tab
38731 * @param {Boolean} hidden True to hide or false to show.
38733 setHidden : function(hidden){
38734 this.hidden = hidden;
38735 this.linode.setStyle("display", hidden ? "none" : "");
38739 * Returns true if this tab is "hidden"
38740 * @return {Boolean}
38742 isHidden : function(){
38743 return this.hidden;
38747 * Returns the text for this tab
38750 getText : function(){
38754 autoSize : function(){
38755 //this.el.beginMeasure();
38756 this.textEl.setWidth(1);
38758 * #2804 [new] Tabs in Roojs
38759 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38761 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38762 //this.el.endMeasure();
38766 * Sets the text for the tab (Note: this also sets the tooltip text)
38767 * @param {String} text The tab's text and tooltip
38769 setText : function(text){
38771 this.textEl.update(text);
38772 this.setTooltip(text);
38773 //if(!this.tabPanel.resizeTabs){
38774 // this.autoSize();
38778 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38780 activate : function(){
38781 this.tabPanel.activate(this.id);
38785 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38787 disable : function(){
38788 if(this.tabPanel.active != this){
38789 this.disabled = true;
38790 this.status_node.addClass("disabled");
38795 * Enables this TabPanelItem if it was previously disabled.
38797 enable : function(){
38798 this.disabled = false;
38799 this.status_node.removeClass("disabled");
38803 * Sets the content for this TabPanelItem.
38804 * @param {String} content The content
38805 * @param {Boolean} loadScripts true to look for and load scripts
38807 setContent : function(content, loadScripts){
38808 this.bodyEl.update(content, loadScripts);
38812 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38813 * @return {Roo.UpdateManager} The UpdateManager
38815 getUpdateManager : function(){
38816 return this.bodyEl.getUpdateManager();
38820 * Set a URL to be used to load the content for this TabPanelItem.
38821 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38822 * @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)
38823 * @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)
38824 * @return {Roo.UpdateManager} The UpdateManager
38826 setUrl : function(url, params, loadOnce){
38827 if(this.refreshDelegate){
38828 this.un('activate', this.refreshDelegate);
38830 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38831 this.on("activate", this.refreshDelegate);
38832 return this.bodyEl.getUpdateManager();
38836 _handleRefresh : function(url, params, loadOnce){
38837 if(!loadOnce || !this.loaded){
38838 var updater = this.bodyEl.getUpdateManager();
38839 updater.update(url, params, this._setLoaded.createDelegate(this));
38844 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38845 * Will fail silently if the setUrl method has not been called.
38846 * This does not activate the panel, just updates its content.
38848 refresh : function(){
38849 if(this.refreshDelegate){
38850 this.loaded = false;
38851 this.refreshDelegate();
38856 _setLoaded : function(){
38857 this.loaded = true;
38861 closeClick : function(e){
38864 this.fireEvent("beforeclose", this, o);
38865 if(o.cancel !== true){
38866 this.tabPanel.removeTab(this.id);
38870 * The text displayed in the tooltip for the close icon.
38873 closeText : "Close this tab"
38876 * This script refer to:
38877 * Title: International Telephone Input
38878 * Author: Jack O'Connor
38879 * Code version: v12.1.12
38880 * Availability: https://github.com/jackocnr/intl-tel-input.git
38883 Roo.bootstrap.PhoneInputData = function() {
38886 "Afghanistan (افغانستان)",
38891 "Albania (Shqipëri)",
38896 "Algeria (الجزائر)",
38921 "Antigua and Barbuda",
38931 "Armenia (Հայաստան)",
38947 "Austria (Österreich)",
38952 "Azerbaijan (Azərbaycan)",
38962 "Bahrain (البحرين)",
38967 "Bangladesh (বাংলাদেশ)",
38977 "Belarus (Беларусь)",
38982 "Belgium (België)",
39012 "Bosnia and Herzegovina (Босна и Херцеговина)",
39027 "British Indian Ocean Territory",
39032 "British Virgin Islands",
39042 "Bulgaria (България)",
39052 "Burundi (Uburundi)",
39057 "Cambodia (កម្ពុជា)",
39062 "Cameroon (Cameroun)",
39071 ["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"]
39074 "Cape Verde (Kabu Verdi)",
39079 "Caribbean Netherlands",
39090 "Central African Republic (République centrafricaine)",
39110 "Christmas Island",
39116 "Cocos (Keeling) Islands",
39127 "Comoros (جزر القمر)",
39132 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39137 "Congo (Republic) (Congo-Brazzaville)",
39157 "Croatia (Hrvatska)",
39178 "Czech Republic (Česká republika)",
39183 "Denmark (Danmark)",
39198 "Dominican Republic (República Dominicana)",
39202 ["809", "829", "849"]
39220 "Equatorial Guinea (Guinea Ecuatorial)",
39240 "Falkland Islands (Islas Malvinas)",
39245 "Faroe Islands (Føroyar)",
39266 "French Guiana (Guyane française)",
39271 "French Polynesia (Polynésie française)",
39286 "Georgia (საქართველო)",
39291 "Germany (Deutschland)",
39311 "Greenland (Kalaallit Nunaat)",
39348 "Guinea-Bissau (Guiné Bissau)",
39373 "Hungary (Magyarország)",
39378 "Iceland (Ísland)",
39398 "Iraq (العراق)",
39414 "Israel (ישראל)",
39441 "Jordan (الأردن)",
39446 "Kazakhstan (Казахстан)",
39467 "Kuwait (الكويت)",
39472 "Kyrgyzstan (Кыргызстан)",
39482 "Latvia (Latvija)",
39487 "Lebanon (لبنان)",
39502 "Libya (ليبيا)",
39512 "Lithuania (Lietuva)",
39527 "Macedonia (FYROM) (Македонија)",
39532 "Madagascar (Madagasikara)",
39562 "Marshall Islands",
39572 "Mauritania (موريتانيا)",
39577 "Mauritius (Moris)",
39598 "Moldova (Republica Moldova)",
39608 "Mongolia (Монгол)",
39613 "Montenegro (Crna Gora)",
39623 "Morocco (المغرب)",
39629 "Mozambique (Moçambique)",
39634 "Myanmar (Burma) (မြန်မာ)",
39639 "Namibia (Namibië)",
39654 "Netherlands (Nederland)",
39659 "New Caledonia (Nouvelle-Calédonie)",
39694 "North Korea (조선 민주주의 인민 공화국)",
39699 "Northern Mariana Islands",
39715 "Pakistan (پاکستان)",
39725 "Palestine (فلسطين)",
39735 "Papua New Guinea",
39777 "Réunion (La Réunion)",
39783 "Romania (România)",
39799 "Saint Barthélemy",
39810 "Saint Kitts and Nevis",
39820 "Saint Martin (Saint-Martin (partie française))",
39826 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39831 "Saint Vincent and the Grenadines",
39846 "São Tomé and Príncipe (São Tomé e Príncipe)",
39851 "Saudi Arabia (المملكة العربية السعودية)",
39856 "Senegal (Sénégal)",
39886 "Slovakia (Slovensko)",
39891 "Slovenia (Slovenija)",
39901 "Somalia (Soomaaliya)",
39911 "South Korea (대한민국)",
39916 "South Sudan (جنوب السودان)",
39926 "Sri Lanka (ශ්රී ලංකාව)",
39931 "Sudan (السودان)",
39941 "Svalbard and Jan Mayen",
39952 "Sweden (Sverige)",
39957 "Switzerland (Schweiz)",
39962 "Syria (سوريا)",
40007 "Trinidad and Tobago",
40012 "Tunisia (تونس)",
40017 "Turkey (Türkiye)",
40027 "Turks and Caicos Islands",
40037 "U.S. Virgin Islands",
40047 "Ukraine (Україна)",
40052 "United Arab Emirates (الإمارات العربية المتحدة)",
40074 "Uzbekistan (Oʻzbekiston)",
40084 "Vatican City (Città del Vaticano)",
40095 "Vietnam (Việt Nam)",
40100 "Wallis and Futuna (Wallis-et-Futuna)",
40105 "Western Sahara (الصحراء الغربية)",
40111 "Yemen (اليمن)",
40135 * This script refer to:
40136 * Title: International Telephone Input
40137 * Author: Jack O'Connor
40138 * Code version: v12.1.12
40139 * Availability: https://github.com/jackocnr/intl-tel-input.git
40143 * @class Roo.bootstrap.PhoneInput
40144 * @extends Roo.bootstrap.TriggerField
40145 * An input with International dial-code selection
40147 * @cfg {String} defaultDialCode default '+852'
40148 * @cfg {Array} preferedCountries default []
40151 * Create a new PhoneInput.
40152 * @param {Object} config Configuration options
40155 Roo.bootstrap.PhoneInput = function(config) {
40156 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40159 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40161 listWidth: undefined,
40163 selectedClass: 'active',
40165 invalidClass : "has-warning",
40167 validClass: 'has-success',
40169 allowed: '0123456789',
40174 * @cfg {String} defaultDialCode The default dial code when initializing the input
40176 defaultDialCode: '+852',
40179 * @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
40181 preferedCountries: false,
40183 getAutoCreate : function()
40185 var data = Roo.bootstrap.PhoneInputData();
40186 var align = this.labelAlign || this.parentLabelAlign();
40189 this.allCountries = [];
40190 this.dialCodeMapping = [];
40192 for (var i = 0; i < data.length; i++) {
40194 this.allCountries[i] = {
40198 priority: c[3] || 0,
40199 areaCodes: c[4] || null
40201 this.dialCodeMapping[c[2]] = {
40204 priority: c[3] || 0,
40205 areaCodes: c[4] || null
40217 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40218 maxlength: this.max_length,
40219 cls : 'form-control tel-input',
40220 autocomplete: 'new-password'
40223 var hiddenInput = {
40226 cls: 'hidden-tel-input'
40230 hiddenInput.name = this.name;
40233 if (this.disabled) {
40234 input.disabled = true;
40237 var flag_container = {
40254 cls: this.hasFeedback ? 'has-feedback' : '',
40260 cls: 'dial-code-holder',
40267 cls: 'roo-select2-container input-group',
40274 if (this.fieldLabel.length) {
40277 tooltip: 'This field is required'
40283 cls: 'control-label',
40289 html: this.fieldLabel
40292 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40298 if(this.indicatorpos == 'right') {
40299 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40306 if(align == 'left') {
40314 if(this.labelWidth > 12){
40315 label.style = "width: " + this.labelWidth + 'px';
40317 if(this.labelWidth < 13 && this.labelmd == 0){
40318 this.labelmd = this.labelWidth;
40320 if(this.labellg > 0){
40321 label.cls += ' col-lg-' + this.labellg;
40322 input.cls += ' col-lg-' + (12 - this.labellg);
40324 if(this.labelmd > 0){
40325 label.cls += ' col-md-' + this.labelmd;
40326 container.cls += ' col-md-' + (12 - this.labelmd);
40328 if(this.labelsm > 0){
40329 label.cls += ' col-sm-' + this.labelsm;
40330 container.cls += ' col-sm-' + (12 - this.labelsm);
40332 if(this.labelxs > 0){
40333 label.cls += ' col-xs-' + this.labelxs;
40334 container.cls += ' col-xs-' + (12 - this.labelxs);
40344 var settings = this;
40346 ['xs','sm','md','lg'].map(function(size){
40347 if (settings[size]) {
40348 cfg.cls += ' col-' + size + '-' + settings[size];
40352 this.store = new Roo.data.Store({
40353 proxy : new Roo.data.MemoryProxy({}),
40354 reader : new Roo.data.JsonReader({
40365 'name' : 'dialCode',
40369 'name' : 'priority',
40373 'name' : 'areaCodes',
40380 if(!this.preferedCountries) {
40381 this.preferedCountries = [
40388 var p = this.preferedCountries.reverse();
40391 for (var i = 0; i < p.length; i++) {
40392 for (var j = 0; j < this.allCountries.length; j++) {
40393 if(this.allCountries[j].iso2 == p[i]) {
40394 var t = this.allCountries[j];
40395 this.allCountries.splice(j,1);
40396 this.allCountries.unshift(t);
40402 this.store.proxy.data = {
40404 data: this.allCountries
40410 initEvents : function()
40413 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40415 this.indicator = this.indicatorEl();
40416 this.flag = this.flagEl();
40417 this.dialCodeHolder = this.dialCodeHolderEl();
40419 this.trigger = this.el.select('div.flag-box',true).first();
40420 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40425 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40426 _this.list.setWidth(lw);
40429 this.list.on('mouseover', this.onViewOver, this);
40430 this.list.on('mousemove', this.onViewMove, this);
40431 this.inputEl().on("keyup", this.onKeyUp, this);
40432 this.inputEl().on("keypress", this.onKeyPress, this);
40434 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40436 this.view = new Roo.View(this.list, this.tpl, {
40437 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40440 this.view.on('click', this.onViewClick, this);
40441 this.setValue(this.defaultDialCode);
40444 onTriggerClick : function(e)
40446 Roo.log('trigger click');
40451 if(this.isExpanded()){
40453 this.hasFocus = false;
40455 this.store.load({});
40456 this.hasFocus = true;
40461 isExpanded : function()
40463 return this.list.isVisible();
40466 collapse : function()
40468 if(!this.isExpanded()){
40472 Roo.get(document).un('mousedown', this.collapseIf, this);
40473 Roo.get(document).un('mousewheel', this.collapseIf, this);
40474 this.fireEvent('collapse', this);
40478 expand : function()
40482 if(this.isExpanded() || !this.hasFocus){
40486 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40487 this.list.setWidth(lw);
40490 this.restrictHeight();
40492 Roo.get(document).on('mousedown', this.collapseIf, this);
40493 Roo.get(document).on('mousewheel', this.collapseIf, this);
40495 this.fireEvent('expand', this);
40498 restrictHeight : function()
40500 this.list.alignTo(this.inputEl(), this.listAlign);
40501 this.list.alignTo(this.inputEl(), this.listAlign);
40504 onViewOver : function(e, t)
40506 if(this.inKeyMode){
40509 var item = this.view.findItemFromChild(t);
40512 var index = this.view.indexOf(item);
40513 this.select(index, false);
40518 onViewClick : function(view, doFocus, el, e)
40520 var index = this.view.getSelectedIndexes()[0];
40522 var r = this.store.getAt(index);
40525 this.onSelect(r, index);
40527 if(doFocus !== false && !this.blockFocus){
40528 this.inputEl().focus();
40532 onViewMove : function(e, t)
40534 this.inKeyMode = false;
40537 select : function(index, scrollIntoView)
40539 this.selectedIndex = index;
40540 this.view.select(index);
40541 if(scrollIntoView !== false){
40542 var el = this.view.getNode(index);
40544 this.list.scrollChildIntoView(el, false);
40549 createList : function()
40551 this.list = Roo.get(document.body).createChild({
40553 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40554 style: 'display:none'
40557 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40560 collapseIf : function(e)
40562 var in_combo = e.within(this.el);
40563 var in_list = e.within(this.list);
40564 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40566 if (in_combo || in_list || is_list) {
40572 onSelect : function(record, index)
40574 if(this.fireEvent('beforeselect', this, record, index) !== false){
40576 this.setFlagClass(record.data.iso2);
40577 this.setDialCode(record.data.dialCode);
40578 this.hasFocus = false;
40580 this.fireEvent('select', this, record, index);
40584 flagEl : function()
40586 var flag = this.el.select('div.flag',true).first();
40593 dialCodeHolderEl : function()
40595 var d = this.el.select('input.dial-code-holder',true).first();
40602 setDialCode : function(v)
40604 this.dialCodeHolder.dom.value = '+'+v;
40607 setFlagClass : function(n)
40609 this.flag.dom.className = 'flag '+n;
40612 getValue : function()
40614 var v = this.inputEl().getValue();
40615 if(this.dialCodeHolder) {
40616 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40621 setValue : function(v)
40623 var d = this.getDialCode(v);
40625 //invalid dial code
40626 if(v.length == 0 || !d || d.length == 0) {
40628 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40629 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40635 this.setFlagClass(this.dialCodeMapping[d].iso2);
40636 this.setDialCode(d);
40637 this.inputEl().dom.value = v.replace('+'+d,'');
40638 this.hiddenEl().dom.value = this.getValue();
40643 getDialCode : function(v)
40647 if (v.length == 0) {
40648 return this.dialCodeHolder.dom.value;
40652 if (v.charAt(0) != "+") {
40655 var numericChars = "";
40656 for (var i = 1; i < v.length; i++) {
40657 var c = v.charAt(i);
40660 if (this.dialCodeMapping[numericChars]) {
40661 dialCode = v.substr(1, i);
40663 if (numericChars.length == 4) {
40673 this.setValue(this.defaultDialCode);
40677 hiddenEl : function()
40679 return this.el.select('input.hidden-tel-input',true).first();
40682 // after setting val
40683 onKeyUp : function(e){
40684 this.setValue(this.getValue());
40687 onKeyPress : function(e){
40688 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40695 * @class Roo.bootstrap.MoneyField
40696 * @extends Roo.bootstrap.ComboBox
40697 * Bootstrap MoneyField class
40700 * Create a new MoneyField.
40701 * @param {Object} config Configuration options
40704 Roo.bootstrap.MoneyField = function(config) {
40706 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40710 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40713 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40715 allowDecimals : true,
40717 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40719 decimalSeparator : ".",
40721 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40723 decimalPrecision : 0,
40725 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40727 allowNegative : true,
40729 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40733 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40735 minValue : Number.NEGATIVE_INFINITY,
40737 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40739 maxValue : Number.MAX_VALUE,
40741 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40743 minText : "The minimum value for this field is {0}",
40745 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40747 maxText : "The maximum value for this field is {0}",
40749 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40750 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40752 nanText : "{0} is not a valid number",
40754 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40758 * @cfg {String} defaults currency of the MoneyField
40759 * value should be in lkey
40761 defaultCurrency : false,
40763 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40765 thousandsDelimiter : false,
40767 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40778 getAutoCreate : function()
40780 var align = this.labelAlign || this.parentLabelAlign();
40792 cls : 'form-control roo-money-amount-input',
40793 autocomplete: 'new-password'
40796 var hiddenInput = {
40800 cls: 'hidden-number-input'
40803 if(this.max_length) {
40804 input.maxlength = this.max_length;
40808 hiddenInput.name = this.name;
40811 if (this.disabled) {
40812 input.disabled = true;
40815 var clg = 12 - this.inputlg;
40816 var cmd = 12 - this.inputmd;
40817 var csm = 12 - this.inputsm;
40818 var cxs = 12 - this.inputxs;
40822 cls : 'row roo-money-field',
40826 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40830 cls: 'roo-select2-container input-group',
40834 cls : 'form-control roo-money-currency-input',
40835 autocomplete: 'new-password',
40837 name : this.currencyName
40841 cls : 'input-group-addon',
40855 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40859 cls: this.hasFeedback ? 'has-feedback' : '',
40870 if (this.fieldLabel.length) {
40873 tooltip: 'This field is required'
40879 cls: 'control-label',
40885 html: this.fieldLabel
40888 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40894 if(this.indicatorpos == 'right') {
40895 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40902 if(align == 'left') {
40910 if(this.labelWidth > 12){
40911 label.style = "width: " + this.labelWidth + 'px';
40913 if(this.labelWidth < 13 && this.labelmd == 0){
40914 this.labelmd = this.labelWidth;
40916 if(this.labellg > 0){
40917 label.cls += ' col-lg-' + this.labellg;
40918 input.cls += ' col-lg-' + (12 - this.labellg);
40920 if(this.labelmd > 0){
40921 label.cls += ' col-md-' + this.labelmd;
40922 container.cls += ' col-md-' + (12 - this.labelmd);
40924 if(this.labelsm > 0){
40925 label.cls += ' col-sm-' + this.labelsm;
40926 container.cls += ' col-sm-' + (12 - this.labelsm);
40928 if(this.labelxs > 0){
40929 label.cls += ' col-xs-' + this.labelxs;
40930 container.cls += ' col-xs-' + (12 - this.labelxs);
40941 var settings = this;
40943 ['xs','sm','md','lg'].map(function(size){
40944 if (settings[size]) {
40945 cfg.cls += ' col-' + size + '-' + settings[size];
40952 initEvents : function()
40954 this.indicator = this.indicatorEl();
40956 this.initCurrencyEvent();
40958 this.initNumberEvent();
40961 initCurrencyEvent : function()
40964 throw "can not find store for combo";
40967 this.store = Roo.factory(this.store, Roo.data);
40968 this.store.parent = this;
40972 this.triggerEl = this.el.select('.input-group-addon', true).first();
40974 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40979 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40980 _this.list.setWidth(lw);
40983 this.list.on('mouseover', this.onViewOver, this);
40984 this.list.on('mousemove', this.onViewMove, this);
40985 this.list.on('scroll', this.onViewScroll, this);
40988 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40991 this.view = new Roo.View(this.list, this.tpl, {
40992 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40995 this.view.on('click', this.onViewClick, this);
40997 this.store.on('beforeload', this.onBeforeLoad, this);
40998 this.store.on('load', this.onLoad, this);
40999 this.store.on('loadexception', this.onLoadException, this);
41001 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41002 "up" : function(e){
41003 this.inKeyMode = true;
41007 "down" : function(e){
41008 if(!this.isExpanded()){
41009 this.onTriggerClick();
41011 this.inKeyMode = true;
41016 "enter" : function(e){
41019 if(this.fireEvent("specialkey", this, e)){
41020 this.onViewClick(false);
41026 "esc" : function(e){
41030 "tab" : function(e){
41033 if(this.fireEvent("specialkey", this, e)){
41034 this.onViewClick(false);
41042 doRelay : function(foo, bar, hname){
41043 if(hname == 'down' || this.scope.isExpanded()){
41044 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41052 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41056 initNumberEvent : function(e)
41058 this.inputEl().on("keydown" , this.fireKey, this);
41059 this.inputEl().on("focus", this.onFocus, this);
41060 this.inputEl().on("blur", this.onBlur, this);
41062 this.inputEl().relayEvent('keyup', this);
41064 if(this.indicator){
41065 this.indicator.addClass('invisible');
41068 this.originalValue = this.getValue();
41070 if(this.validationEvent == 'keyup'){
41071 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41072 this.inputEl().on('keyup', this.filterValidation, this);
41074 else if(this.validationEvent !== false){
41075 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41078 if(this.selectOnFocus){
41079 this.on("focus", this.preFocus, this);
41082 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41083 this.inputEl().on("keypress", this.filterKeys, this);
41085 this.inputEl().relayEvent('keypress', this);
41088 var allowed = "0123456789";
41090 if(this.allowDecimals){
41091 allowed += this.decimalSeparator;
41094 if(this.allowNegative){
41098 if(this.thousandsDelimiter) {
41102 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41104 var keyPress = function(e){
41106 var k = e.getKey();
41108 var c = e.getCharCode();
41111 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41112 allowed.indexOf(String.fromCharCode(c)) === -1
41118 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41122 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41127 this.inputEl().on("keypress", keyPress, this);
41131 onTriggerClick : function(e)
41138 this.loadNext = false;
41140 if(this.isExpanded()){
41145 this.hasFocus = true;
41147 if(this.triggerAction == 'all') {
41148 this.doQuery(this.allQuery, true);
41152 this.doQuery(this.getRawValue());
41155 getCurrency : function()
41157 var v = this.currencyEl().getValue();
41162 restrictHeight : function()
41164 this.list.alignTo(this.currencyEl(), this.listAlign);
41165 this.list.alignTo(this.currencyEl(), this.listAlign);
41168 onViewClick : function(view, doFocus, el, e)
41170 var index = this.view.getSelectedIndexes()[0];
41172 var r = this.store.getAt(index);
41175 this.onSelect(r, index);
41179 onSelect : function(record, index){
41181 if(this.fireEvent('beforeselect', this, record, index) !== false){
41183 this.setFromCurrencyData(index > -1 ? record.data : false);
41187 this.fireEvent('select', this, record, index);
41191 setFromCurrencyData : function(o)
41195 this.lastCurrency = o;
41197 if (this.currencyField) {
41198 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41200 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41203 this.lastSelectionText = currency;
41205 //setting default currency
41206 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41207 this.setCurrency(this.defaultCurrency);
41211 this.setCurrency(currency);
41214 setFromData : function(o)
41218 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41220 this.setFromCurrencyData(c);
41225 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41227 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41230 this.setValue(value);
41234 setCurrency : function(v)
41236 this.currencyValue = v;
41239 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41244 setValue : function(v)
41246 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41252 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41254 this.inputEl().dom.value = (v == '') ? '' :
41255 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41257 if(!this.allowZero && v === '0') {
41258 this.hiddenEl().dom.value = '';
41259 this.inputEl().dom.value = '';
41266 getRawValue : function()
41268 var v = this.inputEl().getValue();
41273 getValue : function()
41275 return this.fixPrecision(this.parseValue(this.getRawValue()));
41278 parseValue : function(value)
41280 if(this.thousandsDelimiter) {
41282 r = new RegExp(",", "g");
41283 value = value.replace(r, "");
41286 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41287 return isNaN(value) ? '' : value;
41291 fixPrecision : function(value)
41293 if(this.thousandsDelimiter) {
41295 r = new RegExp(",", "g");
41296 value = value.replace(r, "");
41299 var nan = isNaN(value);
41301 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41302 return nan ? '' : value;
41304 return parseFloat(value).toFixed(this.decimalPrecision);
41307 decimalPrecisionFcn : function(v)
41309 return Math.floor(v);
41312 validateValue : function(value)
41314 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41318 var num = this.parseValue(value);
41321 this.markInvalid(String.format(this.nanText, value));
41325 if(num < this.minValue){
41326 this.markInvalid(String.format(this.minText, this.minValue));
41330 if(num > this.maxValue){
41331 this.markInvalid(String.format(this.maxText, this.maxValue));
41338 validate : function()
41340 if(this.disabled || this.allowBlank){
41345 var currency = this.getCurrency();
41347 if(this.validateValue(this.getRawValue()) && currency.length){
41352 this.markInvalid();
41356 getName: function()
41361 beforeBlur : function()
41367 var v = this.parseValue(this.getRawValue());
41374 onBlur : function()
41378 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41379 //this.el.removeClass(this.focusClass);
41382 this.hasFocus = false;
41384 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41388 var v = this.getValue();
41390 if(String(v) !== String(this.startValue)){
41391 this.fireEvent('change', this, v, this.startValue);
41394 this.fireEvent("blur", this);
41397 inputEl : function()
41399 return this.el.select('.roo-money-amount-input', true).first();
41402 currencyEl : function()
41404 return this.el.select('.roo-money-currency-input', true).first();
41407 hiddenEl : function()
41409 return this.el.select('input.hidden-number-input',true).first();