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
2677 * Fire when the top 'x' close button is pressed.
2678 * @param {Roo.bootstrap.Modal} this
2679 * @param {Roo.EventObject} e
2683 this.buttons = this.buttons || [];
2686 this.tmpl = Roo.factory(this.tmpl);
2691 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2693 title : 'test dialog',
2703 specificTitle: false,
2705 buttonPosition: 'right',
2728 onRender : function(ct, position)
2730 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2733 var cfg = Roo.apply({}, this.getAutoCreate());
2736 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2738 //if (!cfg.name.length) {
2742 cfg.cls += ' ' + this.cls;
2745 cfg.style = this.style;
2747 this.el = Roo.get(document.body).createChild(cfg, position);
2749 //var type = this.el.dom.type;
2752 if(this.tabIndex !== undefined){
2753 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2756 this.dialogEl = this.el.select('.modal-dialog',true).first();
2757 this.bodyEl = this.el.select('.modal-body',true).first();
2758 this.closeEl = this.el.select('.modal-header .close', true).first();
2759 this.headerEl = this.el.select('.modal-header',true).first();
2760 this.titleEl = this.el.select('.modal-title',true).first();
2761 this.footerEl = this.el.select('.modal-footer',true).first();
2763 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2765 //this.el.addClass("x-dlg-modal");
2767 if (this.buttons.length) {
2768 Roo.each(this.buttons, function(bb) {
2769 var b = Roo.apply({}, bb);
2770 b.xns = b.xns || Roo.bootstrap;
2771 b.xtype = b.xtype || 'Button';
2772 if (typeof(b.listeners) == 'undefined') {
2773 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2776 var btn = Roo.factory(b);
2778 btn.render(this.getButtonContainer());
2782 // render the children.
2785 if(typeof(this.items) != 'undefined'){
2786 var items = this.items;
2789 for(var i =0;i < items.length;i++) {
2790 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2794 this.items = nitems;
2796 // where are these used - they used to be body/close/footer
2800 //this.el.addClass([this.fieldClass, this.cls]);
2804 getAutoCreate : function()
2808 html : this.html || ''
2813 cls : 'modal-title',
2817 if(this.specificTitle){
2823 if (this.allow_close && Roo.bootstrap.version == 3) {
2833 if (this.allow_close && Roo.bootstrap.version == 4) {
2843 if(this.size.length){
2844 size = 'modal-' + this.size;
2847 var footer = Roo.bootstrap.version == 3 ?
2849 cls : 'modal-footer',
2853 cls: 'btn-' + this.buttonPosition
2858 { // BS4 uses mr-auto on left buttons....
2859 cls : 'modal-footer'
2870 cls: "modal-dialog " + size,
2873 cls : "modal-content",
2876 cls : 'modal-header',
2891 modal.cls += ' fade';
2897 getChildContainer : function() {
2902 getButtonContainer : function() {
2904 return Roo.bootstrap.version == 4 ?
2905 this.el.select('.modal-footer',true).first()
2906 : this.el.select('.modal-footer div',true).first();
2909 initEvents : function()
2911 if (this.allow_close) {
2912 this.closeEl.on('click', this.onClosePress, this);
2914 Roo.EventManager.onWindowResize(this.resize, this, true);
2919 onClosePress : function()
2926 this.maskEl.setSize(
2927 Roo.lib.Dom.getViewWidth(true),
2928 Roo.lib.Dom.getViewHeight(true)
2931 if (this.fitwindow) {
2933 var view_height = Roo.lib.Dom.getViewportHeight(true);
2936 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2937 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2942 if(this.max_width !== 0) {
2944 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2947 this.setSize(w, this.height);
2951 if(this.max_height) {
2952 this.setSize(w,Math.min(
2954 Roo.lib.Dom.getViewportHeight(true) - 60
2960 if(!this.fit_content) {
2961 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2965 this.setSize(w, Math.min(
2967 this.headerEl.getHeight() +
2968 this.footerEl.getHeight() +
2969 this.getChildHeight(this.bodyEl.dom.childNodes),
2970 Roo.lib.Dom.getViewportHeight(true) - 60)
2976 setSize : function(w,h)
2987 if (!this.rendered) {
2991 //this.el.setStyle('display', 'block');
2992 this.el.removeClass('hideing');
2993 this.el.dom.style.display='block';
2995 Roo.get(document.body).addClass('modal-open');
2997 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
3000 this.el.addClass('show');
3001 this.el.addClass('in');
3004 this.el.addClass('show');
3005 this.el.addClass('in');
3008 // not sure how we can show data in here..
3010 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3013 Roo.get(document.body).addClass("x-body-masked");
3015 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3016 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3017 this.maskEl.dom.style.display = 'block';
3018 this.maskEl.addClass('show');
3023 this.fireEvent('show', this);
3025 // set zindex here - otherwise it appears to be ignored...
3026 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3029 this.items.forEach( function(e) {
3030 e.layout ? e.layout() : false;
3038 if(this.fireEvent("beforehide", this) !== false){
3040 this.maskEl.removeClass('show');
3042 this.maskEl.dom.style.display = '';
3043 Roo.get(document.body).removeClass("x-body-masked");
3044 this.el.removeClass('in');
3045 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3047 if(this.animate){ // why
3048 this.el.addClass('hideing');
3049 this.el.removeClass('show');
3051 if (!this.el.hasClass('hideing')) {
3052 return; // it's been shown again...
3055 this.el.dom.style.display='';
3057 Roo.get(document.body).removeClass('modal-open');
3058 this.el.removeClass('hideing');
3062 this.el.removeClass('show');
3063 this.el.dom.style.display='';
3064 Roo.get(document.body).removeClass('modal-open');
3067 this.fireEvent('hide', this);
3070 isVisible : function()
3073 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3077 addButton : function(str, cb)
3081 var b = Roo.apply({}, { html : str } );
3082 b.xns = b.xns || Roo.bootstrap;
3083 b.xtype = b.xtype || 'Button';
3084 if (typeof(b.listeners) == 'undefined') {
3085 b.listeners = { click : cb.createDelegate(this) };
3088 var btn = Roo.factory(b);
3090 btn.render(this.getButtonContainer());
3096 setDefaultButton : function(btn)
3098 //this.el.select('.modal-footer').()
3101 resizeTo: function(w,h)
3103 this.dialogEl.setWidth(w);
3105 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3107 this.bodyEl.setHeight(h - diff);
3109 this.fireEvent('resize', this);
3112 setContentSize : function(w, h)
3116 onButtonClick: function(btn,e)
3119 this.fireEvent('btnclick', btn.name, e);
3122 * Set the title of the Dialog
3123 * @param {String} str new Title
3125 setTitle: function(str) {
3126 this.titleEl.dom.innerHTML = str;
3129 * Set the body of the Dialog
3130 * @param {String} str new Title
3132 setBody: function(str) {
3133 this.bodyEl.dom.innerHTML = str;
3136 * Set the body of the Dialog using the template
3137 * @param {Obj} data - apply this data to the template and replace the body contents.
3139 applyBody: function(obj)
3142 Roo.log("Error - using apply Body without a template");
3145 this.tmpl.overwrite(this.bodyEl, obj);
3148 getChildHeight : function(child_nodes)
3152 child_nodes.length == 0
3157 var child_height = 0;
3159 for(var i = 0; i < child_nodes.length; i++) {
3162 * for modal with tabs...
3163 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3165 var layout_childs = child_nodes[i].childNodes;
3167 for(var j = 0; j < layout_childs.length; j++) {
3169 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3171 var layout_body_childs = layout_childs[j].childNodes;
3173 for(var k = 0; k < layout_body_childs.length; k++) {
3175 if(layout_body_childs[k].classList.contains('navbar')) {
3176 child_height += layout_body_childs[k].offsetHeight;
3180 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3182 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3184 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3186 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3187 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3202 child_height += child_nodes[i].offsetHeight;
3203 // Roo.log(child_nodes[i].offsetHeight);
3206 return child_height;
3212 Roo.apply(Roo.bootstrap.Modal, {
3214 * Button config that displays a single OK button
3223 * Button config that displays Yes and No buttons
3239 * Button config that displays OK and Cancel buttons
3254 * Button config that displays Yes, No and Cancel buttons
3278 * messagebox - can be used as a replace
3282 * @class Roo.MessageBox
3283 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3287 Roo.Msg.alert('Status', 'Changes saved successfully.');
3289 // Prompt for user data:
3290 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3292 // process text value...
3296 // Show a dialog using config options:
3298 title:'Save Changes?',
3299 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3300 buttons: Roo.Msg.YESNOCANCEL,
3307 Roo.bootstrap.MessageBox = function(){
3308 var dlg, opt, mask, waitTimer;
3309 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3310 var buttons, activeTextEl, bwidth;
3314 var handleButton = function(button){
3316 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3320 var handleHide = function(){
3322 dlg.el.removeClass(opt.cls);
3325 // Roo.TaskMgr.stop(waitTimer);
3326 // waitTimer = null;
3331 var updateButtons = function(b){
3334 buttons["ok"].hide();
3335 buttons["cancel"].hide();
3336 buttons["yes"].hide();
3337 buttons["no"].hide();
3338 dlg.footerEl.hide();
3342 dlg.footerEl.show();
3343 for(var k in buttons){
3344 if(typeof buttons[k] != "function"){
3347 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3348 width += buttons[k].el.getWidth()+15;
3358 var handleEsc = function(d, k, e){
3359 if(opt && opt.closable !== false){
3369 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3370 * @return {Roo.BasicDialog} The BasicDialog element
3372 getDialog : function(){
3374 dlg = new Roo.bootstrap.Modal( {
3377 //constraintoviewport:false,
3379 //collapsible : false,
3384 //buttonAlign:"center",
3385 closeClick : function(){
3386 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3389 handleButton("cancel");
3394 dlg.on("hide", handleHide);
3396 //dlg.addKeyListener(27, handleEsc);
3398 this.buttons = buttons;
3399 var bt = this.buttonText;
3400 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3401 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3402 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3403 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3405 bodyEl = dlg.bodyEl.createChild({
3407 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3408 '<textarea class="roo-mb-textarea"></textarea>' +
3409 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3411 msgEl = bodyEl.dom.firstChild;
3412 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3413 textboxEl.enableDisplayMode();
3414 textboxEl.addKeyListener([10,13], function(){
3415 if(dlg.isVisible() && opt && opt.buttons){
3418 }else if(opt.buttons.yes){
3419 handleButton("yes");
3423 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3424 textareaEl.enableDisplayMode();
3425 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3426 progressEl.enableDisplayMode();
3428 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3429 var pf = progressEl.dom.firstChild;
3431 pp = Roo.get(pf.firstChild);
3432 pp.setHeight(pf.offsetHeight);
3440 * Updates the message box body text
3441 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3442 * the XHTML-compliant non-breaking space character '&#160;')
3443 * @return {Roo.MessageBox} This message box
3445 updateText : function(text)
3447 if(!dlg.isVisible() && !opt.width){
3448 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3449 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3451 msgEl.innerHTML = text || ' ';
3453 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3454 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3456 Math.min(opt.width || cw , this.maxWidth),
3457 Math.max(opt.minWidth || this.minWidth, bwidth)
3460 activeTextEl.setWidth(w);
3462 if(dlg.isVisible()){
3463 dlg.fixedcenter = false;
3465 // to big, make it scroll. = But as usual stupid IE does not support
3468 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3469 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3470 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3472 bodyEl.dom.style.height = '';
3473 bodyEl.dom.style.overflowY = '';
3476 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3478 bodyEl.dom.style.overflowX = '';
3481 dlg.setContentSize(w, bodyEl.getHeight());
3482 if(dlg.isVisible()){
3483 dlg.fixedcenter = true;
3489 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3490 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3491 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3492 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3493 * @return {Roo.MessageBox} This message box
3495 updateProgress : function(value, text){
3497 this.updateText(text);
3500 if (pp) { // weird bug on my firefox - for some reason this is not defined
3501 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3502 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3508 * Returns true if the message box is currently displayed
3509 * @return {Boolean} True if the message box is visible, else false
3511 isVisible : function(){
3512 return dlg && dlg.isVisible();
3516 * Hides the message box if it is displayed
3519 if(this.isVisible()){
3525 * Displays a new message box, or reinitializes an existing message box, based on the config options
3526 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3527 * The following config object properties are supported:
3529 Property Type Description
3530 ---------- --------------- ------------------------------------------------------------------------------------
3531 animEl String/Element An id or Element from which the message box should animate as it opens and
3532 closes (defaults to undefined)
3533 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3534 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3535 closable Boolean False to hide the top-right close button (defaults to true). Note that
3536 progress and wait dialogs will ignore this property and always hide the
3537 close button as they can only be closed programmatically.
3538 cls String A custom CSS class to apply to the message box element
3539 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3540 displayed (defaults to 75)
3541 fn Function A callback function to execute after closing the dialog. The arguments to the
3542 function will be btn (the name of the button that was clicked, if applicable,
3543 e.g. "ok"), and text (the value of the active text field, if applicable).
3544 Progress and wait dialogs will ignore this option since they do not respond to
3545 user actions and can only be closed programmatically, so any required function
3546 should be called by the same code after it closes the dialog.
3547 icon String A CSS class that provides a background image to be used as an icon for
3548 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3549 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3550 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3551 modal Boolean False to allow user interaction with the page while the message box is
3552 displayed (defaults to true)
3553 msg String A string that will replace the existing message box body text (defaults
3554 to the XHTML-compliant non-breaking space character ' ')
3555 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3556 progress Boolean True to display a progress bar (defaults to false)
3557 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3558 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3559 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3560 title String The title text
3561 value String The string value to set into the active textbox element if displayed
3562 wait Boolean True to display a progress bar (defaults to false)
3563 width Number The width of the dialog in pixels
3570 msg: 'Please enter your address:',
3572 buttons: Roo.MessageBox.OKCANCEL,
3575 animEl: 'addAddressBtn'
3578 * @param {Object} config Configuration options
3579 * @return {Roo.MessageBox} This message box
3581 show : function(options)
3584 // this causes nightmares if you show one dialog after another
3585 // especially on callbacks..
3587 if(this.isVisible()){
3590 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3591 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3592 Roo.log("New Dialog Message:" + options.msg )
3593 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3594 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3597 var d = this.getDialog();
3599 d.setTitle(opt.title || " ");
3600 d.closeEl.setDisplayed(opt.closable !== false);
3601 activeTextEl = textboxEl;
3602 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3607 textareaEl.setHeight(typeof opt.multiline == "number" ?
3608 opt.multiline : this.defaultTextHeight);
3609 activeTextEl = textareaEl;
3618 progressEl.setDisplayed(opt.progress === true);
3620 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3622 this.updateProgress(0);
3623 activeTextEl.dom.value = opt.value || "";
3625 dlg.setDefaultButton(activeTextEl);
3627 var bs = opt.buttons;
3631 }else if(bs && bs.yes){
3632 db = buttons["yes"];
3634 dlg.setDefaultButton(db);
3636 bwidth = updateButtons(opt.buttons);
3637 this.updateText(opt.msg);
3639 d.el.addClass(opt.cls);
3641 d.proxyDrag = opt.proxyDrag === true;
3642 d.modal = opt.modal !== false;
3643 d.mask = opt.modal !== false ? mask : false;
3645 // force it to the end of the z-index stack so it gets a cursor in FF
3646 document.body.appendChild(dlg.el.dom);
3647 d.animateTarget = null;
3648 d.show(options.animEl);
3654 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3655 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3656 * and closing the message box when the process is complete.
3657 * @param {String} title The title bar text
3658 * @param {String} msg The message box body text
3659 * @return {Roo.MessageBox} This message box
3661 progress : function(title, msg){
3668 minWidth: this.minProgressWidth,
3675 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3676 * If a callback function is passed it will be called after the user clicks the button, and the
3677 * id of the button that was clicked will be passed as the only parameter to the callback
3678 * (could also be the top-right close button).
3679 * @param {String} title The title bar text
3680 * @param {String} msg The message box body text
3681 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3682 * @param {Object} scope (optional) The scope of the callback function
3683 * @return {Roo.MessageBox} This message box
3685 alert : function(title, msg, fn, scope)
3700 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3701 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3702 * You are responsible for closing the message box when the process is complete.
3703 * @param {String} msg The message box body text
3704 * @param {String} title (optional) The title bar text
3705 * @return {Roo.MessageBox} This message box
3707 wait : function(msg, title){
3718 waitTimer = Roo.TaskMgr.start({
3720 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3728 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3729 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3730 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3731 * @param {String} title The title bar text
3732 * @param {String} msg The message box body text
3733 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3734 * @param {Object} scope (optional) The scope of the callback function
3735 * @return {Roo.MessageBox} This message box
3737 confirm : function(title, msg, fn, scope){
3741 buttons: this.YESNO,
3750 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3751 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3752 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3753 * (could also be the top-right close button) and the text that was entered will be passed as the two
3754 * parameters to the callback.
3755 * @param {String} title The title bar text
3756 * @param {String} msg The message box body text
3757 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3758 * @param {Object} scope (optional) The scope of the callback function
3759 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3760 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3761 * @return {Roo.MessageBox} This message box
3763 prompt : function(title, msg, fn, scope, multiline){
3767 buttons: this.OKCANCEL,
3772 multiline: multiline,
3779 * Button config that displays a single OK button
3784 * Button config that displays Yes and No buttons
3787 YESNO : {yes:true, no:true},
3789 * Button config that displays OK and Cancel buttons
3792 OKCANCEL : {ok:true, cancel:true},
3794 * Button config that displays Yes, No and Cancel buttons
3797 YESNOCANCEL : {yes:true, no:true, cancel:true},
3800 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3803 defaultTextHeight : 75,
3805 * The maximum width in pixels of the message box (defaults to 600)
3810 * The minimum width in pixels of the message box (defaults to 100)
3815 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3816 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3819 minProgressWidth : 250,
3821 * An object containing the default button text strings that can be overriden for localized language support.
3822 * Supported properties are: ok, cancel, yes and no.
3823 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3836 * Shorthand for {@link Roo.MessageBox}
3838 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3839 Roo.Msg = Roo.Msg || Roo.MessageBox;
3848 * @class Roo.bootstrap.Navbar
3849 * @extends Roo.bootstrap.Component
3850 * Bootstrap Navbar class
3853 * Create a new Navbar
3854 * @param {Object} config The config object
3858 Roo.bootstrap.Navbar = function(config){
3859 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3863 * @event beforetoggle
3864 * Fire before toggle the menu
3865 * @param {Roo.EventObject} e
3867 "beforetoggle" : true
3871 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3880 getAutoCreate : function(){
3883 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3887 initEvents :function ()
3889 //Roo.log(this.el.select('.navbar-toggle',true));
3890 this.el.select('.navbar-toggle',true).on('click', function() {
3891 if(this.fireEvent('beforetoggle', this) !== false){
3892 var ce = this.el.select('.navbar-collapse',true).first();
3893 ce.toggleClass('in'); // old...
3894 if (ce.hasClass('collapse')) {
3896 ce.removeClass('collapse');
3897 ce.addClass('show');
3898 var h = ce.getHeight();
3900 ce.removeClass('show');
3901 // at this point we should be able to see it..
3902 ce.addClass('collapsing');
3904 ce.setHeight(0); // resize it ...
3905 ce.on('transitionend', function() {
3906 Roo.log('done transition');
3907 ce.removeClass('collapsing');
3908 ce.addClass('show');
3909 ce.removeClass('collapse');
3911 ce.dom.style.height = '';
3912 }, this, { single: true} );
3916 ce.setHeight(ce.getHeight());
3917 ce.removeClass('show');
3918 ce.addClass('collapsing');
3920 ce.on('transitionend', function() {
3921 ce.dom.style.height = '';
3922 ce.removeClass('collapsing');
3923 ce.addClass('collapse');
3924 }, this, { single: true} );
3936 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3938 var size = this.el.getSize();
3939 this.maskEl.setSize(size.width, size.height);
3940 this.maskEl.enableDisplayMode("block");
3949 getChildContainer : function()
3951 if (this.el.select('.collapse').getCount()) {
3952 return this.el.select('.collapse',true).first();
3985 * @class Roo.bootstrap.NavSimplebar
3986 * @extends Roo.bootstrap.Navbar
3987 * Bootstrap Sidebar class
3989 * @cfg {Boolean} inverse is inverted color
3991 * @cfg {String} type (nav | pills | tabs)
3992 * @cfg {Boolean} arrangement stacked | justified
3993 * @cfg {String} align (left | right) alignment
3995 * @cfg {Boolean} main (true|false) main nav bar? default false
3996 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3998 * @cfg {String} tag (header|footer|nav|div) default is nav
4000 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
4004 * Create a new Sidebar
4005 * @param {Object} config The config object
4009 Roo.bootstrap.NavSimplebar = function(config){
4010 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4013 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4029 getAutoCreate : function(){
4033 tag : this.tag || 'div',
4034 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4036 if (['light','white'].indexOf(this.weight) > -1) {
4037 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4039 cfg.cls += ' bg-' + this.weight;
4042 cfg.cls += ' navbar-inverse';
4046 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4048 //if (Roo.bootstrap.version == 4) {
4060 this.type = this.type || 'nav';
4061 if (['tabs','pills'].indexOf(this.type) != -1) {
4062 cfg.cn[0].cls += ' nav-' + this.type
4066 if (this.type!=='nav') {
4067 Roo.log('nav type must be nav/tabs/pills')
4069 cfg.cn[0].cls += ' navbar-nav'
4075 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4076 cfg.cn[0].cls += ' nav-' + this.arrangement;
4080 if (this.align === 'right') {
4081 cfg.cn[0].cls += ' navbar-right';
4106 * navbar-expand-md fixed-top
4110 * @class Roo.bootstrap.NavHeaderbar
4111 * @extends Roo.bootstrap.NavSimplebar
4112 * Bootstrap Sidebar class
4114 * @cfg {String} brand what is brand
4115 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4116 * @cfg {String} brand_href href of the brand
4117 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4118 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4119 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4120 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4123 * Create a new Sidebar
4124 * @param {Object} config The config object
4128 Roo.bootstrap.NavHeaderbar = function(config){
4129 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4133 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4140 desktopCenter : false,
4143 getAutoCreate : function(){
4146 tag: this.nav || 'nav',
4147 cls: 'navbar navbar-expand-md',
4153 if (this.desktopCenter) {
4154 cn.push({cls : 'container', cn : []});
4162 cls: 'navbar-toggle navbar-toggler',
4163 'data-toggle': 'collapse',
4168 html: 'Toggle navigation'
4172 cls: 'icon-bar navbar-toggler-icon'
4185 cn.push( Roo.bootstrap.version == 4 ? btn : {
4187 cls: 'navbar-header',
4196 cls: 'collapse navbar-collapse',
4200 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4202 if (['light','white'].indexOf(this.weight) > -1) {
4203 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4205 cfg.cls += ' bg-' + this.weight;
4208 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4209 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4211 // tag can override this..
4213 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4216 if (this.brand !== '') {
4217 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4218 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4220 href: this.brand_href ? this.brand_href : '#',
4221 cls: 'navbar-brand',
4229 cfg.cls += ' main-nav';
4237 getHeaderChildContainer : function()
4239 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4240 return this.el.select('.navbar-header',true).first();
4243 return this.getChildContainer();
4247 initEvents : function()
4249 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4251 if (this.autohide) {
4256 Roo.get(document).on('scroll',function(e) {
4257 var ns = Roo.get(document).getScroll().top;
4258 var os = prevScroll;
4262 ft.removeClass('slideDown');
4263 ft.addClass('slideUp');
4266 ft.removeClass('slideUp');
4267 ft.addClass('slideDown');
4288 * @class Roo.bootstrap.NavSidebar
4289 * @extends Roo.bootstrap.Navbar
4290 * Bootstrap Sidebar class
4293 * Create a new Sidebar
4294 * @param {Object} config The config object
4298 Roo.bootstrap.NavSidebar = function(config){
4299 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4302 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4304 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4306 getAutoCreate : function(){
4311 cls: 'sidebar sidebar-nav'
4333 * @class Roo.bootstrap.NavGroup
4334 * @extends Roo.bootstrap.Component
4335 * Bootstrap NavGroup class
4336 * @cfg {String} align (left|right)
4337 * @cfg {Boolean} inverse
4338 * @cfg {String} type (nav|pills|tab) default nav
4339 * @cfg {String} navId - reference Id for navbar.
4343 * Create a new nav group
4344 * @param {Object} config The config object
4347 Roo.bootstrap.NavGroup = function(config){
4348 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4351 Roo.bootstrap.NavGroup.register(this);
4355 * Fires when the active item changes
4356 * @param {Roo.bootstrap.NavGroup} this
4357 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4358 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4365 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4376 getAutoCreate : function()
4378 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4384 if (Roo.bootstrap.version == 4) {
4385 if (['tabs','pills'].indexOf(this.type) != -1) {
4386 cfg.cls += ' nav-' + this.type;
4388 cfg.cls += ' navbar-nav';
4391 if (['tabs','pills'].indexOf(this.type) != -1) {
4392 cfg.cls += ' nav-' + this.type
4394 if (this.type !== 'nav') {
4395 Roo.log('nav type must be nav/tabs/pills')
4397 cfg.cls += ' navbar-nav'
4401 if (this.parent() && this.parent().sidebar) {
4404 cls: 'dashboard-menu sidebar-menu'
4410 if (this.form === true) {
4413 cls: 'navbar-form form-inline'
4416 if (this.align === 'right') {
4417 cfg.cls += ' navbar-right ml-md-auto';
4419 cfg.cls += ' navbar-left';
4423 if (this.align === 'right') {
4424 cfg.cls += ' navbar-right ml-md-auto';
4426 cfg.cls += ' mr-auto';
4430 cfg.cls += ' navbar-inverse';
4438 * sets the active Navigation item
4439 * @param {Roo.bootstrap.NavItem} the new current navitem
4441 setActiveItem : function(item)
4444 Roo.each(this.navItems, function(v){
4449 v.setActive(false, true);
4456 item.setActive(true, true);
4457 this.fireEvent('changed', this, item, prev);
4462 * gets the active Navigation item
4463 * @return {Roo.bootstrap.NavItem} the current navitem
4465 getActive : function()
4469 Roo.each(this.navItems, function(v){
4480 indexOfNav : function()
4484 Roo.each(this.navItems, function(v,i){
4495 * adds a Navigation item
4496 * @param {Roo.bootstrap.NavItem} the navitem to add
4498 addItem : function(cfg)
4500 if (this.form && Roo.bootstrap.version == 4) {
4503 var cn = new Roo.bootstrap.NavItem(cfg);
4505 cn.parentId = this.id;
4506 cn.onRender(this.el, null);
4510 * register a Navigation item
4511 * @param {Roo.bootstrap.NavItem} the navitem to add
4513 register : function(item)
4515 this.navItems.push( item);
4516 item.navId = this.navId;
4521 * clear all the Navigation item
4524 clearAll : function()
4527 this.el.dom.innerHTML = '';
4530 getNavItem: function(tabId)
4533 Roo.each(this.navItems, function(e) {
4534 if (e.tabId == tabId) {
4544 setActiveNext : function()
4546 var i = this.indexOfNav(this.getActive());
4547 if (i > this.navItems.length) {
4550 this.setActiveItem(this.navItems[i+1]);
4552 setActivePrev : function()
4554 var i = this.indexOfNav(this.getActive());
4558 this.setActiveItem(this.navItems[i-1]);
4560 clearWasActive : function(except) {
4561 Roo.each(this.navItems, function(e) {
4562 if (e.tabId != except.tabId && e.was_active) {
4563 e.was_active = false;
4570 getWasActive : function ()
4573 Roo.each(this.navItems, function(e) {
4588 Roo.apply(Roo.bootstrap.NavGroup, {
4592 * register a Navigation Group
4593 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4595 register : function(navgrp)
4597 this.groups[navgrp.navId] = navgrp;
4601 * fetch a Navigation Group based on the navigation ID
4602 * @param {string} the navgroup to add
4603 * @returns {Roo.bootstrap.NavGroup} the navgroup
4605 get: function(navId) {
4606 if (typeof(this.groups[navId]) == 'undefined') {
4608 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4610 return this.groups[navId] ;
4625 * @class Roo.bootstrap.NavItem
4626 * @extends Roo.bootstrap.Component
4627 * Bootstrap Navbar.NavItem class
4628 * @cfg {String} href link to
4629 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4631 * @cfg {String} html content of button
4632 * @cfg {String} badge text inside badge
4633 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4634 * @cfg {String} glyphicon DEPRICATED - use fa
4635 * @cfg {String} icon DEPRICATED - use fa
4636 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4637 * @cfg {Boolean} active Is item active
4638 * @cfg {Boolean} disabled Is item disabled
4640 * @cfg {Boolean} preventDefault (true | false) default false
4641 * @cfg {String} tabId the tab that this item activates.
4642 * @cfg {String} tagtype (a|span) render as a href or span?
4643 * @cfg {Boolean} animateRef (true|false) link to element default false
4646 * Create a new Navbar Item
4647 * @param {Object} config The config object
4649 Roo.bootstrap.NavItem = function(config){
4650 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4655 * The raw click event for the entire grid.
4656 * @param {Roo.EventObject} e
4661 * Fires when the active item active state changes
4662 * @param {Roo.bootstrap.NavItem} this
4663 * @param {boolean} state the new state
4669 * Fires when scroll to element
4670 * @param {Roo.bootstrap.NavItem} this
4671 * @param {Object} options
4672 * @param {Roo.EventObject} e
4680 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4689 preventDefault : false,
4697 button_outline : false,
4701 getAutoCreate : function(){
4709 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4711 if (this.disabled) {
4712 cfg.cls += ' disabled';
4716 if (this.button_weight.length) {
4717 cfg.tag = this.href ? 'a' : 'button';
4718 cfg.html = this.html || '';
4719 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4721 cfg.href = this.href;
4724 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4727 // menu .. should add dropdown-menu class - so no need for carat..
4729 if (this.badge !== '') {
4731 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4736 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4740 href : this.href || "#",
4741 html: this.html || ''
4744 if (this.tagtype == 'a') {
4745 cfg.cn[0].cls = 'nav-link';
4748 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4751 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4753 if(this.glyphicon) {
4754 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4759 cfg.cn[0].html += " <span class='caret'></span>";
4763 if (this.badge !== '') {
4765 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4773 onRender : function(ct, position)
4775 // Roo.log("Call onRender: " + this.xtype);
4776 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4780 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4781 this.navLink = this.el.select('.nav-link',true).first();
4786 initEvents: function()
4788 if (typeof (this.menu) != 'undefined') {
4789 this.menu.parentType = this.xtype;
4790 this.menu.triggerEl = this.el;
4791 this.menu = this.addxtype(Roo.apply({}, this.menu));
4794 this.el.select('a',true).on('click', this.onClick, this);
4796 if(this.tagtype == 'span'){
4797 this.el.select('span',true).on('click', this.onClick, this);
4800 // at this point parent should be available..
4801 this.parent().register(this);
4804 onClick : function(e)
4806 if (e.getTarget('.dropdown-menu-item')) {
4807 // did you click on a menu itemm.... - then don't trigger onclick..
4812 this.preventDefault ||
4815 Roo.log("NavItem - prevent Default?");
4819 if (this.disabled) {
4823 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4824 if (tg && tg.transition) {
4825 Roo.log("waiting for the transitionend");
4831 //Roo.log("fire event clicked");
4832 if(this.fireEvent('click', this, e) === false){
4836 if(this.tagtype == 'span'){
4840 //Roo.log(this.href);
4841 var ael = this.el.select('a',true).first();
4844 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4845 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4846 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4847 return; // ignore... - it's a 'hash' to another page.
4849 Roo.log("NavItem - prevent Default?");
4851 this.scrollToElement(e);
4855 var p = this.parent();
4857 if (['tabs','pills'].indexOf(p.type)!==-1) {
4858 if (typeof(p.setActiveItem) !== 'undefined') {
4859 p.setActiveItem(this);
4863 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4864 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4865 // remove the collapsed menu expand...
4866 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4870 isActive: function () {
4873 setActive : function(state, fire, is_was_active)
4875 if (this.active && !state && this.navId) {
4876 this.was_active = true;
4877 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4879 nv.clearWasActive(this);
4883 this.active = state;
4886 this.el.removeClass('active');
4887 this.navLink ? this.navLink.removeClass('active') : false;
4888 } else if (!this.el.hasClass('active')) {
4890 this.el.addClass('active');
4891 if (Roo.bootstrap.version == 4 && this.navLink ) {
4892 this.navLink.addClass('active');
4897 this.fireEvent('changed', this, state);
4900 // show a panel if it's registered and related..
4902 if (!this.navId || !this.tabId || !state || is_was_active) {
4906 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4910 var pan = tg.getPanelByName(this.tabId);
4914 // if we can not flip to new panel - go back to old nav highlight..
4915 if (false == tg.showPanel(pan)) {
4916 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4918 var onav = nv.getWasActive();
4920 onav.setActive(true, false, true);
4929 // this should not be here...
4930 setDisabled : function(state)
4932 this.disabled = state;
4934 this.el.removeClass('disabled');
4935 } else if (!this.el.hasClass('disabled')) {
4936 this.el.addClass('disabled');
4942 * Fetch the element to display the tooltip on.
4943 * @return {Roo.Element} defaults to this.el
4945 tooltipEl : function()
4947 return this.el.select('' + this.tagtype + '', true).first();
4950 scrollToElement : function(e)
4952 var c = document.body;
4955 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4957 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4958 c = document.documentElement;
4961 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4967 var o = target.calcOffsetsTo(c);
4974 this.fireEvent('scrollto', this, options, e);
4976 Roo.get(c).scrollTo('top', options.value, true);
4989 * <span> icon </span>
4990 * <span> text </span>
4991 * <span>badge </span>
4995 * @class Roo.bootstrap.NavSidebarItem
4996 * @extends Roo.bootstrap.NavItem
4997 * Bootstrap Navbar.NavSidebarItem class
4998 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4999 * {Boolean} open is the menu open
5000 * {Boolean} buttonView use button as the tigger el rather that a (default false)
5001 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
5002 * {String} buttonSize (sm|md|lg)the extra classes for the button
5003 * {Boolean} showArrow show arrow next to the text (default true)
5005 * Create a new Navbar Button
5006 * @param {Object} config The config object
5008 Roo.bootstrap.NavSidebarItem = function(config){
5009 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5014 * The raw click event for the entire grid.
5015 * @param {Roo.EventObject} e
5020 * Fires when the active item active state changes
5021 * @param {Roo.bootstrap.NavSidebarItem} this
5022 * @param {boolean} state the new state
5030 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5032 badgeWeight : 'default',
5038 buttonWeight : 'default',
5044 getAutoCreate : function(){
5049 href : this.href || '#',
5055 if(this.buttonView){
5058 href : this.href || '#',
5059 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5072 cfg.cls += ' active';
5075 if (this.disabled) {
5076 cfg.cls += ' disabled';
5079 cfg.cls += ' open x-open';
5082 if (this.glyphicon || this.icon) {
5083 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5084 a.cn.push({ tag : 'i', cls : c }) ;
5087 if(!this.buttonView){
5090 html : this.html || ''
5097 if (this.badge !== '') {
5098 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5104 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5107 a.cls += ' dropdown-toggle treeview' ;
5113 initEvents : function()
5115 if (typeof (this.menu) != 'undefined') {
5116 this.menu.parentType = this.xtype;
5117 this.menu.triggerEl = this.el;
5118 this.menu = this.addxtype(Roo.apply({}, this.menu));
5121 this.el.on('click', this.onClick, this);
5123 if(this.badge !== ''){
5124 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5129 onClick : function(e)
5136 if(this.preventDefault){
5140 this.fireEvent('click', this);
5143 disable : function()
5145 this.setDisabled(true);
5150 this.setDisabled(false);
5153 setDisabled : function(state)
5155 if(this.disabled == state){
5159 this.disabled = state;
5162 this.el.addClass('disabled');
5166 this.el.removeClass('disabled');
5171 setActive : function(state)
5173 if(this.active == state){
5177 this.active = state;
5180 this.el.addClass('active');
5184 this.el.removeClass('active');
5189 isActive: function ()
5194 setBadge : function(str)
5200 this.badgeEl.dom.innerHTML = str;
5217 * @class Roo.bootstrap.Row
5218 * @extends Roo.bootstrap.Component
5219 * Bootstrap Row class (contains columns...)
5223 * @param {Object} config The config object
5226 Roo.bootstrap.Row = function(config){
5227 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5230 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5232 getAutoCreate : function(){
5251 * @class Roo.bootstrap.Element
5252 * @extends Roo.bootstrap.Component
5253 * Bootstrap Element class
5254 * @cfg {String} html contents of the element
5255 * @cfg {String} tag tag of the element
5256 * @cfg {String} cls class of the element
5257 * @cfg {Boolean} preventDefault (true|false) default false
5258 * @cfg {Boolean} clickable (true|false) default false
5261 * Create a new Element
5262 * @param {Object} config The config object
5265 Roo.bootstrap.Element = function(config){
5266 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5272 * When a element is chick
5273 * @param {Roo.bootstrap.Element} this
5274 * @param {Roo.EventObject} e
5280 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5285 preventDefault: false,
5288 getAutoCreate : function(){
5292 // cls: this.cls, double assign in parent class Component.js :: onRender
5299 initEvents: function()
5301 Roo.bootstrap.Element.superclass.initEvents.call(this);
5304 this.el.on('click', this.onClick, this);
5309 onClick : function(e)
5311 if(this.preventDefault){
5315 this.fireEvent('click', this, e);
5318 getValue : function()
5320 return this.el.dom.innerHTML;
5323 setValue : function(value)
5325 this.el.dom.innerHTML = value;
5340 * @class Roo.bootstrap.Pagination
5341 * @extends Roo.bootstrap.Component
5342 * Bootstrap Pagination class
5343 * @cfg {String} size xs | sm | md | lg
5344 * @cfg {Boolean} inverse false | true
5347 * Create a new Pagination
5348 * @param {Object} config The config object
5351 Roo.bootstrap.Pagination = function(config){
5352 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5355 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5361 getAutoCreate : function(){
5367 cfg.cls += ' inverse';
5373 cfg.cls += " " + this.cls;
5391 * @class Roo.bootstrap.PaginationItem
5392 * @extends Roo.bootstrap.Component
5393 * Bootstrap PaginationItem class
5394 * @cfg {String} html text
5395 * @cfg {String} href the link
5396 * @cfg {Boolean} preventDefault (true | false) default true
5397 * @cfg {Boolean} active (true | false) default false
5398 * @cfg {Boolean} disabled default false
5402 * Create a new PaginationItem
5403 * @param {Object} config The config object
5407 Roo.bootstrap.PaginationItem = function(config){
5408 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5413 * The raw click event for the entire grid.
5414 * @param {Roo.EventObject} e
5420 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5424 preventDefault: true,
5429 getAutoCreate : function(){
5435 href : this.href ? this.href : '#',
5436 html : this.html ? this.html : ''
5446 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5450 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5456 initEvents: function() {
5458 this.el.on('click', this.onClick, this);
5461 onClick : function(e)
5463 Roo.log('PaginationItem on click ');
5464 if(this.preventDefault){
5472 this.fireEvent('click', this, e);
5488 * @class Roo.bootstrap.Slider
5489 * @extends Roo.bootstrap.Component
5490 * Bootstrap Slider class
5493 * Create a new Slider
5494 * @param {Object} config The config object
5497 Roo.bootstrap.Slider = function(config){
5498 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5501 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5503 getAutoCreate : function(){
5507 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5511 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5523 * Ext JS Library 1.1.1
5524 * Copyright(c) 2006-2007, Ext JS, LLC.
5526 * Originally Released Under LGPL - original licence link has changed is not relivant.
5529 * <script type="text/javascript">
5534 * @class Roo.grid.ColumnModel
5535 * @extends Roo.util.Observable
5536 * This is the default implementation of a ColumnModel used by the Grid. It defines
5537 * the columns in the grid.
5540 var colModel = new Roo.grid.ColumnModel([
5541 {header: "Ticker", width: 60, sortable: true, locked: true},
5542 {header: "Company Name", width: 150, sortable: true},
5543 {header: "Market Cap.", width: 100, sortable: true},
5544 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5545 {header: "Employees", width: 100, sortable: true, resizable: false}
5550 * The config options listed for this class are options which may appear in each
5551 * individual column definition.
5552 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5554 * @param {Object} config An Array of column config objects. See this class's
5555 * config objects for details.
5557 Roo.grid.ColumnModel = function(config){
5559 * The config passed into the constructor
5561 this.config = config;
5564 // if no id, create one
5565 // if the column does not have a dataIndex mapping,
5566 // map it to the order it is in the config
5567 for(var i = 0, len = config.length; i < len; i++){
5569 if(typeof c.dataIndex == "undefined"){
5572 if(typeof c.renderer == "string"){
5573 c.renderer = Roo.util.Format[c.renderer];
5575 if(typeof c.id == "undefined"){
5578 if(c.editor && c.editor.xtype){
5579 c.editor = Roo.factory(c.editor, Roo.grid);
5581 if(c.editor && c.editor.isFormField){
5582 c.editor = new Roo.grid.GridEditor(c.editor);
5584 this.lookup[c.id] = c;
5588 * The width of columns which have no width specified (defaults to 100)
5591 this.defaultWidth = 100;
5594 * Default sortable of columns which have no sortable specified (defaults to false)
5597 this.defaultSortable = false;
5601 * @event widthchange
5602 * Fires when the width of a column changes.
5603 * @param {ColumnModel} this
5604 * @param {Number} columnIndex The column index
5605 * @param {Number} newWidth The new width
5607 "widthchange": true,
5609 * @event headerchange
5610 * Fires when the text of a header changes.
5611 * @param {ColumnModel} this
5612 * @param {Number} columnIndex The column index
5613 * @param {Number} newText The new header text
5615 "headerchange": true,
5617 * @event hiddenchange
5618 * Fires when a column is hidden or "unhidden".
5619 * @param {ColumnModel} this
5620 * @param {Number} columnIndex The column index
5621 * @param {Boolean} hidden true if hidden, false otherwise
5623 "hiddenchange": true,
5625 * @event columnmoved
5626 * Fires when a column is moved.
5627 * @param {ColumnModel} this
5628 * @param {Number} oldIndex
5629 * @param {Number} newIndex
5631 "columnmoved" : true,
5633 * @event columlockchange
5634 * Fires when a column's locked state is changed
5635 * @param {ColumnModel} this
5636 * @param {Number} colIndex
5637 * @param {Boolean} locked true if locked
5639 "columnlockchange" : true
5641 Roo.grid.ColumnModel.superclass.constructor.call(this);
5643 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5645 * @cfg {String} header The header text to display in the Grid view.
5648 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5649 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5650 * specified, the column's index is used as an index into the Record's data Array.
5653 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5654 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5657 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5658 * Defaults to the value of the {@link #defaultSortable} property.
5659 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5662 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5665 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5668 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5671 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5674 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5675 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5676 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5677 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5680 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5683 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5686 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5689 * @cfg {String} cursor (Optional)
5692 * @cfg {String} tooltip (Optional)
5695 * @cfg {Number} xs (Optional)
5698 * @cfg {Number} sm (Optional)
5701 * @cfg {Number} md (Optional)
5704 * @cfg {Number} lg (Optional)
5707 * Returns the id of the column at the specified index.
5708 * @param {Number} index The column index
5709 * @return {String} the id
5711 getColumnId : function(index){
5712 return this.config[index].id;
5716 * Returns the column for a specified id.
5717 * @param {String} id The column id
5718 * @return {Object} the column
5720 getColumnById : function(id){
5721 return this.lookup[id];
5726 * Returns the column for a specified dataIndex.
5727 * @param {String} dataIndex The column dataIndex
5728 * @return {Object|Boolean} the column or false if not found
5730 getColumnByDataIndex: function(dataIndex){
5731 var index = this.findColumnIndex(dataIndex);
5732 return index > -1 ? this.config[index] : false;
5736 * Returns the index for a specified column id.
5737 * @param {String} id The column id
5738 * @return {Number} the index, or -1 if not found
5740 getIndexById : function(id){
5741 for(var i = 0, len = this.config.length; i < len; i++){
5742 if(this.config[i].id == id){
5750 * Returns the index for a specified column dataIndex.
5751 * @param {String} dataIndex The column dataIndex
5752 * @return {Number} the index, or -1 if not found
5755 findColumnIndex : function(dataIndex){
5756 for(var i = 0, len = this.config.length; i < len; i++){
5757 if(this.config[i].dataIndex == dataIndex){
5765 moveColumn : function(oldIndex, newIndex){
5766 var c = this.config[oldIndex];
5767 this.config.splice(oldIndex, 1);
5768 this.config.splice(newIndex, 0, c);
5769 this.dataMap = null;
5770 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5773 isLocked : function(colIndex){
5774 return this.config[colIndex].locked === true;
5777 setLocked : function(colIndex, value, suppressEvent){
5778 if(this.isLocked(colIndex) == value){
5781 this.config[colIndex].locked = value;
5783 this.fireEvent("columnlockchange", this, colIndex, value);
5787 getTotalLockedWidth : function(){
5789 for(var i = 0; i < this.config.length; i++){
5790 if(this.isLocked(i) && !this.isHidden(i)){
5791 this.totalWidth += this.getColumnWidth(i);
5797 getLockedCount : function(){
5798 for(var i = 0, len = this.config.length; i < len; i++){
5799 if(!this.isLocked(i)){
5804 return this.config.length;
5808 * Returns the number of columns.
5811 getColumnCount : function(visibleOnly){
5812 if(visibleOnly === true){
5814 for(var i = 0, len = this.config.length; i < len; i++){
5815 if(!this.isHidden(i)){
5821 return this.config.length;
5825 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5826 * @param {Function} fn
5827 * @param {Object} scope (optional)
5828 * @return {Array} result
5830 getColumnsBy : function(fn, scope){
5832 for(var i = 0, len = this.config.length; i < len; i++){
5833 var c = this.config[i];
5834 if(fn.call(scope||this, c, i) === true){
5842 * Returns true if the specified column is sortable.
5843 * @param {Number} col The column index
5846 isSortable : function(col){
5847 if(typeof this.config[col].sortable == "undefined"){
5848 return this.defaultSortable;
5850 return this.config[col].sortable;
5854 * Returns the rendering (formatting) function defined for the column.
5855 * @param {Number} col The column index.
5856 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5858 getRenderer : function(col){
5859 if(!this.config[col].renderer){
5860 return Roo.grid.ColumnModel.defaultRenderer;
5862 return this.config[col].renderer;
5866 * Sets the rendering (formatting) function for a column.
5867 * @param {Number} col The column index
5868 * @param {Function} fn The function to use to process the cell's raw data
5869 * to return HTML markup for the grid view. The render function is called with
5870 * the following parameters:<ul>
5871 * <li>Data value.</li>
5872 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5873 * <li>css A CSS style string to apply to the table cell.</li>
5874 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5875 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5876 * <li>Row index</li>
5877 * <li>Column index</li>
5878 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5880 setRenderer : function(col, fn){
5881 this.config[col].renderer = fn;
5885 * Returns the width for the specified column.
5886 * @param {Number} col The column index
5889 getColumnWidth : function(col){
5890 return this.config[col].width * 1 || this.defaultWidth;
5894 * Sets the width for a column.
5895 * @param {Number} col The column index
5896 * @param {Number} width The new width
5898 setColumnWidth : function(col, width, suppressEvent){
5899 this.config[col].width = width;
5900 this.totalWidth = null;
5902 this.fireEvent("widthchange", this, col, width);
5907 * Returns the total width of all columns.
5908 * @param {Boolean} includeHidden True to include hidden column widths
5911 getTotalWidth : function(includeHidden){
5912 if(!this.totalWidth){
5913 this.totalWidth = 0;
5914 for(var i = 0, len = this.config.length; i < len; i++){
5915 if(includeHidden || !this.isHidden(i)){
5916 this.totalWidth += this.getColumnWidth(i);
5920 return this.totalWidth;
5924 * Returns the header for the specified column.
5925 * @param {Number} col The column index
5928 getColumnHeader : function(col){
5929 return this.config[col].header;
5933 * Sets the header for a column.
5934 * @param {Number} col The column index
5935 * @param {String} header The new header
5937 setColumnHeader : function(col, header){
5938 this.config[col].header = header;
5939 this.fireEvent("headerchange", this, col, header);
5943 * Returns the tooltip for the specified column.
5944 * @param {Number} col The column index
5947 getColumnTooltip : function(col){
5948 return this.config[col].tooltip;
5951 * Sets the tooltip for a column.
5952 * @param {Number} col The column index
5953 * @param {String} tooltip The new tooltip
5955 setColumnTooltip : function(col, tooltip){
5956 this.config[col].tooltip = tooltip;
5960 * Returns the dataIndex for the specified column.
5961 * @param {Number} col The column index
5964 getDataIndex : function(col){
5965 return this.config[col].dataIndex;
5969 * Sets the dataIndex for a column.
5970 * @param {Number} col The column index
5971 * @param {Number} dataIndex The new dataIndex
5973 setDataIndex : function(col, dataIndex){
5974 this.config[col].dataIndex = dataIndex;
5980 * Returns true if the cell is editable.
5981 * @param {Number} colIndex The column index
5982 * @param {Number} rowIndex The row index - this is nto actually used..?
5985 isCellEditable : function(colIndex, rowIndex){
5986 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5990 * Returns the editor defined for the cell/column.
5991 * return false or null to disable editing.
5992 * @param {Number} colIndex The column index
5993 * @param {Number} rowIndex The row index
5996 getCellEditor : function(colIndex, rowIndex){
5997 return this.config[colIndex].editor;
6001 * Sets if a column is editable.
6002 * @param {Number} col The column index
6003 * @param {Boolean} editable True if the column is editable
6005 setEditable : function(col, editable){
6006 this.config[col].editable = editable;
6011 * Returns true if the column is hidden.
6012 * @param {Number} colIndex The column index
6015 isHidden : function(colIndex){
6016 return this.config[colIndex].hidden;
6021 * Returns true if the column width cannot be changed
6023 isFixed : function(colIndex){
6024 return this.config[colIndex].fixed;
6028 * Returns true if the column can be resized
6031 isResizable : function(colIndex){
6032 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6035 * Sets if a column is hidden.
6036 * @param {Number} colIndex The column index
6037 * @param {Boolean} hidden True if the column is hidden
6039 setHidden : function(colIndex, hidden){
6040 this.config[colIndex].hidden = hidden;
6041 this.totalWidth = null;
6042 this.fireEvent("hiddenchange", this, colIndex, hidden);
6046 * Sets the editor for a column.
6047 * @param {Number} col The column index
6048 * @param {Object} editor The editor object
6050 setEditor : function(col, editor){
6051 this.config[col].editor = editor;
6055 Roo.grid.ColumnModel.defaultRenderer = function(value)
6057 if(typeof value == "object") {
6060 if(typeof value == "string" && value.length < 1){
6064 return String.format("{0}", value);
6067 // Alias for backwards compatibility
6068 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6071 * Ext JS Library 1.1.1
6072 * Copyright(c) 2006-2007, Ext JS, LLC.
6074 * Originally Released Under LGPL - original licence link has changed is not relivant.
6077 * <script type="text/javascript">
6081 * @class Roo.LoadMask
6082 * A simple utility class for generically masking elements while loading data. If the element being masked has
6083 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6084 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6085 * element's UpdateManager load indicator and will be destroyed after the initial load.
6087 * Create a new LoadMask
6088 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6089 * @param {Object} config The config object
6091 Roo.LoadMask = function(el, config){
6092 this.el = Roo.get(el);
6093 Roo.apply(this, config);
6095 this.store.on('beforeload', this.onBeforeLoad, this);
6096 this.store.on('load', this.onLoad, this);
6097 this.store.on('loadexception', this.onLoadException, this);
6098 this.removeMask = false;
6100 var um = this.el.getUpdateManager();
6101 um.showLoadIndicator = false; // disable the default indicator
6102 um.on('beforeupdate', this.onBeforeLoad, this);
6103 um.on('update', this.onLoad, this);
6104 um.on('failure', this.onLoad, this);
6105 this.removeMask = true;
6109 Roo.LoadMask.prototype = {
6111 * @cfg {Boolean} removeMask
6112 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6113 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6117 * The text to display in a centered loading message box (defaults to 'Loading...')
6121 * @cfg {String} msgCls
6122 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6124 msgCls : 'x-mask-loading',
6127 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6133 * Disables the mask to prevent it from being displayed
6135 disable : function(){
6136 this.disabled = true;
6140 * Enables the mask so that it can be displayed
6142 enable : function(){
6143 this.disabled = false;
6146 onLoadException : function()
6150 if (typeof(arguments[3]) != 'undefined') {
6151 Roo.MessageBox.alert("Error loading",arguments[3]);
6155 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6156 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6163 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6168 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6172 onBeforeLoad : function(){
6174 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6179 destroy : function(){
6181 this.store.un('beforeload', this.onBeforeLoad, this);
6182 this.store.un('load', this.onLoad, this);
6183 this.store.un('loadexception', this.onLoadException, this);
6185 var um = this.el.getUpdateManager();
6186 um.un('beforeupdate', this.onBeforeLoad, this);
6187 um.un('update', this.onLoad, this);
6188 um.un('failure', this.onLoad, this);
6199 * @class Roo.bootstrap.Table
6200 * @extends Roo.bootstrap.Component
6201 * Bootstrap Table class
6202 * @cfg {String} cls table class
6203 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6204 * @cfg {String} bgcolor Specifies the background color for a table
6205 * @cfg {Number} border Specifies whether the table cells should have borders or not
6206 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6207 * @cfg {Number} cellspacing Specifies the space between cells
6208 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6209 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6210 * @cfg {String} sortable Specifies that the table should be sortable
6211 * @cfg {String} summary Specifies a summary of the content of a table
6212 * @cfg {Number} width Specifies the width of a table
6213 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6215 * @cfg {boolean} striped Should the rows be alternative striped
6216 * @cfg {boolean} bordered Add borders to the table
6217 * @cfg {boolean} hover Add hover highlighting
6218 * @cfg {boolean} condensed Format condensed
6219 * @cfg {boolean} responsive Format condensed
6220 * @cfg {Boolean} loadMask (true|false) default false
6221 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6222 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6223 * @cfg {Boolean} rowSelection (true|false) default false
6224 * @cfg {Boolean} cellSelection (true|false) default false
6225 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6226 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6227 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6228 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6232 * Create a new Table
6233 * @param {Object} config The config object
6236 Roo.bootstrap.Table = function(config){
6237 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6242 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6243 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6244 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6245 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6247 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6249 this.sm.grid = this;
6250 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6251 this.sm = this.selModel;
6252 this.sm.xmodule = this.xmodule || false;
6255 if (this.cm && typeof(this.cm.config) == 'undefined') {
6256 this.colModel = new Roo.grid.ColumnModel(this.cm);
6257 this.cm = this.colModel;
6258 this.cm.xmodule = this.xmodule || false;
6261 this.store= Roo.factory(this.store, Roo.data);
6262 this.ds = this.store;
6263 this.ds.xmodule = this.xmodule || false;
6266 if (this.footer && this.store) {
6267 this.footer.dataSource = this.ds;
6268 this.footer = Roo.factory(this.footer);
6275 * Fires when a cell is clicked
6276 * @param {Roo.bootstrap.Table} this
6277 * @param {Roo.Element} el
6278 * @param {Number} rowIndex
6279 * @param {Number} columnIndex
6280 * @param {Roo.EventObject} e
6284 * @event celldblclick
6285 * Fires when a cell is double clicked
6286 * @param {Roo.bootstrap.Table} this
6287 * @param {Roo.Element} el
6288 * @param {Number} rowIndex
6289 * @param {Number} columnIndex
6290 * @param {Roo.EventObject} e
6292 "celldblclick" : true,
6295 * Fires when a row is clicked
6296 * @param {Roo.bootstrap.Table} this
6297 * @param {Roo.Element} el
6298 * @param {Number} rowIndex
6299 * @param {Roo.EventObject} e
6303 * @event rowdblclick
6304 * Fires when a row is double clicked
6305 * @param {Roo.bootstrap.Table} this
6306 * @param {Roo.Element} el
6307 * @param {Number} rowIndex
6308 * @param {Roo.EventObject} e
6310 "rowdblclick" : true,
6313 * Fires when a mouseover occur
6314 * @param {Roo.bootstrap.Table} this
6315 * @param {Roo.Element} el
6316 * @param {Number} rowIndex
6317 * @param {Number} columnIndex
6318 * @param {Roo.EventObject} e
6323 * Fires when a mouseout occur
6324 * @param {Roo.bootstrap.Table} this
6325 * @param {Roo.Element} el
6326 * @param {Number} rowIndex
6327 * @param {Number} columnIndex
6328 * @param {Roo.EventObject} e
6333 * Fires when a row is rendered, so you can change add a style to it.
6334 * @param {Roo.bootstrap.Table} this
6335 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6339 * @event rowsrendered
6340 * Fires when all the rows have been rendered
6341 * @param {Roo.bootstrap.Table} this
6343 'rowsrendered' : true,
6345 * @event contextmenu
6346 * The raw contextmenu event for the entire grid.
6347 * @param {Roo.EventObject} e
6349 "contextmenu" : true,
6351 * @event rowcontextmenu
6352 * Fires when a row is right clicked
6353 * @param {Roo.bootstrap.Table} this
6354 * @param {Number} rowIndex
6355 * @param {Roo.EventObject} e
6357 "rowcontextmenu" : true,
6359 * @event cellcontextmenu
6360 * Fires when a cell is right clicked
6361 * @param {Roo.bootstrap.Table} this
6362 * @param {Number} rowIndex
6363 * @param {Number} cellIndex
6364 * @param {Roo.EventObject} e
6366 "cellcontextmenu" : true,
6368 * @event headercontextmenu
6369 * Fires when a header is right clicked
6370 * @param {Roo.bootstrap.Table} this
6371 * @param {Number} columnIndex
6372 * @param {Roo.EventObject} e
6374 "headercontextmenu" : true
6378 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6404 rowSelection : false,
6405 cellSelection : false,
6408 // Roo.Element - the tbody
6410 // Roo.Element - thead element
6413 container: false, // used by gridpanel...
6419 auto_hide_footer : false,
6421 getAutoCreate : function()
6423 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6430 if (this.scrollBody) {
6431 cfg.cls += ' table-body-fixed';
6434 cfg.cls += ' table-striped';
6438 cfg.cls += ' table-hover';
6440 if (this.bordered) {
6441 cfg.cls += ' table-bordered';
6443 if (this.condensed) {
6444 cfg.cls += ' table-condensed';
6446 if (this.responsive) {
6447 cfg.cls += ' table-responsive';
6451 cfg.cls+= ' ' +this.cls;
6454 // this lot should be simplifed...
6467 ].forEach(function(k) {
6475 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6478 if(this.store || this.cm){
6479 if(this.headerShow){
6480 cfg.cn.push(this.renderHeader());
6483 cfg.cn.push(this.renderBody());
6485 if(this.footerShow){
6486 cfg.cn.push(this.renderFooter());
6488 // where does this come from?
6489 //cfg.cls+= ' TableGrid';
6492 return { cn : [ cfg ] };
6495 initEvents : function()
6497 if(!this.store || !this.cm){
6500 if (this.selModel) {
6501 this.selModel.initEvents();
6505 //Roo.log('initEvents with ds!!!!');
6507 this.mainBody = this.el.select('tbody', true).first();
6508 this.mainHead = this.el.select('thead', true).first();
6509 this.mainFoot = this.el.select('tfoot', true).first();
6515 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6516 e.on('click', _this.sort, _this);
6519 this.mainBody.on("click", this.onClick, this);
6520 this.mainBody.on("dblclick", this.onDblClick, this);
6522 // why is this done????? = it breaks dialogs??
6523 //this.parent().el.setStyle('position', 'relative');
6527 this.footer.parentId = this.id;
6528 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6531 this.el.select('tfoot tr td').first().addClass('hide');
6536 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6539 this.store.on('load', this.onLoad, this);
6540 this.store.on('beforeload', this.onBeforeLoad, this);
6541 this.store.on('update', this.onUpdate, this);
6542 this.store.on('add', this.onAdd, this);
6543 this.store.on("clear", this.clear, this);
6545 this.el.on("contextmenu", this.onContextMenu, this);
6547 this.mainBody.on('scroll', this.onBodyScroll, this);
6549 this.cm.on("headerchange", this.onHeaderChange, this);
6551 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6555 onContextMenu : function(e, t)
6557 this.processEvent("contextmenu", e);
6560 processEvent : function(name, e)
6562 if (name != 'touchstart' ) {
6563 this.fireEvent(name, e);
6566 var t = e.getTarget();
6568 var cell = Roo.get(t);
6574 if(cell.findParent('tfoot', false, true)){
6578 if(cell.findParent('thead', false, true)){
6580 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6581 cell = Roo.get(t).findParent('th', false, true);
6583 Roo.log("failed to find th in thead?");
6584 Roo.log(e.getTarget());
6589 var cellIndex = cell.dom.cellIndex;
6591 var ename = name == 'touchstart' ? 'click' : name;
6592 this.fireEvent("header" + ename, this, cellIndex, e);
6597 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6598 cell = Roo.get(t).findParent('td', false, true);
6600 Roo.log("failed to find th in tbody?");
6601 Roo.log(e.getTarget());
6606 var row = cell.findParent('tr', false, true);
6607 var cellIndex = cell.dom.cellIndex;
6608 var rowIndex = row.dom.rowIndex - 1;
6612 this.fireEvent("row" + name, this, rowIndex, e);
6616 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6622 onMouseover : function(e, el)
6624 var cell = Roo.get(el);
6630 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6631 cell = cell.findParent('td', false, true);
6634 var row = cell.findParent('tr', false, true);
6635 var cellIndex = cell.dom.cellIndex;
6636 var rowIndex = row.dom.rowIndex - 1; // start from 0
6638 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6642 onMouseout : function(e, el)
6644 var cell = Roo.get(el);
6650 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6651 cell = cell.findParent('td', false, true);
6654 var row = cell.findParent('tr', false, true);
6655 var cellIndex = cell.dom.cellIndex;
6656 var rowIndex = row.dom.rowIndex - 1; // start from 0
6658 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6662 onClick : function(e, el)
6664 var cell = Roo.get(el);
6666 if(!cell || (!this.cellSelection && !this.rowSelection)){
6670 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6671 cell = cell.findParent('td', false, true);
6674 if(!cell || typeof(cell) == 'undefined'){
6678 var row = cell.findParent('tr', false, true);
6680 if(!row || typeof(row) == 'undefined'){
6684 var cellIndex = cell.dom.cellIndex;
6685 var rowIndex = this.getRowIndex(row);
6687 // why??? - should these not be based on SelectionModel?
6688 if(this.cellSelection){
6689 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6692 if(this.rowSelection){
6693 this.fireEvent('rowclick', this, row, rowIndex, e);
6699 onDblClick : function(e,el)
6701 var cell = Roo.get(el);
6703 if(!cell || (!this.cellSelection && !this.rowSelection)){
6707 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6708 cell = cell.findParent('td', false, true);
6711 if(!cell || typeof(cell) == 'undefined'){
6715 var row = cell.findParent('tr', false, true);
6717 if(!row || typeof(row) == 'undefined'){
6721 var cellIndex = cell.dom.cellIndex;
6722 var rowIndex = this.getRowIndex(row);
6724 if(this.cellSelection){
6725 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6728 if(this.rowSelection){
6729 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6733 sort : function(e,el)
6735 var col = Roo.get(el);
6737 if(!col.hasClass('sortable')){
6741 var sort = col.attr('sort');
6744 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6748 this.store.sortInfo = {field : sort, direction : dir};
6751 Roo.log("calling footer first");
6752 this.footer.onClick('first');
6755 this.store.load({ params : { start : 0 } });
6759 renderHeader : function()
6767 this.totalWidth = 0;
6769 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6771 var config = cm.config[i];
6775 cls : 'x-hcol-' + i,
6777 html: cm.getColumnHeader(i)
6782 if(typeof(config.sortable) != 'undefined' && config.sortable){
6784 c.html = '<i class="glyphicon"></i>' + c.html;
6787 if(typeof(config.lgHeader) != 'undefined'){
6788 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6791 if(typeof(config.mdHeader) != 'undefined'){
6792 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6795 if(typeof(config.smHeader) != 'undefined'){
6796 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6799 if(typeof(config.xsHeader) != 'undefined'){
6800 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6807 if(typeof(config.tooltip) != 'undefined'){
6808 c.tooltip = config.tooltip;
6811 if(typeof(config.colspan) != 'undefined'){
6812 c.colspan = config.colspan;
6815 if(typeof(config.hidden) != 'undefined' && config.hidden){
6816 c.style += ' display:none;';
6819 if(typeof(config.dataIndex) != 'undefined'){
6820 c.sort = config.dataIndex;
6825 if(typeof(config.align) != 'undefined' && config.align.length){
6826 c.style += ' text-align:' + config.align + ';';
6829 if(typeof(config.width) != 'undefined'){
6830 c.style += ' width:' + config.width + 'px;';
6831 this.totalWidth += config.width;
6833 this.totalWidth += 100; // assume minimum of 100 per column?
6836 if(typeof(config.cls) != 'undefined'){
6837 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6840 ['xs','sm','md','lg'].map(function(size){
6842 if(typeof(config[size]) == 'undefined'){
6846 if (!config[size]) { // 0 = hidden
6847 c.cls += ' hidden-' + size;
6851 c.cls += ' col-' + size + '-' + config[size];
6861 renderBody : function()
6871 colspan : this.cm.getColumnCount()
6881 renderFooter : function()
6891 colspan : this.cm.getColumnCount()
6905 // Roo.log('ds onload');
6910 var ds = this.store;
6912 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6913 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6914 if (_this.store.sortInfo) {
6916 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6917 e.select('i', true).addClass(['glyphicon-arrow-up']);
6920 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6921 e.select('i', true).addClass(['glyphicon-arrow-down']);
6926 var tbody = this.mainBody;
6928 if(ds.getCount() > 0){
6929 ds.data.each(function(d,rowIndex){
6930 var row = this.renderRow(cm, ds, rowIndex);
6932 tbody.createChild(row);
6936 if(row.cellObjects.length){
6937 Roo.each(row.cellObjects, function(r){
6938 _this.renderCellObject(r);
6945 var tfoot = this.el.select('tfoot', true).first();
6947 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6949 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6951 var total = this.ds.getTotalCount();
6953 if(this.footer.pageSize < total){
6954 this.mainFoot.show();
6958 Roo.each(this.el.select('tbody td', true).elements, function(e){
6959 e.on('mouseover', _this.onMouseover, _this);
6962 Roo.each(this.el.select('tbody td', true).elements, function(e){
6963 e.on('mouseout', _this.onMouseout, _this);
6965 this.fireEvent('rowsrendered', this);
6971 onUpdate : function(ds,record)
6973 this.refreshRow(record);
6977 onRemove : function(ds, record, index, isUpdate){
6978 if(isUpdate !== true){
6979 this.fireEvent("beforerowremoved", this, index, record);
6981 var bt = this.mainBody.dom;
6983 var rows = this.el.select('tbody > tr', true).elements;
6985 if(typeof(rows[index]) != 'undefined'){
6986 bt.removeChild(rows[index].dom);
6989 // if(bt.rows[index]){
6990 // bt.removeChild(bt.rows[index]);
6993 if(isUpdate !== true){
6994 //this.stripeRows(index);
6995 //this.syncRowHeights(index, index);
6997 this.fireEvent("rowremoved", this, index, record);
7001 onAdd : function(ds, records, rowIndex)
7003 //Roo.log('on Add called');
7004 // - note this does not handle multiple adding very well..
7005 var bt = this.mainBody.dom;
7006 for (var i =0 ; i < records.length;i++) {
7007 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7008 //Roo.log(records[i]);
7009 //Roo.log(this.store.getAt(rowIndex+i));
7010 this.insertRow(this.store, rowIndex + i, false);
7017 refreshRow : function(record){
7018 var ds = this.store, index;
7019 if(typeof record == 'number'){
7021 record = ds.getAt(index);
7023 index = ds.indexOf(record);
7025 this.insertRow(ds, index, true);
7027 this.onRemove(ds, record, index+1, true);
7029 //this.syncRowHeights(index, index);
7031 this.fireEvent("rowupdated", this, index, record);
7034 insertRow : function(dm, rowIndex, isUpdate){
7037 this.fireEvent("beforerowsinserted", this, rowIndex);
7039 //var s = this.getScrollState();
7040 var row = this.renderRow(this.cm, this.store, rowIndex);
7041 // insert before rowIndex..
7042 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7046 if(row.cellObjects.length){
7047 Roo.each(row.cellObjects, function(r){
7048 _this.renderCellObject(r);
7053 this.fireEvent("rowsinserted", this, rowIndex);
7054 //this.syncRowHeights(firstRow, lastRow);
7055 //this.stripeRows(firstRow);
7062 getRowDom : function(rowIndex)
7064 var rows = this.el.select('tbody > tr', true).elements;
7066 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7069 // returns the object tree for a tr..
7072 renderRow : function(cm, ds, rowIndex)
7074 var d = ds.getAt(rowIndex);
7078 cls : 'x-row-' + rowIndex,
7082 var cellObjects = [];
7084 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7085 var config = cm.config[i];
7087 var renderer = cm.getRenderer(i);
7091 if(typeof(renderer) !== 'undefined'){
7092 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7094 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7095 // and are rendered into the cells after the row is rendered - using the id for the element.
7097 if(typeof(value) === 'object'){
7107 rowIndex : rowIndex,
7112 this.fireEvent('rowclass', this, rowcfg);
7116 cls : rowcfg.rowClass + ' x-col-' + i,
7118 html: (typeof(value) === 'object') ? '' : value
7125 if(typeof(config.colspan) != 'undefined'){
7126 td.colspan = config.colspan;
7129 if(typeof(config.hidden) != 'undefined' && config.hidden){
7130 td.style += ' display:none;';
7133 if(typeof(config.align) != 'undefined' && config.align.length){
7134 td.style += ' text-align:' + config.align + ';';
7136 if(typeof(config.valign) != 'undefined' && config.valign.length){
7137 td.style += ' vertical-align:' + config.valign + ';';
7140 if(typeof(config.width) != 'undefined'){
7141 td.style += ' width:' + config.width + 'px;';
7144 if(typeof(config.cursor) != 'undefined'){
7145 td.style += ' cursor:' + config.cursor + ';';
7148 if(typeof(config.cls) != 'undefined'){
7149 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7152 ['xs','sm','md','lg'].map(function(size){
7154 if(typeof(config[size]) == 'undefined'){
7158 if (!config[size]) { // 0 = hidden
7159 td.cls += ' hidden-' + size;
7163 td.cls += ' col-' + size + '-' + config[size];
7171 row.cellObjects = cellObjects;
7179 onBeforeLoad : function()
7188 this.el.select('tbody', true).first().dom.innerHTML = '';
7191 * Show or hide a row.
7192 * @param {Number} rowIndex to show or hide
7193 * @param {Boolean} state hide
7195 setRowVisibility : function(rowIndex, state)
7197 var bt = this.mainBody.dom;
7199 var rows = this.el.select('tbody > tr', true).elements;
7201 if(typeof(rows[rowIndex]) == 'undefined'){
7204 rows[rowIndex].dom.style.display = state ? '' : 'none';
7208 getSelectionModel : function(){
7210 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7212 return this.selModel;
7215 * Render the Roo.bootstrap object from renderder
7217 renderCellObject : function(r)
7221 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7223 var t = r.cfg.render(r.container);
7226 Roo.each(r.cfg.cn, function(c){
7228 container: t.getChildContainer(),
7231 _this.renderCellObject(child);
7236 getRowIndex : function(row)
7240 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7251 * Returns the grid's underlying element = used by panel.Grid
7252 * @return {Element} The element
7254 getGridEl : function(){
7258 * Forces a resize - used by panel.Grid
7259 * @return {Element} The element
7261 autoSize : function()
7263 //var ctr = Roo.get(this.container.dom.parentElement);
7264 var ctr = Roo.get(this.el.dom);
7266 var thd = this.getGridEl().select('thead',true).first();
7267 var tbd = this.getGridEl().select('tbody', true).first();
7268 var tfd = this.getGridEl().select('tfoot', true).first();
7270 var cw = ctr.getWidth();
7274 tbd.setSize(ctr.getWidth(),
7275 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7277 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7280 cw = Math.max(cw, this.totalWidth);
7281 this.getGridEl().select('tr',true).setWidth(cw);
7282 // resize 'expandable coloumn?
7284 return; // we doe not have a view in this design..
7287 onBodyScroll: function()
7289 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7291 this.mainHead.setStyle({
7292 'position' : 'relative',
7293 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7299 var scrollHeight = this.mainBody.dom.scrollHeight;
7301 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7303 var height = this.mainBody.getHeight();
7305 if(scrollHeight - height == scrollTop) {
7307 var total = this.ds.getTotalCount();
7309 if(this.footer.cursor + this.footer.pageSize < total){
7311 this.footer.ds.load({
7313 start : this.footer.cursor + this.footer.pageSize,
7314 limit : this.footer.pageSize
7324 onHeaderChange : function()
7326 var header = this.renderHeader();
7327 var table = this.el.select('table', true).first();
7329 this.mainHead.remove();
7330 this.mainHead = table.createChild(header, this.mainBody, false);
7333 onHiddenChange : function(colModel, colIndex, hidden)
7335 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7336 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7338 this.CSS.updateRule(thSelector, "display", "");
7339 this.CSS.updateRule(tdSelector, "display", "");
7342 this.CSS.updateRule(thSelector, "display", "none");
7343 this.CSS.updateRule(tdSelector, "display", "none");
7346 this.onHeaderChange();
7350 setColumnWidth: function(col_index, width)
7352 // width = "md-2 xs-2..."
7353 if(!this.colModel.config[col_index]) {
7357 var w = width.split(" ");
7359 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7361 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7364 for(var j = 0; j < w.length; j++) {
7370 var size_cls = w[j].split("-");
7372 if(!Number.isInteger(size_cls[1] * 1)) {
7376 if(!this.colModel.config[col_index][size_cls[0]]) {
7380 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7384 h_row[0].classList.replace(
7385 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7386 "col-"+size_cls[0]+"-"+size_cls[1]
7389 for(var i = 0; i < rows.length; i++) {
7391 var size_cls = w[j].split("-");
7393 if(!Number.isInteger(size_cls[1] * 1)) {
7397 if(!this.colModel.config[col_index][size_cls[0]]) {
7401 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7405 rows[i].classList.replace(
7406 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7407 "col-"+size_cls[0]+"-"+size_cls[1]
7411 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7426 * @class Roo.bootstrap.TableCell
7427 * @extends Roo.bootstrap.Component
7428 * Bootstrap TableCell class
7429 * @cfg {String} html cell contain text
7430 * @cfg {String} cls cell class
7431 * @cfg {String} tag cell tag (td|th) default td
7432 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7433 * @cfg {String} align Aligns the content in a cell
7434 * @cfg {String} axis Categorizes cells
7435 * @cfg {String} bgcolor Specifies the background color of a cell
7436 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7437 * @cfg {Number} colspan Specifies the number of columns a cell should span
7438 * @cfg {String} headers Specifies one or more header cells a cell is related to
7439 * @cfg {Number} height Sets the height of a cell
7440 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7441 * @cfg {Number} rowspan Sets the number of rows a cell should span
7442 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7443 * @cfg {String} valign Vertical aligns the content in a cell
7444 * @cfg {Number} width Specifies the width of a cell
7447 * Create a new TableCell
7448 * @param {Object} config The config object
7451 Roo.bootstrap.TableCell = function(config){
7452 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7455 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7475 getAutoCreate : function(){
7476 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7496 cfg.align=this.align
7502 cfg.bgcolor=this.bgcolor
7505 cfg.charoff=this.charoff
7508 cfg.colspan=this.colspan
7511 cfg.headers=this.headers
7514 cfg.height=this.height
7517 cfg.nowrap=this.nowrap
7520 cfg.rowspan=this.rowspan
7523 cfg.scope=this.scope
7526 cfg.valign=this.valign
7529 cfg.width=this.width
7548 * @class Roo.bootstrap.TableRow
7549 * @extends Roo.bootstrap.Component
7550 * Bootstrap TableRow class
7551 * @cfg {String} cls row class
7552 * @cfg {String} align Aligns the content in a table row
7553 * @cfg {String} bgcolor Specifies a background color for a table row
7554 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7555 * @cfg {String} valign Vertical aligns the content in a table row
7558 * Create a new TableRow
7559 * @param {Object} config The config object
7562 Roo.bootstrap.TableRow = function(config){
7563 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7566 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7574 getAutoCreate : function(){
7575 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7585 cfg.align = this.align;
7588 cfg.bgcolor = this.bgcolor;
7591 cfg.charoff = this.charoff;
7594 cfg.valign = this.valign;
7612 * @class Roo.bootstrap.TableBody
7613 * @extends Roo.bootstrap.Component
7614 * Bootstrap TableBody class
7615 * @cfg {String} cls element class
7616 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7617 * @cfg {String} align Aligns the content inside the element
7618 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7619 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7622 * Create a new TableBody
7623 * @param {Object} config The config object
7626 Roo.bootstrap.TableBody = function(config){
7627 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7630 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7638 getAutoCreate : function(){
7639 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7653 cfg.align = this.align;
7656 cfg.charoff = this.charoff;
7659 cfg.valign = this.valign;
7666 // initEvents : function()
7673 // this.store = Roo.factory(this.store, Roo.data);
7674 // this.store.on('load', this.onLoad, this);
7676 // this.store.load();
7680 // onLoad: function ()
7682 // this.fireEvent('load', this);
7692 * Ext JS Library 1.1.1
7693 * Copyright(c) 2006-2007, Ext JS, LLC.
7695 * Originally Released Under LGPL - original licence link has changed is not relivant.
7698 * <script type="text/javascript">
7701 // as we use this in bootstrap.
7702 Roo.namespace('Roo.form');
7704 * @class Roo.form.Action
7705 * Internal Class used to handle form actions
7707 * @param {Roo.form.BasicForm} el The form element or its id
7708 * @param {Object} config Configuration options
7713 // define the action interface
7714 Roo.form.Action = function(form, options){
7716 this.options = options || {};
7719 * Client Validation Failed
7722 Roo.form.Action.CLIENT_INVALID = 'client';
7724 * Server Validation Failed
7727 Roo.form.Action.SERVER_INVALID = 'server';
7729 * Connect to Server Failed
7732 Roo.form.Action.CONNECT_FAILURE = 'connect';
7734 * Reading Data from Server Failed
7737 Roo.form.Action.LOAD_FAILURE = 'load';
7739 Roo.form.Action.prototype = {
7741 failureType : undefined,
7742 response : undefined,
7746 run : function(options){
7751 success : function(response){
7756 handleResponse : function(response){
7760 // default connection failure
7761 failure : function(response){
7763 this.response = response;
7764 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7765 this.form.afterAction(this, false);
7768 processResponse : function(response){
7769 this.response = response;
7770 if(!response.responseText){
7773 this.result = this.handleResponse(response);
7777 // utility functions used internally
7778 getUrl : function(appendParams){
7779 var url = this.options.url || this.form.url || this.form.el.dom.action;
7781 var p = this.getParams();
7783 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7789 getMethod : function(){
7790 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7793 getParams : function(){
7794 var bp = this.form.baseParams;
7795 var p = this.options.params;
7797 if(typeof p == "object"){
7798 p = Roo.urlEncode(Roo.applyIf(p, bp));
7799 }else if(typeof p == 'string' && bp){
7800 p += '&' + Roo.urlEncode(bp);
7803 p = Roo.urlEncode(bp);
7808 createCallback : function(){
7810 success: this.success,
7811 failure: this.failure,
7813 timeout: (this.form.timeout*1000),
7814 upload: this.form.fileUpload ? this.success : undefined
7819 Roo.form.Action.Submit = function(form, options){
7820 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7823 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7826 haveProgress : false,
7827 uploadComplete : false,
7829 // uploadProgress indicator.
7830 uploadProgress : function()
7832 if (!this.form.progressUrl) {
7836 if (!this.haveProgress) {
7837 Roo.MessageBox.progress("Uploading", "Uploading");
7839 if (this.uploadComplete) {
7840 Roo.MessageBox.hide();
7844 this.haveProgress = true;
7846 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7848 var c = new Roo.data.Connection();
7850 url : this.form.progressUrl,
7855 success : function(req){
7856 //console.log(data);
7860 rdata = Roo.decode(req.responseText)
7862 Roo.log("Invalid data from server..");
7866 if (!rdata || !rdata.success) {
7868 Roo.MessageBox.alert(Roo.encode(rdata));
7871 var data = rdata.data;
7873 if (this.uploadComplete) {
7874 Roo.MessageBox.hide();
7879 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7880 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7883 this.uploadProgress.defer(2000,this);
7886 failure: function(data) {
7887 Roo.log('progress url failed ');
7898 // run get Values on the form, so it syncs any secondary forms.
7899 this.form.getValues();
7901 var o = this.options;
7902 var method = this.getMethod();
7903 var isPost = method == 'POST';
7904 if(o.clientValidation === false || this.form.isValid()){
7906 if (this.form.progressUrl) {
7907 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7908 (new Date() * 1) + '' + Math.random());
7913 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7914 form:this.form.el.dom,
7915 url:this.getUrl(!isPost),
7917 params:isPost ? this.getParams() : null,
7918 isUpload: this.form.fileUpload
7921 this.uploadProgress();
7923 }else if (o.clientValidation !== false){ // client validation failed
7924 this.failureType = Roo.form.Action.CLIENT_INVALID;
7925 this.form.afterAction(this, false);
7929 success : function(response)
7931 this.uploadComplete= true;
7932 if (this.haveProgress) {
7933 Roo.MessageBox.hide();
7937 var result = this.processResponse(response);
7938 if(result === true || result.success){
7939 this.form.afterAction(this, true);
7943 this.form.markInvalid(result.errors);
7944 this.failureType = Roo.form.Action.SERVER_INVALID;
7946 this.form.afterAction(this, false);
7948 failure : function(response)
7950 this.uploadComplete= true;
7951 if (this.haveProgress) {
7952 Roo.MessageBox.hide();
7955 this.response = response;
7956 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7957 this.form.afterAction(this, false);
7960 handleResponse : function(response){
7961 if(this.form.errorReader){
7962 var rs = this.form.errorReader.read(response);
7965 for(var i = 0, len = rs.records.length; i < len; i++) {
7966 var r = rs.records[i];
7970 if(errors.length < 1){
7974 success : rs.success,
7980 ret = Roo.decode(response.responseText);
7984 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7994 Roo.form.Action.Load = function(form, options){
7995 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7996 this.reader = this.form.reader;
7999 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8004 Roo.Ajax.request(Roo.apply(
8005 this.createCallback(), {
8006 method:this.getMethod(),
8007 url:this.getUrl(false),
8008 params:this.getParams()
8012 success : function(response){
8014 var result = this.processResponse(response);
8015 if(result === true || !result.success || !result.data){
8016 this.failureType = Roo.form.Action.LOAD_FAILURE;
8017 this.form.afterAction(this, false);
8020 this.form.clearInvalid();
8021 this.form.setValues(result.data);
8022 this.form.afterAction(this, true);
8025 handleResponse : function(response){
8026 if(this.form.reader){
8027 var rs = this.form.reader.read(response);
8028 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8030 success : rs.success,
8034 return Roo.decode(response.responseText);
8038 Roo.form.Action.ACTION_TYPES = {
8039 'load' : Roo.form.Action.Load,
8040 'submit' : Roo.form.Action.Submit
8049 * @class Roo.bootstrap.Form
8050 * @extends Roo.bootstrap.Component
8051 * Bootstrap Form class
8052 * @cfg {String} method GET | POST (default POST)
8053 * @cfg {String} labelAlign top | left (default top)
8054 * @cfg {String} align left | right - for navbars
8055 * @cfg {Boolean} loadMask load mask when submit (default true)
8060 * @param {Object} config The config object
8064 Roo.bootstrap.Form = function(config){
8066 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8068 Roo.bootstrap.Form.popover.apply();
8072 * @event clientvalidation
8073 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8074 * @param {Form} this
8075 * @param {Boolean} valid true if the form has passed client-side validation
8077 clientvalidation: true,
8079 * @event beforeaction
8080 * Fires before any action is performed. Return false to cancel the action.
8081 * @param {Form} this
8082 * @param {Action} action The action to be performed
8086 * @event actionfailed
8087 * Fires when an action fails.
8088 * @param {Form} this
8089 * @param {Action} action The action that failed
8091 actionfailed : true,
8093 * @event actioncomplete
8094 * Fires when an action is completed.
8095 * @param {Form} this
8096 * @param {Action} action The action that completed
8098 actioncomplete : true
8102 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8105 * @cfg {String} method
8106 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8111 * The URL to use for form actions if one isn't supplied in the action options.
8114 * @cfg {Boolean} fileUpload
8115 * Set to true if this form is a file upload.
8119 * @cfg {Object} baseParams
8120 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8124 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8128 * @cfg {Sting} align (left|right) for navbar forms
8133 activeAction : null,
8136 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8137 * element by passing it or its id or mask the form itself by passing in true.
8140 waitMsgTarget : false,
8145 * @cfg {Boolean} errorMask (true|false) default false
8150 * @cfg {Number} maskOffset Default 100
8155 * @cfg {Boolean} maskBody
8159 getAutoCreate : function(){
8163 method : this.method || 'POST',
8164 id : this.id || Roo.id(),
8167 if (this.parent().xtype.match(/^Nav/)) {
8168 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8172 if (this.labelAlign == 'left' ) {
8173 cfg.cls += ' form-horizontal';
8179 initEvents : function()
8181 this.el.on('submit', this.onSubmit, this);
8182 // this was added as random key presses on the form where triggering form submit.
8183 this.el.on('keypress', function(e) {
8184 if (e.getCharCode() != 13) {
8187 // we might need to allow it for textareas.. and some other items.
8188 // check e.getTarget().
8190 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8194 Roo.log("keypress blocked");
8202 onSubmit : function(e){
8207 * Returns true if client-side validation on the form is successful.
8210 isValid : function(){
8211 var items = this.getItems();
8215 items.each(function(f){
8221 Roo.log('invalid field: ' + f.name);
8225 if(!target && f.el.isVisible(true)){
8231 if(this.errorMask && !valid){
8232 Roo.bootstrap.Form.popover.mask(this, target);
8239 * Returns true if any fields in this form have changed since their original load.
8242 isDirty : function(){
8244 var items = this.getItems();
8245 items.each(function(f){
8255 * Performs a predefined action (submit or load) or custom actions you define on this form.
8256 * @param {String} actionName The name of the action type
8257 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8258 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8259 * accept other config options):
8261 Property Type Description
8262 ---------------- --------------- ----------------------------------------------------------------------------------
8263 url String The url for the action (defaults to the form's url)
8264 method String The form method to use (defaults to the form's method, or POST if not defined)
8265 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8266 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8267 validate the form on the client (defaults to false)
8269 * @return {BasicForm} this
8271 doAction : function(action, options){
8272 if(typeof action == 'string'){
8273 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8275 if(this.fireEvent('beforeaction', this, action) !== false){
8276 this.beforeAction(action);
8277 action.run.defer(100, action);
8283 beforeAction : function(action){
8284 var o = action.options;
8289 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8291 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8294 // not really supported yet.. ??
8296 //if(this.waitMsgTarget === true){
8297 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8298 //}else if(this.waitMsgTarget){
8299 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8300 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8302 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8308 afterAction : function(action, success){
8309 this.activeAction = null;
8310 var o = action.options;
8315 Roo.get(document.body).unmask();
8321 //if(this.waitMsgTarget === true){
8322 // this.el.unmask();
8323 //}else if(this.waitMsgTarget){
8324 // this.waitMsgTarget.unmask();
8326 // Roo.MessageBox.updateProgress(1);
8327 // Roo.MessageBox.hide();
8334 Roo.callback(o.success, o.scope, [this, action]);
8335 this.fireEvent('actioncomplete', this, action);
8339 // failure condition..
8340 // we have a scenario where updates need confirming.
8341 // eg. if a locking scenario exists..
8342 // we look for { errors : { needs_confirm : true }} in the response.
8344 (typeof(action.result) != 'undefined') &&
8345 (typeof(action.result.errors) != 'undefined') &&
8346 (typeof(action.result.errors.needs_confirm) != 'undefined')
8349 Roo.log("not supported yet");
8352 Roo.MessageBox.confirm(
8353 "Change requires confirmation",
8354 action.result.errorMsg,
8359 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8369 Roo.callback(o.failure, o.scope, [this, action]);
8370 // show an error message if no failed handler is set..
8371 if (!this.hasListener('actionfailed')) {
8372 Roo.log("need to add dialog support");
8374 Roo.MessageBox.alert("Error",
8375 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8376 action.result.errorMsg :
8377 "Saving Failed, please check your entries or try again"
8382 this.fireEvent('actionfailed', this, action);
8387 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8388 * @param {String} id The value to search for
8391 findField : function(id){
8392 var items = this.getItems();
8393 var field = items.get(id);
8395 items.each(function(f){
8396 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8403 return field || null;
8406 * Mark fields in this form invalid in bulk.
8407 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8408 * @return {BasicForm} this
8410 markInvalid : function(errors){
8411 if(errors instanceof Array){
8412 for(var i = 0, len = errors.length; i < len; i++){
8413 var fieldError = errors[i];
8414 var f = this.findField(fieldError.id);
8416 f.markInvalid(fieldError.msg);
8422 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8423 field.markInvalid(errors[id]);
8427 //Roo.each(this.childForms || [], function (f) {
8428 // f.markInvalid(errors);
8435 * Set values for fields in this form in bulk.
8436 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8437 * @return {BasicForm} this
8439 setValues : function(values){
8440 if(values instanceof Array){ // array of objects
8441 for(var i = 0, len = values.length; i < len; i++){
8443 var f = this.findField(v.id);
8445 f.setValue(v.value);
8446 if(this.trackResetOnLoad){
8447 f.originalValue = f.getValue();
8451 }else{ // object hash
8454 if(typeof values[id] != 'function' && (field = this.findField(id))){
8456 if (field.setFromData &&
8458 field.displayField &&
8459 // combos' with local stores can
8460 // be queried via setValue()
8461 // to set their value..
8462 (field.store && !field.store.isLocal)
8466 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8467 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8468 field.setFromData(sd);
8470 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8472 field.setFromData(values);
8475 field.setValue(values[id]);
8479 if(this.trackResetOnLoad){
8480 field.originalValue = field.getValue();
8486 //Roo.each(this.childForms || [], function (f) {
8487 // f.setValues(values);
8494 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8495 * they are returned as an array.
8496 * @param {Boolean} asString
8499 getValues : function(asString){
8500 //if (this.childForms) {
8501 // copy values from the child forms
8502 // Roo.each(this.childForms, function (f) {
8503 // this.setValues(f.getValues());
8509 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8510 if(asString === true){
8513 return Roo.urlDecode(fs);
8517 * Returns the fields in this form as an object with key/value pairs.
8518 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8521 getFieldValues : function(with_hidden)
8523 var items = this.getItems();
8525 items.each(function(f){
8531 var v = f.getValue();
8533 if (f.inputType =='radio') {
8534 if (typeof(ret[f.getName()]) == 'undefined') {
8535 ret[f.getName()] = ''; // empty..
8538 if (!f.el.dom.checked) {
8546 if(f.xtype == 'MoneyField'){
8547 ret[f.currencyName] = f.getCurrency();
8550 // not sure if this supported any more..
8551 if ((typeof(v) == 'object') && f.getRawValue) {
8552 v = f.getRawValue() ; // dates..
8554 // combo boxes where name != hiddenName...
8555 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8556 ret[f.name] = f.getRawValue();
8558 ret[f.getName()] = v;
8565 * Clears all invalid messages in this form.
8566 * @return {BasicForm} this
8568 clearInvalid : function(){
8569 var items = this.getItems();
8571 items.each(function(f){
8580 * @return {BasicForm} this
8583 var items = this.getItems();
8584 items.each(function(f){
8588 Roo.each(this.childForms || [], function (f) {
8596 getItems : function()
8598 var r=new Roo.util.MixedCollection(false, function(o){
8599 return o.id || (o.id = Roo.id());
8601 var iter = function(el) {
8608 Roo.each(el.items,function(e) {
8617 hideFields : function(items)
8619 Roo.each(items, function(i){
8621 var f = this.findField(i);
8632 showFields : function(items)
8634 Roo.each(items, function(i){
8636 var f = this.findField(i);
8649 Roo.apply(Roo.bootstrap.Form, {
8676 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8677 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8678 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8679 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8682 this.maskEl.top.enableDisplayMode("block");
8683 this.maskEl.left.enableDisplayMode("block");
8684 this.maskEl.bottom.enableDisplayMode("block");
8685 this.maskEl.right.enableDisplayMode("block");
8687 this.toolTip = new Roo.bootstrap.Tooltip({
8688 cls : 'roo-form-error-popover',
8690 'left' : ['r-l', [-2,0], 'right'],
8691 'right' : ['l-r', [2,0], 'left'],
8692 'bottom' : ['tl-bl', [0,2], 'top'],
8693 'top' : [ 'bl-tl', [0,-2], 'bottom']
8697 this.toolTip.render(Roo.get(document.body));
8699 this.toolTip.el.enableDisplayMode("block");
8701 Roo.get(document.body).on('click', function(){
8705 Roo.get(document.body).on('touchstart', function(){
8709 this.isApplied = true
8712 mask : function(form, target)
8716 this.target = target;
8718 if(!this.form.errorMask || !target.el){
8722 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8724 Roo.log(scrollable);
8726 var ot = this.target.el.calcOffsetsTo(scrollable);
8728 var scrollTo = ot[1] - this.form.maskOffset;
8730 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8732 scrollable.scrollTo('top', scrollTo);
8734 var box = this.target.el.getBox();
8736 var zIndex = Roo.bootstrap.Modal.zIndex++;
8739 this.maskEl.top.setStyle('position', 'absolute');
8740 this.maskEl.top.setStyle('z-index', zIndex);
8741 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8742 this.maskEl.top.setLeft(0);
8743 this.maskEl.top.setTop(0);
8744 this.maskEl.top.show();
8746 this.maskEl.left.setStyle('position', 'absolute');
8747 this.maskEl.left.setStyle('z-index', zIndex);
8748 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8749 this.maskEl.left.setLeft(0);
8750 this.maskEl.left.setTop(box.y - this.padding);
8751 this.maskEl.left.show();
8753 this.maskEl.bottom.setStyle('position', 'absolute');
8754 this.maskEl.bottom.setStyle('z-index', zIndex);
8755 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8756 this.maskEl.bottom.setLeft(0);
8757 this.maskEl.bottom.setTop(box.bottom + this.padding);
8758 this.maskEl.bottom.show();
8760 this.maskEl.right.setStyle('position', 'absolute');
8761 this.maskEl.right.setStyle('z-index', zIndex);
8762 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8763 this.maskEl.right.setLeft(box.right + this.padding);
8764 this.maskEl.right.setTop(box.y - this.padding);
8765 this.maskEl.right.show();
8767 this.toolTip.bindEl = this.target.el;
8769 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8771 var tip = this.target.blankText;
8773 if(this.target.getValue() !== '' ) {
8775 if (this.target.invalidText.length) {
8776 tip = this.target.invalidText;
8777 } else if (this.target.regexText.length){
8778 tip = this.target.regexText;
8782 this.toolTip.show(tip);
8784 this.intervalID = window.setInterval(function() {
8785 Roo.bootstrap.Form.popover.unmask();
8788 window.onwheel = function(){ return false;};
8790 (function(){ this.isMasked = true; }).defer(500, this);
8796 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8800 this.maskEl.top.setStyle('position', 'absolute');
8801 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8802 this.maskEl.top.hide();
8804 this.maskEl.left.setStyle('position', 'absolute');
8805 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8806 this.maskEl.left.hide();
8808 this.maskEl.bottom.setStyle('position', 'absolute');
8809 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8810 this.maskEl.bottom.hide();
8812 this.maskEl.right.setStyle('position', 'absolute');
8813 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8814 this.maskEl.right.hide();
8816 this.toolTip.hide();
8818 this.toolTip.el.hide();
8820 window.onwheel = function(){ return true;};
8822 if(this.intervalID){
8823 window.clearInterval(this.intervalID);
8824 this.intervalID = false;
8827 this.isMasked = false;
8837 * Ext JS Library 1.1.1
8838 * Copyright(c) 2006-2007, Ext JS, LLC.
8840 * Originally Released Under LGPL - original licence link has changed is not relivant.
8843 * <script type="text/javascript">
8846 * @class Roo.form.VTypes
8847 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8850 Roo.form.VTypes = function(){
8851 // closure these in so they are only created once.
8852 var alpha = /^[a-zA-Z_]+$/;
8853 var alphanum = /^[a-zA-Z0-9_]+$/;
8854 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8855 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8857 // All these messages and functions are configurable
8860 * The function used to validate email addresses
8861 * @param {String} value The email address
8863 'email' : function(v){
8864 return email.test(v);
8867 * The error text to display when the email validation function returns false
8870 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8872 * The keystroke filter mask to be applied on email input
8875 'emailMask' : /[a-z0-9_\.\-@]/i,
8878 * The function used to validate URLs
8879 * @param {String} value The URL
8881 'url' : function(v){
8885 * The error text to display when the url validation function returns false
8888 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8891 * The function used to validate alpha values
8892 * @param {String} value The value
8894 'alpha' : function(v){
8895 return alpha.test(v);
8898 * The error text to display when the alpha validation function returns false
8901 'alphaText' : 'This field should only contain letters and _',
8903 * The keystroke filter mask to be applied on alpha input
8906 'alphaMask' : /[a-z_]/i,
8909 * The function used to validate alphanumeric values
8910 * @param {String} value The value
8912 'alphanum' : function(v){
8913 return alphanum.test(v);
8916 * The error text to display when the alphanumeric validation function returns false
8919 'alphanumText' : 'This field should only contain letters, numbers and _',
8921 * The keystroke filter mask to be applied on alphanumeric input
8924 'alphanumMask' : /[a-z0-9_]/i
8934 * @class Roo.bootstrap.Input
8935 * @extends Roo.bootstrap.Component
8936 * Bootstrap Input class
8937 * @cfg {Boolean} disabled is it disabled
8938 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8939 * @cfg {String} name name of the input
8940 * @cfg {string} fieldLabel - the label associated
8941 * @cfg {string} placeholder - placeholder to put in text.
8942 * @cfg {string} before - input group add on before
8943 * @cfg {string} after - input group add on after
8944 * @cfg {string} size - (lg|sm) or leave empty..
8945 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8946 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8947 * @cfg {Number} md colspan out of 12 for computer-sized screens
8948 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8949 * @cfg {string} value default value of the input
8950 * @cfg {Number} labelWidth set the width of label
8951 * @cfg {Number} labellg set the width of label (1-12)
8952 * @cfg {Number} labelmd set the width of label (1-12)
8953 * @cfg {Number} labelsm set the width of label (1-12)
8954 * @cfg {Number} labelxs set the width of label (1-12)
8955 * @cfg {String} labelAlign (top|left)
8956 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8957 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8958 * @cfg {String} indicatorpos (left|right) default left
8959 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8960 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8962 * @cfg {String} align (left|center|right) Default left
8963 * @cfg {Boolean} forceFeedback (true|false) Default false
8966 * Create a new Input
8967 * @param {Object} config The config object
8970 Roo.bootstrap.Input = function(config){
8972 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8977 * Fires when this field receives input focus.
8978 * @param {Roo.form.Field} this
8983 * Fires when this field loses input focus.
8984 * @param {Roo.form.Field} this
8989 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8990 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8991 * @param {Roo.form.Field} this
8992 * @param {Roo.EventObject} e The event object
8997 * Fires just before the field blurs if the field value has changed.
8998 * @param {Roo.form.Field} this
8999 * @param {Mixed} newValue The new value
9000 * @param {Mixed} oldValue The original value
9005 * Fires after the field has been marked as invalid.
9006 * @param {Roo.form.Field} this
9007 * @param {String} msg The validation message
9012 * Fires after the field has been validated with no errors.
9013 * @param {Roo.form.Field} this
9018 * Fires after the key up
9019 * @param {Roo.form.Field} this
9020 * @param {Roo.EventObject} e The event Object
9026 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9028 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9029 automatic validation (defaults to "keyup").
9031 validationEvent : "keyup",
9033 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9035 validateOnBlur : true,
9037 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9039 validationDelay : 250,
9041 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9043 focusClass : "x-form-focus", // not needed???
9047 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9049 invalidClass : "has-warning",
9052 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9054 validClass : "has-success",
9057 * @cfg {Boolean} hasFeedback (true|false) default true
9062 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9064 invalidFeedbackClass : "glyphicon-warning-sign",
9067 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9069 validFeedbackClass : "glyphicon-ok",
9072 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9074 selectOnFocus : false,
9077 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9081 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9086 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9088 disableKeyFilter : false,
9091 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9095 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9099 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9101 blankText : "Please complete this mandatory field",
9104 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9108 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9110 maxLength : Number.MAX_VALUE,
9112 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9114 minLengthText : "The minimum length for this field is {0}",
9116 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9118 maxLengthText : "The maximum length for this field is {0}",
9122 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9123 * If available, this function will be called only after the basic validators all return true, and will be passed the
9124 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9128 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9129 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9130 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9134 * @cfg {String} regexText -- Depricated - use Invalid Text
9139 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9145 autocomplete: false,
9164 formatedValue : false,
9165 forceFeedback : false,
9167 indicatorpos : 'left',
9177 parentLabelAlign : function()
9180 while (parent.parent()) {
9181 parent = parent.parent();
9182 if (typeof(parent.labelAlign) !='undefined') {
9183 return parent.labelAlign;
9190 getAutoCreate : function()
9192 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9198 if(this.inputType != 'hidden'){
9199 cfg.cls = 'form-group' //input-group
9205 type : this.inputType,
9207 cls : 'form-control',
9208 placeholder : this.placeholder || '',
9209 autocomplete : this.autocomplete || 'new-password'
9212 if(this.capture.length){
9213 input.capture = this.capture;
9216 if(this.accept.length){
9217 input.accept = this.accept + "/*";
9221 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9224 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9225 input.maxLength = this.maxLength;
9228 if (this.disabled) {
9229 input.disabled=true;
9232 if (this.readOnly) {
9233 input.readonly=true;
9237 input.name = this.name;
9241 input.cls += ' input-' + this.size;
9245 ['xs','sm','md','lg'].map(function(size){
9246 if (settings[size]) {
9247 cfg.cls += ' col-' + size + '-' + settings[size];
9251 var inputblock = input;
9255 cls: 'glyphicon form-control-feedback'
9258 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9261 cls : 'has-feedback',
9269 if (this.before || this.after) {
9272 cls : 'input-group',
9276 if (this.before && typeof(this.before) == 'string') {
9278 inputblock.cn.push({
9280 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9284 if (this.before && typeof(this.before) == 'object') {
9285 this.before = Roo.factory(this.before);
9287 inputblock.cn.push({
9289 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9290 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9294 inputblock.cn.push(input);
9296 if (this.after && typeof(this.after) == 'string') {
9297 inputblock.cn.push({
9299 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9303 if (this.after && typeof(this.after) == 'object') {
9304 this.after = Roo.factory(this.after);
9306 inputblock.cn.push({
9308 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9309 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9313 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9314 inputblock.cls += ' has-feedback';
9315 inputblock.cn.push(feedback);
9320 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9321 tooltip : 'This field is required'
9323 if (Roo.bootstrap.version == 4) {
9326 style : 'display-none'
9329 if (align ==='left' && this.fieldLabel.length) {
9331 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9338 cls : 'control-label col-form-label',
9339 html : this.fieldLabel
9350 var labelCfg = cfg.cn[1];
9351 var contentCfg = cfg.cn[2];
9353 if(this.indicatorpos == 'right'){
9358 cls : 'control-label col-form-label',
9362 html : this.fieldLabel
9376 labelCfg = cfg.cn[0];
9377 contentCfg = cfg.cn[1];
9381 if(this.labelWidth > 12){
9382 labelCfg.style = "width: " + this.labelWidth + 'px';
9385 if(this.labelWidth < 13 && this.labelmd == 0){
9386 this.labelmd = this.labelWidth;
9389 if(this.labellg > 0){
9390 labelCfg.cls += ' col-lg-' + this.labellg;
9391 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9394 if(this.labelmd > 0){
9395 labelCfg.cls += ' col-md-' + this.labelmd;
9396 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9399 if(this.labelsm > 0){
9400 labelCfg.cls += ' col-sm-' + this.labelsm;
9401 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9404 if(this.labelxs > 0){
9405 labelCfg.cls += ' col-xs-' + this.labelxs;
9406 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9410 } else if ( this.fieldLabel.length) {
9415 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9416 tooltip : 'This field is required'
9420 //cls : 'input-group-addon',
9421 html : this.fieldLabel
9429 if(this.indicatorpos == 'right'){
9434 //cls : 'input-group-addon',
9435 html : this.fieldLabel
9440 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9441 tooltip : 'This field is required'
9461 if (this.parentType === 'Navbar' && this.parent().bar) {
9462 cfg.cls += ' navbar-form';
9465 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9466 // on BS4 we do this only if not form
9467 cfg.cls += ' navbar-form';
9475 * return the real input element.
9477 inputEl: function ()
9479 return this.el.select('input.form-control',true).first();
9482 tooltipEl : function()
9484 return this.inputEl();
9487 indicatorEl : function()
9489 if (Roo.bootstrap.version == 4) {
9490 return false; // not enabled in v4 yet.
9493 var indicator = this.el.select('i.roo-required-indicator',true).first();
9503 setDisabled : function(v)
9505 var i = this.inputEl().dom;
9507 i.removeAttribute('disabled');
9511 i.setAttribute('disabled','true');
9513 initEvents : function()
9516 this.inputEl().on("keydown" , this.fireKey, this);
9517 this.inputEl().on("focus", this.onFocus, this);
9518 this.inputEl().on("blur", this.onBlur, this);
9520 this.inputEl().relayEvent('keyup', this);
9522 this.indicator = this.indicatorEl();
9525 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9528 // reference to original value for reset
9529 this.originalValue = this.getValue();
9530 //Roo.form.TextField.superclass.initEvents.call(this);
9531 if(this.validationEvent == 'keyup'){
9532 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9533 this.inputEl().on('keyup', this.filterValidation, this);
9535 else if(this.validationEvent !== false){
9536 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9539 if(this.selectOnFocus){
9540 this.on("focus", this.preFocus, this);
9543 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9544 this.inputEl().on("keypress", this.filterKeys, this);
9546 this.inputEl().relayEvent('keypress', this);
9549 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9550 this.el.on("click", this.autoSize, this);
9553 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9554 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9557 if (typeof(this.before) == 'object') {
9558 this.before.render(this.el.select('.roo-input-before',true).first());
9560 if (typeof(this.after) == 'object') {
9561 this.after.render(this.el.select('.roo-input-after',true).first());
9564 this.inputEl().on('change', this.onChange, this);
9567 filterValidation : function(e){
9568 if(!e.isNavKeyPress()){
9569 this.validationTask.delay(this.validationDelay);
9573 * Validates the field value
9574 * @return {Boolean} True if the value is valid, else false
9576 validate : function(){
9577 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9578 if(this.disabled || this.validateValue(this.getRawValue())){
9589 * Validates a value according to the field's validation rules and marks the field as invalid
9590 * if the validation fails
9591 * @param {Mixed} value The value to validate
9592 * @return {Boolean} True if the value is valid, else false
9594 validateValue : function(value)
9596 if(this.getVisibilityEl().hasClass('hidden')){
9600 if(value.length < 1) { // if it's blank
9601 if(this.allowBlank){
9607 if(value.length < this.minLength){
9610 if(value.length > this.maxLength){
9614 var vt = Roo.form.VTypes;
9615 if(!vt[this.vtype](value, this)){
9619 if(typeof this.validator == "function"){
9620 var msg = this.validator(value);
9624 if (typeof(msg) == 'string') {
9625 this.invalidText = msg;
9629 if(this.regex && !this.regex.test(value)){
9637 fireKey : function(e){
9638 //Roo.log('field ' + e.getKey());
9639 if(e.isNavKeyPress()){
9640 this.fireEvent("specialkey", this, e);
9643 focus : function (selectText){
9645 this.inputEl().focus();
9646 if(selectText === true){
9647 this.inputEl().dom.select();
9653 onFocus : function(){
9654 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9655 // this.el.addClass(this.focusClass);
9658 this.hasFocus = true;
9659 this.startValue = this.getValue();
9660 this.fireEvent("focus", this);
9664 beforeBlur : Roo.emptyFn,
9668 onBlur : function(){
9670 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9671 //this.el.removeClass(this.focusClass);
9673 this.hasFocus = false;
9674 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9677 var v = this.getValue();
9678 if(String(v) !== String(this.startValue)){
9679 this.fireEvent('change', this, v, this.startValue);
9681 this.fireEvent("blur", this);
9684 onChange : function(e)
9686 var v = this.getValue();
9687 if(String(v) !== String(this.startValue)){
9688 this.fireEvent('change', this, v, this.startValue);
9694 * Resets the current field value to the originally loaded value and clears any validation messages
9697 this.setValue(this.originalValue);
9701 * Returns the name of the field
9702 * @return {Mixed} name The name field
9704 getName: function(){
9708 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9709 * @return {Mixed} value The field value
9711 getValue : function(){
9713 var v = this.inputEl().getValue();
9718 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9719 * @return {Mixed} value The field value
9721 getRawValue : function(){
9722 var v = this.inputEl().getValue();
9728 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9729 * @param {Mixed} value The value to set
9731 setRawValue : function(v){
9732 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9735 selectText : function(start, end){
9736 var v = this.getRawValue();
9738 start = start === undefined ? 0 : start;
9739 end = end === undefined ? v.length : end;
9740 var d = this.inputEl().dom;
9741 if(d.setSelectionRange){
9742 d.setSelectionRange(start, end);
9743 }else if(d.createTextRange){
9744 var range = d.createTextRange();
9745 range.moveStart("character", start);
9746 range.moveEnd("character", v.length-end);
9753 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9754 * @param {Mixed} value The value to set
9756 setValue : function(v){
9759 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9765 processValue : function(value){
9766 if(this.stripCharsRe){
9767 var newValue = value.replace(this.stripCharsRe, '');
9768 if(newValue !== value){
9769 this.setRawValue(newValue);
9776 preFocus : function(){
9778 if(this.selectOnFocus){
9779 this.inputEl().dom.select();
9782 filterKeys : function(e){
9784 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9787 var c = e.getCharCode(), cc = String.fromCharCode(c);
9788 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9791 if(!this.maskRe.test(cc)){
9796 * Clear any invalid styles/messages for this field
9798 clearInvalid : function(){
9800 if(!this.el || this.preventMark){ // not rendered
9805 this.el.removeClass([this.invalidClass, 'is-invalid']);
9807 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9809 var feedback = this.el.select('.form-control-feedback', true).first();
9812 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9818 this.indicator.removeClass('visible');
9819 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9822 this.fireEvent('valid', this);
9826 * Mark this field as valid
9828 markValid : function()
9830 if(!this.el || this.preventMark){ // not rendered...
9834 this.el.removeClass([this.invalidClass, this.validClass]);
9835 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9837 var feedback = this.el.select('.form-control-feedback', true).first();
9840 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9844 this.indicator.removeClass('visible');
9845 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9852 if(this.allowBlank && !this.getRawValue().length){
9855 if (Roo.bootstrap.version == 3) {
9856 this.el.addClass(this.validClass);
9858 this.inputEl().addClass('is-valid');
9861 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9863 var feedback = this.el.select('.form-control-feedback', true).first();
9866 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9867 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9872 this.fireEvent('valid', this);
9876 * Mark this field as invalid
9877 * @param {String} msg The validation message
9879 markInvalid : function(msg)
9881 if(!this.el || this.preventMark){ // not rendered
9885 this.el.removeClass([this.invalidClass, this.validClass]);
9886 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9888 var feedback = this.el.select('.form-control-feedback', true).first();
9891 this.el.select('.form-control-feedback', true).first().removeClass(
9892 [this.invalidFeedbackClass, this.validFeedbackClass]);
9899 if(this.allowBlank && !this.getRawValue().length){
9904 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9905 this.indicator.addClass('visible');
9907 if (Roo.bootstrap.version == 3) {
9908 this.el.addClass(this.invalidClass);
9910 this.inputEl().addClass('is-invalid');
9915 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9917 var feedback = this.el.select('.form-control-feedback', true).first();
9920 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9922 if(this.getValue().length || this.forceFeedback){
9923 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9930 this.fireEvent('invalid', this, msg);
9933 SafariOnKeyDown : function(event)
9935 // this is a workaround for a password hang bug on chrome/ webkit.
9936 if (this.inputEl().dom.type != 'password') {
9940 var isSelectAll = false;
9942 if(this.inputEl().dom.selectionEnd > 0){
9943 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9945 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9946 event.preventDefault();
9951 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9953 event.preventDefault();
9954 // this is very hacky as keydown always get's upper case.
9956 var cc = String.fromCharCode(event.getCharCode());
9957 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9961 adjustWidth : function(tag, w){
9962 tag = tag.toLowerCase();
9963 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9964 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9968 if(tag == 'textarea'){
9971 }else if(Roo.isOpera){
9975 if(tag == 'textarea'){
9983 setFieldLabel : function(v)
9989 if(this.indicatorEl()){
9990 var ar = this.el.select('label > span',true);
9992 if (ar.elements.length) {
9993 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9994 this.fieldLabel = v;
9998 var br = this.el.select('label',true);
10000 if(br.elements.length) {
10001 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10002 this.fieldLabel = v;
10006 Roo.log('Cannot Found any of label > span || label in input');
10010 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10011 this.fieldLabel = v;
10026 * @class Roo.bootstrap.TextArea
10027 * @extends Roo.bootstrap.Input
10028 * Bootstrap TextArea class
10029 * @cfg {Number} cols Specifies the visible width of a text area
10030 * @cfg {Number} rows Specifies the visible number of lines in a text area
10031 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10032 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10033 * @cfg {string} html text
10036 * Create a new TextArea
10037 * @param {Object} config The config object
10040 Roo.bootstrap.TextArea = function(config){
10041 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10045 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10055 getAutoCreate : function(){
10057 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10063 if(this.inputType != 'hidden'){
10064 cfg.cls = 'form-group' //input-group
10072 value : this.value || '',
10073 html: this.html || '',
10074 cls : 'form-control',
10075 placeholder : this.placeholder || ''
10079 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10080 input.maxLength = this.maxLength;
10084 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10088 input.cols = this.cols;
10091 if (this.readOnly) {
10092 input.readonly = true;
10096 input.name = this.name;
10100 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10104 ['xs','sm','md','lg'].map(function(size){
10105 if (settings[size]) {
10106 cfg.cls += ' col-' + size + '-' + settings[size];
10110 var inputblock = input;
10112 if(this.hasFeedback && !this.allowBlank){
10116 cls: 'glyphicon form-control-feedback'
10120 cls : 'has-feedback',
10129 if (this.before || this.after) {
10132 cls : 'input-group',
10136 inputblock.cn.push({
10138 cls : 'input-group-addon',
10143 inputblock.cn.push(input);
10145 if(this.hasFeedback && !this.allowBlank){
10146 inputblock.cls += ' has-feedback';
10147 inputblock.cn.push(feedback);
10151 inputblock.cn.push({
10153 cls : 'input-group-addon',
10160 if (align ==='left' && this.fieldLabel.length) {
10165 cls : 'control-label',
10166 html : this.fieldLabel
10177 if(this.labelWidth > 12){
10178 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10181 if(this.labelWidth < 13 && this.labelmd == 0){
10182 this.labelmd = this.labelWidth;
10185 if(this.labellg > 0){
10186 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10187 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10190 if(this.labelmd > 0){
10191 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10192 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10195 if(this.labelsm > 0){
10196 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10197 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10200 if(this.labelxs > 0){
10201 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10202 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10205 } else if ( this.fieldLabel.length) {
10210 //cls : 'input-group-addon',
10211 html : this.fieldLabel
10229 if (this.disabled) {
10230 input.disabled=true;
10237 * return the real textarea element.
10239 inputEl: function ()
10241 return this.el.select('textarea.form-control',true).first();
10245 * Clear any invalid styles/messages for this field
10247 clearInvalid : function()
10250 if(!this.el || this.preventMark){ // not rendered
10254 var label = this.el.select('label', true).first();
10255 var icon = this.el.select('i.fa-star', true).first();
10260 this.el.removeClass( this.validClass);
10261 this.inputEl().removeClass('is-invalid');
10263 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10265 var feedback = this.el.select('.form-control-feedback', true).first();
10268 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10273 this.fireEvent('valid', this);
10277 * Mark this field as valid
10279 markValid : function()
10281 if(!this.el || this.preventMark){ // not rendered
10285 this.el.removeClass([this.invalidClass, this.validClass]);
10286 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10288 var feedback = this.el.select('.form-control-feedback', true).first();
10291 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10294 if(this.disabled || this.allowBlank){
10298 var label = this.el.select('label', true).first();
10299 var icon = this.el.select('i.fa-star', true).first();
10304 if (Roo.bootstrap.version == 3) {
10305 this.el.addClass(this.validClass);
10307 this.inputEl().addClass('is-valid');
10311 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10313 var feedback = this.el.select('.form-control-feedback', true).first();
10316 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10317 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10322 this.fireEvent('valid', this);
10326 * Mark this field as invalid
10327 * @param {String} msg The validation message
10329 markInvalid : function(msg)
10331 if(!this.el || this.preventMark){ // not rendered
10335 this.el.removeClass([this.invalidClass, this.validClass]);
10336 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10338 var feedback = this.el.select('.form-control-feedback', true).first();
10341 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10344 if(this.disabled || this.allowBlank){
10348 var label = this.el.select('label', true).first();
10349 var icon = this.el.select('i.fa-star', true).first();
10351 if(!this.getValue().length && label && !icon){
10352 this.el.createChild({
10354 cls : 'text-danger fa fa-lg fa-star',
10355 tooltip : 'This field is required',
10356 style : 'margin-right:5px;'
10360 if (Roo.bootstrap.version == 3) {
10361 this.el.addClass(this.invalidClass);
10363 this.inputEl().addClass('is-invalid');
10366 // fixme ... this may be depricated need to test..
10367 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10369 var feedback = this.el.select('.form-control-feedback', true).first();
10372 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10374 if(this.getValue().length || this.forceFeedback){
10375 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10382 this.fireEvent('invalid', this, msg);
10390 * trigger field - base class for combo..
10395 * @class Roo.bootstrap.TriggerField
10396 * @extends Roo.bootstrap.Input
10397 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10398 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10399 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10400 * for which you can provide a custom implementation. For example:
10402 var trigger = new Roo.bootstrap.TriggerField();
10403 trigger.onTriggerClick = myTriggerFn;
10404 trigger.applyTo('my-field');
10407 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10408 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10409 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10410 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10411 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10414 * Create a new TriggerField.
10415 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10416 * to the base TextField)
10418 Roo.bootstrap.TriggerField = function(config){
10419 this.mimicing = false;
10420 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10423 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10425 * @cfg {String} triggerClass A CSS class to apply to the trigger
10428 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10433 * @cfg {Boolean} removable (true|false) special filter default false
10437 /** @cfg {Boolean} grow @hide */
10438 /** @cfg {Number} growMin @hide */
10439 /** @cfg {Number} growMax @hide */
10445 autoSize: Roo.emptyFn,
10449 deferHeight : true,
10452 actionMode : 'wrap',
10457 getAutoCreate : function(){
10459 var align = this.labelAlign || this.parentLabelAlign();
10464 cls: 'form-group' //input-group
10471 type : this.inputType,
10472 cls : 'form-control',
10473 autocomplete: 'new-password',
10474 placeholder : this.placeholder || ''
10478 input.name = this.name;
10481 input.cls += ' input-' + this.size;
10484 if (this.disabled) {
10485 input.disabled=true;
10488 var inputblock = input;
10490 if(this.hasFeedback && !this.allowBlank){
10494 cls: 'glyphicon form-control-feedback'
10497 if(this.removable && !this.editable && !this.tickable){
10499 cls : 'has-feedback',
10505 cls : 'roo-combo-removable-btn close'
10512 cls : 'has-feedback',
10521 if(this.removable && !this.editable && !this.tickable){
10523 cls : 'roo-removable',
10529 cls : 'roo-combo-removable-btn close'
10536 if (this.before || this.after) {
10539 cls : 'input-group',
10543 inputblock.cn.push({
10545 cls : 'input-group-addon input-group-prepend input-group-text',
10550 inputblock.cn.push(input);
10552 if(this.hasFeedback && !this.allowBlank){
10553 inputblock.cls += ' has-feedback';
10554 inputblock.cn.push(feedback);
10558 inputblock.cn.push({
10560 cls : 'input-group-addon input-group-append input-group-text',
10569 var ibwrap = inputblock;
10574 cls: 'roo-select2-choices',
10578 cls: 'roo-select2-search-field',
10590 cls: 'roo-select2-container input-group',
10595 cls: 'form-hidden-field'
10601 if(!this.multiple && this.showToggleBtn){
10607 if (this.caret != false) {
10610 cls: 'fa fa-' + this.caret
10617 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10622 cls: 'combobox-clear',
10636 combobox.cls += ' roo-select2-container-multi';
10640 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10641 tooltip : 'This field is required'
10643 if (Roo.bootstrap.version == 4) {
10646 style : 'display:none'
10651 if (align ==='left' && this.fieldLabel.length) {
10653 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10660 cls : 'control-label',
10661 html : this.fieldLabel
10673 var labelCfg = cfg.cn[1];
10674 var contentCfg = cfg.cn[2];
10676 if(this.indicatorpos == 'right'){
10681 cls : 'control-label',
10685 html : this.fieldLabel
10699 labelCfg = cfg.cn[0];
10700 contentCfg = cfg.cn[1];
10703 if(this.labelWidth > 12){
10704 labelCfg.style = "width: " + this.labelWidth + 'px';
10707 if(this.labelWidth < 13 && this.labelmd == 0){
10708 this.labelmd = this.labelWidth;
10711 if(this.labellg > 0){
10712 labelCfg.cls += ' col-lg-' + this.labellg;
10713 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10716 if(this.labelmd > 0){
10717 labelCfg.cls += ' col-md-' + this.labelmd;
10718 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10721 if(this.labelsm > 0){
10722 labelCfg.cls += ' col-sm-' + this.labelsm;
10723 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10726 if(this.labelxs > 0){
10727 labelCfg.cls += ' col-xs-' + this.labelxs;
10728 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10731 } else if ( this.fieldLabel.length) {
10732 // Roo.log(" label");
10737 //cls : 'input-group-addon',
10738 html : this.fieldLabel
10746 if(this.indicatorpos == 'right'){
10754 html : this.fieldLabel
10768 // Roo.log(" no label && no align");
10775 ['xs','sm','md','lg'].map(function(size){
10776 if (settings[size]) {
10777 cfg.cls += ' col-' + size + '-' + settings[size];
10788 onResize : function(w, h){
10789 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10790 // if(typeof w == 'number'){
10791 // var x = w - this.trigger.getWidth();
10792 // this.inputEl().setWidth(this.adjustWidth('input', x));
10793 // this.trigger.setStyle('left', x+'px');
10798 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10801 getResizeEl : function(){
10802 return this.inputEl();
10806 getPositionEl : function(){
10807 return this.inputEl();
10811 alignErrorIcon : function(){
10812 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10816 initEvents : function(){
10820 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10821 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10822 if(!this.multiple && this.showToggleBtn){
10823 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10824 if(this.hideTrigger){
10825 this.trigger.setDisplayed(false);
10827 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10831 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10834 if(this.removable && !this.editable && !this.tickable){
10835 var close = this.closeTriggerEl();
10838 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10839 close.on('click', this.removeBtnClick, this, close);
10843 //this.trigger.addClassOnOver('x-form-trigger-over');
10844 //this.trigger.addClassOnClick('x-form-trigger-click');
10847 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10851 closeTriggerEl : function()
10853 var close = this.el.select('.roo-combo-removable-btn', true).first();
10854 return close ? close : false;
10857 removeBtnClick : function(e, h, el)
10859 e.preventDefault();
10861 if(this.fireEvent("remove", this) !== false){
10863 this.fireEvent("afterremove", this)
10867 createList : function()
10869 this.list = Roo.get(document.body).createChild({
10870 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10871 cls: 'typeahead typeahead-long dropdown-menu',
10872 style: 'display:none'
10875 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10880 initTrigger : function(){
10885 onDestroy : function(){
10887 this.trigger.removeAllListeners();
10888 // this.trigger.remove();
10891 // this.wrap.remove();
10893 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10897 onFocus : function(){
10898 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10900 if(!this.mimicing){
10901 this.wrap.addClass('x-trigger-wrap-focus');
10902 this.mimicing = true;
10903 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10904 if(this.monitorTab){
10905 this.el.on("keydown", this.checkTab, this);
10912 checkTab : function(e){
10913 if(e.getKey() == e.TAB){
10914 this.triggerBlur();
10919 onBlur : function(){
10924 mimicBlur : function(e, t){
10926 if(!this.wrap.contains(t) && this.validateBlur()){
10927 this.triggerBlur();
10933 triggerBlur : function(){
10934 this.mimicing = false;
10935 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10936 if(this.monitorTab){
10937 this.el.un("keydown", this.checkTab, this);
10939 //this.wrap.removeClass('x-trigger-wrap-focus');
10940 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10944 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10945 validateBlur : function(e, t){
10950 onDisable : function(){
10951 this.inputEl().dom.disabled = true;
10952 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10954 // this.wrap.addClass('x-item-disabled');
10959 onEnable : function(){
10960 this.inputEl().dom.disabled = false;
10961 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10963 // this.el.removeClass('x-item-disabled');
10968 onShow : function(){
10969 var ae = this.getActionEl();
10972 ae.dom.style.display = '';
10973 ae.dom.style.visibility = 'visible';
10979 onHide : function(){
10980 var ae = this.getActionEl();
10981 ae.dom.style.display = 'none';
10985 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10986 * by an implementing function.
10988 * @param {EventObject} e
10990 onTriggerClick : Roo.emptyFn
10994 * Ext JS Library 1.1.1
10995 * Copyright(c) 2006-2007, Ext JS, LLC.
10997 * Originally Released Under LGPL - original licence link has changed is not relivant.
11000 * <script type="text/javascript">
11005 * @class Roo.data.SortTypes
11007 * Defines the default sorting (casting?) comparison functions used when sorting data.
11009 Roo.data.SortTypes = {
11011 * Default sort that does nothing
11012 * @param {Mixed} s The value being converted
11013 * @return {Mixed} The comparison value
11015 none : function(s){
11020 * The regular expression used to strip tags
11024 stripTagsRE : /<\/?[^>]+>/gi,
11027 * Strips all HTML tags to sort on text only
11028 * @param {Mixed} s The value being converted
11029 * @return {String} The comparison value
11031 asText : function(s){
11032 return String(s).replace(this.stripTagsRE, "");
11036 * Strips all HTML tags to sort on text only - Case insensitive
11037 * @param {Mixed} s The value being converted
11038 * @return {String} The comparison value
11040 asUCText : function(s){
11041 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11045 * Case insensitive string
11046 * @param {Mixed} s The value being converted
11047 * @return {String} The comparison value
11049 asUCString : function(s) {
11050 return String(s).toUpperCase();
11055 * @param {Mixed} s The value being converted
11056 * @return {Number} The comparison value
11058 asDate : function(s) {
11062 if(s instanceof Date){
11063 return s.getTime();
11065 return Date.parse(String(s));
11070 * @param {Mixed} s The value being converted
11071 * @return {Float} The comparison value
11073 asFloat : function(s) {
11074 var val = parseFloat(String(s).replace(/,/g, ""));
11083 * @param {Mixed} s The value being converted
11084 * @return {Number} The comparison value
11086 asInt : function(s) {
11087 var val = parseInt(String(s).replace(/,/g, ""));
11095 * Ext JS Library 1.1.1
11096 * Copyright(c) 2006-2007, Ext JS, LLC.
11098 * Originally Released Under LGPL - original licence link has changed is not relivant.
11101 * <script type="text/javascript">
11105 * @class Roo.data.Record
11106 * Instances of this class encapsulate both record <em>definition</em> information, and record
11107 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11108 * to access Records cached in an {@link Roo.data.Store} object.<br>
11110 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11111 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11114 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11116 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11117 * {@link #create}. The parameters are the same.
11118 * @param {Array} data An associative Array of data values keyed by the field name.
11119 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11120 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11121 * not specified an integer id is generated.
11123 Roo.data.Record = function(data, id){
11124 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11129 * Generate a constructor for a specific record layout.
11130 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11131 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11132 * Each field definition object may contain the following properties: <ul>
11133 * <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,
11134 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11135 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11136 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11137 * is being used, then this is a string containing the javascript expression to reference the data relative to
11138 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11139 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11140 * this may be omitted.</p></li>
11141 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11142 * <ul><li>auto (Default, implies no conversion)</li>
11147 * <li>date</li></ul></p></li>
11148 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11149 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11150 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11151 * by the Reader into an object that will be stored in the Record. It is passed the
11152 * following parameters:<ul>
11153 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11155 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11157 * <br>usage:<br><pre><code>
11158 var TopicRecord = Roo.data.Record.create(
11159 {name: 'title', mapping: 'topic_title'},
11160 {name: 'author', mapping: 'username'},
11161 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11162 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11163 {name: 'lastPoster', mapping: 'user2'},
11164 {name: 'excerpt', mapping: 'post_text'}
11167 var myNewRecord = new TopicRecord({
11168 title: 'Do my job please',
11171 lastPost: new Date(),
11172 lastPoster: 'Animal',
11173 excerpt: 'No way dude!'
11175 myStore.add(myNewRecord);
11180 Roo.data.Record.create = function(o){
11181 var f = function(){
11182 f.superclass.constructor.apply(this, arguments);
11184 Roo.extend(f, Roo.data.Record);
11185 var p = f.prototype;
11186 p.fields = new Roo.util.MixedCollection(false, function(field){
11189 for(var i = 0, len = o.length; i < len; i++){
11190 p.fields.add(new Roo.data.Field(o[i]));
11192 f.getField = function(name){
11193 return p.fields.get(name);
11198 Roo.data.Record.AUTO_ID = 1000;
11199 Roo.data.Record.EDIT = 'edit';
11200 Roo.data.Record.REJECT = 'reject';
11201 Roo.data.Record.COMMIT = 'commit';
11203 Roo.data.Record.prototype = {
11205 * Readonly flag - true if this record has been modified.
11214 join : function(store){
11215 this.store = store;
11219 * Set the named field to the specified value.
11220 * @param {String} name The name of the field to set.
11221 * @param {Object} value The value to set the field to.
11223 set : function(name, value){
11224 if(this.data[name] == value){
11228 if(!this.modified){
11229 this.modified = {};
11231 if(typeof this.modified[name] == 'undefined'){
11232 this.modified[name] = this.data[name];
11234 this.data[name] = value;
11235 if(!this.editing && this.store){
11236 this.store.afterEdit(this);
11241 * Get the value of the named field.
11242 * @param {String} name The name of the field to get the value of.
11243 * @return {Object} The value of the field.
11245 get : function(name){
11246 return this.data[name];
11250 beginEdit : function(){
11251 this.editing = true;
11252 this.modified = {};
11256 cancelEdit : function(){
11257 this.editing = false;
11258 delete this.modified;
11262 endEdit : function(){
11263 this.editing = false;
11264 if(this.dirty && this.store){
11265 this.store.afterEdit(this);
11270 * Usually called by the {@link Roo.data.Store} which owns the Record.
11271 * Rejects all changes made to the Record since either creation, or the last commit operation.
11272 * Modified fields are reverted to their original values.
11274 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11275 * of reject operations.
11277 reject : function(){
11278 var m = this.modified;
11280 if(typeof m[n] != "function"){
11281 this.data[n] = m[n];
11284 this.dirty = false;
11285 delete this.modified;
11286 this.editing = false;
11288 this.store.afterReject(this);
11293 * Usually called by the {@link Roo.data.Store} which owns the Record.
11294 * Commits all changes made to the Record since either creation, or the last commit operation.
11296 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11297 * of commit operations.
11299 commit : function(){
11300 this.dirty = false;
11301 delete this.modified;
11302 this.editing = false;
11304 this.store.afterCommit(this);
11309 hasError : function(){
11310 return this.error != null;
11314 clearError : function(){
11319 * Creates a copy of this record.
11320 * @param {String} id (optional) A new record id if you don't want to use this record's id
11323 copy : function(newId) {
11324 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11328 * Ext JS Library 1.1.1
11329 * Copyright(c) 2006-2007, Ext JS, LLC.
11331 * Originally Released Under LGPL - original licence link has changed is not relivant.
11334 * <script type="text/javascript">
11340 * @class Roo.data.Store
11341 * @extends Roo.util.Observable
11342 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11343 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11345 * 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
11346 * has no knowledge of the format of the data returned by the Proxy.<br>
11348 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11349 * instances from the data object. These records are cached and made available through accessor functions.
11351 * Creates a new Store.
11352 * @param {Object} config A config object containing the objects needed for the Store to access data,
11353 * and read the data into Records.
11355 Roo.data.Store = function(config){
11356 this.data = new Roo.util.MixedCollection(false);
11357 this.data.getKey = function(o){
11360 this.baseParams = {};
11362 this.paramNames = {
11367 "multisort" : "_multisort"
11370 if(config && config.data){
11371 this.inlineData = config.data;
11372 delete config.data;
11375 Roo.apply(this, config);
11377 if(this.reader){ // reader passed
11378 this.reader = Roo.factory(this.reader, Roo.data);
11379 this.reader.xmodule = this.xmodule || false;
11380 if(!this.recordType){
11381 this.recordType = this.reader.recordType;
11383 if(this.reader.onMetaChange){
11384 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11388 if(this.recordType){
11389 this.fields = this.recordType.prototype.fields;
11391 this.modified = [];
11395 * @event datachanged
11396 * Fires when the data cache has changed, and a widget which is using this Store
11397 * as a Record cache should refresh its view.
11398 * @param {Store} this
11400 datachanged : true,
11402 * @event metachange
11403 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11404 * @param {Store} this
11405 * @param {Object} meta The JSON metadata
11410 * Fires when Records have been added to the Store
11411 * @param {Store} this
11412 * @param {Roo.data.Record[]} records The array of Records added
11413 * @param {Number} index The index at which the record(s) were added
11418 * Fires when a Record has been removed from the Store
11419 * @param {Store} this
11420 * @param {Roo.data.Record} record The Record that was removed
11421 * @param {Number} index The index at which the record was removed
11426 * Fires when a Record has been updated
11427 * @param {Store} this
11428 * @param {Roo.data.Record} record The Record that was updated
11429 * @param {String} operation The update operation being performed. Value may be one of:
11431 Roo.data.Record.EDIT
11432 Roo.data.Record.REJECT
11433 Roo.data.Record.COMMIT
11439 * Fires when the data cache has been cleared.
11440 * @param {Store} this
11444 * @event beforeload
11445 * Fires before a request is made for a new data object. If the beforeload handler returns false
11446 * the load action will be canceled.
11447 * @param {Store} this
11448 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11452 * @event beforeloadadd
11453 * Fires after a new set of Records has been loaded.
11454 * @param {Store} this
11455 * @param {Roo.data.Record[]} records The Records that were loaded
11456 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11458 beforeloadadd : true,
11461 * Fires after a new set of Records has been loaded, before they are added to the store.
11462 * @param {Store} this
11463 * @param {Roo.data.Record[]} records The Records that were loaded
11464 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11465 * @params {Object} return from reader
11469 * @event loadexception
11470 * Fires if an exception occurs in the Proxy during loading.
11471 * Called with the signature of the Proxy's "loadexception" event.
11472 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11475 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11476 * @param {Object} load options
11477 * @param {Object} jsonData from your request (normally this contains the Exception)
11479 loadexception : true
11483 this.proxy = Roo.factory(this.proxy, Roo.data);
11484 this.proxy.xmodule = this.xmodule || false;
11485 this.relayEvents(this.proxy, ["loadexception"]);
11487 this.sortToggle = {};
11488 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11490 Roo.data.Store.superclass.constructor.call(this);
11492 if(this.inlineData){
11493 this.loadData(this.inlineData);
11494 delete this.inlineData;
11498 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11500 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11501 * without a remote query - used by combo/forms at present.
11505 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11508 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11511 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11512 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11515 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11516 * on any HTTP request
11519 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11522 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11526 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11527 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11529 remoteSort : false,
11532 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11533 * loaded or when a record is removed. (defaults to false).
11535 pruneModifiedRecords : false,
11538 lastOptions : null,
11541 * Add Records to the Store and fires the add event.
11542 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11544 add : function(records){
11545 records = [].concat(records);
11546 for(var i = 0, len = records.length; i < len; i++){
11547 records[i].join(this);
11549 var index = this.data.length;
11550 this.data.addAll(records);
11551 this.fireEvent("add", this, records, index);
11555 * Remove a Record from the Store and fires the remove event.
11556 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11558 remove : function(record){
11559 var index = this.data.indexOf(record);
11560 this.data.removeAt(index);
11562 if(this.pruneModifiedRecords){
11563 this.modified.remove(record);
11565 this.fireEvent("remove", this, record, index);
11569 * Remove all Records from the Store and fires the clear event.
11571 removeAll : function(){
11573 if(this.pruneModifiedRecords){
11574 this.modified = [];
11576 this.fireEvent("clear", this);
11580 * Inserts Records to the Store at the given index and fires the add event.
11581 * @param {Number} index The start index at which to insert the passed Records.
11582 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11584 insert : function(index, records){
11585 records = [].concat(records);
11586 for(var i = 0, len = records.length; i < len; i++){
11587 this.data.insert(index, records[i]);
11588 records[i].join(this);
11590 this.fireEvent("add", this, records, index);
11594 * Get the index within the cache of the passed Record.
11595 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11596 * @return {Number} The index of the passed Record. Returns -1 if not found.
11598 indexOf : function(record){
11599 return this.data.indexOf(record);
11603 * Get the index within the cache of the Record with the passed id.
11604 * @param {String} id The id of the Record to find.
11605 * @return {Number} The index of the Record. Returns -1 if not found.
11607 indexOfId : function(id){
11608 return this.data.indexOfKey(id);
11612 * Get the Record with the specified id.
11613 * @param {String} id The id of the Record to find.
11614 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11616 getById : function(id){
11617 return this.data.key(id);
11621 * Get the Record at the specified index.
11622 * @param {Number} index The index of the Record to find.
11623 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11625 getAt : function(index){
11626 return this.data.itemAt(index);
11630 * Returns a range of Records between specified indices.
11631 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11632 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11633 * @return {Roo.data.Record[]} An array of Records
11635 getRange : function(start, end){
11636 return this.data.getRange(start, end);
11640 storeOptions : function(o){
11641 o = Roo.apply({}, o);
11644 this.lastOptions = o;
11648 * Loads the Record cache from the configured Proxy using the configured Reader.
11650 * If using remote paging, then the first load call must specify the <em>start</em>
11651 * and <em>limit</em> properties in the options.params property to establish the initial
11652 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11654 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11655 * and this call will return before the new data has been loaded. Perform any post-processing
11656 * in a callback function, or in a "load" event handler.</strong>
11658 * @param {Object} options An object containing properties which control loading options:<ul>
11659 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11660 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11661 * passed the following arguments:<ul>
11662 * <li>r : Roo.data.Record[]</li>
11663 * <li>options: Options object from the load call</li>
11664 * <li>success: Boolean success indicator</li></ul></li>
11665 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11666 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11669 load : function(options){
11670 options = options || {};
11671 if(this.fireEvent("beforeload", this, options) !== false){
11672 this.storeOptions(options);
11673 var p = Roo.apply(options.params || {}, this.baseParams);
11674 // if meta was not loaded from remote source.. try requesting it.
11675 if (!this.reader.metaFromRemote) {
11676 p._requestMeta = 1;
11678 if(this.sortInfo && this.remoteSort){
11679 var pn = this.paramNames;
11680 p[pn["sort"]] = this.sortInfo.field;
11681 p[pn["dir"]] = this.sortInfo.direction;
11683 if (this.multiSort) {
11684 var pn = this.paramNames;
11685 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11688 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11693 * Reloads the Record cache from the configured Proxy using the configured Reader and
11694 * the options from the last load operation performed.
11695 * @param {Object} options (optional) An object containing properties which may override the options
11696 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11697 * the most recently used options are reused).
11699 reload : function(options){
11700 this.load(Roo.applyIf(options||{}, this.lastOptions));
11704 // Called as a callback by the Reader during a load operation.
11705 loadRecords : function(o, options, success){
11706 if(!o || success === false){
11707 if(success !== false){
11708 this.fireEvent("load", this, [], options, o);
11710 if(options.callback){
11711 options.callback.call(options.scope || this, [], options, false);
11715 // if data returned failure - throw an exception.
11716 if (o.success === false) {
11717 // show a message if no listener is registered.
11718 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11719 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11721 // loadmask wil be hooked into this..
11722 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11725 var r = o.records, t = o.totalRecords || r.length;
11727 this.fireEvent("beforeloadadd", this, r, options, o);
11729 if(!options || options.add !== true){
11730 if(this.pruneModifiedRecords){
11731 this.modified = [];
11733 for(var i = 0, len = r.length; i < len; i++){
11737 this.data = this.snapshot;
11738 delete this.snapshot;
11741 this.data.addAll(r);
11742 this.totalLength = t;
11744 this.fireEvent("datachanged", this);
11746 this.totalLength = Math.max(t, this.data.length+r.length);
11750 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11752 var e = new Roo.data.Record({});
11754 e.set(this.parent.displayField, this.parent.emptyTitle);
11755 e.set(this.parent.valueField, '');
11760 this.fireEvent("load", this, r, options, o);
11761 if(options.callback){
11762 options.callback.call(options.scope || this, r, options, true);
11768 * Loads data from a passed data block. A Reader which understands the format of the data
11769 * must have been configured in the constructor.
11770 * @param {Object} data The data block from which to read the Records. The format of the data expected
11771 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11772 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11774 loadData : function(o, append){
11775 var r = this.reader.readRecords(o);
11776 this.loadRecords(r, {add: append}, true);
11780 * Gets the number of cached records.
11782 * <em>If using paging, this may not be the total size of the dataset. If the data object
11783 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11784 * the data set size</em>
11786 getCount : function(){
11787 return this.data.length || 0;
11791 * Gets the total number of records in the dataset as returned by the server.
11793 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11794 * the dataset size</em>
11796 getTotalCount : function(){
11797 return this.totalLength || 0;
11801 * Returns the sort state of the Store as an object with two properties:
11803 field {String} The name of the field by which the Records are sorted
11804 direction {String} The sort order, "ASC" or "DESC"
11807 getSortState : function(){
11808 return this.sortInfo;
11812 applySort : function(){
11813 if(this.sortInfo && !this.remoteSort){
11814 var s = this.sortInfo, f = s.field;
11815 var st = this.fields.get(f).sortType;
11816 var fn = function(r1, r2){
11817 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11818 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11820 this.data.sort(s.direction, fn);
11821 if(this.snapshot && this.snapshot != this.data){
11822 this.snapshot.sort(s.direction, fn);
11828 * Sets the default sort column and order to be used by the next load operation.
11829 * @param {String} fieldName The name of the field to sort by.
11830 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11832 setDefaultSort : function(field, dir){
11833 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11837 * Sort the Records.
11838 * If remote sorting is used, the sort is performed on the server, and the cache is
11839 * reloaded. If local sorting is used, the cache is sorted internally.
11840 * @param {String} fieldName The name of the field to sort by.
11841 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11843 sort : function(fieldName, dir){
11844 var f = this.fields.get(fieldName);
11846 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11848 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11849 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11854 this.sortToggle[f.name] = dir;
11855 this.sortInfo = {field: f.name, direction: dir};
11856 if(!this.remoteSort){
11858 this.fireEvent("datachanged", this);
11860 this.load(this.lastOptions);
11865 * Calls the specified function for each of the Records in the cache.
11866 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11867 * Returning <em>false</em> aborts and exits the iteration.
11868 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11870 each : function(fn, scope){
11871 this.data.each(fn, scope);
11875 * Gets all records modified since the last commit. Modified records are persisted across load operations
11876 * (e.g., during paging).
11877 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11879 getModifiedRecords : function(){
11880 return this.modified;
11884 createFilterFn : function(property, value, anyMatch){
11885 if(!value.exec){ // not a regex
11886 value = String(value);
11887 if(value.length == 0){
11890 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11892 return function(r){
11893 return value.test(r.data[property]);
11898 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11899 * @param {String} property A field on your records
11900 * @param {Number} start The record index to start at (defaults to 0)
11901 * @param {Number} end The last record index to include (defaults to length - 1)
11902 * @return {Number} The sum
11904 sum : function(property, start, end){
11905 var rs = this.data.items, v = 0;
11906 start = start || 0;
11907 end = (end || end === 0) ? end : rs.length-1;
11909 for(var i = start; i <= end; i++){
11910 v += (rs[i].data[property] || 0);
11916 * Filter the records by a specified property.
11917 * @param {String} field A field on your records
11918 * @param {String/RegExp} value Either a string that the field
11919 * should start with or a RegExp to test against the field
11920 * @param {Boolean} anyMatch True to match any part not just the beginning
11922 filter : function(property, value, anyMatch){
11923 var fn = this.createFilterFn(property, value, anyMatch);
11924 return fn ? this.filterBy(fn) : this.clearFilter();
11928 * Filter by a function. The specified function will be called with each
11929 * record in this data source. If the function returns true the record is included,
11930 * otherwise it is filtered.
11931 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11932 * @param {Object} scope (optional) The scope of the function (defaults to this)
11934 filterBy : function(fn, scope){
11935 this.snapshot = this.snapshot || this.data;
11936 this.data = this.queryBy(fn, scope||this);
11937 this.fireEvent("datachanged", this);
11941 * Query the records by a specified property.
11942 * @param {String} field A field on your records
11943 * @param {String/RegExp} value Either a string that the field
11944 * should start with or a RegExp to test against the field
11945 * @param {Boolean} anyMatch True to match any part not just the beginning
11946 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11948 query : function(property, value, anyMatch){
11949 var fn = this.createFilterFn(property, value, anyMatch);
11950 return fn ? this.queryBy(fn) : this.data.clone();
11954 * Query by a function. The specified function will be called with each
11955 * record in this data source. If the function returns true the record is included
11957 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11958 * @param {Object} scope (optional) The scope of the function (defaults to this)
11959 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11961 queryBy : function(fn, scope){
11962 var data = this.snapshot || this.data;
11963 return data.filterBy(fn, scope||this);
11967 * Collects unique values for a particular dataIndex from this store.
11968 * @param {String} dataIndex The property to collect
11969 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11970 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11971 * @return {Array} An array of the unique values
11973 collect : function(dataIndex, allowNull, bypassFilter){
11974 var d = (bypassFilter === true && this.snapshot) ?
11975 this.snapshot.items : this.data.items;
11976 var v, sv, r = [], l = {};
11977 for(var i = 0, len = d.length; i < len; i++){
11978 v = d[i].data[dataIndex];
11980 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11989 * Revert to a view of the Record cache with no filtering applied.
11990 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11992 clearFilter : function(suppressEvent){
11993 if(this.snapshot && this.snapshot != this.data){
11994 this.data = this.snapshot;
11995 delete this.snapshot;
11996 if(suppressEvent !== true){
11997 this.fireEvent("datachanged", this);
12003 afterEdit : function(record){
12004 if(this.modified.indexOf(record) == -1){
12005 this.modified.push(record);
12007 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12011 afterReject : function(record){
12012 this.modified.remove(record);
12013 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12017 afterCommit : function(record){
12018 this.modified.remove(record);
12019 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12023 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12024 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12026 commitChanges : function(){
12027 var m = this.modified.slice(0);
12028 this.modified = [];
12029 for(var i = 0, len = m.length; i < len; i++){
12035 * Cancel outstanding changes on all changed records.
12037 rejectChanges : function(){
12038 var m = this.modified.slice(0);
12039 this.modified = [];
12040 for(var i = 0, len = m.length; i < len; i++){
12045 onMetaChange : function(meta, rtype, o){
12046 this.recordType = rtype;
12047 this.fields = rtype.prototype.fields;
12048 delete this.snapshot;
12049 this.sortInfo = meta.sortInfo || this.sortInfo;
12050 this.modified = [];
12051 this.fireEvent('metachange', this, this.reader.meta);
12054 moveIndex : function(data, type)
12056 var index = this.indexOf(data);
12058 var newIndex = index + type;
12062 this.insert(newIndex, data);
12067 * Ext JS Library 1.1.1
12068 * Copyright(c) 2006-2007, Ext JS, LLC.
12070 * Originally Released Under LGPL - original licence link has changed is not relivant.
12073 * <script type="text/javascript">
12077 * @class Roo.data.SimpleStore
12078 * @extends Roo.data.Store
12079 * Small helper class to make creating Stores from Array data easier.
12080 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12081 * @cfg {Array} fields An array of field definition objects, or field name strings.
12082 * @cfg {Array} data The multi-dimensional array of data
12084 * @param {Object} config
12086 Roo.data.SimpleStore = function(config){
12087 Roo.data.SimpleStore.superclass.constructor.call(this, {
12089 reader: new Roo.data.ArrayReader({
12092 Roo.data.Record.create(config.fields)
12094 proxy : new Roo.data.MemoryProxy(config.data)
12098 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12100 * Ext JS Library 1.1.1
12101 * Copyright(c) 2006-2007, Ext JS, LLC.
12103 * Originally Released Under LGPL - original licence link has changed is not relivant.
12106 * <script type="text/javascript">
12111 * @extends Roo.data.Store
12112 * @class Roo.data.JsonStore
12113 * Small helper class to make creating Stores for JSON data easier. <br/>
12115 var store = new Roo.data.JsonStore({
12116 url: 'get-images.php',
12118 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12121 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12122 * JsonReader and HttpProxy (unless inline data is provided).</b>
12123 * @cfg {Array} fields An array of field definition objects, or field name strings.
12125 * @param {Object} config
12127 Roo.data.JsonStore = function(c){
12128 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12129 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12130 reader: new Roo.data.JsonReader(c, c.fields)
12133 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12135 * Ext JS Library 1.1.1
12136 * Copyright(c) 2006-2007, Ext JS, LLC.
12138 * Originally Released Under LGPL - original licence link has changed is not relivant.
12141 * <script type="text/javascript">
12145 Roo.data.Field = function(config){
12146 if(typeof config == "string"){
12147 config = {name: config};
12149 Roo.apply(this, config);
12152 this.type = "auto";
12155 var st = Roo.data.SortTypes;
12156 // named sortTypes are supported, here we look them up
12157 if(typeof this.sortType == "string"){
12158 this.sortType = st[this.sortType];
12161 // set default sortType for strings and dates
12162 if(!this.sortType){
12165 this.sortType = st.asUCString;
12168 this.sortType = st.asDate;
12171 this.sortType = st.none;
12176 var stripRe = /[\$,%]/g;
12178 // prebuilt conversion function for this field, instead of
12179 // switching every time we're reading a value
12181 var cv, dateFormat = this.dateFormat;
12186 cv = function(v){ return v; };
12189 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12193 return v !== undefined && v !== null && v !== '' ?
12194 parseInt(String(v).replace(stripRe, ""), 10) : '';
12199 return v !== undefined && v !== null && v !== '' ?
12200 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12205 cv = function(v){ return v === true || v === "true" || v == 1; };
12212 if(v instanceof Date){
12216 if(dateFormat == "timestamp"){
12217 return new Date(v*1000);
12219 return Date.parseDate(v, dateFormat);
12221 var parsed = Date.parse(v);
12222 return parsed ? new Date(parsed) : null;
12231 Roo.data.Field.prototype = {
12239 * Ext JS Library 1.1.1
12240 * Copyright(c) 2006-2007, Ext JS, LLC.
12242 * Originally Released Under LGPL - original licence link has changed is not relivant.
12245 * <script type="text/javascript">
12248 // Base class for reading structured data from a data source. This class is intended to be
12249 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12252 * @class Roo.data.DataReader
12253 * Base class for reading structured data from a data source. This class is intended to be
12254 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12257 Roo.data.DataReader = function(meta, recordType){
12261 this.recordType = recordType instanceof Array ?
12262 Roo.data.Record.create(recordType) : recordType;
12265 Roo.data.DataReader.prototype = {
12267 * Create an empty record
12268 * @param {Object} data (optional) - overlay some values
12269 * @return {Roo.data.Record} record created.
12271 newRow : function(d) {
12273 this.recordType.prototype.fields.each(function(c) {
12275 case 'int' : da[c.name] = 0; break;
12276 case 'date' : da[c.name] = new Date(); break;
12277 case 'float' : da[c.name] = 0.0; break;
12278 case 'boolean' : da[c.name] = false; break;
12279 default : da[c.name] = ""; break;
12283 return new this.recordType(Roo.apply(da, d));
12288 * Ext JS Library 1.1.1
12289 * Copyright(c) 2006-2007, Ext JS, LLC.
12291 * Originally Released Under LGPL - original licence link has changed is not relivant.
12294 * <script type="text/javascript">
12298 * @class Roo.data.DataProxy
12299 * @extends Roo.data.Observable
12300 * This class is an abstract base class for implementations which provide retrieval of
12301 * unformatted data objects.<br>
12303 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12304 * (of the appropriate type which knows how to parse the data object) to provide a block of
12305 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12307 * Custom implementations must implement the load method as described in
12308 * {@link Roo.data.HttpProxy#load}.
12310 Roo.data.DataProxy = function(){
12313 * @event beforeload
12314 * Fires before a network request is made to retrieve a data object.
12315 * @param {Object} This DataProxy object.
12316 * @param {Object} params The params parameter to the load function.
12321 * Fires before the load method's callback is called.
12322 * @param {Object} This DataProxy object.
12323 * @param {Object} o The data object.
12324 * @param {Object} arg The callback argument object passed to the load function.
12328 * @event loadexception
12329 * Fires if an Exception occurs during data retrieval.
12330 * @param {Object} This DataProxy object.
12331 * @param {Object} o The data object.
12332 * @param {Object} arg The callback argument object passed to the load function.
12333 * @param {Object} e The Exception.
12335 loadexception : true
12337 Roo.data.DataProxy.superclass.constructor.call(this);
12340 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12343 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12347 * Ext JS Library 1.1.1
12348 * Copyright(c) 2006-2007, Ext JS, LLC.
12350 * Originally Released Under LGPL - original licence link has changed is not relivant.
12353 * <script type="text/javascript">
12356 * @class Roo.data.MemoryProxy
12357 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12358 * to the Reader when its load method is called.
12360 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12362 Roo.data.MemoryProxy = function(data){
12366 Roo.data.MemoryProxy.superclass.constructor.call(this);
12370 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12373 * Load data from the requested source (in this case an in-memory
12374 * data object passed to the constructor), read the data object into
12375 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12376 * process that block using the passed callback.
12377 * @param {Object} params This parameter is not used by the MemoryProxy class.
12378 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12379 * object into a block of Roo.data.Records.
12380 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12381 * The function must be passed <ul>
12382 * <li>The Record block object</li>
12383 * <li>The "arg" argument from the load function</li>
12384 * <li>A boolean success indicator</li>
12386 * @param {Object} scope The scope in which to call the callback
12387 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12389 load : function(params, reader, callback, scope, arg){
12390 params = params || {};
12393 result = reader.readRecords(this.data);
12395 this.fireEvent("loadexception", this, arg, null, e);
12396 callback.call(scope, null, arg, false);
12399 callback.call(scope, result, arg, true);
12403 update : function(params, records){
12408 * Ext JS Library 1.1.1
12409 * Copyright(c) 2006-2007, Ext JS, LLC.
12411 * Originally Released Under LGPL - original licence link has changed is not relivant.
12414 * <script type="text/javascript">
12417 * @class Roo.data.HttpProxy
12418 * @extends Roo.data.DataProxy
12419 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12420 * configured to reference a certain URL.<br><br>
12422 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12423 * from which the running page was served.<br><br>
12425 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12427 * Be aware that to enable the browser to parse an XML document, the server must set
12428 * the Content-Type header in the HTTP response to "text/xml".
12430 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12431 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12432 * will be used to make the request.
12434 Roo.data.HttpProxy = function(conn){
12435 Roo.data.HttpProxy.superclass.constructor.call(this);
12436 // is conn a conn config or a real conn?
12438 this.useAjax = !conn || !conn.events;
12442 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12443 // thse are take from connection...
12446 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12449 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12450 * extra parameters to each request made by this object. (defaults to undefined)
12453 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12454 * to each request made by this object. (defaults to undefined)
12457 * @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)
12460 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12463 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12469 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12473 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12474 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12475 * a finer-grained basis than the DataProxy events.
12477 getConnection : function(){
12478 return this.useAjax ? Roo.Ajax : this.conn;
12482 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12483 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12484 * process that block using the passed callback.
12485 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12486 * for the request to the remote server.
12487 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12488 * object into a block of Roo.data.Records.
12489 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12490 * The function must be passed <ul>
12491 * <li>The Record block object</li>
12492 * <li>The "arg" argument from the load function</li>
12493 * <li>A boolean success indicator</li>
12495 * @param {Object} scope The scope in which to call the callback
12496 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12498 load : function(params, reader, callback, scope, arg){
12499 if(this.fireEvent("beforeload", this, params) !== false){
12501 params : params || {},
12503 callback : callback,
12508 callback : this.loadResponse,
12512 Roo.applyIf(o, this.conn);
12513 if(this.activeRequest){
12514 Roo.Ajax.abort(this.activeRequest);
12516 this.activeRequest = Roo.Ajax.request(o);
12518 this.conn.request(o);
12521 callback.call(scope||this, null, arg, false);
12526 loadResponse : function(o, success, response){
12527 delete this.activeRequest;
12529 this.fireEvent("loadexception", this, o, response);
12530 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12535 result = o.reader.read(response);
12537 this.fireEvent("loadexception", this, o, response, e);
12538 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12542 this.fireEvent("load", this, o, o.request.arg);
12543 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12547 update : function(dataSet){
12552 updateResponse : function(dataSet){
12557 * Ext JS Library 1.1.1
12558 * Copyright(c) 2006-2007, Ext JS, LLC.
12560 * Originally Released Under LGPL - original licence link has changed is not relivant.
12563 * <script type="text/javascript">
12567 * @class Roo.data.ScriptTagProxy
12568 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12569 * other than the originating domain of the running page.<br><br>
12571 * <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
12572 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12574 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12575 * source code that is used as the source inside a <script> tag.<br><br>
12577 * In order for the browser to process the returned data, the server must wrap the data object
12578 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12579 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12580 * depending on whether the callback name was passed:
12583 boolean scriptTag = false;
12584 String cb = request.getParameter("callback");
12587 response.setContentType("text/javascript");
12589 response.setContentType("application/x-json");
12591 Writer out = response.getWriter();
12593 out.write(cb + "(");
12595 out.print(dataBlock.toJsonString());
12602 * @param {Object} config A configuration object.
12604 Roo.data.ScriptTagProxy = function(config){
12605 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12606 Roo.apply(this, config);
12607 this.head = document.getElementsByTagName("head")[0];
12610 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12612 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12614 * @cfg {String} url The URL from which to request the data object.
12617 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12621 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12622 * the server the name of the callback function set up by the load call to process the returned data object.
12623 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12624 * javascript output which calls this named function passing the data object as its only parameter.
12626 callbackParam : "callback",
12628 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12629 * name to the request.
12634 * Load data from the configured URL, read the data object into
12635 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12636 * process that block using the passed callback.
12637 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12638 * for the request to the remote server.
12639 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12640 * object into a block of Roo.data.Records.
12641 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12642 * The function must be passed <ul>
12643 * <li>The Record block object</li>
12644 * <li>The "arg" argument from the load function</li>
12645 * <li>A boolean success indicator</li>
12647 * @param {Object} scope The scope in which to call the callback
12648 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12650 load : function(params, reader, callback, scope, arg){
12651 if(this.fireEvent("beforeload", this, params) !== false){
12653 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12655 var url = this.url;
12656 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12658 url += "&_dc=" + (new Date().getTime());
12660 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12663 cb : "stcCallback"+transId,
12664 scriptId : "stcScript"+transId,
12668 callback : callback,
12674 window[trans.cb] = function(o){
12675 conn.handleResponse(o, trans);
12678 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12680 if(this.autoAbort !== false){
12684 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12686 var script = document.createElement("script");
12687 script.setAttribute("src", url);
12688 script.setAttribute("type", "text/javascript");
12689 script.setAttribute("id", trans.scriptId);
12690 this.head.appendChild(script);
12692 this.trans = trans;
12694 callback.call(scope||this, null, arg, false);
12699 isLoading : function(){
12700 return this.trans ? true : false;
12704 * Abort the current server request.
12706 abort : function(){
12707 if(this.isLoading()){
12708 this.destroyTrans(this.trans);
12713 destroyTrans : function(trans, isLoaded){
12714 this.head.removeChild(document.getElementById(trans.scriptId));
12715 clearTimeout(trans.timeoutId);
12717 window[trans.cb] = undefined;
12719 delete window[trans.cb];
12722 // if hasn't been loaded, wait for load to remove it to prevent script error
12723 window[trans.cb] = function(){
12724 window[trans.cb] = undefined;
12726 delete window[trans.cb];
12733 handleResponse : function(o, trans){
12734 this.trans = false;
12735 this.destroyTrans(trans, true);
12738 result = trans.reader.readRecords(o);
12740 this.fireEvent("loadexception", this, o, trans.arg, e);
12741 trans.callback.call(trans.scope||window, null, trans.arg, false);
12744 this.fireEvent("load", this, o, trans.arg);
12745 trans.callback.call(trans.scope||window, result, trans.arg, true);
12749 handleFailure : function(trans){
12750 this.trans = false;
12751 this.destroyTrans(trans, false);
12752 this.fireEvent("loadexception", this, null, trans.arg);
12753 trans.callback.call(trans.scope||window, null, trans.arg, false);
12757 * Ext JS Library 1.1.1
12758 * Copyright(c) 2006-2007, Ext JS, LLC.
12760 * Originally Released Under LGPL - original licence link has changed is not relivant.
12763 * <script type="text/javascript">
12767 * @class Roo.data.JsonReader
12768 * @extends Roo.data.DataReader
12769 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12770 * based on mappings in a provided Roo.data.Record constructor.
12772 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12773 * in the reply previously.
12778 var RecordDef = Roo.data.Record.create([
12779 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12780 {name: 'occupation'} // This field will use "occupation" as the mapping.
12782 var myReader = new Roo.data.JsonReader({
12783 totalProperty: "results", // The property which contains the total dataset size (optional)
12784 root: "rows", // The property which contains an Array of row objects
12785 id: "id" // The property within each row object that provides an ID for the record (optional)
12789 * This would consume a JSON file like this:
12791 { 'results': 2, 'rows': [
12792 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12793 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12796 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12797 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12798 * paged from the remote server.
12799 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12800 * @cfg {String} root name of the property which contains the Array of row objects.
12801 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12802 * @cfg {Array} fields Array of field definition objects
12804 * Create a new JsonReader
12805 * @param {Object} meta Metadata configuration options
12806 * @param {Object} recordType Either an Array of field definition objects,
12807 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12809 Roo.data.JsonReader = function(meta, recordType){
12812 // set some defaults:
12813 Roo.applyIf(meta, {
12814 totalProperty: 'total',
12815 successProperty : 'success',
12820 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12822 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12825 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12826 * Used by Store query builder to append _requestMeta to params.
12829 metaFromRemote : false,
12831 * This method is only used by a DataProxy which has retrieved data from a remote server.
12832 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12833 * @return {Object} data A data block which is used by an Roo.data.Store object as
12834 * a cache of Roo.data.Records.
12836 read : function(response){
12837 var json = response.responseText;
12839 var o = /* eval:var:o */ eval("("+json+")");
12841 throw {message: "JsonReader.read: Json object not found"};
12847 this.metaFromRemote = true;
12848 this.meta = o.metaData;
12849 this.recordType = Roo.data.Record.create(o.metaData.fields);
12850 this.onMetaChange(this.meta, this.recordType, o);
12852 return this.readRecords(o);
12855 // private function a store will implement
12856 onMetaChange : function(meta, recordType, o){
12863 simpleAccess: function(obj, subsc) {
12870 getJsonAccessor: function(){
12872 return function(expr) {
12874 return(re.test(expr))
12875 ? new Function("obj", "return obj." + expr)
12880 return Roo.emptyFn;
12885 * Create a data block containing Roo.data.Records from an XML document.
12886 * @param {Object} o An object which contains an Array of row objects in the property specified
12887 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12888 * which contains the total size of the dataset.
12889 * @return {Object} data A data block which is used by an Roo.data.Store object as
12890 * a cache of Roo.data.Records.
12892 readRecords : function(o){
12894 * After any data loads, the raw JSON data is available for further custom processing.
12898 var s = this.meta, Record = this.recordType,
12899 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12901 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12903 if(s.totalProperty) {
12904 this.getTotal = this.getJsonAccessor(s.totalProperty);
12906 if(s.successProperty) {
12907 this.getSuccess = this.getJsonAccessor(s.successProperty);
12909 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12911 var g = this.getJsonAccessor(s.id);
12912 this.getId = function(rec) {
12914 return (r === undefined || r === "") ? null : r;
12917 this.getId = function(){return null;};
12920 for(var jj = 0; jj < fl; jj++){
12922 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12923 this.ef[jj] = this.getJsonAccessor(map);
12927 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12928 if(s.totalProperty){
12929 var vt = parseInt(this.getTotal(o), 10);
12934 if(s.successProperty){
12935 var vs = this.getSuccess(o);
12936 if(vs === false || vs === 'false'){
12941 for(var i = 0; i < c; i++){
12944 var id = this.getId(n);
12945 for(var j = 0; j < fl; j++){
12947 var v = this.ef[j](n);
12949 Roo.log('missing convert for ' + f.name);
12953 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12955 var record = new Record(values, id);
12957 records[i] = record;
12963 totalRecords : totalRecords
12968 * Ext JS Library 1.1.1
12969 * Copyright(c) 2006-2007, Ext JS, LLC.
12971 * Originally Released Under LGPL - original licence link has changed is not relivant.
12974 * <script type="text/javascript">
12978 * @class Roo.data.ArrayReader
12979 * @extends Roo.data.DataReader
12980 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12981 * Each element of that Array represents a row of data fields. The
12982 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12983 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12987 var RecordDef = Roo.data.Record.create([
12988 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12989 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12991 var myReader = new Roo.data.ArrayReader({
12992 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12996 * This would consume an Array like this:
12998 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13000 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
13002 * Create a new JsonReader
13003 * @param {Object} meta Metadata configuration options.
13004 * @param {Object} recordType Either an Array of field definition objects
13005 * as specified to {@link Roo.data.Record#create},
13006 * or an {@link Roo.data.Record} object
13007 * created using {@link Roo.data.Record#create}.
13009 Roo.data.ArrayReader = function(meta, recordType){
13010 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
13013 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13015 * Create a data block containing Roo.data.Records from an XML document.
13016 * @param {Object} o An Array of row objects which represents the dataset.
13017 * @return {Object} data A data block which is used by an Roo.data.Store object as
13018 * a cache of Roo.data.Records.
13020 readRecords : function(o){
13021 var sid = this.meta ? this.meta.id : null;
13022 var recordType = this.recordType, fields = recordType.prototype.fields;
13025 for(var i = 0; i < root.length; i++){
13028 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13029 for(var j = 0, jlen = fields.length; j < jlen; j++){
13030 var f = fields.items[j];
13031 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13032 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13034 values[f.name] = v;
13036 var record = new recordType(values, id);
13038 records[records.length] = record;
13042 totalRecords : records.length
13051 * @class Roo.bootstrap.ComboBox
13052 * @extends Roo.bootstrap.TriggerField
13053 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13054 * @cfg {Boolean} append (true|false) default false
13055 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13056 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13057 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13058 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13059 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13060 * @cfg {Boolean} animate default true
13061 * @cfg {Boolean} emptyResultText only for touch device
13062 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13063 * @cfg {String} emptyTitle default ''
13065 * Create a new ComboBox.
13066 * @param {Object} config Configuration options
13068 Roo.bootstrap.ComboBox = function(config){
13069 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13073 * Fires when the dropdown list is expanded
13074 * @param {Roo.bootstrap.ComboBox} combo This combo box
13079 * Fires when the dropdown list is collapsed
13080 * @param {Roo.bootstrap.ComboBox} combo This combo box
13084 * @event beforeselect
13085 * Fires before a list item is selected. Return false to cancel the selection.
13086 * @param {Roo.bootstrap.ComboBox} combo This combo box
13087 * @param {Roo.data.Record} record The data record returned from the underlying store
13088 * @param {Number} index The index of the selected item in the dropdown list
13090 'beforeselect' : true,
13093 * Fires when a list item is selected
13094 * @param {Roo.bootstrap.ComboBox} combo This combo box
13095 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13096 * @param {Number} index The index of the selected item in the dropdown list
13100 * @event beforequery
13101 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13102 * The event object passed has these properties:
13103 * @param {Roo.bootstrap.ComboBox} combo This combo box
13104 * @param {String} query The query
13105 * @param {Boolean} forceAll true to force "all" query
13106 * @param {Boolean} cancel true to cancel the query
13107 * @param {Object} e The query event object
13109 'beforequery': true,
13112 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13113 * @param {Roo.bootstrap.ComboBox} combo This combo box
13118 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13119 * @param {Roo.bootstrap.ComboBox} combo This combo box
13120 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13125 * Fires when the remove value from the combobox array
13126 * @param {Roo.bootstrap.ComboBox} combo This combo box
13130 * @event afterremove
13131 * Fires when the remove value from the combobox array
13132 * @param {Roo.bootstrap.ComboBox} combo This combo box
13134 'afterremove' : true,
13136 * @event specialfilter
13137 * Fires when specialfilter
13138 * @param {Roo.bootstrap.ComboBox} combo This combo box
13140 'specialfilter' : true,
13143 * Fires when tick the element
13144 * @param {Roo.bootstrap.ComboBox} combo This combo box
13148 * @event touchviewdisplay
13149 * Fires when touch view require special display (default is using displayField)
13150 * @param {Roo.bootstrap.ComboBox} combo This combo box
13151 * @param {Object} cfg set html .
13153 'touchviewdisplay' : true
13158 this.tickItems = [];
13160 this.selectedIndex = -1;
13161 if(this.mode == 'local'){
13162 if(config.queryDelay === undefined){
13163 this.queryDelay = 10;
13165 if(config.minChars === undefined){
13171 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13174 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13175 * rendering into an Roo.Editor, defaults to false)
13178 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13179 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13182 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13185 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13186 * the dropdown list (defaults to undefined, with no header element)
13190 * @cfg {String/Roo.Template} tpl The template to use to render the output
13194 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13196 listWidth: undefined,
13198 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13199 * mode = 'remote' or 'text' if mode = 'local')
13201 displayField: undefined,
13204 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13205 * mode = 'remote' or 'value' if mode = 'local').
13206 * Note: use of a valueField requires the user make a selection
13207 * in order for a value to be mapped.
13209 valueField: undefined,
13211 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13216 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13217 * field's data value (defaults to the underlying DOM element's name)
13219 hiddenName: undefined,
13221 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13225 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13227 selectedClass: 'active',
13230 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13234 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13235 * anchor positions (defaults to 'tl-bl')
13237 listAlign: 'tl-bl?',
13239 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13243 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13244 * query specified by the allQuery config option (defaults to 'query')
13246 triggerAction: 'query',
13248 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13249 * (defaults to 4, does not apply if editable = false)
13253 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13254 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13258 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13259 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13263 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13264 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13268 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13269 * when editable = true (defaults to false)
13271 selectOnFocus:false,
13273 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13275 queryParam: 'query',
13277 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13278 * when mode = 'remote' (defaults to 'Loading...')
13280 loadingText: 'Loading...',
13282 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13286 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13290 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13291 * traditional select (defaults to true)
13295 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13299 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13303 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13304 * listWidth has a higher value)
13308 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13309 * allow the user to set arbitrary text into the field (defaults to false)
13311 forceSelection:false,
13313 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13314 * if typeAhead = true (defaults to 250)
13316 typeAheadDelay : 250,
13318 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13319 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13321 valueNotFoundText : undefined,
13323 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13325 blockFocus : false,
13328 * @cfg {Boolean} disableClear Disable showing of clear button.
13330 disableClear : false,
13332 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13334 alwaysQuery : false,
13337 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13342 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13344 invalidClass : "has-warning",
13347 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13349 validClass : "has-success",
13352 * @cfg {Boolean} specialFilter (true|false) special filter default false
13354 specialFilter : false,
13357 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13359 mobileTouchView : true,
13362 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13364 useNativeIOS : false,
13367 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13369 mobile_restrict_height : false,
13371 ios_options : false,
13383 btnPosition : 'right',
13384 triggerList : true,
13385 showToggleBtn : true,
13387 emptyResultText: 'Empty',
13388 triggerText : 'Select',
13391 // element that contains real text value.. (when hidden is used..)
13393 getAutoCreate : function()
13398 * Render classic select for iso
13401 if(Roo.isIOS && this.useNativeIOS){
13402 cfg = this.getAutoCreateNativeIOS();
13410 if(Roo.isTouch && this.mobileTouchView){
13411 cfg = this.getAutoCreateTouchView();
13418 if(!this.tickable){
13419 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13424 * ComboBox with tickable selections
13427 var align = this.labelAlign || this.parentLabelAlign();
13430 cls : 'form-group roo-combobox-tickable' //input-group
13433 var btn_text_select = '';
13434 var btn_text_done = '';
13435 var btn_text_cancel = '';
13437 if (this.btn_text_show) {
13438 btn_text_select = 'Select';
13439 btn_text_done = 'Done';
13440 btn_text_cancel = 'Cancel';
13445 cls : 'tickable-buttons',
13450 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13451 //html : this.triggerText
13452 html: btn_text_select
13458 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13460 html: btn_text_done
13466 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13468 html: btn_text_cancel
13474 buttons.cn.unshift({
13476 cls: 'roo-select2-search-field-input'
13482 Roo.each(buttons.cn, function(c){
13484 c.cls += ' btn-' + _this.size;
13487 if (_this.disabled) {
13494 style : 'display: contents',
13499 cls: 'form-hidden-field'
13503 cls: 'roo-select2-choices',
13507 cls: 'roo-select2-search-field',
13518 cls: 'roo-select2-container input-group roo-select2-container-multi',
13524 // cls: 'typeahead typeahead-long dropdown-menu',
13525 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13530 if(this.hasFeedback && !this.allowBlank){
13534 cls: 'glyphicon form-control-feedback'
13537 combobox.cn.push(feedback);
13542 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13543 tooltip : 'This field is required'
13545 if (Roo.bootstrap.version == 4) {
13548 style : 'display:none'
13551 if (align ==='left' && this.fieldLabel.length) {
13553 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13560 cls : 'control-label col-form-label',
13561 html : this.fieldLabel
13573 var labelCfg = cfg.cn[1];
13574 var contentCfg = cfg.cn[2];
13577 if(this.indicatorpos == 'right'){
13583 cls : 'control-label col-form-label',
13587 html : this.fieldLabel
13603 labelCfg = cfg.cn[0];
13604 contentCfg = cfg.cn[1];
13608 if(this.labelWidth > 12){
13609 labelCfg.style = "width: " + this.labelWidth + 'px';
13612 if(this.labelWidth < 13 && this.labelmd == 0){
13613 this.labelmd = this.labelWidth;
13616 if(this.labellg > 0){
13617 labelCfg.cls += ' col-lg-' + this.labellg;
13618 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13621 if(this.labelmd > 0){
13622 labelCfg.cls += ' col-md-' + this.labelmd;
13623 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13626 if(this.labelsm > 0){
13627 labelCfg.cls += ' col-sm-' + this.labelsm;
13628 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13631 if(this.labelxs > 0){
13632 labelCfg.cls += ' col-xs-' + this.labelxs;
13633 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13637 } else if ( this.fieldLabel.length) {
13638 // Roo.log(" label");
13643 //cls : 'input-group-addon',
13644 html : this.fieldLabel
13649 if(this.indicatorpos == 'right'){
13653 //cls : 'input-group-addon',
13654 html : this.fieldLabel
13664 // Roo.log(" no label && no align");
13671 ['xs','sm','md','lg'].map(function(size){
13672 if (settings[size]) {
13673 cfg.cls += ' col-' + size + '-' + settings[size];
13681 _initEventsCalled : false,
13684 initEvents: function()
13686 if (this._initEventsCalled) { // as we call render... prevent looping...
13689 this._initEventsCalled = true;
13692 throw "can not find store for combo";
13695 this.indicator = this.indicatorEl();
13697 this.store = Roo.factory(this.store, Roo.data);
13698 this.store.parent = this;
13700 // if we are building from html. then this element is so complex, that we can not really
13701 // use the rendered HTML.
13702 // so we have to trash and replace the previous code.
13703 if (Roo.XComponent.build_from_html) {
13704 // remove this element....
13705 var e = this.el.dom, k=0;
13706 while (e ) { e = e.previousSibling; ++k;}
13711 this.rendered = false;
13713 this.render(this.parent().getChildContainer(true), k);
13716 if(Roo.isIOS && this.useNativeIOS){
13717 this.initIOSView();
13725 if(Roo.isTouch && this.mobileTouchView){
13726 this.initTouchView();
13731 this.initTickableEvents();
13735 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13737 if(this.hiddenName){
13739 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13741 this.hiddenField.dom.value =
13742 this.hiddenValue !== undefined ? this.hiddenValue :
13743 this.value !== undefined ? this.value : '';
13745 // prevent input submission
13746 this.el.dom.removeAttribute('name');
13747 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13752 // this.el.dom.setAttribute('autocomplete', 'off');
13755 var cls = 'x-combo-list';
13757 //this.list = new Roo.Layer({
13758 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13764 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13765 _this.list.setWidth(lw);
13768 this.list.on('mouseover', this.onViewOver, this);
13769 this.list.on('mousemove', this.onViewMove, this);
13770 this.list.on('scroll', this.onViewScroll, this);
13773 this.list.swallowEvent('mousewheel');
13774 this.assetHeight = 0;
13777 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13778 this.assetHeight += this.header.getHeight();
13781 this.innerList = this.list.createChild({cls:cls+'-inner'});
13782 this.innerList.on('mouseover', this.onViewOver, this);
13783 this.innerList.on('mousemove', this.onViewMove, this);
13784 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13786 if(this.allowBlank && !this.pageSize && !this.disableClear){
13787 this.footer = this.list.createChild({cls:cls+'-ft'});
13788 this.pageTb = new Roo.Toolbar(this.footer);
13792 this.footer = this.list.createChild({cls:cls+'-ft'});
13793 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13794 {pageSize: this.pageSize});
13798 if (this.pageTb && this.allowBlank && !this.disableClear) {
13800 this.pageTb.add(new Roo.Toolbar.Fill(), {
13801 cls: 'x-btn-icon x-btn-clear',
13803 handler: function()
13806 _this.clearValue();
13807 _this.onSelect(false, -1);
13812 this.assetHeight += this.footer.getHeight();
13817 this.tpl = Roo.bootstrap.version == 4 ?
13818 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13819 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13822 this.view = new Roo.View(this.list, this.tpl, {
13823 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13825 //this.view.wrapEl.setDisplayed(false);
13826 this.view.on('click', this.onViewClick, this);
13829 this.store.on('beforeload', this.onBeforeLoad, this);
13830 this.store.on('load', this.onLoad, this);
13831 this.store.on('loadexception', this.onLoadException, this);
13833 if(this.resizable){
13834 this.resizer = new Roo.Resizable(this.list, {
13835 pinned:true, handles:'se'
13837 this.resizer.on('resize', function(r, w, h){
13838 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13839 this.listWidth = w;
13840 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13841 this.restrictHeight();
13843 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13846 if(!this.editable){
13847 this.editable = true;
13848 this.setEditable(false);
13853 if (typeof(this.events.add.listeners) != 'undefined') {
13855 this.addicon = this.wrap.createChild(
13856 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13858 this.addicon.on('click', function(e) {
13859 this.fireEvent('add', this);
13862 if (typeof(this.events.edit.listeners) != 'undefined') {
13864 this.editicon = this.wrap.createChild(
13865 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13866 if (this.addicon) {
13867 this.editicon.setStyle('margin-left', '40px');
13869 this.editicon.on('click', function(e) {
13871 // we fire even if inothing is selected..
13872 this.fireEvent('edit', this, this.lastData );
13878 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13879 "up" : function(e){
13880 this.inKeyMode = true;
13884 "down" : function(e){
13885 if(!this.isExpanded()){
13886 this.onTriggerClick();
13888 this.inKeyMode = true;
13893 "enter" : function(e){
13894 // this.onViewClick();
13898 if(this.fireEvent("specialkey", this, e)){
13899 this.onViewClick(false);
13905 "esc" : function(e){
13909 "tab" : function(e){
13912 if(this.fireEvent("specialkey", this, e)){
13913 this.onViewClick(false);
13921 doRelay : function(foo, bar, hname){
13922 if(hname == 'down' || this.scope.isExpanded()){
13923 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13932 this.queryDelay = Math.max(this.queryDelay || 10,
13933 this.mode == 'local' ? 10 : 250);
13936 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13938 if(this.typeAhead){
13939 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13941 if(this.editable !== false){
13942 this.inputEl().on("keyup", this.onKeyUp, this);
13944 if(this.forceSelection){
13945 this.inputEl().on('blur', this.doForce, this);
13949 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13950 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13954 initTickableEvents: function()
13958 if(this.hiddenName){
13960 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13962 this.hiddenField.dom.value =
13963 this.hiddenValue !== undefined ? this.hiddenValue :
13964 this.value !== undefined ? this.value : '';
13966 // prevent input submission
13967 this.el.dom.removeAttribute('name');
13968 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13973 // this.list = this.el.select('ul.dropdown-menu',true).first();
13975 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13976 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13977 if(this.triggerList){
13978 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13981 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13982 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13984 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13985 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13987 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13988 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13990 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13991 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13992 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13995 this.cancelBtn.hide();
14000 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14001 _this.list.setWidth(lw);
14004 this.list.on('mouseover', this.onViewOver, this);
14005 this.list.on('mousemove', this.onViewMove, this);
14007 this.list.on('scroll', this.onViewScroll, this);
14010 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14011 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14014 this.view = new Roo.View(this.list, this.tpl, {
14019 selectedClass: this.selectedClass
14022 //this.view.wrapEl.setDisplayed(false);
14023 this.view.on('click', this.onViewClick, this);
14027 this.store.on('beforeload', this.onBeforeLoad, this);
14028 this.store.on('load', this.onLoad, this);
14029 this.store.on('loadexception', this.onLoadException, this);
14032 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14033 "up" : function(e){
14034 this.inKeyMode = true;
14038 "down" : function(e){
14039 this.inKeyMode = true;
14043 "enter" : function(e){
14044 if(this.fireEvent("specialkey", this, e)){
14045 this.onViewClick(false);
14051 "esc" : function(e){
14052 this.onTickableFooterButtonClick(e, false, false);
14055 "tab" : function(e){
14056 this.fireEvent("specialkey", this, e);
14058 this.onTickableFooterButtonClick(e, false, false);
14065 doRelay : function(e, fn, key){
14066 if(this.scope.isExpanded()){
14067 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14076 this.queryDelay = Math.max(this.queryDelay || 10,
14077 this.mode == 'local' ? 10 : 250);
14080 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14082 if(this.typeAhead){
14083 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14086 if(this.editable !== false){
14087 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14090 this.indicator = this.indicatorEl();
14092 if(this.indicator){
14093 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14094 this.indicator.hide();
14099 onDestroy : function(){
14101 this.view.setStore(null);
14102 this.view.el.removeAllListeners();
14103 this.view.el.remove();
14104 this.view.purgeListeners();
14107 this.list.dom.innerHTML = '';
14111 this.store.un('beforeload', this.onBeforeLoad, this);
14112 this.store.un('load', this.onLoad, this);
14113 this.store.un('loadexception', this.onLoadException, this);
14115 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14119 fireKey : function(e){
14120 if(e.isNavKeyPress() && !this.list.isVisible()){
14121 this.fireEvent("specialkey", this, e);
14126 onResize: function(w, h){
14127 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14129 // if(typeof w != 'number'){
14130 // // we do not handle it!?!?
14133 // var tw = this.trigger.getWidth();
14134 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14135 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14137 // this.inputEl().setWidth( this.adjustWidth('input', x));
14139 // //this.trigger.setStyle('left', x+'px');
14141 // if(this.list && this.listWidth === undefined){
14142 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14143 // this.list.setWidth(lw);
14144 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14152 * Allow or prevent the user from directly editing the field text. If false is passed,
14153 * the user will only be able to select from the items defined in the dropdown list. This method
14154 * is the runtime equivalent of setting the 'editable' config option at config time.
14155 * @param {Boolean} value True to allow the user to directly edit the field text
14157 setEditable : function(value){
14158 if(value == this.editable){
14161 this.editable = value;
14163 this.inputEl().dom.setAttribute('readOnly', true);
14164 this.inputEl().on('mousedown', this.onTriggerClick, this);
14165 this.inputEl().addClass('x-combo-noedit');
14167 this.inputEl().dom.setAttribute('readOnly', false);
14168 this.inputEl().un('mousedown', this.onTriggerClick, this);
14169 this.inputEl().removeClass('x-combo-noedit');
14175 onBeforeLoad : function(combo,opts){
14176 if(!this.hasFocus){
14180 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14182 this.restrictHeight();
14183 this.selectedIndex = -1;
14187 onLoad : function(){
14189 this.hasQuery = false;
14191 if(!this.hasFocus){
14195 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14196 this.loading.hide();
14199 if(this.store.getCount() > 0){
14202 this.restrictHeight();
14203 if(this.lastQuery == this.allQuery){
14204 if(this.editable && !this.tickable){
14205 this.inputEl().dom.select();
14209 !this.selectByValue(this.value, true) &&
14212 !this.store.lastOptions ||
14213 typeof(this.store.lastOptions.add) == 'undefined' ||
14214 this.store.lastOptions.add != true
14217 this.select(0, true);
14220 if(this.autoFocus){
14223 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14224 this.taTask.delay(this.typeAheadDelay);
14228 this.onEmptyResults();
14234 onLoadException : function()
14236 this.hasQuery = false;
14238 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14239 this.loading.hide();
14242 if(this.tickable && this.editable){
14247 // only causes errors at present
14248 //Roo.log(this.store.reader.jsonData);
14249 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14251 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14257 onTypeAhead : function(){
14258 if(this.store.getCount() > 0){
14259 var r = this.store.getAt(0);
14260 var newValue = r.data[this.displayField];
14261 var len = newValue.length;
14262 var selStart = this.getRawValue().length;
14264 if(selStart != len){
14265 this.setRawValue(newValue);
14266 this.selectText(selStart, newValue.length);
14272 onSelect : function(record, index){
14274 if(this.fireEvent('beforeselect', this, record, index) !== false){
14276 this.setFromData(index > -1 ? record.data : false);
14279 this.fireEvent('select', this, record, index);
14284 * Returns the currently selected field value or empty string if no value is set.
14285 * @return {String} value The selected value
14287 getValue : function()
14289 if(Roo.isIOS && this.useNativeIOS){
14290 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14294 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14297 if(this.valueField){
14298 return typeof this.value != 'undefined' ? this.value : '';
14300 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14304 getRawValue : function()
14306 if(Roo.isIOS && this.useNativeIOS){
14307 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14310 var v = this.inputEl().getValue();
14316 * Clears any text/value currently set in the field
14318 clearValue : function(){
14320 if(this.hiddenField){
14321 this.hiddenField.dom.value = '';
14324 this.setRawValue('');
14325 this.lastSelectionText = '';
14326 this.lastData = false;
14328 var close = this.closeTriggerEl();
14339 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14340 * will be displayed in the field. If the value does not match the data value of an existing item,
14341 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14342 * Otherwise the field will be blank (although the value will still be set).
14343 * @param {String} value The value to match
14345 setValue : function(v)
14347 if(Roo.isIOS && this.useNativeIOS){
14348 this.setIOSValue(v);
14358 if(this.valueField){
14359 var r = this.findRecord(this.valueField, v);
14361 text = r.data[this.displayField];
14362 }else if(this.valueNotFoundText !== undefined){
14363 text = this.valueNotFoundText;
14366 this.lastSelectionText = text;
14367 if(this.hiddenField){
14368 this.hiddenField.dom.value = v;
14370 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14373 var close = this.closeTriggerEl();
14376 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14382 * @property {Object} the last set data for the element
14387 * Sets the value of the field based on a object which is related to the record format for the store.
14388 * @param {Object} value the value to set as. or false on reset?
14390 setFromData : function(o){
14397 var dv = ''; // display value
14398 var vv = ''; // value value..
14400 if (this.displayField) {
14401 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14403 // this is an error condition!!!
14404 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14407 if(this.valueField){
14408 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14411 var close = this.closeTriggerEl();
14414 if(dv.length || vv * 1 > 0){
14416 this.blockFocus=true;
14422 if(this.hiddenField){
14423 this.hiddenField.dom.value = vv;
14425 this.lastSelectionText = dv;
14426 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14430 // no hidden field.. - we store the value in 'value', but still display
14431 // display field!!!!
14432 this.lastSelectionText = dv;
14433 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14440 reset : function(){
14441 // overridden so that last data is reset..
14448 this.setValue(this.originalValue);
14449 //this.clearInvalid();
14450 this.lastData = false;
14452 this.view.clearSelections();
14458 findRecord : function(prop, value){
14460 if(this.store.getCount() > 0){
14461 this.store.each(function(r){
14462 if(r.data[prop] == value){
14472 getName: function()
14474 // returns hidden if it's set..
14475 if (!this.rendered) {return ''};
14476 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14480 onViewMove : function(e, t){
14481 this.inKeyMode = false;
14485 onViewOver : function(e, t){
14486 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14489 var item = this.view.findItemFromChild(t);
14492 var index = this.view.indexOf(item);
14493 this.select(index, false);
14498 onViewClick : function(view, doFocus, el, e)
14500 var index = this.view.getSelectedIndexes()[0];
14502 var r = this.store.getAt(index);
14506 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14513 Roo.each(this.tickItems, function(v,k){
14515 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14517 _this.tickItems.splice(k, 1);
14519 if(typeof(e) == 'undefined' && view == false){
14520 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14532 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14533 this.tickItems.push(r.data);
14536 if(typeof(e) == 'undefined' && view == false){
14537 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14544 this.onSelect(r, index);
14546 if(doFocus !== false && !this.blockFocus){
14547 this.inputEl().focus();
14552 restrictHeight : function(){
14553 //this.innerList.dom.style.height = '';
14554 //var inner = this.innerList.dom;
14555 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14556 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14557 //this.list.beginUpdate();
14558 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14559 this.list.alignTo(this.inputEl(), this.listAlign);
14560 this.list.alignTo(this.inputEl(), this.listAlign);
14561 //this.list.endUpdate();
14565 onEmptyResults : function(){
14567 if(this.tickable && this.editable){
14568 this.hasFocus = false;
14569 this.restrictHeight();
14577 * Returns true if the dropdown list is expanded, else false.
14579 isExpanded : function(){
14580 return this.list.isVisible();
14584 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14585 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14586 * @param {String} value The data value of the item to select
14587 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14588 * selected item if it is not currently in view (defaults to true)
14589 * @return {Boolean} True if the value matched an item in the list, else false
14591 selectByValue : function(v, scrollIntoView){
14592 if(v !== undefined && v !== null){
14593 var r = this.findRecord(this.valueField || this.displayField, v);
14595 this.select(this.store.indexOf(r), scrollIntoView);
14603 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14604 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14605 * @param {Number} index The zero-based index of the list item to select
14606 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14607 * selected item if it is not currently in view (defaults to true)
14609 select : function(index, scrollIntoView){
14610 this.selectedIndex = index;
14611 this.view.select(index);
14612 if(scrollIntoView !== false){
14613 var el = this.view.getNode(index);
14615 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14618 this.list.scrollChildIntoView(el, false);
14624 selectNext : function(){
14625 var ct = this.store.getCount();
14627 if(this.selectedIndex == -1){
14629 }else if(this.selectedIndex < ct-1){
14630 this.select(this.selectedIndex+1);
14636 selectPrev : function(){
14637 var ct = this.store.getCount();
14639 if(this.selectedIndex == -1){
14641 }else if(this.selectedIndex != 0){
14642 this.select(this.selectedIndex-1);
14648 onKeyUp : function(e){
14649 if(this.editable !== false && !e.isSpecialKey()){
14650 this.lastKey = e.getKey();
14651 this.dqTask.delay(this.queryDelay);
14656 validateBlur : function(){
14657 return !this.list || !this.list.isVisible();
14661 initQuery : function(){
14663 var v = this.getRawValue();
14665 if(this.tickable && this.editable){
14666 v = this.tickableInputEl().getValue();
14673 doForce : function(){
14674 if(this.inputEl().dom.value.length > 0){
14675 this.inputEl().dom.value =
14676 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14682 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14683 * query allowing the query action to be canceled if needed.
14684 * @param {String} query The SQL query to execute
14685 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14686 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14687 * saved in the current store (defaults to false)
14689 doQuery : function(q, forceAll){
14691 if(q === undefined || q === null){
14696 forceAll: forceAll,
14700 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14705 forceAll = qe.forceAll;
14706 if(forceAll === true || (q.length >= this.minChars)){
14708 this.hasQuery = true;
14710 if(this.lastQuery != q || this.alwaysQuery){
14711 this.lastQuery = q;
14712 if(this.mode == 'local'){
14713 this.selectedIndex = -1;
14715 this.store.clearFilter();
14718 if(this.specialFilter){
14719 this.fireEvent('specialfilter', this);
14724 this.store.filter(this.displayField, q);
14727 this.store.fireEvent("datachanged", this.store);
14734 this.store.baseParams[this.queryParam] = q;
14736 var options = {params : this.getParams(q)};
14739 options.add = true;
14740 options.params.start = this.page * this.pageSize;
14743 this.store.load(options);
14746 * this code will make the page width larger, at the beginning, the list not align correctly,
14747 * we should expand the list on onLoad
14748 * so command out it
14753 this.selectedIndex = -1;
14758 this.loadNext = false;
14762 getParams : function(q){
14764 //p[this.queryParam] = q;
14768 p.limit = this.pageSize;
14774 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14776 collapse : function(){
14777 if(!this.isExpanded()){
14783 this.hasFocus = false;
14787 this.cancelBtn.hide();
14788 this.trigger.show();
14791 this.tickableInputEl().dom.value = '';
14792 this.tickableInputEl().blur();
14797 Roo.get(document).un('mousedown', this.collapseIf, this);
14798 Roo.get(document).un('mousewheel', this.collapseIf, this);
14799 if (!this.editable) {
14800 Roo.get(document).un('keydown', this.listKeyPress, this);
14802 this.fireEvent('collapse', this);
14808 collapseIf : function(e){
14809 var in_combo = e.within(this.el);
14810 var in_list = e.within(this.list);
14811 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14813 if (in_combo || in_list || is_list) {
14814 //e.stopPropagation();
14819 this.onTickableFooterButtonClick(e, false, false);
14827 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14829 expand : function(){
14831 if(this.isExpanded() || !this.hasFocus){
14835 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14836 this.list.setWidth(lw);
14842 this.restrictHeight();
14846 this.tickItems = Roo.apply([], this.item);
14849 this.cancelBtn.show();
14850 this.trigger.hide();
14853 this.tickableInputEl().focus();
14858 Roo.get(document).on('mousedown', this.collapseIf, this);
14859 Roo.get(document).on('mousewheel', this.collapseIf, this);
14860 if (!this.editable) {
14861 Roo.get(document).on('keydown', this.listKeyPress, this);
14864 this.fireEvent('expand', this);
14868 // Implements the default empty TriggerField.onTriggerClick function
14869 onTriggerClick : function(e)
14871 Roo.log('trigger click');
14873 if(this.disabled || !this.triggerList){
14878 this.loadNext = false;
14880 if(this.isExpanded()){
14882 if (!this.blockFocus) {
14883 this.inputEl().focus();
14887 this.hasFocus = true;
14888 if(this.triggerAction == 'all') {
14889 this.doQuery(this.allQuery, true);
14891 this.doQuery(this.getRawValue());
14893 if (!this.blockFocus) {
14894 this.inputEl().focus();
14899 onTickableTriggerClick : function(e)
14906 this.loadNext = false;
14907 this.hasFocus = true;
14909 if(this.triggerAction == 'all') {
14910 this.doQuery(this.allQuery, true);
14912 this.doQuery(this.getRawValue());
14916 onSearchFieldClick : function(e)
14918 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14919 this.onTickableFooterButtonClick(e, false, false);
14923 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14928 this.loadNext = false;
14929 this.hasFocus = true;
14931 if(this.triggerAction == 'all') {
14932 this.doQuery(this.allQuery, true);
14934 this.doQuery(this.getRawValue());
14938 listKeyPress : function(e)
14940 //Roo.log('listkeypress');
14941 // scroll to first matching element based on key pres..
14942 if (e.isSpecialKey()) {
14945 var k = String.fromCharCode(e.getKey()).toUpperCase();
14948 var csel = this.view.getSelectedNodes();
14949 var cselitem = false;
14951 var ix = this.view.indexOf(csel[0]);
14952 cselitem = this.store.getAt(ix);
14953 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14959 this.store.each(function(v) {
14961 // start at existing selection.
14962 if (cselitem.id == v.id) {
14968 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14969 match = this.store.indexOf(v);
14975 if (match === false) {
14976 return true; // no more action?
14979 this.view.select(match);
14980 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14981 sn.scrollIntoView(sn.dom.parentNode, false);
14984 onViewScroll : function(e, t){
14986 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){
14990 this.hasQuery = true;
14992 this.loading = this.list.select('.loading', true).first();
14994 if(this.loading === null){
14995 this.list.createChild({
14997 cls: 'loading roo-select2-more-results roo-select2-active',
14998 html: 'Loading more results...'
15001 this.loading = this.list.select('.loading', true).first();
15003 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15005 this.loading.hide();
15008 this.loading.show();
15013 this.loadNext = true;
15015 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15020 addItem : function(o)
15022 var dv = ''; // display value
15024 if (this.displayField) {
15025 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15027 // this is an error condition!!!
15028 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15035 var choice = this.choices.createChild({
15037 cls: 'roo-select2-search-choice',
15046 cls: 'roo-select2-search-choice-close fa fa-times',
15051 }, this.searchField);
15053 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15055 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15063 this.inputEl().dom.value = '';
15068 onRemoveItem : function(e, _self, o)
15070 e.preventDefault();
15072 this.lastItem = Roo.apply([], this.item);
15074 var index = this.item.indexOf(o.data) * 1;
15077 Roo.log('not this item?!');
15081 this.item.splice(index, 1);
15086 this.fireEvent('remove', this, e);
15092 syncValue : function()
15094 if(!this.item.length){
15101 Roo.each(this.item, function(i){
15102 if(_this.valueField){
15103 value.push(i[_this.valueField]);
15110 this.value = value.join(',');
15112 if(this.hiddenField){
15113 this.hiddenField.dom.value = this.value;
15116 this.store.fireEvent("datachanged", this.store);
15121 clearItem : function()
15123 if(!this.multiple){
15129 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15137 if(this.tickable && !Roo.isTouch){
15138 this.view.refresh();
15142 inputEl: function ()
15144 if(Roo.isIOS && this.useNativeIOS){
15145 return this.el.select('select.roo-ios-select', true).first();
15148 if(Roo.isTouch && this.mobileTouchView){
15149 return this.el.select('input.form-control',true).first();
15153 return this.searchField;
15156 return this.el.select('input.form-control',true).first();
15159 onTickableFooterButtonClick : function(e, btn, el)
15161 e.preventDefault();
15163 this.lastItem = Roo.apply([], this.item);
15165 if(btn && btn.name == 'cancel'){
15166 this.tickItems = Roo.apply([], this.item);
15175 Roo.each(this.tickItems, function(o){
15183 validate : function()
15185 if(this.getVisibilityEl().hasClass('hidden')){
15189 var v = this.getRawValue();
15192 v = this.getValue();
15195 if(this.disabled || this.allowBlank || v.length){
15200 this.markInvalid();
15204 tickableInputEl : function()
15206 if(!this.tickable || !this.editable){
15207 return this.inputEl();
15210 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15214 getAutoCreateTouchView : function()
15219 cls: 'form-group' //input-group
15225 type : this.inputType,
15226 cls : 'form-control x-combo-noedit',
15227 autocomplete: 'new-password',
15228 placeholder : this.placeholder || '',
15233 input.name = this.name;
15237 input.cls += ' input-' + this.size;
15240 if (this.disabled) {
15241 input.disabled = true;
15252 inputblock.cls += ' input-group';
15254 inputblock.cn.unshift({
15256 cls : 'input-group-addon input-group-prepend input-group-text',
15261 if(this.removable && !this.multiple){
15262 inputblock.cls += ' roo-removable';
15264 inputblock.cn.push({
15267 cls : 'roo-combo-removable-btn close'
15271 if(this.hasFeedback && !this.allowBlank){
15273 inputblock.cls += ' has-feedback';
15275 inputblock.cn.push({
15277 cls: 'glyphicon form-control-feedback'
15284 inputblock.cls += (this.before) ? '' : ' input-group';
15286 inputblock.cn.push({
15288 cls : 'input-group-addon input-group-append input-group-text',
15294 var ibwrap = inputblock;
15299 cls: 'roo-select2-choices',
15303 cls: 'roo-select2-search-field',
15316 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15321 cls: 'form-hidden-field'
15327 if(!this.multiple && this.showToggleBtn){
15334 if (this.caret != false) {
15337 cls: 'fa fa-' + this.caret
15344 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15349 cls: 'combobox-clear',
15363 combobox.cls += ' roo-select2-container-multi';
15366 var align = this.labelAlign || this.parentLabelAlign();
15368 if (align ==='left' && this.fieldLabel.length) {
15373 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15374 tooltip : 'This field is required'
15378 cls : 'control-label col-form-label',
15379 html : this.fieldLabel
15390 var labelCfg = cfg.cn[1];
15391 var contentCfg = cfg.cn[2];
15394 if(this.indicatorpos == 'right'){
15399 cls : 'control-label col-form-label',
15403 html : this.fieldLabel
15407 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15408 tooltip : 'This field is required'
15421 labelCfg = cfg.cn[0];
15422 contentCfg = cfg.cn[1];
15427 if(this.labelWidth > 12){
15428 labelCfg.style = "width: " + this.labelWidth + 'px';
15431 if(this.labelWidth < 13 && this.labelmd == 0){
15432 this.labelmd = this.labelWidth;
15435 if(this.labellg > 0){
15436 labelCfg.cls += ' col-lg-' + this.labellg;
15437 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15440 if(this.labelmd > 0){
15441 labelCfg.cls += ' col-md-' + this.labelmd;
15442 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15445 if(this.labelsm > 0){
15446 labelCfg.cls += ' col-sm-' + this.labelsm;
15447 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15450 if(this.labelxs > 0){
15451 labelCfg.cls += ' col-xs-' + this.labelxs;
15452 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15456 } else if ( this.fieldLabel.length) {
15460 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15461 tooltip : 'This field is required'
15465 cls : 'control-label',
15466 html : this.fieldLabel
15477 if(this.indicatorpos == 'right'){
15481 cls : 'control-label',
15482 html : this.fieldLabel,
15486 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15487 tooltip : 'This field is required'
15504 var settings = this;
15506 ['xs','sm','md','lg'].map(function(size){
15507 if (settings[size]) {
15508 cfg.cls += ' col-' + size + '-' + settings[size];
15515 initTouchView : function()
15517 this.renderTouchView();
15519 this.touchViewEl.on('scroll', function(){
15520 this.el.dom.scrollTop = 0;
15523 this.originalValue = this.getValue();
15525 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15527 this.inputEl().on("click", this.showTouchView, this);
15528 if (this.triggerEl) {
15529 this.triggerEl.on("click", this.showTouchView, this);
15533 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15534 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15536 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15538 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15539 this.store.on('load', this.onTouchViewLoad, this);
15540 this.store.on('loadexception', this.onTouchViewLoadException, this);
15542 if(this.hiddenName){
15544 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15546 this.hiddenField.dom.value =
15547 this.hiddenValue !== undefined ? this.hiddenValue :
15548 this.value !== undefined ? this.value : '';
15550 this.el.dom.removeAttribute('name');
15551 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15555 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15556 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15559 if(this.removable && !this.multiple){
15560 var close = this.closeTriggerEl();
15562 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15563 close.on('click', this.removeBtnClick, this, close);
15567 * fix the bug in Safari iOS8
15569 this.inputEl().on("focus", function(e){
15570 document.activeElement.blur();
15573 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15580 renderTouchView : function()
15582 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15583 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15585 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15586 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15588 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15589 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15590 this.touchViewBodyEl.setStyle('overflow', 'auto');
15592 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15593 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15595 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15596 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15600 showTouchView : function()
15606 this.touchViewHeaderEl.hide();
15608 if(this.modalTitle.length){
15609 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15610 this.touchViewHeaderEl.show();
15613 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15614 this.touchViewEl.show();
15616 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15618 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15619 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15621 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15623 if(this.modalTitle.length){
15624 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15627 this.touchViewBodyEl.setHeight(bodyHeight);
15631 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15633 this.touchViewEl.addClass('in');
15636 if(this._touchViewMask){
15637 Roo.get(document.body).addClass("x-body-masked");
15638 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15639 this._touchViewMask.setStyle('z-index', 10000);
15640 this._touchViewMask.addClass('show');
15643 this.doTouchViewQuery();
15647 hideTouchView : function()
15649 this.touchViewEl.removeClass('in');
15653 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15655 this.touchViewEl.setStyle('display', 'none');
15658 if(this._touchViewMask){
15659 this._touchViewMask.removeClass('show');
15660 Roo.get(document.body).removeClass("x-body-masked");
15664 setTouchViewValue : function()
15671 Roo.each(this.tickItems, function(o){
15676 this.hideTouchView();
15679 doTouchViewQuery : function()
15688 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15692 if(!this.alwaysQuery || this.mode == 'local'){
15693 this.onTouchViewLoad();
15700 onTouchViewBeforeLoad : function(combo,opts)
15706 onTouchViewLoad : function()
15708 if(this.store.getCount() < 1){
15709 this.onTouchViewEmptyResults();
15713 this.clearTouchView();
15715 var rawValue = this.getRawValue();
15717 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15719 this.tickItems = [];
15721 this.store.data.each(function(d, rowIndex){
15722 var row = this.touchViewListGroup.createChild(template);
15724 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15725 row.addClass(d.data.cls);
15728 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15731 html : d.data[this.displayField]
15734 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15735 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15738 row.removeClass('selected');
15739 if(!this.multiple && this.valueField &&
15740 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15743 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15744 row.addClass('selected');
15747 if(this.multiple && this.valueField &&
15748 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15752 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15753 this.tickItems.push(d.data);
15756 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15760 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15762 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15764 if(this.modalTitle.length){
15765 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15768 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15770 if(this.mobile_restrict_height && listHeight < bodyHeight){
15771 this.touchViewBodyEl.setHeight(listHeight);
15776 if(firstChecked && listHeight > bodyHeight){
15777 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15782 onTouchViewLoadException : function()
15784 this.hideTouchView();
15787 onTouchViewEmptyResults : function()
15789 this.clearTouchView();
15791 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15793 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15797 clearTouchView : function()
15799 this.touchViewListGroup.dom.innerHTML = '';
15802 onTouchViewClick : function(e, el, o)
15804 e.preventDefault();
15807 var rowIndex = o.rowIndex;
15809 var r = this.store.getAt(rowIndex);
15811 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15813 if(!this.multiple){
15814 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15815 c.dom.removeAttribute('checked');
15818 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15820 this.setFromData(r.data);
15822 var close = this.closeTriggerEl();
15828 this.hideTouchView();
15830 this.fireEvent('select', this, r, rowIndex);
15835 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15836 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15837 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15841 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15842 this.addItem(r.data);
15843 this.tickItems.push(r.data);
15847 getAutoCreateNativeIOS : function()
15850 cls: 'form-group' //input-group,
15855 cls : 'roo-ios-select'
15859 combobox.name = this.name;
15862 if (this.disabled) {
15863 combobox.disabled = true;
15866 var settings = this;
15868 ['xs','sm','md','lg'].map(function(size){
15869 if (settings[size]) {
15870 cfg.cls += ' col-' + size + '-' + settings[size];
15880 initIOSView : function()
15882 this.store.on('load', this.onIOSViewLoad, this);
15887 onIOSViewLoad : function()
15889 if(this.store.getCount() < 1){
15893 this.clearIOSView();
15895 if(this.allowBlank) {
15897 var default_text = '-- SELECT --';
15899 if(this.placeholder.length){
15900 default_text = this.placeholder;
15903 if(this.emptyTitle.length){
15904 default_text += ' - ' + this.emptyTitle + ' -';
15907 var opt = this.inputEl().createChild({
15910 html : default_text
15914 o[this.valueField] = 0;
15915 o[this.displayField] = default_text;
15917 this.ios_options.push({
15924 this.store.data.each(function(d, rowIndex){
15928 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15929 html = d.data[this.displayField];
15934 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15935 value = d.data[this.valueField];
15944 if(this.value == d.data[this.valueField]){
15945 option['selected'] = true;
15948 var opt = this.inputEl().createChild(option);
15950 this.ios_options.push({
15957 this.inputEl().on('change', function(){
15958 this.fireEvent('select', this);
15963 clearIOSView: function()
15965 this.inputEl().dom.innerHTML = '';
15967 this.ios_options = [];
15970 setIOSValue: function(v)
15974 if(!this.ios_options){
15978 Roo.each(this.ios_options, function(opts){
15980 opts.el.dom.removeAttribute('selected');
15982 if(opts.data[this.valueField] != v){
15986 opts.el.dom.setAttribute('selected', true);
15992 * @cfg {Boolean} grow
15996 * @cfg {Number} growMin
16000 * @cfg {Number} growMax
16009 Roo.apply(Roo.bootstrap.ComboBox, {
16013 cls: 'modal-header',
16035 cls: 'list-group-item',
16039 cls: 'roo-combobox-list-group-item-value'
16043 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16057 listItemCheckbox : {
16059 cls: 'list-group-item',
16063 cls: 'roo-combobox-list-group-item-value'
16067 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16083 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16088 cls: 'modal-footer',
16096 cls: 'col-xs-6 text-left',
16099 cls: 'btn btn-danger roo-touch-view-cancel',
16105 cls: 'col-xs-6 text-right',
16108 cls: 'btn btn-success roo-touch-view-ok',
16119 Roo.apply(Roo.bootstrap.ComboBox, {
16121 touchViewTemplate : {
16123 cls: 'modal fade roo-combobox-touch-view',
16127 cls: 'modal-dialog',
16128 style : 'position:fixed', // we have to fix position....
16132 cls: 'modal-content',
16134 Roo.bootstrap.ComboBox.header,
16135 Roo.bootstrap.ComboBox.body,
16136 Roo.bootstrap.ComboBox.footer
16145 * Ext JS Library 1.1.1
16146 * Copyright(c) 2006-2007, Ext JS, LLC.
16148 * Originally Released Under LGPL - original licence link has changed is not relivant.
16151 * <script type="text/javascript">
16156 * @extends Roo.util.Observable
16157 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16158 * This class also supports single and multi selection modes. <br>
16159 * Create a data model bound view:
16161 var store = new Roo.data.Store(...);
16163 var view = new Roo.View({
16165 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16167 singleSelect: true,
16168 selectedClass: "ydataview-selected",
16172 // listen for node click?
16173 view.on("click", function(vw, index, node, e){
16174 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16178 dataModel.load("foobar.xml");
16180 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16182 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16183 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16185 * Note: old style constructor is still suported (container, template, config)
16188 * Create a new View
16189 * @param {Object} config The config object
16192 Roo.View = function(config, depreciated_tpl, depreciated_config){
16194 this.parent = false;
16196 if (typeof(depreciated_tpl) == 'undefined') {
16197 // new way.. - universal constructor.
16198 Roo.apply(this, config);
16199 this.el = Roo.get(this.el);
16202 this.el = Roo.get(config);
16203 this.tpl = depreciated_tpl;
16204 Roo.apply(this, depreciated_config);
16206 this.wrapEl = this.el.wrap().wrap();
16207 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16210 if(typeof(this.tpl) == "string"){
16211 this.tpl = new Roo.Template(this.tpl);
16213 // support xtype ctors..
16214 this.tpl = new Roo.factory(this.tpl, Roo);
16218 this.tpl.compile();
16223 * @event beforeclick
16224 * Fires before a click is processed. Returns false to cancel the default action.
16225 * @param {Roo.View} this
16226 * @param {Number} index The index of the target node
16227 * @param {HTMLElement} node The target node
16228 * @param {Roo.EventObject} e The raw event object
16230 "beforeclick" : true,
16233 * Fires when a template node is clicked.
16234 * @param {Roo.View} this
16235 * @param {Number} index The index of the target node
16236 * @param {HTMLElement} node The target node
16237 * @param {Roo.EventObject} e The raw event object
16242 * Fires when a template node is double clicked.
16243 * @param {Roo.View} this
16244 * @param {Number} index The index of the target node
16245 * @param {HTMLElement} node The target node
16246 * @param {Roo.EventObject} e The raw event object
16250 * @event contextmenu
16251 * Fires when a template node is right clicked.
16252 * @param {Roo.View} this
16253 * @param {Number} index The index of the target node
16254 * @param {HTMLElement} node The target node
16255 * @param {Roo.EventObject} e The raw event object
16257 "contextmenu" : true,
16259 * @event selectionchange
16260 * Fires when the selected nodes change.
16261 * @param {Roo.View} this
16262 * @param {Array} selections Array of the selected nodes
16264 "selectionchange" : true,
16267 * @event beforeselect
16268 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16269 * @param {Roo.View} this
16270 * @param {HTMLElement} node The node to be selected
16271 * @param {Array} selections Array of currently selected nodes
16273 "beforeselect" : true,
16275 * @event preparedata
16276 * Fires on every row to render, to allow you to change the data.
16277 * @param {Roo.View} this
16278 * @param {Object} data to be rendered (change this)
16280 "preparedata" : true
16288 "click": this.onClick,
16289 "dblclick": this.onDblClick,
16290 "contextmenu": this.onContextMenu,
16294 this.selections = [];
16296 this.cmp = new Roo.CompositeElementLite([]);
16298 this.store = Roo.factory(this.store, Roo.data);
16299 this.setStore(this.store, true);
16302 if ( this.footer && this.footer.xtype) {
16304 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16306 this.footer.dataSource = this.store;
16307 this.footer.container = fctr;
16308 this.footer = Roo.factory(this.footer, Roo);
16309 fctr.insertFirst(this.el);
16311 // this is a bit insane - as the paging toolbar seems to detach the el..
16312 // dom.parentNode.parentNode.parentNode
16313 // they get detached?
16317 Roo.View.superclass.constructor.call(this);
16322 Roo.extend(Roo.View, Roo.util.Observable, {
16325 * @cfg {Roo.data.Store} store Data store to load data from.
16330 * @cfg {String|Roo.Element} el The container element.
16335 * @cfg {String|Roo.Template} tpl The template used by this View
16339 * @cfg {String} dataName the named area of the template to use as the data area
16340 * Works with domtemplates roo-name="name"
16344 * @cfg {String} selectedClass The css class to add to selected nodes
16346 selectedClass : "x-view-selected",
16348 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16353 * @cfg {String} text to display on mask (default Loading)
16357 * @cfg {Boolean} multiSelect Allow multiple selection
16359 multiSelect : false,
16361 * @cfg {Boolean} singleSelect Allow single selection
16363 singleSelect: false,
16366 * @cfg {Boolean} toggleSelect - selecting
16368 toggleSelect : false,
16371 * @cfg {Boolean} tickable - selecting
16376 * Returns the element this view is bound to.
16377 * @return {Roo.Element}
16379 getEl : function(){
16380 return this.wrapEl;
16386 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16388 refresh : function(){
16389 //Roo.log('refresh');
16392 // if we are using something like 'domtemplate', then
16393 // the what gets used is:
16394 // t.applySubtemplate(NAME, data, wrapping data..)
16395 // the outer template then get' applied with
16396 // the store 'extra data'
16397 // and the body get's added to the
16398 // roo-name="data" node?
16399 // <span class='roo-tpl-{name}'></span> ?????
16403 this.clearSelections();
16404 this.el.update("");
16406 var records = this.store.getRange();
16407 if(records.length < 1) {
16409 // is this valid?? = should it render a template??
16411 this.el.update(this.emptyText);
16415 if (this.dataName) {
16416 this.el.update(t.apply(this.store.meta)); //????
16417 el = this.el.child('.roo-tpl-' + this.dataName);
16420 for(var i = 0, len = records.length; i < len; i++){
16421 var data = this.prepareData(records[i].data, i, records[i]);
16422 this.fireEvent("preparedata", this, data, i, records[i]);
16424 var d = Roo.apply({}, data);
16427 Roo.apply(d, {'roo-id' : Roo.id()});
16431 Roo.each(this.parent.item, function(item){
16432 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16435 Roo.apply(d, {'roo-data-checked' : 'checked'});
16439 html[html.length] = Roo.util.Format.trim(
16441 t.applySubtemplate(this.dataName, d, this.store.meta) :
16448 el.update(html.join(""));
16449 this.nodes = el.dom.childNodes;
16450 this.updateIndexes(0);
16455 * Function to override to reformat the data that is sent to
16456 * the template for each node.
16457 * DEPRICATED - use the preparedata event handler.
16458 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16459 * a JSON object for an UpdateManager bound view).
16461 prepareData : function(data, index, record)
16463 this.fireEvent("preparedata", this, data, index, record);
16467 onUpdate : function(ds, record){
16468 // Roo.log('on update');
16469 this.clearSelections();
16470 var index = this.store.indexOf(record);
16471 var n = this.nodes[index];
16472 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16473 n.parentNode.removeChild(n);
16474 this.updateIndexes(index, index);
16480 onAdd : function(ds, records, index)
16482 //Roo.log(['on Add', ds, records, index] );
16483 this.clearSelections();
16484 if(this.nodes.length == 0){
16488 var n = this.nodes[index];
16489 for(var i = 0, len = records.length; i < len; i++){
16490 var d = this.prepareData(records[i].data, i, records[i]);
16492 this.tpl.insertBefore(n, d);
16495 this.tpl.append(this.el, d);
16498 this.updateIndexes(index);
16501 onRemove : function(ds, record, index){
16502 // Roo.log('onRemove');
16503 this.clearSelections();
16504 var el = this.dataName ?
16505 this.el.child('.roo-tpl-' + this.dataName) :
16508 el.dom.removeChild(this.nodes[index]);
16509 this.updateIndexes(index);
16513 * Refresh an individual node.
16514 * @param {Number} index
16516 refreshNode : function(index){
16517 this.onUpdate(this.store, this.store.getAt(index));
16520 updateIndexes : function(startIndex, endIndex){
16521 var ns = this.nodes;
16522 startIndex = startIndex || 0;
16523 endIndex = endIndex || ns.length - 1;
16524 for(var i = startIndex; i <= endIndex; i++){
16525 ns[i].nodeIndex = i;
16530 * Changes the data store this view uses and refresh the view.
16531 * @param {Store} store
16533 setStore : function(store, initial){
16534 if(!initial && this.store){
16535 this.store.un("datachanged", this.refresh);
16536 this.store.un("add", this.onAdd);
16537 this.store.un("remove", this.onRemove);
16538 this.store.un("update", this.onUpdate);
16539 this.store.un("clear", this.refresh);
16540 this.store.un("beforeload", this.onBeforeLoad);
16541 this.store.un("load", this.onLoad);
16542 this.store.un("loadexception", this.onLoad);
16546 store.on("datachanged", this.refresh, this);
16547 store.on("add", this.onAdd, this);
16548 store.on("remove", this.onRemove, this);
16549 store.on("update", this.onUpdate, this);
16550 store.on("clear", this.refresh, this);
16551 store.on("beforeload", this.onBeforeLoad, this);
16552 store.on("load", this.onLoad, this);
16553 store.on("loadexception", this.onLoad, this);
16561 * onbeforeLoad - masks the loading area.
16564 onBeforeLoad : function(store,opts)
16566 //Roo.log('onBeforeLoad');
16568 this.el.update("");
16570 this.el.mask(this.mask ? this.mask : "Loading" );
16572 onLoad : function ()
16579 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16580 * @param {HTMLElement} node
16581 * @return {HTMLElement} The template node
16583 findItemFromChild : function(node){
16584 var el = this.dataName ?
16585 this.el.child('.roo-tpl-' + this.dataName,true) :
16588 if(!node || node.parentNode == el){
16591 var p = node.parentNode;
16592 while(p && p != el){
16593 if(p.parentNode == el){
16602 onClick : function(e){
16603 var item = this.findItemFromChild(e.getTarget());
16605 var index = this.indexOf(item);
16606 if(this.onItemClick(item, index, e) !== false){
16607 this.fireEvent("click", this, index, item, e);
16610 this.clearSelections();
16615 onContextMenu : function(e){
16616 var item = this.findItemFromChild(e.getTarget());
16618 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16623 onDblClick : function(e){
16624 var item = this.findItemFromChild(e.getTarget());
16626 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16630 onItemClick : function(item, index, e)
16632 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16635 if (this.toggleSelect) {
16636 var m = this.isSelected(item) ? 'unselect' : 'select';
16639 _t[m](item, true, false);
16642 if(this.multiSelect || this.singleSelect){
16643 if(this.multiSelect && e.shiftKey && this.lastSelection){
16644 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16646 this.select(item, this.multiSelect && e.ctrlKey);
16647 this.lastSelection = item;
16650 if(!this.tickable){
16651 e.preventDefault();
16659 * Get the number of selected nodes.
16662 getSelectionCount : function(){
16663 return this.selections.length;
16667 * Get the currently selected nodes.
16668 * @return {Array} An array of HTMLElements
16670 getSelectedNodes : function(){
16671 return this.selections;
16675 * Get the indexes of the selected nodes.
16678 getSelectedIndexes : function(){
16679 var indexes = [], s = this.selections;
16680 for(var i = 0, len = s.length; i < len; i++){
16681 indexes.push(s[i].nodeIndex);
16687 * Clear all selections
16688 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16690 clearSelections : function(suppressEvent){
16691 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16692 this.cmp.elements = this.selections;
16693 this.cmp.removeClass(this.selectedClass);
16694 this.selections = [];
16695 if(!suppressEvent){
16696 this.fireEvent("selectionchange", this, this.selections);
16702 * Returns true if the passed node is selected
16703 * @param {HTMLElement/Number} node The node or node index
16704 * @return {Boolean}
16706 isSelected : function(node){
16707 var s = this.selections;
16711 node = this.getNode(node);
16712 return s.indexOf(node) !== -1;
16717 * @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
16718 * @param {Boolean} keepExisting (optional) true to keep existing selections
16719 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16721 select : function(nodeInfo, keepExisting, suppressEvent){
16722 if(nodeInfo instanceof Array){
16724 this.clearSelections(true);
16726 for(var i = 0, len = nodeInfo.length; i < len; i++){
16727 this.select(nodeInfo[i], true, true);
16731 var node = this.getNode(nodeInfo);
16732 if(!node || this.isSelected(node)){
16733 return; // already selected.
16736 this.clearSelections(true);
16739 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16740 Roo.fly(node).addClass(this.selectedClass);
16741 this.selections.push(node);
16742 if(!suppressEvent){
16743 this.fireEvent("selectionchange", this, this.selections);
16751 * @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
16752 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16753 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16755 unselect : function(nodeInfo, keepExisting, suppressEvent)
16757 if(nodeInfo instanceof Array){
16758 Roo.each(this.selections, function(s) {
16759 this.unselect(s, nodeInfo);
16763 var node = this.getNode(nodeInfo);
16764 if(!node || !this.isSelected(node)){
16765 //Roo.log("not selected");
16766 return; // not selected.
16770 Roo.each(this.selections, function(s) {
16772 Roo.fly(node).removeClass(this.selectedClass);
16779 this.selections= ns;
16780 this.fireEvent("selectionchange", this, this.selections);
16784 * Gets a template node.
16785 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16786 * @return {HTMLElement} The node or null if it wasn't found
16788 getNode : function(nodeInfo){
16789 if(typeof nodeInfo == "string"){
16790 return document.getElementById(nodeInfo);
16791 }else if(typeof nodeInfo == "number"){
16792 return this.nodes[nodeInfo];
16798 * Gets a range template nodes.
16799 * @param {Number} startIndex
16800 * @param {Number} endIndex
16801 * @return {Array} An array of nodes
16803 getNodes : function(start, end){
16804 var ns = this.nodes;
16805 start = start || 0;
16806 end = typeof end == "undefined" ? ns.length - 1 : end;
16809 for(var i = start; i <= end; i++){
16813 for(var i = start; i >= end; i--){
16821 * Finds the index of the passed node
16822 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16823 * @return {Number} The index of the node or -1
16825 indexOf : function(node){
16826 node = this.getNode(node);
16827 if(typeof node.nodeIndex == "number"){
16828 return node.nodeIndex;
16830 var ns = this.nodes;
16831 for(var i = 0, len = ns.length; i < len; i++){
16842 * based on jquery fullcalendar
16846 Roo.bootstrap = Roo.bootstrap || {};
16848 * @class Roo.bootstrap.Calendar
16849 * @extends Roo.bootstrap.Component
16850 * Bootstrap Calendar class
16851 * @cfg {Boolean} loadMask (true|false) default false
16852 * @cfg {Object} header generate the user specific header of the calendar, default false
16855 * Create a new Container
16856 * @param {Object} config The config object
16861 Roo.bootstrap.Calendar = function(config){
16862 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16866 * Fires when a date is selected
16867 * @param {DatePicker} this
16868 * @param {Date} date The selected date
16872 * @event monthchange
16873 * Fires when the displayed month changes
16874 * @param {DatePicker} this
16875 * @param {Date} date The selected month
16877 'monthchange': true,
16879 * @event evententer
16880 * Fires when mouse over an event
16881 * @param {Calendar} this
16882 * @param {event} Event
16884 'evententer': true,
16886 * @event eventleave
16887 * Fires when the mouse leaves an
16888 * @param {Calendar} this
16891 'eventleave': true,
16893 * @event eventclick
16894 * Fires when the mouse click an
16895 * @param {Calendar} this
16904 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16907 * @cfg {Number} startDay
16908 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16916 getAutoCreate : function(){
16919 var fc_button = function(name, corner, style, content ) {
16920 return Roo.apply({},{
16922 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16924 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16927 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16938 style : 'width:100%',
16945 cls : 'fc-header-left',
16947 fc_button('prev', 'left', 'arrow', '‹' ),
16948 fc_button('next', 'right', 'arrow', '›' ),
16949 { tag: 'span', cls: 'fc-header-space' },
16950 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16958 cls : 'fc-header-center',
16962 cls: 'fc-header-title',
16965 html : 'month / year'
16973 cls : 'fc-header-right',
16975 /* fc_button('month', 'left', '', 'month' ),
16976 fc_button('week', '', '', 'week' ),
16977 fc_button('day', 'right', '', 'day' )
16989 header = this.header;
16992 var cal_heads = function() {
16994 // fixme - handle this.
16996 for (var i =0; i < Date.dayNames.length; i++) {
16997 var d = Date.dayNames[i];
17000 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17001 html : d.substring(0,3)
17005 ret[0].cls += ' fc-first';
17006 ret[6].cls += ' fc-last';
17009 var cal_cell = function(n) {
17012 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17017 cls: 'fc-day-number',
17021 cls: 'fc-day-content',
17025 style: 'position: relative;' // height: 17px;
17037 var cal_rows = function() {
17040 for (var r = 0; r < 6; r++) {
17047 for (var i =0; i < Date.dayNames.length; i++) {
17048 var d = Date.dayNames[i];
17049 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17052 row.cn[0].cls+=' fc-first';
17053 row.cn[0].cn[0].style = 'min-height:90px';
17054 row.cn[6].cls+=' fc-last';
17058 ret[0].cls += ' fc-first';
17059 ret[4].cls += ' fc-prev-last';
17060 ret[5].cls += ' fc-last';
17067 cls: 'fc-border-separate',
17068 style : 'width:100%',
17076 cls : 'fc-first fc-last',
17094 cls : 'fc-content',
17095 style : "position: relative;",
17098 cls : 'fc-view fc-view-month fc-grid',
17099 style : 'position: relative',
17100 unselectable : 'on',
17103 cls : 'fc-event-container',
17104 style : 'position:absolute;z-index:8;top:0;left:0;'
17122 initEvents : function()
17125 throw "can not find store for calendar";
17131 style: "text-align:center",
17135 style: "background-color:white;width:50%;margin:250 auto",
17139 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17150 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17152 var size = this.el.select('.fc-content', true).first().getSize();
17153 this.maskEl.setSize(size.width, size.height);
17154 this.maskEl.enableDisplayMode("block");
17155 if(!this.loadMask){
17156 this.maskEl.hide();
17159 this.store = Roo.factory(this.store, Roo.data);
17160 this.store.on('load', this.onLoad, this);
17161 this.store.on('beforeload', this.onBeforeLoad, this);
17165 this.cells = this.el.select('.fc-day',true);
17166 //Roo.log(this.cells);
17167 this.textNodes = this.el.query('.fc-day-number');
17168 this.cells.addClassOnOver('fc-state-hover');
17170 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17171 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17172 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17173 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17175 this.on('monthchange', this.onMonthChange, this);
17177 this.update(new Date().clearTime());
17180 resize : function() {
17181 var sz = this.el.getSize();
17183 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17184 this.el.select('.fc-day-content div',true).setHeight(34);
17189 showPrevMonth : function(e){
17190 this.update(this.activeDate.add("mo", -1));
17192 showToday : function(e){
17193 this.update(new Date().clearTime());
17196 showNextMonth : function(e){
17197 this.update(this.activeDate.add("mo", 1));
17201 showPrevYear : function(){
17202 this.update(this.activeDate.add("y", -1));
17206 showNextYear : function(){
17207 this.update(this.activeDate.add("y", 1));
17212 update : function(date)
17214 var vd = this.activeDate;
17215 this.activeDate = date;
17216 // if(vd && this.el){
17217 // var t = date.getTime();
17218 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17219 // Roo.log('using add remove');
17221 // this.fireEvent('monthchange', this, date);
17223 // this.cells.removeClass("fc-state-highlight");
17224 // this.cells.each(function(c){
17225 // if(c.dateValue == t){
17226 // c.addClass("fc-state-highlight");
17227 // setTimeout(function(){
17228 // try{c.dom.firstChild.focus();}catch(e){}
17238 var days = date.getDaysInMonth();
17240 var firstOfMonth = date.getFirstDateOfMonth();
17241 var startingPos = firstOfMonth.getDay()-this.startDay;
17243 if(startingPos < this.startDay){
17247 var pm = date.add(Date.MONTH, -1);
17248 var prevStart = pm.getDaysInMonth()-startingPos;
17250 this.cells = this.el.select('.fc-day',true);
17251 this.textNodes = this.el.query('.fc-day-number');
17252 this.cells.addClassOnOver('fc-state-hover');
17254 var cells = this.cells.elements;
17255 var textEls = this.textNodes;
17257 Roo.each(cells, function(cell){
17258 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17261 days += startingPos;
17263 // convert everything to numbers so it's fast
17264 var day = 86400000;
17265 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17268 //Roo.log(prevStart);
17270 var today = new Date().clearTime().getTime();
17271 var sel = date.clearTime().getTime();
17272 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17273 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17274 var ddMatch = this.disabledDatesRE;
17275 var ddText = this.disabledDatesText;
17276 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17277 var ddaysText = this.disabledDaysText;
17278 var format = this.format;
17280 var setCellClass = function(cal, cell){
17284 //Roo.log('set Cell Class');
17286 var t = d.getTime();
17290 cell.dateValue = t;
17292 cell.className += " fc-today";
17293 cell.className += " fc-state-highlight";
17294 cell.title = cal.todayText;
17297 // disable highlight in other month..
17298 //cell.className += " fc-state-highlight";
17303 cell.className = " fc-state-disabled";
17304 cell.title = cal.minText;
17308 cell.className = " fc-state-disabled";
17309 cell.title = cal.maxText;
17313 if(ddays.indexOf(d.getDay()) != -1){
17314 cell.title = ddaysText;
17315 cell.className = " fc-state-disabled";
17318 if(ddMatch && format){
17319 var fvalue = d.dateFormat(format);
17320 if(ddMatch.test(fvalue)){
17321 cell.title = ddText.replace("%0", fvalue);
17322 cell.className = " fc-state-disabled";
17326 if (!cell.initialClassName) {
17327 cell.initialClassName = cell.dom.className;
17330 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17335 for(; i < startingPos; i++) {
17336 textEls[i].innerHTML = (++prevStart);
17337 d.setDate(d.getDate()+1);
17339 cells[i].className = "fc-past fc-other-month";
17340 setCellClass(this, cells[i]);
17345 for(; i < days; i++){
17346 intDay = i - startingPos + 1;
17347 textEls[i].innerHTML = (intDay);
17348 d.setDate(d.getDate()+1);
17350 cells[i].className = ''; // "x-date-active";
17351 setCellClass(this, cells[i]);
17355 for(; i < 42; i++) {
17356 textEls[i].innerHTML = (++extraDays);
17357 d.setDate(d.getDate()+1);
17359 cells[i].className = "fc-future fc-other-month";
17360 setCellClass(this, cells[i]);
17363 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17365 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17367 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17368 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17370 if(totalRows != 6){
17371 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17372 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17375 this.fireEvent('monthchange', this, date);
17379 if(!this.internalRender){
17380 var main = this.el.dom.firstChild;
17381 var w = main.offsetWidth;
17382 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17383 Roo.fly(main).setWidth(w);
17384 this.internalRender = true;
17385 // opera does not respect the auto grow header center column
17386 // then, after it gets a width opera refuses to recalculate
17387 // without a second pass
17388 if(Roo.isOpera && !this.secondPass){
17389 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17390 this.secondPass = true;
17391 this.update.defer(10, this, [date]);
17398 findCell : function(dt) {
17399 dt = dt.clearTime().getTime();
17401 this.cells.each(function(c){
17402 //Roo.log("check " +c.dateValue + '?=' + dt);
17403 if(c.dateValue == dt){
17413 findCells : function(ev) {
17414 var s = ev.start.clone().clearTime().getTime();
17416 var e= ev.end.clone().clearTime().getTime();
17419 this.cells.each(function(c){
17420 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17422 if(c.dateValue > e){
17425 if(c.dateValue < s){
17434 // findBestRow: function(cells)
17438 // for (var i =0 ; i < cells.length;i++) {
17439 // ret = Math.max(cells[i].rows || 0,ret);
17446 addItem : function(ev)
17448 // look for vertical location slot in
17449 var cells = this.findCells(ev);
17451 // ev.row = this.findBestRow(cells);
17453 // work out the location.
17457 for(var i =0; i < cells.length; i++) {
17459 cells[i].row = cells[0].row;
17462 cells[i].row = cells[i].row + 1;
17472 if (crow.start.getY() == cells[i].getY()) {
17474 crow.end = cells[i];
17491 cells[0].events.push(ev);
17493 this.calevents.push(ev);
17496 clearEvents: function() {
17498 if(!this.calevents){
17502 Roo.each(this.cells.elements, function(c){
17508 Roo.each(this.calevents, function(e) {
17509 Roo.each(e.els, function(el) {
17510 el.un('mouseenter' ,this.onEventEnter, this);
17511 el.un('mouseleave' ,this.onEventLeave, this);
17516 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17522 renderEvents: function()
17526 this.cells.each(function(c) {
17535 if(c.row != c.events.length){
17536 r = 4 - (4 - (c.row - c.events.length));
17539 c.events = ev.slice(0, r);
17540 c.more = ev.slice(r);
17542 if(c.more.length && c.more.length == 1){
17543 c.events.push(c.more.pop());
17546 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17550 this.cells.each(function(c) {
17552 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17555 for (var e = 0; e < c.events.length; e++){
17556 var ev = c.events[e];
17557 var rows = ev.rows;
17559 for(var i = 0; i < rows.length; i++) {
17561 // how many rows should it span..
17564 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17565 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17567 unselectable : "on",
17570 cls: 'fc-event-inner',
17574 // cls: 'fc-event-time',
17575 // html : cells.length > 1 ? '' : ev.time
17579 cls: 'fc-event-title',
17580 html : String.format('{0}', ev.title)
17587 cls: 'ui-resizable-handle ui-resizable-e',
17588 html : '  '
17595 cfg.cls += ' fc-event-start';
17597 if ((i+1) == rows.length) {
17598 cfg.cls += ' fc-event-end';
17601 var ctr = _this.el.select('.fc-event-container',true).first();
17602 var cg = ctr.createChild(cfg);
17604 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17605 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17607 var r = (c.more.length) ? 1 : 0;
17608 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17609 cg.setWidth(ebox.right - sbox.x -2);
17611 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17612 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17613 cg.on('click', _this.onEventClick, _this, ev);
17624 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17625 style : 'position: absolute',
17626 unselectable : "on",
17629 cls: 'fc-event-inner',
17633 cls: 'fc-event-title',
17641 cls: 'ui-resizable-handle ui-resizable-e',
17642 html : '  '
17648 var ctr = _this.el.select('.fc-event-container',true).first();
17649 var cg = ctr.createChild(cfg);
17651 var sbox = c.select('.fc-day-content',true).first().getBox();
17652 var ebox = c.select('.fc-day-content',true).first().getBox();
17654 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17655 cg.setWidth(ebox.right - sbox.x -2);
17657 cg.on('click', _this.onMoreEventClick, _this, c.more);
17667 onEventEnter: function (e, el,event,d) {
17668 this.fireEvent('evententer', this, el, event);
17671 onEventLeave: function (e, el,event,d) {
17672 this.fireEvent('eventleave', this, el, event);
17675 onEventClick: function (e, el,event,d) {
17676 this.fireEvent('eventclick', this, el, event);
17679 onMonthChange: function () {
17683 onMoreEventClick: function(e, el, more)
17687 this.calpopover.placement = 'right';
17688 this.calpopover.setTitle('More');
17690 this.calpopover.setContent('');
17692 var ctr = this.calpopover.el.select('.popover-content', true).first();
17694 Roo.each(more, function(m){
17696 cls : 'fc-event-hori fc-event-draggable',
17699 var cg = ctr.createChild(cfg);
17701 cg.on('click', _this.onEventClick, _this, m);
17704 this.calpopover.show(el);
17709 onLoad: function ()
17711 this.calevents = [];
17714 if(this.store.getCount() > 0){
17715 this.store.data.each(function(d){
17718 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17719 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17720 time : d.data.start_time,
17721 title : d.data.title,
17722 description : d.data.description,
17723 venue : d.data.venue
17728 this.renderEvents();
17730 if(this.calevents.length && this.loadMask){
17731 this.maskEl.hide();
17735 onBeforeLoad: function()
17737 this.clearEvents();
17739 this.maskEl.show();
17753 * @class Roo.bootstrap.Popover
17754 * @extends Roo.bootstrap.Component
17755 * Bootstrap Popover class
17756 * @cfg {String} html contents of the popover (or false to use children..)
17757 * @cfg {String} title of popover (or false to hide)
17758 * @cfg {String} placement how it is placed
17759 * @cfg {String} trigger click || hover (or false to trigger manually)
17760 * @cfg {String} over what (parent or false to trigger manually.)
17761 * @cfg {Number} delay - delay before showing
17764 * Create a new Popover
17765 * @param {Object} config The config object
17768 Roo.bootstrap.Popover = function(config){
17769 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17775 * After the popover show
17777 * @param {Roo.bootstrap.Popover} this
17782 * After the popover hide
17784 * @param {Roo.bootstrap.Popover} this
17790 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17792 title: 'Fill in a title',
17795 placement : 'right',
17796 trigger : 'hover', // hover
17802 can_build_overlaid : false,
17804 getChildContainer : function()
17806 return this.el.select('.popover-content',true).first();
17809 getAutoCreate : function(){
17812 cls : 'popover roo-dynamic',
17813 style: 'display:block',
17819 cls : 'popover-inner',
17823 cls: 'popover-title popover-header',
17827 cls : 'popover-content popover-body',
17838 setTitle: function(str)
17841 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17843 setContent: function(str)
17846 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17848 // as it get's added to the bottom of the page.
17849 onRender : function(ct, position)
17851 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17853 var cfg = Roo.apply({}, this.getAutoCreate());
17857 cfg.cls += ' ' + this.cls;
17860 cfg.style = this.style;
17862 //Roo.log("adding to ");
17863 this.el = Roo.get(document.body).createChild(cfg, position);
17864 // Roo.log(this.el);
17869 initEvents : function()
17871 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17872 this.el.enableDisplayMode('block');
17874 if (this.over === false) {
17877 if (this.triggers === false) {
17880 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17881 var triggers = this.trigger ? this.trigger.split(' ') : [];
17882 Roo.each(triggers, function(trigger) {
17884 if (trigger == 'click') {
17885 on_el.on('click', this.toggle, this);
17886 } else if (trigger != 'manual') {
17887 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17888 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17890 on_el.on(eventIn ,this.enter, this);
17891 on_el.on(eventOut, this.leave, this);
17902 toggle : function () {
17903 this.hoverState == 'in' ? this.leave() : this.enter();
17906 enter : function () {
17908 clearTimeout(this.timeout);
17910 this.hoverState = 'in';
17912 if (!this.delay || !this.delay.show) {
17917 this.timeout = setTimeout(function () {
17918 if (_t.hoverState == 'in') {
17921 }, this.delay.show)
17924 leave : function() {
17925 clearTimeout(this.timeout);
17927 this.hoverState = 'out';
17929 if (!this.delay || !this.delay.hide) {
17934 this.timeout = setTimeout(function () {
17935 if (_t.hoverState == 'out') {
17938 }, this.delay.hide)
17941 show : function (on_el)
17944 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17948 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17949 if (this.html !== false) {
17950 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17952 this.el.removeClass([
17953 'fade','top','bottom', 'left', 'right','in',
17954 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17956 if (!this.title.length) {
17957 this.el.select('.popover-title',true).hide();
17960 var placement = typeof this.placement == 'function' ?
17961 this.placement.call(this, this.el, on_el) :
17964 var autoToken = /\s?auto?\s?/i;
17965 var autoPlace = autoToken.test(placement);
17967 placement = placement.replace(autoToken, '') || 'top';
17971 //this.el.setXY([0,0]);
17973 this.el.dom.style.display='block';
17974 this.el.addClass(placement);
17976 //this.el.appendTo(on_el);
17978 var p = this.getPosition();
17979 var box = this.el.getBox();
17984 var align = Roo.bootstrap.Popover.alignment[placement];
17987 this.el.alignTo(on_el, align[0],align[1]);
17988 //var arrow = this.el.select('.arrow',true).first();
17989 //arrow.set(align[2],
17991 this.el.addClass('in');
17994 if (this.el.hasClass('fade')) {
17998 this.hoverState = 'in';
18000 this.fireEvent('show', this);
18005 this.el.setXY([0,0]);
18006 this.el.removeClass('in');
18008 this.hoverState = null;
18010 this.fireEvent('hide', this);
18015 Roo.bootstrap.Popover.alignment = {
18016 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18017 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18018 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18019 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18030 * @class Roo.bootstrap.Progress
18031 * @extends Roo.bootstrap.Component
18032 * Bootstrap Progress class
18033 * @cfg {Boolean} striped striped of the progress bar
18034 * @cfg {Boolean} active animated of the progress bar
18038 * Create a new Progress
18039 * @param {Object} config The config object
18042 Roo.bootstrap.Progress = function(config){
18043 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18046 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18051 getAutoCreate : function(){
18059 cfg.cls += ' progress-striped';
18063 cfg.cls += ' active';
18082 * @class Roo.bootstrap.ProgressBar
18083 * @extends Roo.bootstrap.Component
18084 * Bootstrap ProgressBar class
18085 * @cfg {Number} aria_valuenow aria-value now
18086 * @cfg {Number} aria_valuemin aria-value min
18087 * @cfg {Number} aria_valuemax aria-value max
18088 * @cfg {String} label label for the progress bar
18089 * @cfg {String} panel (success | info | warning | danger )
18090 * @cfg {String} role role of the progress bar
18091 * @cfg {String} sr_only text
18095 * Create a new ProgressBar
18096 * @param {Object} config The config object
18099 Roo.bootstrap.ProgressBar = function(config){
18100 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18103 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18107 aria_valuemax : 100,
18113 getAutoCreate : function()
18118 cls: 'progress-bar',
18119 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18131 cfg.role = this.role;
18134 if(this.aria_valuenow){
18135 cfg['aria-valuenow'] = this.aria_valuenow;
18138 if(this.aria_valuemin){
18139 cfg['aria-valuemin'] = this.aria_valuemin;
18142 if(this.aria_valuemax){
18143 cfg['aria-valuemax'] = this.aria_valuemax;
18146 if(this.label && !this.sr_only){
18147 cfg.html = this.label;
18151 cfg.cls += ' progress-bar-' + this.panel;
18157 update : function(aria_valuenow)
18159 this.aria_valuenow = aria_valuenow;
18161 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18176 * @class Roo.bootstrap.TabGroup
18177 * @extends Roo.bootstrap.Column
18178 * Bootstrap Column class
18179 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18180 * @cfg {Boolean} carousel true to make the group behave like a carousel
18181 * @cfg {Boolean} bullets show bullets for the panels
18182 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18183 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18184 * @cfg {Boolean} showarrow (true|false) show arrow default true
18187 * Create a new TabGroup
18188 * @param {Object} config The config object
18191 Roo.bootstrap.TabGroup = function(config){
18192 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18194 this.navId = Roo.id();
18197 Roo.bootstrap.TabGroup.register(this);
18201 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18204 transition : false,
18209 slideOnTouch : false,
18212 getAutoCreate : function()
18214 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18216 cfg.cls += ' tab-content';
18218 if (this.carousel) {
18219 cfg.cls += ' carousel slide';
18222 cls : 'carousel-inner',
18226 if(this.bullets && !Roo.isTouch){
18229 cls : 'carousel-bullets',
18233 if(this.bullets_cls){
18234 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18241 cfg.cn[0].cn.push(bullets);
18244 if(this.showarrow){
18245 cfg.cn[0].cn.push({
18247 class : 'carousel-arrow',
18251 class : 'carousel-prev',
18255 class : 'fa fa-chevron-left'
18261 class : 'carousel-next',
18265 class : 'fa fa-chevron-right'
18278 initEvents: function()
18280 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18281 // this.el.on("touchstart", this.onTouchStart, this);
18284 if(this.autoslide){
18287 this.slideFn = window.setInterval(function() {
18288 _this.showPanelNext();
18292 if(this.showarrow){
18293 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18294 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18300 // onTouchStart : function(e, el, o)
18302 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18306 // this.showPanelNext();
18310 getChildContainer : function()
18312 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18316 * register a Navigation item
18317 * @param {Roo.bootstrap.NavItem} the navitem to add
18319 register : function(item)
18321 this.tabs.push( item);
18322 item.navId = this.navId; // not really needed..
18327 getActivePanel : function()
18330 Roo.each(this.tabs, function(t) {
18340 getPanelByName : function(n)
18343 Roo.each(this.tabs, function(t) {
18344 if (t.tabId == n) {
18352 indexOfPanel : function(p)
18355 Roo.each(this.tabs, function(t,i) {
18356 if (t.tabId == p.tabId) {
18365 * show a specific panel
18366 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18367 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18369 showPanel : function (pan)
18371 if(this.transition || typeof(pan) == 'undefined'){
18372 Roo.log("waiting for the transitionend");
18376 if (typeof(pan) == 'number') {
18377 pan = this.tabs[pan];
18380 if (typeof(pan) == 'string') {
18381 pan = this.getPanelByName(pan);
18384 var cur = this.getActivePanel();
18387 Roo.log('pan or acitve pan is undefined');
18391 if (pan.tabId == this.getActivePanel().tabId) {
18395 if (false === cur.fireEvent('beforedeactivate')) {
18399 if(this.bullets > 0 && !Roo.isTouch){
18400 this.setActiveBullet(this.indexOfPanel(pan));
18403 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18405 //class="carousel-item carousel-item-next carousel-item-left"
18407 this.transition = true;
18408 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18409 var lr = dir == 'next' ? 'left' : 'right';
18410 pan.el.addClass(dir); // or prev
18411 pan.el.addClass('carousel-item-' + dir); // or prev
18412 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18413 cur.el.addClass(lr); // or right
18414 pan.el.addClass(lr);
18415 cur.el.addClass('carousel-item-' +lr); // or right
18416 pan.el.addClass('carousel-item-' +lr);
18420 cur.el.on('transitionend', function() {
18421 Roo.log("trans end?");
18423 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18424 pan.setActive(true);
18426 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18427 cur.setActive(false);
18429 _this.transition = false;
18431 }, this, { single: true } );
18436 cur.setActive(false);
18437 pan.setActive(true);
18442 showPanelNext : function()
18444 var i = this.indexOfPanel(this.getActivePanel());
18446 if (i >= this.tabs.length - 1 && !this.autoslide) {
18450 if (i >= this.tabs.length - 1 && this.autoslide) {
18454 this.showPanel(this.tabs[i+1]);
18457 showPanelPrev : function()
18459 var i = this.indexOfPanel(this.getActivePanel());
18461 if (i < 1 && !this.autoslide) {
18465 if (i < 1 && this.autoslide) {
18466 i = this.tabs.length;
18469 this.showPanel(this.tabs[i-1]);
18473 addBullet: function()
18475 if(!this.bullets || Roo.isTouch){
18478 var ctr = this.el.select('.carousel-bullets',true).first();
18479 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18480 var bullet = ctr.createChild({
18481 cls : 'bullet bullet-' + i
18482 },ctr.dom.lastChild);
18487 bullet.on('click', (function(e, el, o, ii, t){
18489 e.preventDefault();
18491 this.showPanel(ii);
18493 if(this.autoslide && this.slideFn){
18494 clearInterval(this.slideFn);
18495 this.slideFn = window.setInterval(function() {
18496 _this.showPanelNext();
18500 }).createDelegate(this, [i, bullet], true));
18505 setActiveBullet : function(i)
18511 Roo.each(this.el.select('.bullet', true).elements, function(el){
18512 el.removeClass('selected');
18515 var bullet = this.el.select('.bullet-' + i, true).first();
18521 bullet.addClass('selected');
18532 Roo.apply(Roo.bootstrap.TabGroup, {
18536 * register a Navigation Group
18537 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18539 register : function(navgrp)
18541 this.groups[navgrp.navId] = navgrp;
18545 * fetch a Navigation Group based on the navigation ID
18546 * if one does not exist , it will get created.
18547 * @param {string} the navgroup to add
18548 * @returns {Roo.bootstrap.NavGroup} the navgroup
18550 get: function(navId) {
18551 if (typeof(this.groups[navId]) == 'undefined') {
18552 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18554 return this.groups[navId] ;
18569 * @class Roo.bootstrap.TabPanel
18570 * @extends Roo.bootstrap.Component
18571 * Bootstrap TabPanel class
18572 * @cfg {Boolean} active panel active
18573 * @cfg {String} html panel content
18574 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18575 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18576 * @cfg {String} href click to link..
18580 * Create a new TabPanel
18581 * @param {Object} config The config object
18584 Roo.bootstrap.TabPanel = function(config){
18585 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18589 * Fires when the active status changes
18590 * @param {Roo.bootstrap.TabPanel} this
18591 * @param {Boolean} state the new state
18596 * @event beforedeactivate
18597 * Fires before a tab is de-activated - can be used to do validation on a form.
18598 * @param {Roo.bootstrap.TabPanel} this
18599 * @return {Boolean} false if there is an error
18602 'beforedeactivate': true
18605 this.tabId = this.tabId || Roo.id();
18609 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18617 getAutoCreate : function(){
18622 // item is needed for carousel - not sure if it has any effect otherwise
18623 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18624 html: this.html || ''
18628 cfg.cls += ' active';
18632 cfg.tabId = this.tabId;
18640 initEvents: function()
18642 var p = this.parent();
18644 this.navId = this.navId || p.navId;
18646 if (typeof(this.navId) != 'undefined') {
18647 // not really needed.. but just in case.. parent should be a NavGroup.
18648 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18652 var i = tg.tabs.length - 1;
18654 if(this.active && tg.bullets > 0 && i < tg.bullets){
18655 tg.setActiveBullet(i);
18659 this.el.on('click', this.onClick, this);
18662 this.el.on("touchstart", this.onTouchStart, this);
18663 this.el.on("touchmove", this.onTouchMove, this);
18664 this.el.on("touchend", this.onTouchEnd, this);
18669 onRender : function(ct, position)
18671 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18674 setActive : function(state)
18676 Roo.log("panel - set active " + this.tabId + "=" + state);
18678 this.active = state;
18680 this.el.removeClass('active');
18682 } else if (!this.el.hasClass('active')) {
18683 this.el.addClass('active');
18686 this.fireEvent('changed', this, state);
18689 onClick : function(e)
18691 e.preventDefault();
18693 if(!this.href.length){
18697 window.location.href = this.href;
18706 onTouchStart : function(e)
18708 this.swiping = false;
18710 this.startX = e.browserEvent.touches[0].clientX;
18711 this.startY = e.browserEvent.touches[0].clientY;
18714 onTouchMove : function(e)
18716 this.swiping = true;
18718 this.endX = e.browserEvent.touches[0].clientX;
18719 this.endY = e.browserEvent.touches[0].clientY;
18722 onTouchEnd : function(e)
18729 var tabGroup = this.parent();
18731 if(this.endX > this.startX){ // swiping right
18732 tabGroup.showPanelPrev();
18736 if(this.startX > this.endX){ // swiping left
18737 tabGroup.showPanelNext();
18756 * @class Roo.bootstrap.DateField
18757 * @extends Roo.bootstrap.Input
18758 * Bootstrap DateField class
18759 * @cfg {Number} weekStart default 0
18760 * @cfg {String} viewMode default empty, (months|years)
18761 * @cfg {String} minViewMode default empty, (months|years)
18762 * @cfg {Number} startDate default -Infinity
18763 * @cfg {Number} endDate default Infinity
18764 * @cfg {Boolean} todayHighlight default false
18765 * @cfg {Boolean} todayBtn default false
18766 * @cfg {Boolean} calendarWeeks default false
18767 * @cfg {Object} daysOfWeekDisabled default empty
18768 * @cfg {Boolean} singleMode default false (true | false)
18770 * @cfg {Boolean} keyboardNavigation default true
18771 * @cfg {String} language default en
18774 * Create a new DateField
18775 * @param {Object} config The config object
18778 Roo.bootstrap.DateField = function(config){
18779 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18783 * Fires when this field show.
18784 * @param {Roo.bootstrap.DateField} this
18785 * @param {Mixed} date The date value
18790 * Fires when this field hide.
18791 * @param {Roo.bootstrap.DateField} this
18792 * @param {Mixed} date The date value
18797 * Fires when select a date.
18798 * @param {Roo.bootstrap.DateField} this
18799 * @param {Mixed} date The date value
18803 * @event beforeselect
18804 * Fires when before select a date.
18805 * @param {Roo.bootstrap.DateField} this
18806 * @param {Mixed} date The date value
18808 beforeselect : true
18812 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18815 * @cfg {String} format
18816 * The default date format string which can be overriden for localization support. The format must be
18817 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18821 * @cfg {String} altFormats
18822 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18823 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18825 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18833 todayHighlight : false,
18839 keyboardNavigation: true,
18841 calendarWeeks: false,
18843 startDate: -Infinity,
18847 daysOfWeekDisabled: [],
18851 singleMode : false,
18853 UTCDate: function()
18855 return new Date(Date.UTC.apply(Date, arguments));
18858 UTCToday: function()
18860 var today = new Date();
18861 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18864 getDate: function() {
18865 var d = this.getUTCDate();
18866 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18869 getUTCDate: function() {
18873 setDate: function(d) {
18874 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18877 setUTCDate: function(d) {
18879 this.setValue(this.formatDate(this.date));
18882 onRender: function(ct, position)
18885 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18887 this.language = this.language || 'en';
18888 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18889 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18891 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18892 this.format = this.format || 'm/d/y';
18893 this.isInline = false;
18894 this.isInput = true;
18895 this.component = this.el.select('.add-on', true).first() || false;
18896 this.component = (this.component && this.component.length === 0) ? false : this.component;
18897 this.hasInput = this.component && this.inputEl().length;
18899 if (typeof(this.minViewMode === 'string')) {
18900 switch (this.minViewMode) {
18902 this.minViewMode = 1;
18905 this.minViewMode = 2;
18908 this.minViewMode = 0;
18913 if (typeof(this.viewMode === 'string')) {
18914 switch (this.viewMode) {
18927 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18929 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18931 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18933 this.picker().on('mousedown', this.onMousedown, this);
18934 this.picker().on('click', this.onClick, this);
18936 this.picker().addClass('datepicker-dropdown');
18938 this.startViewMode = this.viewMode;
18940 if(this.singleMode){
18941 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18942 v.setVisibilityMode(Roo.Element.DISPLAY);
18946 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18947 v.setStyle('width', '189px');
18951 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18952 if(!this.calendarWeeks){
18957 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18958 v.attr('colspan', function(i, val){
18959 return parseInt(val) + 1;
18964 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18966 this.setStartDate(this.startDate);
18967 this.setEndDate(this.endDate);
18969 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18976 if(this.isInline) {
18981 picker : function()
18983 return this.pickerEl;
18984 // return this.el.select('.datepicker', true).first();
18987 fillDow: function()
18989 var dowCnt = this.weekStart;
18998 if(this.calendarWeeks){
19006 while (dowCnt < this.weekStart + 7) {
19010 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19014 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19017 fillMonths: function()
19020 var months = this.picker().select('>.datepicker-months td', true).first();
19022 months.dom.innerHTML = '';
19028 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19031 months.createChild(month);
19038 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;
19040 if (this.date < this.startDate) {
19041 this.viewDate = new Date(this.startDate);
19042 } else if (this.date > this.endDate) {
19043 this.viewDate = new Date(this.endDate);
19045 this.viewDate = new Date(this.date);
19053 var d = new Date(this.viewDate),
19054 year = d.getUTCFullYear(),
19055 month = d.getUTCMonth(),
19056 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19057 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19058 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19059 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19060 currentDate = this.date && this.date.valueOf(),
19061 today = this.UTCToday();
19063 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19065 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19067 // this.picker.select('>tfoot th.today').
19068 // .text(dates[this.language].today)
19069 // .toggle(this.todayBtn !== false);
19071 this.updateNavArrows();
19074 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19076 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19078 prevMonth.setUTCDate(day);
19080 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19082 var nextMonth = new Date(prevMonth);
19084 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19086 nextMonth = nextMonth.valueOf();
19088 var fillMonths = false;
19090 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19092 while(prevMonth.valueOf() <= nextMonth) {
19095 if (prevMonth.getUTCDay() === this.weekStart) {
19097 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19105 if(this.calendarWeeks){
19106 // ISO 8601: First week contains first thursday.
19107 // ISO also states week starts on Monday, but we can be more abstract here.
19109 // Start of current week: based on weekstart/current date
19110 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19111 // Thursday of this week
19112 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19113 // First Thursday of year, year from thursday
19114 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19115 // Calendar week: ms between thursdays, div ms per day, div 7 days
19116 calWeek = (th - yth) / 864e5 / 7 + 1;
19118 fillMonths.cn.push({
19126 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19128 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19131 if (this.todayHighlight &&
19132 prevMonth.getUTCFullYear() == today.getFullYear() &&
19133 prevMonth.getUTCMonth() == today.getMonth() &&
19134 prevMonth.getUTCDate() == today.getDate()) {
19135 clsName += ' today';
19138 if (currentDate && prevMonth.valueOf() === currentDate) {
19139 clsName += ' active';
19142 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19143 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19144 clsName += ' disabled';
19147 fillMonths.cn.push({
19149 cls: 'day ' + clsName,
19150 html: prevMonth.getDate()
19153 prevMonth.setDate(prevMonth.getDate()+1);
19156 var currentYear = this.date && this.date.getUTCFullYear();
19157 var currentMonth = this.date && this.date.getUTCMonth();
19159 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19161 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19162 v.removeClass('active');
19164 if(currentYear === year && k === currentMonth){
19165 v.addClass('active');
19168 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19169 v.addClass('disabled');
19175 year = parseInt(year/10, 10) * 10;
19177 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19179 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19182 for (var i = -1; i < 11; i++) {
19183 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19185 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19193 showMode: function(dir)
19196 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19199 Roo.each(this.picker().select('>div',true).elements, function(v){
19200 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19203 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19208 if(this.isInline) {
19212 this.picker().removeClass(['bottom', 'top']);
19214 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19216 * place to the top of element!
19220 this.picker().addClass('top');
19221 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19226 this.picker().addClass('bottom');
19228 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19231 parseDate : function(value)
19233 if(!value || value instanceof Date){
19236 var v = Date.parseDate(value, this.format);
19237 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19238 v = Date.parseDate(value, 'Y-m-d');
19240 if(!v && this.altFormats){
19241 if(!this.altFormatsArray){
19242 this.altFormatsArray = this.altFormats.split("|");
19244 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19245 v = Date.parseDate(value, this.altFormatsArray[i]);
19251 formatDate : function(date, fmt)
19253 return (!date || !(date instanceof Date)) ?
19254 date : date.dateFormat(fmt || this.format);
19257 onFocus : function()
19259 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19263 onBlur : function()
19265 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19267 var d = this.inputEl().getValue();
19274 showPopup : function()
19276 this.picker().show();
19280 this.fireEvent('showpopup', this, this.date);
19283 hidePopup : function()
19285 if(this.isInline) {
19288 this.picker().hide();
19289 this.viewMode = this.startViewMode;
19292 this.fireEvent('hidepopup', this, this.date);
19296 onMousedown: function(e)
19298 e.stopPropagation();
19299 e.preventDefault();
19304 Roo.bootstrap.DateField.superclass.keyup.call(this);
19308 setValue: function(v)
19310 if(this.fireEvent('beforeselect', this, v) !== false){
19311 var d = new Date(this.parseDate(v) ).clearTime();
19313 if(isNaN(d.getTime())){
19314 this.date = this.viewDate = '';
19315 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19319 v = this.formatDate(d);
19321 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19323 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19327 this.fireEvent('select', this, this.date);
19331 getValue: function()
19333 return this.formatDate(this.date);
19336 fireKey: function(e)
19338 if (!this.picker().isVisible()){
19339 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19345 var dateChanged = false,
19347 newDate, newViewDate;
19352 e.preventDefault();
19356 if (!this.keyboardNavigation) {
19359 dir = e.keyCode == 37 ? -1 : 1;
19362 newDate = this.moveYear(this.date, dir);
19363 newViewDate = this.moveYear(this.viewDate, dir);
19364 } else if (e.shiftKey){
19365 newDate = this.moveMonth(this.date, dir);
19366 newViewDate = this.moveMonth(this.viewDate, dir);
19368 newDate = new Date(this.date);
19369 newDate.setUTCDate(this.date.getUTCDate() + dir);
19370 newViewDate = new Date(this.viewDate);
19371 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19373 if (this.dateWithinRange(newDate)){
19374 this.date = newDate;
19375 this.viewDate = newViewDate;
19376 this.setValue(this.formatDate(this.date));
19378 e.preventDefault();
19379 dateChanged = true;
19384 if (!this.keyboardNavigation) {
19387 dir = e.keyCode == 38 ? -1 : 1;
19389 newDate = this.moveYear(this.date, dir);
19390 newViewDate = this.moveYear(this.viewDate, dir);
19391 } else if (e.shiftKey){
19392 newDate = this.moveMonth(this.date, dir);
19393 newViewDate = this.moveMonth(this.viewDate, dir);
19395 newDate = new Date(this.date);
19396 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19397 newViewDate = new Date(this.viewDate);
19398 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19400 if (this.dateWithinRange(newDate)){
19401 this.date = newDate;
19402 this.viewDate = newViewDate;
19403 this.setValue(this.formatDate(this.date));
19405 e.preventDefault();
19406 dateChanged = true;
19410 this.setValue(this.formatDate(this.date));
19412 e.preventDefault();
19415 this.setValue(this.formatDate(this.date));
19429 onClick: function(e)
19431 e.stopPropagation();
19432 e.preventDefault();
19434 var target = e.getTarget();
19436 if(target.nodeName.toLowerCase() === 'i'){
19437 target = Roo.get(target).dom.parentNode;
19440 var nodeName = target.nodeName;
19441 var className = target.className;
19442 var html = target.innerHTML;
19443 //Roo.log(nodeName);
19445 switch(nodeName.toLowerCase()) {
19447 switch(className) {
19453 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19454 switch(this.viewMode){
19456 this.viewDate = this.moveMonth(this.viewDate, dir);
19460 this.viewDate = this.moveYear(this.viewDate, dir);
19466 var date = new Date();
19467 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19469 this.setValue(this.formatDate(this.date));
19476 if (className.indexOf('disabled') < 0) {
19477 this.viewDate.setUTCDate(1);
19478 if (className.indexOf('month') > -1) {
19479 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19481 var year = parseInt(html, 10) || 0;
19482 this.viewDate.setUTCFullYear(year);
19486 if(this.singleMode){
19487 this.setValue(this.formatDate(this.viewDate));
19498 //Roo.log(className);
19499 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19500 var day = parseInt(html, 10) || 1;
19501 var year = this.viewDate.getUTCFullYear(),
19502 month = this.viewDate.getUTCMonth();
19504 if (className.indexOf('old') > -1) {
19511 } else if (className.indexOf('new') > -1) {
19519 //Roo.log([year,month,day]);
19520 this.date = this.UTCDate(year, month, day,0,0,0,0);
19521 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19523 //Roo.log(this.formatDate(this.date));
19524 this.setValue(this.formatDate(this.date));
19531 setStartDate: function(startDate)
19533 this.startDate = startDate || -Infinity;
19534 if (this.startDate !== -Infinity) {
19535 this.startDate = this.parseDate(this.startDate);
19538 this.updateNavArrows();
19541 setEndDate: function(endDate)
19543 this.endDate = endDate || Infinity;
19544 if (this.endDate !== Infinity) {
19545 this.endDate = this.parseDate(this.endDate);
19548 this.updateNavArrows();
19551 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19553 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19554 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19555 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19557 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19558 return parseInt(d, 10);
19561 this.updateNavArrows();
19564 updateNavArrows: function()
19566 if(this.singleMode){
19570 var d = new Date(this.viewDate),
19571 year = d.getUTCFullYear(),
19572 month = d.getUTCMonth();
19574 Roo.each(this.picker().select('.prev', true).elements, function(v){
19576 switch (this.viewMode) {
19579 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19585 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19592 Roo.each(this.picker().select('.next', true).elements, function(v){
19594 switch (this.viewMode) {
19597 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19603 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19611 moveMonth: function(date, dir)
19616 var new_date = new Date(date.valueOf()),
19617 day = new_date.getUTCDate(),
19618 month = new_date.getUTCMonth(),
19619 mag = Math.abs(dir),
19621 dir = dir > 0 ? 1 : -1;
19624 // If going back one month, make sure month is not current month
19625 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19627 return new_date.getUTCMonth() == month;
19629 // If going forward one month, make sure month is as expected
19630 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19632 return new_date.getUTCMonth() != new_month;
19634 new_month = month + dir;
19635 new_date.setUTCMonth(new_month);
19636 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19637 if (new_month < 0 || new_month > 11) {
19638 new_month = (new_month + 12) % 12;
19641 // For magnitudes >1, move one month at a time...
19642 for (var i=0; i<mag; i++) {
19643 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19644 new_date = this.moveMonth(new_date, dir);
19646 // ...then reset the day, keeping it in the new month
19647 new_month = new_date.getUTCMonth();
19648 new_date.setUTCDate(day);
19650 return new_month != new_date.getUTCMonth();
19653 // Common date-resetting loop -- if date is beyond end of month, make it
19656 new_date.setUTCDate(--day);
19657 new_date.setUTCMonth(new_month);
19662 moveYear: function(date, dir)
19664 return this.moveMonth(date, dir*12);
19667 dateWithinRange: function(date)
19669 return date >= this.startDate && date <= this.endDate;
19675 this.picker().remove();
19678 validateValue : function(value)
19680 if(this.getVisibilityEl().hasClass('hidden')){
19684 if(value.length < 1) {
19685 if(this.allowBlank){
19691 if(value.length < this.minLength){
19694 if(value.length > this.maxLength){
19698 var vt = Roo.form.VTypes;
19699 if(!vt[this.vtype](value, this)){
19703 if(typeof this.validator == "function"){
19704 var msg = this.validator(value);
19710 if(this.regex && !this.regex.test(value)){
19714 if(typeof(this.parseDate(value)) == 'undefined'){
19718 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19722 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19732 this.date = this.viewDate = '';
19734 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19739 Roo.apply(Roo.bootstrap.DateField, {
19750 html: '<i class="fa fa-arrow-left"/>'
19760 html: '<i class="fa fa-arrow-right"/>'
19802 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19803 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19804 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19805 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19806 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19819 navFnc: 'FullYear',
19824 navFnc: 'FullYear',
19829 Roo.apply(Roo.bootstrap.DateField, {
19833 cls: 'datepicker dropdown-menu roo-dynamic',
19837 cls: 'datepicker-days',
19841 cls: 'table-condensed',
19843 Roo.bootstrap.DateField.head,
19847 Roo.bootstrap.DateField.footer
19854 cls: 'datepicker-months',
19858 cls: 'table-condensed',
19860 Roo.bootstrap.DateField.head,
19861 Roo.bootstrap.DateField.content,
19862 Roo.bootstrap.DateField.footer
19869 cls: 'datepicker-years',
19873 cls: 'table-condensed',
19875 Roo.bootstrap.DateField.head,
19876 Roo.bootstrap.DateField.content,
19877 Roo.bootstrap.DateField.footer
19896 * @class Roo.bootstrap.TimeField
19897 * @extends Roo.bootstrap.Input
19898 * Bootstrap DateField class
19902 * Create a new TimeField
19903 * @param {Object} config The config object
19906 Roo.bootstrap.TimeField = function(config){
19907 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19911 * Fires when this field show.
19912 * @param {Roo.bootstrap.DateField} thisthis
19913 * @param {Mixed} date The date value
19918 * Fires when this field hide.
19919 * @param {Roo.bootstrap.DateField} this
19920 * @param {Mixed} date The date value
19925 * Fires when select a date.
19926 * @param {Roo.bootstrap.DateField} this
19927 * @param {Mixed} date The date value
19933 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19936 * @cfg {String} format
19937 * The default time format string which can be overriden for localization support. The format must be
19938 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19942 onRender: function(ct, position)
19945 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19947 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19949 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19951 this.pop = this.picker().select('>.datepicker-time',true).first();
19952 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19954 this.picker().on('mousedown', this.onMousedown, this);
19955 this.picker().on('click', this.onClick, this);
19957 this.picker().addClass('datepicker-dropdown');
19962 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19963 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19964 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19965 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19966 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19967 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19971 fireKey: function(e){
19972 if (!this.picker().isVisible()){
19973 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19979 e.preventDefault();
19987 this.onTogglePeriod();
19990 this.onIncrementMinutes();
19993 this.onDecrementMinutes();
20002 onClick: function(e) {
20003 e.stopPropagation();
20004 e.preventDefault();
20007 picker : function()
20009 return this.el.select('.datepicker', true).first();
20012 fillTime: function()
20014 var time = this.pop.select('tbody', true).first();
20016 time.dom.innerHTML = '';
20031 cls: 'hours-up glyphicon glyphicon-chevron-up'
20051 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20072 cls: 'timepicker-hour',
20087 cls: 'timepicker-minute',
20102 cls: 'btn btn-primary period',
20124 cls: 'hours-down glyphicon glyphicon-chevron-down'
20144 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20162 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20169 var hours = this.time.getHours();
20170 var minutes = this.time.getMinutes();
20183 hours = hours - 12;
20187 hours = '0' + hours;
20191 minutes = '0' + minutes;
20194 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20195 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20196 this.pop.select('button', true).first().dom.innerHTML = period;
20202 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20204 var cls = ['bottom'];
20206 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20213 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20218 this.picker().addClass(cls.join('-'));
20222 Roo.each(cls, function(c){
20224 _this.picker().setTop(_this.inputEl().getHeight());
20228 _this.picker().setTop(0 - _this.picker().getHeight());
20233 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20237 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20244 onFocus : function()
20246 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20250 onBlur : function()
20252 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20258 this.picker().show();
20263 this.fireEvent('show', this, this.date);
20268 this.picker().hide();
20271 this.fireEvent('hide', this, this.date);
20274 setTime : function()
20277 this.setValue(this.time.format(this.format));
20279 this.fireEvent('select', this, this.date);
20284 onMousedown: function(e){
20285 e.stopPropagation();
20286 e.preventDefault();
20289 onIncrementHours: function()
20291 Roo.log('onIncrementHours');
20292 this.time = this.time.add(Date.HOUR, 1);
20297 onDecrementHours: function()
20299 Roo.log('onDecrementHours');
20300 this.time = this.time.add(Date.HOUR, -1);
20304 onIncrementMinutes: function()
20306 Roo.log('onIncrementMinutes');
20307 this.time = this.time.add(Date.MINUTE, 1);
20311 onDecrementMinutes: function()
20313 Roo.log('onDecrementMinutes');
20314 this.time = this.time.add(Date.MINUTE, -1);
20318 onTogglePeriod: function()
20320 Roo.log('onTogglePeriod');
20321 this.time = this.time.add(Date.HOUR, 12);
20328 Roo.apply(Roo.bootstrap.TimeField, {
20358 cls: 'btn btn-info ok',
20370 Roo.apply(Roo.bootstrap.TimeField, {
20374 cls: 'datepicker dropdown-menu',
20378 cls: 'datepicker-time',
20382 cls: 'table-condensed',
20384 Roo.bootstrap.TimeField.content,
20385 Roo.bootstrap.TimeField.footer
20404 * @class Roo.bootstrap.MonthField
20405 * @extends Roo.bootstrap.Input
20406 * Bootstrap MonthField class
20408 * @cfg {String} language default en
20411 * Create a new MonthField
20412 * @param {Object} config The config object
20415 Roo.bootstrap.MonthField = function(config){
20416 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20421 * Fires when this field show.
20422 * @param {Roo.bootstrap.MonthField} this
20423 * @param {Mixed} date The date value
20428 * Fires when this field hide.
20429 * @param {Roo.bootstrap.MonthField} this
20430 * @param {Mixed} date The date value
20435 * Fires when select a date.
20436 * @param {Roo.bootstrap.MonthField} this
20437 * @param {String} oldvalue The old value
20438 * @param {String} newvalue The new value
20444 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20446 onRender: function(ct, position)
20449 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20451 this.language = this.language || 'en';
20452 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20453 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20455 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20456 this.isInline = false;
20457 this.isInput = true;
20458 this.component = this.el.select('.add-on', true).first() || false;
20459 this.component = (this.component && this.component.length === 0) ? false : this.component;
20460 this.hasInput = this.component && this.inputEL().length;
20462 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20464 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20466 this.picker().on('mousedown', this.onMousedown, this);
20467 this.picker().on('click', this.onClick, this);
20469 this.picker().addClass('datepicker-dropdown');
20471 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20472 v.setStyle('width', '189px');
20479 if(this.isInline) {
20485 setValue: function(v, suppressEvent)
20487 var o = this.getValue();
20489 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20493 if(suppressEvent !== true){
20494 this.fireEvent('select', this, o, v);
20499 getValue: function()
20504 onClick: function(e)
20506 e.stopPropagation();
20507 e.preventDefault();
20509 var target = e.getTarget();
20511 if(target.nodeName.toLowerCase() === 'i'){
20512 target = Roo.get(target).dom.parentNode;
20515 var nodeName = target.nodeName;
20516 var className = target.className;
20517 var html = target.innerHTML;
20519 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20523 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20525 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20531 picker : function()
20533 return this.pickerEl;
20536 fillMonths: function()
20539 var months = this.picker().select('>.datepicker-months td', true).first();
20541 months.dom.innerHTML = '';
20547 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20550 months.createChild(month);
20559 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20560 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20563 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20564 e.removeClass('active');
20566 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20567 e.addClass('active');
20574 if(this.isInline) {
20578 this.picker().removeClass(['bottom', 'top']);
20580 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20582 * place to the top of element!
20586 this.picker().addClass('top');
20587 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20592 this.picker().addClass('bottom');
20594 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20597 onFocus : function()
20599 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20603 onBlur : function()
20605 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20607 var d = this.inputEl().getValue();
20616 this.picker().show();
20617 this.picker().select('>.datepicker-months', true).first().show();
20621 this.fireEvent('show', this, this.date);
20626 if(this.isInline) {
20629 this.picker().hide();
20630 this.fireEvent('hide', this, this.date);
20634 onMousedown: function(e)
20636 e.stopPropagation();
20637 e.preventDefault();
20642 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20646 fireKey: function(e)
20648 if (!this.picker().isVisible()){
20649 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20660 e.preventDefault();
20664 dir = e.keyCode == 37 ? -1 : 1;
20666 this.vIndex = this.vIndex + dir;
20668 if(this.vIndex < 0){
20672 if(this.vIndex > 11){
20676 if(isNaN(this.vIndex)){
20680 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20686 dir = e.keyCode == 38 ? -1 : 1;
20688 this.vIndex = this.vIndex + dir * 4;
20690 if(this.vIndex < 0){
20694 if(this.vIndex > 11){
20698 if(isNaN(this.vIndex)){
20702 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20707 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20708 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20712 e.preventDefault();
20715 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20716 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20732 this.picker().remove();
20737 Roo.apply(Roo.bootstrap.MonthField, {
20756 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20757 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20762 Roo.apply(Roo.bootstrap.MonthField, {
20766 cls: 'datepicker dropdown-menu roo-dynamic',
20770 cls: 'datepicker-months',
20774 cls: 'table-condensed',
20776 Roo.bootstrap.DateField.content
20796 * @class Roo.bootstrap.CheckBox
20797 * @extends Roo.bootstrap.Input
20798 * Bootstrap CheckBox class
20800 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20801 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20802 * @cfg {String} boxLabel The text that appears beside the checkbox
20803 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20804 * @cfg {Boolean} checked initnal the element
20805 * @cfg {Boolean} inline inline the element (default false)
20806 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20807 * @cfg {String} tooltip label tooltip
20810 * Create a new CheckBox
20811 * @param {Object} config The config object
20814 Roo.bootstrap.CheckBox = function(config){
20815 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20820 * Fires when the element is checked or unchecked.
20821 * @param {Roo.bootstrap.CheckBox} this This input
20822 * @param {Boolean} checked The new checked value
20827 * Fires when the element is click.
20828 * @param {Roo.bootstrap.CheckBox} this This input
20835 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20837 inputType: 'checkbox',
20846 getAutoCreate : function()
20848 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20854 cfg.cls = 'form-group ' + this.inputType; //input-group
20857 cfg.cls += ' ' + this.inputType + '-inline';
20863 type : this.inputType,
20864 value : this.inputValue,
20865 cls : 'roo-' + this.inputType, //'form-box',
20866 placeholder : this.placeholder || ''
20870 if(this.inputType != 'radio'){
20874 cls : 'roo-hidden-value',
20875 value : this.checked ? this.inputValue : this.valueOff
20880 if (this.weight) { // Validity check?
20881 cfg.cls += " " + this.inputType + "-" + this.weight;
20884 if (this.disabled) {
20885 input.disabled=true;
20889 input.checked = this.checked;
20894 input.name = this.name;
20896 if(this.inputType != 'radio'){
20897 hidden.name = this.name;
20898 input.name = '_hidden_' + this.name;
20903 input.cls += ' input-' + this.size;
20908 ['xs','sm','md','lg'].map(function(size){
20909 if (settings[size]) {
20910 cfg.cls += ' col-' + size + '-' + settings[size];
20914 var inputblock = input;
20916 if (this.before || this.after) {
20919 cls : 'input-group',
20924 inputblock.cn.push({
20926 cls : 'input-group-addon',
20931 inputblock.cn.push(input);
20933 if(this.inputType != 'radio'){
20934 inputblock.cn.push(hidden);
20938 inputblock.cn.push({
20940 cls : 'input-group-addon',
20947 if (align ==='left' && this.fieldLabel.length) {
20948 // Roo.log("left and has label");
20953 cls : 'control-label',
20954 html : this.fieldLabel
20964 if(this.labelWidth > 12){
20965 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20968 if(this.labelWidth < 13 && this.labelmd == 0){
20969 this.labelmd = this.labelWidth;
20972 if(this.labellg > 0){
20973 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20974 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20977 if(this.labelmd > 0){
20978 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20979 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20982 if(this.labelsm > 0){
20983 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20984 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20987 if(this.labelxs > 0){
20988 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20989 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20992 } else if ( this.fieldLabel.length) {
20993 // Roo.log(" label");
20997 tag: this.boxLabel ? 'span' : 'label',
20999 cls: 'control-label box-input-label',
21000 //cls : 'input-group-addon',
21001 html : this.fieldLabel
21010 // Roo.log(" no label && no align");
21011 cfg.cn = [ inputblock ] ;
21017 var boxLabelCfg = {
21019 //'for': id, // box label is handled by onclick - so no for...
21021 html: this.boxLabel
21025 boxLabelCfg.tooltip = this.tooltip;
21028 cfg.cn.push(boxLabelCfg);
21031 if(this.inputType != 'radio'){
21032 cfg.cn.push(hidden);
21040 * return the real input element.
21042 inputEl: function ()
21044 return this.el.select('input.roo-' + this.inputType,true).first();
21046 hiddenEl: function ()
21048 return this.el.select('input.roo-hidden-value',true).first();
21051 labelEl: function()
21053 return this.el.select('label.control-label',true).first();
21055 /* depricated... */
21059 return this.labelEl();
21062 boxLabelEl: function()
21064 return this.el.select('label.box-label',true).first();
21067 initEvents : function()
21069 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21071 this.inputEl().on('click', this.onClick, this);
21073 if (this.boxLabel) {
21074 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21077 this.startValue = this.getValue();
21080 Roo.bootstrap.CheckBox.register(this);
21084 onClick : function(e)
21086 if(this.fireEvent('click', this, e) !== false){
21087 this.setChecked(!this.checked);
21092 setChecked : function(state,suppressEvent)
21094 this.startValue = this.getValue();
21096 if(this.inputType == 'radio'){
21098 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21099 e.dom.checked = false;
21102 this.inputEl().dom.checked = true;
21104 this.inputEl().dom.value = this.inputValue;
21106 if(suppressEvent !== true){
21107 this.fireEvent('check', this, true);
21115 this.checked = state;
21117 this.inputEl().dom.checked = state;
21120 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21122 if(suppressEvent !== true){
21123 this.fireEvent('check', this, state);
21129 getValue : function()
21131 if(this.inputType == 'radio'){
21132 return this.getGroupValue();
21135 return this.hiddenEl().dom.value;
21139 getGroupValue : function()
21141 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21145 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21148 setValue : function(v,suppressEvent)
21150 if(this.inputType == 'radio'){
21151 this.setGroupValue(v, suppressEvent);
21155 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21160 setGroupValue : function(v, suppressEvent)
21162 this.startValue = this.getValue();
21164 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21165 e.dom.checked = false;
21167 if(e.dom.value == v){
21168 e.dom.checked = true;
21172 if(suppressEvent !== true){
21173 this.fireEvent('check', this, true);
21181 validate : function()
21183 if(this.getVisibilityEl().hasClass('hidden')){
21189 (this.inputType == 'radio' && this.validateRadio()) ||
21190 (this.inputType == 'checkbox' && this.validateCheckbox())
21196 this.markInvalid();
21200 validateRadio : function()
21202 if(this.getVisibilityEl().hasClass('hidden')){
21206 if(this.allowBlank){
21212 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21213 if(!e.dom.checked){
21225 validateCheckbox : function()
21228 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21229 //return (this.getValue() == this.inputValue) ? true : false;
21232 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21240 for(var i in group){
21241 if(group[i].el.isVisible(true)){
21249 for(var i in group){
21254 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21261 * Mark this field as valid
21263 markValid : function()
21267 this.fireEvent('valid', this);
21269 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21272 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21279 if(this.inputType == 'radio'){
21280 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21281 var fg = e.findParent('.form-group', false, true);
21282 if (Roo.bootstrap.version == 3) {
21283 fg.removeClass([_this.invalidClass, _this.validClass]);
21284 fg.addClass(_this.validClass);
21286 fg.removeClass(['is-valid', 'is-invalid']);
21287 fg.addClass('is-valid');
21295 var fg = this.el.findParent('.form-group', false, true);
21296 if (Roo.bootstrap.version == 3) {
21297 fg.removeClass([this.invalidClass, this.validClass]);
21298 fg.addClass(this.validClass);
21300 fg.removeClass(['is-valid', 'is-invalid']);
21301 fg.addClass('is-valid');
21306 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21312 for(var i in group){
21313 var fg = group[i].el.findParent('.form-group', false, true);
21314 if (Roo.bootstrap.version == 3) {
21315 fg.removeClass([this.invalidClass, this.validClass]);
21316 fg.addClass(this.validClass);
21318 fg.removeClass(['is-valid', 'is-invalid']);
21319 fg.addClass('is-valid');
21325 * Mark this field as invalid
21326 * @param {String} msg The validation message
21328 markInvalid : function(msg)
21330 if(this.allowBlank){
21336 this.fireEvent('invalid', this, msg);
21338 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21341 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21345 label.markInvalid();
21348 if(this.inputType == 'radio'){
21350 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21351 var fg = e.findParent('.form-group', false, true);
21352 if (Roo.bootstrap.version == 3) {
21353 fg.removeClass([_this.invalidClass, _this.validClass]);
21354 fg.addClass(_this.invalidClass);
21356 fg.removeClass(['is-invalid', 'is-valid']);
21357 fg.addClass('is-invalid');
21365 var fg = this.el.findParent('.form-group', false, true);
21366 if (Roo.bootstrap.version == 3) {
21367 fg.removeClass([_this.invalidClass, _this.validClass]);
21368 fg.addClass(_this.invalidClass);
21370 fg.removeClass(['is-invalid', 'is-valid']);
21371 fg.addClass('is-invalid');
21376 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21382 for(var i in group){
21383 var fg = group[i].el.findParent('.form-group', false, true);
21384 if (Roo.bootstrap.version == 3) {
21385 fg.removeClass([_this.invalidClass, _this.validClass]);
21386 fg.addClass(_this.invalidClass);
21388 fg.removeClass(['is-invalid', 'is-valid']);
21389 fg.addClass('is-invalid');
21395 clearInvalid : function()
21397 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21399 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21401 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21403 if (label && label.iconEl) {
21404 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21405 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21409 disable : function()
21411 if(this.inputType != 'radio'){
21412 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21419 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21420 _this.getActionEl().addClass(this.disabledClass);
21421 e.dom.disabled = true;
21425 this.disabled = true;
21426 this.fireEvent("disable", this);
21430 enable : function()
21432 if(this.inputType != 'radio'){
21433 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21440 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21441 _this.getActionEl().removeClass(this.disabledClass);
21442 e.dom.disabled = false;
21446 this.disabled = false;
21447 this.fireEvent("enable", this);
21451 setBoxLabel : function(v)
21456 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21462 Roo.apply(Roo.bootstrap.CheckBox, {
21467 * register a CheckBox Group
21468 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21470 register : function(checkbox)
21472 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21473 this.groups[checkbox.groupId] = {};
21476 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21480 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21484 * fetch a CheckBox Group based on the group ID
21485 * @param {string} the group ID
21486 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21488 get: function(groupId) {
21489 if (typeof(this.groups[groupId]) == 'undefined') {
21493 return this.groups[groupId] ;
21506 * @class Roo.bootstrap.Radio
21507 * @extends Roo.bootstrap.Component
21508 * Bootstrap Radio class
21509 * @cfg {String} boxLabel - the label associated
21510 * @cfg {String} value - the value of radio
21513 * Create a new Radio
21514 * @param {Object} config The config object
21516 Roo.bootstrap.Radio = function(config){
21517 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21521 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21527 getAutoCreate : function()
21531 cls : 'form-group radio',
21536 html : this.boxLabel
21544 initEvents : function()
21546 this.parent().register(this);
21548 this.el.on('click', this.onClick, this);
21552 onClick : function(e)
21554 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21555 this.setChecked(true);
21559 setChecked : function(state, suppressEvent)
21561 this.parent().setValue(this.value, suppressEvent);
21565 setBoxLabel : function(v)
21570 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21585 * @class Roo.bootstrap.SecurePass
21586 * @extends Roo.bootstrap.Input
21587 * Bootstrap SecurePass class
21591 * Create a new SecurePass
21592 * @param {Object} config The config object
21595 Roo.bootstrap.SecurePass = function (config) {
21596 // these go here, so the translation tool can replace them..
21598 PwdEmpty: "Please type a password, and then retype it to confirm.",
21599 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21600 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21601 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21602 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21603 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21604 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21605 TooWeak: "Your password is Too Weak."
21607 this.meterLabel = "Password strength:";
21608 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21609 this.meterClass = [
21610 "roo-password-meter-tooweak",
21611 "roo-password-meter-weak",
21612 "roo-password-meter-medium",
21613 "roo-password-meter-strong",
21614 "roo-password-meter-grey"
21619 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21622 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21624 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21626 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21627 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21628 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21629 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21630 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21631 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21632 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21642 * @cfg {String/Object} Label for the strength meter (defaults to
21643 * 'Password strength:')
21648 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21649 * ['Weak', 'Medium', 'Strong'])
21652 pwdStrengths: false,
21665 initEvents: function ()
21667 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21669 if (this.el.is('input[type=password]') && Roo.isSafari) {
21670 this.el.on('keydown', this.SafariOnKeyDown, this);
21673 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21676 onRender: function (ct, position)
21678 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21679 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21680 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21682 this.trigger.createChild({
21687 cls: 'roo-password-meter-grey col-xs-12',
21690 //width: this.meterWidth + 'px'
21694 cls: 'roo-password-meter-text'
21700 if (this.hideTrigger) {
21701 this.trigger.setDisplayed(false);
21703 this.setSize(this.width || '', this.height || '');
21706 onDestroy: function ()
21708 if (this.trigger) {
21709 this.trigger.removeAllListeners();
21710 this.trigger.remove();
21713 this.wrap.remove();
21715 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21718 checkStrength: function ()
21720 var pwd = this.inputEl().getValue();
21721 if (pwd == this._lastPwd) {
21726 if (this.ClientSideStrongPassword(pwd)) {
21728 } else if (this.ClientSideMediumPassword(pwd)) {
21730 } else if (this.ClientSideWeakPassword(pwd)) {
21736 Roo.log('strength1: ' + strength);
21738 //var pm = this.trigger.child('div/div/div').dom;
21739 var pm = this.trigger.child('div/div');
21740 pm.removeClass(this.meterClass);
21741 pm.addClass(this.meterClass[strength]);
21744 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21746 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21748 this._lastPwd = pwd;
21752 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21754 this._lastPwd = '';
21756 var pm = this.trigger.child('div/div');
21757 pm.removeClass(this.meterClass);
21758 pm.addClass('roo-password-meter-grey');
21761 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21764 this.inputEl().dom.type='password';
21767 validateValue: function (value)
21770 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21773 if (value.length == 0) {
21774 if (this.allowBlank) {
21775 this.clearInvalid();
21779 this.markInvalid(this.errors.PwdEmpty);
21780 this.errorMsg = this.errors.PwdEmpty;
21788 if ('[\x21-\x7e]*'.match(value)) {
21789 this.markInvalid(this.errors.PwdBadChar);
21790 this.errorMsg = this.errors.PwdBadChar;
21793 if (value.length < 6) {
21794 this.markInvalid(this.errors.PwdShort);
21795 this.errorMsg = this.errors.PwdShort;
21798 if (value.length > 16) {
21799 this.markInvalid(this.errors.PwdLong);
21800 this.errorMsg = this.errors.PwdLong;
21804 if (this.ClientSideStrongPassword(value)) {
21806 } else if (this.ClientSideMediumPassword(value)) {
21808 } else if (this.ClientSideWeakPassword(value)) {
21815 if (strength < 2) {
21816 //this.markInvalid(this.errors.TooWeak);
21817 this.errorMsg = this.errors.TooWeak;
21822 console.log('strength2: ' + strength);
21824 //var pm = this.trigger.child('div/div/div').dom;
21826 var pm = this.trigger.child('div/div');
21827 pm.removeClass(this.meterClass);
21828 pm.addClass(this.meterClass[strength]);
21830 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21832 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21834 this.errorMsg = '';
21838 CharacterSetChecks: function (type)
21841 this.fResult = false;
21844 isctype: function (character, type)
21847 case this.kCapitalLetter:
21848 if (character >= 'A' && character <= 'Z') {
21853 case this.kSmallLetter:
21854 if (character >= 'a' && character <= 'z') {
21860 if (character >= '0' && character <= '9') {
21865 case this.kPunctuation:
21866 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21877 IsLongEnough: function (pwd, size)
21879 return !(pwd == null || isNaN(size) || pwd.length < size);
21882 SpansEnoughCharacterSets: function (word, nb)
21884 if (!this.IsLongEnough(word, nb))
21889 var characterSetChecks = new Array(
21890 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21891 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21894 for (var index = 0; index < word.length; ++index) {
21895 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21896 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21897 characterSetChecks[nCharSet].fResult = true;
21904 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21905 if (characterSetChecks[nCharSet].fResult) {
21910 if (nCharSets < nb) {
21916 ClientSideStrongPassword: function (pwd)
21918 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21921 ClientSideMediumPassword: function (pwd)
21923 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21926 ClientSideWeakPassword: function (pwd)
21928 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21931 })//<script type="text/javascript">
21934 * Based Ext JS Library 1.1.1
21935 * Copyright(c) 2006-2007, Ext JS, LLC.
21941 * @class Roo.HtmlEditorCore
21942 * @extends Roo.Component
21943 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21945 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21948 Roo.HtmlEditorCore = function(config){
21951 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21956 * @event initialize
21957 * Fires when the editor is fully initialized (including the iframe)
21958 * @param {Roo.HtmlEditorCore} this
21963 * Fires when the editor is first receives the focus. Any insertion must wait
21964 * until after this event.
21965 * @param {Roo.HtmlEditorCore} this
21969 * @event beforesync
21970 * Fires before the textarea is updated with content from the editor iframe. Return false
21971 * to cancel the sync.
21972 * @param {Roo.HtmlEditorCore} this
21973 * @param {String} html
21977 * @event beforepush
21978 * Fires before the iframe editor is updated with content from the textarea. Return false
21979 * to cancel the push.
21980 * @param {Roo.HtmlEditorCore} this
21981 * @param {String} html
21986 * Fires when the textarea is updated with content from the editor iframe.
21987 * @param {Roo.HtmlEditorCore} this
21988 * @param {String} html
21993 * Fires when the iframe editor is updated with content from the textarea.
21994 * @param {Roo.HtmlEditorCore} this
21995 * @param {String} html
22000 * @event editorevent
22001 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22002 * @param {Roo.HtmlEditorCore} this
22008 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22010 // defaults : white / black...
22011 this.applyBlacklists();
22018 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22022 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22028 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22033 * @cfg {Number} height (in pixels)
22037 * @cfg {Number} width (in pixels)
22042 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22045 stylesheets: false,
22050 // private properties
22051 validationEvent : false,
22053 initialized : false,
22055 sourceEditMode : false,
22056 onFocus : Roo.emptyFn,
22058 hideMode:'offsets',
22062 // blacklist + whitelisted elements..
22069 * Protected method that will not generally be called directly. It
22070 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22071 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22073 getDocMarkup : function(){
22077 // inherit styels from page...??
22078 if (this.stylesheets === false) {
22080 Roo.get(document.head).select('style').each(function(node) {
22081 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22084 Roo.get(document.head).select('link').each(function(node) {
22085 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22088 } else if (!this.stylesheets.length) {
22090 st = '<style type="text/css">' +
22091 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22094 st = '<style type="text/css">' +
22099 st += '<style type="text/css">' +
22100 'IMG { cursor: pointer } ' +
22103 var cls = 'roo-htmleditor-body';
22105 if(this.bodyCls.length){
22106 cls += ' ' + this.bodyCls;
22109 return '<html><head>' + st +
22110 //<style type="text/css">' +
22111 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22113 ' </head><body class="' + cls + '"></body></html>';
22117 onRender : function(ct, position)
22120 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22121 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22124 this.el.dom.style.border = '0 none';
22125 this.el.dom.setAttribute('tabIndex', -1);
22126 this.el.addClass('x-hidden hide');
22130 if(Roo.isIE){ // fix IE 1px bogus margin
22131 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22135 this.frameId = Roo.id();
22139 var iframe = this.owner.wrap.createChild({
22141 cls: 'form-control', // bootstrap..
22143 name: this.frameId,
22144 frameBorder : 'no',
22145 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22150 this.iframe = iframe.dom;
22152 this.assignDocWin();
22154 this.doc.designMode = 'on';
22157 this.doc.write(this.getDocMarkup());
22161 var task = { // must defer to wait for browser to be ready
22163 //console.log("run task?" + this.doc.readyState);
22164 this.assignDocWin();
22165 if(this.doc.body || this.doc.readyState == 'complete'){
22167 this.doc.designMode="on";
22171 Roo.TaskMgr.stop(task);
22172 this.initEditor.defer(10, this);
22179 Roo.TaskMgr.start(task);
22184 onResize : function(w, h)
22186 Roo.log('resize: ' +w + ',' + h );
22187 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22191 if(typeof w == 'number'){
22193 this.iframe.style.width = w + 'px';
22195 if(typeof h == 'number'){
22197 this.iframe.style.height = h + 'px';
22199 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22206 * Toggles the editor between standard and source edit mode.
22207 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22209 toggleSourceEdit : function(sourceEditMode){
22211 this.sourceEditMode = sourceEditMode === true;
22213 if(this.sourceEditMode){
22215 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22218 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22219 //this.iframe.className = '';
22222 //this.setSize(this.owner.wrap.getSize());
22223 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22230 * Protected method that will not generally be called directly. If you need/want
22231 * custom HTML cleanup, this is the method you should override.
22232 * @param {String} html The HTML to be cleaned
22233 * return {String} The cleaned HTML
22235 cleanHtml : function(html){
22236 html = String(html);
22237 if(html.length > 5){
22238 if(Roo.isSafari){ // strip safari nonsense
22239 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22242 if(html == ' '){
22249 * HTML Editor -> Textarea
22250 * Protected method that will not generally be called directly. Syncs the contents
22251 * of the editor iframe with the textarea.
22253 syncValue : function(){
22254 if(this.initialized){
22255 var bd = (this.doc.body || this.doc.documentElement);
22256 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22257 var html = bd.innerHTML;
22259 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22260 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22262 html = '<div style="'+m[0]+'">' + html + '</div>';
22265 html = this.cleanHtml(html);
22266 // fix up the special chars.. normaly like back quotes in word...
22267 // however we do not want to do this with chinese..
22268 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22269 var cc = b.charCodeAt();
22271 (cc >= 0x4E00 && cc < 0xA000 ) ||
22272 (cc >= 0x3400 && cc < 0x4E00 ) ||
22273 (cc >= 0xf900 && cc < 0xfb00 )
22279 if(this.owner.fireEvent('beforesync', this, html) !== false){
22280 this.el.dom.value = html;
22281 this.owner.fireEvent('sync', this, html);
22287 * Protected method that will not generally be called directly. Pushes the value of the textarea
22288 * into the iframe editor.
22290 pushValue : function(){
22291 if(this.initialized){
22292 var v = this.el.dom.value.trim();
22294 // if(v.length < 1){
22298 if(this.owner.fireEvent('beforepush', this, v) !== false){
22299 var d = (this.doc.body || this.doc.documentElement);
22301 this.cleanUpPaste();
22302 this.el.dom.value = d.innerHTML;
22303 this.owner.fireEvent('push', this, v);
22309 deferFocus : function(){
22310 this.focus.defer(10, this);
22314 focus : function(){
22315 if(this.win && !this.sourceEditMode){
22322 assignDocWin: function()
22324 var iframe = this.iframe;
22327 this.doc = iframe.contentWindow.document;
22328 this.win = iframe.contentWindow;
22330 // if (!Roo.get(this.frameId)) {
22333 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22334 // this.win = Roo.get(this.frameId).dom.contentWindow;
22336 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22340 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22341 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22346 initEditor : function(){
22347 //console.log("INIT EDITOR");
22348 this.assignDocWin();
22352 this.doc.designMode="on";
22354 this.doc.write(this.getDocMarkup());
22357 var dbody = (this.doc.body || this.doc.documentElement);
22358 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22359 // this copies styles from the containing element into thsi one..
22360 // not sure why we need all of this..
22361 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22363 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22364 //ss['background-attachment'] = 'fixed'; // w3c
22365 dbody.bgProperties = 'fixed'; // ie
22366 //Roo.DomHelper.applyStyles(dbody, ss);
22367 Roo.EventManager.on(this.doc, {
22368 //'mousedown': this.onEditorEvent,
22369 'mouseup': this.onEditorEvent,
22370 'dblclick': this.onEditorEvent,
22371 'click': this.onEditorEvent,
22372 'keyup': this.onEditorEvent,
22377 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22379 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22380 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22382 this.initialized = true;
22384 this.owner.fireEvent('initialize', this);
22389 onDestroy : function(){
22395 //for (var i =0; i < this.toolbars.length;i++) {
22396 // // fixme - ask toolbars for heights?
22397 // this.toolbars[i].onDestroy();
22400 //this.wrap.dom.innerHTML = '';
22401 //this.wrap.remove();
22406 onFirstFocus : function(){
22408 this.assignDocWin();
22411 this.activated = true;
22414 if(Roo.isGecko){ // prevent silly gecko errors
22416 var s = this.win.getSelection();
22417 if(!s.focusNode || s.focusNode.nodeType != 3){
22418 var r = s.getRangeAt(0);
22419 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22424 this.execCmd('useCSS', true);
22425 this.execCmd('styleWithCSS', false);
22428 this.owner.fireEvent('activate', this);
22432 adjustFont: function(btn){
22433 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22434 //if(Roo.isSafari){ // safari
22437 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22438 if(Roo.isSafari){ // safari
22439 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22440 v = (v < 10) ? 10 : v;
22441 v = (v > 48) ? 48 : v;
22442 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22447 v = Math.max(1, v+adjust);
22449 this.execCmd('FontSize', v );
22452 onEditorEvent : function(e)
22454 this.owner.fireEvent('editorevent', this, e);
22455 // this.updateToolbar();
22456 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22459 insertTag : function(tg)
22461 // could be a bit smarter... -> wrap the current selected tRoo..
22462 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22464 range = this.createRange(this.getSelection());
22465 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22466 wrappingNode.appendChild(range.extractContents());
22467 range.insertNode(wrappingNode);
22474 this.execCmd("formatblock", tg);
22478 insertText : function(txt)
22482 var range = this.createRange();
22483 range.deleteContents();
22484 //alert(Sender.getAttribute('label'));
22486 range.insertNode(this.doc.createTextNode(txt));
22492 * Executes a Midas editor command on the editor document and performs necessary focus and
22493 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22494 * @param {String} cmd The Midas command
22495 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22497 relayCmd : function(cmd, value){
22499 this.execCmd(cmd, value);
22500 this.owner.fireEvent('editorevent', this);
22501 //this.updateToolbar();
22502 this.owner.deferFocus();
22506 * Executes a Midas editor command directly on the editor document.
22507 * For visual commands, you should use {@link #relayCmd} instead.
22508 * <b>This should only be called after the editor is initialized.</b>
22509 * @param {String} cmd The Midas command
22510 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22512 execCmd : function(cmd, value){
22513 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22520 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22522 * @param {String} text | dom node..
22524 insertAtCursor : function(text)
22527 if(!this.activated){
22533 var r = this.doc.selection.createRange();
22544 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22548 // from jquery ui (MIT licenced)
22550 var win = this.win;
22552 if (win.getSelection && win.getSelection().getRangeAt) {
22553 range = win.getSelection().getRangeAt(0);
22554 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22555 range.insertNode(node);
22556 } else if (win.document.selection && win.document.selection.createRange) {
22557 // no firefox support
22558 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22559 win.document.selection.createRange().pasteHTML(txt);
22561 // no firefox support
22562 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22563 this.execCmd('InsertHTML', txt);
22572 mozKeyPress : function(e){
22574 var c = e.getCharCode(), cmd;
22577 c = String.fromCharCode(c).toLowerCase();
22591 this.cleanUpPaste.defer(100, this);
22599 e.preventDefault();
22607 fixKeys : function(){ // load time branching for fastest keydown performance
22609 return function(e){
22610 var k = e.getKey(), r;
22613 r = this.doc.selection.createRange();
22616 r.pasteHTML('    ');
22623 r = this.doc.selection.createRange();
22625 var target = r.parentElement();
22626 if(!target || target.tagName.toLowerCase() != 'li'){
22628 r.pasteHTML('<br />');
22634 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22635 this.cleanUpPaste.defer(100, this);
22641 }else if(Roo.isOpera){
22642 return function(e){
22643 var k = e.getKey();
22647 this.execCmd('InsertHTML','    ');
22650 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22651 this.cleanUpPaste.defer(100, this);
22656 }else if(Roo.isSafari){
22657 return function(e){
22658 var k = e.getKey();
22662 this.execCmd('InsertText','\t');
22666 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22667 this.cleanUpPaste.defer(100, this);
22675 getAllAncestors: function()
22677 var p = this.getSelectedNode();
22680 a.push(p); // push blank onto stack..
22681 p = this.getParentElement();
22685 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22689 a.push(this.doc.body);
22693 lastSelNode : false,
22696 getSelection : function()
22698 this.assignDocWin();
22699 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22702 getSelectedNode: function()
22704 // this may only work on Gecko!!!
22706 // should we cache this!!!!
22711 var range = this.createRange(this.getSelection()).cloneRange();
22714 var parent = range.parentElement();
22716 var testRange = range.duplicate();
22717 testRange.moveToElementText(parent);
22718 if (testRange.inRange(range)) {
22721 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22724 parent = parent.parentElement;
22729 // is ancestor a text element.
22730 var ac = range.commonAncestorContainer;
22731 if (ac.nodeType == 3) {
22732 ac = ac.parentNode;
22735 var ar = ac.childNodes;
22738 var other_nodes = [];
22739 var has_other_nodes = false;
22740 for (var i=0;i<ar.length;i++) {
22741 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22744 // fullly contained node.
22746 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22751 // probably selected..
22752 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22753 other_nodes.push(ar[i]);
22757 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22762 has_other_nodes = true;
22764 if (!nodes.length && other_nodes.length) {
22765 nodes= other_nodes;
22767 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22773 createRange: function(sel)
22775 // this has strange effects when using with
22776 // top toolbar - not sure if it's a great idea.
22777 //this.editor.contentWindow.focus();
22778 if (typeof sel != "undefined") {
22780 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22782 return this.doc.createRange();
22785 return this.doc.createRange();
22788 getParentElement: function()
22791 this.assignDocWin();
22792 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22794 var range = this.createRange(sel);
22797 var p = range.commonAncestorContainer;
22798 while (p.nodeType == 3) { // text node
22809 * Range intersection.. the hard stuff...
22813 * [ -- selected range --- ]
22817 * if end is before start or hits it. fail.
22818 * if start is after end or hits it fail.
22820 * if either hits (but other is outside. - then it's not
22826 // @see http://www.thismuchiknow.co.uk/?p=64.
22827 rangeIntersectsNode : function(range, node)
22829 var nodeRange = node.ownerDocument.createRange();
22831 nodeRange.selectNode(node);
22833 nodeRange.selectNodeContents(node);
22836 var rangeStartRange = range.cloneRange();
22837 rangeStartRange.collapse(true);
22839 var rangeEndRange = range.cloneRange();
22840 rangeEndRange.collapse(false);
22842 var nodeStartRange = nodeRange.cloneRange();
22843 nodeStartRange.collapse(true);
22845 var nodeEndRange = nodeRange.cloneRange();
22846 nodeEndRange.collapse(false);
22848 return rangeStartRange.compareBoundaryPoints(
22849 Range.START_TO_START, nodeEndRange) == -1 &&
22850 rangeEndRange.compareBoundaryPoints(
22851 Range.START_TO_START, nodeStartRange) == 1;
22855 rangeCompareNode : function(range, node)
22857 var nodeRange = node.ownerDocument.createRange();
22859 nodeRange.selectNode(node);
22861 nodeRange.selectNodeContents(node);
22865 range.collapse(true);
22867 nodeRange.collapse(true);
22869 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22870 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22872 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22874 var nodeIsBefore = ss == 1;
22875 var nodeIsAfter = ee == -1;
22877 if (nodeIsBefore && nodeIsAfter) {
22880 if (!nodeIsBefore && nodeIsAfter) {
22881 return 1; //right trailed.
22884 if (nodeIsBefore && !nodeIsAfter) {
22885 return 2; // left trailed.
22891 // private? - in a new class?
22892 cleanUpPaste : function()
22894 // cleans up the whole document..
22895 Roo.log('cleanuppaste');
22897 this.cleanUpChildren(this.doc.body);
22898 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22899 if (clean != this.doc.body.innerHTML) {
22900 this.doc.body.innerHTML = clean;
22905 cleanWordChars : function(input) {// change the chars to hex code
22906 var he = Roo.HtmlEditorCore;
22908 var output = input;
22909 Roo.each(he.swapCodes, function(sw) {
22910 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22912 output = output.replace(swapper, sw[1]);
22919 cleanUpChildren : function (n)
22921 if (!n.childNodes.length) {
22924 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22925 this.cleanUpChild(n.childNodes[i]);
22932 cleanUpChild : function (node)
22935 //console.log(node);
22936 if (node.nodeName == "#text") {
22937 // clean up silly Windows -- stuff?
22940 if (node.nodeName == "#comment") {
22941 node.parentNode.removeChild(node);
22942 // clean up silly Windows -- stuff?
22945 var lcname = node.tagName.toLowerCase();
22946 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22947 // whitelist of tags..
22949 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22951 node.parentNode.removeChild(node);
22956 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22958 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22959 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22961 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22962 // remove_keep_children = true;
22965 if (remove_keep_children) {
22966 this.cleanUpChildren(node);
22967 // inserts everything just before this node...
22968 while (node.childNodes.length) {
22969 var cn = node.childNodes[0];
22970 node.removeChild(cn);
22971 node.parentNode.insertBefore(cn, node);
22973 node.parentNode.removeChild(node);
22977 if (!node.attributes || !node.attributes.length) {
22978 this.cleanUpChildren(node);
22982 function cleanAttr(n,v)
22985 if (v.match(/^\./) || v.match(/^\//)) {
22988 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22991 if (v.match(/^#/)) {
22994 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22995 node.removeAttribute(n);
22999 var cwhite = this.cwhite;
23000 var cblack = this.cblack;
23002 function cleanStyle(n,v)
23004 if (v.match(/expression/)) { //XSS?? should we even bother..
23005 node.removeAttribute(n);
23009 var parts = v.split(/;/);
23012 Roo.each(parts, function(p) {
23013 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23017 var l = p.split(':').shift().replace(/\s+/g,'');
23018 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23020 if ( cwhite.length && cblack.indexOf(l) > -1) {
23021 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23022 //node.removeAttribute(n);
23026 // only allow 'c whitelisted system attributes'
23027 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23028 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23029 //node.removeAttribute(n);
23039 if (clean.length) {
23040 node.setAttribute(n, clean.join(';'));
23042 node.removeAttribute(n);
23048 for (var i = node.attributes.length-1; i > -1 ; i--) {
23049 var a = node.attributes[i];
23052 if (a.name.toLowerCase().substr(0,2)=='on') {
23053 node.removeAttribute(a.name);
23056 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23057 node.removeAttribute(a.name);
23060 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23061 cleanAttr(a.name,a.value); // fixme..
23064 if (a.name == 'style') {
23065 cleanStyle(a.name,a.value);
23068 /// clean up MS crap..
23069 // tecnically this should be a list of valid class'es..
23072 if (a.name == 'class') {
23073 if (a.value.match(/^Mso/)) {
23074 node.className = '';
23077 if (a.value.match(/^body$/)) {
23078 node.className = '';
23089 this.cleanUpChildren(node);
23095 * Clean up MS wordisms...
23097 cleanWord : function(node)
23102 this.cleanWord(this.doc.body);
23105 if (node.nodeName == "#text") {
23106 // clean up silly Windows -- stuff?
23109 if (node.nodeName == "#comment") {
23110 node.parentNode.removeChild(node);
23111 // clean up silly Windows -- stuff?
23115 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23116 node.parentNode.removeChild(node);
23120 // remove - but keep children..
23121 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23122 while (node.childNodes.length) {
23123 var cn = node.childNodes[0];
23124 node.removeChild(cn);
23125 node.parentNode.insertBefore(cn, node);
23127 node.parentNode.removeChild(node);
23128 this.iterateChildren(node, this.cleanWord);
23132 if (node.className.length) {
23134 var cn = node.className.split(/\W+/);
23136 Roo.each(cn, function(cls) {
23137 if (cls.match(/Mso[a-zA-Z]+/)) {
23142 node.className = cna.length ? cna.join(' ') : '';
23144 node.removeAttribute("class");
23148 if (node.hasAttribute("lang")) {
23149 node.removeAttribute("lang");
23152 if (node.hasAttribute("style")) {
23154 var styles = node.getAttribute("style").split(";");
23156 Roo.each(styles, function(s) {
23157 if (!s.match(/:/)) {
23160 var kv = s.split(":");
23161 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23164 // what ever is left... we allow.
23167 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23168 if (!nstyle.length) {
23169 node.removeAttribute('style');
23172 this.iterateChildren(node, this.cleanWord);
23178 * iterateChildren of a Node, calling fn each time, using this as the scole..
23179 * @param {DomNode} node node to iterate children of.
23180 * @param {Function} fn method of this class to call on each item.
23182 iterateChildren : function(node, fn)
23184 if (!node.childNodes.length) {
23187 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23188 fn.call(this, node.childNodes[i])
23194 * cleanTableWidths.
23196 * Quite often pasting from word etc.. results in tables with column and widths.
23197 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23200 cleanTableWidths : function(node)
23205 this.cleanTableWidths(this.doc.body);
23210 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23213 Roo.log(node.tagName);
23214 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23215 this.iterateChildren(node, this.cleanTableWidths);
23218 if (node.hasAttribute('width')) {
23219 node.removeAttribute('width');
23223 if (node.hasAttribute("style")) {
23226 var styles = node.getAttribute("style").split(";");
23228 Roo.each(styles, function(s) {
23229 if (!s.match(/:/)) {
23232 var kv = s.split(":");
23233 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23236 // what ever is left... we allow.
23239 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23240 if (!nstyle.length) {
23241 node.removeAttribute('style');
23245 this.iterateChildren(node, this.cleanTableWidths);
23253 domToHTML : function(currentElement, depth, nopadtext) {
23255 depth = depth || 0;
23256 nopadtext = nopadtext || false;
23258 if (!currentElement) {
23259 return this.domToHTML(this.doc.body);
23262 //Roo.log(currentElement);
23264 var allText = false;
23265 var nodeName = currentElement.nodeName;
23266 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23268 if (nodeName == '#text') {
23270 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23275 if (nodeName != 'BODY') {
23278 // Prints the node tagName, such as <A>, <IMG>, etc
23281 for(i = 0; i < currentElement.attributes.length;i++) {
23283 var aname = currentElement.attributes.item(i).name;
23284 if (!currentElement.attributes.item(i).value.length) {
23287 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23290 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23299 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23302 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23307 // Traverse the tree
23309 var currentElementChild = currentElement.childNodes.item(i);
23310 var allText = true;
23311 var innerHTML = '';
23313 while (currentElementChild) {
23314 // Formatting code (indent the tree so it looks nice on the screen)
23315 var nopad = nopadtext;
23316 if (lastnode == 'SPAN') {
23320 if (currentElementChild.nodeName == '#text') {
23321 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23322 toadd = nopadtext ? toadd : toadd.trim();
23323 if (!nopad && toadd.length > 80) {
23324 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23326 innerHTML += toadd;
23329 currentElementChild = currentElement.childNodes.item(i);
23335 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23337 // Recursively traverse the tree structure of the child node
23338 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23339 lastnode = currentElementChild.nodeName;
23341 currentElementChild=currentElement.childNodes.item(i);
23347 // The remaining code is mostly for formatting the tree
23348 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23353 ret+= "</"+tagName+">";
23359 applyBlacklists : function()
23361 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23362 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23366 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23367 if (b.indexOf(tag) > -1) {
23370 this.white.push(tag);
23374 Roo.each(w, function(tag) {
23375 if (b.indexOf(tag) > -1) {
23378 if (this.white.indexOf(tag) > -1) {
23381 this.white.push(tag);
23386 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23387 if (w.indexOf(tag) > -1) {
23390 this.black.push(tag);
23394 Roo.each(b, function(tag) {
23395 if (w.indexOf(tag) > -1) {
23398 if (this.black.indexOf(tag) > -1) {
23401 this.black.push(tag);
23406 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23407 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23411 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23412 if (b.indexOf(tag) > -1) {
23415 this.cwhite.push(tag);
23419 Roo.each(w, function(tag) {
23420 if (b.indexOf(tag) > -1) {
23423 if (this.cwhite.indexOf(tag) > -1) {
23426 this.cwhite.push(tag);
23431 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23432 if (w.indexOf(tag) > -1) {
23435 this.cblack.push(tag);
23439 Roo.each(b, function(tag) {
23440 if (w.indexOf(tag) > -1) {
23443 if (this.cblack.indexOf(tag) > -1) {
23446 this.cblack.push(tag);
23451 setStylesheets : function(stylesheets)
23453 if(typeof(stylesheets) == 'string'){
23454 Roo.get(this.iframe.contentDocument.head).createChild({
23456 rel : 'stylesheet',
23465 Roo.each(stylesheets, function(s) {
23470 Roo.get(_this.iframe.contentDocument.head).createChild({
23472 rel : 'stylesheet',
23481 removeStylesheets : function()
23485 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23490 setStyle : function(style)
23492 Roo.get(this.iframe.contentDocument.head).createChild({
23501 // hide stuff that is not compatible
23515 * @event specialkey
23519 * @cfg {String} fieldClass @hide
23522 * @cfg {String} focusClass @hide
23525 * @cfg {String} autoCreate @hide
23528 * @cfg {String} inputType @hide
23531 * @cfg {String} invalidClass @hide
23534 * @cfg {String} invalidText @hide
23537 * @cfg {String} msgFx @hide
23540 * @cfg {String} validateOnBlur @hide
23544 Roo.HtmlEditorCore.white = [
23545 'area', 'br', 'img', 'input', 'hr', 'wbr',
23547 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23548 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23549 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23550 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23551 'table', 'ul', 'xmp',
23553 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23556 'dir', 'menu', 'ol', 'ul', 'dl',
23562 Roo.HtmlEditorCore.black = [
23563 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23565 'base', 'basefont', 'bgsound', 'blink', 'body',
23566 'frame', 'frameset', 'head', 'html', 'ilayer',
23567 'iframe', 'layer', 'link', 'meta', 'object',
23568 'script', 'style' ,'title', 'xml' // clean later..
23570 Roo.HtmlEditorCore.clean = [
23571 'script', 'style', 'title', 'xml'
23573 Roo.HtmlEditorCore.remove = [
23578 Roo.HtmlEditorCore.ablack = [
23582 Roo.HtmlEditorCore.aclean = [
23583 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23587 Roo.HtmlEditorCore.pwhite= [
23588 'http', 'https', 'mailto'
23591 // white listed style attributes.
23592 Roo.HtmlEditorCore.cwhite= [
23593 // 'text-align', /// default is to allow most things..
23599 // black listed style attributes.
23600 Roo.HtmlEditorCore.cblack= [
23601 // 'font-size' -- this can be set by the project
23605 Roo.HtmlEditorCore.swapCodes =[
23624 * @class Roo.bootstrap.HtmlEditor
23625 * @extends Roo.bootstrap.TextArea
23626 * Bootstrap HtmlEditor class
23629 * Create a new HtmlEditor
23630 * @param {Object} config The config object
23633 Roo.bootstrap.HtmlEditor = function(config){
23634 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23635 if (!this.toolbars) {
23636 this.toolbars = [];
23639 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23642 * @event initialize
23643 * Fires when the editor is fully initialized (including the iframe)
23644 * @param {HtmlEditor} this
23649 * Fires when the editor is first receives the focus. Any insertion must wait
23650 * until after this event.
23651 * @param {HtmlEditor} this
23655 * @event beforesync
23656 * Fires before the textarea is updated with content from the editor iframe. Return false
23657 * to cancel the sync.
23658 * @param {HtmlEditor} this
23659 * @param {String} html
23663 * @event beforepush
23664 * Fires before the iframe editor is updated with content from the textarea. Return false
23665 * to cancel the push.
23666 * @param {HtmlEditor} this
23667 * @param {String} html
23672 * Fires when the textarea is updated with content from the editor iframe.
23673 * @param {HtmlEditor} this
23674 * @param {String} html
23679 * Fires when the iframe editor is updated with content from the textarea.
23680 * @param {HtmlEditor} this
23681 * @param {String} html
23685 * @event editmodechange
23686 * Fires when the editor switches edit modes
23687 * @param {HtmlEditor} this
23688 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23690 editmodechange: true,
23692 * @event editorevent
23693 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23694 * @param {HtmlEditor} this
23698 * @event firstfocus
23699 * Fires when on first focus - needed by toolbars..
23700 * @param {HtmlEditor} this
23705 * Auto save the htmlEditor value as a file into Events
23706 * @param {HtmlEditor} this
23710 * @event savedpreview
23711 * preview the saved version of htmlEditor
23712 * @param {HtmlEditor} this
23719 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23723 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23728 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23733 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23738 * @cfg {Number} height (in pixels)
23742 * @cfg {Number} width (in pixels)
23747 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23750 stylesheets: false,
23755 // private properties
23756 validationEvent : false,
23758 initialized : false,
23761 onFocus : Roo.emptyFn,
23763 hideMode:'offsets',
23765 tbContainer : false,
23769 toolbarContainer :function() {
23770 return this.wrap.select('.x-html-editor-tb',true).first();
23774 * Protected method that will not generally be called directly. It
23775 * is called when the editor creates its toolbar. Override this method if you need to
23776 * add custom toolbar buttons.
23777 * @param {HtmlEditor} editor
23779 createToolbar : function(){
23780 Roo.log('renewing');
23781 Roo.log("create toolbars");
23783 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23784 this.toolbars[0].render(this.toolbarContainer());
23788 // if (!editor.toolbars || !editor.toolbars.length) {
23789 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23792 // for (var i =0 ; i < editor.toolbars.length;i++) {
23793 // editor.toolbars[i] = Roo.factory(
23794 // typeof(editor.toolbars[i]) == 'string' ?
23795 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23796 // Roo.bootstrap.HtmlEditor);
23797 // editor.toolbars[i].init(editor);
23803 onRender : function(ct, position)
23805 // Roo.log("Call onRender: " + this.xtype);
23807 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23809 this.wrap = this.inputEl().wrap({
23810 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23813 this.editorcore.onRender(ct, position);
23815 if (this.resizable) {
23816 this.resizeEl = new Roo.Resizable(this.wrap, {
23820 minHeight : this.height,
23821 height: this.height,
23822 handles : this.resizable,
23825 resize : function(r, w, h) {
23826 _t.onResize(w,h); // -something
23832 this.createToolbar(this);
23835 if(!this.width && this.resizable){
23836 this.setSize(this.wrap.getSize());
23838 if (this.resizeEl) {
23839 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23840 // should trigger onReize..
23846 onResize : function(w, h)
23848 Roo.log('resize: ' +w + ',' + h );
23849 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23853 if(this.inputEl() ){
23854 if(typeof w == 'number'){
23855 var aw = w - this.wrap.getFrameWidth('lr');
23856 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23859 if(typeof h == 'number'){
23860 var tbh = -11; // fixme it needs to tool bar size!
23861 for (var i =0; i < this.toolbars.length;i++) {
23862 // fixme - ask toolbars for heights?
23863 tbh += this.toolbars[i].el.getHeight();
23864 //if (this.toolbars[i].footer) {
23865 // tbh += this.toolbars[i].footer.el.getHeight();
23873 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23874 ah -= 5; // knock a few pixes off for look..
23875 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23879 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23880 this.editorcore.onResize(ew,eh);
23885 * Toggles the editor between standard and source edit mode.
23886 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23888 toggleSourceEdit : function(sourceEditMode)
23890 this.editorcore.toggleSourceEdit(sourceEditMode);
23892 if(this.editorcore.sourceEditMode){
23893 Roo.log('editor - showing textarea');
23896 // Roo.log(this.syncValue());
23898 this.inputEl().removeClass(['hide', 'x-hidden']);
23899 this.inputEl().dom.removeAttribute('tabIndex');
23900 this.inputEl().focus();
23902 Roo.log('editor - hiding textarea');
23904 // Roo.log(this.pushValue());
23907 this.inputEl().addClass(['hide', 'x-hidden']);
23908 this.inputEl().dom.setAttribute('tabIndex', -1);
23909 //this.deferFocus();
23912 if(this.resizable){
23913 this.setSize(this.wrap.getSize());
23916 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23919 // private (for BoxComponent)
23920 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23922 // private (for BoxComponent)
23923 getResizeEl : function(){
23927 // private (for BoxComponent)
23928 getPositionEl : function(){
23933 initEvents : function(){
23934 this.originalValue = this.getValue();
23938 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23941 // markInvalid : Roo.emptyFn,
23943 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23946 // clearInvalid : Roo.emptyFn,
23948 setValue : function(v){
23949 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23950 this.editorcore.pushValue();
23955 deferFocus : function(){
23956 this.focus.defer(10, this);
23960 focus : function(){
23961 this.editorcore.focus();
23967 onDestroy : function(){
23973 for (var i =0; i < this.toolbars.length;i++) {
23974 // fixme - ask toolbars for heights?
23975 this.toolbars[i].onDestroy();
23978 this.wrap.dom.innerHTML = '';
23979 this.wrap.remove();
23984 onFirstFocus : function(){
23985 //Roo.log("onFirstFocus");
23986 this.editorcore.onFirstFocus();
23987 for (var i =0; i < this.toolbars.length;i++) {
23988 this.toolbars[i].onFirstFocus();
23994 syncValue : function()
23996 this.editorcore.syncValue();
23999 pushValue : function()
24001 this.editorcore.pushValue();
24005 // hide stuff that is not compatible
24019 * @event specialkey
24023 * @cfg {String} fieldClass @hide
24026 * @cfg {String} focusClass @hide
24029 * @cfg {String} autoCreate @hide
24032 * @cfg {String} inputType @hide
24036 * @cfg {String} invalidText @hide
24039 * @cfg {String} msgFx @hide
24042 * @cfg {String} validateOnBlur @hide
24051 Roo.namespace('Roo.bootstrap.htmleditor');
24053 * @class Roo.bootstrap.HtmlEditorToolbar1
24058 new Roo.bootstrap.HtmlEditor({
24061 new Roo.bootstrap.HtmlEditorToolbar1({
24062 disable : { fonts: 1 , format: 1, ..., ... , ...],
24068 * @cfg {Object} disable List of elements to disable..
24069 * @cfg {Array} btns List of additional buttons.
24073 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24076 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24079 Roo.apply(this, config);
24081 // default disabled, based on 'good practice'..
24082 this.disable = this.disable || {};
24083 Roo.applyIf(this.disable, {
24086 specialElements : true
24088 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24090 this.editor = config.editor;
24091 this.editorcore = config.editor.editorcore;
24093 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24095 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24096 // dont call parent... till later.
24098 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24103 editorcore : false,
24108 "h1","h2","h3","h4","h5","h6",
24110 "abbr", "acronym", "address", "cite", "samp", "var",
24114 onRender : function(ct, position)
24116 // Roo.log("Call onRender: " + this.xtype);
24118 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24120 this.el.dom.style.marginBottom = '0';
24122 var editorcore = this.editorcore;
24123 var editor= this.editor;
24126 var btn = function(id,cmd , toggle, handler, html){
24128 var event = toggle ? 'toggle' : 'click';
24133 xns: Roo.bootstrap,
24137 enableToggle:toggle !== false,
24139 pressed : toggle ? false : null,
24142 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24143 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24149 // var cb_box = function...
24154 xns: Roo.bootstrap,
24159 xns: Roo.bootstrap,
24163 Roo.each(this.formats, function(f) {
24164 style.menu.items.push({
24166 xns: Roo.bootstrap,
24167 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24172 editorcore.insertTag(this.tagname);
24179 children.push(style);
24181 btn('bold',false,true);
24182 btn('italic',false,true);
24183 btn('align-left', 'justifyleft',true);
24184 btn('align-center', 'justifycenter',true);
24185 btn('align-right' , 'justifyright',true);
24186 btn('link', false, false, function(btn) {
24187 //Roo.log("create link?");
24188 var url = prompt(this.createLinkText, this.defaultLinkValue);
24189 if(url && url != 'http:/'+'/'){
24190 this.editorcore.relayCmd('createlink', url);
24193 btn('list','insertunorderedlist',true);
24194 btn('pencil', false,true, function(btn){
24196 this.toggleSourceEdit(btn.pressed);
24199 if (this.editor.btns.length > 0) {
24200 for (var i = 0; i<this.editor.btns.length; i++) {
24201 children.push(this.editor.btns[i]);
24209 xns: Roo.bootstrap,
24214 xns: Roo.bootstrap,
24219 cog.menu.items.push({
24221 xns: Roo.bootstrap,
24222 html : Clean styles,
24227 editorcore.insertTag(this.tagname);
24236 this.xtype = 'NavSimplebar';
24238 for(var i=0;i< children.length;i++) {
24240 this.buttons.add(this.addxtypeChild(children[i]));
24244 editor.on('editorevent', this.updateToolbar, this);
24246 onBtnClick : function(id)
24248 this.editorcore.relayCmd(id);
24249 this.editorcore.focus();
24253 * Protected method that will not generally be called directly. It triggers
24254 * a toolbar update by reading the markup state of the current selection in the editor.
24256 updateToolbar: function(){
24258 if(!this.editorcore.activated){
24259 this.editor.onFirstFocus(); // is this neeed?
24263 var btns = this.buttons;
24264 var doc = this.editorcore.doc;
24265 btns.get('bold').setActive(doc.queryCommandState('bold'));
24266 btns.get('italic').setActive(doc.queryCommandState('italic'));
24267 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24269 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24270 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24271 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24273 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24274 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24277 var ans = this.editorcore.getAllAncestors();
24278 if (this.formatCombo) {
24281 var store = this.formatCombo.store;
24282 this.formatCombo.setValue("");
24283 for (var i =0; i < ans.length;i++) {
24284 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24286 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24294 // hides menus... - so this cant be on a menu...
24295 Roo.bootstrap.MenuMgr.hideAll();
24297 Roo.bootstrap.MenuMgr.hideAll();
24298 //this.editorsyncValue();
24300 onFirstFocus: function() {
24301 this.buttons.each(function(item){
24305 toggleSourceEdit : function(sourceEditMode){
24308 if(sourceEditMode){
24309 Roo.log("disabling buttons");
24310 this.buttons.each( function(item){
24311 if(item.cmd != 'pencil'){
24317 Roo.log("enabling buttons");
24318 if(this.editorcore.initialized){
24319 this.buttons.each( function(item){
24325 Roo.log("calling toggole on editor");
24326 // tell the editor that it's been pressed..
24327 this.editor.toggleSourceEdit(sourceEditMode);
24337 * @class Roo.bootstrap.Table.AbstractSelectionModel
24338 * @extends Roo.util.Observable
24339 * Abstract base class for grid SelectionModels. It provides the interface that should be
24340 * implemented by descendant classes. This class should not be directly instantiated.
24343 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24344 this.locked = false;
24345 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24349 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24350 /** @ignore Called by the grid automatically. Do not call directly. */
24351 init : function(grid){
24357 * Locks the selections.
24360 this.locked = true;
24364 * Unlocks the selections.
24366 unlock : function(){
24367 this.locked = false;
24371 * Returns true if the selections are locked.
24372 * @return {Boolean}
24374 isLocked : function(){
24375 return this.locked;
24379 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24380 * @class Roo.bootstrap.Table.RowSelectionModel
24381 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24382 * It supports multiple selections and keyboard selection/navigation.
24384 * @param {Object} config
24387 Roo.bootstrap.Table.RowSelectionModel = function(config){
24388 Roo.apply(this, config);
24389 this.selections = new Roo.util.MixedCollection(false, function(o){
24394 this.lastActive = false;
24398 * @event selectionchange
24399 * Fires when the selection changes
24400 * @param {SelectionModel} this
24402 "selectionchange" : true,
24404 * @event afterselectionchange
24405 * Fires after the selection changes (eg. by key press or clicking)
24406 * @param {SelectionModel} this
24408 "afterselectionchange" : true,
24410 * @event beforerowselect
24411 * Fires when a row is selected being selected, return false to cancel.
24412 * @param {SelectionModel} this
24413 * @param {Number} rowIndex The selected index
24414 * @param {Boolean} keepExisting False if other selections will be cleared
24416 "beforerowselect" : true,
24419 * Fires when a row is selected.
24420 * @param {SelectionModel} this
24421 * @param {Number} rowIndex The selected index
24422 * @param {Roo.data.Record} r The record
24424 "rowselect" : true,
24426 * @event rowdeselect
24427 * Fires when a row is deselected.
24428 * @param {SelectionModel} this
24429 * @param {Number} rowIndex The selected index
24431 "rowdeselect" : true
24433 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24434 this.locked = false;
24437 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24439 * @cfg {Boolean} singleSelect
24440 * True to allow selection of only one row at a time (defaults to false)
24442 singleSelect : false,
24445 initEvents : function()
24448 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24449 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24450 //}else{ // allow click to work like normal
24451 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24453 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24454 this.grid.on("rowclick", this.handleMouseDown, this);
24456 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24457 "up" : function(e){
24459 this.selectPrevious(e.shiftKey);
24460 }else if(this.last !== false && this.lastActive !== false){
24461 var last = this.last;
24462 this.selectRange(this.last, this.lastActive-1);
24463 this.grid.getView().focusRow(this.lastActive);
24464 if(last !== false){
24468 this.selectFirstRow();
24470 this.fireEvent("afterselectionchange", this);
24472 "down" : function(e){
24474 this.selectNext(e.shiftKey);
24475 }else if(this.last !== false && this.lastActive !== false){
24476 var last = this.last;
24477 this.selectRange(this.last, this.lastActive+1);
24478 this.grid.getView().focusRow(this.lastActive);
24479 if(last !== false){
24483 this.selectFirstRow();
24485 this.fireEvent("afterselectionchange", this);
24489 this.grid.store.on('load', function(){
24490 this.selections.clear();
24493 var view = this.grid.view;
24494 view.on("refresh", this.onRefresh, this);
24495 view.on("rowupdated", this.onRowUpdated, this);
24496 view.on("rowremoved", this.onRemove, this);
24501 onRefresh : function()
24503 var ds = this.grid.store, i, v = this.grid.view;
24504 var s = this.selections;
24505 s.each(function(r){
24506 if((i = ds.indexOfId(r.id)) != -1){
24515 onRemove : function(v, index, r){
24516 this.selections.remove(r);
24520 onRowUpdated : function(v, index, r){
24521 if(this.isSelected(r)){
24522 v.onRowSelect(index);
24528 * @param {Array} records The records to select
24529 * @param {Boolean} keepExisting (optional) True to keep existing selections
24531 selectRecords : function(records, keepExisting)
24534 this.clearSelections();
24536 var ds = this.grid.store;
24537 for(var i = 0, len = records.length; i < len; i++){
24538 this.selectRow(ds.indexOf(records[i]), true);
24543 * Gets the number of selected rows.
24546 getCount : function(){
24547 return this.selections.length;
24551 * Selects the first row in the grid.
24553 selectFirstRow : function(){
24558 * Select the last row.
24559 * @param {Boolean} keepExisting (optional) True to keep existing selections
24561 selectLastRow : function(keepExisting){
24562 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24563 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24567 * Selects the row immediately following the last selected row.
24568 * @param {Boolean} keepExisting (optional) True to keep existing selections
24570 selectNext : function(keepExisting)
24572 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24573 this.selectRow(this.last+1, keepExisting);
24574 this.grid.getView().focusRow(this.last);
24579 * Selects the row that precedes the last selected row.
24580 * @param {Boolean} keepExisting (optional) True to keep existing selections
24582 selectPrevious : function(keepExisting){
24584 this.selectRow(this.last-1, keepExisting);
24585 this.grid.getView().focusRow(this.last);
24590 * Returns the selected records
24591 * @return {Array} Array of selected records
24593 getSelections : function(){
24594 return [].concat(this.selections.items);
24598 * Returns the first selected record.
24601 getSelected : function(){
24602 return this.selections.itemAt(0);
24607 * Clears all selections.
24609 clearSelections : function(fast)
24615 var ds = this.grid.store;
24616 var s = this.selections;
24617 s.each(function(r){
24618 this.deselectRow(ds.indexOfId(r.id));
24622 this.selections.clear();
24629 * Selects all rows.
24631 selectAll : function(){
24635 this.selections.clear();
24636 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24637 this.selectRow(i, true);
24642 * Returns True if there is a selection.
24643 * @return {Boolean}
24645 hasSelection : function(){
24646 return this.selections.length > 0;
24650 * Returns True if the specified row is selected.
24651 * @param {Number/Record} record The record or index of the record to check
24652 * @return {Boolean}
24654 isSelected : function(index){
24655 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24656 return (r && this.selections.key(r.id) ? true : false);
24660 * Returns True if the specified record id is selected.
24661 * @param {String} id The id of record to check
24662 * @return {Boolean}
24664 isIdSelected : function(id){
24665 return (this.selections.key(id) ? true : false);
24670 handleMouseDBClick : function(e, t){
24674 handleMouseDown : function(e, t)
24676 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24677 if(this.isLocked() || rowIndex < 0 ){
24680 if(e.shiftKey && this.last !== false){
24681 var last = this.last;
24682 this.selectRange(last, rowIndex, e.ctrlKey);
24683 this.last = last; // reset the last
24687 var isSelected = this.isSelected(rowIndex);
24688 //Roo.log("select row:" + rowIndex);
24690 this.deselectRow(rowIndex);
24692 this.selectRow(rowIndex, true);
24696 if(e.button !== 0 && isSelected){
24697 alert('rowIndex 2: ' + rowIndex);
24698 view.focusRow(rowIndex);
24699 }else if(e.ctrlKey && isSelected){
24700 this.deselectRow(rowIndex);
24701 }else if(!isSelected){
24702 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24703 view.focusRow(rowIndex);
24707 this.fireEvent("afterselectionchange", this);
24710 handleDragableRowClick : function(grid, rowIndex, e)
24712 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24713 this.selectRow(rowIndex, false);
24714 grid.view.focusRow(rowIndex);
24715 this.fireEvent("afterselectionchange", this);
24720 * Selects multiple rows.
24721 * @param {Array} rows Array of the indexes of the row to select
24722 * @param {Boolean} keepExisting (optional) True to keep existing selections
24724 selectRows : function(rows, keepExisting){
24726 this.clearSelections();
24728 for(var i = 0, len = rows.length; i < len; i++){
24729 this.selectRow(rows[i], true);
24734 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24735 * @param {Number} startRow The index of the first row in the range
24736 * @param {Number} endRow The index of the last row in the range
24737 * @param {Boolean} keepExisting (optional) True to retain existing selections
24739 selectRange : function(startRow, endRow, keepExisting){
24744 this.clearSelections();
24746 if(startRow <= endRow){
24747 for(var i = startRow; i <= endRow; i++){
24748 this.selectRow(i, true);
24751 for(var i = startRow; i >= endRow; i--){
24752 this.selectRow(i, true);
24758 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24759 * @param {Number} startRow The index of the first row in the range
24760 * @param {Number} endRow The index of the last row in the range
24762 deselectRange : function(startRow, endRow, preventViewNotify){
24766 for(var i = startRow; i <= endRow; i++){
24767 this.deselectRow(i, preventViewNotify);
24773 * @param {Number} row The index of the row to select
24774 * @param {Boolean} keepExisting (optional) True to keep existing selections
24776 selectRow : function(index, keepExisting, preventViewNotify)
24778 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24781 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24782 if(!keepExisting || this.singleSelect){
24783 this.clearSelections();
24786 var r = this.grid.store.getAt(index);
24787 //console.log('selectRow - record id :' + r.id);
24789 this.selections.add(r);
24790 this.last = this.lastActive = index;
24791 if(!preventViewNotify){
24792 var proxy = new Roo.Element(
24793 this.grid.getRowDom(index)
24795 proxy.addClass('bg-info info');
24797 this.fireEvent("rowselect", this, index, r);
24798 this.fireEvent("selectionchange", this);
24804 * @param {Number} row The index of the row to deselect
24806 deselectRow : function(index, preventViewNotify)
24811 if(this.last == index){
24814 if(this.lastActive == index){
24815 this.lastActive = false;
24818 var r = this.grid.store.getAt(index);
24823 this.selections.remove(r);
24824 //.console.log('deselectRow - record id :' + r.id);
24825 if(!preventViewNotify){
24827 var proxy = new Roo.Element(
24828 this.grid.getRowDom(index)
24830 proxy.removeClass('bg-info info');
24832 this.fireEvent("rowdeselect", this, index);
24833 this.fireEvent("selectionchange", this);
24837 restoreLast : function(){
24839 this.last = this._last;
24844 acceptsNav : function(row, col, cm){
24845 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24849 onEditorKey : function(field, e){
24850 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24855 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24857 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24859 }else if(k == e.ENTER && !e.ctrlKey){
24863 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24865 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24867 }else if(k == e.ESC){
24871 g.startEditing(newCell[0], newCell[1]);
24877 * Ext JS Library 1.1.1
24878 * Copyright(c) 2006-2007, Ext JS, LLC.
24880 * Originally Released Under LGPL - original licence link has changed is not relivant.
24883 * <script type="text/javascript">
24887 * @class Roo.bootstrap.PagingToolbar
24888 * @extends Roo.bootstrap.NavSimplebar
24889 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24891 * Create a new PagingToolbar
24892 * @param {Object} config The config object
24893 * @param {Roo.data.Store} store
24895 Roo.bootstrap.PagingToolbar = function(config)
24897 // old args format still supported... - xtype is prefered..
24898 // created from xtype...
24900 this.ds = config.dataSource;
24902 if (config.store && !this.ds) {
24903 this.store= Roo.factory(config.store, Roo.data);
24904 this.ds = this.store;
24905 this.ds.xmodule = this.xmodule || false;
24908 this.toolbarItems = [];
24909 if (config.items) {
24910 this.toolbarItems = config.items;
24913 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24918 this.bind(this.ds);
24921 if (Roo.bootstrap.version == 4) {
24922 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24924 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24929 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24931 * @cfg {Roo.data.Store} dataSource
24932 * The underlying data store providing the paged data
24935 * @cfg {String/HTMLElement/Element} container
24936 * container The id or element that will contain the toolbar
24939 * @cfg {Boolean} displayInfo
24940 * True to display the displayMsg (defaults to false)
24943 * @cfg {Number} pageSize
24944 * The number of records to display per page (defaults to 20)
24948 * @cfg {String} displayMsg
24949 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24951 displayMsg : 'Displaying {0} - {1} of {2}',
24953 * @cfg {String} emptyMsg
24954 * The message to display when no records are found (defaults to "No data to display")
24956 emptyMsg : 'No data to display',
24958 * Customizable piece of the default paging text (defaults to "Page")
24961 beforePageText : "Page",
24963 * Customizable piece of the default paging text (defaults to "of %0")
24966 afterPageText : "of {0}",
24968 * Customizable piece of the default paging text (defaults to "First Page")
24971 firstText : "First Page",
24973 * Customizable piece of the default paging text (defaults to "Previous Page")
24976 prevText : "Previous Page",
24978 * Customizable piece of the default paging text (defaults to "Next Page")
24981 nextText : "Next Page",
24983 * Customizable piece of the default paging text (defaults to "Last Page")
24986 lastText : "Last Page",
24988 * Customizable piece of the default paging text (defaults to "Refresh")
24991 refreshText : "Refresh",
24995 onRender : function(ct, position)
24997 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24998 this.navgroup.parentId = this.id;
24999 this.navgroup.onRender(this.el, null);
25000 // add the buttons to the navgroup
25002 if(this.displayInfo){
25003 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25004 this.displayEl = this.el.select('.x-paging-info', true).first();
25005 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25006 // this.displayEl = navel.el.select('span',true).first();
25012 Roo.each(_this.buttons, function(e){ // this might need to use render????
25013 Roo.factory(e).render(_this.el);
25017 Roo.each(_this.toolbarItems, function(e) {
25018 _this.navgroup.addItem(e);
25022 this.first = this.navgroup.addItem({
25023 tooltip: this.firstText,
25024 cls: "prev btn-outline-secondary",
25025 html : ' <i class="fa fa-step-backward"></i>',
25027 preventDefault: true,
25028 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25031 this.prev = this.navgroup.addItem({
25032 tooltip: this.prevText,
25033 cls: "prev btn-outline-secondary",
25034 html : ' <i class="fa fa-backward"></i>',
25036 preventDefault: true,
25037 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25039 //this.addSeparator();
25042 var field = this.navgroup.addItem( {
25044 cls : 'x-paging-position btn-outline-secondary',
25046 html : this.beforePageText +
25047 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25048 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25051 this.field = field.el.select('input', true).first();
25052 this.field.on("keydown", this.onPagingKeydown, this);
25053 this.field.on("focus", function(){this.dom.select();});
25056 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25057 //this.field.setHeight(18);
25058 //this.addSeparator();
25059 this.next = this.navgroup.addItem({
25060 tooltip: this.nextText,
25061 cls: "next btn-outline-secondary",
25062 html : ' <i class="fa fa-forward"></i>',
25064 preventDefault: true,
25065 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25067 this.last = this.navgroup.addItem({
25068 tooltip: this.lastText,
25069 html : ' <i class="fa fa-step-forward"></i>',
25070 cls: "next btn-outline-secondary",
25072 preventDefault: true,
25073 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25075 //this.addSeparator();
25076 this.loading = this.navgroup.addItem({
25077 tooltip: this.refreshText,
25078 cls: "btn-outline-secondary",
25079 html : ' <i class="fa fa-refresh"></i>',
25080 preventDefault: true,
25081 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25087 updateInfo : function(){
25088 if(this.displayEl){
25089 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25090 var msg = count == 0 ?
25094 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25096 this.displayEl.update(msg);
25101 onLoad : function(ds, r, o)
25103 this.cursor = o.params.start ? o.params.start : 0;
25105 var d = this.getPageData(),
25110 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25111 this.field.dom.value = ap;
25112 this.first.setDisabled(ap == 1);
25113 this.prev.setDisabled(ap == 1);
25114 this.next.setDisabled(ap == ps);
25115 this.last.setDisabled(ap == ps);
25116 this.loading.enable();
25121 getPageData : function(){
25122 var total = this.ds.getTotalCount();
25125 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25126 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25131 onLoadError : function(){
25132 this.loading.enable();
25136 onPagingKeydown : function(e){
25137 var k = e.getKey();
25138 var d = this.getPageData();
25140 var v = this.field.dom.value, pageNum;
25141 if(!v || isNaN(pageNum = parseInt(v, 10))){
25142 this.field.dom.value = d.activePage;
25145 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25146 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25149 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))
25151 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25152 this.field.dom.value = pageNum;
25153 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25156 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25158 var v = this.field.dom.value, pageNum;
25159 var increment = (e.shiftKey) ? 10 : 1;
25160 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25163 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25164 this.field.dom.value = d.activePage;
25167 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25169 this.field.dom.value = parseInt(v, 10) + increment;
25170 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25171 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25178 beforeLoad : function(){
25180 this.loading.disable();
25185 onClick : function(which){
25194 ds.load({params:{start: 0, limit: this.pageSize}});
25197 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25200 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25203 var total = ds.getTotalCount();
25204 var extra = total % this.pageSize;
25205 var lastStart = extra ? (total - extra) : total-this.pageSize;
25206 ds.load({params:{start: lastStart, limit: this.pageSize}});
25209 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25215 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25216 * @param {Roo.data.Store} store The data store to unbind
25218 unbind : function(ds){
25219 ds.un("beforeload", this.beforeLoad, this);
25220 ds.un("load", this.onLoad, this);
25221 ds.un("loadexception", this.onLoadError, this);
25222 ds.un("remove", this.updateInfo, this);
25223 ds.un("add", this.updateInfo, this);
25224 this.ds = undefined;
25228 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25229 * @param {Roo.data.Store} store The data store to bind
25231 bind : function(ds){
25232 ds.on("beforeload", this.beforeLoad, this);
25233 ds.on("load", this.onLoad, this);
25234 ds.on("loadexception", this.onLoadError, this);
25235 ds.on("remove", this.updateInfo, this);
25236 ds.on("add", this.updateInfo, this);
25247 * @class Roo.bootstrap.MessageBar
25248 * @extends Roo.bootstrap.Component
25249 * Bootstrap MessageBar class
25250 * @cfg {String} html contents of the MessageBar
25251 * @cfg {String} weight (info | success | warning | danger) default info
25252 * @cfg {String} beforeClass insert the bar before the given class
25253 * @cfg {Boolean} closable (true | false) default false
25254 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25257 * Create a new Element
25258 * @param {Object} config The config object
25261 Roo.bootstrap.MessageBar = function(config){
25262 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25265 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25271 beforeClass: 'bootstrap-sticky-wrap',
25273 getAutoCreate : function(){
25277 cls: 'alert alert-dismissable alert-' + this.weight,
25282 html: this.html || ''
25288 cfg.cls += ' alert-messages-fixed';
25302 onRender : function(ct, position)
25304 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25307 var cfg = Roo.apply({}, this.getAutoCreate());
25311 cfg.cls += ' ' + this.cls;
25314 cfg.style = this.style;
25316 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25318 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25321 this.el.select('>button.close').on('click', this.hide, this);
25327 if (!this.rendered) {
25333 this.fireEvent('show', this);
25339 if (!this.rendered) {
25345 this.fireEvent('hide', this);
25348 update : function()
25350 // var e = this.el.dom.firstChild;
25352 // if(this.closable){
25353 // e = e.nextSibling;
25356 // e.data = this.html || '';
25358 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25374 * @class Roo.bootstrap.Graph
25375 * @extends Roo.bootstrap.Component
25376 * Bootstrap Graph class
25380 @cfg {String} graphtype bar | vbar | pie
25381 @cfg {number} g_x coodinator | centre x (pie)
25382 @cfg {number} g_y coodinator | centre y (pie)
25383 @cfg {number} g_r radius (pie)
25384 @cfg {number} g_height height of the chart (respected by all elements in the set)
25385 @cfg {number} g_width width of the chart (respected by all elements in the set)
25386 @cfg {Object} title The title of the chart
25389 -opts (object) options for the chart
25391 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25392 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25394 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.
25395 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25397 o stretch (boolean)
25399 -opts (object) options for the pie
25402 o startAngle (number)
25403 o endAngle (number)
25407 * Create a new Input
25408 * @param {Object} config The config object
25411 Roo.bootstrap.Graph = function(config){
25412 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25418 * The img click event for the img.
25419 * @param {Roo.EventObject} e
25425 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25436 //g_colors: this.colors,
25443 getAutoCreate : function(){
25454 onRender : function(ct,position){
25457 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25459 if (typeof(Raphael) == 'undefined') {
25460 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25464 this.raphael = Raphael(this.el.dom);
25466 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25467 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25468 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25469 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25471 r.text(160, 10, "Single Series Chart").attr(txtattr);
25472 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25473 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25474 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25476 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25477 r.barchart(330, 10, 300, 220, data1);
25478 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25479 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25482 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25483 // r.barchart(30, 30, 560, 250, xdata, {
25484 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25485 // axis : "0 0 1 1",
25486 // axisxlabels : xdata
25487 // //yvalues : cols,
25490 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25492 // this.load(null,xdata,{
25493 // axis : "0 0 1 1",
25494 // axisxlabels : xdata
25499 load : function(graphtype,xdata,opts)
25501 this.raphael.clear();
25503 graphtype = this.graphtype;
25508 var r = this.raphael,
25509 fin = function () {
25510 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25512 fout = function () {
25513 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25515 pfin = function() {
25516 this.sector.stop();
25517 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25520 this.label[0].stop();
25521 this.label[0].attr({ r: 7.5 });
25522 this.label[1].attr({ "font-weight": 800 });
25525 pfout = function() {
25526 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25529 this.label[0].animate({ r: 5 }, 500, "bounce");
25530 this.label[1].attr({ "font-weight": 400 });
25536 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25539 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25542 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25543 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25545 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25552 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25557 setTitle: function(o)
25562 initEvents: function() {
25565 this.el.on('click', this.onClick, this);
25569 onClick : function(e)
25571 Roo.log('img onclick');
25572 this.fireEvent('click', this, e);
25584 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25587 * @class Roo.bootstrap.dash.NumberBox
25588 * @extends Roo.bootstrap.Component
25589 * Bootstrap NumberBox class
25590 * @cfg {String} headline Box headline
25591 * @cfg {String} content Box content
25592 * @cfg {String} icon Box icon
25593 * @cfg {String} footer Footer text
25594 * @cfg {String} fhref Footer href
25597 * Create a new NumberBox
25598 * @param {Object} config The config object
25602 Roo.bootstrap.dash.NumberBox = function(config){
25603 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25607 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25616 getAutoCreate : function(){
25620 cls : 'small-box ',
25628 cls : 'roo-headline',
25629 html : this.headline
25633 cls : 'roo-content',
25634 html : this.content
25648 cls : 'ion ' + this.icon
25657 cls : 'small-box-footer',
25658 href : this.fhref || '#',
25662 cfg.cn.push(footer);
25669 onRender : function(ct,position){
25670 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25677 setHeadline: function (value)
25679 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25682 setFooter: function (value, href)
25684 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25687 this.el.select('a.small-box-footer',true).first().attr('href', href);
25692 setContent: function (value)
25694 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25697 initEvents: function()
25711 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25714 * @class Roo.bootstrap.dash.TabBox
25715 * @extends Roo.bootstrap.Component
25716 * Bootstrap TabBox class
25717 * @cfg {String} title Title of the TabBox
25718 * @cfg {String} icon Icon of the TabBox
25719 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25720 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25723 * Create a new TabBox
25724 * @param {Object} config The config object
25728 Roo.bootstrap.dash.TabBox = function(config){
25729 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25734 * When a pane is added
25735 * @param {Roo.bootstrap.dash.TabPane} pane
25739 * @event activatepane
25740 * When a pane is activated
25741 * @param {Roo.bootstrap.dash.TabPane} pane
25743 "activatepane" : true
25751 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25756 tabScrollable : false,
25758 getChildContainer : function()
25760 return this.el.select('.tab-content', true).first();
25763 getAutoCreate : function(){
25767 cls: 'pull-left header',
25775 cls: 'fa ' + this.icon
25781 cls: 'nav nav-tabs pull-right',
25787 if(this.tabScrollable){
25794 cls: 'nav nav-tabs pull-right',
25805 cls: 'nav-tabs-custom',
25810 cls: 'tab-content no-padding',
25818 initEvents : function()
25820 //Roo.log('add add pane handler');
25821 this.on('addpane', this.onAddPane, this);
25824 * Updates the box title
25825 * @param {String} html to set the title to.
25827 setTitle : function(value)
25829 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25831 onAddPane : function(pane)
25833 this.panes.push(pane);
25834 //Roo.log('addpane');
25836 // tabs are rendere left to right..
25837 if(!this.showtabs){
25841 var ctr = this.el.select('.nav-tabs', true).first();
25844 var existing = ctr.select('.nav-tab',true);
25845 var qty = existing.getCount();;
25848 var tab = ctr.createChild({
25850 cls : 'nav-tab' + (qty ? '' : ' active'),
25858 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25861 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25863 pane.el.addClass('active');
25868 onTabClick : function(ev,un,ob,pane)
25870 //Roo.log('tab - prev default');
25871 ev.preventDefault();
25874 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25875 pane.tab.addClass('active');
25876 //Roo.log(pane.title);
25877 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25878 // technically we should have a deactivate event.. but maybe add later.
25879 // and it should not de-activate the selected tab...
25880 this.fireEvent('activatepane', pane);
25881 pane.el.addClass('active');
25882 pane.fireEvent('activate');
25887 getActivePane : function()
25890 Roo.each(this.panes, function(p) {
25891 if(p.el.hasClass('active')){
25912 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25914 * @class Roo.bootstrap.TabPane
25915 * @extends Roo.bootstrap.Component
25916 * Bootstrap TabPane class
25917 * @cfg {Boolean} active (false | true) Default false
25918 * @cfg {String} title title of panel
25922 * Create a new TabPane
25923 * @param {Object} config The config object
25926 Roo.bootstrap.dash.TabPane = function(config){
25927 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25933 * When a pane is activated
25934 * @param {Roo.bootstrap.dash.TabPane} pane
25941 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25946 // the tabBox that this is attached to.
25949 getAutoCreate : function()
25957 cfg.cls += ' active';
25962 initEvents : function()
25964 //Roo.log('trigger add pane handler');
25965 this.parent().fireEvent('addpane', this)
25969 * Updates the tab title
25970 * @param {String} html to set the title to.
25972 setTitle: function(str)
25978 this.tab.select('a', true).first().dom.innerHTML = str;
25995 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25998 * @class Roo.bootstrap.menu.Menu
25999 * @extends Roo.bootstrap.Component
26000 * Bootstrap Menu class - container for Menu
26001 * @cfg {String} html Text of the menu
26002 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26003 * @cfg {String} icon Font awesome icon
26004 * @cfg {String} pos Menu align to (top | bottom) default bottom
26008 * Create a new Menu
26009 * @param {Object} config The config object
26013 Roo.bootstrap.menu.Menu = function(config){
26014 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26018 * @event beforeshow
26019 * Fires before this menu is displayed
26020 * @param {Roo.bootstrap.menu.Menu} this
26024 * @event beforehide
26025 * Fires before this menu is hidden
26026 * @param {Roo.bootstrap.menu.Menu} this
26031 * Fires after this menu is displayed
26032 * @param {Roo.bootstrap.menu.Menu} this
26037 * Fires after this menu is hidden
26038 * @param {Roo.bootstrap.menu.Menu} this
26043 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26044 * @param {Roo.bootstrap.menu.Menu} this
26045 * @param {Roo.EventObject} e
26052 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26056 weight : 'default',
26061 getChildContainer : function() {
26062 if(this.isSubMenu){
26066 return this.el.select('ul.dropdown-menu', true).first();
26069 getAutoCreate : function()
26074 cls : 'roo-menu-text',
26082 cls : 'fa ' + this.icon
26093 cls : 'dropdown-button btn btn-' + this.weight,
26098 cls : 'dropdown-toggle btn btn-' + this.weight,
26108 cls : 'dropdown-menu'
26114 if(this.pos == 'top'){
26115 cfg.cls += ' dropup';
26118 if(this.isSubMenu){
26121 cls : 'dropdown-menu'
26128 onRender : function(ct, position)
26130 this.isSubMenu = ct.hasClass('dropdown-submenu');
26132 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26135 initEvents : function()
26137 if(this.isSubMenu){
26141 this.hidden = true;
26143 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26144 this.triggerEl.on('click', this.onTriggerPress, this);
26146 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26147 this.buttonEl.on('click', this.onClick, this);
26153 if(this.isSubMenu){
26157 return this.el.select('ul.dropdown-menu', true).first();
26160 onClick : function(e)
26162 this.fireEvent("click", this, e);
26165 onTriggerPress : function(e)
26167 if (this.isVisible()) {
26174 isVisible : function(){
26175 return !this.hidden;
26180 this.fireEvent("beforeshow", this);
26182 this.hidden = false;
26183 this.el.addClass('open');
26185 Roo.get(document).on("mouseup", this.onMouseUp, this);
26187 this.fireEvent("show", this);
26194 this.fireEvent("beforehide", this);
26196 this.hidden = true;
26197 this.el.removeClass('open');
26199 Roo.get(document).un("mouseup", this.onMouseUp);
26201 this.fireEvent("hide", this);
26204 onMouseUp : function()
26218 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26221 * @class Roo.bootstrap.menu.Item
26222 * @extends Roo.bootstrap.Component
26223 * Bootstrap MenuItem class
26224 * @cfg {Boolean} submenu (true | false) default false
26225 * @cfg {String} html text of the item
26226 * @cfg {String} href the link
26227 * @cfg {Boolean} disable (true | false) default false
26228 * @cfg {Boolean} preventDefault (true | false) default true
26229 * @cfg {String} icon Font awesome icon
26230 * @cfg {String} pos Submenu align to (left | right) default right
26234 * Create a new Item
26235 * @param {Object} config The config object
26239 Roo.bootstrap.menu.Item = function(config){
26240 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26244 * Fires when the mouse is hovering over this menu
26245 * @param {Roo.bootstrap.menu.Item} this
26246 * @param {Roo.EventObject} e
26251 * Fires when the mouse exits this menu
26252 * @param {Roo.bootstrap.menu.Item} this
26253 * @param {Roo.EventObject} e
26259 * The raw click event for the entire grid.
26260 * @param {Roo.EventObject} e
26266 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26271 preventDefault: true,
26276 getAutoCreate : function()
26281 cls : 'roo-menu-item-text',
26289 cls : 'fa ' + this.icon
26298 href : this.href || '#',
26305 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26309 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26311 if(this.pos == 'left'){
26312 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26319 initEvents : function()
26321 this.el.on('mouseover', this.onMouseOver, this);
26322 this.el.on('mouseout', this.onMouseOut, this);
26324 this.el.select('a', true).first().on('click', this.onClick, this);
26328 onClick : function(e)
26330 if(this.preventDefault){
26331 e.preventDefault();
26334 this.fireEvent("click", this, e);
26337 onMouseOver : function(e)
26339 if(this.submenu && this.pos == 'left'){
26340 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26343 this.fireEvent("mouseover", this, e);
26346 onMouseOut : function(e)
26348 this.fireEvent("mouseout", this, e);
26360 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26363 * @class Roo.bootstrap.menu.Separator
26364 * @extends Roo.bootstrap.Component
26365 * Bootstrap Separator class
26368 * Create a new Separator
26369 * @param {Object} config The config object
26373 Roo.bootstrap.menu.Separator = function(config){
26374 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26377 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26379 getAutoCreate : function(){
26400 * @class Roo.bootstrap.Tooltip
26401 * Bootstrap Tooltip class
26402 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26403 * to determine which dom element triggers the tooltip.
26405 * It needs to add support for additional attributes like tooltip-position
26408 * Create a new Toolti
26409 * @param {Object} config The config object
26412 Roo.bootstrap.Tooltip = function(config){
26413 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26415 this.alignment = Roo.bootstrap.Tooltip.alignment;
26417 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26418 this.alignment = config.alignment;
26423 Roo.apply(Roo.bootstrap.Tooltip, {
26425 * @function init initialize tooltip monitoring.
26429 currentTip : false,
26430 currentRegion : false,
26436 Roo.get(document).on('mouseover', this.enter ,this);
26437 Roo.get(document).on('mouseout', this.leave, this);
26440 this.currentTip = new Roo.bootstrap.Tooltip();
26443 enter : function(ev)
26445 var dom = ev.getTarget();
26447 //Roo.log(['enter',dom]);
26448 var el = Roo.fly(dom);
26449 if (this.currentEl) {
26451 //Roo.log(this.currentEl);
26452 //Roo.log(this.currentEl.contains(dom));
26453 if (this.currentEl == el) {
26456 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26462 if (this.currentTip.el) {
26463 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26467 if(!el || el.dom == document){
26473 // you can not look for children, as if el is the body.. then everythign is the child..
26474 if (!el.attr('tooltip')) { //
26475 if (!el.select("[tooltip]").elements.length) {
26478 // is the mouse over this child...?
26479 bindEl = el.select("[tooltip]").first();
26480 var xy = ev.getXY();
26481 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26482 //Roo.log("not in region.");
26485 //Roo.log("child element over..");
26488 this.currentEl = bindEl;
26489 this.currentTip.bind(bindEl);
26490 this.currentRegion = Roo.lib.Region.getRegion(dom);
26491 this.currentTip.enter();
26494 leave : function(ev)
26496 var dom = ev.getTarget();
26497 //Roo.log(['leave',dom]);
26498 if (!this.currentEl) {
26503 if (dom != this.currentEl.dom) {
26506 var xy = ev.getXY();
26507 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26510 // only activate leave if mouse cursor is outside... bounding box..
26515 if (this.currentTip) {
26516 this.currentTip.leave();
26518 //Roo.log('clear currentEl');
26519 this.currentEl = false;
26524 'left' : ['r-l', [-2,0], 'right'],
26525 'right' : ['l-r', [2,0], 'left'],
26526 'bottom' : ['t-b', [0,2], 'top'],
26527 'top' : [ 'b-t', [0,-2], 'bottom']
26533 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26538 delay : null, // can be { show : 300 , hide: 500}
26542 hoverState : null, //???
26544 placement : 'bottom',
26548 getAutoCreate : function(){
26555 cls : 'tooltip-arrow'
26558 cls : 'tooltip-inner'
26565 bind : function(el)
26571 enter : function () {
26573 if (this.timeout != null) {
26574 clearTimeout(this.timeout);
26577 this.hoverState = 'in';
26578 //Roo.log("enter - show");
26579 if (!this.delay || !this.delay.show) {
26584 this.timeout = setTimeout(function () {
26585 if (_t.hoverState == 'in') {
26588 }, this.delay.show);
26592 clearTimeout(this.timeout);
26594 this.hoverState = 'out';
26595 if (!this.delay || !this.delay.hide) {
26601 this.timeout = setTimeout(function () {
26602 //Roo.log("leave - timeout");
26604 if (_t.hoverState == 'out') {
26606 Roo.bootstrap.Tooltip.currentEl = false;
26611 show : function (msg)
26614 this.render(document.body);
26617 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26619 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26621 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26623 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26625 var placement = typeof this.placement == 'function' ?
26626 this.placement.call(this, this.el, on_el) :
26629 var autoToken = /\s?auto?\s?/i;
26630 var autoPlace = autoToken.test(placement);
26632 placement = placement.replace(autoToken, '') || 'top';
26636 //this.el.setXY([0,0]);
26638 //this.el.dom.style.display='block';
26640 //this.el.appendTo(on_el);
26642 var p = this.getPosition();
26643 var box = this.el.getBox();
26649 var align = this.alignment[placement];
26651 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26653 if(placement == 'top' || placement == 'bottom'){
26655 placement = 'right';
26658 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26659 placement = 'left';
26662 var scroll = Roo.select('body', true).first().getScroll();
26664 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26668 align = this.alignment[placement];
26671 this.el.alignTo(this.bindEl, align[0],align[1]);
26672 //var arrow = this.el.select('.arrow',true).first();
26673 //arrow.set(align[2],
26675 this.el.addClass(placement);
26677 this.el.addClass('in fade');
26679 this.hoverState = null;
26681 if (this.el.hasClass('fade')) {
26692 //this.el.setXY([0,0]);
26693 this.el.removeClass('in');
26709 * @class Roo.bootstrap.LocationPicker
26710 * @extends Roo.bootstrap.Component
26711 * Bootstrap LocationPicker class
26712 * @cfg {Number} latitude Position when init default 0
26713 * @cfg {Number} longitude Position when init default 0
26714 * @cfg {Number} zoom default 15
26715 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26716 * @cfg {Boolean} mapTypeControl default false
26717 * @cfg {Boolean} disableDoubleClickZoom default false
26718 * @cfg {Boolean} scrollwheel default true
26719 * @cfg {Boolean} streetViewControl default false
26720 * @cfg {Number} radius default 0
26721 * @cfg {String} locationName
26722 * @cfg {Boolean} draggable default true
26723 * @cfg {Boolean} enableAutocomplete default false
26724 * @cfg {Boolean} enableReverseGeocode default true
26725 * @cfg {String} markerTitle
26728 * Create a new LocationPicker
26729 * @param {Object} config The config object
26733 Roo.bootstrap.LocationPicker = function(config){
26735 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26740 * Fires when the picker initialized.
26741 * @param {Roo.bootstrap.LocationPicker} this
26742 * @param {Google Location} location
26746 * @event positionchanged
26747 * Fires when the picker position changed.
26748 * @param {Roo.bootstrap.LocationPicker} this
26749 * @param {Google Location} location
26751 positionchanged : true,
26754 * Fires when the map resize.
26755 * @param {Roo.bootstrap.LocationPicker} this
26760 * Fires when the map show.
26761 * @param {Roo.bootstrap.LocationPicker} this
26766 * Fires when the map hide.
26767 * @param {Roo.bootstrap.LocationPicker} this
26772 * Fires when click the map.
26773 * @param {Roo.bootstrap.LocationPicker} this
26774 * @param {Map event} e
26778 * @event mapRightClick
26779 * Fires when right click the map.
26780 * @param {Roo.bootstrap.LocationPicker} this
26781 * @param {Map event} e
26783 mapRightClick : true,
26785 * @event markerClick
26786 * Fires when click the marker.
26787 * @param {Roo.bootstrap.LocationPicker} this
26788 * @param {Map event} e
26790 markerClick : true,
26792 * @event markerRightClick
26793 * Fires when right click the marker.
26794 * @param {Roo.bootstrap.LocationPicker} this
26795 * @param {Map event} e
26797 markerRightClick : true,
26799 * @event OverlayViewDraw
26800 * Fires when OverlayView Draw
26801 * @param {Roo.bootstrap.LocationPicker} this
26803 OverlayViewDraw : true,
26805 * @event OverlayViewOnAdd
26806 * Fires when OverlayView Draw
26807 * @param {Roo.bootstrap.LocationPicker} this
26809 OverlayViewOnAdd : true,
26811 * @event OverlayViewOnRemove
26812 * Fires when OverlayView Draw
26813 * @param {Roo.bootstrap.LocationPicker} this
26815 OverlayViewOnRemove : true,
26817 * @event OverlayViewShow
26818 * Fires when OverlayView Draw
26819 * @param {Roo.bootstrap.LocationPicker} this
26820 * @param {Pixel} cpx
26822 OverlayViewShow : true,
26824 * @event OverlayViewHide
26825 * Fires when OverlayView Draw
26826 * @param {Roo.bootstrap.LocationPicker} this
26828 OverlayViewHide : true,
26830 * @event loadexception
26831 * Fires when load google lib failed.
26832 * @param {Roo.bootstrap.LocationPicker} this
26834 loadexception : true
26839 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26841 gMapContext: false,
26847 mapTypeControl: false,
26848 disableDoubleClickZoom: false,
26850 streetViewControl: false,
26854 enableAutocomplete: false,
26855 enableReverseGeocode: true,
26858 getAutoCreate: function()
26863 cls: 'roo-location-picker'
26869 initEvents: function(ct, position)
26871 if(!this.el.getWidth() || this.isApplied()){
26875 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26880 initial: function()
26882 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26883 this.fireEvent('loadexception', this);
26887 if(!this.mapTypeId){
26888 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26891 this.gMapContext = this.GMapContext();
26893 this.initOverlayView();
26895 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26899 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26900 _this.setPosition(_this.gMapContext.marker.position);
26903 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26904 _this.fireEvent('mapClick', this, event);
26908 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26909 _this.fireEvent('mapRightClick', this, event);
26913 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26914 _this.fireEvent('markerClick', this, event);
26918 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26919 _this.fireEvent('markerRightClick', this, event);
26923 this.setPosition(this.gMapContext.location);
26925 this.fireEvent('initial', this, this.gMapContext.location);
26928 initOverlayView: function()
26932 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26936 _this.fireEvent('OverlayViewDraw', _this);
26941 _this.fireEvent('OverlayViewOnAdd', _this);
26944 onRemove: function()
26946 _this.fireEvent('OverlayViewOnRemove', _this);
26949 show: function(cpx)
26951 _this.fireEvent('OverlayViewShow', _this, cpx);
26956 _this.fireEvent('OverlayViewHide', _this);
26962 fromLatLngToContainerPixel: function(event)
26964 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26967 isApplied: function()
26969 return this.getGmapContext() == false ? false : true;
26972 getGmapContext: function()
26974 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26977 GMapContext: function()
26979 var position = new google.maps.LatLng(this.latitude, this.longitude);
26981 var _map = new google.maps.Map(this.el.dom, {
26984 mapTypeId: this.mapTypeId,
26985 mapTypeControl: this.mapTypeControl,
26986 disableDoubleClickZoom: this.disableDoubleClickZoom,
26987 scrollwheel: this.scrollwheel,
26988 streetViewControl: this.streetViewControl,
26989 locationName: this.locationName,
26990 draggable: this.draggable,
26991 enableAutocomplete: this.enableAutocomplete,
26992 enableReverseGeocode: this.enableReverseGeocode
26995 var _marker = new google.maps.Marker({
26996 position: position,
26998 title: this.markerTitle,
26999 draggable: this.draggable
27006 location: position,
27007 radius: this.radius,
27008 locationName: this.locationName,
27009 addressComponents: {
27010 formatted_address: null,
27011 addressLine1: null,
27012 addressLine2: null,
27014 streetNumber: null,
27018 stateOrProvince: null
27021 domContainer: this.el.dom,
27022 geodecoder: new google.maps.Geocoder()
27026 drawCircle: function(center, radius, options)
27028 if (this.gMapContext.circle != null) {
27029 this.gMapContext.circle.setMap(null);
27033 options = Roo.apply({}, options, {
27034 strokeColor: "#0000FF",
27035 strokeOpacity: .35,
27037 fillColor: "#0000FF",
27041 options.map = this.gMapContext.map;
27042 options.radius = radius;
27043 options.center = center;
27044 this.gMapContext.circle = new google.maps.Circle(options);
27045 return this.gMapContext.circle;
27051 setPosition: function(location)
27053 this.gMapContext.location = location;
27054 this.gMapContext.marker.setPosition(location);
27055 this.gMapContext.map.panTo(location);
27056 this.drawCircle(location, this.gMapContext.radius, {});
27060 if (this.gMapContext.settings.enableReverseGeocode) {
27061 this.gMapContext.geodecoder.geocode({
27062 latLng: this.gMapContext.location
27063 }, function(results, status) {
27065 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27066 _this.gMapContext.locationName = results[0].formatted_address;
27067 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27069 _this.fireEvent('positionchanged', this, location);
27076 this.fireEvent('positionchanged', this, location);
27081 google.maps.event.trigger(this.gMapContext.map, "resize");
27083 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27085 this.fireEvent('resize', this);
27088 setPositionByLatLng: function(latitude, longitude)
27090 this.setPosition(new google.maps.LatLng(latitude, longitude));
27093 getCurrentPosition: function()
27096 latitude: this.gMapContext.location.lat(),
27097 longitude: this.gMapContext.location.lng()
27101 getAddressName: function()
27103 return this.gMapContext.locationName;
27106 getAddressComponents: function()
27108 return this.gMapContext.addressComponents;
27111 address_component_from_google_geocode: function(address_components)
27115 for (var i = 0; i < address_components.length; i++) {
27116 var component = address_components[i];
27117 if (component.types.indexOf("postal_code") >= 0) {
27118 result.postalCode = component.short_name;
27119 } else if (component.types.indexOf("street_number") >= 0) {
27120 result.streetNumber = component.short_name;
27121 } else if (component.types.indexOf("route") >= 0) {
27122 result.streetName = component.short_name;
27123 } else if (component.types.indexOf("neighborhood") >= 0) {
27124 result.city = component.short_name;
27125 } else if (component.types.indexOf("locality") >= 0) {
27126 result.city = component.short_name;
27127 } else if (component.types.indexOf("sublocality") >= 0) {
27128 result.district = component.short_name;
27129 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27130 result.stateOrProvince = component.short_name;
27131 } else if (component.types.indexOf("country") >= 0) {
27132 result.country = component.short_name;
27136 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27137 result.addressLine2 = "";
27141 setZoomLevel: function(zoom)
27143 this.gMapContext.map.setZoom(zoom);
27156 this.fireEvent('show', this);
27167 this.fireEvent('hide', this);
27172 Roo.apply(Roo.bootstrap.LocationPicker, {
27174 OverlayView : function(map, options)
27176 options = options || {};
27190 * @class Roo.bootstrap.Alert
27191 * @extends Roo.bootstrap.Component
27192 * Bootstrap Alert class
27193 * @cfg {String} title The title of alert
27194 * @cfg {String} html The content of alert
27195 * @cfg {String} weight ( success | info | warning | danger )
27196 * @cfg {String} faicon font-awesomeicon
27199 * Create a new alert
27200 * @param {Object} config The config object
27204 Roo.bootstrap.Alert = function(config){
27205 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27209 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27216 getAutoCreate : function()
27225 cls : 'roo-alert-icon'
27230 cls : 'roo-alert-title',
27235 cls : 'roo-alert-text',
27242 cfg.cn[0].cls += ' fa ' + this.faicon;
27246 cfg.cls += ' alert-' + this.weight;
27252 initEvents: function()
27254 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27257 setTitle : function(str)
27259 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27262 setText : function(str)
27264 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27267 setWeight : function(weight)
27270 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27273 this.weight = weight;
27275 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27278 setIcon : function(icon)
27281 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27284 this.faicon = icon;
27286 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27307 * @class Roo.bootstrap.UploadCropbox
27308 * @extends Roo.bootstrap.Component
27309 * Bootstrap UploadCropbox class
27310 * @cfg {String} emptyText show when image has been loaded
27311 * @cfg {String} rotateNotify show when image too small to rotate
27312 * @cfg {Number} errorTimeout default 3000
27313 * @cfg {Number} minWidth default 300
27314 * @cfg {Number} minHeight default 300
27315 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27316 * @cfg {Boolean} isDocument (true|false) default false
27317 * @cfg {String} url action url
27318 * @cfg {String} paramName default 'imageUpload'
27319 * @cfg {String} method default POST
27320 * @cfg {Boolean} loadMask (true|false) default true
27321 * @cfg {Boolean} loadingText default 'Loading...'
27324 * Create a new UploadCropbox
27325 * @param {Object} config The config object
27328 Roo.bootstrap.UploadCropbox = function(config){
27329 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27333 * @event beforeselectfile
27334 * Fire before select file
27335 * @param {Roo.bootstrap.UploadCropbox} this
27337 "beforeselectfile" : true,
27340 * Fire after initEvent
27341 * @param {Roo.bootstrap.UploadCropbox} this
27346 * Fire after initEvent
27347 * @param {Roo.bootstrap.UploadCropbox} this
27348 * @param {String} data
27353 * Fire when preparing the file data
27354 * @param {Roo.bootstrap.UploadCropbox} this
27355 * @param {Object} file
27360 * Fire when get exception
27361 * @param {Roo.bootstrap.UploadCropbox} this
27362 * @param {XMLHttpRequest} xhr
27364 "exception" : true,
27366 * @event beforeloadcanvas
27367 * Fire before load the canvas
27368 * @param {Roo.bootstrap.UploadCropbox} this
27369 * @param {String} src
27371 "beforeloadcanvas" : true,
27374 * Fire when trash image
27375 * @param {Roo.bootstrap.UploadCropbox} this
27380 * Fire when download the image
27381 * @param {Roo.bootstrap.UploadCropbox} this
27385 * @event footerbuttonclick
27386 * Fire when footerbuttonclick
27387 * @param {Roo.bootstrap.UploadCropbox} this
27388 * @param {String} type
27390 "footerbuttonclick" : true,
27394 * @param {Roo.bootstrap.UploadCropbox} this
27399 * Fire when rotate the image
27400 * @param {Roo.bootstrap.UploadCropbox} this
27401 * @param {String} pos
27406 * Fire when inspect the file
27407 * @param {Roo.bootstrap.UploadCropbox} this
27408 * @param {Object} file
27413 * Fire when xhr upload the file
27414 * @param {Roo.bootstrap.UploadCropbox} this
27415 * @param {Object} data
27420 * Fire when arrange the file data
27421 * @param {Roo.bootstrap.UploadCropbox} this
27422 * @param {Object} formData
27427 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27430 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27432 emptyText : 'Click to upload image',
27433 rotateNotify : 'Image is too small to rotate',
27434 errorTimeout : 3000,
27448 cropType : 'image/jpeg',
27450 canvasLoaded : false,
27451 isDocument : false,
27453 paramName : 'imageUpload',
27455 loadingText : 'Loading...',
27458 getAutoCreate : function()
27462 cls : 'roo-upload-cropbox',
27466 cls : 'roo-upload-cropbox-selector',
27471 cls : 'roo-upload-cropbox-body',
27472 style : 'cursor:pointer',
27476 cls : 'roo-upload-cropbox-preview'
27480 cls : 'roo-upload-cropbox-thumb'
27484 cls : 'roo-upload-cropbox-empty-notify',
27485 html : this.emptyText
27489 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27490 html : this.rotateNotify
27496 cls : 'roo-upload-cropbox-footer',
27499 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27509 onRender : function(ct, position)
27511 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27513 if (this.buttons.length) {
27515 Roo.each(this.buttons, function(bb) {
27517 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27519 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27525 this.maskEl = this.el;
27529 initEvents : function()
27531 this.urlAPI = (window.createObjectURL && window) ||
27532 (window.URL && URL.revokeObjectURL && URL) ||
27533 (window.webkitURL && webkitURL);
27535 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27536 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27538 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27539 this.selectorEl.hide();
27541 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27542 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27544 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27545 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27546 this.thumbEl.hide();
27548 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27549 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27551 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27552 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27553 this.errorEl.hide();
27555 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27556 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27557 this.footerEl.hide();
27559 this.setThumbBoxSize();
27565 this.fireEvent('initial', this);
27572 window.addEventListener("resize", function() { _this.resize(); } );
27574 this.bodyEl.on('click', this.beforeSelectFile, this);
27577 this.bodyEl.on('touchstart', this.onTouchStart, this);
27578 this.bodyEl.on('touchmove', this.onTouchMove, this);
27579 this.bodyEl.on('touchend', this.onTouchEnd, this);
27583 this.bodyEl.on('mousedown', this.onMouseDown, this);
27584 this.bodyEl.on('mousemove', this.onMouseMove, this);
27585 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27586 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27587 Roo.get(document).on('mouseup', this.onMouseUp, this);
27590 this.selectorEl.on('change', this.onFileSelected, this);
27596 this.baseScale = 1;
27598 this.baseRotate = 1;
27599 this.dragable = false;
27600 this.pinching = false;
27603 this.cropData = false;
27604 this.notifyEl.dom.innerHTML = this.emptyText;
27606 this.selectorEl.dom.value = '';
27610 resize : function()
27612 if(this.fireEvent('resize', this) != false){
27613 this.setThumbBoxPosition();
27614 this.setCanvasPosition();
27618 onFooterButtonClick : function(e, el, o, type)
27621 case 'rotate-left' :
27622 this.onRotateLeft(e);
27624 case 'rotate-right' :
27625 this.onRotateRight(e);
27628 this.beforeSelectFile(e);
27643 this.fireEvent('footerbuttonclick', this, type);
27646 beforeSelectFile : function(e)
27648 e.preventDefault();
27650 if(this.fireEvent('beforeselectfile', this) != false){
27651 this.selectorEl.dom.click();
27655 onFileSelected : function(e)
27657 e.preventDefault();
27659 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27663 var file = this.selectorEl.dom.files[0];
27665 if(this.fireEvent('inspect', this, file) != false){
27666 this.prepare(file);
27671 trash : function(e)
27673 this.fireEvent('trash', this);
27676 download : function(e)
27678 this.fireEvent('download', this);
27681 loadCanvas : function(src)
27683 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27687 this.imageEl = document.createElement('img');
27691 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27693 this.imageEl.src = src;
27697 onLoadCanvas : function()
27699 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27700 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27702 this.bodyEl.un('click', this.beforeSelectFile, this);
27704 this.notifyEl.hide();
27705 this.thumbEl.show();
27706 this.footerEl.show();
27708 this.baseRotateLevel();
27710 if(this.isDocument){
27711 this.setThumbBoxSize();
27714 this.setThumbBoxPosition();
27716 this.baseScaleLevel();
27722 this.canvasLoaded = true;
27725 this.maskEl.unmask();
27730 setCanvasPosition : function()
27732 if(!this.canvasEl){
27736 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27737 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27739 this.previewEl.setLeft(pw);
27740 this.previewEl.setTop(ph);
27744 onMouseDown : function(e)
27748 this.dragable = true;
27749 this.pinching = false;
27751 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27752 this.dragable = false;
27756 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27757 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27761 onMouseMove : function(e)
27765 if(!this.canvasLoaded){
27769 if (!this.dragable){
27773 var minX = Math.ceil(this.thumbEl.getLeft(true));
27774 var minY = Math.ceil(this.thumbEl.getTop(true));
27776 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27777 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27779 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27780 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27782 x = x - this.mouseX;
27783 y = y - this.mouseY;
27785 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27786 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27788 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27789 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27791 this.previewEl.setLeft(bgX);
27792 this.previewEl.setTop(bgY);
27794 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27795 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27798 onMouseUp : function(e)
27802 this.dragable = false;
27805 onMouseWheel : function(e)
27809 this.startScale = this.scale;
27811 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27813 if(!this.zoomable()){
27814 this.scale = this.startScale;
27823 zoomable : function()
27825 var minScale = this.thumbEl.getWidth() / this.minWidth;
27827 if(this.minWidth < this.minHeight){
27828 minScale = this.thumbEl.getHeight() / this.minHeight;
27831 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27832 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27836 (this.rotate == 0 || this.rotate == 180) &&
27838 width > this.imageEl.OriginWidth ||
27839 height > this.imageEl.OriginHeight ||
27840 (width < this.minWidth && height < this.minHeight)
27848 (this.rotate == 90 || this.rotate == 270) &&
27850 width > this.imageEl.OriginWidth ||
27851 height > this.imageEl.OriginHeight ||
27852 (width < this.minHeight && height < this.minWidth)
27859 !this.isDocument &&
27860 (this.rotate == 0 || this.rotate == 180) &&
27862 width < this.minWidth ||
27863 width > this.imageEl.OriginWidth ||
27864 height < this.minHeight ||
27865 height > this.imageEl.OriginHeight
27872 !this.isDocument &&
27873 (this.rotate == 90 || this.rotate == 270) &&
27875 width < this.minHeight ||
27876 width > this.imageEl.OriginWidth ||
27877 height < this.minWidth ||
27878 height > this.imageEl.OriginHeight
27888 onRotateLeft : function(e)
27890 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27892 var minScale = this.thumbEl.getWidth() / this.minWidth;
27894 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27895 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27897 this.startScale = this.scale;
27899 while (this.getScaleLevel() < minScale){
27901 this.scale = this.scale + 1;
27903 if(!this.zoomable()){
27908 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27909 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27914 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27921 this.scale = this.startScale;
27923 this.onRotateFail();
27928 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27930 if(this.isDocument){
27931 this.setThumbBoxSize();
27932 this.setThumbBoxPosition();
27933 this.setCanvasPosition();
27938 this.fireEvent('rotate', this, 'left');
27942 onRotateRight : function(e)
27944 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27946 var minScale = this.thumbEl.getWidth() / this.minWidth;
27948 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27949 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27951 this.startScale = this.scale;
27953 while (this.getScaleLevel() < minScale){
27955 this.scale = this.scale + 1;
27957 if(!this.zoomable()){
27962 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27963 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27968 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27975 this.scale = this.startScale;
27977 this.onRotateFail();
27982 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27984 if(this.isDocument){
27985 this.setThumbBoxSize();
27986 this.setThumbBoxPosition();
27987 this.setCanvasPosition();
27992 this.fireEvent('rotate', this, 'right');
27995 onRotateFail : function()
27997 this.errorEl.show(true);
28001 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28006 this.previewEl.dom.innerHTML = '';
28008 var canvasEl = document.createElement("canvas");
28010 var contextEl = canvasEl.getContext("2d");
28012 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28013 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28014 var center = this.imageEl.OriginWidth / 2;
28016 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28017 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28018 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28019 center = this.imageEl.OriginHeight / 2;
28022 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28024 contextEl.translate(center, center);
28025 contextEl.rotate(this.rotate * Math.PI / 180);
28027 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28029 this.canvasEl = document.createElement("canvas");
28031 this.contextEl = this.canvasEl.getContext("2d");
28033 switch (this.rotate) {
28036 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28037 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28039 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28044 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28045 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28047 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28048 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);
28052 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28057 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28058 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28060 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28061 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);
28065 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);
28070 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28071 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28073 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28074 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28078 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);
28085 this.previewEl.appendChild(this.canvasEl);
28087 this.setCanvasPosition();
28092 if(!this.canvasLoaded){
28096 var imageCanvas = document.createElement("canvas");
28098 var imageContext = imageCanvas.getContext("2d");
28100 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28101 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28103 var center = imageCanvas.width / 2;
28105 imageContext.translate(center, center);
28107 imageContext.rotate(this.rotate * Math.PI / 180);
28109 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28111 var canvas = document.createElement("canvas");
28113 var context = canvas.getContext("2d");
28115 canvas.width = this.minWidth;
28116 canvas.height = this.minHeight;
28118 switch (this.rotate) {
28121 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28122 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28124 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28125 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28127 var targetWidth = this.minWidth - 2 * x;
28128 var targetHeight = this.minHeight - 2 * y;
28132 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28133 scale = targetWidth / width;
28136 if(x > 0 && y == 0){
28137 scale = targetHeight / height;
28140 if(x > 0 && y > 0){
28141 scale = targetWidth / width;
28143 if(width < height){
28144 scale = targetHeight / height;
28148 context.scale(scale, scale);
28150 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28151 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28153 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28154 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28156 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28161 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28162 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28164 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28165 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28167 var targetWidth = this.minWidth - 2 * x;
28168 var targetHeight = this.minHeight - 2 * y;
28172 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28173 scale = targetWidth / width;
28176 if(x > 0 && y == 0){
28177 scale = targetHeight / height;
28180 if(x > 0 && y > 0){
28181 scale = targetWidth / width;
28183 if(width < height){
28184 scale = targetHeight / height;
28188 context.scale(scale, scale);
28190 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28191 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28193 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28194 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28196 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28198 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28203 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28204 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28206 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28207 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28209 var targetWidth = this.minWidth - 2 * x;
28210 var targetHeight = this.minHeight - 2 * y;
28214 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28215 scale = targetWidth / width;
28218 if(x > 0 && y == 0){
28219 scale = targetHeight / height;
28222 if(x > 0 && y > 0){
28223 scale = targetWidth / width;
28225 if(width < height){
28226 scale = targetHeight / height;
28230 context.scale(scale, scale);
28232 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28233 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28235 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28236 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28238 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28239 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28241 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28246 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28247 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28249 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28250 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28252 var targetWidth = this.minWidth - 2 * x;
28253 var targetHeight = this.minHeight - 2 * y;
28257 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28258 scale = targetWidth / width;
28261 if(x > 0 && y == 0){
28262 scale = targetHeight / height;
28265 if(x > 0 && y > 0){
28266 scale = targetWidth / width;
28268 if(width < height){
28269 scale = targetHeight / height;
28273 context.scale(scale, scale);
28275 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28276 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28278 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28279 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28281 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28283 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28290 this.cropData = canvas.toDataURL(this.cropType);
28292 if(this.fireEvent('crop', this, this.cropData) !== false){
28293 this.process(this.file, this.cropData);
28300 setThumbBoxSize : function()
28304 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28305 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28306 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28308 this.minWidth = width;
28309 this.minHeight = height;
28311 if(this.rotate == 90 || this.rotate == 270){
28312 this.minWidth = height;
28313 this.minHeight = width;
28318 width = Math.ceil(this.minWidth * height / this.minHeight);
28320 if(this.minWidth > this.minHeight){
28322 height = Math.ceil(this.minHeight * width / this.minWidth);
28325 this.thumbEl.setStyle({
28326 width : width + 'px',
28327 height : height + 'px'
28334 setThumbBoxPosition : function()
28336 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28337 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28339 this.thumbEl.setLeft(x);
28340 this.thumbEl.setTop(y);
28344 baseRotateLevel : function()
28346 this.baseRotate = 1;
28349 typeof(this.exif) != 'undefined' &&
28350 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28351 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28353 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28356 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28360 baseScaleLevel : function()
28364 if(this.isDocument){
28366 if(this.baseRotate == 6 || this.baseRotate == 8){
28368 height = this.thumbEl.getHeight();
28369 this.baseScale = height / this.imageEl.OriginWidth;
28371 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28372 width = this.thumbEl.getWidth();
28373 this.baseScale = width / this.imageEl.OriginHeight;
28379 height = this.thumbEl.getHeight();
28380 this.baseScale = height / this.imageEl.OriginHeight;
28382 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28383 width = this.thumbEl.getWidth();
28384 this.baseScale = width / this.imageEl.OriginWidth;
28390 if(this.baseRotate == 6 || this.baseRotate == 8){
28392 width = this.thumbEl.getHeight();
28393 this.baseScale = width / this.imageEl.OriginHeight;
28395 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28396 height = this.thumbEl.getWidth();
28397 this.baseScale = height / this.imageEl.OriginHeight;
28400 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28401 height = this.thumbEl.getWidth();
28402 this.baseScale = height / this.imageEl.OriginHeight;
28404 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28405 width = this.thumbEl.getHeight();
28406 this.baseScale = width / this.imageEl.OriginWidth;
28413 width = this.thumbEl.getWidth();
28414 this.baseScale = width / this.imageEl.OriginWidth;
28416 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28417 height = this.thumbEl.getHeight();
28418 this.baseScale = height / this.imageEl.OriginHeight;
28421 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28423 height = this.thumbEl.getHeight();
28424 this.baseScale = height / this.imageEl.OriginHeight;
28426 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28427 width = this.thumbEl.getWidth();
28428 this.baseScale = width / this.imageEl.OriginWidth;
28436 getScaleLevel : function()
28438 return this.baseScale * Math.pow(1.1, this.scale);
28441 onTouchStart : function(e)
28443 if(!this.canvasLoaded){
28444 this.beforeSelectFile(e);
28448 var touches = e.browserEvent.touches;
28454 if(touches.length == 1){
28455 this.onMouseDown(e);
28459 if(touches.length != 2){
28465 for(var i = 0, finger; finger = touches[i]; i++){
28466 coords.push(finger.pageX, finger.pageY);
28469 var x = Math.pow(coords[0] - coords[2], 2);
28470 var y = Math.pow(coords[1] - coords[3], 2);
28472 this.startDistance = Math.sqrt(x + y);
28474 this.startScale = this.scale;
28476 this.pinching = true;
28477 this.dragable = false;
28481 onTouchMove : function(e)
28483 if(!this.pinching && !this.dragable){
28487 var touches = e.browserEvent.touches;
28494 this.onMouseMove(e);
28500 for(var i = 0, finger; finger = touches[i]; i++){
28501 coords.push(finger.pageX, finger.pageY);
28504 var x = Math.pow(coords[0] - coords[2], 2);
28505 var y = Math.pow(coords[1] - coords[3], 2);
28507 this.endDistance = Math.sqrt(x + y);
28509 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28511 if(!this.zoomable()){
28512 this.scale = this.startScale;
28520 onTouchEnd : function(e)
28522 this.pinching = false;
28523 this.dragable = false;
28527 process : function(file, crop)
28530 this.maskEl.mask(this.loadingText);
28533 this.xhr = new XMLHttpRequest();
28535 file.xhr = this.xhr;
28537 this.xhr.open(this.method, this.url, true);
28540 "Accept": "application/json",
28541 "Cache-Control": "no-cache",
28542 "X-Requested-With": "XMLHttpRequest"
28545 for (var headerName in headers) {
28546 var headerValue = headers[headerName];
28548 this.xhr.setRequestHeader(headerName, headerValue);
28554 this.xhr.onload = function()
28556 _this.xhrOnLoad(_this.xhr);
28559 this.xhr.onerror = function()
28561 _this.xhrOnError(_this.xhr);
28564 var formData = new FormData();
28566 formData.append('returnHTML', 'NO');
28569 formData.append('crop', crop);
28572 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28573 formData.append(this.paramName, file, file.name);
28576 if(typeof(file.filename) != 'undefined'){
28577 formData.append('filename', file.filename);
28580 if(typeof(file.mimetype) != 'undefined'){
28581 formData.append('mimetype', file.mimetype);
28584 if(this.fireEvent('arrange', this, formData) != false){
28585 this.xhr.send(formData);
28589 xhrOnLoad : function(xhr)
28592 this.maskEl.unmask();
28595 if (xhr.readyState !== 4) {
28596 this.fireEvent('exception', this, xhr);
28600 var response = Roo.decode(xhr.responseText);
28602 if(!response.success){
28603 this.fireEvent('exception', this, xhr);
28607 var response = Roo.decode(xhr.responseText);
28609 this.fireEvent('upload', this, response);
28613 xhrOnError : function()
28616 this.maskEl.unmask();
28619 Roo.log('xhr on error');
28621 var response = Roo.decode(xhr.responseText);
28627 prepare : function(file)
28630 this.maskEl.mask(this.loadingText);
28636 if(typeof(file) === 'string'){
28637 this.loadCanvas(file);
28641 if(!file || !this.urlAPI){
28646 this.cropType = file.type;
28650 if(this.fireEvent('prepare', this, this.file) != false){
28652 var reader = new FileReader();
28654 reader.onload = function (e) {
28655 if (e.target.error) {
28656 Roo.log(e.target.error);
28660 var buffer = e.target.result,
28661 dataView = new DataView(buffer),
28663 maxOffset = dataView.byteLength - 4,
28667 if (dataView.getUint16(0) === 0xffd8) {
28668 while (offset < maxOffset) {
28669 markerBytes = dataView.getUint16(offset);
28671 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28672 markerLength = dataView.getUint16(offset + 2) + 2;
28673 if (offset + markerLength > dataView.byteLength) {
28674 Roo.log('Invalid meta data: Invalid segment size.');
28678 if(markerBytes == 0xffe1){
28679 _this.parseExifData(
28686 offset += markerLength;
28696 var url = _this.urlAPI.createObjectURL(_this.file);
28698 _this.loadCanvas(url);
28703 reader.readAsArrayBuffer(this.file);
28709 parseExifData : function(dataView, offset, length)
28711 var tiffOffset = offset + 10,
28715 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28716 // No Exif data, might be XMP data instead
28720 // Check for the ASCII code for "Exif" (0x45786966):
28721 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28722 // No Exif data, might be XMP data instead
28725 if (tiffOffset + 8 > dataView.byteLength) {
28726 Roo.log('Invalid Exif data: Invalid segment size.');
28729 // Check for the two null bytes:
28730 if (dataView.getUint16(offset + 8) !== 0x0000) {
28731 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28734 // Check the byte alignment:
28735 switch (dataView.getUint16(tiffOffset)) {
28737 littleEndian = true;
28740 littleEndian = false;
28743 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28746 // Check for the TIFF tag marker (0x002A):
28747 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28748 Roo.log('Invalid Exif data: Missing TIFF marker.');
28751 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28752 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28754 this.parseExifTags(
28757 tiffOffset + dirOffset,
28762 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28767 if (dirOffset + 6 > dataView.byteLength) {
28768 Roo.log('Invalid Exif data: Invalid directory offset.');
28771 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28772 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28773 if (dirEndOffset + 4 > dataView.byteLength) {
28774 Roo.log('Invalid Exif data: Invalid directory size.');
28777 for (i = 0; i < tagsNumber; i += 1) {
28781 dirOffset + 2 + 12 * i, // tag offset
28785 // Return the offset to the next directory:
28786 return dataView.getUint32(dirEndOffset, littleEndian);
28789 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28791 var tag = dataView.getUint16(offset, littleEndian);
28793 this.exif[tag] = this.getExifValue(
28797 dataView.getUint16(offset + 2, littleEndian), // tag type
28798 dataView.getUint32(offset + 4, littleEndian), // tag length
28803 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28805 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28814 Roo.log('Invalid Exif data: Invalid tag type.');
28818 tagSize = tagType.size * length;
28819 // Determine if the value is contained in the dataOffset bytes,
28820 // or if the value at the dataOffset is a pointer to the actual data:
28821 dataOffset = tagSize > 4 ?
28822 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28823 if (dataOffset + tagSize > dataView.byteLength) {
28824 Roo.log('Invalid Exif data: Invalid data offset.');
28827 if (length === 1) {
28828 return tagType.getValue(dataView, dataOffset, littleEndian);
28831 for (i = 0; i < length; i += 1) {
28832 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28835 if (tagType.ascii) {
28837 // Concatenate the chars:
28838 for (i = 0; i < values.length; i += 1) {
28840 // Ignore the terminating NULL byte(s):
28841 if (c === '\u0000') {
28853 Roo.apply(Roo.bootstrap.UploadCropbox, {
28855 'Orientation': 0x0112
28859 1: 0, //'top-left',
28861 3: 180, //'bottom-right',
28862 // 4: 'bottom-left',
28864 6: 90, //'right-top',
28865 // 7: 'right-bottom',
28866 8: 270 //'left-bottom'
28870 // byte, 8-bit unsigned int:
28872 getValue: function (dataView, dataOffset) {
28873 return dataView.getUint8(dataOffset);
28877 // ascii, 8-bit byte:
28879 getValue: function (dataView, dataOffset) {
28880 return String.fromCharCode(dataView.getUint8(dataOffset));
28885 // short, 16 bit int:
28887 getValue: function (dataView, dataOffset, littleEndian) {
28888 return dataView.getUint16(dataOffset, littleEndian);
28892 // long, 32 bit int:
28894 getValue: function (dataView, dataOffset, littleEndian) {
28895 return dataView.getUint32(dataOffset, littleEndian);
28899 // rational = two long values, first is numerator, second is denominator:
28901 getValue: function (dataView, dataOffset, littleEndian) {
28902 return dataView.getUint32(dataOffset, littleEndian) /
28903 dataView.getUint32(dataOffset + 4, littleEndian);
28907 // slong, 32 bit signed int:
28909 getValue: function (dataView, dataOffset, littleEndian) {
28910 return dataView.getInt32(dataOffset, littleEndian);
28914 // srational, two slongs, first is numerator, second is denominator:
28916 getValue: function (dataView, dataOffset, littleEndian) {
28917 return dataView.getInt32(dataOffset, littleEndian) /
28918 dataView.getInt32(dataOffset + 4, littleEndian);
28928 cls : 'btn-group roo-upload-cropbox-rotate-left',
28929 action : 'rotate-left',
28933 cls : 'btn btn-default',
28934 html : '<i class="fa fa-undo"></i>'
28940 cls : 'btn-group roo-upload-cropbox-picture',
28941 action : 'picture',
28945 cls : 'btn btn-default',
28946 html : '<i class="fa fa-picture-o"></i>'
28952 cls : 'btn-group roo-upload-cropbox-rotate-right',
28953 action : 'rotate-right',
28957 cls : 'btn btn-default',
28958 html : '<i class="fa fa-repeat"></i>'
28966 cls : 'btn-group roo-upload-cropbox-rotate-left',
28967 action : 'rotate-left',
28971 cls : 'btn btn-default',
28972 html : '<i class="fa fa-undo"></i>'
28978 cls : 'btn-group roo-upload-cropbox-download',
28979 action : 'download',
28983 cls : 'btn btn-default',
28984 html : '<i class="fa fa-download"></i>'
28990 cls : 'btn-group roo-upload-cropbox-crop',
28995 cls : 'btn btn-default',
28996 html : '<i class="fa fa-crop"></i>'
29002 cls : 'btn-group roo-upload-cropbox-trash',
29007 cls : 'btn btn-default',
29008 html : '<i class="fa fa-trash"></i>'
29014 cls : 'btn-group roo-upload-cropbox-rotate-right',
29015 action : 'rotate-right',
29019 cls : 'btn btn-default',
29020 html : '<i class="fa fa-repeat"></i>'
29028 cls : 'btn-group roo-upload-cropbox-rotate-left',
29029 action : 'rotate-left',
29033 cls : 'btn btn-default',
29034 html : '<i class="fa fa-undo"></i>'
29040 cls : 'btn-group roo-upload-cropbox-rotate-right',
29041 action : 'rotate-right',
29045 cls : 'btn btn-default',
29046 html : '<i class="fa fa-repeat"></i>'
29059 * @class Roo.bootstrap.DocumentManager
29060 * @extends Roo.bootstrap.Component
29061 * Bootstrap DocumentManager class
29062 * @cfg {String} paramName default 'imageUpload'
29063 * @cfg {String} toolTipName default 'filename'
29064 * @cfg {String} method default POST
29065 * @cfg {String} url action url
29066 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29067 * @cfg {Boolean} multiple multiple upload default true
29068 * @cfg {Number} thumbSize default 300
29069 * @cfg {String} fieldLabel
29070 * @cfg {Number} labelWidth default 4
29071 * @cfg {String} labelAlign (left|top) default left
29072 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29073 * @cfg {Number} labellg set the width of label (1-12)
29074 * @cfg {Number} labelmd set the width of label (1-12)
29075 * @cfg {Number} labelsm set the width of label (1-12)
29076 * @cfg {Number} labelxs set the width of label (1-12)
29079 * Create a new DocumentManager
29080 * @param {Object} config The config object
29083 Roo.bootstrap.DocumentManager = function(config){
29084 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29087 this.delegates = [];
29092 * Fire when initial the DocumentManager
29093 * @param {Roo.bootstrap.DocumentManager} this
29098 * inspect selected file
29099 * @param {Roo.bootstrap.DocumentManager} this
29100 * @param {File} file
29105 * Fire when xhr load exception
29106 * @param {Roo.bootstrap.DocumentManager} this
29107 * @param {XMLHttpRequest} xhr
29109 "exception" : true,
29111 * @event afterupload
29112 * Fire when xhr load exception
29113 * @param {Roo.bootstrap.DocumentManager} this
29114 * @param {XMLHttpRequest} xhr
29116 "afterupload" : true,
29119 * prepare the form data
29120 * @param {Roo.bootstrap.DocumentManager} this
29121 * @param {Object} formData
29126 * Fire when remove the file
29127 * @param {Roo.bootstrap.DocumentManager} this
29128 * @param {Object} file
29133 * Fire after refresh the file
29134 * @param {Roo.bootstrap.DocumentManager} this
29139 * Fire after click the image
29140 * @param {Roo.bootstrap.DocumentManager} this
29141 * @param {Object} file
29146 * Fire when upload a image and editable set to true
29147 * @param {Roo.bootstrap.DocumentManager} this
29148 * @param {Object} file
29152 * @event beforeselectfile
29153 * Fire before select file
29154 * @param {Roo.bootstrap.DocumentManager} this
29156 "beforeselectfile" : true,
29159 * Fire before process file
29160 * @param {Roo.bootstrap.DocumentManager} this
29161 * @param {Object} file
29165 * @event previewrendered
29166 * Fire when preview rendered
29167 * @param {Roo.bootstrap.DocumentManager} this
29168 * @param {Object} file
29170 "previewrendered" : true,
29173 "previewResize" : true
29178 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29187 paramName : 'imageUpload',
29188 toolTipName : 'filename',
29191 labelAlign : 'left',
29201 getAutoCreate : function()
29203 var managerWidget = {
29205 cls : 'roo-document-manager',
29209 cls : 'roo-document-manager-selector',
29214 cls : 'roo-document-manager-uploader',
29218 cls : 'roo-document-manager-upload-btn',
29219 html : '<i class="fa fa-plus"></i>'
29230 cls : 'column col-md-12',
29235 if(this.fieldLabel.length){
29240 cls : 'column col-md-12',
29241 html : this.fieldLabel
29245 cls : 'column col-md-12',
29250 if(this.labelAlign == 'left'){
29255 html : this.fieldLabel
29264 if(this.labelWidth > 12){
29265 content[0].style = "width: " + this.labelWidth + 'px';
29268 if(this.labelWidth < 13 && this.labelmd == 0){
29269 this.labelmd = this.labelWidth;
29272 if(this.labellg > 0){
29273 content[0].cls += ' col-lg-' + this.labellg;
29274 content[1].cls += ' col-lg-' + (12 - this.labellg);
29277 if(this.labelmd > 0){
29278 content[0].cls += ' col-md-' + this.labelmd;
29279 content[1].cls += ' col-md-' + (12 - this.labelmd);
29282 if(this.labelsm > 0){
29283 content[0].cls += ' col-sm-' + this.labelsm;
29284 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29287 if(this.labelxs > 0){
29288 content[0].cls += ' col-xs-' + this.labelxs;
29289 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29297 cls : 'row clearfix',
29305 initEvents : function()
29307 this.managerEl = this.el.select('.roo-document-manager', true).first();
29308 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29310 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29311 this.selectorEl.hide();
29314 this.selectorEl.attr('multiple', 'multiple');
29317 this.selectorEl.on('change', this.onFileSelected, this);
29319 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29320 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29322 this.uploader.on('click', this.onUploaderClick, this);
29324 this.renderProgressDialog();
29328 window.addEventListener("resize", function() { _this.refresh(); } );
29330 this.fireEvent('initial', this);
29333 renderProgressDialog : function()
29337 this.progressDialog = new Roo.bootstrap.Modal({
29338 cls : 'roo-document-manager-progress-dialog',
29339 allow_close : false,
29350 btnclick : function() {
29351 _this.uploadCancel();
29357 this.progressDialog.render(Roo.get(document.body));
29359 this.progress = new Roo.bootstrap.Progress({
29360 cls : 'roo-document-manager-progress',
29365 this.progress.render(this.progressDialog.getChildContainer());
29367 this.progressBar = new Roo.bootstrap.ProgressBar({
29368 cls : 'roo-document-manager-progress-bar',
29371 aria_valuemax : 12,
29375 this.progressBar.render(this.progress.getChildContainer());
29378 onUploaderClick : function(e)
29380 e.preventDefault();
29382 if(this.fireEvent('beforeselectfile', this) != false){
29383 this.selectorEl.dom.click();
29388 onFileSelected : function(e)
29390 e.preventDefault();
29392 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29396 Roo.each(this.selectorEl.dom.files, function(file){
29397 if(this.fireEvent('inspect', this, file) != false){
29398 this.files.push(file);
29408 this.selectorEl.dom.value = '';
29410 if(!this.files || !this.files.length){
29414 if(this.boxes > 0 && this.files.length > this.boxes){
29415 this.files = this.files.slice(0, this.boxes);
29418 this.uploader.show();
29420 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29421 this.uploader.hide();
29430 Roo.each(this.files, function(file){
29432 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29433 var f = this.renderPreview(file);
29438 if(file.type.indexOf('image') != -1){
29439 this.delegates.push(
29441 _this.process(file);
29442 }).createDelegate(this)
29450 _this.process(file);
29451 }).createDelegate(this)
29456 this.files = files;
29458 this.delegates = this.delegates.concat(docs);
29460 if(!this.delegates.length){
29465 this.progressBar.aria_valuemax = this.delegates.length;
29472 arrange : function()
29474 if(!this.delegates.length){
29475 this.progressDialog.hide();
29480 var delegate = this.delegates.shift();
29482 this.progressDialog.show();
29484 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29486 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29491 refresh : function()
29493 this.uploader.show();
29495 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29496 this.uploader.hide();
29499 Roo.isTouch ? this.closable(false) : this.closable(true);
29501 this.fireEvent('refresh', this);
29504 onRemove : function(e, el, o)
29506 e.preventDefault();
29508 this.fireEvent('remove', this, o);
29512 remove : function(o)
29516 Roo.each(this.files, function(file){
29517 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29526 this.files = files;
29533 Roo.each(this.files, function(file){
29538 file.target.remove();
29547 onClick : function(e, el, o)
29549 e.preventDefault();
29551 this.fireEvent('click', this, o);
29555 closable : function(closable)
29557 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29559 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29571 xhrOnLoad : function(xhr)
29573 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29577 if (xhr.readyState !== 4) {
29579 this.fireEvent('exception', this, xhr);
29583 var response = Roo.decode(xhr.responseText);
29585 if(!response.success){
29587 this.fireEvent('exception', this, xhr);
29591 var file = this.renderPreview(response.data);
29593 this.files.push(file);
29597 this.fireEvent('afterupload', this, xhr);
29601 xhrOnError : function(xhr)
29603 Roo.log('xhr on error');
29605 var response = Roo.decode(xhr.responseText);
29612 process : function(file)
29614 if(this.fireEvent('process', this, file) !== false){
29615 if(this.editable && file.type.indexOf('image') != -1){
29616 this.fireEvent('edit', this, file);
29620 this.uploadStart(file, false);
29627 uploadStart : function(file, crop)
29629 this.xhr = new XMLHttpRequest();
29631 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29636 file.xhr = this.xhr;
29638 this.managerEl.createChild({
29640 cls : 'roo-document-manager-loading',
29644 tooltip : file.name,
29645 cls : 'roo-document-manager-thumb',
29646 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29652 this.xhr.open(this.method, this.url, true);
29655 "Accept": "application/json",
29656 "Cache-Control": "no-cache",
29657 "X-Requested-With": "XMLHttpRequest"
29660 for (var headerName in headers) {
29661 var headerValue = headers[headerName];
29663 this.xhr.setRequestHeader(headerName, headerValue);
29669 this.xhr.onload = function()
29671 _this.xhrOnLoad(_this.xhr);
29674 this.xhr.onerror = function()
29676 _this.xhrOnError(_this.xhr);
29679 var formData = new FormData();
29681 formData.append('returnHTML', 'NO');
29684 formData.append('crop', crop);
29687 formData.append(this.paramName, file, file.name);
29694 if(this.fireEvent('prepare', this, formData, options) != false){
29696 if(options.manually){
29700 this.xhr.send(formData);
29704 this.uploadCancel();
29707 uploadCancel : function()
29713 this.delegates = [];
29715 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29722 renderPreview : function(file)
29724 if(typeof(file.target) != 'undefined' && file.target){
29728 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29730 var previewEl = this.managerEl.createChild({
29732 cls : 'roo-document-manager-preview',
29736 tooltip : file[this.toolTipName],
29737 cls : 'roo-document-manager-thumb',
29738 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29743 html : '<i class="fa fa-times-circle"></i>'
29748 var close = previewEl.select('button.close', true).first();
29750 close.on('click', this.onRemove, this, file);
29752 file.target = previewEl;
29754 var image = previewEl.select('img', true).first();
29758 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29760 image.on('click', this.onClick, this, file);
29762 this.fireEvent('previewrendered', this, file);
29768 onPreviewLoad : function(file, image)
29770 if(typeof(file.target) == 'undefined' || !file.target){
29774 var width = image.dom.naturalWidth || image.dom.width;
29775 var height = image.dom.naturalHeight || image.dom.height;
29777 if(!this.previewResize) {
29781 if(width > height){
29782 file.target.addClass('wide');
29786 file.target.addClass('tall');
29791 uploadFromSource : function(file, crop)
29793 this.xhr = new XMLHttpRequest();
29795 this.managerEl.createChild({
29797 cls : 'roo-document-manager-loading',
29801 tooltip : file.name,
29802 cls : 'roo-document-manager-thumb',
29803 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29809 this.xhr.open(this.method, this.url, true);
29812 "Accept": "application/json",
29813 "Cache-Control": "no-cache",
29814 "X-Requested-With": "XMLHttpRequest"
29817 for (var headerName in headers) {
29818 var headerValue = headers[headerName];
29820 this.xhr.setRequestHeader(headerName, headerValue);
29826 this.xhr.onload = function()
29828 _this.xhrOnLoad(_this.xhr);
29831 this.xhr.onerror = function()
29833 _this.xhrOnError(_this.xhr);
29836 var formData = new FormData();
29838 formData.append('returnHTML', 'NO');
29840 formData.append('crop', crop);
29842 if(typeof(file.filename) != 'undefined'){
29843 formData.append('filename', file.filename);
29846 if(typeof(file.mimetype) != 'undefined'){
29847 formData.append('mimetype', file.mimetype);
29852 if(this.fireEvent('prepare', this, formData) != false){
29853 this.xhr.send(formData);
29863 * @class Roo.bootstrap.DocumentViewer
29864 * @extends Roo.bootstrap.Component
29865 * Bootstrap DocumentViewer class
29866 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29867 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29870 * Create a new DocumentViewer
29871 * @param {Object} config The config object
29874 Roo.bootstrap.DocumentViewer = function(config){
29875 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29880 * Fire after initEvent
29881 * @param {Roo.bootstrap.DocumentViewer} this
29887 * @param {Roo.bootstrap.DocumentViewer} this
29892 * Fire after download button
29893 * @param {Roo.bootstrap.DocumentViewer} this
29898 * Fire after trash button
29899 * @param {Roo.bootstrap.DocumentViewer} this
29906 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29908 showDownload : true,
29912 getAutoCreate : function()
29916 cls : 'roo-document-viewer',
29920 cls : 'roo-document-viewer-body',
29924 cls : 'roo-document-viewer-thumb',
29928 cls : 'roo-document-viewer-image'
29936 cls : 'roo-document-viewer-footer',
29939 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29943 cls : 'btn-group roo-document-viewer-download',
29947 cls : 'btn btn-default',
29948 html : '<i class="fa fa-download"></i>'
29954 cls : 'btn-group roo-document-viewer-trash',
29958 cls : 'btn btn-default',
29959 html : '<i class="fa fa-trash"></i>'
29972 initEvents : function()
29974 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29975 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29977 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29978 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29980 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29981 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29983 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29984 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29986 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29987 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29989 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29990 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29992 this.bodyEl.on('click', this.onClick, this);
29993 this.downloadBtn.on('click', this.onDownload, this);
29994 this.trashBtn.on('click', this.onTrash, this);
29996 this.downloadBtn.hide();
29997 this.trashBtn.hide();
29999 if(this.showDownload){
30000 this.downloadBtn.show();
30003 if(this.showTrash){
30004 this.trashBtn.show();
30007 if(!this.showDownload && !this.showTrash) {
30008 this.footerEl.hide();
30013 initial : function()
30015 this.fireEvent('initial', this);
30019 onClick : function(e)
30021 e.preventDefault();
30023 this.fireEvent('click', this);
30026 onDownload : function(e)
30028 e.preventDefault();
30030 this.fireEvent('download', this);
30033 onTrash : function(e)
30035 e.preventDefault();
30037 this.fireEvent('trash', this);
30049 * @class Roo.bootstrap.NavProgressBar
30050 * @extends Roo.bootstrap.Component
30051 * Bootstrap NavProgressBar class
30054 * Create a new nav progress bar
30055 * @param {Object} config The config object
30058 Roo.bootstrap.NavProgressBar = function(config){
30059 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30061 this.bullets = this.bullets || [];
30063 // Roo.bootstrap.NavProgressBar.register(this);
30067 * Fires when the active item changes
30068 * @param {Roo.bootstrap.NavProgressBar} this
30069 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30070 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30077 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30082 getAutoCreate : function()
30084 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30088 cls : 'roo-navigation-bar-group',
30092 cls : 'roo-navigation-top-bar'
30096 cls : 'roo-navigation-bullets-bar',
30100 cls : 'roo-navigation-bar'
30107 cls : 'roo-navigation-bottom-bar'
30117 initEvents: function()
30122 onRender : function(ct, position)
30124 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30126 if(this.bullets.length){
30127 Roo.each(this.bullets, function(b){
30136 addItem : function(cfg)
30138 var item = new Roo.bootstrap.NavProgressItem(cfg);
30140 item.parentId = this.id;
30141 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30144 var top = new Roo.bootstrap.Element({
30146 cls : 'roo-navigation-bar-text'
30149 var bottom = new Roo.bootstrap.Element({
30151 cls : 'roo-navigation-bar-text'
30154 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30155 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30157 var topText = new Roo.bootstrap.Element({
30159 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30162 var bottomText = new Roo.bootstrap.Element({
30164 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30167 topText.onRender(top.el, null);
30168 bottomText.onRender(bottom.el, null);
30171 item.bottomEl = bottom;
30174 this.barItems.push(item);
30179 getActive : function()
30181 var active = false;
30183 Roo.each(this.barItems, function(v){
30185 if (!v.isActive()) {
30197 setActiveItem : function(item)
30201 Roo.each(this.barItems, function(v){
30202 if (v.rid == item.rid) {
30206 if (v.isActive()) {
30207 v.setActive(false);
30212 item.setActive(true);
30214 this.fireEvent('changed', this, item, prev);
30217 getBarItem: function(rid)
30221 Roo.each(this.barItems, function(e) {
30222 if (e.rid != rid) {
30233 indexOfItem : function(item)
30237 Roo.each(this.barItems, function(v, i){
30239 if (v.rid != item.rid) {
30250 setActiveNext : function()
30252 var i = this.indexOfItem(this.getActive());
30254 if (i > this.barItems.length) {
30258 this.setActiveItem(this.barItems[i+1]);
30261 setActivePrev : function()
30263 var i = this.indexOfItem(this.getActive());
30269 this.setActiveItem(this.barItems[i-1]);
30272 format : function()
30274 if(!this.barItems.length){
30278 var width = 100 / this.barItems.length;
30280 Roo.each(this.barItems, function(i){
30281 i.el.setStyle('width', width + '%');
30282 i.topEl.el.setStyle('width', width + '%');
30283 i.bottomEl.el.setStyle('width', width + '%');
30292 * Nav Progress Item
30297 * @class Roo.bootstrap.NavProgressItem
30298 * @extends Roo.bootstrap.Component
30299 * Bootstrap NavProgressItem class
30300 * @cfg {String} rid the reference id
30301 * @cfg {Boolean} active (true|false) Is item active default false
30302 * @cfg {Boolean} disabled (true|false) Is item active default false
30303 * @cfg {String} html
30304 * @cfg {String} position (top|bottom) text position default bottom
30305 * @cfg {String} icon show icon instead of number
30308 * Create a new NavProgressItem
30309 * @param {Object} config The config object
30311 Roo.bootstrap.NavProgressItem = function(config){
30312 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30317 * The raw click event for the entire grid.
30318 * @param {Roo.bootstrap.NavProgressItem} this
30319 * @param {Roo.EventObject} e
30326 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30332 position : 'bottom',
30335 getAutoCreate : function()
30337 var iconCls = 'roo-navigation-bar-item-icon';
30339 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30343 cls: 'roo-navigation-bar-item',
30353 cfg.cls += ' active';
30356 cfg.cls += ' disabled';
30362 disable : function()
30364 this.setDisabled(true);
30367 enable : function()
30369 this.setDisabled(false);
30372 initEvents: function()
30374 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30376 this.iconEl.on('click', this.onClick, this);
30379 onClick : function(e)
30381 e.preventDefault();
30387 if(this.fireEvent('click', this, e) === false){
30391 this.parent().setActiveItem(this);
30394 isActive: function ()
30396 return this.active;
30399 setActive : function(state)
30401 if(this.active == state){
30405 this.active = state;
30408 this.el.addClass('active');
30412 this.el.removeClass('active');
30417 setDisabled : function(state)
30419 if(this.disabled == state){
30423 this.disabled = state;
30426 this.el.addClass('disabled');
30430 this.el.removeClass('disabled');
30433 tooltipEl : function()
30435 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30448 * @class Roo.bootstrap.FieldLabel
30449 * @extends Roo.bootstrap.Component
30450 * Bootstrap FieldLabel class
30451 * @cfg {String} html contents of the element
30452 * @cfg {String} tag tag of the element default label
30453 * @cfg {String} cls class of the element
30454 * @cfg {String} target label target
30455 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30456 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30457 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30458 * @cfg {String} iconTooltip default "This field is required"
30459 * @cfg {String} indicatorpos (left|right) default left
30462 * Create a new FieldLabel
30463 * @param {Object} config The config object
30466 Roo.bootstrap.FieldLabel = function(config){
30467 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30472 * Fires after the field has been marked as invalid.
30473 * @param {Roo.form.FieldLabel} this
30474 * @param {String} msg The validation message
30479 * Fires after the field has been validated with no errors.
30480 * @param {Roo.form.FieldLabel} this
30486 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30493 invalidClass : 'has-warning',
30494 validClass : 'has-success',
30495 iconTooltip : 'This field is required',
30496 indicatorpos : 'left',
30498 getAutoCreate : function(){
30501 if (!this.allowBlank) {
30507 cls : 'roo-bootstrap-field-label ' + this.cls,
30512 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30513 tooltip : this.iconTooltip
30522 if(this.indicatorpos == 'right'){
30525 cls : 'roo-bootstrap-field-label ' + this.cls,
30534 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30535 tooltip : this.iconTooltip
30544 initEvents: function()
30546 Roo.bootstrap.Element.superclass.initEvents.call(this);
30548 this.indicator = this.indicatorEl();
30550 if(this.indicator){
30551 this.indicator.removeClass('visible');
30552 this.indicator.addClass('invisible');
30555 Roo.bootstrap.FieldLabel.register(this);
30558 indicatorEl : function()
30560 var indicator = this.el.select('i.roo-required-indicator',true).first();
30571 * Mark this field as valid
30573 markValid : function()
30575 if(this.indicator){
30576 this.indicator.removeClass('visible');
30577 this.indicator.addClass('invisible');
30579 if (Roo.bootstrap.version == 3) {
30580 this.el.removeClass(this.invalidClass);
30581 this.el.addClass(this.validClass);
30583 this.el.removeClass('is-invalid');
30584 this.el.addClass('is-valid');
30588 this.fireEvent('valid', this);
30592 * Mark this field as invalid
30593 * @param {String} msg The validation message
30595 markInvalid : function(msg)
30597 if(this.indicator){
30598 this.indicator.removeClass('invisible');
30599 this.indicator.addClass('visible');
30601 if (Roo.bootstrap.version == 3) {
30602 this.el.removeClass(this.validClass);
30603 this.el.addClass(this.invalidClass);
30605 this.el.removeClass('is-valid');
30606 this.el.addClass('is-invalid');
30610 this.fireEvent('invalid', this, msg);
30616 Roo.apply(Roo.bootstrap.FieldLabel, {
30621 * register a FieldLabel Group
30622 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30624 register : function(label)
30626 if(this.groups.hasOwnProperty(label.target)){
30630 this.groups[label.target] = label;
30634 * fetch a FieldLabel Group based on the target
30635 * @param {string} target
30636 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30638 get: function(target) {
30639 if (typeof(this.groups[target]) == 'undefined') {
30643 return this.groups[target] ;
30652 * page DateSplitField.
30658 * @class Roo.bootstrap.DateSplitField
30659 * @extends Roo.bootstrap.Component
30660 * Bootstrap DateSplitField class
30661 * @cfg {string} fieldLabel - the label associated
30662 * @cfg {Number} labelWidth set the width of label (0-12)
30663 * @cfg {String} labelAlign (top|left)
30664 * @cfg {Boolean} dayAllowBlank (true|false) default false
30665 * @cfg {Boolean} monthAllowBlank (true|false) default false
30666 * @cfg {Boolean} yearAllowBlank (true|false) default false
30667 * @cfg {string} dayPlaceholder
30668 * @cfg {string} monthPlaceholder
30669 * @cfg {string} yearPlaceholder
30670 * @cfg {string} dayFormat default 'd'
30671 * @cfg {string} monthFormat default 'm'
30672 * @cfg {string} yearFormat default 'Y'
30673 * @cfg {Number} labellg set the width of label (1-12)
30674 * @cfg {Number} labelmd set the width of label (1-12)
30675 * @cfg {Number} labelsm set the width of label (1-12)
30676 * @cfg {Number} labelxs set the width of label (1-12)
30680 * Create a new DateSplitField
30681 * @param {Object} config The config object
30684 Roo.bootstrap.DateSplitField = function(config){
30685 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30691 * getting the data of years
30692 * @param {Roo.bootstrap.DateSplitField} this
30693 * @param {Object} years
30698 * getting the data of days
30699 * @param {Roo.bootstrap.DateSplitField} this
30700 * @param {Object} days
30705 * Fires after the field has been marked as invalid.
30706 * @param {Roo.form.Field} this
30707 * @param {String} msg The validation message
30712 * Fires after the field has been validated with no errors.
30713 * @param {Roo.form.Field} this
30719 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30722 labelAlign : 'top',
30724 dayAllowBlank : false,
30725 monthAllowBlank : false,
30726 yearAllowBlank : false,
30727 dayPlaceholder : '',
30728 monthPlaceholder : '',
30729 yearPlaceholder : '',
30733 isFormField : true,
30739 getAutoCreate : function()
30743 cls : 'row roo-date-split-field-group',
30748 cls : 'form-hidden-field roo-date-split-field-group-value',
30754 var labelCls = 'col-md-12';
30755 var contentCls = 'col-md-4';
30757 if(this.fieldLabel){
30761 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30765 html : this.fieldLabel
30770 if(this.labelAlign == 'left'){
30772 if(this.labelWidth > 12){
30773 label.style = "width: " + this.labelWidth + 'px';
30776 if(this.labelWidth < 13 && this.labelmd == 0){
30777 this.labelmd = this.labelWidth;
30780 if(this.labellg > 0){
30781 labelCls = ' col-lg-' + this.labellg;
30782 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30785 if(this.labelmd > 0){
30786 labelCls = ' col-md-' + this.labelmd;
30787 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30790 if(this.labelsm > 0){
30791 labelCls = ' col-sm-' + this.labelsm;
30792 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30795 if(this.labelxs > 0){
30796 labelCls = ' col-xs-' + this.labelxs;
30797 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30801 label.cls += ' ' + labelCls;
30803 cfg.cn.push(label);
30806 Roo.each(['day', 'month', 'year'], function(t){
30809 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30816 inputEl: function ()
30818 return this.el.select('.roo-date-split-field-group-value', true).first();
30821 onRender : function(ct, position)
30825 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30827 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30829 this.dayField = new Roo.bootstrap.ComboBox({
30830 allowBlank : this.dayAllowBlank,
30831 alwaysQuery : true,
30832 displayField : 'value',
30835 forceSelection : true,
30837 placeholder : this.dayPlaceholder,
30838 selectOnFocus : true,
30839 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30840 triggerAction : 'all',
30842 valueField : 'value',
30843 store : new Roo.data.SimpleStore({
30844 data : (function() {
30846 _this.fireEvent('days', _this, days);
30849 fields : [ 'value' ]
30852 select : function (_self, record, index)
30854 _this.setValue(_this.getValue());
30859 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30861 this.monthField = new Roo.bootstrap.MonthField({
30862 after : '<i class=\"fa fa-calendar\"></i>',
30863 allowBlank : this.monthAllowBlank,
30864 placeholder : this.monthPlaceholder,
30867 render : function (_self)
30869 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30870 e.preventDefault();
30874 select : function (_self, oldvalue, newvalue)
30876 _this.setValue(_this.getValue());
30881 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30883 this.yearField = new Roo.bootstrap.ComboBox({
30884 allowBlank : this.yearAllowBlank,
30885 alwaysQuery : true,
30886 displayField : 'value',
30889 forceSelection : true,
30891 placeholder : this.yearPlaceholder,
30892 selectOnFocus : true,
30893 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30894 triggerAction : 'all',
30896 valueField : 'value',
30897 store : new Roo.data.SimpleStore({
30898 data : (function() {
30900 _this.fireEvent('years', _this, years);
30903 fields : [ 'value' ]
30906 select : function (_self, record, index)
30908 _this.setValue(_this.getValue());
30913 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30916 setValue : function(v, format)
30918 this.inputEl.dom.value = v;
30920 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30922 var d = Date.parseDate(v, f);
30929 this.setDay(d.format(this.dayFormat));
30930 this.setMonth(d.format(this.monthFormat));
30931 this.setYear(d.format(this.yearFormat));
30938 setDay : function(v)
30940 this.dayField.setValue(v);
30941 this.inputEl.dom.value = this.getValue();
30946 setMonth : function(v)
30948 this.monthField.setValue(v, true);
30949 this.inputEl.dom.value = this.getValue();
30954 setYear : function(v)
30956 this.yearField.setValue(v);
30957 this.inputEl.dom.value = this.getValue();
30962 getDay : function()
30964 return this.dayField.getValue();
30967 getMonth : function()
30969 return this.monthField.getValue();
30972 getYear : function()
30974 return this.yearField.getValue();
30977 getValue : function()
30979 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30981 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30991 this.inputEl.dom.value = '';
30996 validate : function()
30998 var d = this.dayField.validate();
30999 var m = this.monthField.validate();
31000 var y = this.yearField.validate();
31005 (!this.dayAllowBlank && !d) ||
31006 (!this.monthAllowBlank && !m) ||
31007 (!this.yearAllowBlank && !y)
31012 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31021 this.markInvalid();
31026 markValid : function()
31029 var label = this.el.select('label', true).first();
31030 var icon = this.el.select('i.fa-star', true).first();
31036 this.fireEvent('valid', this);
31040 * Mark this field as invalid
31041 * @param {String} msg The validation message
31043 markInvalid : function(msg)
31046 var label = this.el.select('label', true).first();
31047 var icon = this.el.select('i.fa-star', true).first();
31049 if(label && !icon){
31050 this.el.select('.roo-date-split-field-label', true).createChild({
31052 cls : 'text-danger fa fa-lg fa-star',
31053 tooltip : 'This field is required',
31054 style : 'margin-right:5px;'
31058 this.fireEvent('invalid', this, msg);
31061 clearInvalid : function()
31063 var label = this.el.select('label', true).first();
31064 var icon = this.el.select('i.fa-star', true).first();
31070 this.fireEvent('valid', this);
31073 getName: function()
31083 * http://masonry.desandro.com
31085 * The idea is to render all the bricks based on vertical width...
31087 * The original code extends 'outlayer' - we might need to use that....
31093 * @class Roo.bootstrap.LayoutMasonry
31094 * @extends Roo.bootstrap.Component
31095 * Bootstrap Layout Masonry class
31098 * Create a new Element
31099 * @param {Object} config The config object
31102 Roo.bootstrap.LayoutMasonry = function(config){
31104 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31108 Roo.bootstrap.LayoutMasonry.register(this);
31114 * Fire after layout the items
31115 * @param {Roo.bootstrap.LayoutMasonry} this
31116 * @param {Roo.EventObject} e
31123 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31126 * @cfg {Boolean} isLayoutInstant = no animation?
31128 isLayoutInstant : false, // needed?
31131 * @cfg {Number} boxWidth width of the columns
31136 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31141 * @cfg {Number} padWidth padding below box..
31146 * @cfg {Number} gutter gutter width..
31151 * @cfg {Number} maxCols maximum number of columns
31157 * @cfg {Boolean} isAutoInitial defalut true
31159 isAutoInitial : true,
31164 * @cfg {Boolean} isHorizontal defalut false
31166 isHorizontal : false,
31168 currentSize : null,
31174 bricks: null, //CompositeElement
31178 _isLayoutInited : false,
31180 // isAlternative : false, // only use for vertical layout...
31183 * @cfg {Number} alternativePadWidth padding below box..
31185 alternativePadWidth : 50,
31187 selectedBrick : [],
31189 getAutoCreate : function(){
31191 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31195 cls: 'blog-masonary-wrapper ' + this.cls,
31197 cls : 'mas-boxes masonary'
31204 getChildContainer: function( )
31206 if (this.boxesEl) {
31207 return this.boxesEl;
31210 this.boxesEl = this.el.select('.mas-boxes').first();
31212 return this.boxesEl;
31216 initEvents : function()
31220 if(this.isAutoInitial){
31221 Roo.log('hook children rendered');
31222 this.on('childrenrendered', function() {
31223 Roo.log('children rendered');
31229 initial : function()
31231 this.selectedBrick = [];
31233 this.currentSize = this.el.getBox(true);
31235 Roo.EventManager.onWindowResize(this.resize, this);
31237 if(!this.isAutoInitial){
31245 //this.layout.defer(500,this);
31249 resize : function()
31251 var cs = this.el.getBox(true);
31254 this.currentSize.width == cs.width &&
31255 this.currentSize.x == cs.x &&
31256 this.currentSize.height == cs.height &&
31257 this.currentSize.y == cs.y
31259 Roo.log("no change in with or X or Y");
31263 this.currentSize = cs;
31269 layout : function()
31271 this._resetLayout();
31273 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31275 this.layoutItems( isInstant );
31277 this._isLayoutInited = true;
31279 this.fireEvent('layout', this);
31283 _resetLayout : function()
31285 if(this.isHorizontal){
31286 this.horizontalMeasureColumns();
31290 this.verticalMeasureColumns();
31294 verticalMeasureColumns : function()
31296 this.getContainerWidth();
31298 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31299 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31303 var boxWidth = this.boxWidth + this.padWidth;
31305 if(this.containerWidth < this.boxWidth){
31306 boxWidth = this.containerWidth
31309 var containerWidth = this.containerWidth;
31311 var cols = Math.floor(containerWidth / boxWidth);
31313 this.cols = Math.max( cols, 1 );
31315 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31317 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31319 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31321 this.colWidth = boxWidth + avail - this.padWidth;
31323 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31324 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31327 horizontalMeasureColumns : function()
31329 this.getContainerWidth();
31331 var boxWidth = this.boxWidth;
31333 if(this.containerWidth < boxWidth){
31334 boxWidth = this.containerWidth;
31337 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31339 this.el.setHeight(boxWidth);
31343 getContainerWidth : function()
31345 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31348 layoutItems : function( isInstant )
31350 Roo.log(this.bricks);
31352 var items = Roo.apply([], this.bricks);
31354 if(this.isHorizontal){
31355 this._horizontalLayoutItems( items , isInstant );
31359 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31360 // this._verticalAlternativeLayoutItems( items , isInstant );
31364 this._verticalLayoutItems( items , isInstant );
31368 _verticalLayoutItems : function ( items , isInstant)
31370 if ( !items || !items.length ) {
31375 ['xs', 'xs', 'xs', 'tall'],
31376 ['xs', 'xs', 'tall'],
31377 ['xs', 'xs', 'sm'],
31378 ['xs', 'xs', 'xs'],
31384 ['sm', 'xs', 'xs'],
31388 ['tall', 'xs', 'xs', 'xs'],
31389 ['tall', 'xs', 'xs'],
31401 Roo.each(items, function(item, k){
31403 switch (item.size) {
31404 // these layouts take up a full box,
31415 boxes.push([item]);
31438 var filterPattern = function(box, length)
31446 var pattern = box.slice(0, length);
31450 Roo.each(pattern, function(i){
31451 format.push(i.size);
31454 Roo.each(standard, function(s){
31456 if(String(s) != String(format)){
31465 if(!match && length == 1){
31470 filterPattern(box, length - 1);
31474 queue.push(pattern);
31476 box = box.slice(length, box.length);
31478 filterPattern(box, 4);
31484 Roo.each(boxes, function(box, k){
31490 if(box.length == 1){
31495 filterPattern(box, 4);
31499 this._processVerticalLayoutQueue( queue, isInstant );
31503 // _verticalAlternativeLayoutItems : function( items , isInstant )
31505 // if ( !items || !items.length ) {
31509 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31513 _horizontalLayoutItems : function ( items , isInstant)
31515 if ( !items || !items.length || items.length < 3) {
31521 var eItems = items.slice(0, 3);
31523 items = items.slice(3, items.length);
31526 ['xs', 'xs', 'xs', 'wide'],
31527 ['xs', 'xs', 'wide'],
31528 ['xs', 'xs', 'sm'],
31529 ['xs', 'xs', 'xs'],
31535 ['sm', 'xs', 'xs'],
31539 ['wide', 'xs', 'xs', 'xs'],
31540 ['wide', 'xs', 'xs'],
31553 Roo.each(items, function(item, k){
31555 switch (item.size) {
31566 boxes.push([item]);
31590 var filterPattern = function(box, length)
31598 var pattern = box.slice(0, length);
31602 Roo.each(pattern, function(i){
31603 format.push(i.size);
31606 Roo.each(standard, function(s){
31608 if(String(s) != String(format)){
31617 if(!match && length == 1){
31622 filterPattern(box, length - 1);
31626 queue.push(pattern);
31628 box = box.slice(length, box.length);
31630 filterPattern(box, 4);
31636 Roo.each(boxes, function(box, k){
31642 if(box.length == 1){
31647 filterPattern(box, 4);
31654 var pos = this.el.getBox(true);
31658 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31660 var hit_end = false;
31662 Roo.each(queue, function(box){
31666 Roo.each(box, function(b){
31668 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31678 Roo.each(box, function(b){
31680 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31683 mx = Math.max(mx, b.x);
31687 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31691 Roo.each(box, function(b){
31693 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31707 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31710 /** Sets position of item in DOM
31711 * @param {Element} item
31712 * @param {Number} x - horizontal position
31713 * @param {Number} y - vertical position
31714 * @param {Boolean} isInstant - disables transitions
31716 _processVerticalLayoutQueue : function( queue, isInstant )
31718 var pos = this.el.getBox(true);
31723 for (var i = 0; i < this.cols; i++){
31727 Roo.each(queue, function(box, k){
31729 var col = k % this.cols;
31731 Roo.each(box, function(b,kk){
31733 b.el.position('absolute');
31735 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31736 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31738 if(b.size == 'md-left' || b.size == 'md-right'){
31739 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31740 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31743 b.el.setWidth(width);
31744 b.el.setHeight(height);
31746 b.el.select('iframe',true).setSize(width,height);
31750 for (var i = 0; i < this.cols; i++){
31752 if(maxY[i] < maxY[col]){
31757 col = Math.min(col, i);
31761 x = pos.x + col * (this.colWidth + this.padWidth);
31765 var positions = [];
31767 switch (box.length){
31769 positions = this.getVerticalOneBoxColPositions(x, y, box);
31772 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31775 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31778 positions = this.getVerticalFourBoxColPositions(x, y, box);
31784 Roo.each(box, function(b,kk){
31786 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31788 var sz = b.el.getSize();
31790 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31798 for (var i = 0; i < this.cols; i++){
31799 mY = Math.max(mY, maxY[i]);
31802 this.el.setHeight(mY - pos.y);
31806 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31808 // var pos = this.el.getBox(true);
31811 // var maxX = pos.right;
31813 // var maxHeight = 0;
31815 // Roo.each(items, function(item, k){
31819 // item.el.position('absolute');
31821 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31823 // item.el.setWidth(width);
31825 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31827 // item.el.setHeight(height);
31830 // item.el.setXY([x, y], isInstant ? false : true);
31832 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31835 // y = y + height + this.alternativePadWidth;
31837 // maxHeight = maxHeight + height + this.alternativePadWidth;
31841 // this.el.setHeight(maxHeight);
31845 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31847 var pos = this.el.getBox(true);
31852 var maxX = pos.right;
31854 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31856 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31858 Roo.each(queue, function(box, k){
31860 Roo.each(box, function(b, kk){
31862 b.el.position('absolute');
31864 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31865 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31867 if(b.size == 'md-left' || b.size == 'md-right'){
31868 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31869 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31872 b.el.setWidth(width);
31873 b.el.setHeight(height);
31881 var positions = [];
31883 switch (box.length){
31885 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31888 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31891 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31894 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31900 Roo.each(box, function(b,kk){
31902 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31904 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31912 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31914 Roo.each(eItems, function(b,k){
31916 b.size = (k == 0) ? 'sm' : 'xs';
31917 b.x = (k == 0) ? 2 : 1;
31918 b.y = (k == 0) ? 2 : 1;
31920 b.el.position('absolute');
31922 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31924 b.el.setWidth(width);
31926 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31928 b.el.setHeight(height);
31932 var positions = [];
31935 x : maxX - this.unitWidth * 2 - this.gutter,
31940 x : maxX - this.unitWidth,
31941 y : minY + (this.unitWidth + this.gutter) * 2
31945 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31949 Roo.each(eItems, function(b,k){
31951 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31957 getVerticalOneBoxColPositions : function(x, y, box)
31961 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31963 if(box[0].size == 'md-left'){
31967 if(box[0].size == 'md-right'){
31972 x : x + (this.unitWidth + this.gutter) * rand,
31979 getVerticalTwoBoxColPositions : function(x, y, box)
31983 if(box[0].size == 'xs'){
31987 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31991 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32005 x : x + (this.unitWidth + this.gutter) * 2,
32006 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32013 getVerticalThreeBoxColPositions : function(x, y, box)
32017 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32025 x : x + (this.unitWidth + this.gutter) * 1,
32030 x : x + (this.unitWidth + this.gutter) * 2,
32038 if(box[0].size == 'xs' && box[1].size == 'xs'){
32047 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32051 x : x + (this.unitWidth + this.gutter) * 1,
32065 x : x + (this.unitWidth + this.gutter) * 2,
32070 x : x + (this.unitWidth + this.gutter) * 2,
32071 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32078 getVerticalFourBoxColPositions : function(x, y, box)
32082 if(box[0].size == 'xs'){
32091 y : y + (this.unitHeight + this.gutter) * 1
32096 y : y + (this.unitHeight + this.gutter) * 2
32100 x : x + (this.unitWidth + this.gutter) * 1,
32114 x : x + (this.unitWidth + this.gutter) * 2,
32119 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32120 y : y + (this.unitHeight + this.gutter) * 1
32124 x : x + (this.unitWidth + this.gutter) * 2,
32125 y : y + (this.unitWidth + this.gutter) * 2
32132 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32136 if(box[0].size == 'md-left'){
32138 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32145 if(box[0].size == 'md-right'){
32147 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32148 y : minY + (this.unitWidth + this.gutter) * 1
32154 var rand = Math.floor(Math.random() * (4 - box[0].y));
32157 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32158 y : minY + (this.unitWidth + this.gutter) * rand
32165 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32169 if(box[0].size == 'xs'){
32172 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32177 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32178 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32186 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32191 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32192 y : minY + (this.unitWidth + this.gutter) * 2
32199 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32203 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32206 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32211 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32212 y : minY + (this.unitWidth + this.gutter) * 1
32216 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32217 y : minY + (this.unitWidth + this.gutter) * 2
32224 if(box[0].size == 'xs' && box[1].size == 'xs'){
32227 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32232 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32237 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32238 y : minY + (this.unitWidth + this.gutter) * 1
32246 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32251 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32252 y : minY + (this.unitWidth + this.gutter) * 2
32256 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32257 y : minY + (this.unitWidth + this.gutter) * 2
32264 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32268 if(box[0].size == 'xs'){
32271 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32276 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32281 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),
32286 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32287 y : minY + (this.unitWidth + this.gutter) * 1
32295 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32300 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32301 y : minY + (this.unitWidth + this.gutter) * 2
32305 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32306 y : minY + (this.unitWidth + this.gutter) * 2
32310 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),
32311 y : minY + (this.unitWidth + this.gutter) * 2
32319 * remove a Masonry Brick
32320 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32322 removeBrick : function(brick_id)
32328 for (var i = 0; i<this.bricks.length; i++) {
32329 if (this.bricks[i].id == brick_id) {
32330 this.bricks.splice(i,1);
32331 this.el.dom.removeChild(Roo.get(brick_id).dom);
32338 * adds a Masonry Brick
32339 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32341 addBrick : function(cfg)
32343 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32344 //this.register(cn);
32345 cn.parentId = this.id;
32346 cn.render(this.el);
32351 * register a Masonry Brick
32352 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32355 register : function(brick)
32357 this.bricks.push(brick);
32358 brick.masonryId = this.id;
32362 * clear all the Masonry Brick
32364 clearAll : function()
32367 //this.getChildContainer().dom.innerHTML = "";
32368 this.el.dom.innerHTML = '';
32371 getSelected : function()
32373 if (!this.selectedBrick) {
32377 return this.selectedBrick;
32381 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32385 * register a Masonry Layout
32386 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32389 register : function(layout)
32391 this.groups[layout.id] = layout;
32394 * fetch a Masonry Layout based on the masonry layout ID
32395 * @param {string} the masonry layout to add
32396 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32399 get: function(layout_id) {
32400 if (typeof(this.groups[layout_id]) == 'undefined') {
32403 return this.groups[layout_id] ;
32415 * http://masonry.desandro.com
32417 * The idea is to render all the bricks based on vertical width...
32419 * The original code extends 'outlayer' - we might need to use that....
32425 * @class Roo.bootstrap.LayoutMasonryAuto
32426 * @extends Roo.bootstrap.Component
32427 * Bootstrap Layout Masonry class
32430 * Create a new Element
32431 * @param {Object} config The config object
32434 Roo.bootstrap.LayoutMasonryAuto = function(config){
32435 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32438 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32441 * @cfg {Boolean} isFitWidth - resize the width..
32443 isFitWidth : false, // options..
32445 * @cfg {Boolean} isOriginLeft = left align?
32447 isOriginLeft : true,
32449 * @cfg {Boolean} isOriginTop = top align?
32451 isOriginTop : false,
32453 * @cfg {Boolean} isLayoutInstant = no animation?
32455 isLayoutInstant : false, // needed?
32457 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32459 isResizingContainer : true,
32461 * @cfg {Number} columnWidth width of the columns
32467 * @cfg {Number} maxCols maximum number of columns
32472 * @cfg {Number} padHeight padding below box..
32478 * @cfg {Boolean} isAutoInitial defalut true
32481 isAutoInitial : true,
32487 initialColumnWidth : 0,
32488 currentSize : null,
32490 colYs : null, // array.
32497 bricks: null, //CompositeElement
32498 cols : 0, // array?
32499 // element : null, // wrapped now this.el
32500 _isLayoutInited : null,
32503 getAutoCreate : function(){
32507 cls: 'blog-masonary-wrapper ' + this.cls,
32509 cls : 'mas-boxes masonary'
32516 getChildContainer: function( )
32518 if (this.boxesEl) {
32519 return this.boxesEl;
32522 this.boxesEl = this.el.select('.mas-boxes').first();
32524 return this.boxesEl;
32528 initEvents : function()
32532 if(this.isAutoInitial){
32533 Roo.log('hook children rendered');
32534 this.on('childrenrendered', function() {
32535 Roo.log('children rendered');
32542 initial : function()
32544 this.reloadItems();
32546 this.currentSize = this.el.getBox(true);
32548 /// was window resize... - let's see if this works..
32549 Roo.EventManager.onWindowResize(this.resize, this);
32551 if(!this.isAutoInitial){
32556 this.layout.defer(500,this);
32559 reloadItems: function()
32561 this.bricks = this.el.select('.masonry-brick', true);
32563 this.bricks.each(function(b) {
32564 //Roo.log(b.getSize());
32565 if (!b.attr('originalwidth')) {
32566 b.attr('originalwidth', b.getSize().width);
32571 Roo.log(this.bricks.elements.length);
32574 resize : function()
32577 var cs = this.el.getBox(true);
32579 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32580 Roo.log("no change in with or X");
32583 this.currentSize = cs;
32587 layout : function()
32590 this._resetLayout();
32591 //this._manageStamps();
32593 // don't animate first layout
32594 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32595 this.layoutItems( isInstant );
32597 // flag for initalized
32598 this._isLayoutInited = true;
32601 layoutItems : function( isInstant )
32603 //var items = this._getItemsForLayout( this.items );
32604 // original code supports filtering layout items.. we just ignore it..
32606 this._layoutItems( this.bricks , isInstant );
32608 this._postLayout();
32610 _layoutItems : function ( items , isInstant)
32612 //this.fireEvent( 'layout', this, items );
32615 if ( !items || !items.elements.length ) {
32616 // no items, emit event with empty array
32621 items.each(function(item) {
32622 Roo.log("layout item");
32624 // get x/y object from method
32625 var position = this._getItemLayoutPosition( item );
32627 position.item = item;
32628 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32629 queue.push( position );
32632 this._processLayoutQueue( queue );
32634 /** Sets position of item in DOM
32635 * @param {Element} item
32636 * @param {Number} x - horizontal position
32637 * @param {Number} y - vertical position
32638 * @param {Boolean} isInstant - disables transitions
32640 _processLayoutQueue : function( queue )
32642 for ( var i=0, len = queue.length; i < len; i++ ) {
32643 var obj = queue[i];
32644 obj.item.position('absolute');
32645 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32651 * Any logic you want to do after each layout,
32652 * i.e. size the container
32654 _postLayout : function()
32656 this.resizeContainer();
32659 resizeContainer : function()
32661 if ( !this.isResizingContainer ) {
32664 var size = this._getContainerSize();
32666 this.el.setSize(size.width,size.height);
32667 this.boxesEl.setSize(size.width,size.height);
32673 _resetLayout : function()
32675 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32676 this.colWidth = this.el.getWidth();
32677 //this.gutter = this.el.getWidth();
32679 this.measureColumns();
32685 this.colYs.push( 0 );
32691 measureColumns : function()
32693 this.getContainerWidth();
32694 // if columnWidth is 0, default to outerWidth of first item
32695 if ( !this.columnWidth ) {
32696 var firstItem = this.bricks.first();
32697 Roo.log(firstItem);
32698 this.columnWidth = this.containerWidth;
32699 if (firstItem && firstItem.attr('originalwidth') ) {
32700 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32702 // columnWidth fall back to item of first element
32703 Roo.log("set column width?");
32704 this.initialColumnWidth = this.columnWidth ;
32706 // if first elem has no width, default to size of container
32711 if (this.initialColumnWidth) {
32712 this.columnWidth = this.initialColumnWidth;
32717 // column width is fixed at the top - however if container width get's smaller we should
32720 // this bit calcs how man columns..
32722 var columnWidth = this.columnWidth += this.gutter;
32724 // calculate columns
32725 var containerWidth = this.containerWidth + this.gutter;
32727 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32728 // fix rounding errors, typically with gutters
32729 var excess = columnWidth - containerWidth % columnWidth;
32732 // if overshoot is less than a pixel, round up, otherwise floor it
32733 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32734 cols = Math[ mathMethod ]( cols );
32735 this.cols = Math.max( cols, 1 );
32736 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32738 // padding positioning..
32739 var totalColWidth = this.cols * this.columnWidth;
32740 var padavail = this.containerWidth - totalColWidth;
32741 // so for 2 columns - we need 3 'pads'
32743 var padNeeded = (1+this.cols) * this.padWidth;
32745 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32747 this.columnWidth += padExtra
32748 //this.padWidth = Math.floor(padavail / ( this.cols));
32750 // adjust colum width so that padding is fixed??
32752 // we have 3 columns ... total = width * 3
32753 // we have X left over... that should be used by
32755 //if (this.expandC) {
32763 getContainerWidth : function()
32765 /* // container is parent if fit width
32766 var container = this.isFitWidth ? this.element.parentNode : this.element;
32767 // check that this.size and size are there
32768 // IE8 triggers resize on body size change, so they might not be
32770 var size = getSize( container ); //FIXME
32771 this.containerWidth = size && size.innerWidth; //FIXME
32774 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32778 _getItemLayoutPosition : function( item ) // what is item?
32780 // we resize the item to our columnWidth..
32782 item.setWidth(this.columnWidth);
32783 item.autoBoxAdjust = false;
32785 var sz = item.getSize();
32787 // how many columns does this brick span
32788 var remainder = this.containerWidth % this.columnWidth;
32790 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32791 // round if off by 1 pixel, otherwise use ceil
32792 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32793 colSpan = Math.min( colSpan, this.cols );
32795 // normally this should be '1' as we dont' currently allow multi width columns..
32797 var colGroup = this._getColGroup( colSpan );
32798 // get the minimum Y value from the columns
32799 var minimumY = Math.min.apply( Math, colGroup );
32800 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32802 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32804 // position the brick
32806 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32807 y: this.currentSize.y + minimumY + this.padHeight
32811 // apply setHeight to necessary columns
32812 var setHeight = minimumY + sz.height + this.padHeight;
32813 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32815 var setSpan = this.cols + 1 - colGroup.length;
32816 for ( var i = 0; i < setSpan; i++ ) {
32817 this.colYs[ shortColIndex + i ] = setHeight ;
32824 * @param {Number} colSpan - number of columns the element spans
32825 * @returns {Array} colGroup
32827 _getColGroup : function( colSpan )
32829 if ( colSpan < 2 ) {
32830 // if brick spans only one column, use all the column Ys
32835 // how many different places could this brick fit horizontally
32836 var groupCount = this.cols + 1 - colSpan;
32837 // for each group potential horizontal position
32838 for ( var i = 0; i < groupCount; i++ ) {
32839 // make an array of colY values for that one group
32840 var groupColYs = this.colYs.slice( i, i + colSpan );
32841 // and get the max value of the array
32842 colGroup[i] = Math.max.apply( Math, groupColYs );
32847 _manageStamp : function( stamp )
32849 var stampSize = stamp.getSize();
32850 var offset = stamp.getBox();
32851 // get the columns that this stamp affects
32852 var firstX = this.isOriginLeft ? offset.x : offset.right;
32853 var lastX = firstX + stampSize.width;
32854 var firstCol = Math.floor( firstX / this.columnWidth );
32855 firstCol = Math.max( 0, firstCol );
32857 var lastCol = Math.floor( lastX / this.columnWidth );
32858 // lastCol should not go over if multiple of columnWidth #425
32859 lastCol -= lastX % this.columnWidth ? 0 : 1;
32860 lastCol = Math.min( this.cols - 1, lastCol );
32862 // set colYs to bottom of the stamp
32863 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32866 for ( var i = firstCol; i <= lastCol; i++ ) {
32867 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32872 _getContainerSize : function()
32874 this.maxY = Math.max.apply( Math, this.colYs );
32879 if ( this.isFitWidth ) {
32880 size.width = this._getContainerFitWidth();
32886 _getContainerFitWidth : function()
32888 var unusedCols = 0;
32889 // count unused columns
32892 if ( this.colYs[i] !== 0 ) {
32897 // fit container to columns that have been used
32898 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32901 needsResizeLayout : function()
32903 var previousWidth = this.containerWidth;
32904 this.getContainerWidth();
32905 return previousWidth !== this.containerWidth;
32920 * @class Roo.bootstrap.MasonryBrick
32921 * @extends Roo.bootstrap.Component
32922 * Bootstrap MasonryBrick class
32925 * Create a new MasonryBrick
32926 * @param {Object} config The config object
32929 Roo.bootstrap.MasonryBrick = function(config){
32931 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32933 Roo.bootstrap.MasonryBrick.register(this);
32939 * When a MasonryBrick is clcik
32940 * @param {Roo.bootstrap.MasonryBrick} this
32941 * @param {Roo.EventObject} e
32947 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32950 * @cfg {String} title
32954 * @cfg {String} html
32958 * @cfg {String} bgimage
32962 * @cfg {String} videourl
32966 * @cfg {String} cls
32970 * @cfg {String} href
32974 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32979 * @cfg {String} placetitle (center|bottom)
32984 * @cfg {Boolean} isFitContainer defalut true
32986 isFitContainer : true,
32989 * @cfg {Boolean} preventDefault defalut false
32991 preventDefault : false,
32994 * @cfg {Boolean} inverse defalut false
32996 maskInverse : false,
32998 getAutoCreate : function()
33000 if(!this.isFitContainer){
33001 return this.getSplitAutoCreate();
33004 var cls = 'masonry-brick masonry-brick-full';
33006 if(this.href.length){
33007 cls += ' masonry-brick-link';
33010 if(this.bgimage.length){
33011 cls += ' masonry-brick-image';
33014 if(this.maskInverse){
33015 cls += ' mask-inverse';
33018 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33019 cls += ' enable-mask';
33023 cls += ' masonry-' + this.size + '-brick';
33026 if(this.placetitle.length){
33028 switch (this.placetitle) {
33030 cls += ' masonry-center-title';
33033 cls += ' masonry-bottom-title';
33040 if(!this.html.length && !this.bgimage.length){
33041 cls += ' masonry-center-title';
33044 if(!this.html.length && this.bgimage.length){
33045 cls += ' masonry-bottom-title';
33050 cls += ' ' + this.cls;
33054 tag: (this.href.length) ? 'a' : 'div',
33059 cls: 'masonry-brick-mask'
33063 cls: 'masonry-brick-paragraph',
33069 if(this.href.length){
33070 cfg.href = this.href;
33073 var cn = cfg.cn[1].cn;
33075 if(this.title.length){
33078 cls: 'masonry-brick-title',
33083 if(this.html.length){
33086 cls: 'masonry-brick-text',
33091 if (!this.title.length && !this.html.length) {
33092 cfg.cn[1].cls += ' hide';
33095 if(this.bgimage.length){
33098 cls: 'masonry-brick-image-view',
33103 if(this.videourl.length){
33104 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33105 // youtube support only?
33108 cls: 'masonry-brick-image-view',
33111 allowfullscreen : true
33119 getSplitAutoCreate : function()
33121 var cls = 'masonry-brick masonry-brick-split';
33123 if(this.href.length){
33124 cls += ' masonry-brick-link';
33127 if(this.bgimage.length){
33128 cls += ' masonry-brick-image';
33132 cls += ' masonry-' + this.size + '-brick';
33135 switch (this.placetitle) {
33137 cls += ' masonry-center-title';
33140 cls += ' masonry-bottom-title';
33143 if(!this.bgimage.length){
33144 cls += ' masonry-center-title';
33147 if(this.bgimage.length){
33148 cls += ' masonry-bottom-title';
33154 cls += ' ' + this.cls;
33158 tag: (this.href.length) ? 'a' : 'div',
33163 cls: 'masonry-brick-split-head',
33167 cls: 'masonry-brick-paragraph',
33174 cls: 'masonry-brick-split-body',
33180 if(this.href.length){
33181 cfg.href = this.href;
33184 if(this.title.length){
33185 cfg.cn[0].cn[0].cn.push({
33187 cls: 'masonry-brick-title',
33192 if(this.html.length){
33193 cfg.cn[1].cn.push({
33195 cls: 'masonry-brick-text',
33200 if(this.bgimage.length){
33201 cfg.cn[0].cn.push({
33203 cls: 'masonry-brick-image-view',
33208 if(this.videourl.length){
33209 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33210 // youtube support only?
33211 cfg.cn[0].cn.cn.push({
33213 cls: 'masonry-brick-image-view',
33216 allowfullscreen : true
33223 initEvents: function()
33225 switch (this.size) {
33258 this.el.on('touchstart', this.onTouchStart, this);
33259 this.el.on('touchmove', this.onTouchMove, this);
33260 this.el.on('touchend', this.onTouchEnd, this);
33261 this.el.on('contextmenu', this.onContextMenu, this);
33263 this.el.on('mouseenter' ,this.enter, this);
33264 this.el.on('mouseleave', this.leave, this);
33265 this.el.on('click', this.onClick, this);
33268 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33269 this.parent().bricks.push(this);
33274 onClick: function(e, el)
33276 var time = this.endTimer - this.startTimer;
33277 // Roo.log(e.preventDefault());
33280 e.preventDefault();
33285 if(!this.preventDefault){
33289 e.preventDefault();
33291 if (this.activeClass != '') {
33292 this.selectBrick();
33295 this.fireEvent('click', this, e);
33298 enter: function(e, el)
33300 e.preventDefault();
33302 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33306 if(this.bgimage.length && this.html.length){
33307 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33311 leave: function(e, el)
33313 e.preventDefault();
33315 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33319 if(this.bgimage.length && this.html.length){
33320 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33324 onTouchStart: function(e, el)
33326 // e.preventDefault();
33328 this.touchmoved = false;
33330 if(!this.isFitContainer){
33334 if(!this.bgimage.length || !this.html.length){
33338 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33340 this.timer = new Date().getTime();
33344 onTouchMove: function(e, el)
33346 this.touchmoved = true;
33349 onContextMenu : function(e,el)
33351 e.preventDefault();
33352 e.stopPropagation();
33356 onTouchEnd: function(e, el)
33358 // e.preventDefault();
33360 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33367 if(!this.bgimage.length || !this.html.length){
33369 if(this.href.length){
33370 window.location.href = this.href;
33376 if(!this.isFitContainer){
33380 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33382 window.location.href = this.href;
33385 //selection on single brick only
33386 selectBrick : function() {
33388 if (!this.parentId) {
33392 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33393 var index = m.selectedBrick.indexOf(this.id);
33396 m.selectedBrick.splice(index,1);
33397 this.el.removeClass(this.activeClass);
33401 for(var i = 0; i < m.selectedBrick.length; i++) {
33402 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33403 b.el.removeClass(b.activeClass);
33406 m.selectedBrick = [];
33408 m.selectedBrick.push(this.id);
33409 this.el.addClass(this.activeClass);
33413 isSelected : function(){
33414 return this.el.hasClass(this.activeClass);
33419 Roo.apply(Roo.bootstrap.MasonryBrick, {
33422 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33424 * register a Masonry Brick
33425 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33428 register : function(brick)
33430 //this.groups[brick.id] = brick;
33431 this.groups.add(brick.id, brick);
33434 * fetch a masonry brick based on the masonry brick ID
33435 * @param {string} the masonry brick to add
33436 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33439 get: function(brick_id)
33441 // if (typeof(this.groups[brick_id]) == 'undefined') {
33444 // return this.groups[brick_id] ;
33446 if(this.groups.key(brick_id)) {
33447 return this.groups.key(brick_id);
33465 * @class Roo.bootstrap.Brick
33466 * @extends Roo.bootstrap.Component
33467 * Bootstrap Brick class
33470 * Create a new Brick
33471 * @param {Object} config The config object
33474 Roo.bootstrap.Brick = function(config){
33475 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33481 * When a Brick is click
33482 * @param {Roo.bootstrap.Brick} this
33483 * @param {Roo.EventObject} e
33489 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33492 * @cfg {String} title
33496 * @cfg {String} html
33500 * @cfg {String} bgimage
33504 * @cfg {String} cls
33508 * @cfg {String} href
33512 * @cfg {String} video
33516 * @cfg {Boolean} square
33520 getAutoCreate : function()
33522 var cls = 'roo-brick';
33524 if(this.href.length){
33525 cls += ' roo-brick-link';
33528 if(this.bgimage.length){
33529 cls += ' roo-brick-image';
33532 if(!this.html.length && !this.bgimage.length){
33533 cls += ' roo-brick-center-title';
33536 if(!this.html.length && this.bgimage.length){
33537 cls += ' roo-brick-bottom-title';
33541 cls += ' ' + this.cls;
33545 tag: (this.href.length) ? 'a' : 'div',
33550 cls: 'roo-brick-paragraph',
33556 if(this.href.length){
33557 cfg.href = this.href;
33560 var cn = cfg.cn[0].cn;
33562 if(this.title.length){
33565 cls: 'roo-brick-title',
33570 if(this.html.length){
33573 cls: 'roo-brick-text',
33580 if(this.bgimage.length){
33583 cls: 'roo-brick-image-view',
33591 initEvents: function()
33593 if(this.title.length || this.html.length){
33594 this.el.on('mouseenter' ,this.enter, this);
33595 this.el.on('mouseleave', this.leave, this);
33598 Roo.EventManager.onWindowResize(this.resize, this);
33600 if(this.bgimage.length){
33601 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33602 this.imageEl.on('load', this.onImageLoad, this);
33609 onImageLoad : function()
33614 resize : function()
33616 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33618 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33620 if(this.bgimage.length){
33621 var image = this.el.select('.roo-brick-image-view', true).first();
33623 image.setWidth(paragraph.getWidth());
33626 image.setHeight(paragraph.getWidth());
33629 this.el.setHeight(image.getHeight());
33630 paragraph.setHeight(image.getHeight());
33636 enter: function(e, el)
33638 e.preventDefault();
33640 if(this.bgimage.length){
33641 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33642 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33646 leave: function(e, el)
33648 e.preventDefault();
33650 if(this.bgimage.length){
33651 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33652 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33667 * @class Roo.bootstrap.NumberField
33668 * @extends Roo.bootstrap.Input
33669 * Bootstrap NumberField class
33675 * Create a new NumberField
33676 * @param {Object} config The config object
33679 Roo.bootstrap.NumberField = function(config){
33680 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33683 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33686 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33688 allowDecimals : true,
33690 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33692 decimalSeparator : ".",
33694 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33696 decimalPrecision : 2,
33698 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33700 allowNegative : true,
33703 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33707 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33709 minValue : Number.NEGATIVE_INFINITY,
33711 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33713 maxValue : Number.MAX_VALUE,
33715 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33717 minText : "The minimum value for this field is {0}",
33719 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33721 maxText : "The maximum value for this field is {0}",
33723 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33724 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33726 nanText : "{0} is not a valid number",
33728 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33730 thousandsDelimiter : false,
33732 * @cfg {String} valueAlign alignment of value
33734 valueAlign : "left",
33736 getAutoCreate : function()
33738 var hiddenInput = {
33742 cls: 'hidden-number-input'
33746 hiddenInput.name = this.name;
33751 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33753 this.name = hiddenInput.name;
33755 if(cfg.cn.length > 0) {
33756 cfg.cn.push(hiddenInput);
33763 initEvents : function()
33765 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33767 var allowed = "0123456789";
33769 if(this.allowDecimals){
33770 allowed += this.decimalSeparator;
33773 if(this.allowNegative){
33777 if(this.thousandsDelimiter) {
33781 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33783 var keyPress = function(e){
33785 var k = e.getKey();
33787 var c = e.getCharCode();
33790 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33791 allowed.indexOf(String.fromCharCode(c)) === -1
33797 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33801 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33806 this.el.on("keypress", keyPress, this);
33809 validateValue : function(value)
33812 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33816 var num = this.parseValue(value);
33819 this.markInvalid(String.format(this.nanText, value));
33823 if(num < this.minValue){
33824 this.markInvalid(String.format(this.minText, this.minValue));
33828 if(num > this.maxValue){
33829 this.markInvalid(String.format(this.maxText, this.maxValue));
33836 getValue : function()
33838 var v = this.hiddenEl().getValue();
33840 return this.fixPrecision(this.parseValue(v));
33843 parseValue : function(value)
33845 if(this.thousandsDelimiter) {
33847 r = new RegExp(",", "g");
33848 value = value.replace(r, "");
33851 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33852 return isNaN(value) ? '' : value;
33855 fixPrecision : function(value)
33857 if(this.thousandsDelimiter) {
33859 r = new RegExp(",", "g");
33860 value = value.replace(r, "");
33863 var nan = isNaN(value);
33865 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33866 return nan ? '' : value;
33868 return parseFloat(value).toFixed(this.decimalPrecision);
33871 setValue : function(v)
33873 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33879 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33881 this.inputEl().dom.value = (v == '') ? '' :
33882 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33884 if(!this.allowZero && v === '0') {
33885 this.hiddenEl().dom.value = '';
33886 this.inputEl().dom.value = '';
33893 decimalPrecisionFcn : function(v)
33895 return Math.floor(v);
33898 beforeBlur : function()
33900 var v = this.parseValue(this.getRawValue());
33902 if(v || v === 0 || v === ''){
33907 hiddenEl : function()
33909 return this.el.select('input.hidden-number-input',true).first();
33921 * @class Roo.bootstrap.DocumentSlider
33922 * @extends Roo.bootstrap.Component
33923 * Bootstrap DocumentSlider class
33926 * Create a new DocumentViewer
33927 * @param {Object} config The config object
33930 Roo.bootstrap.DocumentSlider = function(config){
33931 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33938 * Fire after initEvent
33939 * @param {Roo.bootstrap.DocumentSlider} this
33944 * Fire after update
33945 * @param {Roo.bootstrap.DocumentSlider} this
33951 * @param {Roo.bootstrap.DocumentSlider} this
33957 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33963 getAutoCreate : function()
33967 cls : 'roo-document-slider',
33971 cls : 'roo-document-slider-header',
33975 cls : 'roo-document-slider-header-title'
33981 cls : 'roo-document-slider-body',
33985 cls : 'roo-document-slider-prev',
33989 cls : 'fa fa-chevron-left'
33995 cls : 'roo-document-slider-thumb',
33999 cls : 'roo-document-slider-image'
34005 cls : 'roo-document-slider-next',
34009 cls : 'fa fa-chevron-right'
34021 initEvents : function()
34023 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34024 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34026 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34027 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34029 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34030 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34032 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34033 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34035 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34036 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34038 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34039 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34041 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34042 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34044 this.thumbEl.on('click', this.onClick, this);
34046 this.prevIndicator.on('click', this.prev, this);
34048 this.nextIndicator.on('click', this.next, this);
34052 initial : function()
34054 if(this.files.length){
34055 this.indicator = 1;
34059 this.fireEvent('initial', this);
34062 update : function()
34064 this.imageEl.attr('src', this.files[this.indicator - 1]);
34066 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34068 this.prevIndicator.show();
34070 if(this.indicator == 1){
34071 this.prevIndicator.hide();
34074 this.nextIndicator.show();
34076 if(this.indicator == this.files.length){
34077 this.nextIndicator.hide();
34080 this.thumbEl.scrollTo('top');
34082 this.fireEvent('update', this);
34085 onClick : function(e)
34087 e.preventDefault();
34089 this.fireEvent('click', this);
34094 e.preventDefault();
34096 this.indicator = Math.max(1, this.indicator - 1);
34103 e.preventDefault();
34105 this.indicator = Math.min(this.files.length, this.indicator + 1);
34119 * @class Roo.bootstrap.RadioSet
34120 * @extends Roo.bootstrap.Input
34121 * Bootstrap RadioSet class
34122 * @cfg {String} indicatorpos (left|right) default left
34123 * @cfg {Boolean} inline (true|false) inline the element (default true)
34124 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34126 * Create a new RadioSet
34127 * @param {Object} config The config object
34130 Roo.bootstrap.RadioSet = function(config){
34132 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34136 Roo.bootstrap.RadioSet.register(this);
34141 * Fires when the element is checked or unchecked.
34142 * @param {Roo.bootstrap.RadioSet} this This radio
34143 * @param {Roo.bootstrap.Radio} item The checked item
34148 * Fires when the element is click.
34149 * @param {Roo.bootstrap.RadioSet} this This radio set
34150 * @param {Roo.bootstrap.Radio} item The checked item
34151 * @param {Roo.EventObject} e The event object
34158 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34166 indicatorpos : 'left',
34168 getAutoCreate : function()
34172 cls : 'roo-radio-set-label',
34176 html : this.fieldLabel
34180 if (Roo.bootstrap.version == 3) {
34183 if(this.indicatorpos == 'left'){
34186 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34187 tooltip : 'This field is required'
34192 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34193 tooltip : 'This field is required'
34199 cls : 'roo-radio-set-items'
34202 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34204 if (align === 'left' && this.fieldLabel.length) {
34207 cls : "roo-radio-set-right",
34213 if(this.labelWidth > 12){
34214 label.style = "width: " + this.labelWidth + 'px';
34217 if(this.labelWidth < 13 && this.labelmd == 0){
34218 this.labelmd = this.labelWidth;
34221 if(this.labellg > 0){
34222 label.cls += ' col-lg-' + this.labellg;
34223 items.cls += ' col-lg-' + (12 - this.labellg);
34226 if(this.labelmd > 0){
34227 label.cls += ' col-md-' + this.labelmd;
34228 items.cls += ' col-md-' + (12 - this.labelmd);
34231 if(this.labelsm > 0){
34232 label.cls += ' col-sm-' + this.labelsm;
34233 items.cls += ' col-sm-' + (12 - this.labelsm);
34236 if(this.labelxs > 0){
34237 label.cls += ' col-xs-' + this.labelxs;
34238 items.cls += ' col-xs-' + (12 - this.labelxs);
34244 cls : 'roo-radio-set',
34248 cls : 'roo-radio-set-input',
34251 value : this.value ? this.value : ''
34258 if(this.weight.length){
34259 cfg.cls += ' roo-radio-' + this.weight;
34263 cfg.cls += ' roo-radio-set-inline';
34267 ['xs','sm','md','lg'].map(function(size){
34268 if (settings[size]) {
34269 cfg.cls += ' col-' + size + '-' + settings[size];
34277 initEvents : function()
34279 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34280 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34282 if(!this.fieldLabel.length){
34283 this.labelEl.hide();
34286 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34287 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34289 this.indicator = this.indicatorEl();
34291 if(this.indicator){
34292 this.indicator.addClass('invisible');
34295 this.originalValue = this.getValue();
34299 inputEl: function ()
34301 return this.el.select('.roo-radio-set-input', true).first();
34304 getChildContainer : function()
34306 return this.itemsEl;
34309 register : function(item)
34311 this.radioes.push(item);
34315 validate : function()
34317 if(this.getVisibilityEl().hasClass('hidden')){
34323 Roo.each(this.radioes, function(i){
34332 if(this.allowBlank) {
34336 if(this.disabled || valid){
34341 this.markInvalid();
34346 markValid : function()
34348 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34349 this.indicatorEl().removeClass('visible');
34350 this.indicatorEl().addClass('invisible');
34354 if (Roo.bootstrap.version == 3) {
34355 this.el.removeClass([this.invalidClass, this.validClass]);
34356 this.el.addClass(this.validClass);
34358 this.el.removeClass(['is-invalid','is-valid']);
34359 this.el.addClass(['is-valid']);
34361 this.fireEvent('valid', this);
34364 markInvalid : function(msg)
34366 if(this.allowBlank || this.disabled){
34370 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34371 this.indicatorEl().removeClass('invisible');
34372 this.indicatorEl().addClass('visible');
34374 if (Roo.bootstrap.version == 3) {
34375 this.el.removeClass([this.invalidClass, this.validClass]);
34376 this.el.addClass(this.invalidClass);
34378 this.el.removeClass(['is-invalid','is-valid']);
34379 this.el.addClass(['is-invalid']);
34382 this.fireEvent('invalid', this, msg);
34386 setValue : function(v, suppressEvent)
34388 if(this.value === v){
34395 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34398 Roo.each(this.radioes, function(i){
34400 i.el.removeClass('checked');
34403 Roo.each(this.radioes, function(i){
34405 if(i.value === v || i.value.toString() === v.toString()){
34407 i.el.addClass('checked');
34409 if(suppressEvent !== true){
34410 this.fireEvent('check', this, i);
34421 clearInvalid : function(){
34423 if(!this.el || this.preventMark){
34427 this.el.removeClass([this.invalidClass]);
34429 this.fireEvent('valid', this);
34434 Roo.apply(Roo.bootstrap.RadioSet, {
34438 register : function(set)
34440 this.groups[set.name] = set;
34443 get: function(name)
34445 if (typeof(this.groups[name]) == 'undefined') {
34449 return this.groups[name] ;
34455 * Ext JS Library 1.1.1
34456 * Copyright(c) 2006-2007, Ext JS, LLC.
34458 * Originally Released Under LGPL - original licence link has changed is not relivant.
34461 * <script type="text/javascript">
34466 * @class Roo.bootstrap.SplitBar
34467 * @extends Roo.util.Observable
34468 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34472 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34473 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34474 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34475 split.minSize = 100;
34476 split.maxSize = 600;
34477 split.animate = true;
34478 split.on('moved', splitterMoved);
34481 * Create a new SplitBar
34482 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34483 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34484 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34485 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34486 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34487 position of the SplitBar).
34489 Roo.bootstrap.SplitBar = function(cfg){
34494 // dragElement : elm
34495 // resizingElement: el,
34497 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34498 // placement : Roo.bootstrap.SplitBar.LEFT ,
34499 // existingProxy ???
34502 this.el = Roo.get(cfg.dragElement, true);
34503 this.el.dom.unselectable = "on";
34505 this.resizingEl = Roo.get(cfg.resizingElement, true);
34509 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34510 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34513 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34516 * The minimum size of the resizing element. (Defaults to 0)
34522 * The maximum size of the resizing element. (Defaults to 2000)
34525 this.maxSize = 2000;
34528 * Whether to animate the transition to the new size
34531 this.animate = false;
34534 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34537 this.useShim = false;
34542 if(!cfg.existingProxy){
34544 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34546 this.proxy = Roo.get(cfg.existingProxy).dom;
34549 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34552 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34555 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34558 this.dragSpecs = {};
34561 * @private The adapter to use to positon and resize elements
34563 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34564 this.adapter.init(this);
34566 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34568 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34569 this.el.addClass("roo-splitbar-h");
34572 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34573 this.el.addClass("roo-splitbar-v");
34579 * Fires when the splitter is moved (alias for {@link #event-moved})
34580 * @param {Roo.bootstrap.SplitBar} this
34581 * @param {Number} newSize the new width or height
34586 * Fires when the splitter is moved
34587 * @param {Roo.bootstrap.SplitBar} this
34588 * @param {Number} newSize the new width or height
34592 * @event beforeresize
34593 * Fires before the splitter is dragged
34594 * @param {Roo.bootstrap.SplitBar} this
34596 "beforeresize" : true,
34598 "beforeapply" : true
34601 Roo.util.Observable.call(this);
34604 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34605 onStartProxyDrag : function(x, y){
34606 this.fireEvent("beforeresize", this);
34608 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34610 o.enableDisplayMode("block");
34611 // all splitbars share the same overlay
34612 Roo.bootstrap.SplitBar.prototype.overlay = o;
34614 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34615 this.overlay.show();
34616 Roo.get(this.proxy).setDisplayed("block");
34617 var size = this.adapter.getElementSize(this);
34618 this.activeMinSize = this.getMinimumSize();;
34619 this.activeMaxSize = this.getMaximumSize();;
34620 var c1 = size - this.activeMinSize;
34621 var c2 = Math.max(this.activeMaxSize - size, 0);
34622 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34623 this.dd.resetConstraints();
34624 this.dd.setXConstraint(
34625 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34626 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34628 this.dd.setYConstraint(0, 0);
34630 this.dd.resetConstraints();
34631 this.dd.setXConstraint(0, 0);
34632 this.dd.setYConstraint(
34633 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34634 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34637 this.dragSpecs.startSize = size;
34638 this.dragSpecs.startPoint = [x, y];
34639 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34643 * @private Called after the drag operation by the DDProxy
34645 onEndProxyDrag : function(e){
34646 Roo.get(this.proxy).setDisplayed(false);
34647 var endPoint = Roo.lib.Event.getXY(e);
34649 this.overlay.hide();
34652 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34653 newSize = this.dragSpecs.startSize +
34654 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34655 endPoint[0] - this.dragSpecs.startPoint[0] :
34656 this.dragSpecs.startPoint[0] - endPoint[0]
34659 newSize = this.dragSpecs.startSize +
34660 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34661 endPoint[1] - this.dragSpecs.startPoint[1] :
34662 this.dragSpecs.startPoint[1] - endPoint[1]
34665 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34666 if(newSize != this.dragSpecs.startSize){
34667 if(this.fireEvent('beforeapply', this, newSize) !== false){
34668 this.adapter.setElementSize(this, newSize);
34669 this.fireEvent("moved", this, newSize);
34670 this.fireEvent("resize", this, newSize);
34676 * Get the adapter this SplitBar uses
34677 * @return The adapter object
34679 getAdapter : function(){
34680 return this.adapter;
34684 * Set the adapter this SplitBar uses
34685 * @param {Object} adapter A SplitBar adapter object
34687 setAdapter : function(adapter){
34688 this.adapter = adapter;
34689 this.adapter.init(this);
34693 * Gets the minimum size for the resizing element
34694 * @return {Number} The minimum size
34696 getMinimumSize : function(){
34697 return this.minSize;
34701 * Sets the minimum size for the resizing element
34702 * @param {Number} minSize The minimum size
34704 setMinimumSize : function(minSize){
34705 this.minSize = minSize;
34709 * Gets the maximum size for the resizing element
34710 * @return {Number} The maximum size
34712 getMaximumSize : function(){
34713 return this.maxSize;
34717 * Sets the maximum size for the resizing element
34718 * @param {Number} maxSize The maximum size
34720 setMaximumSize : function(maxSize){
34721 this.maxSize = maxSize;
34725 * Sets the initialize size for the resizing element
34726 * @param {Number} size The initial size
34728 setCurrentSize : function(size){
34729 var oldAnimate = this.animate;
34730 this.animate = false;
34731 this.adapter.setElementSize(this, size);
34732 this.animate = oldAnimate;
34736 * Destroy this splitbar.
34737 * @param {Boolean} removeEl True to remove the element
34739 destroy : function(removeEl){
34741 this.shim.remove();
34744 this.proxy.parentNode.removeChild(this.proxy);
34752 * @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.
34754 Roo.bootstrap.SplitBar.createProxy = function(dir){
34755 var proxy = new Roo.Element(document.createElement("div"));
34756 proxy.unselectable();
34757 var cls = 'roo-splitbar-proxy';
34758 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34759 document.body.appendChild(proxy.dom);
34764 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34765 * Default Adapter. It assumes the splitter and resizing element are not positioned
34766 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34768 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34771 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34772 // do nothing for now
34773 init : function(s){
34777 * Called before drag operations to get the current size of the resizing element.
34778 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34780 getElementSize : function(s){
34781 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34782 return s.resizingEl.getWidth();
34784 return s.resizingEl.getHeight();
34789 * Called after drag operations to set the size of the resizing element.
34790 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34791 * @param {Number} newSize The new size to set
34792 * @param {Function} onComplete A function to be invoked when resizing is complete
34794 setElementSize : function(s, newSize, onComplete){
34795 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34797 s.resizingEl.setWidth(newSize);
34799 onComplete(s, newSize);
34802 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34807 s.resizingEl.setHeight(newSize);
34809 onComplete(s, newSize);
34812 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34819 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34820 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34821 * Adapter that moves the splitter element to align with the resized sizing element.
34822 * Used with an absolute positioned SplitBar.
34823 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34824 * document.body, make sure you assign an id to the body element.
34826 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34827 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34828 this.container = Roo.get(container);
34831 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34832 init : function(s){
34833 this.basic.init(s);
34836 getElementSize : function(s){
34837 return this.basic.getElementSize(s);
34840 setElementSize : function(s, newSize, onComplete){
34841 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34844 moveSplitter : function(s){
34845 var yes = Roo.bootstrap.SplitBar;
34846 switch(s.placement){
34848 s.el.setX(s.resizingEl.getRight());
34851 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34854 s.el.setY(s.resizingEl.getBottom());
34857 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34864 * Orientation constant - Create a vertical SplitBar
34868 Roo.bootstrap.SplitBar.VERTICAL = 1;
34871 * Orientation constant - Create a horizontal SplitBar
34875 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34878 * Placement constant - The resizing element is to the left of the splitter element
34882 Roo.bootstrap.SplitBar.LEFT = 1;
34885 * Placement constant - The resizing element is to the right of the splitter element
34889 Roo.bootstrap.SplitBar.RIGHT = 2;
34892 * Placement constant - The resizing element is positioned above the splitter element
34896 Roo.bootstrap.SplitBar.TOP = 3;
34899 * Placement constant - The resizing element is positioned under splitter element
34903 Roo.bootstrap.SplitBar.BOTTOM = 4;
34904 Roo.namespace("Roo.bootstrap.layout");/*
34906 * Ext JS Library 1.1.1
34907 * Copyright(c) 2006-2007, Ext JS, LLC.
34909 * Originally Released Under LGPL - original licence link has changed is not relivant.
34912 * <script type="text/javascript">
34916 * @class Roo.bootstrap.layout.Manager
34917 * @extends Roo.bootstrap.Component
34918 * Base class for layout managers.
34920 Roo.bootstrap.layout.Manager = function(config)
34922 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34928 /** false to disable window resize monitoring @type Boolean */
34929 this.monitorWindowResize = true;
34934 * Fires when a layout is performed.
34935 * @param {Roo.LayoutManager} this
34939 * @event regionresized
34940 * Fires when the user resizes a region.
34941 * @param {Roo.LayoutRegion} region The resized region
34942 * @param {Number} newSize The new size (width for east/west, height for north/south)
34944 "regionresized" : true,
34946 * @event regioncollapsed
34947 * Fires when a region is collapsed.
34948 * @param {Roo.LayoutRegion} region The collapsed region
34950 "regioncollapsed" : true,
34952 * @event regionexpanded
34953 * Fires when a region is expanded.
34954 * @param {Roo.LayoutRegion} region The expanded region
34956 "regionexpanded" : true
34958 this.updating = false;
34961 this.el = Roo.get(config.el);
34967 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34972 monitorWindowResize : true,
34978 onRender : function(ct, position)
34981 this.el = Roo.get(ct);
34984 //this.fireEvent('render',this);
34988 initEvents: function()
34992 // ie scrollbar fix
34993 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34994 document.body.scroll = "no";
34995 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34996 this.el.position('relative');
34998 this.id = this.el.id;
34999 this.el.addClass("roo-layout-container");
35000 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35001 if(this.el.dom != document.body ) {
35002 this.el.on('resize', this.layout,this);
35003 this.el.on('show', this.layout,this);
35009 * Returns true if this layout is currently being updated
35010 * @return {Boolean}
35012 isUpdating : function(){
35013 return this.updating;
35017 * Suspend the LayoutManager from doing auto-layouts while
35018 * making multiple add or remove calls
35020 beginUpdate : function(){
35021 this.updating = true;
35025 * Restore auto-layouts and optionally disable the manager from performing a layout
35026 * @param {Boolean} noLayout true to disable a layout update
35028 endUpdate : function(noLayout){
35029 this.updating = false;
35035 layout: function(){
35039 onRegionResized : function(region, newSize){
35040 this.fireEvent("regionresized", region, newSize);
35044 onRegionCollapsed : function(region){
35045 this.fireEvent("regioncollapsed", region);
35048 onRegionExpanded : function(region){
35049 this.fireEvent("regionexpanded", region);
35053 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35054 * performs box-model adjustments.
35055 * @return {Object} The size as an object {width: (the width), height: (the height)}
35057 getViewSize : function()
35060 if(this.el.dom != document.body){
35061 size = this.el.getSize();
35063 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35065 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35066 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35071 * Returns the Element this layout is bound to.
35072 * @return {Roo.Element}
35074 getEl : function(){
35079 * Returns the specified region.
35080 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35081 * @return {Roo.LayoutRegion}
35083 getRegion : function(target){
35084 return this.regions[target.toLowerCase()];
35087 onWindowResize : function(){
35088 if(this.monitorWindowResize){
35095 * Ext JS Library 1.1.1
35096 * Copyright(c) 2006-2007, Ext JS, LLC.
35098 * Originally Released Under LGPL - original licence link has changed is not relivant.
35101 * <script type="text/javascript">
35104 * @class Roo.bootstrap.layout.Border
35105 * @extends Roo.bootstrap.layout.Manager
35106 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35107 * please see: examples/bootstrap/nested.html<br><br>
35109 <b>The container the layout is rendered into can be either the body element or any other element.
35110 If it is not the body element, the container needs to either be an absolute positioned element,
35111 or you will need to add "position:relative" to the css of the container. You will also need to specify
35112 the container size if it is not the body element.</b>
35115 * Create a new Border
35116 * @param {Object} config Configuration options
35118 Roo.bootstrap.layout.Border = function(config){
35119 config = config || {};
35120 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35124 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35125 if(config[region]){
35126 config[region].region = region;
35127 this.addRegion(config[region]);
35133 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35135 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35137 parent : false, // this might point to a 'nest' or a ???
35140 * Creates and adds a new region if it doesn't already exist.
35141 * @param {String} target The target region key (north, south, east, west or center).
35142 * @param {Object} config The regions config object
35143 * @return {BorderLayoutRegion} The new region
35145 addRegion : function(config)
35147 if(!this.regions[config.region]){
35148 var r = this.factory(config);
35149 this.bindRegion(r);
35151 return this.regions[config.region];
35155 bindRegion : function(r){
35156 this.regions[r.config.region] = r;
35158 r.on("visibilitychange", this.layout, this);
35159 r.on("paneladded", this.layout, this);
35160 r.on("panelremoved", this.layout, this);
35161 r.on("invalidated", this.layout, this);
35162 r.on("resized", this.onRegionResized, this);
35163 r.on("collapsed", this.onRegionCollapsed, this);
35164 r.on("expanded", this.onRegionExpanded, this);
35168 * Performs a layout update.
35170 layout : function()
35172 if(this.updating) {
35176 // render all the rebions if they have not been done alreayd?
35177 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35178 if(this.regions[region] && !this.regions[region].bodyEl){
35179 this.regions[region].onRender(this.el)
35183 var size = this.getViewSize();
35184 var w = size.width;
35185 var h = size.height;
35190 //var x = 0, y = 0;
35192 var rs = this.regions;
35193 var north = rs["north"];
35194 var south = rs["south"];
35195 var west = rs["west"];
35196 var east = rs["east"];
35197 var center = rs["center"];
35198 //if(this.hideOnLayout){ // not supported anymore
35199 //c.el.setStyle("display", "none");
35201 if(north && north.isVisible()){
35202 var b = north.getBox();
35203 var m = north.getMargins();
35204 b.width = w - (m.left+m.right);
35207 centerY = b.height + b.y + m.bottom;
35208 centerH -= centerY;
35209 north.updateBox(this.safeBox(b));
35211 if(south && south.isVisible()){
35212 var b = south.getBox();
35213 var m = south.getMargins();
35214 b.width = w - (m.left+m.right);
35216 var totalHeight = (b.height + m.top + m.bottom);
35217 b.y = h - totalHeight + m.top;
35218 centerH -= totalHeight;
35219 south.updateBox(this.safeBox(b));
35221 if(west && west.isVisible()){
35222 var b = west.getBox();
35223 var m = west.getMargins();
35224 b.height = centerH - (m.top+m.bottom);
35226 b.y = centerY + m.top;
35227 var totalWidth = (b.width + m.left + m.right);
35228 centerX += totalWidth;
35229 centerW -= totalWidth;
35230 west.updateBox(this.safeBox(b));
35232 if(east && east.isVisible()){
35233 var b = east.getBox();
35234 var m = east.getMargins();
35235 b.height = centerH - (m.top+m.bottom);
35236 var totalWidth = (b.width + m.left + m.right);
35237 b.x = w - totalWidth + m.left;
35238 b.y = centerY + m.top;
35239 centerW -= totalWidth;
35240 east.updateBox(this.safeBox(b));
35243 var m = center.getMargins();
35245 x: centerX + m.left,
35246 y: centerY + m.top,
35247 width: centerW - (m.left+m.right),
35248 height: centerH - (m.top+m.bottom)
35250 //if(this.hideOnLayout){
35251 //center.el.setStyle("display", "block");
35253 center.updateBox(this.safeBox(centerBox));
35256 this.fireEvent("layout", this);
35260 safeBox : function(box){
35261 box.width = Math.max(0, box.width);
35262 box.height = Math.max(0, box.height);
35267 * Adds a ContentPanel (or subclass) to this layout.
35268 * @param {String} target The target region key (north, south, east, west or center).
35269 * @param {Roo.ContentPanel} panel The panel to add
35270 * @return {Roo.ContentPanel} The added panel
35272 add : function(target, panel){
35274 target = target.toLowerCase();
35275 return this.regions[target].add(panel);
35279 * Remove a ContentPanel (or subclass) to this layout.
35280 * @param {String} target The target region key (north, south, east, west or center).
35281 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35282 * @return {Roo.ContentPanel} The removed panel
35284 remove : function(target, panel){
35285 target = target.toLowerCase();
35286 return this.regions[target].remove(panel);
35290 * Searches all regions for a panel with the specified id
35291 * @param {String} panelId
35292 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35294 findPanel : function(panelId){
35295 var rs = this.regions;
35296 for(var target in rs){
35297 if(typeof rs[target] != "function"){
35298 var p = rs[target].getPanel(panelId);
35308 * Searches all regions for a panel with the specified id and activates (shows) it.
35309 * @param {String/ContentPanel} panelId The panels id or the panel itself
35310 * @return {Roo.ContentPanel} The shown panel or null
35312 showPanel : function(panelId) {
35313 var rs = this.regions;
35314 for(var target in rs){
35315 var r = rs[target];
35316 if(typeof r != "function"){
35317 if(r.hasPanel(panelId)){
35318 return r.showPanel(panelId);
35326 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35327 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35330 restoreState : function(provider){
35332 provider = Roo.state.Manager;
35334 var sm = new Roo.LayoutStateManager();
35335 sm.init(this, provider);
35341 * Adds a xtype elements to the layout.
35345 xtype : 'ContentPanel',
35352 xtype : 'NestedLayoutPanel',
35358 items : [ ... list of content panels or nested layout panels.. ]
35362 * @param {Object} cfg Xtype definition of item to add.
35364 addxtype : function(cfg)
35366 // basically accepts a pannel...
35367 // can accept a layout region..!?!?
35368 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35371 // theory? children can only be panels??
35373 //if (!cfg.xtype.match(/Panel$/)) {
35378 if (typeof(cfg.region) == 'undefined') {
35379 Roo.log("Failed to add Panel, region was not set");
35383 var region = cfg.region;
35389 xitems = cfg.items;
35394 if ( region == 'center') {
35395 Roo.log("Center: " + cfg.title);
35401 case 'Content': // ContentPanel (el, cfg)
35402 case 'Scroll': // ContentPanel (el, cfg)
35404 cfg.autoCreate = cfg.autoCreate || true;
35405 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35407 // var el = this.el.createChild();
35408 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35411 this.add(region, ret);
35415 case 'TreePanel': // our new panel!
35416 cfg.el = this.el.createChild();
35417 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35418 this.add(region, ret);
35423 // create a new Layout (which is a Border Layout...
35425 var clayout = cfg.layout;
35426 clayout.el = this.el.createChild();
35427 clayout.items = clayout.items || [];
35431 // replace this exitems with the clayout ones..
35432 xitems = clayout.items;
35434 // force background off if it's in center...
35435 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35436 cfg.background = false;
35438 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35441 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35442 //console.log('adding nested layout panel ' + cfg.toSource());
35443 this.add(region, ret);
35444 nb = {}; /// find first...
35449 // needs grid and region
35451 //var el = this.getRegion(region).el.createChild();
35453 *var el = this.el.createChild();
35454 // create the grid first...
35455 cfg.grid.container = el;
35456 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35459 if (region == 'center' && this.active ) {
35460 cfg.background = false;
35463 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35465 this.add(region, ret);
35467 if (cfg.background) {
35468 // render grid on panel activation (if panel background)
35469 ret.on('activate', function(gp) {
35470 if (!gp.grid.rendered) {
35471 // gp.grid.render(el);
35475 // cfg.grid.render(el);
35481 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35482 // it was the old xcomponent building that caused this before.
35483 // espeically if border is the top element in the tree.
35493 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35495 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35496 this.add(region, ret);
35500 throw "Can not add '" + cfg.xtype + "' to Border";
35506 this.beginUpdate();
35510 Roo.each(xitems, function(i) {
35511 region = nb && i.region ? i.region : false;
35513 var add = ret.addxtype(i);
35516 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35517 if (!i.background) {
35518 abn[region] = nb[region] ;
35525 // make the last non-background panel active..
35526 //if (nb) { Roo.log(abn); }
35529 for(var r in abn) {
35530 region = this.getRegion(r);
35532 // tried using nb[r], but it does not work..
35534 region.showPanel(abn[r]);
35545 factory : function(cfg)
35548 var validRegions = Roo.bootstrap.layout.Border.regions;
35550 var target = cfg.region;
35553 var r = Roo.bootstrap.layout;
35557 return new r.North(cfg);
35559 return new r.South(cfg);
35561 return new r.East(cfg);
35563 return new r.West(cfg);
35565 return new r.Center(cfg);
35567 throw 'Layout region "'+target+'" not supported.';
35574 * Ext JS Library 1.1.1
35575 * Copyright(c) 2006-2007, Ext JS, LLC.
35577 * Originally Released Under LGPL - original licence link has changed is not relivant.
35580 * <script type="text/javascript">
35584 * @class Roo.bootstrap.layout.Basic
35585 * @extends Roo.util.Observable
35586 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35587 * and does not have a titlebar, tabs or any other features. All it does is size and position
35588 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35589 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35590 * @cfg {string} region the region that it inhabits..
35591 * @cfg {bool} skipConfig skip config?
35595 Roo.bootstrap.layout.Basic = function(config){
35597 this.mgr = config.mgr;
35599 this.position = config.region;
35601 var skipConfig = config.skipConfig;
35605 * @scope Roo.BasicLayoutRegion
35609 * @event beforeremove
35610 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35611 * @param {Roo.LayoutRegion} this
35612 * @param {Roo.ContentPanel} panel The panel
35613 * @param {Object} e The cancel event object
35615 "beforeremove" : true,
35617 * @event invalidated
35618 * Fires when the layout for this region is changed.
35619 * @param {Roo.LayoutRegion} this
35621 "invalidated" : true,
35623 * @event visibilitychange
35624 * Fires when this region is shown or hidden
35625 * @param {Roo.LayoutRegion} this
35626 * @param {Boolean} visibility true or false
35628 "visibilitychange" : true,
35630 * @event paneladded
35631 * Fires when a panel is added.
35632 * @param {Roo.LayoutRegion} this
35633 * @param {Roo.ContentPanel} panel The panel
35635 "paneladded" : true,
35637 * @event panelremoved
35638 * Fires when a panel is removed.
35639 * @param {Roo.LayoutRegion} this
35640 * @param {Roo.ContentPanel} panel The panel
35642 "panelremoved" : true,
35644 * @event beforecollapse
35645 * Fires when this region before collapse.
35646 * @param {Roo.LayoutRegion} this
35648 "beforecollapse" : true,
35651 * Fires when this region is collapsed.
35652 * @param {Roo.LayoutRegion} this
35654 "collapsed" : true,
35657 * Fires when this region is expanded.
35658 * @param {Roo.LayoutRegion} this
35663 * Fires when this region is slid into view.
35664 * @param {Roo.LayoutRegion} this
35666 "slideshow" : true,
35669 * Fires when this region slides out of view.
35670 * @param {Roo.LayoutRegion} this
35672 "slidehide" : true,
35674 * @event panelactivated
35675 * Fires when a panel is activated.
35676 * @param {Roo.LayoutRegion} this
35677 * @param {Roo.ContentPanel} panel The activated panel
35679 "panelactivated" : true,
35682 * Fires when the user resizes this region.
35683 * @param {Roo.LayoutRegion} this
35684 * @param {Number} newSize The new size (width for east/west, height for north/south)
35688 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35689 this.panels = new Roo.util.MixedCollection();
35690 this.panels.getKey = this.getPanelId.createDelegate(this);
35692 this.activePanel = null;
35693 // ensure listeners are added...
35695 if (config.listeners || config.events) {
35696 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35697 listeners : config.listeners || {},
35698 events : config.events || {}
35702 if(skipConfig !== true){
35703 this.applyConfig(config);
35707 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35709 getPanelId : function(p){
35713 applyConfig : function(config){
35714 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35715 this.config = config;
35720 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35721 * the width, for horizontal (north, south) the height.
35722 * @param {Number} newSize The new width or height
35724 resizeTo : function(newSize){
35725 var el = this.el ? this.el :
35726 (this.activePanel ? this.activePanel.getEl() : null);
35728 switch(this.position){
35731 el.setWidth(newSize);
35732 this.fireEvent("resized", this, newSize);
35736 el.setHeight(newSize);
35737 this.fireEvent("resized", this, newSize);
35743 getBox : function(){
35744 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35747 getMargins : function(){
35748 return this.margins;
35751 updateBox : function(box){
35753 var el = this.activePanel.getEl();
35754 el.dom.style.left = box.x + "px";
35755 el.dom.style.top = box.y + "px";
35756 this.activePanel.setSize(box.width, box.height);
35760 * Returns the container element for this region.
35761 * @return {Roo.Element}
35763 getEl : function(){
35764 return this.activePanel;
35768 * Returns true if this region is currently visible.
35769 * @return {Boolean}
35771 isVisible : function(){
35772 return this.activePanel ? true : false;
35775 setActivePanel : function(panel){
35776 panel = this.getPanel(panel);
35777 if(this.activePanel && this.activePanel != panel){
35778 this.activePanel.setActiveState(false);
35779 this.activePanel.getEl().setLeftTop(-10000,-10000);
35781 this.activePanel = panel;
35782 panel.setActiveState(true);
35784 panel.setSize(this.box.width, this.box.height);
35786 this.fireEvent("panelactivated", this, panel);
35787 this.fireEvent("invalidated");
35791 * Show the specified panel.
35792 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35793 * @return {Roo.ContentPanel} The shown panel or null
35795 showPanel : function(panel){
35796 panel = this.getPanel(panel);
35798 this.setActivePanel(panel);
35804 * Get the active panel for this region.
35805 * @return {Roo.ContentPanel} The active panel or null
35807 getActivePanel : function(){
35808 return this.activePanel;
35812 * Add the passed ContentPanel(s)
35813 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35814 * @return {Roo.ContentPanel} The panel added (if only one was added)
35816 add : function(panel){
35817 if(arguments.length > 1){
35818 for(var i = 0, len = arguments.length; i < len; i++) {
35819 this.add(arguments[i]);
35823 if(this.hasPanel(panel)){
35824 this.showPanel(panel);
35827 var el = panel.getEl();
35828 if(el.dom.parentNode != this.mgr.el.dom){
35829 this.mgr.el.dom.appendChild(el.dom);
35831 if(panel.setRegion){
35832 panel.setRegion(this);
35834 this.panels.add(panel);
35835 el.setStyle("position", "absolute");
35836 if(!panel.background){
35837 this.setActivePanel(panel);
35838 if(this.config.initialSize && this.panels.getCount()==1){
35839 this.resizeTo(this.config.initialSize);
35842 this.fireEvent("paneladded", this, panel);
35847 * Returns true if the panel is in this region.
35848 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35849 * @return {Boolean}
35851 hasPanel : function(panel){
35852 if(typeof panel == "object"){ // must be panel obj
35853 panel = panel.getId();
35855 return this.getPanel(panel) ? true : false;
35859 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35860 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35861 * @param {Boolean} preservePanel Overrides the config preservePanel option
35862 * @return {Roo.ContentPanel} The panel that was removed
35864 remove : function(panel, preservePanel){
35865 panel = this.getPanel(panel);
35870 this.fireEvent("beforeremove", this, panel, e);
35871 if(e.cancel === true){
35874 var panelId = panel.getId();
35875 this.panels.removeKey(panelId);
35880 * Returns the panel specified or null if it's not in this region.
35881 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35882 * @return {Roo.ContentPanel}
35884 getPanel : function(id){
35885 if(typeof id == "object"){ // must be panel obj
35888 return this.panels.get(id);
35892 * Returns this regions position (north/south/east/west/center).
35895 getPosition: function(){
35896 return this.position;
35900 * Ext JS Library 1.1.1
35901 * Copyright(c) 2006-2007, Ext JS, LLC.
35903 * Originally Released Under LGPL - original licence link has changed is not relivant.
35906 * <script type="text/javascript">
35910 * @class Roo.bootstrap.layout.Region
35911 * @extends Roo.bootstrap.layout.Basic
35912 * This class represents a region in a layout manager.
35914 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35915 * @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})
35916 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35917 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35918 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35919 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35920 * @cfg {String} title The title for the region (overrides panel titles)
35921 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35922 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35923 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35924 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35925 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35926 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35927 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35928 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35929 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35930 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35932 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35933 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35934 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35935 * @cfg {Number} width For East/West panels
35936 * @cfg {Number} height For North/South panels
35937 * @cfg {Boolean} split To show the splitter
35938 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35940 * @cfg {string} cls Extra CSS classes to add to region
35942 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35943 * @cfg {string} region the region that it inhabits..
35946 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35947 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35949 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35950 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35951 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35953 Roo.bootstrap.layout.Region = function(config)
35955 this.applyConfig(config);
35957 var mgr = config.mgr;
35958 var pos = config.region;
35959 config.skipConfig = true;
35960 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35963 this.onRender(mgr.el);
35966 this.visible = true;
35967 this.collapsed = false;
35968 this.unrendered_panels = [];
35971 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35973 position: '', // set by wrapper (eg. north/south etc..)
35974 unrendered_panels : null, // unrendered panels.
35976 tabPosition : false,
35978 mgr: false, // points to 'Border'
35981 createBody : function(){
35982 /** This region's body element
35983 * @type Roo.Element */
35984 this.bodyEl = this.el.createChild({
35986 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35990 onRender: function(ctr, pos)
35992 var dh = Roo.DomHelper;
35993 /** This region's container element
35994 * @type Roo.Element */
35995 this.el = dh.append(ctr.dom, {
35997 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35999 /** This region's title element
36000 * @type Roo.Element */
36002 this.titleEl = dh.append(this.el.dom, {
36004 unselectable: "on",
36005 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36007 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36008 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36012 this.titleEl.enableDisplayMode();
36013 /** This region's title text element
36014 * @type HTMLElement */
36015 this.titleTextEl = this.titleEl.dom.firstChild;
36016 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36018 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36019 this.closeBtn.enableDisplayMode();
36020 this.closeBtn.on("click", this.closeClicked, this);
36021 this.closeBtn.hide();
36023 this.createBody(this.config);
36024 if(this.config.hideWhenEmpty){
36026 this.on("paneladded", this.validateVisibility, this);
36027 this.on("panelremoved", this.validateVisibility, this);
36029 if(this.autoScroll){
36030 this.bodyEl.setStyle("overflow", "auto");
36032 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36034 //if(c.titlebar !== false){
36035 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36036 this.titleEl.hide();
36038 this.titleEl.show();
36039 if(this.config.title){
36040 this.titleTextEl.innerHTML = this.config.title;
36044 if(this.config.collapsed){
36045 this.collapse(true);
36047 if(this.config.hidden){
36051 if (this.unrendered_panels && this.unrendered_panels.length) {
36052 for (var i =0;i< this.unrendered_panels.length; i++) {
36053 this.add(this.unrendered_panels[i]);
36055 this.unrendered_panels = null;
36061 applyConfig : function(c)
36064 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36065 var dh = Roo.DomHelper;
36066 if(c.titlebar !== false){
36067 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36068 this.collapseBtn.on("click", this.collapse, this);
36069 this.collapseBtn.enableDisplayMode();
36071 if(c.showPin === true || this.showPin){
36072 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36073 this.stickBtn.enableDisplayMode();
36074 this.stickBtn.on("click", this.expand, this);
36075 this.stickBtn.hide();
36080 /** This region's collapsed element
36081 * @type Roo.Element */
36084 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36085 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36088 if(c.floatable !== false){
36089 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36090 this.collapsedEl.on("click", this.collapseClick, this);
36093 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36094 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36095 id: "message", unselectable: "on", style:{"float":"left"}});
36096 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36098 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36099 this.expandBtn.on("click", this.expand, this);
36103 if(this.collapseBtn){
36104 this.collapseBtn.setVisible(c.collapsible == true);
36107 this.cmargins = c.cmargins || this.cmargins ||
36108 (this.position == "west" || this.position == "east" ?
36109 {top: 0, left: 2, right:2, bottom: 0} :
36110 {top: 2, left: 0, right:0, bottom: 2});
36112 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36115 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36117 this.autoScroll = c.autoScroll || false;
36122 this.duration = c.duration || .30;
36123 this.slideDuration = c.slideDuration || .45;
36128 * Returns true if this region is currently visible.
36129 * @return {Boolean}
36131 isVisible : function(){
36132 return this.visible;
36136 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36137 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36139 //setCollapsedTitle : function(title){
36140 // title = title || " ";
36141 // if(this.collapsedTitleTextEl){
36142 // this.collapsedTitleTextEl.innerHTML = title;
36146 getBox : function(){
36148 // if(!this.collapsed){
36149 b = this.el.getBox(false, true);
36151 // b = this.collapsedEl.getBox(false, true);
36156 getMargins : function(){
36157 return this.margins;
36158 //return this.collapsed ? this.cmargins : this.margins;
36161 highlight : function(){
36162 this.el.addClass("x-layout-panel-dragover");
36165 unhighlight : function(){
36166 this.el.removeClass("x-layout-panel-dragover");
36169 updateBox : function(box)
36171 if (!this.bodyEl) {
36172 return; // not rendered yet..
36176 if(!this.collapsed){
36177 this.el.dom.style.left = box.x + "px";
36178 this.el.dom.style.top = box.y + "px";
36179 this.updateBody(box.width, box.height);
36181 this.collapsedEl.dom.style.left = box.x + "px";
36182 this.collapsedEl.dom.style.top = box.y + "px";
36183 this.collapsedEl.setSize(box.width, box.height);
36186 this.tabs.autoSizeTabs();
36190 updateBody : function(w, h)
36193 this.el.setWidth(w);
36194 w -= this.el.getBorderWidth("rl");
36195 if(this.config.adjustments){
36196 w += this.config.adjustments[0];
36199 if(h !== null && h > 0){
36200 this.el.setHeight(h);
36201 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36202 h -= this.el.getBorderWidth("tb");
36203 if(this.config.adjustments){
36204 h += this.config.adjustments[1];
36206 this.bodyEl.setHeight(h);
36208 h = this.tabs.syncHeight(h);
36211 if(this.panelSize){
36212 w = w !== null ? w : this.panelSize.width;
36213 h = h !== null ? h : this.panelSize.height;
36215 if(this.activePanel){
36216 var el = this.activePanel.getEl();
36217 w = w !== null ? w : el.getWidth();
36218 h = h !== null ? h : el.getHeight();
36219 this.panelSize = {width: w, height: h};
36220 this.activePanel.setSize(w, h);
36222 if(Roo.isIE && this.tabs){
36223 this.tabs.el.repaint();
36228 * Returns the container element for this region.
36229 * @return {Roo.Element}
36231 getEl : function(){
36236 * Hides this region.
36239 //if(!this.collapsed){
36240 this.el.dom.style.left = "-2000px";
36243 // this.collapsedEl.dom.style.left = "-2000px";
36244 // this.collapsedEl.hide();
36246 this.visible = false;
36247 this.fireEvent("visibilitychange", this, false);
36251 * Shows this region if it was previously hidden.
36254 //if(!this.collapsed){
36257 // this.collapsedEl.show();
36259 this.visible = true;
36260 this.fireEvent("visibilitychange", this, true);
36263 closeClicked : function(){
36264 if(this.activePanel){
36265 this.remove(this.activePanel);
36269 collapseClick : function(e){
36271 e.stopPropagation();
36274 e.stopPropagation();
36280 * Collapses this region.
36281 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36284 collapse : function(skipAnim, skipCheck = false){
36285 if(this.collapsed) {
36289 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36291 this.collapsed = true;
36293 this.split.el.hide();
36295 if(this.config.animate && skipAnim !== true){
36296 this.fireEvent("invalidated", this);
36297 this.animateCollapse();
36299 this.el.setLocation(-20000,-20000);
36301 this.collapsedEl.show();
36302 this.fireEvent("collapsed", this);
36303 this.fireEvent("invalidated", this);
36309 animateCollapse : function(){
36314 * Expands this region if it was previously collapsed.
36315 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36316 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36319 expand : function(e, skipAnim){
36321 e.stopPropagation();
36323 if(!this.collapsed || this.el.hasActiveFx()) {
36327 this.afterSlideIn();
36330 this.collapsed = false;
36331 if(this.config.animate && skipAnim !== true){
36332 this.animateExpand();
36336 this.split.el.show();
36338 this.collapsedEl.setLocation(-2000,-2000);
36339 this.collapsedEl.hide();
36340 this.fireEvent("invalidated", this);
36341 this.fireEvent("expanded", this);
36345 animateExpand : function(){
36349 initTabs : function()
36351 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36353 var ts = new Roo.bootstrap.panel.Tabs({
36354 el: this.bodyEl.dom,
36356 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36357 disableTooltips: this.config.disableTabTips,
36358 toolbar : this.config.toolbar
36361 if(this.config.hideTabs){
36362 ts.stripWrap.setDisplayed(false);
36365 ts.resizeTabs = this.config.resizeTabs === true;
36366 ts.minTabWidth = this.config.minTabWidth || 40;
36367 ts.maxTabWidth = this.config.maxTabWidth || 250;
36368 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36369 ts.monitorResize = false;
36370 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36371 ts.bodyEl.addClass('roo-layout-tabs-body');
36372 this.panels.each(this.initPanelAsTab, this);
36375 initPanelAsTab : function(panel){
36376 var ti = this.tabs.addTab(
36380 this.config.closeOnTab && panel.isClosable(),
36383 if(panel.tabTip !== undefined){
36384 ti.setTooltip(panel.tabTip);
36386 ti.on("activate", function(){
36387 this.setActivePanel(panel);
36390 if(this.config.closeOnTab){
36391 ti.on("beforeclose", function(t, e){
36393 this.remove(panel);
36397 panel.tabItem = ti;
36402 updatePanelTitle : function(panel, title)
36404 if(this.activePanel == panel){
36405 this.updateTitle(title);
36408 var ti = this.tabs.getTab(panel.getEl().id);
36410 if(panel.tabTip !== undefined){
36411 ti.setTooltip(panel.tabTip);
36416 updateTitle : function(title){
36417 if(this.titleTextEl && !this.config.title){
36418 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36422 setActivePanel : function(panel)
36424 panel = this.getPanel(panel);
36425 if(this.activePanel && this.activePanel != panel){
36426 if(this.activePanel.setActiveState(false) === false){
36430 this.activePanel = panel;
36431 panel.setActiveState(true);
36432 if(this.panelSize){
36433 panel.setSize(this.panelSize.width, this.panelSize.height);
36436 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36438 this.updateTitle(panel.getTitle());
36440 this.fireEvent("invalidated", this);
36442 this.fireEvent("panelactivated", this, panel);
36446 * Shows the specified panel.
36447 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36448 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36450 showPanel : function(panel)
36452 panel = this.getPanel(panel);
36455 var tab = this.tabs.getTab(panel.getEl().id);
36456 if(tab.isHidden()){
36457 this.tabs.unhideTab(tab.id);
36461 this.setActivePanel(panel);
36468 * Get the active panel for this region.
36469 * @return {Roo.ContentPanel} The active panel or null
36471 getActivePanel : function(){
36472 return this.activePanel;
36475 validateVisibility : function(){
36476 if(this.panels.getCount() < 1){
36477 this.updateTitle(" ");
36478 this.closeBtn.hide();
36481 if(!this.isVisible()){
36488 * Adds the passed ContentPanel(s) to this region.
36489 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36490 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36492 add : function(panel)
36494 if(arguments.length > 1){
36495 for(var i = 0, len = arguments.length; i < len; i++) {
36496 this.add(arguments[i]);
36501 // if we have not been rendered yet, then we can not really do much of this..
36502 if (!this.bodyEl) {
36503 this.unrendered_panels.push(panel);
36510 if(this.hasPanel(panel)){
36511 this.showPanel(panel);
36514 panel.setRegion(this);
36515 this.panels.add(panel);
36516 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36517 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36518 // and hide them... ???
36519 this.bodyEl.dom.appendChild(panel.getEl().dom);
36520 if(panel.background !== true){
36521 this.setActivePanel(panel);
36523 this.fireEvent("paneladded", this, panel);
36530 this.initPanelAsTab(panel);
36534 if(panel.background !== true){
36535 this.tabs.activate(panel.getEl().id);
36537 this.fireEvent("paneladded", this, panel);
36542 * Hides the tab for the specified panel.
36543 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36545 hidePanel : function(panel){
36546 if(this.tabs && (panel = this.getPanel(panel))){
36547 this.tabs.hideTab(panel.getEl().id);
36552 * Unhides the tab for a previously hidden panel.
36553 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36555 unhidePanel : function(panel){
36556 if(this.tabs && (panel = this.getPanel(panel))){
36557 this.tabs.unhideTab(panel.getEl().id);
36561 clearPanels : function(){
36562 while(this.panels.getCount() > 0){
36563 this.remove(this.panels.first());
36568 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36569 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36570 * @param {Boolean} preservePanel Overrides the config preservePanel option
36571 * @return {Roo.ContentPanel} The panel that was removed
36573 remove : function(panel, preservePanel)
36575 panel = this.getPanel(panel);
36580 this.fireEvent("beforeremove", this, panel, e);
36581 if(e.cancel === true){
36584 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36585 var panelId = panel.getId();
36586 this.panels.removeKey(panelId);
36588 document.body.appendChild(panel.getEl().dom);
36591 this.tabs.removeTab(panel.getEl().id);
36592 }else if (!preservePanel){
36593 this.bodyEl.dom.removeChild(panel.getEl().dom);
36595 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36596 var p = this.panels.first();
36597 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36598 tempEl.appendChild(p.getEl().dom);
36599 this.bodyEl.update("");
36600 this.bodyEl.dom.appendChild(p.getEl().dom);
36602 this.updateTitle(p.getTitle());
36604 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36605 this.setActivePanel(p);
36607 panel.setRegion(null);
36608 if(this.activePanel == panel){
36609 this.activePanel = null;
36611 if(this.config.autoDestroy !== false && preservePanel !== true){
36612 try{panel.destroy();}catch(e){}
36614 this.fireEvent("panelremoved", this, panel);
36619 * Returns the TabPanel component used by this region
36620 * @return {Roo.TabPanel}
36622 getTabs : function(){
36626 createTool : function(parentEl, className){
36627 var btn = Roo.DomHelper.append(parentEl, {
36629 cls: "x-layout-tools-button",
36632 cls: "roo-layout-tools-button-inner " + className,
36636 btn.addClassOnOver("roo-layout-tools-button-over");
36641 * Ext JS Library 1.1.1
36642 * Copyright(c) 2006-2007, Ext JS, LLC.
36644 * Originally Released Under LGPL - original licence link has changed is not relivant.
36647 * <script type="text/javascript">
36653 * @class Roo.SplitLayoutRegion
36654 * @extends Roo.LayoutRegion
36655 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36657 Roo.bootstrap.layout.Split = function(config){
36658 this.cursor = config.cursor;
36659 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36662 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36664 splitTip : "Drag to resize.",
36665 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36666 useSplitTips : false,
36668 applyConfig : function(config){
36669 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36672 onRender : function(ctr,pos) {
36674 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36675 if(!this.config.split){
36680 var splitEl = Roo.DomHelper.append(ctr.dom, {
36682 id: this.el.id + "-split",
36683 cls: "roo-layout-split roo-layout-split-"+this.position,
36686 /** The SplitBar for this region
36687 * @type Roo.SplitBar */
36688 // does not exist yet...
36689 Roo.log([this.position, this.orientation]);
36691 this.split = new Roo.bootstrap.SplitBar({
36692 dragElement : splitEl,
36693 resizingElement: this.el,
36694 orientation : this.orientation
36697 this.split.on("moved", this.onSplitMove, this);
36698 this.split.useShim = this.config.useShim === true;
36699 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36700 if(this.useSplitTips){
36701 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36703 //if(config.collapsible){
36704 // this.split.el.on("dblclick", this.collapse, this);
36707 if(typeof this.config.minSize != "undefined"){
36708 this.split.minSize = this.config.minSize;
36710 if(typeof this.config.maxSize != "undefined"){
36711 this.split.maxSize = this.config.maxSize;
36713 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36714 this.hideSplitter();
36719 getHMaxSize : function(){
36720 var cmax = this.config.maxSize || 10000;
36721 var center = this.mgr.getRegion("center");
36722 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36725 getVMaxSize : function(){
36726 var cmax = this.config.maxSize || 10000;
36727 var center = this.mgr.getRegion("center");
36728 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36731 onSplitMove : function(split, newSize){
36732 this.fireEvent("resized", this, newSize);
36736 * Returns the {@link Roo.SplitBar} for this region.
36737 * @return {Roo.SplitBar}
36739 getSplitBar : function(){
36744 this.hideSplitter();
36745 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36748 hideSplitter : function(){
36750 this.split.el.setLocation(-2000,-2000);
36751 this.split.el.hide();
36757 this.split.el.show();
36759 Roo.bootstrap.layout.Split.superclass.show.call(this);
36762 beforeSlide: function(){
36763 if(Roo.isGecko){// firefox overflow auto bug workaround
36764 this.bodyEl.clip();
36766 this.tabs.bodyEl.clip();
36768 if(this.activePanel){
36769 this.activePanel.getEl().clip();
36771 if(this.activePanel.beforeSlide){
36772 this.activePanel.beforeSlide();
36778 afterSlide : function(){
36779 if(Roo.isGecko){// firefox overflow auto bug workaround
36780 this.bodyEl.unclip();
36782 this.tabs.bodyEl.unclip();
36784 if(this.activePanel){
36785 this.activePanel.getEl().unclip();
36786 if(this.activePanel.afterSlide){
36787 this.activePanel.afterSlide();
36793 initAutoHide : function(){
36794 if(this.autoHide !== false){
36795 if(!this.autoHideHd){
36796 var st = new Roo.util.DelayedTask(this.slideIn, this);
36797 this.autoHideHd = {
36798 "mouseout": function(e){
36799 if(!e.within(this.el, true)){
36803 "mouseover" : function(e){
36809 this.el.on(this.autoHideHd);
36813 clearAutoHide : function(){
36814 if(this.autoHide !== false){
36815 this.el.un("mouseout", this.autoHideHd.mouseout);
36816 this.el.un("mouseover", this.autoHideHd.mouseover);
36820 clearMonitor : function(){
36821 Roo.get(document).un("click", this.slideInIf, this);
36824 // these names are backwards but not changed for compat
36825 slideOut : function(){
36826 if(this.isSlid || this.el.hasActiveFx()){
36829 this.isSlid = true;
36830 if(this.collapseBtn){
36831 this.collapseBtn.hide();
36833 this.closeBtnState = this.closeBtn.getStyle('display');
36834 this.closeBtn.hide();
36836 this.stickBtn.show();
36839 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36840 this.beforeSlide();
36841 this.el.setStyle("z-index", 10001);
36842 this.el.slideIn(this.getSlideAnchor(), {
36843 callback: function(){
36845 this.initAutoHide();
36846 Roo.get(document).on("click", this.slideInIf, this);
36847 this.fireEvent("slideshow", this);
36854 afterSlideIn : function(){
36855 this.clearAutoHide();
36856 this.isSlid = false;
36857 this.clearMonitor();
36858 this.el.setStyle("z-index", "");
36859 if(this.collapseBtn){
36860 this.collapseBtn.show();
36862 this.closeBtn.setStyle('display', this.closeBtnState);
36864 this.stickBtn.hide();
36866 this.fireEvent("slidehide", this);
36869 slideIn : function(cb){
36870 if(!this.isSlid || this.el.hasActiveFx()){
36874 this.isSlid = false;
36875 this.beforeSlide();
36876 this.el.slideOut(this.getSlideAnchor(), {
36877 callback: function(){
36878 this.el.setLeftTop(-10000, -10000);
36880 this.afterSlideIn();
36888 slideInIf : function(e){
36889 if(!e.within(this.el)){
36894 animateCollapse : function(){
36895 this.beforeSlide();
36896 this.el.setStyle("z-index", 20000);
36897 var anchor = this.getSlideAnchor();
36898 this.el.slideOut(anchor, {
36899 callback : function(){
36900 this.el.setStyle("z-index", "");
36901 this.collapsedEl.slideIn(anchor, {duration:.3});
36903 this.el.setLocation(-10000,-10000);
36905 this.fireEvent("collapsed", this);
36912 animateExpand : function(){
36913 this.beforeSlide();
36914 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36915 this.el.setStyle("z-index", 20000);
36916 this.collapsedEl.hide({
36919 this.el.slideIn(this.getSlideAnchor(), {
36920 callback : function(){
36921 this.el.setStyle("z-index", "");
36924 this.split.el.show();
36926 this.fireEvent("invalidated", this);
36927 this.fireEvent("expanded", this);
36955 getAnchor : function(){
36956 return this.anchors[this.position];
36959 getCollapseAnchor : function(){
36960 return this.canchors[this.position];
36963 getSlideAnchor : function(){
36964 return this.sanchors[this.position];
36967 getAlignAdj : function(){
36968 var cm = this.cmargins;
36969 switch(this.position){
36985 getExpandAdj : function(){
36986 var c = this.collapsedEl, cm = this.cmargins;
36987 switch(this.position){
36989 return [-(cm.right+c.getWidth()+cm.left), 0];
36992 return [cm.right+c.getWidth()+cm.left, 0];
36995 return [0, -(cm.top+cm.bottom+c.getHeight())];
36998 return [0, cm.top+cm.bottom+c.getHeight()];
37004 * Ext JS Library 1.1.1
37005 * Copyright(c) 2006-2007, Ext JS, LLC.
37007 * Originally Released Under LGPL - original licence link has changed is not relivant.
37010 * <script type="text/javascript">
37013 * These classes are private internal classes
37015 Roo.bootstrap.layout.Center = function(config){
37016 config.region = "center";
37017 Roo.bootstrap.layout.Region.call(this, config);
37018 this.visible = true;
37019 this.minWidth = config.minWidth || 20;
37020 this.minHeight = config.minHeight || 20;
37023 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37025 // center panel can't be hidden
37029 // center panel can't be hidden
37032 getMinWidth: function(){
37033 return this.minWidth;
37036 getMinHeight: function(){
37037 return this.minHeight;
37051 Roo.bootstrap.layout.North = function(config)
37053 config.region = 'north';
37054 config.cursor = 'n-resize';
37056 Roo.bootstrap.layout.Split.call(this, config);
37060 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37061 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37062 this.split.el.addClass("roo-layout-split-v");
37064 var size = config.initialSize || config.height;
37065 if(typeof size != "undefined"){
37066 this.el.setHeight(size);
37069 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37071 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37075 getBox : function(){
37076 if(this.collapsed){
37077 return this.collapsedEl.getBox();
37079 var box = this.el.getBox();
37081 box.height += this.split.el.getHeight();
37086 updateBox : function(box){
37087 if(this.split && !this.collapsed){
37088 box.height -= this.split.el.getHeight();
37089 this.split.el.setLeft(box.x);
37090 this.split.el.setTop(box.y+box.height);
37091 this.split.el.setWidth(box.width);
37093 if(this.collapsed){
37094 this.updateBody(box.width, null);
37096 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37104 Roo.bootstrap.layout.South = function(config){
37105 config.region = 'south';
37106 config.cursor = 's-resize';
37107 Roo.bootstrap.layout.Split.call(this, config);
37109 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37110 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37111 this.split.el.addClass("roo-layout-split-v");
37113 var size = config.initialSize || config.height;
37114 if(typeof size != "undefined"){
37115 this.el.setHeight(size);
37119 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37120 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37121 getBox : function(){
37122 if(this.collapsed){
37123 return this.collapsedEl.getBox();
37125 var box = this.el.getBox();
37127 var sh = this.split.el.getHeight();
37134 updateBox : function(box){
37135 if(this.split && !this.collapsed){
37136 var sh = this.split.el.getHeight();
37139 this.split.el.setLeft(box.x);
37140 this.split.el.setTop(box.y-sh);
37141 this.split.el.setWidth(box.width);
37143 if(this.collapsed){
37144 this.updateBody(box.width, null);
37146 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37150 Roo.bootstrap.layout.East = function(config){
37151 config.region = "east";
37152 config.cursor = "e-resize";
37153 Roo.bootstrap.layout.Split.call(this, config);
37155 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37156 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37157 this.split.el.addClass("roo-layout-split-h");
37159 var size = config.initialSize || config.width;
37160 if(typeof size != "undefined"){
37161 this.el.setWidth(size);
37164 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37165 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37166 getBox : function(){
37167 if(this.collapsed){
37168 return this.collapsedEl.getBox();
37170 var box = this.el.getBox();
37172 var sw = this.split.el.getWidth();
37179 updateBox : function(box){
37180 if(this.split && !this.collapsed){
37181 var sw = this.split.el.getWidth();
37183 this.split.el.setLeft(box.x);
37184 this.split.el.setTop(box.y);
37185 this.split.el.setHeight(box.height);
37188 if(this.collapsed){
37189 this.updateBody(null, box.height);
37191 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37195 Roo.bootstrap.layout.West = function(config){
37196 config.region = "west";
37197 config.cursor = "w-resize";
37199 Roo.bootstrap.layout.Split.call(this, config);
37201 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37202 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37203 this.split.el.addClass("roo-layout-split-h");
37207 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37208 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37210 onRender: function(ctr, pos)
37212 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37213 var size = this.config.initialSize || this.config.width;
37214 if(typeof size != "undefined"){
37215 this.el.setWidth(size);
37219 getBox : function(){
37220 if(this.collapsed){
37221 return this.collapsedEl.getBox();
37223 var box = this.el.getBox();
37225 box.width += this.split.el.getWidth();
37230 updateBox : function(box){
37231 if(this.split && !this.collapsed){
37232 var sw = this.split.el.getWidth();
37234 this.split.el.setLeft(box.x+box.width);
37235 this.split.el.setTop(box.y);
37236 this.split.el.setHeight(box.height);
37238 if(this.collapsed){
37239 this.updateBody(null, box.height);
37241 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37243 });Roo.namespace("Roo.bootstrap.panel");/*
37245 * Ext JS Library 1.1.1
37246 * Copyright(c) 2006-2007, Ext JS, LLC.
37248 * Originally Released Under LGPL - original licence link has changed is not relivant.
37251 * <script type="text/javascript">
37254 * @class Roo.ContentPanel
37255 * @extends Roo.util.Observable
37256 * A basic ContentPanel element.
37257 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37258 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37259 * @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
37260 * @cfg {Boolean} closable True if the panel can be closed/removed
37261 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37262 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37263 * @cfg {Toolbar} toolbar A toolbar for this panel
37264 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37265 * @cfg {String} title The title for this panel
37266 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37267 * @cfg {String} url Calls {@link #setUrl} with this value
37268 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37269 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37270 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37271 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37272 * @cfg {Boolean} badges render the badges
37275 * Create a new ContentPanel.
37276 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37277 * @param {String/Object} config A string to set only the title or a config object
37278 * @param {String} content (optional) Set the HTML content for this panel
37279 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37281 Roo.bootstrap.panel.Content = function( config){
37283 this.tpl = config.tpl || false;
37285 var el = config.el;
37286 var content = config.content;
37288 if(config.autoCreate){ // xtype is available if this is called from factory
37291 this.el = Roo.get(el);
37292 if(!this.el && config && config.autoCreate){
37293 if(typeof config.autoCreate == "object"){
37294 if(!config.autoCreate.id){
37295 config.autoCreate.id = config.id||el;
37297 this.el = Roo.DomHelper.append(document.body,
37298 config.autoCreate, true);
37300 var elcfg = { tag: "div",
37301 cls: "roo-layout-inactive-content",
37305 elcfg.html = config.html;
37309 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37312 this.closable = false;
37313 this.loaded = false;
37314 this.active = false;
37317 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37319 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37321 this.wrapEl = this.el; //this.el.wrap();
37323 if (config.toolbar.items) {
37324 ti = config.toolbar.items ;
37325 delete config.toolbar.items ;
37329 this.toolbar.render(this.wrapEl, 'before');
37330 for(var i =0;i < ti.length;i++) {
37331 // Roo.log(['add child', items[i]]);
37332 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37334 this.toolbar.items = nitems;
37335 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37336 delete config.toolbar;
37340 // xtype created footer. - not sure if will work as we normally have to render first..
37341 if (this.footer && !this.footer.el && this.footer.xtype) {
37342 if (!this.wrapEl) {
37343 this.wrapEl = this.el.wrap();
37346 this.footer.container = this.wrapEl.createChild();
37348 this.footer = Roo.factory(this.footer, Roo);
37353 if(typeof config == "string"){
37354 this.title = config;
37356 Roo.apply(this, config);
37360 this.resizeEl = Roo.get(this.resizeEl, true);
37362 this.resizeEl = this.el;
37364 // handle view.xtype
37372 * Fires when this panel is activated.
37373 * @param {Roo.ContentPanel} this
37377 * @event deactivate
37378 * Fires when this panel is activated.
37379 * @param {Roo.ContentPanel} this
37381 "deactivate" : true,
37385 * Fires when this panel is resized if fitToFrame is true.
37386 * @param {Roo.ContentPanel} this
37387 * @param {Number} width The width after any component adjustments
37388 * @param {Number} height The height after any component adjustments
37394 * Fires when this tab is created
37395 * @param {Roo.ContentPanel} this
37406 if(this.autoScroll){
37407 this.resizeEl.setStyle("overflow", "auto");
37409 // fix randome scrolling
37410 //this.el.on('scroll', function() {
37411 // Roo.log('fix random scolling');
37412 // this.scrollTo('top',0);
37415 content = content || this.content;
37417 this.setContent(content);
37419 if(config && config.url){
37420 this.setUrl(this.url, this.params, this.loadOnce);
37425 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37427 if (this.view && typeof(this.view.xtype) != 'undefined') {
37428 this.view.el = this.el.appendChild(document.createElement("div"));
37429 this.view = Roo.factory(this.view);
37430 this.view.render && this.view.render(false, '');
37434 this.fireEvent('render', this);
37437 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37441 setRegion : function(region){
37442 this.region = region;
37443 this.setActiveClass(region && !this.background);
37447 setActiveClass: function(state)
37450 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37451 this.el.setStyle('position','relative');
37453 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37454 this.el.setStyle('position', 'absolute');
37459 * Returns the toolbar for this Panel if one was configured.
37460 * @return {Roo.Toolbar}
37462 getToolbar : function(){
37463 return this.toolbar;
37466 setActiveState : function(active)
37468 this.active = active;
37469 this.setActiveClass(active);
37471 if(this.fireEvent("deactivate", this) === false){
37476 this.fireEvent("activate", this);
37480 * Updates this panel's element
37481 * @param {String} content The new content
37482 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37484 setContent : function(content, loadScripts){
37485 this.el.update(content, loadScripts);
37488 ignoreResize : function(w, h){
37489 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37492 this.lastSize = {width: w, height: h};
37497 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37498 * @return {Roo.UpdateManager} The UpdateManager
37500 getUpdateManager : function(){
37501 return this.el.getUpdateManager();
37504 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37505 * @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:
37508 url: "your-url.php",
37509 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37510 callback: yourFunction,
37511 scope: yourObject, //(optional scope)
37514 text: "Loading...",
37519 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37520 * 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.
37521 * @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}
37522 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37523 * @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.
37524 * @return {Roo.ContentPanel} this
37527 var um = this.el.getUpdateManager();
37528 um.update.apply(um, arguments);
37534 * 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.
37535 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37536 * @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)
37537 * @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)
37538 * @return {Roo.UpdateManager} The UpdateManager
37540 setUrl : function(url, params, loadOnce){
37541 if(this.refreshDelegate){
37542 this.removeListener("activate", this.refreshDelegate);
37544 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37545 this.on("activate", this.refreshDelegate);
37546 return this.el.getUpdateManager();
37549 _handleRefresh : function(url, params, loadOnce){
37550 if(!loadOnce || !this.loaded){
37551 var updater = this.el.getUpdateManager();
37552 updater.update(url, params, this._setLoaded.createDelegate(this));
37556 _setLoaded : function(){
37557 this.loaded = true;
37561 * Returns this panel's id
37564 getId : function(){
37569 * Returns this panel's element - used by regiosn to add.
37570 * @return {Roo.Element}
37572 getEl : function(){
37573 return this.wrapEl || this.el;
37578 adjustForComponents : function(width, height)
37580 //Roo.log('adjustForComponents ');
37581 if(this.resizeEl != this.el){
37582 width -= this.el.getFrameWidth('lr');
37583 height -= this.el.getFrameWidth('tb');
37586 var te = this.toolbar.getEl();
37587 te.setWidth(width);
37588 height -= te.getHeight();
37591 var te = this.footer.getEl();
37592 te.setWidth(width);
37593 height -= te.getHeight();
37597 if(this.adjustments){
37598 width += this.adjustments[0];
37599 height += this.adjustments[1];
37601 return {"width": width, "height": height};
37604 setSize : function(width, height){
37605 if(this.fitToFrame && !this.ignoreResize(width, height)){
37606 if(this.fitContainer && this.resizeEl != this.el){
37607 this.el.setSize(width, height);
37609 var size = this.adjustForComponents(width, height);
37610 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37611 this.fireEvent('resize', this, size.width, size.height);
37616 * Returns this panel's title
37619 getTitle : function(){
37621 if (typeof(this.title) != 'object') {
37626 for (var k in this.title) {
37627 if (!this.title.hasOwnProperty(k)) {
37631 if (k.indexOf('-') >= 0) {
37632 var s = k.split('-');
37633 for (var i = 0; i<s.length; i++) {
37634 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37637 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37644 * Set this panel's title
37645 * @param {String} title
37647 setTitle : function(title){
37648 this.title = title;
37650 this.region.updatePanelTitle(this, title);
37655 * Returns true is this panel was configured to be closable
37656 * @return {Boolean}
37658 isClosable : function(){
37659 return this.closable;
37662 beforeSlide : function(){
37664 this.resizeEl.clip();
37667 afterSlide : function(){
37669 this.resizeEl.unclip();
37673 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37674 * Will fail silently if the {@link #setUrl} method has not been called.
37675 * This does not activate the panel, just updates its content.
37677 refresh : function(){
37678 if(this.refreshDelegate){
37679 this.loaded = false;
37680 this.refreshDelegate();
37685 * Destroys this panel
37687 destroy : function(){
37688 this.el.removeAllListeners();
37689 var tempEl = document.createElement("span");
37690 tempEl.appendChild(this.el.dom);
37691 tempEl.innerHTML = "";
37697 * form - if the content panel contains a form - this is a reference to it.
37698 * @type {Roo.form.Form}
37702 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37703 * This contains a reference to it.
37709 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37719 * @param {Object} cfg Xtype definition of item to add.
37723 getChildContainer: function () {
37724 return this.getEl();
37729 var ret = new Roo.factory(cfg);
37734 if (cfg.xtype.match(/^Form$/)) {
37737 //if (this.footer) {
37738 // el = this.footer.container.insertSibling(false, 'before');
37740 el = this.el.createChild();
37743 this.form = new Roo.form.Form(cfg);
37746 if ( this.form.allItems.length) {
37747 this.form.render(el.dom);
37751 // should only have one of theses..
37752 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37753 // views.. should not be just added - used named prop 'view''
37755 cfg.el = this.el.appendChild(document.createElement("div"));
37758 var ret = new Roo.factory(cfg);
37760 ret.render && ret.render(false, ''); // render blank..
37770 * @class Roo.bootstrap.panel.Grid
37771 * @extends Roo.bootstrap.panel.Content
37773 * Create a new GridPanel.
37774 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37775 * @param {Object} config A the config object
37781 Roo.bootstrap.panel.Grid = function(config)
37785 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37786 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37788 config.el = this.wrapper;
37789 //this.el = this.wrapper;
37791 if (config.container) {
37792 // ctor'ed from a Border/panel.grid
37795 this.wrapper.setStyle("overflow", "hidden");
37796 this.wrapper.addClass('roo-grid-container');
37801 if(config.toolbar){
37802 var tool_el = this.wrapper.createChild();
37803 this.toolbar = Roo.factory(config.toolbar);
37805 if (config.toolbar.items) {
37806 ti = config.toolbar.items ;
37807 delete config.toolbar.items ;
37811 this.toolbar.render(tool_el);
37812 for(var i =0;i < ti.length;i++) {
37813 // Roo.log(['add child', items[i]]);
37814 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37816 this.toolbar.items = nitems;
37818 delete config.toolbar;
37821 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37822 config.grid.scrollBody = true;;
37823 config.grid.monitorWindowResize = false; // turn off autosizing
37824 config.grid.autoHeight = false;
37825 config.grid.autoWidth = false;
37827 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37829 if (config.background) {
37830 // render grid on panel activation (if panel background)
37831 this.on('activate', function(gp) {
37832 if (!gp.grid.rendered) {
37833 gp.grid.render(this.wrapper);
37834 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37839 this.grid.render(this.wrapper);
37840 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37843 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37844 // ??? needed ??? config.el = this.wrapper;
37849 // xtype created footer. - not sure if will work as we normally have to render first..
37850 if (this.footer && !this.footer.el && this.footer.xtype) {
37852 var ctr = this.grid.getView().getFooterPanel(true);
37853 this.footer.dataSource = this.grid.dataSource;
37854 this.footer = Roo.factory(this.footer, Roo);
37855 this.footer.render(ctr);
37865 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37866 getId : function(){
37867 return this.grid.id;
37871 * Returns the grid for this panel
37872 * @return {Roo.bootstrap.Table}
37874 getGrid : function(){
37878 setSize : function(width, height){
37879 if(!this.ignoreResize(width, height)){
37880 var grid = this.grid;
37881 var size = this.adjustForComponents(width, height);
37882 var gridel = grid.getGridEl();
37883 gridel.setSize(size.width, size.height);
37885 var thd = grid.getGridEl().select('thead',true).first();
37886 var tbd = grid.getGridEl().select('tbody', true).first();
37888 tbd.setSize(width, height - thd.getHeight());
37897 beforeSlide : function(){
37898 this.grid.getView().scroller.clip();
37901 afterSlide : function(){
37902 this.grid.getView().scroller.unclip();
37905 destroy : function(){
37906 this.grid.destroy();
37908 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37913 * @class Roo.bootstrap.panel.Nest
37914 * @extends Roo.bootstrap.panel.Content
37916 * Create a new Panel, that can contain a layout.Border.
37919 * @param {Roo.BorderLayout} layout The layout for this panel
37920 * @param {String/Object} config A string to set only the title or a config object
37922 Roo.bootstrap.panel.Nest = function(config)
37924 // construct with only one argument..
37925 /* FIXME - implement nicer consturctors
37926 if (layout.layout) {
37928 layout = config.layout;
37929 delete config.layout;
37931 if (layout.xtype && !layout.getEl) {
37932 // then layout needs constructing..
37933 layout = Roo.factory(layout, Roo);
37937 config.el = config.layout.getEl();
37939 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37941 config.layout.monitorWindowResize = false; // turn off autosizing
37942 this.layout = config.layout;
37943 this.layout.getEl().addClass("roo-layout-nested-layout");
37944 this.layout.parent = this;
37951 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37953 setSize : function(width, height){
37954 if(!this.ignoreResize(width, height)){
37955 var size = this.adjustForComponents(width, height);
37956 var el = this.layout.getEl();
37957 if (size.height < 1) {
37958 el.setWidth(size.width);
37960 el.setSize(size.width, size.height);
37962 var touch = el.dom.offsetWidth;
37963 this.layout.layout();
37964 // ie requires a double layout on the first pass
37965 if(Roo.isIE && !this.initialized){
37966 this.initialized = true;
37967 this.layout.layout();
37972 // activate all subpanels if not currently active..
37974 setActiveState : function(active){
37975 this.active = active;
37976 this.setActiveClass(active);
37979 this.fireEvent("deactivate", this);
37983 this.fireEvent("activate", this);
37984 // not sure if this should happen before or after..
37985 if (!this.layout) {
37986 return; // should not happen..
37989 for (var r in this.layout.regions) {
37990 reg = this.layout.getRegion(r);
37991 if (reg.getActivePanel()) {
37992 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37993 reg.setActivePanel(reg.getActivePanel());
37996 if (!reg.panels.length) {
37999 reg.showPanel(reg.getPanel(0));
38008 * Returns the nested BorderLayout for this panel
38009 * @return {Roo.BorderLayout}
38011 getLayout : function(){
38012 return this.layout;
38016 * Adds a xtype elements to the layout of the nested panel
38020 xtype : 'ContentPanel',
38027 xtype : 'NestedLayoutPanel',
38033 items : [ ... list of content panels or nested layout panels.. ]
38037 * @param {Object} cfg Xtype definition of item to add.
38039 addxtype : function(cfg) {
38040 return this.layout.addxtype(cfg);
38045 * Ext JS Library 1.1.1
38046 * Copyright(c) 2006-2007, Ext JS, LLC.
38048 * Originally Released Under LGPL - original licence link has changed is not relivant.
38051 * <script type="text/javascript">
38054 * @class Roo.TabPanel
38055 * @extends Roo.util.Observable
38056 * A lightweight tab container.
38060 // basic tabs 1, built from existing content
38061 var tabs = new Roo.TabPanel("tabs1");
38062 tabs.addTab("script", "View Script");
38063 tabs.addTab("markup", "View Markup");
38064 tabs.activate("script");
38066 // more advanced tabs, built from javascript
38067 var jtabs = new Roo.TabPanel("jtabs");
38068 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38070 // set up the UpdateManager
38071 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38072 var updater = tab2.getUpdateManager();
38073 updater.setDefaultUrl("ajax1.htm");
38074 tab2.on('activate', updater.refresh, updater, true);
38076 // Use setUrl for Ajax loading
38077 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38078 tab3.setUrl("ajax2.htm", null, true);
38081 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38084 jtabs.activate("jtabs-1");
38087 * Create a new TabPanel.
38088 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38089 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38091 Roo.bootstrap.panel.Tabs = function(config){
38093 * The container element for this TabPanel.
38094 * @type Roo.Element
38096 this.el = Roo.get(config.el);
38099 if(typeof config == "boolean"){
38100 this.tabPosition = config ? "bottom" : "top";
38102 Roo.apply(this, config);
38106 if(this.tabPosition == "bottom"){
38107 // if tabs are at the bottom = create the body first.
38108 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38109 this.el.addClass("roo-tabs-bottom");
38111 // next create the tabs holders
38113 if (this.tabPosition == "west"){
38115 var reg = this.region; // fake it..
38117 if (!reg.mgr.parent) {
38120 reg = reg.mgr.parent.region;
38122 Roo.log("got nest?");
38124 if (reg.mgr.getRegion('west')) {
38125 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38126 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38127 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38128 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38129 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38137 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38138 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38139 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38140 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38145 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38148 // finally - if tabs are at the top, then create the body last..
38149 if(this.tabPosition != "bottom"){
38150 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38151 * @type Roo.Element
38153 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38154 this.el.addClass("roo-tabs-top");
38158 this.bodyEl.setStyle("position", "relative");
38160 this.active = null;
38161 this.activateDelegate = this.activate.createDelegate(this);
38166 * Fires when the active tab changes
38167 * @param {Roo.TabPanel} this
38168 * @param {Roo.TabPanelItem} activePanel The new active tab
38172 * @event beforetabchange
38173 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38174 * @param {Roo.TabPanel} this
38175 * @param {Object} e Set cancel to true on this object to cancel the tab change
38176 * @param {Roo.TabPanelItem} tab The tab being changed to
38178 "beforetabchange" : true
38181 Roo.EventManager.onWindowResize(this.onResize, this);
38182 this.cpad = this.el.getPadding("lr");
38183 this.hiddenCount = 0;
38186 // toolbar on the tabbar support...
38187 if (this.toolbar) {
38188 alert("no toolbar support yet");
38189 this.toolbar = false;
38191 var tcfg = this.toolbar;
38192 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38193 this.toolbar = new Roo.Toolbar(tcfg);
38194 if (Roo.isSafari) {
38195 var tbl = tcfg.container.child('table', true);
38196 tbl.setAttribute('width', '100%');
38204 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38207 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38209 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38211 tabPosition : "top",
38213 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38215 currentTabWidth : 0,
38217 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38221 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38225 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38227 preferredTabWidth : 175,
38229 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38231 resizeTabs : false,
38233 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38235 monitorResize : true,
38237 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38239 toolbar : false, // set by caller..
38241 region : false, /// set by caller
38243 disableTooltips : true, // not used yet...
38246 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38247 * @param {String} id The id of the div to use <b>or create</b>
38248 * @param {String} text The text for the tab
38249 * @param {String} content (optional) Content to put in the TabPanelItem body
38250 * @param {Boolean} closable (optional) True to create a close icon on the tab
38251 * @return {Roo.TabPanelItem} The created TabPanelItem
38253 addTab : function(id, text, content, closable, tpl)
38255 var item = new Roo.bootstrap.panel.TabItem({
38259 closable : closable,
38262 this.addTabItem(item);
38264 item.setContent(content);
38270 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38271 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38272 * @return {Roo.TabPanelItem}
38274 getTab : function(id){
38275 return this.items[id];
38279 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38280 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38282 hideTab : function(id){
38283 var t = this.items[id];
38286 this.hiddenCount++;
38287 this.autoSizeTabs();
38292 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38293 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38295 unhideTab : function(id){
38296 var t = this.items[id];
38298 t.setHidden(false);
38299 this.hiddenCount--;
38300 this.autoSizeTabs();
38305 * Adds an existing {@link Roo.TabPanelItem}.
38306 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38308 addTabItem : function(item)
38310 this.items[item.id] = item;
38311 this.items.push(item);
38312 this.autoSizeTabs();
38313 // if(this.resizeTabs){
38314 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38315 // this.autoSizeTabs();
38317 // item.autoSize();
38322 * Removes a {@link Roo.TabPanelItem}.
38323 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38325 removeTab : function(id){
38326 var items = this.items;
38327 var tab = items[id];
38328 if(!tab) { return; }
38329 var index = items.indexOf(tab);
38330 if(this.active == tab && items.length > 1){
38331 var newTab = this.getNextAvailable(index);
38336 this.stripEl.dom.removeChild(tab.pnode.dom);
38337 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38338 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38340 items.splice(index, 1);
38341 delete this.items[tab.id];
38342 tab.fireEvent("close", tab);
38343 tab.purgeListeners();
38344 this.autoSizeTabs();
38347 getNextAvailable : function(start){
38348 var items = this.items;
38350 // look for a next tab that will slide over to
38351 // replace the one being removed
38352 while(index < items.length){
38353 var item = items[++index];
38354 if(item && !item.isHidden()){
38358 // if one isn't found select the previous tab (on the left)
38361 var item = items[--index];
38362 if(item && !item.isHidden()){
38370 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38371 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38373 disableTab : function(id){
38374 var tab = this.items[id];
38375 if(tab && this.active != tab){
38381 * Enables a {@link Roo.TabPanelItem} that is disabled.
38382 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38384 enableTab : function(id){
38385 var tab = this.items[id];
38390 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38391 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38392 * @return {Roo.TabPanelItem} The TabPanelItem.
38394 activate : function(id)
38396 //Roo.log('activite:' + id);
38398 var tab = this.items[id];
38402 if(tab == this.active || tab.disabled){
38406 this.fireEvent("beforetabchange", this, e, tab);
38407 if(e.cancel !== true && !tab.disabled){
38409 this.active.hide();
38411 this.active = this.items[id];
38412 this.active.show();
38413 this.fireEvent("tabchange", this, this.active);
38419 * Gets the active {@link Roo.TabPanelItem}.
38420 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38422 getActiveTab : function(){
38423 return this.active;
38427 * Updates the tab body element to fit the height of the container element
38428 * for overflow scrolling
38429 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38431 syncHeight : function(targetHeight){
38432 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38433 var bm = this.bodyEl.getMargins();
38434 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38435 this.bodyEl.setHeight(newHeight);
38439 onResize : function(){
38440 if(this.monitorResize){
38441 this.autoSizeTabs();
38446 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38448 beginUpdate : function(){
38449 this.updating = true;
38453 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38455 endUpdate : function(){
38456 this.updating = false;
38457 this.autoSizeTabs();
38461 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38463 autoSizeTabs : function()
38465 var count = this.items.length;
38466 var vcount = count - this.hiddenCount;
38469 this.stripEl.hide();
38471 this.stripEl.show();
38474 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38479 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38480 var availWidth = Math.floor(w / vcount);
38481 var b = this.stripBody;
38482 if(b.getWidth() > w){
38483 var tabs = this.items;
38484 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38485 if(availWidth < this.minTabWidth){
38486 /*if(!this.sleft){ // incomplete scrolling code
38487 this.createScrollButtons();
38490 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38493 if(this.currentTabWidth < this.preferredTabWidth){
38494 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38500 * Returns the number of tabs in this TabPanel.
38503 getCount : function(){
38504 return this.items.length;
38508 * Resizes all the tabs to the passed width
38509 * @param {Number} The new width
38511 setTabWidth : function(width){
38512 this.currentTabWidth = width;
38513 for(var i = 0, len = this.items.length; i < len; i++) {
38514 if(!this.items[i].isHidden()) {
38515 this.items[i].setWidth(width);
38521 * Destroys this TabPanel
38522 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38524 destroy : function(removeEl){
38525 Roo.EventManager.removeResizeListener(this.onResize, this);
38526 for(var i = 0, len = this.items.length; i < len; i++){
38527 this.items[i].purgeListeners();
38529 if(removeEl === true){
38530 this.el.update("");
38535 createStrip : function(container)
38537 var strip = document.createElement("nav");
38538 strip.className = Roo.bootstrap.version == 4 ?
38539 "navbar-light bg-light" :
38540 "navbar navbar-default"; //"x-tabs-wrap";
38541 container.appendChild(strip);
38545 createStripList : function(strip)
38547 // div wrapper for retard IE
38548 // returns the "tr" element.
38549 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38550 //'<div class="x-tabs-strip-wrap">'+
38551 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38552 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38553 return strip.firstChild; //.firstChild.firstChild.firstChild;
38555 createBody : function(container)
38557 var body = document.createElement("div");
38558 Roo.id(body, "tab-body");
38559 //Roo.fly(body).addClass("x-tabs-body");
38560 Roo.fly(body).addClass("tab-content");
38561 container.appendChild(body);
38564 createItemBody :function(bodyEl, id){
38565 var body = Roo.getDom(id);
38567 body = document.createElement("div");
38570 //Roo.fly(body).addClass("x-tabs-item-body");
38571 Roo.fly(body).addClass("tab-pane");
38572 bodyEl.insertBefore(body, bodyEl.firstChild);
38576 createStripElements : function(stripEl, text, closable, tpl)
38578 var td = document.createElement("li"); // was td..
38579 td.className = 'nav-item';
38581 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38584 stripEl.appendChild(td);
38586 td.className = "x-tabs-closable";
38587 if(!this.closeTpl){
38588 this.closeTpl = new Roo.Template(
38589 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38590 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38591 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38594 var el = this.closeTpl.overwrite(td, {"text": text});
38595 var close = el.getElementsByTagName("div")[0];
38596 var inner = el.getElementsByTagName("em")[0];
38597 return {"el": el, "close": close, "inner": inner};
38600 // not sure what this is..
38601 // if(!this.tabTpl){
38602 //this.tabTpl = new Roo.Template(
38603 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38604 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38606 // this.tabTpl = new Roo.Template(
38607 // '<a href="#">' +
38608 // '<span unselectable="on"' +
38609 // (this.disableTooltips ? '' : ' title="{text}"') +
38610 // ' >{text}</span></a>'
38616 var template = tpl || this.tabTpl || false;
38619 template = new Roo.Template(
38620 Roo.bootstrap.version == 4 ?
38622 '<a class="nav-link" href="#" unselectable="on"' +
38623 (this.disableTooltips ? '' : ' title="{text}"') +
38626 '<a class="nav-link" href="#">' +
38627 '<span unselectable="on"' +
38628 (this.disableTooltips ? '' : ' title="{text}"') +
38629 ' >{text}</span></a>'
38634 switch (typeof(template)) {
38638 template = new Roo.Template(template);
38644 var el = template.overwrite(td, {"text": text});
38646 var inner = el.getElementsByTagName("span")[0];
38648 return {"el": el, "inner": inner};
38656 * @class Roo.TabPanelItem
38657 * @extends Roo.util.Observable
38658 * Represents an individual item (tab plus body) in a TabPanel.
38659 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38660 * @param {String} id The id of this TabPanelItem
38661 * @param {String} text The text for the tab of this TabPanelItem
38662 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38664 Roo.bootstrap.panel.TabItem = function(config){
38666 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38667 * @type Roo.TabPanel
38669 this.tabPanel = config.panel;
38671 * The id for this TabPanelItem
38674 this.id = config.id;
38676 this.disabled = false;
38678 this.text = config.text;
38680 this.loaded = false;
38681 this.closable = config.closable;
38684 * The body element for this TabPanelItem.
38685 * @type Roo.Element
38687 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38688 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38689 this.bodyEl.setStyle("display", "block");
38690 this.bodyEl.setStyle("zoom", "1");
38691 //this.hideAction();
38693 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38695 this.el = Roo.get(els.el);
38696 this.inner = Roo.get(els.inner, true);
38697 this.textEl = Roo.bootstrap.version == 4 ?
38698 this.el : Roo.get(this.el.dom.firstChild, true);
38700 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38701 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38704 // this.el.on("mousedown", this.onTabMouseDown, this);
38705 this.el.on("click", this.onTabClick, this);
38707 if(config.closable){
38708 var c = Roo.get(els.close, true);
38709 c.dom.title = this.closeText;
38710 c.addClassOnOver("close-over");
38711 c.on("click", this.closeClick, this);
38717 * Fires when this tab becomes the active tab.
38718 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38719 * @param {Roo.TabPanelItem} this
38723 * @event beforeclose
38724 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38725 * @param {Roo.TabPanelItem} this
38726 * @param {Object} e Set cancel to true on this object to cancel the close.
38728 "beforeclose": true,
38731 * Fires when this tab is closed.
38732 * @param {Roo.TabPanelItem} this
38736 * @event deactivate
38737 * Fires when this tab is no longer the active tab.
38738 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38739 * @param {Roo.TabPanelItem} this
38741 "deactivate" : true
38743 this.hidden = false;
38745 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38748 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38750 purgeListeners : function(){
38751 Roo.util.Observable.prototype.purgeListeners.call(this);
38752 this.el.removeAllListeners();
38755 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38758 this.status_node.addClass("active");
38761 this.tabPanel.stripWrap.repaint();
38763 this.fireEvent("activate", this.tabPanel, this);
38767 * Returns true if this tab is the active tab.
38768 * @return {Boolean}
38770 isActive : function(){
38771 return this.tabPanel.getActiveTab() == this;
38775 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38778 this.status_node.removeClass("active");
38780 this.fireEvent("deactivate", this.tabPanel, this);
38783 hideAction : function(){
38784 this.bodyEl.hide();
38785 this.bodyEl.setStyle("position", "absolute");
38786 this.bodyEl.setLeft("-20000px");
38787 this.bodyEl.setTop("-20000px");
38790 showAction : function(){
38791 this.bodyEl.setStyle("position", "relative");
38792 this.bodyEl.setTop("");
38793 this.bodyEl.setLeft("");
38794 this.bodyEl.show();
38798 * Set the tooltip for the tab.
38799 * @param {String} tooltip The tab's tooltip
38801 setTooltip : function(text){
38802 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38803 this.textEl.dom.qtip = text;
38804 this.textEl.dom.removeAttribute('title');
38806 this.textEl.dom.title = text;
38810 onTabClick : function(e){
38811 e.preventDefault();
38812 this.tabPanel.activate(this.id);
38815 onTabMouseDown : function(e){
38816 e.preventDefault();
38817 this.tabPanel.activate(this.id);
38820 getWidth : function(){
38821 return this.inner.getWidth();
38824 setWidth : function(width){
38825 var iwidth = width - this.linode.getPadding("lr");
38826 this.inner.setWidth(iwidth);
38827 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38828 this.linode.setWidth(width);
38832 * Show or hide the tab
38833 * @param {Boolean} hidden True to hide or false to show.
38835 setHidden : function(hidden){
38836 this.hidden = hidden;
38837 this.linode.setStyle("display", hidden ? "none" : "");
38841 * Returns true if this tab is "hidden"
38842 * @return {Boolean}
38844 isHidden : function(){
38845 return this.hidden;
38849 * Returns the text for this tab
38852 getText : function(){
38856 autoSize : function(){
38857 //this.el.beginMeasure();
38858 this.textEl.setWidth(1);
38860 * #2804 [new] Tabs in Roojs
38861 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38863 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38864 //this.el.endMeasure();
38868 * Sets the text for the tab (Note: this also sets the tooltip text)
38869 * @param {String} text The tab's text and tooltip
38871 setText : function(text){
38873 this.textEl.update(text);
38874 this.setTooltip(text);
38875 //if(!this.tabPanel.resizeTabs){
38876 // this.autoSize();
38880 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38882 activate : function(){
38883 this.tabPanel.activate(this.id);
38887 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38889 disable : function(){
38890 if(this.tabPanel.active != this){
38891 this.disabled = true;
38892 this.status_node.addClass("disabled");
38897 * Enables this TabPanelItem if it was previously disabled.
38899 enable : function(){
38900 this.disabled = false;
38901 this.status_node.removeClass("disabled");
38905 * Sets the content for this TabPanelItem.
38906 * @param {String} content The content
38907 * @param {Boolean} loadScripts true to look for and load scripts
38909 setContent : function(content, loadScripts){
38910 this.bodyEl.update(content, loadScripts);
38914 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38915 * @return {Roo.UpdateManager} The UpdateManager
38917 getUpdateManager : function(){
38918 return this.bodyEl.getUpdateManager();
38922 * Set a URL to be used to load the content for this TabPanelItem.
38923 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38924 * @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)
38925 * @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)
38926 * @return {Roo.UpdateManager} The UpdateManager
38928 setUrl : function(url, params, loadOnce){
38929 if(this.refreshDelegate){
38930 this.un('activate', this.refreshDelegate);
38932 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38933 this.on("activate", this.refreshDelegate);
38934 return this.bodyEl.getUpdateManager();
38938 _handleRefresh : function(url, params, loadOnce){
38939 if(!loadOnce || !this.loaded){
38940 var updater = this.bodyEl.getUpdateManager();
38941 updater.update(url, params, this._setLoaded.createDelegate(this));
38946 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38947 * Will fail silently if the setUrl method has not been called.
38948 * This does not activate the panel, just updates its content.
38950 refresh : function(){
38951 if(this.refreshDelegate){
38952 this.loaded = false;
38953 this.refreshDelegate();
38958 _setLoaded : function(){
38959 this.loaded = true;
38963 closeClick : function(e){
38966 this.fireEvent("beforeclose", this, o);
38967 if(o.cancel !== true){
38968 this.tabPanel.removeTab(this.id);
38972 * The text displayed in the tooltip for the close icon.
38975 closeText : "Close this tab"
38978 * This script refer to:
38979 * Title: International Telephone Input
38980 * Author: Jack O'Connor
38981 * Code version: v12.1.12
38982 * Availability: https://github.com/jackocnr/intl-tel-input.git
38985 Roo.bootstrap.PhoneInputData = function() {
38988 "Afghanistan (افغانستان)",
38993 "Albania (Shqipëri)",
38998 "Algeria (الجزائر)",
39023 "Antigua and Barbuda",
39033 "Armenia (Հայաստան)",
39049 "Austria (Österreich)",
39054 "Azerbaijan (Azərbaycan)",
39064 "Bahrain (البحرين)",
39069 "Bangladesh (বাংলাদেশ)",
39079 "Belarus (Беларусь)",
39084 "Belgium (België)",
39114 "Bosnia and Herzegovina (Босна и Херцеговина)",
39129 "British Indian Ocean Territory",
39134 "British Virgin Islands",
39144 "Bulgaria (България)",
39154 "Burundi (Uburundi)",
39159 "Cambodia (កម្ពុជា)",
39164 "Cameroon (Cameroun)",
39173 ["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"]
39176 "Cape Verde (Kabu Verdi)",
39181 "Caribbean Netherlands",
39192 "Central African Republic (République centrafricaine)",
39212 "Christmas Island",
39218 "Cocos (Keeling) Islands",
39229 "Comoros (جزر القمر)",
39234 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39239 "Congo (Republic) (Congo-Brazzaville)",
39259 "Croatia (Hrvatska)",
39280 "Czech Republic (Česká republika)",
39285 "Denmark (Danmark)",
39300 "Dominican Republic (República Dominicana)",
39304 ["809", "829", "849"]
39322 "Equatorial Guinea (Guinea Ecuatorial)",
39342 "Falkland Islands (Islas Malvinas)",
39347 "Faroe Islands (Føroyar)",
39368 "French Guiana (Guyane française)",
39373 "French Polynesia (Polynésie française)",
39388 "Georgia (საქართველო)",
39393 "Germany (Deutschland)",
39413 "Greenland (Kalaallit Nunaat)",
39450 "Guinea-Bissau (Guiné Bissau)",
39475 "Hungary (Magyarország)",
39480 "Iceland (Ísland)",
39500 "Iraq (العراق)",
39516 "Israel (ישראל)",
39543 "Jordan (الأردن)",
39548 "Kazakhstan (Казахстан)",
39569 "Kuwait (الكويت)",
39574 "Kyrgyzstan (Кыргызстан)",
39584 "Latvia (Latvija)",
39589 "Lebanon (لبنان)",
39604 "Libya (ليبيا)",
39614 "Lithuania (Lietuva)",
39629 "Macedonia (FYROM) (Македонија)",
39634 "Madagascar (Madagasikara)",
39664 "Marshall Islands",
39674 "Mauritania (موريتانيا)",
39679 "Mauritius (Moris)",
39700 "Moldova (Republica Moldova)",
39710 "Mongolia (Монгол)",
39715 "Montenegro (Crna Gora)",
39725 "Morocco (المغرب)",
39731 "Mozambique (Moçambique)",
39736 "Myanmar (Burma) (မြန်မာ)",
39741 "Namibia (Namibië)",
39756 "Netherlands (Nederland)",
39761 "New Caledonia (Nouvelle-Calédonie)",
39796 "North Korea (조선 민주주의 인민 공화국)",
39801 "Northern Mariana Islands",
39817 "Pakistan (پاکستان)",
39827 "Palestine (فلسطين)",
39837 "Papua New Guinea",
39879 "Réunion (La Réunion)",
39885 "Romania (România)",
39901 "Saint Barthélemy",
39912 "Saint Kitts and Nevis",
39922 "Saint Martin (Saint-Martin (partie française))",
39928 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39933 "Saint Vincent and the Grenadines",
39948 "São Tomé and Príncipe (São Tomé e Príncipe)",
39953 "Saudi Arabia (المملكة العربية السعودية)",
39958 "Senegal (Sénégal)",
39988 "Slovakia (Slovensko)",
39993 "Slovenia (Slovenija)",
40003 "Somalia (Soomaaliya)",
40013 "South Korea (대한민국)",
40018 "South Sudan (جنوب السودان)",
40028 "Sri Lanka (ශ්රී ලංකාව)",
40033 "Sudan (السودان)",
40043 "Svalbard and Jan Mayen",
40054 "Sweden (Sverige)",
40059 "Switzerland (Schweiz)",
40064 "Syria (سوريا)",
40109 "Trinidad and Tobago",
40114 "Tunisia (تونس)",
40119 "Turkey (Türkiye)",
40129 "Turks and Caicos Islands",
40139 "U.S. Virgin Islands",
40149 "Ukraine (Україна)",
40154 "United Arab Emirates (الإمارات العربية المتحدة)",
40176 "Uzbekistan (Oʻzbekiston)",
40186 "Vatican City (Città del Vaticano)",
40197 "Vietnam (Việt Nam)",
40202 "Wallis and Futuna (Wallis-et-Futuna)",
40207 "Western Sahara (الصحراء الغربية)",
40213 "Yemen (اليمن)",
40237 * This script refer to:
40238 * Title: International Telephone Input
40239 * Author: Jack O'Connor
40240 * Code version: v12.1.12
40241 * Availability: https://github.com/jackocnr/intl-tel-input.git
40245 * @class Roo.bootstrap.PhoneInput
40246 * @extends Roo.bootstrap.TriggerField
40247 * An input with International dial-code selection
40249 * @cfg {String} defaultDialCode default '+852'
40250 * @cfg {Array} preferedCountries default []
40253 * Create a new PhoneInput.
40254 * @param {Object} config Configuration options
40257 Roo.bootstrap.PhoneInput = function(config) {
40258 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40261 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40263 listWidth: undefined,
40265 selectedClass: 'active',
40267 invalidClass : "has-warning",
40269 validClass: 'has-success',
40271 allowed: '0123456789',
40276 * @cfg {String} defaultDialCode The default dial code when initializing the input
40278 defaultDialCode: '+852',
40281 * @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
40283 preferedCountries: false,
40285 getAutoCreate : function()
40287 var data = Roo.bootstrap.PhoneInputData();
40288 var align = this.labelAlign || this.parentLabelAlign();
40291 this.allCountries = [];
40292 this.dialCodeMapping = [];
40294 for (var i = 0; i < data.length; i++) {
40296 this.allCountries[i] = {
40300 priority: c[3] || 0,
40301 areaCodes: c[4] || null
40303 this.dialCodeMapping[c[2]] = {
40306 priority: c[3] || 0,
40307 areaCodes: c[4] || null
40319 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40320 maxlength: this.max_length,
40321 cls : 'form-control tel-input',
40322 autocomplete: 'new-password'
40325 var hiddenInput = {
40328 cls: 'hidden-tel-input'
40332 hiddenInput.name = this.name;
40335 if (this.disabled) {
40336 input.disabled = true;
40339 var flag_container = {
40356 cls: this.hasFeedback ? 'has-feedback' : '',
40362 cls: 'dial-code-holder',
40369 cls: 'roo-select2-container input-group',
40376 if (this.fieldLabel.length) {
40379 tooltip: 'This field is required'
40385 cls: 'control-label',
40391 html: this.fieldLabel
40394 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40400 if(this.indicatorpos == 'right') {
40401 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40408 if(align == 'left') {
40416 if(this.labelWidth > 12){
40417 label.style = "width: " + this.labelWidth + 'px';
40419 if(this.labelWidth < 13 && this.labelmd == 0){
40420 this.labelmd = this.labelWidth;
40422 if(this.labellg > 0){
40423 label.cls += ' col-lg-' + this.labellg;
40424 input.cls += ' col-lg-' + (12 - this.labellg);
40426 if(this.labelmd > 0){
40427 label.cls += ' col-md-' + this.labelmd;
40428 container.cls += ' col-md-' + (12 - this.labelmd);
40430 if(this.labelsm > 0){
40431 label.cls += ' col-sm-' + this.labelsm;
40432 container.cls += ' col-sm-' + (12 - this.labelsm);
40434 if(this.labelxs > 0){
40435 label.cls += ' col-xs-' + this.labelxs;
40436 container.cls += ' col-xs-' + (12 - this.labelxs);
40446 var settings = this;
40448 ['xs','sm','md','lg'].map(function(size){
40449 if (settings[size]) {
40450 cfg.cls += ' col-' + size + '-' + settings[size];
40454 this.store = new Roo.data.Store({
40455 proxy : new Roo.data.MemoryProxy({}),
40456 reader : new Roo.data.JsonReader({
40467 'name' : 'dialCode',
40471 'name' : 'priority',
40475 'name' : 'areaCodes',
40482 if(!this.preferedCountries) {
40483 this.preferedCountries = [
40490 var p = this.preferedCountries.reverse();
40493 for (var i = 0; i < p.length; i++) {
40494 for (var j = 0; j < this.allCountries.length; j++) {
40495 if(this.allCountries[j].iso2 == p[i]) {
40496 var t = this.allCountries[j];
40497 this.allCountries.splice(j,1);
40498 this.allCountries.unshift(t);
40504 this.store.proxy.data = {
40506 data: this.allCountries
40512 initEvents : function()
40515 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40517 this.indicator = this.indicatorEl();
40518 this.flag = this.flagEl();
40519 this.dialCodeHolder = this.dialCodeHolderEl();
40521 this.trigger = this.el.select('div.flag-box',true).first();
40522 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40527 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40528 _this.list.setWidth(lw);
40531 this.list.on('mouseover', this.onViewOver, this);
40532 this.list.on('mousemove', this.onViewMove, this);
40533 this.inputEl().on("keyup", this.onKeyUp, this);
40534 this.inputEl().on("keypress", this.onKeyPress, this);
40536 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40538 this.view = new Roo.View(this.list, this.tpl, {
40539 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40542 this.view.on('click', this.onViewClick, this);
40543 this.setValue(this.defaultDialCode);
40546 onTriggerClick : function(e)
40548 Roo.log('trigger click');
40553 if(this.isExpanded()){
40555 this.hasFocus = false;
40557 this.store.load({});
40558 this.hasFocus = true;
40563 isExpanded : function()
40565 return this.list.isVisible();
40568 collapse : function()
40570 if(!this.isExpanded()){
40574 Roo.get(document).un('mousedown', this.collapseIf, this);
40575 Roo.get(document).un('mousewheel', this.collapseIf, this);
40576 this.fireEvent('collapse', this);
40580 expand : function()
40584 if(this.isExpanded() || !this.hasFocus){
40588 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40589 this.list.setWidth(lw);
40592 this.restrictHeight();
40594 Roo.get(document).on('mousedown', this.collapseIf, this);
40595 Roo.get(document).on('mousewheel', this.collapseIf, this);
40597 this.fireEvent('expand', this);
40600 restrictHeight : function()
40602 this.list.alignTo(this.inputEl(), this.listAlign);
40603 this.list.alignTo(this.inputEl(), this.listAlign);
40606 onViewOver : function(e, t)
40608 if(this.inKeyMode){
40611 var item = this.view.findItemFromChild(t);
40614 var index = this.view.indexOf(item);
40615 this.select(index, false);
40620 onViewClick : function(view, doFocus, el, e)
40622 var index = this.view.getSelectedIndexes()[0];
40624 var r = this.store.getAt(index);
40627 this.onSelect(r, index);
40629 if(doFocus !== false && !this.blockFocus){
40630 this.inputEl().focus();
40634 onViewMove : function(e, t)
40636 this.inKeyMode = false;
40639 select : function(index, scrollIntoView)
40641 this.selectedIndex = index;
40642 this.view.select(index);
40643 if(scrollIntoView !== false){
40644 var el = this.view.getNode(index);
40646 this.list.scrollChildIntoView(el, false);
40651 createList : function()
40653 this.list = Roo.get(document.body).createChild({
40655 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40656 style: 'display:none'
40659 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40662 collapseIf : function(e)
40664 var in_combo = e.within(this.el);
40665 var in_list = e.within(this.list);
40666 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40668 if (in_combo || in_list || is_list) {
40674 onSelect : function(record, index)
40676 if(this.fireEvent('beforeselect', this, record, index) !== false){
40678 this.setFlagClass(record.data.iso2);
40679 this.setDialCode(record.data.dialCode);
40680 this.hasFocus = false;
40682 this.fireEvent('select', this, record, index);
40686 flagEl : function()
40688 var flag = this.el.select('div.flag',true).first();
40695 dialCodeHolderEl : function()
40697 var d = this.el.select('input.dial-code-holder',true).first();
40704 setDialCode : function(v)
40706 this.dialCodeHolder.dom.value = '+'+v;
40709 setFlagClass : function(n)
40711 this.flag.dom.className = 'flag '+n;
40714 getValue : function()
40716 var v = this.inputEl().getValue();
40717 if(this.dialCodeHolder) {
40718 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40723 setValue : function(v)
40725 var d = this.getDialCode(v);
40727 //invalid dial code
40728 if(v.length == 0 || !d || d.length == 0) {
40730 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40731 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40737 this.setFlagClass(this.dialCodeMapping[d].iso2);
40738 this.setDialCode(d);
40739 this.inputEl().dom.value = v.replace('+'+d,'');
40740 this.hiddenEl().dom.value = this.getValue();
40745 getDialCode : function(v)
40749 if (v.length == 0) {
40750 return this.dialCodeHolder.dom.value;
40754 if (v.charAt(0) != "+") {
40757 var numericChars = "";
40758 for (var i = 1; i < v.length; i++) {
40759 var c = v.charAt(i);
40762 if (this.dialCodeMapping[numericChars]) {
40763 dialCode = v.substr(1, i);
40765 if (numericChars.length == 4) {
40775 this.setValue(this.defaultDialCode);
40779 hiddenEl : function()
40781 return this.el.select('input.hidden-tel-input',true).first();
40784 // after setting val
40785 onKeyUp : function(e){
40786 this.setValue(this.getValue());
40789 onKeyPress : function(e){
40790 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40797 * @class Roo.bootstrap.MoneyField
40798 * @extends Roo.bootstrap.ComboBox
40799 * Bootstrap MoneyField class
40802 * Create a new MoneyField.
40803 * @param {Object} config Configuration options
40806 Roo.bootstrap.MoneyField = function(config) {
40808 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40812 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40815 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40817 allowDecimals : true,
40819 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40821 decimalSeparator : ".",
40823 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40825 decimalPrecision : 0,
40827 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40829 allowNegative : true,
40831 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40835 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40837 minValue : Number.NEGATIVE_INFINITY,
40839 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40841 maxValue : Number.MAX_VALUE,
40843 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40845 minText : "The minimum value for this field is {0}",
40847 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40849 maxText : "The maximum value for this field is {0}",
40851 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40852 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40854 nanText : "{0} is not a valid number",
40856 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40860 * @cfg {String} defaults currency of the MoneyField
40861 * value should be in lkey
40863 defaultCurrency : false,
40865 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40867 thousandsDelimiter : false,
40869 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40880 getAutoCreate : function()
40882 var align = this.labelAlign || this.parentLabelAlign();
40894 cls : 'form-control roo-money-amount-input',
40895 autocomplete: 'new-password'
40898 var hiddenInput = {
40902 cls: 'hidden-number-input'
40905 if(this.max_length) {
40906 input.maxlength = this.max_length;
40910 hiddenInput.name = this.name;
40913 if (this.disabled) {
40914 input.disabled = true;
40917 var clg = 12 - this.inputlg;
40918 var cmd = 12 - this.inputmd;
40919 var csm = 12 - this.inputsm;
40920 var cxs = 12 - this.inputxs;
40924 cls : 'row roo-money-field',
40928 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40932 cls: 'roo-select2-container input-group',
40936 cls : 'form-control roo-money-currency-input',
40937 autocomplete: 'new-password',
40939 name : this.currencyName
40943 cls : 'input-group-addon',
40957 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40961 cls: this.hasFeedback ? 'has-feedback' : '',
40972 if (this.fieldLabel.length) {
40975 tooltip: 'This field is required'
40981 cls: 'control-label',
40987 html: this.fieldLabel
40990 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40996 if(this.indicatorpos == 'right') {
40997 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41004 if(align == 'left') {
41012 if(this.labelWidth > 12){
41013 label.style = "width: " + this.labelWidth + 'px';
41015 if(this.labelWidth < 13 && this.labelmd == 0){
41016 this.labelmd = this.labelWidth;
41018 if(this.labellg > 0){
41019 label.cls += ' col-lg-' + this.labellg;
41020 input.cls += ' col-lg-' + (12 - this.labellg);
41022 if(this.labelmd > 0){
41023 label.cls += ' col-md-' + this.labelmd;
41024 container.cls += ' col-md-' + (12 - this.labelmd);
41026 if(this.labelsm > 0){
41027 label.cls += ' col-sm-' + this.labelsm;
41028 container.cls += ' col-sm-' + (12 - this.labelsm);
41030 if(this.labelxs > 0){
41031 label.cls += ' col-xs-' + this.labelxs;
41032 container.cls += ' col-xs-' + (12 - this.labelxs);
41043 var settings = this;
41045 ['xs','sm','md','lg'].map(function(size){
41046 if (settings[size]) {
41047 cfg.cls += ' col-' + size + '-' + settings[size];
41054 initEvents : function()
41056 this.indicator = this.indicatorEl();
41058 this.initCurrencyEvent();
41060 this.initNumberEvent();
41063 initCurrencyEvent : function()
41066 throw "can not find store for combo";
41069 this.store = Roo.factory(this.store, Roo.data);
41070 this.store.parent = this;
41074 this.triggerEl = this.el.select('.input-group-addon', true).first();
41076 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41081 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41082 _this.list.setWidth(lw);
41085 this.list.on('mouseover', this.onViewOver, this);
41086 this.list.on('mousemove', this.onViewMove, this);
41087 this.list.on('scroll', this.onViewScroll, this);
41090 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41093 this.view = new Roo.View(this.list, this.tpl, {
41094 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41097 this.view.on('click', this.onViewClick, this);
41099 this.store.on('beforeload', this.onBeforeLoad, this);
41100 this.store.on('load', this.onLoad, this);
41101 this.store.on('loadexception', this.onLoadException, this);
41103 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41104 "up" : function(e){
41105 this.inKeyMode = true;
41109 "down" : function(e){
41110 if(!this.isExpanded()){
41111 this.onTriggerClick();
41113 this.inKeyMode = true;
41118 "enter" : function(e){
41121 if(this.fireEvent("specialkey", this, e)){
41122 this.onViewClick(false);
41128 "esc" : function(e){
41132 "tab" : function(e){
41135 if(this.fireEvent("specialkey", this, e)){
41136 this.onViewClick(false);
41144 doRelay : function(foo, bar, hname){
41145 if(hname == 'down' || this.scope.isExpanded()){
41146 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41154 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41158 initNumberEvent : function(e)
41160 this.inputEl().on("keydown" , this.fireKey, this);
41161 this.inputEl().on("focus", this.onFocus, this);
41162 this.inputEl().on("blur", this.onBlur, this);
41164 this.inputEl().relayEvent('keyup', this);
41166 if(this.indicator){
41167 this.indicator.addClass('invisible');
41170 this.originalValue = this.getValue();
41172 if(this.validationEvent == 'keyup'){
41173 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41174 this.inputEl().on('keyup', this.filterValidation, this);
41176 else if(this.validationEvent !== false){
41177 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41180 if(this.selectOnFocus){
41181 this.on("focus", this.preFocus, this);
41184 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41185 this.inputEl().on("keypress", this.filterKeys, this);
41187 this.inputEl().relayEvent('keypress', this);
41190 var allowed = "0123456789";
41192 if(this.allowDecimals){
41193 allowed += this.decimalSeparator;
41196 if(this.allowNegative){
41200 if(this.thousandsDelimiter) {
41204 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41206 var keyPress = function(e){
41208 var k = e.getKey();
41210 var c = e.getCharCode();
41213 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41214 allowed.indexOf(String.fromCharCode(c)) === -1
41220 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41224 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41229 this.inputEl().on("keypress", keyPress, this);
41233 onTriggerClick : function(e)
41240 this.loadNext = false;
41242 if(this.isExpanded()){
41247 this.hasFocus = true;
41249 if(this.triggerAction == 'all') {
41250 this.doQuery(this.allQuery, true);
41254 this.doQuery(this.getRawValue());
41257 getCurrency : function()
41259 var v = this.currencyEl().getValue();
41264 restrictHeight : function()
41266 this.list.alignTo(this.currencyEl(), this.listAlign);
41267 this.list.alignTo(this.currencyEl(), this.listAlign);
41270 onViewClick : function(view, doFocus, el, e)
41272 var index = this.view.getSelectedIndexes()[0];
41274 var r = this.store.getAt(index);
41277 this.onSelect(r, index);
41281 onSelect : function(record, index){
41283 if(this.fireEvent('beforeselect', this, record, index) !== false){
41285 this.setFromCurrencyData(index > -1 ? record.data : false);
41289 this.fireEvent('select', this, record, index);
41293 setFromCurrencyData : function(o)
41297 this.lastCurrency = o;
41299 if (this.currencyField) {
41300 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41302 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41305 this.lastSelectionText = currency;
41307 //setting default currency
41308 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41309 this.setCurrency(this.defaultCurrency);
41313 this.setCurrency(currency);
41316 setFromData : function(o)
41320 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41322 this.setFromCurrencyData(c);
41327 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41329 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41332 this.setValue(value);
41336 setCurrency : function(v)
41338 this.currencyValue = v;
41341 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41346 setValue : function(v)
41348 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41354 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41356 this.inputEl().dom.value = (v == '') ? '' :
41357 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41359 if(!this.allowZero && v === '0') {
41360 this.hiddenEl().dom.value = '';
41361 this.inputEl().dom.value = '';
41368 getRawValue : function()
41370 var v = this.inputEl().getValue();
41375 getValue : function()
41377 return this.fixPrecision(this.parseValue(this.getRawValue()));
41380 parseValue : function(value)
41382 if(this.thousandsDelimiter) {
41384 r = new RegExp(",", "g");
41385 value = value.replace(r, "");
41388 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41389 return isNaN(value) ? '' : value;
41393 fixPrecision : function(value)
41395 if(this.thousandsDelimiter) {
41397 r = new RegExp(",", "g");
41398 value = value.replace(r, "");
41401 var nan = isNaN(value);
41403 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41404 return nan ? '' : value;
41406 return parseFloat(value).toFixed(this.decimalPrecision);
41409 decimalPrecisionFcn : function(v)
41411 return Math.floor(v);
41414 validateValue : function(value)
41416 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41420 var num = this.parseValue(value);
41423 this.markInvalid(String.format(this.nanText, value));
41427 if(num < this.minValue){
41428 this.markInvalid(String.format(this.minText, this.minValue));
41432 if(num > this.maxValue){
41433 this.markInvalid(String.format(this.maxText, this.maxValue));
41440 validate : function()
41442 if(this.disabled || this.allowBlank){
41447 var currency = this.getCurrency();
41449 if(this.validateValue(this.getRawValue()) && currency.length){
41454 this.markInvalid();
41458 getName: function()
41463 beforeBlur : function()
41469 var v = this.parseValue(this.getRawValue());
41476 onBlur : function()
41480 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41481 //this.el.removeClass(this.focusClass);
41484 this.hasFocus = false;
41486 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41490 var v = this.getValue();
41492 if(String(v) !== String(this.startValue)){
41493 this.fireEvent('change', this, v, this.startValue);
41496 this.fireEvent("blur", this);
41499 inputEl : function()
41501 return this.el.select('.roo-money-amount-input', true).first();
41504 currencyEl : function()
41506 return this.el.select('.roo-money-currency-input', true).first();
41509 hiddenEl : function()
41511 return this.el.select('input.hidden-number-input',true).first();