2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets, function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
585 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
586 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
587 * @cfg {String} size ( lg | sm | xs)
588 * @cfg {String} tag ( a | input | submit)
589 * @cfg {String} href empty or href
590 * @cfg {Boolean} disabled default false;
591 * @cfg {Boolean} isClose default false;
592 * @cfg {String} glyphicon depricated - use fa
593 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
594 * @cfg {String} badge text for badge
595 * @cfg {String} theme (default|glow)
596 * @cfg {Boolean} inverse dark themed version
597 * @cfg {Boolean} toggle is it a slidy toggle button
598 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
599 * @cfg {String} ontext text for on slidy toggle state
600 * @cfg {String} offtext text for off slidy toggle state
601 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
602 * @cfg {Boolean} removeClass remove the standard class..
603 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
606 * Create a new button
607 * @param {Object} config The config object
611 Roo.bootstrap.Button = function(config){
612 Roo.bootstrap.Button.superclass.constructor.call(this, config);
613 this.weightClass = ["btn-default btn-outline-secondary",
625 * When a butotn is pressed
626 * @param {Roo.bootstrap.Button} btn
627 * @param {Roo.EventObject} e
632 * After the button has been toggles
633 * @param {Roo.bootstrap.Button} btn
634 * @param {Roo.EventObject} e
635 * @param {boolean} pressed (also available as button.pressed)
641 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
662 preventDefault: true,
670 getAutoCreate : function(){
678 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
679 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
684 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
686 if (this.toggle == true) {
689 cls: 'slider-frame roo-button',
694 'data-off-text':'OFF',
695 cls: 'slider-button',
701 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
702 cfg.cls += ' '+this.weight;
711 cfg["aria-hidden"] = true;
713 cfg.html = "×";
719 if (this.theme==='default') {
720 cfg.cls = 'btn roo-button';
722 //if (this.parentType != 'Navbar') {
723 this.weight = this.weight.length ? this.weight : 'default';
725 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
727 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
728 var weight = this.weight == 'default' ? 'secondary' : this.weight;
729 cfg.cls += ' btn-' + outline + weight;
730 if (this.weight == 'default') {
732 cfg.cls += ' btn-' + this.weight;
735 } else if (this.theme==='glow') {
738 cfg.cls = 'btn-glow roo-button';
740 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
742 cfg.cls += ' ' + this.weight;
748 this.cls += ' inverse';
752 if (this.active || this.pressed === true) {
753 cfg.cls += ' active';
757 cfg.disabled = 'disabled';
761 Roo.log('changing to ul' );
763 this.glyphicon = 'caret';
764 if (Roo.bootstrap.version == 4) {
765 this.fa = 'caret-down';
770 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
772 //gsRoo.log(this.parentType);
773 if (this.parentType === 'Navbar' && !this.parent().bar) {
774 Roo.log('changing to li?');
783 href : this.href || '#'
786 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
787 cfg.cls += ' dropdown';
794 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
796 if (this.glyphicon) {
797 cfg.html = ' ' + cfg.html;
802 cls: 'glyphicon glyphicon-' + this.glyphicon
807 cfg.html = ' ' + cfg.html;
812 cls: 'fa fas fa-' + this.fa
822 // cfg.cls='btn roo-button';
826 var value = cfg.html;
831 cls: 'glyphicon glyphicon-' + this.glyphicon,
838 cls: 'fa fas fa-' + this.fa,
843 var bw = this.badge_weight.length ? this.badge_weight :
844 (this.weight.length ? this.weight : 'secondary');
845 bw = bw == 'default' ? 'secondary' : bw;
851 cls: 'badge badge-' + bw,
860 cfg.cls += ' dropdown';
861 cfg.html = typeof(cfg.html) != 'undefined' ?
862 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
865 if (cfg.tag !== 'a' && this.href !== '') {
866 throw "Tag must be a to set href.";
867 } else if (this.href.length > 0) {
868 cfg.href = this.href;
871 if(this.removeClass){
876 cfg.target = this.target;
881 initEvents: function() {
882 // Roo.log('init events?');
883 // Roo.log(this.el.dom);
886 if (typeof (this.menu) != 'undefined') {
887 this.menu.parentType = this.xtype;
888 this.menu.triggerEl = this.el;
889 this.addxtype(Roo.apply({}, this.menu));
893 if (this.el.hasClass('roo-button')) {
894 this.el.on('click', this.onClick, this);
896 this.el.select('.roo-button').on('click', this.onClick, this);
899 if(this.removeClass){
900 this.el.on('click', this.onClick, this);
903 this.el.enableDisplayMode();
906 onClick : function(e)
912 Roo.log('button on click ');
913 if(this.preventDefault){
917 if (this.pressed === true || this.pressed === false) {
918 this.toggleActive(e);
922 this.fireEvent('click', this, e);
926 * Enables this button
930 this.disabled = false;
931 this.el.removeClass('disabled');
935 * Disable this button
939 this.disabled = true;
940 this.el.addClass('disabled');
943 * sets the active state on/off,
944 * @param {Boolean} state (optional) Force a particular state
946 setActive : function(v) {
948 this.el[v ? 'addClass' : 'removeClass']('active');
952 * toggles the current active state
954 toggleActive : function(e)
956 this.setActive(!this.pressed);
957 this.fireEvent('toggle', this, e, !this.pressed);
960 * get the current active state
961 * @return {boolean} true if it's active
963 isActive : function()
965 return this.el.hasClass('active');
968 * set the text of the first selected button
970 setText : function(str)
972 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
975 * get the text of the first selected button
979 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
982 setWeight : function(str)
984 this.el.removeClass(this.weightClass);
986 var outline = this.outline ? 'outline-' : '';
987 if (str == 'default') {
988 this.el.addClass('btn-default btn-outline-secondary');
991 this.el.addClass('btn-' + outline + str);
1005 * @class Roo.bootstrap.Column
1006 * @extends Roo.bootstrap.Component
1007 * Bootstrap Column class
1008 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1009 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1010 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1011 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1012 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1013 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1014 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1015 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1018 * @cfg {Boolean} hidden (true|false) hide the element
1019 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1020 * @cfg {String} fa (ban|check|...) font awesome icon
1021 * @cfg {Number} fasize (1|2|....) font awsome size
1023 * @cfg {String} icon (info-sign|check|...) glyphicon name
1025 * @cfg {String} html content of column.
1028 * Create a new Column
1029 * @param {Object} config The config object
1032 Roo.bootstrap.Column = function(config){
1033 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1036 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1054 getAutoCreate : function(){
1055 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1063 ['xs','sm','md','lg'].map(function(size){
1064 //Roo.log( size + ':' + settings[size]);
1066 if (settings[size+'off'] !== false) {
1067 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1070 if (settings[size] === false) {
1074 if (!settings[size]) { // 0 = hidden
1075 cfg.cls += ' hidden-' + size;
1078 cfg.cls += ' col-' + size + '-' + settings[size];
1083 cfg.cls += ' hidden';
1086 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1087 cfg.cls +=' alert alert-' + this.alert;
1091 if (this.html.length) {
1092 cfg.html = this.html;
1096 if (this.fasize > 1) {
1097 fasize = ' fa-' + this.fasize + 'x';
1099 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1104 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1123 * @class Roo.bootstrap.Container
1124 * @extends Roo.bootstrap.Component
1125 * Bootstrap Container class
1126 * @cfg {Boolean} jumbotron is it a jumbotron element
1127 * @cfg {String} html content of element
1128 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1129 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1130 * @cfg {String} header content of header (for panel)
1131 * @cfg {String} footer content of footer (for panel)
1132 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1133 * @cfg {String} tag (header|aside|section) type of HTML tag.
1134 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1135 * @cfg {String} fa font awesome icon
1136 * @cfg {String} icon (info-sign|check|...) glyphicon name
1137 * @cfg {Boolean} hidden (true|false) hide the element
1138 * @cfg {Boolean} expandable (true|false) default false
1139 * @cfg {Boolean} expanded (true|false) default true
1140 * @cfg {String} rheader contet on the right of header
1141 * @cfg {Boolean} clickable (true|false) default false
1145 * Create a new Container
1146 * @param {Object} config The config object
1149 Roo.bootstrap.Container = function(config){
1150 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1156 * After the panel has been expand
1158 * @param {Roo.bootstrap.Container} this
1163 * After the panel has been collapsed
1165 * @param {Roo.bootstrap.Container} this
1170 * When a element is chick
1171 * @param {Roo.bootstrap.Container} this
1172 * @param {Roo.EventObject} e
1178 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1196 getChildContainer : function() {
1202 if (this.panel.length) {
1203 return this.el.select('.panel-body',true).first();
1210 getAutoCreate : function(){
1213 tag : this.tag || 'div',
1217 if (this.jumbotron) {
1218 cfg.cls = 'jumbotron';
1223 // - this is applied by the parent..
1225 // cfg.cls = this.cls + '';
1228 if (this.sticky.length) {
1230 var bd = Roo.get(document.body);
1231 if (!bd.hasClass('bootstrap-sticky')) {
1232 bd.addClass('bootstrap-sticky');
1233 Roo.select('html',true).setStyle('height', '100%');
1236 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1240 if (this.well.length) {
1241 switch (this.well) {
1244 cfg.cls +=' well well-' +this.well;
1253 cfg.cls += ' hidden';
1257 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1258 cfg.cls +=' alert alert-' + this.alert;
1263 if (this.panel.length) {
1264 cfg.cls += ' panel panel-' + this.panel;
1266 if (this.header.length) {
1270 if(this.expandable){
1272 cfg.cls = cfg.cls + ' expandable';
1276 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1284 cls : 'panel-title',
1285 html : (this.expandable ? ' ' : '') + this.header
1289 cls: 'panel-header-right',
1295 cls : 'panel-heading',
1296 style : this.expandable ? 'cursor: pointer' : '',
1304 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1309 if (this.footer.length) {
1311 cls : 'panel-footer',
1320 body.html = this.html || cfg.html;
1321 // prefix with the icons..
1323 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1326 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1331 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1332 cfg.cls = 'container';
1338 initEvents: function()
1340 if(this.expandable){
1341 var headerEl = this.headerEl();
1344 headerEl.on('click', this.onToggleClick, this);
1349 this.el.on('click', this.onClick, this);
1354 onToggleClick : function()
1356 var headerEl = this.headerEl();
1372 if(this.fireEvent('expand', this)) {
1374 this.expanded = true;
1376 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1378 this.el.select('.panel-body',true).first().removeClass('hide');
1380 var toggleEl = this.toggleEl();
1386 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1391 collapse : function()
1393 if(this.fireEvent('collapse', this)) {
1395 this.expanded = false;
1397 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1398 this.el.select('.panel-body',true).first().addClass('hide');
1400 var toggleEl = this.toggleEl();
1406 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1410 toggleEl : function()
1412 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1416 return this.el.select('.panel-heading .fa',true).first();
1419 headerEl : function()
1421 if(!this.el || !this.panel.length || !this.header.length){
1425 return this.el.select('.panel-heading',true).first()
1430 if(!this.el || !this.panel.length){
1434 return this.el.select('.panel-body',true).first()
1437 titleEl : function()
1439 if(!this.el || !this.panel.length || !this.header.length){
1443 return this.el.select('.panel-title',true).first();
1446 setTitle : function(v)
1448 var titleEl = this.titleEl();
1454 titleEl.dom.innerHTML = v;
1457 getTitle : function()
1460 var titleEl = this.titleEl();
1466 return titleEl.dom.innerHTML;
1469 setRightTitle : function(v)
1471 var t = this.el.select('.panel-header-right',true).first();
1477 t.dom.innerHTML = v;
1480 onClick : function(e)
1484 this.fireEvent('click', this, e);
1497 * @class Roo.bootstrap.Img
1498 * @extends Roo.bootstrap.Component
1499 * Bootstrap Img class
1500 * @cfg {Boolean} imgResponsive false | true
1501 * @cfg {String} border rounded | circle | thumbnail
1502 * @cfg {String} src image source
1503 * @cfg {String} alt image alternative text
1504 * @cfg {String} href a tag href
1505 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1506 * @cfg {String} xsUrl xs image source
1507 * @cfg {String} smUrl sm image source
1508 * @cfg {String} mdUrl md image source
1509 * @cfg {String} lgUrl lg image source
1512 * Create a new Input
1513 * @param {Object} config The config object
1516 Roo.bootstrap.Img = function(config){
1517 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1523 * The img click event for the img.
1524 * @param {Roo.EventObject} e
1530 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1532 imgResponsive: true,
1542 getAutoCreate : function()
1544 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1545 return this.createSingleImg();
1550 cls: 'roo-image-responsive-group',
1555 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1557 if(!_this[size + 'Url']){
1563 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1564 html: _this.html || cfg.html,
1565 src: _this[size + 'Url']
1568 img.cls += ' roo-image-responsive-' + size;
1570 var s = ['xs', 'sm', 'md', 'lg'];
1572 s.splice(s.indexOf(size), 1);
1574 Roo.each(s, function(ss){
1575 img.cls += ' hidden-' + ss;
1578 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1579 cfg.cls += ' img-' + _this.border;
1583 cfg.alt = _this.alt;
1596 a.target = _this.target;
1600 cfg.cn.push((_this.href) ? a : img);
1607 createSingleImg : function()
1611 cls: (this.imgResponsive) ? 'img-responsive' : '',
1613 src : 'about:blank' // just incase src get's set to undefined?!?
1616 cfg.html = this.html || cfg.html;
1618 cfg.src = this.src || cfg.src;
1620 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1621 cfg.cls += ' img-' + this.border;
1638 a.target = this.target;
1643 return (this.href) ? a : cfg;
1646 initEvents: function()
1649 this.el.on('click', this.onClick, this);
1654 onClick : function(e)
1656 Roo.log('img onclick');
1657 this.fireEvent('click', this, e);
1660 * Sets the url of the image - used to update it
1661 * @param {String} url the url of the image
1664 setSrc : function(url)
1668 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1669 this.el.dom.src = url;
1673 this.el.select('img', true).first().dom.src = url;
1689 * @class Roo.bootstrap.Link
1690 * @extends Roo.bootstrap.Component
1691 * Bootstrap Link Class
1692 * @cfg {String} alt image alternative text
1693 * @cfg {String} href a tag href
1694 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1695 * @cfg {String} html the content of the link.
1696 * @cfg {String} anchor name for the anchor link
1697 * @cfg {String} fa - favicon
1699 * @cfg {Boolean} preventDefault (true | false) default false
1703 * Create a new Input
1704 * @param {Object} config The config object
1707 Roo.bootstrap.Link = function(config){
1708 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1714 * The img click event for the img.
1715 * @param {Roo.EventObject} e
1721 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1725 preventDefault: false,
1731 getAutoCreate : function()
1733 var html = this.html || '';
1735 if (this.fa !== false) {
1736 html = '<i class="fa fa-' + this.fa + '"></i>';
1741 // anchor's do not require html/href...
1742 if (this.anchor === false) {
1744 cfg.href = this.href || '#';
1746 cfg.name = this.anchor;
1747 if (this.html !== false || this.fa !== false) {
1750 if (this.href !== false) {
1751 cfg.href = this.href;
1755 if(this.alt !== false){
1760 if(this.target !== false) {
1761 cfg.target = this.target;
1767 initEvents: function() {
1769 if(!this.href || this.preventDefault){
1770 this.el.on('click', this.onClick, this);
1774 onClick : function(e)
1776 if(this.preventDefault){
1779 //Roo.log('img onclick');
1780 this.fireEvent('click', this, e);
1793 * @class Roo.bootstrap.Header
1794 * @extends Roo.bootstrap.Component
1795 * Bootstrap Header class
1796 * @cfg {String} html content of header
1797 * @cfg {Number} level (1|2|3|4|5|6) default 1
1800 * Create a new Header
1801 * @param {Object} config The config object
1805 Roo.bootstrap.Header = function(config){
1806 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1809 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1817 getAutoCreate : function(){
1822 tag: 'h' + (1 *this.level),
1823 html: this.html || ''
1835 * Ext JS Library 1.1.1
1836 * Copyright(c) 2006-2007, Ext JS, LLC.
1838 * Originally Released Under LGPL - original licence link has changed is not relivant.
1841 * <script type="text/javascript">
1845 * @class Roo.bootstrap.MenuMgr
1846 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1849 Roo.bootstrap.MenuMgr = function(){
1850 var menus, active, groups = {}, attached = false, lastShow = new Date();
1852 // private - called when first menu is created
1855 active = new Roo.util.MixedCollection();
1856 Roo.get(document).addKeyListener(27, function(){
1857 if(active.length > 0){
1865 if(active && active.length > 0){
1866 var c = active.clone();
1876 if(active.length < 1){
1877 Roo.get(document).un("mouseup", onMouseDown);
1885 var last = active.last();
1886 lastShow = new Date();
1889 Roo.get(document).on("mouseup", onMouseDown);
1894 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1895 m.parentMenu.activeChild = m;
1896 }else if(last && last.isVisible()){
1897 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1902 function onBeforeHide(m){
1904 m.activeChild.hide();
1906 if(m.autoHideTimer){
1907 clearTimeout(m.autoHideTimer);
1908 delete m.autoHideTimer;
1913 function onBeforeShow(m){
1914 var pm = m.parentMenu;
1915 if(!pm && !m.allowOtherMenus){
1917 }else if(pm && pm.activeChild && active != m){
1918 pm.activeChild.hide();
1922 // private this should really trigger on mouseup..
1923 function onMouseDown(e){
1924 Roo.log("on Mouse Up");
1926 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1927 Roo.log("MenuManager hideAll");
1936 function onBeforeCheck(mi, state){
1938 var g = groups[mi.group];
1939 for(var i = 0, l = g.length; i < l; i++){
1941 g[i].setChecked(false);
1950 * Hides all menus that are currently visible
1952 hideAll : function(){
1957 register : function(menu){
1961 menus[menu.id] = menu;
1962 menu.on("beforehide", onBeforeHide);
1963 menu.on("hide", onHide);
1964 menu.on("beforeshow", onBeforeShow);
1965 menu.on("show", onShow);
1967 if(g && menu.events["checkchange"]){
1971 groups[g].push(menu);
1972 menu.on("checkchange", onCheck);
1977 * Returns a {@link Roo.menu.Menu} object
1978 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1979 * be used to generate and return a new Menu instance.
1981 get : function(menu){
1982 if(typeof menu == "string"){ // menu id
1984 }else if(menu.events){ // menu instance
1987 /*else if(typeof menu.length == 'number'){ // array of menu items?
1988 return new Roo.bootstrap.Menu({items:menu});
1989 }else{ // otherwise, must be a config
1990 return new Roo.bootstrap.Menu(menu);
1997 unregister : function(menu){
1998 delete menus[menu.id];
1999 menu.un("beforehide", onBeforeHide);
2000 menu.un("hide", onHide);
2001 menu.un("beforeshow", onBeforeShow);
2002 menu.un("show", onShow);
2004 if(g && menu.events["checkchange"]){
2005 groups[g].remove(menu);
2006 menu.un("checkchange", onCheck);
2011 registerCheckable : function(menuItem){
2012 var g = menuItem.group;
2017 groups[g].push(menuItem);
2018 menuItem.on("beforecheckchange", onBeforeCheck);
2023 unregisterCheckable : function(menuItem){
2024 var g = menuItem.group;
2026 groups[g].remove(menuItem);
2027 menuItem.un("beforecheckchange", onBeforeCheck);
2039 * @class Roo.bootstrap.Menu
2040 * @extends Roo.bootstrap.Component
2041 * Bootstrap Menu class - container for MenuItems
2042 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2043 * @cfg {bool} hidden if the menu should be hidden when rendered.
2044 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2045 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2049 * @param {Object} config The config object
2053 Roo.bootstrap.Menu = function(config){
2054 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2055 if (this.registerMenu && this.type != 'treeview') {
2056 Roo.bootstrap.MenuMgr.register(this);
2063 * Fires before this menu is displayed (return false to block)
2064 * @param {Roo.menu.Menu} this
2069 * Fires before this menu is hidden (return false to block)
2070 * @param {Roo.menu.Menu} this
2075 * Fires after this menu is displayed
2076 * @param {Roo.menu.Menu} this
2081 * Fires after this menu is hidden
2082 * @param {Roo.menu.Menu} this
2087 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2088 * @param {Roo.menu.Menu} this
2089 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2090 * @param {Roo.EventObject} e
2095 * Fires when the mouse is hovering over this menu
2096 * @param {Roo.menu.Menu} this
2097 * @param {Roo.EventObject} e
2098 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2103 * Fires when the mouse exits this menu
2104 * @param {Roo.menu.Menu} this
2105 * @param {Roo.EventObject} e
2106 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2111 * Fires when a menu item contained in this menu is clicked
2112 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2113 * @param {Roo.EventObject} e
2117 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2120 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2124 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2127 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2129 registerMenu : true,
2131 menuItems :false, // stores the menu items..
2141 getChildContainer : function() {
2145 getAutoCreate : function(){
2147 //if (['right'].indexOf(this.align)!==-1) {
2148 // cfg.cn[1].cls += ' pull-right'
2154 cls : 'dropdown-menu' ,
2155 style : 'z-index:1000'
2159 if (this.type === 'submenu') {
2160 cfg.cls = 'submenu active';
2162 if (this.type === 'treeview') {
2163 cfg.cls = 'treeview-menu';
2168 initEvents : function() {
2170 // Roo.log("ADD event");
2171 // Roo.log(this.triggerEl.dom);
2173 this.triggerEl.on('click', this.onTriggerClick, this);
2175 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2178 if (this.triggerEl.hasClass('nav-item')) {
2179 // dropdown toggle on the 'a' in BS4?
2180 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2182 this.triggerEl.addClass('dropdown-toggle');
2185 this.el.on('touchstart' , this.onTouch, this);
2187 this.el.on('click' , this.onClick, this);
2189 this.el.on("mouseover", this.onMouseOver, this);
2190 this.el.on("mouseout", this.onMouseOut, this);
2194 findTargetItem : function(e)
2196 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2200 //Roo.log(t); Roo.log(t.id);
2202 //Roo.log(this.menuitems);
2203 return this.menuitems.get(t.id);
2205 //return this.items.get(t.menuItemId);
2211 onTouch : function(e)
2213 Roo.log("menu.onTouch");
2214 //e.stopEvent(); this make the user popdown broken
2218 onClick : function(e)
2220 Roo.log("menu.onClick");
2222 var t = this.findTargetItem(e);
2223 if(!t || t.isContainer){
2228 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2229 if(t == this.activeItem && t.shouldDeactivate(e)){
2230 this.activeItem.deactivate();
2231 delete this.activeItem;
2235 this.setActiveItem(t, true);
2243 Roo.log('pass click event');
2247 this.fireEvent("click", this, t, e);
2251 if(!t.href.length || t.href == '#'){
2252 (function() { _this.hide(); }).defer(100);
2257 onMouseOver : function(e){
2258 var t = this.findTargetItem(e);
2261 // if(t.canActivate && !t.disabled){
2262 // this.setActiveItem(t, true);
2266 this.fireEvent("mouseover", this, e, t);
2268 isVisible : function(){
2269 return !this.hidden;
2271 onMouseOut : function(e){
2272 var t = this.findTargetItem(e);
2275 // if(t == this.activeItem && t.shouldDeactivate(e)){
2276 // this.activeItem.deactivate();
2277 // delete this.activeItem;
2280 this.fireEvent("mouseout", this, e, t);
2285 * Displays this menu relative to another element
2286 * @param {String/HTMLElement/Roo.Element} element The element to align to
2287 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2288 * the element (defaults to this.defaultAlign)
2289 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2291 show : function(el, pos, parentMenu)
2293 if (false === this.fireEvent("beforeshow", this)) {
2294 Roo.log("show canceled");
2297 this.parentMenu = parentMenu;
2302 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2305 * Displays this menu at a specific xy position
2306 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2307 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2309 showAt : function(xy, parentMenu, /* private: */_e){
2310 this.parentMenu = parentMenu;
2315 this.fireEvent("beforeshow", this);
2316 //xy = this.el.adjustForConstraints(xy);
2320 this.hideMenuItems();
2321 this.hidden = false;
2322 this.triggerEl.addClass('open');
2323 this.el.addClass('show');
2325 // reassign x when hitting right
2326 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2327 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2330 // reassign y when hitting bottom
2331 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2332 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2335 // but the list may align on trigger left or trigger top... should it be a properity?
2337 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2342 this.fireEvent("show", this);
2348 this.doFocus.defer(50, this);
2352 doFocus : function(){
2354 this.focusEl.focus();
2359 * Hides this menu and optionally all parent menus
2360 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2362 hide : function(deep)
2364 if (false === this.fireEvent("beforehide", this)) {
2365 Roo.log("hide canceled");
2368 this.hideMenuItems();
2369 if(this.el && this.isVisible()){
2371 if(this.activeItem){
2372 this.activeItem.deactivate();
2373 this.activeItem = null;
2375 this.triggerEl.removeClass('open');;
2376 this.el.removeClass('show');
2378 this.fireEvent("hide", this);
2380 if(deep === true && this.parentMenu){
2381 this.parentMenu.hide(true);
2385 onTriggerClick : function(e)
2387 Roo.log('trigger click');
2389 var target = e.getTarget();
2391 Roo.log(target.nodeName.toLowerCase());
2393 if(target.nodeName.toLowerCase() === 'i'){
2399 onTriggerPress : function(e)
2401 Roo.log('trigger press');
2402 //Roo.log(e.getTarget());
2403 // Roo.log(this.triggerEl.dom);
2405 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2406 var pel = Roo.get(e.getTarget());
2407 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2408 Roo.log('is treeview or dropdown?');
2412 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2416 if (this.isVisible()) {
2421 this.show(this.triggerEl, '?', false);
2424 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2431 hideMenuItems : function()
2433 Roo.log("hide Menu Items");
2438 this.el.select('.open',true).each(function(aa) {
2440 aa.removeClass('open');
2444 addxtypeChild : function (tree, cntr) {
2445 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2447 this.menuitems.add(comp);
2459 this.getEl().dom.innerHTML = '';
2460 this.menuitems.clear();
2474 * @class Roo.bootstrap.MenuItem
2475 * @extends Roo.bootstrap.Component
2476 * Bootstrap MenuItem class
2477 * @cfg {String} html the menu label
2478 * @cfg {String} href the link
2479 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2480 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2481 * @cfg {Boolean} active used on sidebars to highlight active itesm
2482 * @cfg {String} fa favicon to show on left of menu item.
2483 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2487 * Create a new MenuItem
2488 * @param {Object} config The config object
2492 Roo.bootstrap.MenuItem = function(config){
2493 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2498 * The raw click event for the entire grid.
2499 * @param {Roo.bootstrap.MenuItem} this
2500 * @param {Roo.EventObject} e
2506 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2510 preventDefault: false,
2511 isContainer : false,
2515 getAutoCreate : function(){
2517 if(this.isContainer){
2520 cls: 'dropdown-menu-item '
2530 cls : 'dropdown-item',
2535 if (this.fa !== false) {
2538 cls : 'fa fa-' + this.fa
2547 cls: 'dropdown-menu-item',
2550 if (this.parent().type == 'treeview') {
2551 cfg.cls = 'treeview-menu';
2554 cfg.cls += ' active';
2559 anc.href = this.href || cfg.cn[0].href ;
2560 ctag.html = this.html || cfg.cn[0].html ;
2564 initEvents: function()
2566 if (this.parent().type == 'treeview') {
2567 this.el.select('a').on('click', this.onClick, this);
2571 this.menu.parentType = this.xtype;
2572 this.menu.triggerEl = this.el;
2573 this.menu = this.addxtype(Roo.apply({}, this.menu));
2577 onClick : function(e)
2579 Roo.log('item on click ');
2581 if(this.preventDefault){
2584 //this.parent().hideMenuItems();
2586 this.fireEvent('click', this, e);
2605 * @class Roo.bootstrap.MenuSeparator
2606 * @extends Roo.bootstrap.Component
2607 * Bootstrap MenuSeparator class
2610 * Create a new MenuItem
2611 * @param {Object} config The config object
2615 Roo.bootstrap.MenuSeparator = function(config){
2616 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2619 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2621 getAutoCreate : function(){
2640 * @class Roo.bootstrap.Modal
2641 * @extends Roo.bootstrap.Component
2642 * Bootstrap Modal class
2643 * @cfg {String} title Title of dialog
2644 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2645 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2646 * @cfg {Boolean} specificTitle default false
2647 * @cfg {Array} buttons Array of buttons or standard button set..
2648 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2649 * @cfg {Boolean} animate default true
2650 * @cfg {Boolean} allow_close default true
2651 * @cfg {Boolean} fitwindow default false
2652 * @cfg {String} size (sm|lg) default empty
2653 * @cfg {Number} max_width set the max width of modal
2657 * Create a new Modal Dialog
2658 * @param {Object} config The config object
2661 Roo.bootstrap.Modal = function(config){
2662 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2667 * The raw btnclick event for the button
2668 * @param {Roo.EventObject} e
2673 * Fire when dialog resize
2674 * @param {Roo.bootstrap.Modal} this
2675 * @param {Roo.EventObject} e
2679 this.buttons = this.buttons || [];
2682 this.tmpl = Roo.factory(this.tmpl);
2687 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2689 title : 'test dialog',
2699 specificTitle: false,
2701 buttonPosition: 'right',
2724 onRender : function(ct, position)
2726 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2729 var cfg = Roo.apply({}, this.getAutoCreate());
2732 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2734 //if (!cfg.name.length) {
2738 cfg.cls += ' ' + this.cls;
2741 cfg.style = this.style;
2743 this.el = Roo.get(document.body).createChild(cfg, position);
2745 //var type = this.el.dom.type;
2748 if(this.tabIndex !== undefined){
2749 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2752 this.dialogEl = this.el.select('.modal-dialog',true).first();
2753 this.bodyEl = this.el.select('.modal-body',true).first();
2754 this.closeEl = this.el.select('.modal-header .close', true).first();
2755 this.headerEl = this.el.select('.modal-header',true).first();
2756 this.titleEl = this.el.select('.modal-title',true).first();
2757 this.footerEl = this.el.select('.modal-footer',true).first();
2759 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2761 //this.el.addClass("x-dlg-modal");
2763 if (this.buttons.length) {
2764 Roo.each(this.buttons, function(bb) {
2765 var b = Roo.apply({}, bb);
2766 b.xns = b.xns || Roo.bootstrap;
2767 b.xtype = b.xtype || 'Button';
2768 if (typeof(b.listeners) == 'undefined') {
2769 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2772 var btn = Roo.factory(b);
2774 btn.render(this.getButtonContainer());
2778 // render the children.
2781 if(typeof(this.items) != 'undefined'){
2782 var items = this.items;
2785 for(var i =0;i < items.length;i++) {
2786 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2790 this.items = nitems;
2792 // where are these used - they used to be body/close/footer
2796 //this.el.addClass([this.fieldClass, this.cls]);
2800 getAutoCreate : function()
2804 html : this.html || ''
2809 cls : 'modal-title',
2813 if(this.specificTitle){
2819 if (this.allow_close && Roo.bootstrap.version == 3) {
2829 if (this.allow_close && Roo.bootstrap.version == 4) {
2839 if(this.size.length){
2840 size = 'modal-' + this.size;
2843 var footer = Roo.bootstrap.version == 3 ?
2845 cls : 'modal-footer',
2849 cls: 'btn-' + this.buttonPosition
2854 { // BS4 uses mr-auto on left buttons....
2855 cls : 'modal-footer'
2866 cls: "modal-dialog " + size,
2869 cls : "modal-content",
2872 cls : 'modal-header',
2887 modal.cls += ' fade';
2893 getChildContainer : function() {
2898 getButtonContainer : function() {
2900 return Roo.bootstrap.version == 4 ?
2901 this.el.select('.modal-footer',true).first()
2902 : this.el.select('.modal-footer div',true).first();
2905 initEvents : function()
2907 if (this.allow_close) {
2908 this.closeEl.on('click', this.hide, this);
2910 Roo.EventManager.onWindowResize(this.resize, this, true);
2918 this.maskEl.setSize(
2919 Roo.lib.Dom.getViewWidth(true),
2920 Roo.lib.Dom.getViewHeight(true)
2923 if (this.fitwindow) {
2927 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2928 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2933 if(this.max_width !== 0) {
2935 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2938 this.setSize(w, this.height);
2942 if(this.max_height) {
2943 this.setSize(w,Math.min(
2945 Roo.lib.Dom.getViewportHeight(true) - 60
2951 if(!this.fit_content) {
2952 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2956 this.setSize(w, Math.min(
2958 this.headerEl.getHeight() +
2959 this.footerEl.getHeight() +
2960 this.getChildHeight(this.bodyEl.dom.childNodes),
2961 Roo.lib.Dom.getViewportHeight(true) - 60)
2967 setSize : function(w,h)
2978 if (!this.rendered) {
2982 //this.el.setStyle('display', 'block');
2983 this.el.removeClass('hideing');
2984 this.el.dom.style.display='block';
2986 Roo.get(document.body).addClass('modal-open');
2988 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2991 this.el.addClass('show');
2992 this.el.addClass('in');
2995 this.el.addClass('show');
2996 this.el.addClass('in');
2999 // not sure how we can show data in here..
3001 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3004 Roo.get(document.body).addClass("x-body-masked");
3006 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3007 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3008 this.maskEl.dom.style.display = 'block';
3009 this.maskEl.addClass('show');
3014 this.fireEvent('show', this);
3016 // set zindex here - otherwise it appears to be ignored...
3017 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3020 this.items.forEach( function(e) {
3021 e.layout ? e.layout() : false;
3029 if(this.fireEvent("beforehide", this) !== false){
3031 this.maskEl.removeClass('show');
3033 this.maskEl.dom.style.display = '';
3034 Roo.get(document.body).removeClass("x-body-masked");
3035 this.el.removeClass('in');
3036 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3038 if(this.animate){ // why
3039 this.el.addClass('hideing');
3040 this.el.removeClass('show');
3042 if (!this.el.hasClass('hideing')) {
3043 return; // it's been shown again...
3046 this.el.dom.style.display='';
3048 Roo.get(document.body).removeClass('modal-open');
3049 this.el.removeClass('hideing');
3053 this.el.removeClass('show');
3054 this.el.dom.style.display='';
3055 Roo.get(document.body).removeClass('modal-open');
3058 this.fireEvent('hide', this);
3061 isVisible : function()
3064 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3068 addButton : function(str, cb)
3072 var b = Roo.apply({}, { html : str } );
3073 b.xns = b.xns || Roo.bootstrap;
3074 b.xtype = b.xtype || 'Button';
3075 if (typeof(b.listeners) == 'undefined') {
3076 b.listeners = { click : cb.createDelegate(this) };
3079 var btn = Roo.factory(b);
3081 btn.render(this.getButtonContainer());
3087 setDefaultButton : function(btn)
3089 //this.el.select('.modal-footer').()
3092 resizeTo: function(w,h)
3094 this.dialogEl.setWidth(w);
3096 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3098 this.bodyEl.setHeight(h - diff);
3100 this.fireEvent('resize', this);
3103 setContentSize : function(w, h)
3107 onButtonClick: function(btn,e)
3110 this.fireEvent('btnclick', btn.name, e);
3113 * Set the title of the Dialog
3114 * @param {String} str new Title
3116 setTitle: function(str) {
3117 this.titleEl.dom.innerHTML = str;
3120 * Set the body of the Dialog
3121 * @param {String} str new Title
3123 setBody: function(str) {
3124 this.bodyEl.dom.innerHTML = str;
3127 * Set the body of the Dialog using the template
3128 * @param {Obj} data - apply this data to the template and replace the body contents.
3130 applyBody: function(obj)
3133 Roo.log("Error - using apply Body without a template");
3136 this.tmpl.overwrite(this.bodyEl, obj);
3139 getChildHeight : function(child_nodes)
3143 child_nodes.length == 0
3148 var child_height = 0;
3150 for(var i = 0; i < child_nodes.length; i++) {
3153 * for modal with tabs...
3154 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3156 var layout_childs = child_nodes[i].childNodes;
3158 for(var j = 0; j < layout_childs.length; j++) {
3160 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3162 var layout_body_childs = layout_childs[j].childNodes;
3164 for(var k = 0; k < layout_body_childs.length; k++) {
3166 if(layout_body_childs[k].classList.contains('navbar')) {
3167 child_height += layout_body_childs[k].offsetHeight;
3171 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3173 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3175 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3177 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3178 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3193 child_height += child_nodes[i].offsetHeight;
3194 // Roo.log(child_nodes[i].offsetHeight);
3197 return child_height;
3203 Roo.apply(Roo.bootstrap.Modal, {
3205 * Button config that displays a single OK button
3214 * Button config that displays Yes and No buttons
3230 * Button config that displays OK and Cancel buttons
3245 * Button config that displays Yes, No and Cancel buttons
3269 * messagebox - can be used as a replace
3273 * @class Roo.MessageBox
3274 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3278 Roo.Msg.alert('Status', 'Changes saved successfully.');
3280 // Prompt for user data:
3281 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3283 // process text value...
3287 // Show a dialog using config options:
3289 title:'Save Changes?',
3290 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3291 buttons: Roo.Msg.YESNOCANCEL,
3298 Roo.bootstrap.MessageBox = function(){
3299 var dlg, opt, mask, waitTimer;
3300 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3301 var buttons, activeTextEl, bwidth;
3305 var handleButton = function(button){
3307 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3311 var handleHide = function(){
3313 dlg.el.removeClass(opt.cls);
3316 // Roo.TaskMgr.stop(waitTimer);
3317 // waitTimer = null;
3322 var updateButtons = function(b){
3325 buttons["ok"].hide();
3326 buttons["cancel"].hide();
3327 buttons["yes"].hide();
3328 buttons["no"].hide();
3329 dlg.footerEl.hide();
3333 dlg.footerEl.show();
3334 for(var k in buttons){
3335 if(typeof buttons[k] != "function"){
3338 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3339 width += buttons[k].el.getWidth()+15;
3349 var handleEsc = function(d, k, e){
3350 if(opt && opt.closable !== false){
3360 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3361 * @return {Roo.BasicDialog} The BasicDialog element
3363 getDialog : function(){
3365 dlg = new Roo.bootstrap.Modal( {
3368 //constraintoviewport:false,
3370 //collapsible : false,
3375 //buttonAlign:"center",
3376 closeClick : function(){
3377 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3380 handleButton("cancel");
3385 dlg.on("hide", handleHide);
3387 //dlg.addKeyListener(27, handleEsc);
3389 this.buttons = buttons;
3390 var bt = this.buttonText;
3391 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3392 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3393 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3394 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3396 bodyEl = dlg.bodyEl.createChild({
3398 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3399 '<textarea class="roo-mb-textarea"></textarea>' +
3400 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3402 msgEl = bodyEl.dom.firstChild;
3403 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3404 textboxEl.enableDisplayMode();
3405 textboxEl.addKeyListener([10,13], function(){
3406 if(dlg.isVisible() && opt && opt.buttons){
3409 }else if(opt.buttons.yes){
3410 handleButton("yes");
3414 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3415 textareaEl.enableDisplayMode();
3416 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3417 progressEl.enableDisplayMode();
3419 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3420 var pf = progressEl.dom.firstChild;
3422 pp = Roo.get(pf.firstChild);
3423 pp.setHeight(pf.offsetHeight);
3431 * Updates the message box body text
3432 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3433 * the XHTML-compliant non-breaking space character '&#160;')
3434 * @return {Roo.MessageBox} This message box
3436 updateText : function(text)
3438 if(!dlg.isVisible() && !opt.width){
3439 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3440 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3442 msgEl.innerHTML = text || ' ';
3444 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3445 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3447 Math.min(opt.width || cw , this.maxWidth),
3448 Math.max(opt.minWidth || this.minWidth, bwidth)
3451 activeTextEl.setWidth(w);
3453 if(dlg.isVisible()){
3454 dlg.fixedcenter = false;
3456 // to big, make it scroll. = But as usual stupid IE does not support
3459 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3460 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3461 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3463 bodyEl.dom.style.height = '';
3464 bodyEl.dom.style.overflowY = '';
3467 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3469 bodyEl.dom.style.overflowX = '';
3472 dlg.setContentSize(w, bodyEl.getHeight());
3473 if(dlg.isVisible()){
3474 dlg.fixedcenter = true;
3480 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3481 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3482 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3483 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3484 * @return {Roo.MessageBox} This message box
3486 updateProgress : function(value, text){
3488 this.updateText(text);
3491 if (pp) { // weird bug on my firefox - for some reason this is not defined
3492 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3493 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3499 * Returns true if the message box is currently displayed
3500 * @return {Boolean} True if the message box is visible, else false
3502 isVisible : function(){
3503 return dlg && dlg.isVisible();
3507 * Hides the message box if it is displayed
3510 if(this.isVisible()){
3516 * Displays a new message box, or reinitializes an existing message box, based on the config options
3517 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3518 * The following config object properties are supported:
3520 Property Type Description
3521 ---------- --------------- ------------------------------------------------------------------------------------
3522 animEl String/Element An id or Element from which the message box should animate as it opens and
3523 closes (defaults to undefined)
3524 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3525 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3526 closable Boolean False to hide the top-right close button (defaults to true). Note that
3527 progress and wait dialogs will ignore this property and always hide the
3528 close button as they can only be closed programmatically.
3529 cls String A custom CSS class to apply to the message box element
3530 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3531 displayed (defaults to 75)
3532 fn Function A callback function to execute after closing the dialog. The arguments to the
3533 function will be btn (the name of the button that was clicked, if applicable,
3534 e.g. "ok"), and text (the value of the active text field, if applicable).
3535 Progress and wait dialogs will ignore this option since they do not respond to
3536 user actions and can only be closed programmatically, so any required function
3537 should be called by the same code after it closes the dialog.
3538 icon String A CSS class that provides a background image to be used as an icon for
3539 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3540 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3541 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3542 modal Boolean False to allow user interaction with the page while the message box is
3543 displayed (defaults to true)
3544 msg String A string that will replace the existing message box body text (defaults
3545 to the XHTML-compliant non-breaking space character ' ')
3546 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3547 progress Boolean True to display a progress bar (defaults to false)
3548 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3549 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3550 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3551 title String The title text
3552 value String The string value to set into the active textbox element if displayed
3553 wait Boolean True to display a progress bar (defaults to false)
3554 width Number The width of the dialog in pixels
3561 msg: 'Please enter your address:',
3563 buttons: Roo.MessageBox.OKCANCEL,
3566 animEl: 'addAddressBtn'
3569 * @param {Object} config Configuration options
3570 * @return {Roo.MessageBox} This message box
3572 show : function(options)
3575 // this causes nightmares if you show one dialog after another
3576 // especially on callbacks..
3578 if(this.isVisible()){
3581 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3582 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3583 Roo.log("New Dialog Message:" + options.msg )
3584 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3585 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3588 var d = this.getDialog();
3590 d.setTitle(opt.title || " ");
3591 d.closeEl.setDisplayed(opt.closable !== false);
3592 activeTextEl = textboxEl;
3593 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3598 textareaEl.setHeight(typeof opt.multiline == "number" ?
3599 opt.multiline : this.defaultTextHeight);
3600 activeTextEl = textareaEl;
3609 progressEl.setDisplayed(opt.progress === true);
3611 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3613 this.updateProgress(0);
3614 activeTextEl.dom.value = opt.value || "";
3616 dlg.setDefaultButton(activeTextEl);
3618 var bs = opt.buttons;
3622 }else if(bs && bs.yes){
3623 db = buttons["yes"];
3625 dlg.setDefaultButton(db);
3627 bwidth = updateButtons(opt.buttons);
3628 this.updateText(opt.msg);
3630 d.el.addClass(opt.cls);
3632 d.proxyDrag = opt.proxyDrag === true;
3633 d.modal = opt.modal !== false;
3634 d.mask = opt.modal !== false ? mask : false;
3636 // force it to the end of the z-index stack so it gets a cursor in FF
3637 document.body.appendChild(dlg.el.dom);
3638 d.animateTarget = null;
3639 d.show(options.animEl);
3645 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3646 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3647 * and closing the message box when the process is complete.
3648 * @param {String} title The title bar text
3649 * @param {String} msg The message box body text
3650 * @return {Roo.MessageBox} This message box
3652 progress : function(title, msg){
3659 minWidth: this.minProgressWidth,
3666 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3667 * If a callback function is passed it will be called after the user clicks the button, and the
3668 * id of the button that was clicked will be passed as the only parameter to the callback
3669 * (could also be the top-right close button).
3670 * @param {String} title The title bar text
3671 * @param {String} msg The message box body text
3672 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3673 * @param {Object} scope (optional) The scope of the callback function
3674 * @return {Roo.MessageBox} This message box
3676 alert : function(title, msg, fn, scope)
3691 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3692 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3693 * You are responsible for closing the message box when the process is complete.
3694 * @param {String} msg The message box body text
3695 * @param {String} title (optional) The title bar text
3696 * @return {Roo.MessageBox} This message box
3698 wait : function(msg, title){
3709 waitTimer = Roo.TaskMgr.start({
3711 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3719 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3720 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3721 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3722 * @param {String} title The title bar text
3723 * @param {String} msg The message box body text
3724 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3725 * @param {Object} scope (optional) The scope of the callback function
3726 * @return {Roo.MessageBox} This message box
3728 confirm : function(title, msg, fn, scope){
3732 buttons: this.YESNO,
3741 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3742 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3743 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3744 * (could also be the top-right close button) and the text that was entered will be passed as the two
3745 * parameters to the callback.
3746 * @param {String} title The title bar text
3747 * @param {String} msg The message box body text
3748 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3749 * @param {Object} scope (optional) The scope of the callback function
3750 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3751 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3752 * @return {Roo.MessageBox} This message box
3754 prompt : function(title, msg, fn, scope, multiline){
3758 buttons: this.OKCANCEL,
3763 multiline: multiline,
3770 * Button config that displays a single OK button
3775 * Button config that displays Yes and No buttons
3778 YESNO : {yes:true, no:true},
3780 * Button config that displays OK and Cancel buttons
3783 OKCANCEL : {ok:true, cancel:true},
3785 * Button config that displays Yes, No and Cancel buttons
3788 YESNOCANCEL : {yes:true, no:true, cancel:true},
3791 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3794 defaultTextHeight : 75,
3796 * The maximum width in pixels of the message box (defaults to 600)
3801 * The minimum width in pixels of the message box (defaults to 100)
3806 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3807 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3810 minProgressWidth : 250,
3812 * An object containing the default button text strings that can be overriden for localized language support.
3813 * Supported properties are: ok, cancel, yes and no.
3814 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3827 * Shorthand for {@link Roo.MessageBox}
3829 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3830 Roo.Msg = Roo.Msg || Roo.MessageBox;
3839 * @class Roo.bootstrap.Navbar
3840 * @extends Roo.bootstrap.Component
3841 * Bootstrap Navbar class
3844 * Create a new Navbar
3845 * @param {Object} config The config object
3849 Roo.bootstrap.Navbar = function(config){
3850 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3854 * @event beforetoggle
3855 * Fire before toggle the menu
3856 * @param {Roo.EventObject} e
3858 "beforetoggle" : true
3862 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3871 getAutoCreate : function(){
3874 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3878 initEvents :function ()
3880 //Roo.log(this.el.select('.navbar-toggle',true));
3881 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
3888 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3890 var size = this.el.getSize();
3891 this.maskEl.setSize(size.width, size.height);
3892 this.maskEl.enableDisplayMode("block");
3901 getChildContainer : function()
3903 if (this.el && this.el.select('.collapse').getCount()) {
3904 return this.el.select('.collapse',true).first();
3919 onToggle : function()
3922 if(this.fireEvent('beforetoggle', this) === false){
3925 var ce = this.el.select('.navbar-collapse',true).first();
3927 if (!ce.hasClass('show')) {
3937 * Expand the navbar pulldown
3939 expand : function ()
3942 var ce = this.el.select('.navbar-collapse',true).first();
3943 if (ce.hasClass('collapsing')) {
3946 ce.dom.style.height = '';
3948 ce.addClass('in'); // old...
3949 ce.removeClass('collapse');
3950 ce.addClass('show');
3951 var h = ce.getHeight();
3953 ce.removeClass('show');
3954 // at this point we should be able to see it..
3955 ce.addClass('collapsing');
3957 ce.setHeight(0); // resize it ...
3958 ce.on('transitionend', function() {
3959 //Roo.log('done transition');
3960 ce.removeClass('collapsing');
3961 ce.addClass('show');
3962 ce.removeClass('collapse');
3964 ce.dom.style.height = '';
3965 }, this, { single: true} );
3967 ce.dom.scrollTop = 0;
3970 * Collapse the navbar pulldown
3972 collapse : function()
3974 var ce = this.el.select('.navbar-collapse',true).first();
3976 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
3977 // it's collapsed or collapsing..
3980 ce.removeClass('in'); // old...
3981 ce.setHeight(ce.getHeight());
3982 ce.removeClass('show');
3983 ce.addClass('collapsing');
3985 ce.on('transitionend', function() {
3986 ce.dom.style.height = '';
3987 ce.removeClass('collapsing');
3988 ce.addClass('collapse');
3989 }, this, { single: true} );
4009 * @class Roo.bootstrap.NavSimplebar
4010 * @extends Roo.bootstrap.Navbar
4011 * Bootstrap Sidebar class
4013 * @cfg {Boolean} inverse is inverted color
4015 * @cfg {String} type (nav | pills | tabs)
4016 * @cfg {Boolean} arrangement stacked | justified
4017 * @cfg {String} align (left | right) alignment
4019 * @cfg {Boolean} main (true|false) main nav bar? default false
4020 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
4022 * @cfg {String} tag (header|footer|nav|div) default is nav
4024 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
4028 * Create a new Sidebar
4029 * @param {Object} config The config object
4033 Roo.bootstrap.NavSimplebar = function(config){
4034 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4037 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4053 getAutoCreate : function(){
4057 tag : this.tag || 'div',
4058 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4060 if (['light','white'].indexOf(this.weight) > -1) {
4061 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4063 cfg.cls += ' bg-' + this.weight;
4066 cfg.cls += ' navbar-inverse';
4070 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4072 //if (Roo.bootstrap.version == 4) {
4084 this.type = this.type || 'nav';
4085 if (['tabs','pills'].indexOf(this.type) != -1) {
4086 cfg.cn[0].cls += ' nav-' + this.type
4090 if (this.type!=='nav') {
4091 Roo.log('nav type must be nav/tabs/pills')
4093 cfg.cn[0].cls += ' navbar-nav'
4099 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4100 cfg.cn[0].cls += ' nav-' + this.arrangement;
4104 if (this.align === 'right') {
4105 cfg.cn[0].cls += ' navbar-right';
4130 * navbar-expand-md fixed-top
4134 * @class Roo.bootstrap.NavHeaderbar
4135 * @extends Roo.bootstrap.NavSimplebar
4136 * Bootstrap Sidebar class
4138 * @cfg {String} brand what is brand
4139 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4140 * @cfg {String} brand_href href of the brand
4141 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4142 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4143 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4144 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4147 * Create a new Sidebar
4148 * @param {Object} config The config object
4152 Roo.bootstrap.NavHeaderbar = function(config){
4153 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4157 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4164 desktopCenter : false,
4167 getAutoCreate : function(){
4170 tag: this.nav || 'nav',
4171 cls: 'navbar navbar-expand-md',
4177 if (this.desktopCenter) {
4178 cn.push({cls : 'container', cn : []});
4186 cls: 'navbar-toggle navbar-toggler',
4187 'data-toggle': 'collapse',
4192 html: 'Toggle navigation'
4196 cls: 'icon-bar navbar-toggler-icon'
4209 cn.push( Roo.bootstrap.version == 4 ? btn : {
4211 cls: 'navbar-header',
4220 cls: 'collapse navbar-collapse',
4224 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4226 if (['light','white'].indexOf(this.weight) > -1) {
4227 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4229 cfg.cls += ' bg-' + this.weight;
4232 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4233 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4235 // tag can override this..
4237 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4240 if (this.brand !== '') {
4241 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4242 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4244 href: this.brand_href ? this.brand_href : '#',
4245 cls: 'navbar-brand',
4253 cfg.cls += ' main-nav';
4261 getHeaderChildContainer : function()
4263 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4264 return this.el.select('.navbar-header',true).first();
4267 return this.getChildContainer();
4271 initEvents : function()
4273 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4275 if (this.autohide) {
4280 Roo.get(document).on('scroll',function(e) {
4281 var ns = Roo.get(document).getScroll().top;
4282 var os = prevScroll;
4286 ft.removeClass('slideDown');
4287 ft.addClass('slideUp');
4290 ft.removeClass('slideUp');
4291 ft.addClass('slideDown');
4312 * @class Roo.bootstrap.NavSidebar
4313 * @extends Roo.bootstrap.Navbar
4314 * Bootstrap Sidebar class
4317 * Create a new Sidebar
4318 * @param {Object} config The config object
4322 Roo.bootstrap.NavSidebar = function(config){
4323 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4326 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4328 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4330 getAutoCreate : function(){
4335 cls: 'sidebar sidebar-nav'
4357 * @class Roo.bootstrap.NavGroup
4358 * @extends Roo.bootstrap.Component
4359 * Bootstrap NavGroup class
4360 * @cfg {String} align (left|right)
4361 * @cfg {Boolean} inverse
4362 * @cfg {String} type (nav|pills|tab) default nav
4363 * @cfg {String} navId - reference Id for navbar.
4367 * Create a new nav group
4368 * @param {Object} config The config object
4371 Roo.bootstrap.NavGroup = function(config){
4372 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4375 Roo.bootstrap.NavGroup.register(this);
4379 * Fires when the active item changes
4380 * @param {Roo.bootstrap.NavGroup} this
4381 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4382 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4389 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4400 getAutoCreate : function()
4402 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4408 if (Roo.bootstrap.version == 4) {
4409 if (['tabs','pills'].indexOf(this.type) != -1) {
4410 cfg.cls += ' nav-' + this.type;
4412 cfg.cls += ' navbar-nav';
4415 if (['tabs','pills'].indexOf(this.type) != -1) {
4416 cfg.cls += ' nav-' + this.type
4418 if (this.type !== 'nav') {
4419 Roo.log('nav type must be nav/tabs/pills')
4421 cfg.cls += ' navbar-nav'
4425 if (this.parent() && this.parent().sidebar) {
4428 cls: 'dashboard-menu sidebar-menu'
4434 if (this.form === true) {
4437 cls: 'navbar-form form-inline'
4440 if (this.align === 'right') {
4441 cfg.cls += ' navbar-right ml-md-auto';
4443 cfg.cls += ' navbar-left';
4447 if (this.align === 'right') {
4448 cfg.cls += ' navbar-right ml-md-auto';
4450 cfg.cls += ' mr-auto';
4454 cfg.cls += ' navbar-inverse';
4462 * sets the active Navigation item
4463 * @param {Roo.bootstrap.NavItem} the new current navitem
4465 setActiveItem : function(item)
4468 Roo.each(this.navItems, function(v){
4473 v.setActive(false, true);
4480 item.setActive(true, true);
4481 this.fireEvent('changed', this, item, prev);
4486 * gets the active Navigation item
4487 * @return {Roo.bootstrap.NavItem} the current navitem
4489 getActive : function()
4493 Roo.each(this.navItems, function(v){
4504 indexOfNav : function()
4508 Roo.each(this.navItems, function(v,i){
4519 * adds a Navigation item
4520 * @param {Roo.bootstrap.NavItem} the navitem to add
4522 addItem : function(cfg)
4524 if (this.form && Roo.bootstrap.version == 4) {
4527 var cn = new Roo.bootstrap.NavItem(cfg);
4529 cn.parentId = this.id;
4530 cn.onRender(this.el, null);
4534 * register a Navigation item
4535 * @param {Roo.bootstrap.NavItem} the navitem to add
4537 register : function(item)
4539 this.navItems.push( item);
4540 item.navId = this.navId;
4545 * clear all the Navigation item
4548 clearAll : function()
4551 this.el.dom.innerHTML = '';
4554 getNavItem: function(tabId)
4557 Roo.each(this.navItems, function(e) {
4558 if (e.tabId == tabId) {
4568 setActiveNext : function()
4570 var i = this.indexOfNav(this.getActive());
4571 if (i > this.navItems.length) {
4574 this.setActiveItem(this.navItems[i+1]);
4576 setActivePrev : function()
4578 var i = this.indexOfNav(this.getActive());
4582 this.setActiveItem(this.navItems[i-1]);
4584 clearWasActive : function(except) {
4585 Roo.each(this.navItems, function(e) {
4586 if (e.tabId != except.tabId && e.was_active) {
4587 e.was_active = false;
4594 getWasActive : function ()
4597 Roo.each(this.navItems, function(e) {
4612 Roo.apply(Roo.bootstrap.NavGroup, {
4616 * register a Navigation Group
4617 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4619 register : function(navgrp)
4621 this.groups[navgrp.navId] = navgrp;
4625 * fetch a Navigation Group based on the navigation ID
4626 * @param {string} the navgroup to add
4627 * @returns {Roo.bootstrap.NavGroup} the navgroup
4629 get: function(navId) {
4630 if (typeof(this.groups[navId]) == 'undefined') {
4632 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4634 return this.groups[navId] ;
4649 * @class Roo.bootstrap.NavItem
4650 * @extends Roo.bootstrap.Component
4651 * Bootstrap Navbar.NavItem class
4652 * @cfg {String} href link to
4653 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4655 * @cfg {String} html content of button
4656 * @cfg {String} badge text inside badge
4657 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4658 * @cfg {String} glyphicon DEPRICATED - use fa
4659 * @cfg {String} icon DEPRICATED - use fa
4660 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4661 * @cfg {Boolean} active Is item active
4662 * @cfg {Boolean} disabled Is item disabled
4664 * @cfg {Boolean} preventDefault (true | false) default false
4665 * @cfg {String} tabId the tab that this item activates.
4666 * @cfg {String} tagtype (a|span) render as a href or span?
4667 * @cfg {Boolean} animateRef (true|false) link to element default false
4670 * Create a new Navbar Item
4671 * @param {Object} config The config object
4673 Roo.bootstrap.NavItem = function(config){
4674 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4679 * The raw click event for the entire grid.
4680 * @param {Roo.EventObject} e
4685 * Fires when the active item active state changes
4686 * @param {Roo.bootstrap.NavItem} this
4687 * @param {boolean} state the new state
4693 * Fires when scroll to element
4694 * @param {Roo.bootstrap.NavItem} this
4695 * @param {Object} options
4696 * @param {Roo.EventObject} e
4704 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4713 preventDefault : false,
4721 button_outline : false,
4725 getAutoCreate : function(){
4733 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4735 if (this.disabled) {
4736 cfg.cls += ' disabled';
4740 if (this.button_weight.length) {
4741 cfg.tag = this.href ? 'a' : 'button';
4742 cfg.html = this.html || '';
4743 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4745 cfg.href = this.href;
4748 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4751 // menu .. should add dropdown-menu class - so no need for carat..
4753 if (this.badge !== '') {
4755 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4760 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4764 href : this.href || "#",
4765 html: this.html || ''
4768 if (this.tagtype == 'a') {
4769 cfg.cn[0].cls = 'nav-link';
4772 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4775 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4777 if(this.glyphicon) {
4778 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4783 cfg.cn[0].html += " <span class='caret'></span>";
4787 if (this.badge !== '') {
4789 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4797 onRender : function(ct, position)
4799 // Roo.log("Call onRender: " + this.xtype);
4800 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4804 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4805 this.navLink = this.el.select('.nav-link',true).first();
4810 initEvents: function()
4812 if (typeof (this.menu) != 'undefined') {
4813 this.menu.parentType = this.xtype;
4814 this.menu.triggerEl = this.el;
4815 this.menu = this.addxtype(Roo.apply({}, this.menu));
4818 this.el.select('a',true).on('click', this.onClick, this);
4820 if(this.tagtype == 'span'){
4821 this.el.select('span',true).on('click', this.onClick, this);
4824 // at this point parent should be available..
4825 this.parent().register(this);
4828 onClick : function(e)
4830 if (e.getTarget('.dropdown-menu-item')) {
4831 // did you click on a menu itemm.... - then don't trigger onclick..
4836 this.preventDefault ||
4839 Roo.log("NavItem - prevent Default?");
4843 if (this.disabled) {
4847 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4848 if (tg && tg.transition) {
4849 Roo.log("waiting for the transitionend");
4855 //Roo.log("fire event clicked");
4856 if(this.fireEvent('click', this, e) === false){
4860 if(this.tagtype == 'span'){
4864 //Roo.log(this.href);
4865 var ael = this.el.select('a',true).first();
4868 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4869 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4870 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4871 return; // ignore... - it's a 'hash' to another page.
4873 Roo.log("NavItem - prevent Default?");
4875 this.scrollToElement(e);
4879 var p = this.parent();
4881 if (['tabs','pills'].indexOf(p.type)!==-1) {
4882 if (typeof(p.setActiveItem) !== 'undefined') {
4883 p.setActiveItem(this);
4887 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4888 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4889 // remove the collapsed menu expand...
4890 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4894 isActive: function () {
4897 setActive : function(state, fire, is_was_active)
4899 if (this.active && !state && this.navId) {
4900 this.was_active = true;
4901 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4903 nv.clearWasActive(this);
4907 this.active = state;
4910 this.el.removeClass('active');
4911 this.navLink ? this.navLink.removeClass('active') : false;
4912 } else if (!this.el.hasClass('active')) {
4914 this.el.addClass('active');
4915 if (Roo.bootstrap.version == 4 && this.navLink ) {
4916 this.navLink.addClass('active');
4921 this.fireEvent('changed', this, state);
4924 // show a panel if it's registered and related..
4926 if (!this.navId || !this.tabId || !state || is_was_active) {
4930 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4934 var pan = tg.getPanelByName(this.tabId);
4938 // if we can not flip to new panel - go back to old nav highlight..
4939 if (false == tg.showPanel(pan)) {
4940 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4942 var onav = nv.getWasActive();
4944 onav.setActive(true, false, true);
4953 // this should not be here...
4954 setDisabled : function(state)
4956 this.disabled = state;
4958 this.el.removeClass('disabled');
4959 } else if (!this.el.hasClass('disabled')) {
4960 this.el.addClass('disabled');
4966 * Fetch the element to display the tooltip on.
4967 * @return {Roo.Element} defaults to this.el
4969 tooltipEl : function()
4971 return this.el.select('' + this.tagtype + '', true).first();
4974 scrollToElement : function(e)
4976 var c = document.body;
4979 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4981 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4982 c = document.documentElement;
4985 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4991 var o = target.calcOffsetsTo(c);
4998 this.fireEvent('scrollto', this, options, e);
5000 Roo.get(c).scrollTo('top', options.value, true);
5013 * <span> icon </span>
5014 * <span> text </span>
5015 * <span>badge </span>
5019 * @class Roo.bootstrap.NavSidebarItem
5020 * @extends Roo.bootstrap.NavItem
5021 * Bootstrap Navbar.NavSidebarItem class
5022 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
5023 * {Boolean} open is the menu open
5024 * {Boolean} buttonView use button as the tigger el rather that a (default false)
5025 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
5026 * {String} buttonSize (sm|md|lg)the extra classes for the button
5027 * {Boolean} showArrow show arrow next to the text (default true)
5029 * Create a new Navbar Button
5030 * @param {Object} config The config object
5032 Roo.bootstrap.NavSidebarItem = function(config){
5033 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5038 * The raw click event for the entire grid.
5039 * @param {Roo.EventObject} e
5044 * Fires when the active item active state changes
5045 * @param {Roo.bootstrap.NavSidebarItem} this
5046 * @param {boolean} state the new state
5054 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5056 badgeWeight : 'default',
5062 buttonWeight : 'default',
5068 getAutoCreate : function(){
5073 href : this.href || '#',
5079 if(this.buttonView){
5082 href : this.href || '#',
5083 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5096 cfg.cls += ' active';
5099 if (this.disabled) {
5100 cfg.cls += ' disabled';
5103 cfg.cls += ' open x-open';
5106 if (this.glyphicon || this.icon) {
5107 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5108 a.cn.push({ tag : 'i', cls : c }) ;
5111 if(!this.buttonView){
5114 html : this.html || ''
5121 if (this.badge !== '') {
5122 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5128 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5131 a.cls += ' dropdown-toggle treeview' ;
5137 initEvents : function()
5139 if (typeof (this.menu) != 'undefined') {
5140 this.menu.parentType = this.xtype;
5141 this.menu.triggerEl = this.el;
5142 this.menu = this.addxtype(Roo.apply({}, this.menu));
5145 this.el.on('click', this.onClick, this);
5147 if(this.badge !== ''){
5148 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5153 onClick : function(e)
5160 if(this.preventDefault){
5164 this.fireEvent('click', this, e);
5167 disable : function()
5169 this.setDisabled(true);
5174 this.setDisabled(false);
5177 setDisabled : function(state)
5179 if(this.disabled == state){
5183 this.disabled = state;
5186 this.el.addClass('disabled');
5190 this.el.removeClass('disabled');
5195 setActive : function(state)
5197 if(this.active == state){
5201 this.active = state;
5204 this.el.addClass('active');
5208 this.el.removeClass('active');
5213 isActive: function ()
5218 setBadge : function(str)
5224 this.badgeEl.dom.innerHTML = str;
5241 * @class Roo.bootstrap.Row
5242 * @extends Roo.bootstrap.Component
5243 * Bootstrap Row class (contains columns...)
5247 * @param {Object} config The config object
5250 Roo.bootstrap.Row = function(config){
5251 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5254 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5256 getAutoCreate : function(){
5275 * @class Roo.bootstrap.Element
5276 * @extends Roo.bootstrap.Component
5277 * Bootstrap Element class
5278 * @cfg {String} html contents of the element
5279 * @cfg {String} tag tag of the element
5280 * @cfg {String} cls class of the element
5281 * @cfg {Boolean} preventDefault (true|false) default false
5282 * @cfg {Boolean} clickable (true|false) default false
5285 * Create a new Element
5286 * @param {Object} config The config object
5289 Roo.bootstrap.Element = function(config){
5290 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5296 * When a element is chick
5297 * @param {Roo.bootstrap.Element} this
5298 * @param {Roo.EventObject} e
5304 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5309 preventDefault: false,
5312 getAutoCreate : function(){
5316 // cls: this.cls, double assign in parent class Component.js :: onRender
5323 initEvents: function()
5325 Roo.bootstrap.Element.superclass.initEvents.call(this);
5328 this.el.on('click', this.onClick, this);
5333 onClick : function(e)
5335 if(this.preventDefault){
5339 this.fireEvent('click', this, e);
5342 getValue : function()
5344 return this.el.dom.innerHTML;
5347 setValue : function(value)
5349 this.el.dom.innerHTML = value;
5364 * @class Roo.bootstrap.Pagination
5365 * @extends Roo.bootstrap.Component
5366 * Bootstrap Pagination class
5367 * @cfg {String} size xs | sm | md | lg
5368 * @cfg {Boolean} inverse false | true
5371 * Create a new Pagination
5372 * @param {Object} config The config object
5375 Roo.bootstrap.Pagination = function(config){
5376 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5379 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5385 getAutoCreate : function(){
5391 cfg.cls += ' inverse';
5397 cfg.cls += " " + this.cls;
5415 * @class Roo.bootstrap.PaginationItem
5416 * @extends Roo.bootstrap.Component
5417 * Bootstrap PaginationItem class
5418 * @cfg {String} html text
5419 * @cfg {String} href the link
5420 * @cfg {Boolean} preventDefault (true | false) default true
5421 * @cfg {Boolean} active (true | false) default false
5422 * @cfg {Boolean} disabled default false
5426 * Create a new PaginationItem
5427 * @param {Object} config The config object
5431 Roo.bootstrap.PaginationItem = function(config){
5432 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5437 * The raw click event for the entire grid.
5438 * @param {Roo.EventObject} e
5444 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5448 preventDefault: true,
5453 getAutoCreate : function(){
5459 href : this.href ? this.href : '#',
5460 html : this.html ? this.html : ''
5470 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5474 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5480 initEvents: function() {
5482 this.el.on('click', this.onClick, this);
5485 onClick : function(e)
5487 Roo.log('PaginationItem on click ');
5488 if(this.preventDefault){
5496 this.fireEvent('click', this, e);
5512 * @class Roo.bootstrap.Slider
5513 * @extends Roo.bootstrap.Component
5514 * Bootstrap Slider class
5517 * Create a new Slider
5518 * @param {Object} config The config object
5521 Roo.bootstrap.Slider = function(config){
5522 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5525 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5527 getAutoCreate : function(){
5531 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5535 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5547 * Ext JS Library 1.1.1
5548 * Copyright(c) 2006-2007, Ext JS, LLC.
5550 * Originally Released Under LGPL - original licence link has changed is not relivant.
5553 * <script type="text/javascript">
5558 * @class Roo.grid.ColumnModel
5559 * @extends Roo.util.Observable
5560 * This is the default implementation of a ColumnModel used by the Grid. It defines
5561 * the columns in the grid.
5564 var colModel = new Roo.grid.ColumnModel([
5565 {header: "Ticker", width: 60, sortable: true, locked: true},
5566 {header: "Company Name", width: 150, sortable: true},
5567 {header: "Market Cap.", width: 100, sortable: true},
5568 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5569 {header: "Employees", width: 100, sortable: true, resizable: false}
5574 * The config options listed for this class are options which may appear in each
5575 * individual column definition.
5576 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5578 * @param {Object} config An Array of column config objects. See this class's
5579 * config objects for details.
5581 Roo.grid.ColumnModel = function(config){
5583 * The config passed into the constructor
5585 this.config = config;
5588 // if no id, create one
5589 // if the column does not have a dataIndex mapping,
5590 // map it to the order it is in the config
5591 for(var i = 0, len = config.length; i < len; i++){
5593 if(typeof c.dataIndex == "undefined"){
5596 if(typeof c.renderer == "string"){
5597 c.renderer = Roo.util.Format[c.renderer];
5599 if(typeof c.id == "undefined"){
5602 if(c.editor && c.editor.xtype){
5603 c.editor = Roo.factory(c.editor, Roo.grid);
5605 if(c.editor && c.editor.isFormField){
5606 c.editor = new Roo.grid.GridEditor(c.editor);
5608 this.lookup[c.id] = c;
5612 * The width of columns which have no width specified (defaults to 100)
5615 this.defaultWidth = 100;
5618 * Default sortable of columns which have no sortable specified (defaults to false)
5621 this.defaultSortable = false;
5625 * @event widthchange
5626 * Fires when the width of a column changes.
5627 * @param {ColumnModel} this
5628 * @param {Number} columnIndex The column index
5629 * @param {Number} newWidth The new width
5631 "widthchange": true,
5633 * @event headerchange
5634 * Fires when the text of a header changes.
5635 * @param {ColumnModel} this
5636 * @param {Number} columnIndex The column index
5637 * @param {Number} newText The new header text
5639 "headerchange": true,
5641 * @event hiddenchange
5642 * Fires when a column is hidden or "unhidden".
5643 * @param {ColumnModel} this
5644 * @param {Number} columnIndex The column index
5645 * @param {Boolean} hidden true if hidden, false otherwise
5647 "hiddenchange": true,
5649 * @event columnmoved
5650 * Fires when a column is moved.
5651 * @param {ColumnModel} this
5652 * @param {Number} oldIndex
5653 * @param {Number} newIndex
5655 "columnmoved" : true,
5657 * @event columlockchange
5658 * Fires when a column's locked state is changed
5659 * @param {ColumnModel} this
5660 * @param {Number} colIndex
5661 * @param {Boolean} locked true if locked
5663 "columnlockchange" : true
5665 Roo.grid.ColumnModel.superclass.constructor.call(this);
5667 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5669 * @cfg {String} header The header text to display in the Grid view.
5672 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5673 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5674 * specified, the column's index is used as an index into the Record's data Array.
5677 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5678 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5681 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5682 * Defaults to the value of the {@link #defaultSortable} property.
5683 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5686 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5689 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5692 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5695 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5698 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5699 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5700 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5701 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5704 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5707 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5710 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5713 * @cfg {String} cursor (Optional)
5716 * @cfg {String} tooltip (Optional)
5719 * @cfg {Number} xs (Optional)
5722 * @cfg {Number} sm (Optional)
5725 * @cfg {Number} md (Optional)
5728 * @cfg {Number} lg (Optional)
5731 * Returns the id of the column at the specified index.
5732 * @param {Number} index The column index
5733 * @return {String} the id
5735 getColumnId : function(index){
5736 return this.config[index].id;
5740 * Returns the column for a specified id.
5741 * @param {String} id The column id
5742 * @return {Object} the column
5744 getColumnById : function(id){
5745 return this.lookup[id];
5750 * Returns the column for a specified dataIndex.
5751 * @param {String} dataIndex The column dataIndex
5752 * @return {Object|Boolean} the column or false if not found
5754 getColumnByDataIndex: function(dataIndex){
5755 var index = this.findColumnIndex(dataIndex);
5756 return index > -1 ? this.config[index] : false;
5760 * Returns the index for a specified column id.
5761 * @param {String} id The column id
5762 * @return {Number} the index, or -1 if not found
5764 getIndexById : function(id){
5765 for(var i = 0, len = this.config.length; i < len; i++){
5766 if(this.config[i].id == id){
5774 * Returns the index for a specified column dataIndex.
5775 * @param {String} dataIndex The column dataIndex
5776 * @return {Number} the index, or -1 if not found
5779 findColumnIndex : function(dataIndex){
5780 for(var i = 0, len = this.config.length; i < len; i++){
5781 if(this.config[i].dataIndex == dataIndex){
5789 moveColumn : function(oldIndex, newIndex){
5790 var c = this.config[oldIndex];
5791 this.config.splice(oldIndex, 1);
5792 this.config.splice(newIndex, 0, c);
5793 this.dataMap = null;
5794 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5797 isLocked : function(colIndex){
5798 return this.config[colIndex].locked === true;
5801 setLocked : function(colIndex, value, suppressEvent){
5802 if(this.isLocked(colIndex) == value){
5805 this.config[colIndex].locked = value;
5807 this.fireEvent("columnlockchange", this, colIndex, value);
5811 getTotalLockedWidth : function(){
5813 for(var i = 0; i < this.config.length; i++){
5814 if(this.isLocked(i) && !this.isHidden(i)){
5815 this.totalWidth += this.getColumnWidth(i);
5821 getLockedCount : function(){
5822 for(var i = 0, len = this.config.length; i < len; i++){
5823 if(!this.isLocked(i)){
5828 return this.config.length;
5832 * Returns the number of columns.
5835 getColumnCount : function(visibleOnly){
5836 if(visibleOnly === true){
5838 for(var i = 0, len = this.config.length; i < len; i++){
5839 if(!this.isHidden(i)){
5845 return this.config.length;
5849 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5850 * @param {Function} fn
5851 * @param {Object} scope (optional)
5852 * @return {Array} result
5854 getColumnsBy : function(fn, scope){
5856 for(var i = 0, len = this.config.length; i < len; i++){
5857 var c = this.config[i];
5858 if(fn.call(scope||this, c, i) === true){
5866 * Returns true if the specified column is sortable.
5867 * @param {Number} col The column index
5870 isSortable : function(col){
5871 if(typeof this.config[col].sortable == "undefined"){
5872 return this.defaultSortable;
5874 return this.config[col].sortable;
5878 * Returns the rendering (formatting) function defined for the column.
5879 * @param {Number} col The column index.
5880 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5882 getRenderer : function(col){
5883 if(!this.config[col].renderer){
5884 return Roo.grid.ColumnModel.defaultRenderer;
5886 return this.config[col].renderer;
5890 * Sets the rendering (formatting) function for a column.
5891 * @param {Number} col The column index
5892 * @param {Function} fn The function to use to process the cell's raw data
5893 * to return HTML markup for the grid view. The render function is called with
5894 * the following parameters:<ul>
5895 * <li>Data value.</li>
5896 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5897 * <li>css A CSS style string to apply to the table cell.</li>
5898 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5899 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5900 * <li>Row index</li>
5901 * <li>Column index</li>
5902 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5904 setRenderer : function(col, fn){
5905 this.config[col].renderer = fn;
5909 * Returns the width for the specified column.
5910 * @param {Number} col The column index
5913 getColumnWidth : function(col){
5914 return this.config[col].width * 1 || this.defaultWidth;
5918 * Sets the width for a column.
5919 * @param {Number} col The column index
5920 * @param {Number} width The new width
5922 setColumnWidth : function(col, width, suppressEvent){
5923 this.config[col].width = width;
5924 this.totalWidth = null;
5926 this.fireEvent("widthchange", this, col, width);
5931 * Returns the total width of all columns.
5932 * @param {Boolean} includeHidden True to include hidden column widths
5935 getTotalWidth : function(includeHidden){
5936 if(!this.totalWidth){
5937 this.totalWidth = 0;
5938 for(var i = 0, len = this.config.length; i < len; i++){
5939 if(includeHidden || !this.isHidden(i)){
5940 this.totalWidth += this.getColumnWidth(i);
5944 return this.totalWidth;
5948 * Returns the header for the specified column.
5949 * @param {Number} col The column index
5952 getColumnHeader : function(col){
5953 return this.config[col].header;
5957 * Sets the header for a column.
5958 * @param {Number} col The column index
5959 * @param {String} header The new header
5961 setColumnHeader : function(col, header){
5962 this.config[col].header = header;
5963 this.fireEvent("headerchange", this, col, header);
5967 * Returns the tooltip for the specified column.
5968 * @param {Number} col The column index
5971 getColumnTooltip : function(col){
5972 return this.config[col].tooltip;
5975 * Sets the tooltip for a column.
5976 * @param {Number} col The column index
5977 * @param {String} tooltip The new tooltip
5979 setColumnTooltip : function(col, tooltip){
5980 this.config[col].tooltip = tooltip;
5984 * Returns the dataIndex for the specified column.
5985 * @param {Number} col The column index
5988 getDataIndex : function(col){
5989 return this.config[col].dataIndex;
5993 * Sets the dataIndex for a column.
5994 * @param {Number} col The column index
5995 * @param {Number} dataIndex The new dataIndex
5997 setDataIndex : function(col, dataIndex){
5998 this.config[col].dataIndex = dataIndex;
6004 * Returns true if the cell is editable.
6005 * @param {Number} colIndex The column index
6006 * @param {Number} rowIndex The row index - this is nto actually used..?
6009 isCellEditable : function(colIndex, rowIndex){
6010 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
6014 * Returns the editor defined for the cell/column.
6015 * return false or null to disable editing.
6016 * @param {Number} colIndex The column index
6017 * @param {Number} rowIndex The row index
6020 getCellEditor : function(colIndex, rowIndex){
6021 return this.config[colIndex].editor;
6025 * Sets if a column is editable.
6026 * @param {Number} col The column index
6027 * @param {Boolean} editable True if the column is editable
6029 setEditable : function(col, editable){
6030 this.config[col].editable = editable;
6035 * Returns true if the column is hidden.
6036 * @param {Number} colIndex The column index
6039 isHidden : function(colIndex){
6040 return this.config[colIndex].hidden;
6045 * Returns true if the column width cannot be changed
6047 isFixed : function(colIndex){
6048 return this.config[colIndex].fixed;
6052 * Returns true if the column can be resized
6055 isResizable : function(colIndex){
6056 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6059 * Sets if a column is hidden.
6060 * @param {Number} colIndex The column index
6061 * @param {Boolean} hidden True if the column is hidden
6063 setHidden : function(colIndex, hidden){
6064 this.config[colIndex].hidden = hidden;
6065 this.totalWidth = null;
6066 this.fireEvent("hiddenchange", this, colIndex, hidden);
6070 * Sets the editor for a column.
6071 * @param {Number} col The column index
6072 * @param {Object} editor The editor object
6074 setEditor : function(col, editor){
6075 this.config[col].editor = editor;
6079 Roo.grid.ColumnModel.defaultRenderer = function(value)
6081 if(typeof value == "object") {
6084 if(typeof value == "string" && value.length < 1){
6088 return String.format("{0}", value);
6091 // Alias for backwards compatibility
6092 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6095 * Ext JS Library 1.1.1
6096 * Copyright(c) 2006-2007, Ext JS, LLC.
6098 * Originally Released Under LGPL - original licence link has changed is not relivant.
6101 * <script type="text/javascript">
6105 * @class Roo.LoadMask
6106 * A simple utility class for generically masking elements while loading data. If the element being masked has
6107 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6108 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6109 * element's UpdateManager load indicator and will be destroyed after the initial load.
6111 * Create a new LoadMask
6112 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6113 * @param {Object} config The config object
6115 Roo.LoadMask = function(el, config){
6116 this.el = Roo.get(el);
6117 Roo.apply(this, config);
6119 this.store.on('beforeload', this.onBeforeLoad, this);
6120 this.store.on('load', this.onLoad, this);
6121 this.store.on('loadexception', this.onLoadException, this);
6122 this.removeMask = false;
6124 var um = this.el.getUpdateManager();
6125 um.showLoadIndicator = false; // disable the default indicator
6126 um.on('beforeupdate', this.onBeforeLoad, this);
6127 um.on('update', this.onLoad, this);
6128 um.on('failure', this.onLoad, this);
6129 this.removeMask = true;
6133 Roo.LoadMask.prototype = {
6135 * @cfg {Boolean} removeMask
6136 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6137 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6141 * The text to display in a centered loading message box (defaults to 'Loading...')
6145 * @cfg {String} msgCls
6146 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6148 msgCls : 'x-mask-loading',
6151 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6157 * Disables the mask to prevent it from being displayed
6159 disable : function(){
6160 this.disabled = true;
6164 * Enables the mask so that it can be displayed
6166 enable : function(){
6167 this.disabled = false;
6170 onLoadException : function()
6174 if (typeof(arguments[3]) != 'undefined') {
6175 Roo.MessageBox.alert("Error loading",arguments[3]);
6179 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6180 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6187 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6192 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6196 onBeforeLoad : function(){
6198 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6203 destroy : function(){
6205 this.store.un('beforeload', this.onBeforeLoad, this);
6206 this.store.un('load', this.onLoad, this);
6207 this.store.un('loadexception', this.onLoadException, this);
6209 var um = this.el.getUpdateManager();
6210 um.un('beforeupdate', this.onBeforeLoad, this);
6211 um.un('update', this.onLoad, this);
6212 um.un('failure', this.onLoad, this);
6223 * @class Roo.bootstrap.Table
6224 * @extends Roo.bootstrap.Component
6225 * Bootstrap Table class
6226 * @cfg {String} cls table class
6227 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6228 * @cfg {String} bgcolor Specifies the background color for a table
6229 * @cfg {Number} border Specifies whether the table cells should have borders or not
6230 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6231 * @cfg {Number} cellspacing Specifies the space between cells
6232 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6233 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6234 * @cfg {String} sortable Specifies that the table should be sortable
6235 * @cfg {String} summary Specifies a summary of the content of a table
6236 * @cfg {Number} width Specifies the width of a table
6237 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6239 * @cfg {boolean} striped Should the rows be alternative striped
6240 * @cfg {boolean} bordered Add borders to the table
6241 * @cfg {boolean} hover Add hover highlighting
6242 * @cfg {boolean} condensed Format condensed
6243 * @cfg {boolean} responsive Format condensed
6244 * @cfg {Boolean} loadMask (true|false) default false
6245 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6246 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6247 * @cfg {Boolean} rowSelection (true|false) default false
6248 * @cfg {Boolean} cellSelection (true|false) default false
6249 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6250 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6251 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6252 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6256 * Create a new Table
6257 * @param {Object} config The config object
6260 Roo.bootstrap.Table = function(config){
6261 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6266 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6267 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6268 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6269 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6271 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6273 this.sm.grid = this;
6274 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6275 this.sm = this.selModel;
6276 this.sm.xmodule = this.xmodule || false;
6279 if (this.cm && typeof(this.cm.config) == 'undefined') {
6280 this.colModel = new Roo.grid.ColumnModel(this.cm);
6281 this.cm = this.colModel;
6282 this.cm.xmodule = this.xmodule || false;
6285 this.store= Roo.factory(this.store, Roo.data);
6286 this.ds = this.store;
6287 this.ds.xmodule = this.xmodule || false;
6290 if (this.footer && this.store) {
6291 this.footer.dataSource = this.ds;
6292 this.footer = Roo.factory(this.footer);
6299 * Fires when a cell is clicked
6300 * @param {Roo.bootstrap.Table} this
6301 * @param {Roo.Element} el
6302 * @param {Number} rowIndex
6303 * @param {Number} columnIndex
6304 * @param {Roo.EventObject} e
6308 * @event celldblclick
6309 * Fires when a cell is double clicked
6310 * @param {Roo.bootstrap.Table} this
6311 * @param {Roo.Element} el
6312 * @param {Number} rowIndex
6313 * @param {Number} columnIndex
6314 * @param {Roo.EventObject} e
6316 "celldblclick" : true,
6319 * Fires when a row is clicked
6320 * @param {Roo.bootstrap.Table} this
6321 * @param {Roo.Element} el
6322 * @param {Number} rowIndex
6323 * @param {Roo.EventObject} e
6327 * @event rowdblclick
6328 * Fires when a row is double clicked
6329 * @param {Roo.bootstrap.Table} this
6330 * @param {Roo.Element} el
6331 * @param {Number} rowIndex
6332 * @param {Roo.EventObject} e
6334 "rowdblclick" : true,
6337 * Fires when a mouseover occur
6338 * @param {Roo.bootstrap.Table} this
6339 * @param {Roo.Element} el
6340 * @param {Number} rowIndex
6341 * @param {Number} columnIndex
6342 * @param {Roo.EventObject} e
6347 * Fires when a mouseout occur
6348 * @param {Roo.bootstrap.Table} this
6349 * @param {Roo.Element} el
6350 * @param {Number} rowIndex
6351 * @param {Number} columnIndex
6352 * @param {Roo.EventObject} e
6357 * Fires when a row is rendered, so you can change add a style to it.
6358 * @param {Roo.bootstrap.Table} this
6359 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6363 * @event rowsrendered
6364 * Fires when all the rows have been rendered
6365 * @param {Roo.bootstrap.Table} this
6367 'rowsrendered' : true,
6369 * @event contextmenu
6370 * The raw contextmenu event for the entire grid.
6371 * @param {Roo.EventObject} e
6373 "contextmenu" : true,
6375 * @event rowcontextmenu
6376 * Fires when a row is right clicked
6377 * @param {Roo.bootstrap.Table} this
6378 * @param {Number} rowIndex
6379 * @param {Roo.EventObject} e
6381 "rowcontextmenu" : true,
6383 * @event cellcontextmenu
6384 * Fires when a cell is right clicked
6385 * @param {Roo.bootstrap.Table} this
6386 * @param {Number} rowIndex
6387 * @param {Number} cellIndex
6388 * @param {Roo.EventObject} e
6390 "cellcontextmenu" : true,
6392 * @event headercontextmenu
6393 * Fires when a header is right clicked
6394 * @param {Roo.bootstrap.Table} this
6395 * @param {Number} columnIndex
6396 * @param {Roo.EventObject} e
6398 "headercontextmenu" : true
6402 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6428 rowSelection : false,
6429 cellSelection : false,
6432 // Roo.Element - the tbody
6434 // Roo.Element - thead element
6437 container: false, // used by gridpanel...
6443 auto_hide_footer : false,
6445 getAutoCreate : function()
6447 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6454 if (this.scrollBody) {
6455 cfg.cls += ' table-body-fixed';
6458 cfg.cls += ' table-striped';
6462 cfg.cls += ' table-hover';
6464 if (this.bordered) {
6465 cfg.cls += ' table-bordered';
6467 if (this.condensed) {
6468 cfg.cls += ' table-condensed';
6470 if (this.responsive) {
6471 cfg.cls += ' table-responsive';
6475 cfg.cls+= ' ' +this.cls;
6478 // this lot should be simplifed...
6491 ].forEach(function(k) {
6499 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6502 if(this.store || this.cm){
6503 if(this.headerShow){
6504 cfg.cn.push(this.renderHeader());
6507 cfg.cn.push(this.renderBody());
6509 if(this.footerShow){
6510 cfg.cn.push(this.renderFooter());
6512 // where does this come from?
6513 //cfg.cls+= ' TableGrid';
6516 return { cn : [ cfg ] };
6519 initEvents : function()
6521 if(!this.store || !this.cm){
6524 if (this.selModel) {
6525 this.selModel.initEvents();
6529 //Roo.log('initEvents with ds!!!!');
6531 this.mainBody = this.el.select('tbody', true).first();
6532 this.mainHead = this.el.select('thead', true).first();
6533 this.mainFoot = this.el.select('tfoot', true).first();
6539 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6540 e.on('click', _this.sort, _this);
6543 this.mainBody.on("click", this.onClick, this);
6544 this.mainBody.on("dblclick", this.onDblClick, this);
6546 // why is this done????? = it breaks dialogs??
6547 //this.parent().el.setStyle('position', 'relative');
6551 this.footer.parentId = this.id;
6552 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6555 this.el.select('tfoot tr td').first().addClass('hide');
6560 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6563 this.store.on('load', this.onLoad, this);
6564 this.store.on('beforeload', this.onBeforeLoad, this);
6565 this.store.on('update', this.onUpdate, this);
6566 this.store.on('add', this.onAdd, this);
6567 this.store.on("clear", this.clear, this);
6569 this.el.on("contextmenu", this.onContextMenu, this);
6571 this.mainBody.on('scroll', this.onBodyScroll, this);
6573 this.cm.on("headerchange", this.onHeaderChange, this);
6575 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6579 onContextMenu : function(e, t)
6581 this.processEvent("contextmenu", e);
6584 processEvent : function(name, e)
6586 if (name != 'touchstart' ) {
6587 this.fireEvent(name, e);
6590 var t = e.getTarget();
6592 var cell = Roo.get(t);
6598 if(cell.findParent('tfoot', false, true)){
6602 if(cell.findParent('thead', false, true)){
6604 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6605 cell = Roo.get(t).findParent('th', false, true);
6607 Roo.log("failed to find th in thead?");
6608 Roo.log(e.getTarget());
6613 var cellIndex = cell.dom.cellIndex;
6615 var ename = name == 'touchstart' ? 'click' : name;
6616 this.fireEvent("header" + ename, this, cellIndex, e);
6621 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6622 cell = Roo.get(t).findParent('td', false, true);
6624 Roo.log("failed to find th in tbody?");
6625 Roo.log(e.getTarget());
6630 var row = cell.findParent('tr', false, true);
6631 var cellIndex = cell.dom.cellIndex;
6632 var rowIndex = row.dom.rowIndex - 1;
6636 this.fireEvent("row" + name, this, rowIndex, e);
6640 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6646 onMouseover : function(e, el)
6648 var cell = Roo.get(el);
6654 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6655 cell = cell.findParent('td', false, true);
6658 var row = cell.findParent('tr', false, true);
6659 var cellIndex = cell.dom.cellIndex;
6660 var rowIndex = row.dom.rowIndex - 1; // start from 0
6662 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6666 onMouseout : function(e, el)
6668 var cell = Roo.get(el);
6674 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6675 cell = cell.findParent('td', false, true);
6678 var row = cell.findParent('tr', false, true);
6679 var cellIndex = cell.dom.cellIndex;
6680 var rowIndex = row.dom.rowIndex - 1; // start from 0
6682 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6686 onClick : function(e, el)
6688 var cell = Roo.get(el);
6690 if(!cell || (!this.cellSelection && !this.rowSelection)){
6694 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6695 cell = cell.findParent('td', false, true);
6698 if(!cell || typeof(cell) == 'undefined'){
6702 var row = cell.findParent('tr', false, true);
6704 if(!row || typeof(row) == 'undefined'){
6708 var cellIndex = cell.dom.cellIndex;
6709 var rowIndex = this.getRowIndex(row);
6711 // why??? - should these not be based on SelectionModel?
6712 if(this.cellSelection){
6713 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6716 if(this.rowSelection){
6717 this.fireEvent('rowclick', this, row, rowIndex, e);
6723 onDblClick : function(e,el)
6725 var cell = Roo.get(el);
6727 if(!cell || (!this.cellSelection && !this.rowSelection)){
6731 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6732 cell = cell.findParent('td', false, true);
6735 if(!cell || typeof(cell) == 'undefined'){
6739 var row = cell.findParent('tr', false, true);
6741 if(!row || typeof(row) == 'undefined'){
6745 var cellIndex = cell.dom.cellIndex;
6746 var rowIndex = this.getRowIndex(row);
6748 if(this.cellSelection){
6749 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6752 if(this.rowSelection){
6753 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6757 sort : function(e,el)
6759 var col = Roo.get(el);
6761 if(!col.hasClass('sortable')){
6765 var sort = col.attr('sort');
6768 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6772 this.store.sortInfo = {field : sort, direction : dir};
6775 Roo.log("calling footer first");
6776 this.footer.onClick('first');
6779 this.store.load({ params : { start : 0 } });
6783 renderHeader : function()
6791 this.totalWidth = 0;
6793 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6795 var config = cm.config[i];
6799 cls : 'x-hcol-' + i,
6801 html: cm.getColumnHeader(i)
6806 if(typeof(config.sortable) != 'undefined' && config.sortable){
6808 c.html = '<i class="glyphicon"></i>' + c.html;
6811 if(typeof(config.lgHeader) != 'undefined'){
6812 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6815 if(typeof(config.mdHeader) != 'undefined'){
6816 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6819 if(typeof(config.smHeader) != 'undefined'){
6820 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6823 if(typeof(config.xsHeader) != 'undefined'){
6824 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6831 if(typeof(config.tooltip) != 'undefined'){
6832 c.tooltip = config.tooltip;
6835 if(typeof(config.colspan) != 'undefined'){
6836 c.colspan = config.colspan;
6839 if(typeof(config.hidden) != 'undefined' && config.hidden){
6840 c.style += ' display:none;';
6843 if(typeof(config.dataIndex) != 'undefined'){
6844 c.sort = config.dataIndex;
6849 if(typeof(config.align) != 'undefined' && config.align.length){
6850 c.style += ' text-align:' + config.align + ';';
6853 if(typeof(config.width) != 'undefined'){
6854 c.style += ' width:' + config.width + 'px;';
6855 this.totalWidth += config.width;
6857 this.totalWidth += 100; // assume minimum of 100 per column?
6860 if(typeof(config.cls) != 'undefined'){
6861 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6864 ['xs','sm','md','lg'].map(function(size){
6866 if(typeof(config[size]) == 'undefined'){
6870 if (!config[size]) { // 0 = hidden
6871 // BS 4 '0' is treated as hide that column and below.
6872 c.cls += ' hidden-' + size + ' hidden' + size + 'down';
6876 c.cls += ' col-' + size + '-' + config[size] + (
6877 size == 'xs' ? (' col-' + + config[size] ) : '' // bs4 col-{num} replaces col-xs
6889 renderBody : function()
6899 colspan : this.cm.getColumnCount()
6909 renderFooter : function()
6919 colspan : this.cm.getColumnCount()
6933 // Roo.log('ds onload');
6938 var ds = this.store;
6940 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6941 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6942 if (_this.store.sortInfo) {
6944 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6945 e.select('i', true).addClass(['glyphicon-arrow-up']);
6948 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6949 e.select('i', true).addClass(['glyphicon-arrow-down']);
6954 var tbody = this.mainBody;
6956 if(ds.getCount() > 0){
6957 ds.data.each(function(d,rowIndex){
6958 var row = this.renderRow(cm, ds, rowIndex);
6960 tbody.createChild(row);
6964 if(row.cellObjects.length){
6965 Roo.each(row.cellObjects, function(r){
6966 _this.renderCellObject(r);
6973 var tfoot = this.el.select('tfoot', true).first();
6975 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6977 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6979 var total = this.ds.getTotalCount();
6981 if(this.footer.pageSize < total){
6982 this.mainFoot.show();
6986 Roo.each(this.el.select('tbody td', true).elements, function(e){
6987 e.on('mouseover', _this.onMouseover, _this);
6990 Roo.each(this.el.select('tbody td', true).elements, function(e){
6991 e.on('mouseout', _this.onMouseout, _this);
6993 this.fireEvent('rowsrendered', this);
6999 onUpdate : function(ds,record)
7001 this.refreshRow(record);
7005 onRemove : function(ds, record, index, isUpdate){
7006 if(isUpdate !== true){
7007 this.fireEvent("beforerowremoved", this, index, record);
7009 var bt = this.mainBody.dom;
7011 var rows = this.el.select('tbody > tr', true).elements;
7013 if(typeof(rows[index]) != 'undefined'){
7014 bt.removeChild(rows[index].dom);
7017 // if(bt.rows[index]){
7018 // bt.removeChild(bt.rows[index]);
7021 if(isUpdate !== true){
7022 //this.stripeRows(index);
7023 //this.syncRowHeights(index, index);
7025 this.fireEvent("rowremoved", this, index, record);
7029 onAdd : function(ds, records, rowIndex)
7031 //Roo.log('on Add called');
7032 // - note this does not handle multiple adding very well..
7033 var bt = this.mainBody.dom;
7034 for (var i =0 ; i < records.length;i++) {
7035 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7036 //Roo.log(records[i]);
7037 //Roo.log(this.store.getAt(rowIndex+i));
7038 this.insertRow(this.store, rowIndex + i, false);
7045 refreshRow : function(record){
7046 var ds = this.store, index;
7047 if(typeof record == 'number'){
7049 record = ds.getAt(index);
7051 index = ds.indexOf(record);
7053 this.insertRow(ds, index, true);
7055 this.onRemove(ds, record, index+1, true);
7057 //this.syncRowHeights(index, index);
7059 this.fireEvent("rowupdated", this, index, record);
7062 insertRow : function(dm, rowIndex, isUpdate){
7065 this.fireEvent("beforerowsinserted", this, rowIndex);
7067 //var s = this.getScrollState();
7068 var row = this.renderRow(this.cm, this.store, rowIndex);
7069 // insert before rowIndex..
7070 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7074 if(row.cellObjects.length){
7075 Roo.each(row.cellObjects, function(r){
7076 _this.renderCellObject(r);
7081 this.fireEvent("rowsinserted", this, rowIndex);
7082 //this.syncRowHeights(firstRow, lastRow);
7083 //this.stripeRows(firstRow);
7090 getRowDom : function(rowIndex)
7092 var rows = this.el.select('tbody > tr', true).elements;
7094 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7097 // returns the object tree for a tr..
7100 renderRow : function(cm, ds, rowIndex)
7102 var d = ds.getAt(rowIndex);
7106 cls : 'x-row-' + rowIndex,
7110 var cellObjects = [];
7112 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7113 var config = cm.config[i];
7115 var renderer = cm.getRenderer(i);
7119 if(typeof(renderer) !== 'undefined'){
7120 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7122 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7123 // and are rendered into the cells after the row is rendered - using the id for the element.
7125 if(typeof(value) === 'object'){
7135 rowIndex : rowIndex,
7140 this.fireEvent('rowclass', this, rowcfg);
7144 cls : rowcfg.rowClass + ' x-col-' + i,
7146 html: (typeof(value) === 'object') ? '' : value
7153 if(typeof(config.colspan) != 'undefined'){
7154 td.colspan = config.colspan;
7157 if(typeof(config.hidden) != 'undefined' && config.hidden){
7158 td.style += ' display:none;';
7161 if(typeof(config.align) != 'undefined' && config.align.length){
7162 td.style += ' text-align:' + config.align + ';';
7164 if(typeof(config.valign) != 'undefined' && config.valign.length){
7165 td.style += ' vertical-align:' + config.valign + ';';
7168 if(typeof(config.width) != 'undefined'){
7169 td.style += ' width:' + config.width + 'px;';
7172 if(typeof(config.cursor) != 'undefined'){
7173 td.style += ' cursor:' + config.cursor + ';';
7176 if(typeof(config.cls) != 'undefined'){
7177 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7180 ['xs','sm','md','lg'].map(function(size){
7182 if(typeof(config[size]) == 'undefined'){
7188 if (!config[size]) { // 0 = hidden
7189 // BS 4 '0' is treated as hide that column and below.
7190 td.cls += ' hidden-' + size + ' hidden' + size + 'down';
7194 td.cls += ' col-' + size + '-' + config[size] + (
7195 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
7205 row.cellObjects = cellObjects;
7213 onBeforeLoad : function()
7222 this.el.select('tbody', true).first().dom.innerHTML = '';
7225 * Show or hide a row.
7226 * @param {Number} rowIndex to show or hide
7227 * @param {Boolean} state hide
7229 setRowVisibility : function(rowIndex, state)
7231 var bt = this.mainBody.dom;
7233 var rows = this.el.select('tbody > tr', true).elements;
7235 if(typeof(rows[rowIndex]) == 'undefined'){
7238 rows[rowIndex].dom.style.display = state ? '' : 'none';
7242 getSelectionModel : function(){
7244 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7246 return this.selModel;
7249 * Render the Roo.bootstrap object from renderder
7251 renderCellObject : function(r)
7255 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7257 var t = r.cfg.render(r.container);
7260 Roo.each(r.cfg.cn, function(c){
7262 container: t.getChildContainer(),
7265 _this.renderCellObject(child);
7270 getRowIndex : function(row)
7274 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7285 * Returns the grid's underlying element = used by panel.Grid
7286 * @return {Element} The element
7288 getGridEl : function(){
7292 * Forces a resize - used by panel.Grid
7293 * @return {Element} The element
7295 autoSize : function()
7297 //var ctr = Roo.get(this.container.dom.parentElement);
7298 var ctr = Roo.get(this.el.dom);
7300 var thd = this.getGridEl().select('thead',true).first();
7301 var tbd = this.getGridEl().select('tbody', true).first();
7302 var tfd = this.getGridEl().select('tfoot', true).first();
7304 var cw = ctr.getWidth();
7308 tbd.setSize(ctr.getWidth(),
7309 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7311 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7314 cw = Math.max(cw, this.totalWidth);
7315 this.getGridEl().select('tr',true).setWidth(cw);
7316 // resize 'expandable coloumn?
7318 return; // we doe not have a view in this design..
7321 onBodyScroll: function()
7323 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7325 this.mainHead.setStyle({
7326 'position' : 'relative',
7327 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7333 var scrollHeight = this.mainBody.dom.scrollHeight;
7335 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7337 var height = this.mainBody.getHeight();
7339 if(scrollHeight - height == scrollTop) {
7341 var total = this.ds.getTotalCount();
7343 if(this.footer.cursor + this.footer.pageSize < total){
7345 this.footer.ds.load({
7347 start : this.footer.cursor + this.footer.pageSize,
7348 limit : this.footer.pageSize
7358 onHeaderChange : function()
7360 var header = this.renderHeader();
7361 var table = this.el.select('table', true).first();
7363 this.mainHead.remove();
7364 this.mainHead = table.createChild(header, this.mainBody, false);
7367 onHiddenChange : function(colModel, colIndex, hidden)
7369 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7370 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7372 this.CSS.updateRule(thSelector, "display", "");
7373 this.CSS.updateRule(tdSelector, "display", "");
7376 this.CSS.updateRule(thSelector, "display", "none");
7377 this.CSS.updateRule(tdSelector, "display", "none");
7380 this.onHeaderChange();
7384 setColumnWidth: function(col_index, width)
7386 // width = "md-2 xs-2..."
7387 if(!this.colModel.config[col_index]) {
7391 var w = width.split(" ");
7393 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7395 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7398 for(var j = 0; j < w.length; j++) {
7404 var size_cls = w[j].split("-");
7406 if(!Number.isInteger(size_cls[1] * 1)) {
7410 if(!this.colModel.config[col_index][size_cls[0]]) {
7414 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7418 h_row[0].classList.replace(
7419 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7420 "col-"+size_cls[0]+"-"+size_cls[1]
7423 for(var i = 0; i < rows.length; i++) {
7425 var size_cls = w[j].split("-");
7427 if(!Number.isInteger(size_cls[1] * 1)) {
7431 if(!this.colModel.config[col_index][size_cls[0]]) {
7435 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7439 rows[i].classList.replace(
7440 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7441 "col-"+size_cls[0]+"-"+size_cls[1]
7445 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7460 * @class Roo.bootstrap.TableCell
7461 * @extends Roo.bootstrap.Component
7462 * Bootstrap TableCell class
7463 * @cfg {String} html cell contain text
7464 * @cfg {String} cls cell class
7465 * @cfg {String} tag cell tag (td|th) default td
7466 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7467 * @cfg {String} align Aligns the content in a cell
7468 * @cfg {String} axis Categorizes cells
7469 * @cfg {String} bgcolor Specifies the background color of a cell
7470 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7471 * @cfg {Number} colspan Specifies the number of columns a cell should span
7472 * @cfg {String} headers Specifies one or more header cells a cell is related to
7473 * @cfg {Number} height Sets the height of a cell
7474 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7475 * @cfg {Number} rowspan Sets the number of rows a cell should span
7476 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7477 * @cfg {String} valign Vertical aligns the content in a cell
7478 * @cfg {Number} width Specifies the width of a cell
7481 * Create a new TableCell
7482 * @param {Object} config The config object
7485 Roo.bootstrap.TableCell = function(config){
7486 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7489 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7509 getAutoCreate : function(){
7510 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7530 cfg.align=this.align
7536 cfg.bgcolor=this.bgcolor
7539 cfg.charoff=this.charoff
7542 cfg.colspan=this.colspan
7545 cfg.headers=this.headers
7548 cfg.height=this.height
7551 cfg.nowrap=this.nowrap
7554 cfg.rowspan=this.rowspan
7557 cfg.scope=this.scope
7560 cfg.valign=this.valign
7563 cfg.width=this.width
7582 * @class Roo.bootstrap.TableRow
7583 * @extends Roo.bootstrap.Component
7584 * Bootstrap TableRow class
7585 * @cfg {String} cls row class
7586 * @cfg {String} align Aligns the content in a table row
7587 * @cfg {String} bgcolor Specifies a background color for a table row
7588 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7589 * @cfg {String} valign Vertical aligns the content in a table row
7592 * Create a new TableRow
7593 * @param {Object} config The config object
7596 Roo.bootstrap.TableRow = function(config){
7597 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7600 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7608 getAutoCreate : function(){
7609 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7619 cfg.align = this.align;
7622 cfg.bgcolor = this.bgcolor;
7625 cfg.charoff = this.charoff;
7628 cfg.valign = this.valign;
7646 * @class Roo.bootstrap.TableBody
7647 * @extends Roo.bootstrap.Component
7648 * Bootstrap TableBody class
7649 * @cfg {String} cls element class
7650 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7651 * @cfg {String} align Aligns the content inside the element
7652 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7653 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7656 * Create a new TableBody
7657 * @param {Object} config The config object
7660 Roo.bootstrap.TableBody = function(config){
7661 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7664 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7672 getAutoCreate : function(){
7673 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7687 cfg.align = this.align;
7690 cfg.charoff = this.charoff;
7693 cfg.valign = this.valign;
7700 // initEvents : function()
7707 // this.store = Roo.factory(this.store, Roo.data);
7708 // this.store.on('load', this.onLoad, this);
7710 // this.store.load();
7714 // onLoad: function ()
7716 // this.fireEvent('load', this);
7726 * Ext JS Library 1.1.1
7727 * Copyright(c) 2006-2007, Ext JS, LLC.
7729 * Originally Released Under LGPL - original licence link has changed is not relivant.
7732 * <script type="text/javascript">
7735 // as we use this in bootstrap.
7736 Roo.namespace('Roo.form');
7738 * @class Roo.form.Action
7739 * Internal Class used to handle form actions
7741 * @param {Roo.form.BasicForm} el The form element or its id
7742 * @param {Object} config Configuration options
7747 // define the action interface
7748 Roo.form.Action = function(form, options){
7750 this.options = options || {};
7753 * Client Validation Failed
7756 Roo.form.Action.CLIENT_INVALID = 'client';
7758 * Server Validation Failed
7761 Roo.form.Action.SERVER_INVALID = 'server';
7763 * Connect to Server Failed
7766 Roo.form.Action.CONNECT_FAILURE = 'connect';
7768 * Reading Data from Server Failed
7771 Roo.form.Action.LOAD_FAILURE = 'load';
7773 Roo.form.Action.prototype = {
7775 failureType : undefined,
7776 response : undefined,
7780 run : function(options){
7785 success : function(response){
7790 handleResponse : function(response){
7794 // default connection failure
7795 failure : function(response){
7797 this.response = response;
7798 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7799 this.form.afterAction(this, false);
7802 processResponse : function(response){
7803 this.response = response;
7804 if(!response.responseText){
7807 this.result = this.handleResponse(response);
7811 // utility functions used internally
7812 getUrl : function(appendParams){
7813 var url = this.options.url || this.form.url || this.form.el.dom.action;
7815 var p = this.getParams();
7817 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7823 getMethod : function(){
7824 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7827 getParams : function(){
7828 var bp = this.form.baseParams;
7829 var p = this.options.params;
7831 if(typeof p == "object"){
7832 p = Roo.urlEncode(Roo.applyIf(p, bp));
7833 }else if(typeof p == 'string' && bp){
7834 p += '&' + Roo.urlEncode(bp);
7837 p = Roo.urlEncode(bp);
7842 createCallback : function(){
7844 success: this.success,
7845 failure: this.failure,
7847 timeout: (this.form.timeout*1000),
7848 upload: this.form.fileUpload ? this.success : undefined
7853 Roo.form.Action.Submit = function(form, options){
7854 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7857 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7860 haveProgress : false,
7861 uploadComplete : false,
7863 // uploadProgress indicator.
7864 uploadProgress : function()
7866 if (!this.form.progressUrl) {
7870 if (!this.haveProgress) {
7871 Roo.MessageBox.progress("Uploading", "Uploading");
7873 if (this.uploadComplete) {
7874 Roo.MessageBox.hide();
7878 this.haveProgress = true;
7880 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7882 var c = new Roo.data.Connection();
7884 url : this.form.progressUrl,
7889 success : function(req){
7890 //console.log(data);
7894 rdata = Roo.decode(req.responseText)
7896 Roo.log("Invalid data from server..");
7900 if (!rdata || !rdata.success) {
7902 Roo.MessageBox.alert(Roo.encode(rdata));
7905 var data = rdata.data;
7907 if (this.uploadComplete) {
7908 Roo.MessageBox.hide();
7913 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7914 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7917 this.uploadProgress.defer(2000,this);
7920 failure: function(data) {
7921 Roo.log('progress url failed ');
7932 // run get Values on the form, so it syncs any secondary forms.
7933 this.form.getValues();
7935 var o = this.options;
7936 var method = this.getMethod();
7937 var isPost = method == 'POST';
7938 if(o.clientValidation === false || this.form.isValid()){
7940 if (this.form.progressUrl) {
7941 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7942 (new Date() * 1) + '' + Math.random());
7947 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7948 form:this.form.el.dom,
7949 url:this.getUrl(!isPost),
7951 params:isPost ? this.getParams() : null,
7952 isUpload: this.form.fileUpload,
7953 formData : this.form.formData
7956 this.uploadProgress();
7958 }else if (o.clientValidation !== false){ // client validation failed
7959 this.failureType = Roo.form.Action.CLIENT_INVALID;
7960 this.form.afterAction(this, false);
7964 success : function(response)
7966 this.uploadComplete= true;
7967 if (this.haveProgress) {
7968 Roo.MessageBox.hide();
7972 var result = this.processResponse(response);
7973 if(result === true || result.success){
7974 this.form.afterAction(this, true);
7978 this.form.markInvalid(result.errors);
7979 this.failureType = Roo.form.Action.SERVER_INVALID;
7981 this.form.afterAction(this, false);
7983 failure : function(response)
7985 this.uploadComplete= true;
7986 if (this.haveProgress) {
7987 Roo.MessageBox.hide();
7990 this.response = response;
7991 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7992 this.form.afterAction(this, false);
7995 handleResponse : function(response){
7996 if(this.form.errorReader){
7997 var rs = this.form.errorReader.read(response);
8000 for(var i = 0, len = rs.records.length; i < len; i++) {
8001 var r = rs.records[i];
8005 if(errors.length < 1){
8009 success : rs.success,
8015 ret = Roo.decode(response.responseText);
8019 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
8029 Roo.form.Action.Load = function(form, options){
8030 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
8031 this.reader = this.form.reader;
8034 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8039 Roo.Ajax.request(Roo.apply(
8040 this.createCallback(), {
8041 method:this.getMethod(),
8042 url:this.getUrl(false),
8043 params:this.getParams()
8047 success : function(response){
8049 var result = this.processResponse(response);
8050 if(result === true || !result.success || !result.data){
8051 this.failureType = Roo.form.Action.LOAD_FAILURE;
8052 this.form.afterAction(this, false);
8055 this.form.clearInvalid();
8056 this.form.setValues(result.data);
8057 this.form.afterAction(this, true);
8060 handleResponse : function(response){
8061 if(this.form.reader){
8062 var rs = this.form.reader.read(response);
8063 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8065 success : rs.success,
8069 return Roo.decode(response.responseText);
8073 Roo.form.Action.ACTION_TYPES = {
8074 'load' : Roo.form.Action.Load,
8075 'submit' : Roo.form.Action.Submit
8084 * @class Roo.bootstrap.Form
8085 * @extends Roo.bootstrap.Component
8086 * Bootstrap Form class
8087 * @cfg {String} method GET | POST (default POST)
8088 * @cfg {String} labelAlign top | left (default top)
8089 * @cfg {String} align left | right - for navbars
8090 * @cfg {Boolean} loadMask load mask when submit (default true)
8095 * @param {Object} config The config object
8099 Roo.bootstrap.Form = function(config){
8101 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8103 Roo.bootstrap.Form.popover.apply();
8107 * @event clientvalidation
8108 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8109 * @param {Form} this
8110 * @param {Boolean} valid true if the form has passed client-side validation
8112 clientvalidation: true,
8114 * @event beforeaction
8115 * Fires before any action is performed. Return false to cancel the action.
8116 * @param {Form} this
8117 * @param {Action} action The action to be performed
8121 * @event actionfailed
8122 * Fires when an action fails.
8123 * @param {Form} this
8124 * @param {Action} action The action that failed
8126 actionfailed : true,
8128 * @event actioncomplete
8129 * Fires when an action is completed.
8130 * @param {Form} this
8131 * @param {Action} action The action that completed
8133 actioncomplete : true
8137 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8140 * @cfg {String} method
8141 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8146 * The URL to use for form actions if one isn't supplied in the action options.
8149 * @cfg {Boolean} fileUpload
8150 * Set to true if this form is a file upload.
8154 * @cfg {Object} baseParams
8155 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8159 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8163 * @cfg {Sting} align (left|right) for navbar forms
8168 activeAction : null,
8171 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8172 * element by passing it or its id or mask the form itself by passing in true.
8175 waitMsgTarget : false,
8180 * @cfg {Boolean} errorMask (true|false) default false
8185 * @cfg {Number} maskOffset Default 100
8190 * @cfg {Boolean} maskBody
8194 getAutoCreate : function(){
8198 method : this.method || 'POST',
8199 id : this.id || Roo.id(),
8202 if (this.parent().xtype.match(/^Nav/)) {
8203 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8207 if (this.labelAlign == 'left' ) {
8208 cfg.cls += ' form-horizontal';
8214 initEvents : function()
8216 this.el.on('submit', this.onSubmit, this);
8217 // this was added as random key presses on the form where triggering form submit.
8218 this.el.on('keypress', function(e) {
8219 if (e.getCharCode() != 13) {
8222 // we might need to allow it for textareas.. and some other items.
8223 // check e.getTarget().
8225 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8229 Roo.log("keypress blocked");
8237 onSubmit : function(e){
8242 * Returns true if client-side validation on the form is successful.
8245 isValid : function(){
8246 var items = this.getItems();
8250 items.each(function(f){
8256 Roo.log('invalid field: ' + f.name);
8260 if(!target && f.el.isVisible(true)){
8266 if(this.errorMask && !valid){
8267 Roo.bootstrap.Form.popover.mask(this, target);
8274 * Returns true if any fields in this form have changed since their original load.
8277 isDirty : function(){
8279 var items = this.getItems();
8280 items.each(function(f){
8290 * Performs a predefined action (submit or load) or custom actions you define on this form.
8291 * @param {String} actionName The name of the action type
8292 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8293 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8294 * accept other config options):
8296 Property Type Description
8297 ---------------- --------------- ----------------------------------------------------------------------------------
8298 url String The url for the action (defaults to the form's url)
8299 method String The form method to use (defaults to the form's method, or POST if not defined)
8300 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8301 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8302 validate the form on the client (defaults to false)
8304 * @return {BasicForm} this
8306 doAction : function(action, options){
8307 if(typeof action == 'string'){
8308 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8310 if(this.fireEvent('beforeaction', this, action) !== false){
8311 this.beforeAction(action);
8312 action.run.defer(100, action);
8318 beforeAction : function(action){
8319 var o = action.options;
8324 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8326 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8329 // not really supported yet.. ??
8331 //if(this.waitMsgTarget === true){
8332 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8333 //}else if(this.waitMsgTarget){
8334 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8335 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8337 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8343 afterAction : function(action, success){
8344 this.activeAction = null;
8345 var o = action.options;
8350 Roo.get(document.body).unmask();
8356 //if(this.waitMsgTarget === true){
8357 // this.el.unmask();
8358 //}else if(this.waitMsgTarget){
8359 // this.waitMsgTarget.unmask();
8361 // Roo.MessageBox.updateProgress(1);
8362 // Roo.MessageBox.hide();
8369 Roo.callback(o.success, o.scope, [this, action]);
8370 this.fireEvent('actioncomplete', this, action);
8374 // failure condition..
8375 // we have a scenario where updates need confirming.
8376 // eg. if a locking scenario exists..
8377 // we look for { errors : { needs_confirm : true }} in the response.
8379 (typeof(action.result) != 'undefined') &&
8380 (typeof(action.result.errors) != 'undefined') &&
8381 (typeof(action.result.errors.needs_confirm) != 'undefined')
8384 Roo.log("not supported yet");
8387 Roo.MessageBox.confirm(
8388 "Change requires confirmation",
8389 action.result.errorMsg,
8394 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8404 Roo.callback(o.failure, o.scope, [this, action]);
8405 // show an error message if no failed handler is set..
8406 if (!this.hasListener('actionfailed')) {
8407 Roo.log("need to add dialog support");
8409 Roo.MessageBox.alert("Error",
8410 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8411 action.result.errorMsg :
8412 "Saving Failed, please check your entries or try again"
8417 this.fireEvent('actionfailed', this, action);
8422 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8423 * @param {String} id The value to search for
8426 findField : function(id){
8427 var items = this.getItems();
8428 var field = items.get(id);
8430 items.each(function(f){
8431 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8438 return field || null;
8441 * Mark fields in this form invalid in bulk.
8442 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8443 * @return {BasicForm} this
8445 markInvalid : function(errors){
8446 if(errors instanceof Array){
8447 for(var i = 0, len = errors.length; i < len; i++){
8448 var fieldError = errors[i];
8449 var f = this.findField(fieldError.id);
8451 f.markInvalid(fieldError.msg);
8457 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8458 field.markInvalid(errors[id]);
8462 //Roo.each(this.childForms || [], function (f) {
8463 // f.markInvalid(errors);
8470 * Set values for fields in this form in bulk.
8471 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8472 * @return {BasicForm} this
8474 setValues : function(values){
8475 if(values instanceof Array){ // array of objects
8476 for(var i = 0, len = values.length; i < len; i++){
8478 var f = this.findField(v.id);
8480 f.setValue(v.value);
8481 if(this.trackResetOnLoad){
8482 f.originalValue = f.getValue();
8486 }else{ // object hash
8489 if(typeof values[id] != 'function' && (field = this.findField(id))){
8491 if (field.setFromData &&
8493 field.displayField &&
8494 // combos' with local stores can
8495 // be queried via setValue()
8496 // to set their value..
8497 (field.store && !field.store.isLocal)
8501 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8502 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8503 field.setFromData(sd);
8505 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8507 field.setFromData(values);
8510 field.setValue(values[id]);
8514 if(this.trackResetOnLoad){
8515 field.originalValue = field.getValue();
8521 //Roo.each(this.childForms || [], function (f) {
8522 // f.setValues(values);
8529 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8530 * they are returned as an array.
8531 * @param {Boolean} asString
8534 getValues : function(asString){
8535 //if (this.childForms) {
8536 // copy values from the child forms
8537 // Roo.each(this.childForms, function (f) {
8538 // this.setValues(f.getValues());
8544 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8545 if(asString === true){
8548 return Roo.urlDecode(fs);
8552 * Returns the fields in this form as an object with key/value pairs.
8553 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8556 getFieldValues : function(with_hidden)
8558 var items = this.getItems();
8560 items.each(function(f){
8566 var v = f.getValue();
8568 if (f.inputType =='radio') {
8569 if (typeof(ret[f.getName()]) == 'undefined') {
8570 ret[f.getName()] = ''; // empty..
8573 if (!f.el.dom.checked) {
8581 if(f.xtype == 'MoneyField'){
8582 ret[f.currencyName] = f.getCurrency();
8585 // not sure if this supported any more..
8586 if ((typeof(v) == 'object') && f.getRawValue) {
8587 v = f.getRawValue() ; // dates..
8589 // combo boxes where name != hiddenName...
8590 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8591 ret[f.name] = f.getRawValue();
8593 ret[f.getName()] = v;
8600 * Clears all invalid messages in this form.
8601 * @return {BasicForm} this
8603 clearInvalid : function(){
8604 var items = this.getItems();
8606 items.each(function(f){
8615 * @return {BasicForm} this
8618 var items = this.getItems();
8619 items.each(function(f){
8623 Roo.each(this.childForms || [], function (f) {
8631 getItems : function()
8633 var r=new Roo.util.MixedCollection(false, function(o){
8634 return o.id || (o.id = Roo.id());
8636 var iter = function(el) {
8643 Roo.each(el.items,function(e) {
8652 hideFields : function(items)
8654 Roo.each(items, function(i){
8656 var f = this.findField(i);
8667 showFields : function(items)
8669 Roo.each(items, function(i){
8671 var f = this.findField(i);
8684 Roo.apply(Roo.bootstrap.Form, {
8711 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8712 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8713 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8714 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8717 this.maskEl.top.enableDisplayMode("block");
8718 this.maskEl.left.enableDisplayMode("block");
8719 this.maskEl.bottom.enableDisplayMode("block");
8720 this.maskEl.right.enableDisplayMode("block");
8722 this.toolTip = new Roo.bootstrap.Tooltip({
8723 cls : 'roo-form-error-popover',
8725 'left' : ['r-l', [-2,0], 'right'],
8726 'right' : ['l-r', [2,0], 'left'],
8727 'bottom' : ['tl-bl', [0,2], 'top'],
8728 'top' : [ 'bl-tl', [0,-2], 'bottom']
8732 this.toolTip.render(Roo.get(document.body));
8734 this.toolTip.el.enableDisplayMode("block");
8736 Roo.get(document.body).on('click', function(){
8740 Roo.get(document.body).on('touchstart', function(){
8744 this.isApplied = true
8747 mask : function(form, target)
8751 this.target = target;
8753 if(!this.form.errorMask || !target.el){
8757 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8759 Roo.log(scrollable);
8761 var ot = this.target.el.calcOffsetsTo(scrollable);
8763 var scrollTo = ot[1] - this.form.maskOffset;
8765 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8767 scrollable.scrollTo('top', scrollTo);
8769 var box = this.target.el.getBox();
8771 var zIndex = Roo.bootstrap.Modal.zIndex++;
8774 this.maskEl.top.setStyle('position', 'absolute');
8775 this.maskEl.top.setStyle('z-index', zIndex);
8776 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8777 this.maskEl.top.setLeft(0);
8778 this.maskEl.top.setTop(0);
8779 this.maskEl.top.show();
8781 this.maskEl.left.setStyle('position', 'absolute');
8782 this.maskEl.left.setStyle('z-index', zIndex);
8783 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8784 this.maskEl.left.setLeft(0);
8785 this.maskEl.left.setTop(box.y - this.padding);
8786 this.maskEl.left.show();
8788 this.maskEl.bottom.setStyle('position', 'absolute');
8789 this.maskEl.bottom.setStyle('z-index', zIndex);
8790 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8791 this.maskEl.bottom.setLeft(0);
8792 this.maskEl.bottom.setTop(box.bottom + this.padding);
8793 this.maskEl.bottom.show();
8795 this.maskEl.right.setStyle('position', 'absolute');
8796 this.maskEl.right.setStyle('z-index', zIndex);
8797 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8798 this.maskEl.right.setLeft(box.right + this.padding);
8799 this.maskEl.right.setTop(box.y - this.padding);
8800 this.maskEl.right.show();
8802 this.toolTip.bindEl = this.target.el;
8804 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8806 var tip = this.target.blankText;
8808 if(this.target.getValue() !== '' ) {
8810 if (this.target.invalidText.length) {
8811 tip = this.target.invalidText;
8812 } else if (this.target.regexText.length){
8813 tip = this.target.regexText;
8817 this.toolTip.show(tip);
8819 this.intervalID = window.setInterval(function() {
8820 Roo.bootstrap.Form.popover.unmask();
8823 window.onwheel = function(){ return false;};
8825 (function(){ this.isMasked = true; }).defer(500, this);
8831 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8835 this.maskEl.top.setStyle('position', 'absolute');
8836 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8837 this.maskEl.top.hide();
8839 this.maskEl.left.setStyle('position', 'absolute');
8840 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8841 this.maskEl.left.hide();
8843 this.maskEl.bottom.setStyle('position', 'absolute');
8844 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8845 this.maskEl.bottom.hide();
8847 this.maskEl.right.setStyle('position', 'absolute');
8848 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8849 this.maskEl.right.hide();
8851 this.toolTip.hide();
8853 this.toolTip.el.hide();
8855 window.onwheel = function(){ return true;};
8857 if(this.intervalID){
8858 window.clearInterval(this.intervalID);
8859 this.intervalID = false;
8862 this.isMasked = false;
8872 * Ext JS Library 1.1.1
8873 * Copyright(c) 2006-2007, Ext JS, LLC.
8875 * Originally Released Under LGPL - original licence link has changed is not relivant.
8878 * <script type="text/javascript">
8881 * @class Roo.form.VTypes
8882 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8885 Roo.form.VTypes = function(){
8886 // closure these in so they are only created once.
8887 var alpha = /^[a-zA-Z_]+$/;
8888 var alphanum = /^[a-zA-Z0-9_]+$/;
8889 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8890 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8892 // All these messages and functions are configurable
8895 * The function used to validate email addresses
8896 * @param {String} value The email address
8898 'email' : function(v){
8899 return email.test(v);
8902 * The error text to display when the email validation function returns false
8905 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8907 * The keystroke filter mask to be applied on email input
8910 'emailMask' : /[a-z0-9_\.\-@]/i,
8913 * The function used to validate URLs
8914 * @param {String} value The URL
8916 'url' : function(v){
8920 * The error text to display when the url validation function returns false
8923 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8926 * The function used to validate alpha values
8927 * @param {String} value The value
8929 'alpha' : function(v){
8930 return alpha.test(v);
8933 * The error text to display when the alpha validation function returns false
8936 'alphaText' : 'This field should only contain letters and _',
8938 * The keystroke filter mask to be applied on alpha input
8941 'alphaMask' : /[a-z_]/i,
8944 * The function used to validate alphanumeric values
8945 * @param {String} value The value
8947 'alphanum' : function(v){
8948 return alphanum.test(v);
8951 * The error text to display when the alphanumeric validation function returns false
8954 'alphanumText' : 'This field should only contain letters, numbers and _',
8956 * The keystroke filter mask to be applied on alphanumeric input
8959 'alphanumMask' : /[a-z0-9_]/i
8969 * @class Roo.bootstrap.Input
8970 * @extends Roo.bootstrap.Component
8971 * Bootstrap Input class
8972 * @cfg {Boolean} disabled is it disabled
8973 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8974 * @cfg {String} name name of the input
8975 * @cfg {string} fieldLabel - the label associated
8976 * @cfg {string} placeholder - placeholder to put in text.
8977 * @cfg {string} before - input group add on before
8978 * @cfg {string} after - input group add on after
8979 * @cfg {string} size - (lg|sm) or leave empty..
8980 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8981 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8982 * @cfg {Number} md colspan out of 12 for computer-sized screens
8983 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8984 * @cfg {string} value default value of the input
8985 * @cfg {Number} labelWidth set the width of label
8986 * @cfg {Number} labellg set the width of label (1-12)
8987 * @cfg {Number} labelmd set the width of label (1-12)
8988 * @cfg {Number} labelsm set the width of label (1-12)
8989 * @cfg {Number} labelxs set the width of label (1-12)
8990 * @cfg {String} labelAlign (top|left)
8991 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8992 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8993 * @cfg {String} indicatorpos (left|right) default left
8994 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8995 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8997 * @cfg {String} align (left|center|right) Default left
8998 * @cfg {Boolean} forceFeedback (true|false) Default false
9001 * Create a new Input
9002 * @param {Object} config The config object
9005 Roo.bootstrap.Input = function(config){
9007 Roo.bootstrap.Input.superclass.constructor.call(this, config);
9012 * Fires when this field receives input focus.
9013 * @param {Roo.form.Field} this
9018 * Fires when this field loses input focus.
9019 * @param {Roo.form.Field} this
9024 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
9025 * {@link Roo.EventObject#getKey} to determine which key was pressed.
9026 * @param {Roo.form.Field} this
9027 * @param {Roo.EventObject} e The event object
9032 * Fires just before the field blurs if the field value has changed.
9033 * @param {Roo.form.Field} this
9034 * @param {Mixed} newValue The new value
9035 * @param {Mixed} oldValue The original value
9040 * Fires after the field has been marked as invalid.
9041 * @param {Roo.form.Field} this
9042 * @param {String} msg The validation message
9047 * Fires after the field has been validated with no errors.
9048 * @param {Roo.form.Field} this
9053 * Fires after the key up
9054 * @param {Roo.form.Field} this
9055 * @param {Roo.EventObject} e The event Object
9061 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9063 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9064 automatic validation (defaults to "keyup").
9066 validationEvent : "keyup",
9068 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9070 validateOnBlur : true,
9072 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9074 validationDelay : 250,
9076 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9078 focusClass : "x-form-focus", // not needed???
9082 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9084 invalidClass : "has-warning",
9087 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9089 validClass : "has-success",
9092 * @cfg {Boolean} hasFeedback (true|false) default true
9097 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9099 invalidFeedbackClass : "glyphicon-warning-sign",
9102 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9104 validFeedbackClass : "glyphicon-ok",
9107 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9109 selectOnFocus : false,
9112 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9116 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9121 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9123 disableKeyFilter : false,
9126 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9130 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9134 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9136 blankText : "Please complete this mandatory field",
9139 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9143 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9145 maxLength : Number.MAX_VALUE,
9147 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9149 minLengthText : "The minimum length for this field is {0}",
9151 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9153 maxLengthText : "The maximum length for this field is {0}",
9157 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9158 * If available, this function will be called only after the basic validators all return true, and will be passed the
9159 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9163 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9164 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9165 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9169 * @cfg {String} regexText -- Depricated - use Invalid Text
9174 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9180 autocomplete: false,
9199 formatedValue : false,
9200 forceFeedback : false,
9202 indicatorpos : 'left',
9212 parentLabelAlign : function()
9215 while (parent.parent()) {
9216 parent = parent.parent();
9217 if (typeof(parent.labelAlign) !='undefined') {
9218 return parent.labelAlign;
9225 getAutoCreate : function()
9227 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9233 if(this.inputType != 'hidden'){
9234 cfg.cls = 'form-group' //input-group
9240 type : this.inputType,
9242 cls : 'form-control',
9243 placeholder : this.placeholder || '',
9244 autocomplete : this.autocomplete || 'new-password'
9247 if(this.capture.length){
9248 input.capture = this.capture;
9251 if(this.accept.length){
9252 input.accept = this.accept + "/*";
9256 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9259 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9260 input.maxLength = this.maxLength;
9263 if (this.disabled) {
9264 input.disabled=true;
9267 if (this.readOnly) {
9268 input.readonly=true;
9272 input.name = this.name;
9276 input.cls += ' input-' + this.size;
9280 ['xs','sm','md','lg'].map(function(size){
9281 if (settings[size]) {
9282 cfg.cls += ' col-' + size + '-' + settings[size];
9286 var inputblock = input;
9290 cls: 'glyphicon form-control-feedback'
9293 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9296 cls : 'has-feedback',
9304 if (this.before || this.after) {
9307 cls : 'input-group',
9311 if (this.before && typeof(this.before) == 'string') {
9313 inputblock.cn.push({
9315 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9319 if (this.before && typeof(this.before) == 'object') {
9320 this.before = Roo.factory(this.before);
9322 inputblock.cn.push({
9324 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9325 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9329 inputblock.cn.push(input);
9331 if (this.after && typeof(this.after) == 'string') {
9332 inputblock.cn.push({
9334 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9338 if (this.after && typeof(this.after) == 'object') {
9339 this.after = Roo.factory(this.after);
9341 inputblock.cn.push({
9343 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9344 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9348 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9349 inputblock.cls += ' has-feedback';
9350 inputblock.cn.push(feedback);
9355 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9356 tooltip : 'This field is required'
9358 if (Roo.bootstrap.version == 4) {
9361 style : 'display-none'
9364 if (align ==='left' && this.fieldLabel.length) {
9366 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9373 cls : 'control-label col-form-label',
9374 html : this.fieldLabel
9385 var labelCfg = cfg.cn[1];
9386 var contentCfg = cfg.cn[2];
9388 if(this.indicatorpos == 'right'){
9393 cls : 'control-label col-form-label',
9397 html : this.fieldLabel
9411 labelCfg = cfg.cn[0];
9412 contentCfg = cfg.cn[1];
9416 if(this.labelWidth > 12){
9417 labelCfg.style = "width: " + this.labelWidth + 'px';
9420 if(this.labelWidth < 13 && this.labelmd == 0){
9421 this.labelmd = this.labelWidth;
9424 if(this.labellg > 0){
9425 labelCfg.cls += ' col-lg-' + this.labellg;
9426 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9429 if(this.labelmd > 0){
9430 labelCfg.cls += ' col-md-' + this.labelmd;
9431 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9434 if(this.labelsm > 0){
9435 labelCfg.cls += ' col-sm-' + this.labelsm;
9436 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9439 if(this.labelxs > 0){
9440 labelCfg.cls += ' col-xs-' + this.labelxs;
9441 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9445 } else if ( this.fieldLabel.length) {
9450 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9451 tooltip : 'This field is required'
9455 //cls : 'input-group-addon',
9456 html : this.fieldLabel
9464 if(this.indicatorpos == 'right'){
9469 //cls : 'input-group-addon',
9470 html : this.fieldLabel
9475 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9476 tooltip : 'This field is required'
9496 if (this.parentType === 'Navbar' && this.parent().bar) {
9497 cfg.cls += ' navbar-form';
9500 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9501 // on BS4 we do this only if not form
9502 cfg.cls += ' navbar-form';
9510 * return the real input element.
9512 inputEl: function ()
9514 return this.el.select('input.form-control',true).first();
9517 tooltipEl : function()
9519 return this.inputEl();
9522 indicatorEl : function()
9524 if (Roo.bootstrap.version == 4) {
9525 return false; // not enabled in v4 yet.
9528 var indicator = this.el.select('i.roo-required-indicator',true).first();
9538 setDisabled : function(v)
9540 var i = this.inputEl().dom;
9542 i.removeAttribute('disabled');
9546 i.setAttribute('disabled','true');
9548 initEvents : function()
9551 this.inputEl().on("keydown" , this.fireKey, this);
9552 this.inputEl().on("focus", this.onFocus, this);
9553 this.inputEl().on("blur", this.onBlur, this);
9555 this.inputEl().relayEvent('keyup', this);
9557 this.indicator = this.indicatorEl();
9560 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9563 // reference to original value for reset
9564 this.originalValue = this.getValue();
9565 //Roo.form.TextField.superclass.initEvents.call(this);
9566 if(this.validationEvent == 'keyup'){
9567 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9568 this.inputEl().on('keyup', this.filterValidation, this);
9570 else if(this.validationEvent !== false){
9571 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9574 if(this.selectOnFocus){
9575 this.on("focus", this.preFocus, this);
9578 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9579 this.inputEl().on("keypress", this.filterKeys, this);
9581 this.inputEl().relayEvent('keypress', this);
9584 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9585 this.el.on("click", this.autoSize, this);
9588 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9589 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9592 if (typeof(this.before) == 'object') {
9593 this.before.render(this.el.select('.roo-input-before',true).first());
9595 if (typeof(this.after) == 'object') {
9596 this.after.render(this.el.select('.roo-input-after',true).first());
9599 this.inputEl().on('change', this.onChange, this);
9602 filterValidation : function(e){
9603 if(!e.isNavKeyPress()){
9604 this.validationTask.delay(this.validationDelay);
9608 * Validates the field value
9609 * @return {Boolean} True if the value is valid, else false
9611 validate : function(){
9612 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9613 if(this.disabled || this.validateValue(this.getRawValue())){
9624 * Validates a value according to the field's validation rules and marks the field as invalid
9625 * if the validation fails
9626 * @param {Mixed} value The value to validate
9627 * @return {Boolean} True if the value is valid, else false
9629 validateValue : function(value)
9631 if(this.getVisibilityEl().hasClass('hidden')){
9635 if(value.length < 1) { // if it's blank
9636 if(this.allowBlank){
9642 if(value.length < this.minLength){
9645 if(value.length > this.maxLength){
9649 var vt = Roo.form.VTypes;
9650 if(!vt[this.vtype](value, this)){
9654 if(typeof this.validator == "function"){
9655 var msg = this.validator(value);
9659 if (typeof(msg) == 'string') {
9660 this.invalidText = msg;
9664 if(this.regex && !this.regex.test(value)){
9672 fireKey : function(e){
9673 //Roo.log('field ' + e.getKey());
9674 if(e.isNavKeyPress()){
9675 this.fireEvent("specialkey", this, e);
9678 focus : function (selectText){
9680 this.inputEl().focus();
9681 if(selectText === true){
9682 this.inputEl().dom.select();
9688 onFocus : function(){
9689 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9690 // this.el.addClass(this.focusClass);
9693 this.hasFocus = true;
9694 this.startValue = this.getValue();
9695 this.fireEvent("focus", this);
9699 beforeBlur : Roo.emptyFn,
9703 onBlur : function(){
9705 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9706 //this.el.removeClass(this.focusClass);
9708 this.hasFocus = false;
9709 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9712 var v = this.getValue();
9713 if(String(v) !== String(this.startValue)){
9714 this.fireEvent('change', this, v, this.startValue);
9716 this.fireEvent("blur", this);
9719 onChange : function(e)
9721 var v = this.getValue();
9722 if(String(v) !== String(this.startValue)){
9723 this.fireEvent('change', this, v, this.startValue);
9729 * Resets the current field value to the originally loaded value and clears any validation messages
9732 this.setValue(this.originalValue);
9736 * Returns the name of the field
9737 * @return {Mixed} name The name field
9739 getName: function(){
9743 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9744 * @return {Mixed} value The field value
9746 getValue : function(){
9748 var v = this.inputEl().getValue();
9753 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9754 * @return {Mixed} value The field value
9756 getRawValue : function(){
9757 var v = this.inputEl().getValue();
9763 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9764 * @param {Mixed} value The value to set
9766 setRawValue : function(v){
9767 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9770 selectText : function(start, end){
9771 var v = this.getRawValue();
9773 start = start === undefined ? 0 : start;
9774 end = end === undefined ? v.length : end;
9775 var d = this.inputEl().dom;
9776 if(d.setSelectionRange){
9777 d.setSelectionRange(start, end);
9778 }else if(d.createTextRange){
9779 var range = d.createTextRange();
9780 range.moveStart("character", start);
9781 range.moveEnd("character", v.length-end);
9788 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9789 * @param {Mixed} value The value to set
9791 setValue : function(v){
9794 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9800 processValue : function(value){
9801 if(this.stripCharsRe){
9802 var newValue = value.replace(this.stripCharsRe, '');
9803 if(newValue !== value){
9804 this.setRawValue(newValue);
9811 preFocus : function(){
9813 if(this.selectOnFocus){
9814 this.inputEl().dom.select();
9817 filterKeys : function(e){
9819 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9822 var c = e.getCharCode(), cc = String.fromCharCode(c);
9823 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9826 if(!this.maskRe.test(cc)){
9831 * Clear any invalid styles/messages for this field
9833 clearInvalid : function(){
9835 if(!this.el || this.preventMark){ // not rendered
9840 this.el.removeClass([this.invalidClass, 'is-invalid']);
9842 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9844 var feedback = this.el.select('.form-control-feedback', true).first();
9847 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9853 this.indicator.removeClass('visible');
9854 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9857 this.fireEvent('valid', this);
9861 * Mark this field as valid
9863 markValid : function()
9865 if(!this.el || this.preventMark){ // not rendered...
9869 this.el.removeClass([this.invalidClass, this.validClass]);
9870 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9872 var feedback = this.el.select('.form-control-feedback', true).first();
9875 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9879 this.indicator.removeClass('visible');
9880 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9887 if(this.allowBlank && !this.getRawValue().length){
9890 if (Roo.bootstrap.version == 3) {
9891 this.el.addClass(this.validClass);
9893 this.inputEl().addClass('is-valid');
9896 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9898 var feedback = this.el.select('.form-control-feedback', true).first();
9901 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9902 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9907 this.fireEvent('valid', this);
9911 * Mark this field as invalid
9912 * @param {String} msg The validation message
9914 markInvalid : function(msg)
9916 if(!this.el || this.preventMark){ // not rendered
9920 this.el.removeClass([this.invalidClass, this.validClass]);
9921 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9923 var feedback = this.el.select('.form-control-feedback', true).first();
9926 this.el.select('.form-control-feedback', true).first().removeClass(
9927 [this.invalidFeedbackClass, this.validFeedbackClass]);
9934 if(this.allowBlank && !this.getRawValue().length){
9939 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9940 this.indicator.addClass('visible');
9942 if (Roo.bootstrap.version == 3) {
9943 this.el.addClass(this.invalidClass);
9945 this.inputEl().addClass('is-invalid');
9950 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9952 var feedback = this.el.select('.form-control-feedback', true).first();
9955 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9957 if(this.getValue().length || this.forceFeedback){
9958 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9965 this.fireEvent('invalid', this, msg);
9968 SafariOnKeyDown : function(event)
9970 // this is a workaround for a password hang bug on chrome/ webkit.
9971 if (this.inputEl().dom.type != 'password') {
9975 var isSelectAll = false;
9977 if(this.inputEl().dom.selectionEnd > 0){
9978 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9980 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9981 event.preventDefault();
9986 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9988 event.preventDefault();
9989 // this is very hacky as keydown always get's upper case.
9991 var cc = String.fromCharCode(event.getCharCode());
9992 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9996 adjustWidth : function(tag, w){
9997 tag = tag.toLowerCase();
9998 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9999 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
10000 if(tag == 'input'){
10003 if(tag == 'textarea'){
10006 }else if(Roo.isOpera){
10007 if(tag == 'input'){
10010 if(tag == 'textarea'){
10018 setFieldLabel : function(v)
10020 if(!this.rendered){
10024 if(this.indicatorEl()){
10025 var ar = this.el.select('label > span',true);
10027 if (ar.elements.length) {
10028 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10029 this.fieldLabel = v;
10033 var br = this.el.select('label',true);
10035 if(br.elements.length) {
10036 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10037 this.fieldLabel = v;
10041 Roo.log('Cannot Found any of label > span || label in input');
10045 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10046 this.fieldLabel = v;
10061 * @class Roo.bootstrap.TextArea
10062 * @extends Roo.bootstrap.Input
10063 * Bootstrap TextArea class
10064 * @cfg {Number} cols Specifies the visible width of a text area
10065 * @cfg {Number} rows Specifies the visible number of lines in a text area
10066 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10067 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10068 * @cfg {string} html text
10071 * Create a new TextArea
10072 * @param {Object} config The config object
10075 Roo.bootstrap.TextArea = function(config){
10076 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10080 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10090 getAutoCreate : function(){
10092 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10098 if(this.inputType != 'hidden'){
10099 cfg.cls = 'form-group' //input-group
10107 value : this.value || '',
10108 html: this.html || '',
10109 cls : 'form-control',
10110 placeholder : this.placeholder || ''
10114 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10115 input.maxLength = this.maxLength;
10119 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10123 input.cols = this.cols;
10126 if (this.readOnly) {
10127 input.readonly = true;
10131 input.name = this.name;
10135 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10139 ['xs','sm','md','lg'].map(function(size){
10140 if (settings[size]) {
10141 cfg.cls += ' col-' + size + '-' + settings[size];
10145 var inputblock = input;
10147 if(this.hasFeedback && !this.allowBlank){
10151 cls: 'glyphicon form-control-feedback'
10155 cls : 'has-feedback',
10164 if (this.before || this.after) {
10167 cls : 'input-group',
10171 inputblock.cn.push({
10173 cls : 'input-group-addon',
10178 inputblock.cn.push(input);
10180 if(this.hasFeedback && !this.allowBlank){
10181 inputblock.cls += ' has-feedback';
10182 inputblock.cn.push(feedback);
10186 inputblock.cn.push({
10188 cls : 'input-group-addon',
10195 if (align ==='left' && this.fieldLabel.length) {
10200 cls : 'control-label',
10201 html : this.fieldLabel
10212 if(this.labelWidth > 12){
10213 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10216 if(this.labelWidth < 13 && this.labelmd == 0){
10217 this.labelmd = this.labelWidth;
10220 if(this.labellg > 0){
10221 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10222 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10225 if(this.labelmd > 0){
10226 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10227 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10230 if(this.labelsm > 0){
10231 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10232 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10235 if(this.labelxs > 0){
10236 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10237 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10240 } else if ( this.fieldLabel.length) {
10245 //cls : 'input-group-addon',
10246 html : this.fieldLabel
10264 if (this.disabled) {
10265 input.disabled=true;
10272 * return the real textarea element.
10274 inputEl: function ()
10276 return this.el.select('textarea.form-control',true).first();
10280 * Clear any invalid styles/messages for this field
10282 clearInvalid : function()
10285 if(!this.el || this.preventMark){ // not rendered
10289 var label = this.el.select('label', true).first();
10290 var icon = this.el.select('i.fa-star', true).first();
10295 this.el.removeClass( this.validClass);
10296 this.inputEl().removeClass('is-invalid');
10298 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10300 var feedback = this.el.select('.form-control-feedback', true).first();
10303 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10308 this.fireEvent('valid', this);
10312 * Mark this field as valid
10314 markValid : function()
10316 if(!this.el || this.preventMark){ // not rendered
10320 this.el.removeClass([this.invalidClass, this.validClass]);
10321 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10323 var feedback = this.el.select('.form-control-feedback', true).first();
10326 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10329 if(this.disabled || this.allowBlank){
10333 var label = this.el.select('label', true).first();
10334 var icon = this.el.select('i.fa-star', true).first();
10339 if (Roo.bootstrap.version == 3) {
10340 this.el.addClass(this.validClass);
10342 this.inputEl().addClass('is-valid');
10346 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10348 var feedback = this.el.select('.form-control-feedback', true).first();
10351 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10352 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10357 this.fireEvent('valid', this);
10361 * Mark this field as invalid
10362 * @param {String} msg The validation message
10364 markInvalid : function(msg)
10366 if(!this.el || this.preventMark){ // not rendered
10370 this.el.removeClass([this.invalidClass, this.validClass]);
10371 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10373 var feedback = this.el.select('.form-control-feedback', true).first();
10376 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10379 if(this.disabled || this.allowBlank){
10383 var label = this.el.select('label', true).first();
10384 var icon = this.el.select('i.fa-star', true).first();
10386 if(!this.getValue().length && label && !icon){
10387 this.el.createChild({
10389 cls : 'text-danger fa fa-lg fa-star',
10390 tooltip : 'This field is required',
10391 style : 'margin-right:5px;'
10395 if (Roo.bootstrap.version == 3) {
10396 this.el.addClass(this.invalidClass);
10398 this.inputEl().addClass('is-invalid');
10401 // fixme ... this may be depricated need to test..
10402 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10404 var feedback = this.el.select('.form-control-feedback', true).first();
10407 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10409 if(this.getValue().length || this.forceFeedback){
10410 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10417 this.fireEvent('invalid', this, msg);
10425 * trigger field - base class for combo..
10430 * @class Roo.bootstrap.TriggerField
10431 * @extends Roo.bootstrap.Input
10432 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10433 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10434 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10435 * for which you can provide a custom implementation. For example:
10437 var trigger = new Roo.bootstrap.TriggerField();
10438 trigger.onTriggerClick = myTriggerFn;
10439 trigger.applyTo('my-field');
10442 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10443 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10444 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10445 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10446 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10449 * Create a new TriggerField.
10450 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10451 * to the base TextField)
10453 Roo.bootstrap.TriggerField = function(config){
10454 this.mimicing = false;
10455 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10458 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10460 * @cfg {String} triggerClass A CSS class to apply to the trigger
10463 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10468 * @cfg {Boolean} removable (true|false) special filter default false
10472 /** @cfg {Boolean} grow @hide */
10473 /** @cfg {Number} growMin @hide */
10474 /** @cfg {Number} growMax @hide */
10480 autoSize: Roo.emptyFn,
10484 deferHeight : true,
10487 actionMode : 'wrap',
10492 getAutoCreate : function(){
10494 var align = this.labelAlign || this.parentLabelAlign();
10499 cls: 'form-group' //input-group
10506 type : this.inputType,
10507 cls : 'form-control',
10508 autocomplete: 'new-password',
10509 placeholder : this.placeholder || ''
10513 input.name = this.name;
10516 input.cls += ' input-' + this.size;
10519 if (this.disabled) {
10520 input.disabled=true;
10523 var inputblock = input;
10525 if(this.hasFeedback && !this.allowBlank){
10529 cls: 'glyphicon form-control-feedback'
10532 if(this.removable && !this.editable && !this.tickable){
10534 cls : 'has-feedback',
10540 cls : 'roo-combo-removable-btn close'
10547 cls : 'has-feedback',
10556 if(this.removable && !this.editable && !this.tickable){
10558 cls : 'roo-removable',
10564 cls : 'roo-combo-removable-btn close'
10571 if (this.before || this.after) {
10574 cls : 'input-group',
10578 inputblock.cn.push({
10580 cls : 'input-group-addon input-group-prepend input-group-text',
10585 inputblock.cn.push(input);
10587 if(this.hasFeedback && !this.allowBlank){
10588 inputblock.cls += ' has-feedback';
10589 inputblock.cn.push(feedback);
10593 inputblock.cn.push({
10595 cls : 'input-group-addon input-group-append input-group-text',
10604 var ibwrap = inputblock;
10609 cls: 'roo-select2-choices',
10613 cls: 'roo-select2-search-field',
10625 cls: 'roo-select2-container input-group',
10630 cls: 'form-hidden-field'
10636 if(!this.multiple && this.showToggleBtn){
10642 if (this.caret != false) {
10645 cls: 'fa fa-' + this.caret
10652 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10657 cls: 'combobox-clear',
10671 combobox.cls += ' roo-select2-container-multi';
10675 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10676 tooltip : 'This field is required'
10678 if (Roo.bootstrap.version == 4) {
10681 style : 'display:none'
10686 if (align ==='left' && this.fieldLabel.length) {
10688 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10695 cls : 'control-label',
10696 html : this.fieldLabel
10708 var labelCfg = cfg.cn[1];
10709 var contentCfg = cfg.cn[2];
10711 if(this.indicatorpos == 'right'){
10716 cls : 'control-label',
10720 html : this.fieldLabel
10734 labelCfg = cfg.cn[0];
10735 contentCfg = cfg.cn[1];
10738 if(this.labelWidth > 12){
10739 labelCfg.style = "width: " + this.labelWidth + 'px';
10742 if(this.labelWidth < 13 && this.labelmd == 0){
10743 this.labelmd = this.labelWidth;
10746 if(this.labellg > 0){
10747 labelCfg.cls += ' col-lg-' + this.labellg;
10748 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10751 if(this.labelmd > 0){
10752 labelCfg.cls += ' col-md-' + this.labelmd;
10753 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10756 if(this.labelsm > 0){
10757 labelCfg.cls += ' col-sm-' + this.labelsm;
10758 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10761 if(this.labelxs > 0){
10762 labelCfg.cls += ' col-xs-' + this.labelxs;
10763 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10766 } else if ( this.fieldLabel.length) {
10767 // Roo.log(" label");
10772 //cls : 'input-group-addon',
10773 html : this.fieldLabel
10781 if(this.indicatorpos == 'right'){
10789 html : this.fieldLabel
10803 // Roo.log(" no label && no align");
10810 ['xs','sm','md','lg'].map(function(size){
10811 if (settings[size]) {
10812 cfg.cls += ' col-' + size + '-' + settings[size];
10823 onResize : function(w, h){
10824 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10825 // if(typeof w == 'number'){
10826 // var x = w - this.trigger.getWidth();
10827 // this.inputEl().setWidth(this.adjustWidth('input', x));
10828 // this.trigger.setStyle('left', x+'px');
10833 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10836 getResizeEl : function(){
10837 return this.inputEl();
10841 getPositionEl : function(){
10842 return this.inputEl();
10846 alignErrorIcon : function(){
10847 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10851 initEvents : function(){
10855 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10856 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10857 if(!this.multiple && this.showToggleBtn){
10858 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10859 if(this.hideTrigger){
10860 this.trigger.setDisplayed(false);
10862 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10866 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10869 if(this.removable && !this.editable && !this.tickable){
10870 var close = this.closeTriggerEl();
10873 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10874 close.on('click', this.removeBtnClick, this, close);
10878 //this.trigger.addClassOnOver('x-form-trigger-over');
10879 //this.trigger.addClassOnClick('x-form-trigger-click');
10882 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10886 closeTriggerEl : function()
10888 var close = this.el.select('.roo-combo-removable-btn', true).first();
10889 return close ? close : false;
10892 removeBtnClick : function(e, h, el)
10894 e.preventDefault();
10896 if(this.fireEvent("remove", this) !== false){
10898 this.fireEvent("afterremove", this)
10902 createList : function()
10904 this.list = Roo.get(document.body).createChild({
10905 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10906 cls: 'typeahead typeahead-long dropdown-menu',
10907 style: 'display:none'
10910 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10915 initTrigger : function(){
10920 onDestroy : function(){
10922 this.trigger.removeAllListeners();
10923 // this.trigger.remove();
10926 // this.wrap.remove();
10928 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10932 onFocus : function(){
10933 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10935 if(!this.mimicing){
10936 this.wrap.addClass('x-trigger-wrap-focus');
10937 this.mimicing = true;
10938 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10939 if(this.monitorTab){
10940 this.el.on("keydown", this.checkTab, this);
10947 checkTab : function(e){
10948 if(e.getKey() == e.TAB){
10949 this.triggerBlur();
10954 onBlur : function(){
10959 mimicBlur : function(e, t){
10961 if(!this.wrap.contains(t) && this.validateBlur()){
10962 this.triggerBlur();
10968 triggerBlur : function(){
10969 this.mimicing = false;
10970 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10971 if(this.monitorTab){
10972 this.el.un("keydown", this.checkTab, this);
10974 //this.wrap.removeClass('x-trigger-wrap-focus');
10975 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10979 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10980 validateBlur : function(e, t){
10985 onDisable : function(){
10986 this.inputEl().dom.disabled = true;
10987 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10989 // this.wrap.addClass('x-item-disabled');
10994 onEnable : function(){
10995 this.inputEl().dom.disabled = false;
10996 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10998 // this.el.removeClass('x-item-disabled');
11003 onShow : function(){
11004 var ae = this.getActionEl();
11007 ae.dom.style.display = '';
11008 ae.dom.style.visibility = 'visible';
11014 onHide : function(){
11015 var ae = this.getActionEl();
11016 ae.dom.style.display = 'none';
11020 * The function that should handle the trigger's click event. This method does nothing by default until overridden
11021 * by an implementing function.
11023 * @param {EventObject} e
11025 onTriggerClick : Roo.emptyFn
11029 * Ext JS Library 1.1.1
11030 * Copyright(c) 2006-2007, Ext JS, LLC.
11032 * Originally Released Under LGPL - original licence link has changed is not relivant.
11035 * <script type="text/javascript">
11040 * @class Roo.data.SortTypes
11042 * Defines the default sorting (casting?) comparison functions used when sorting data.
11044 Roo.data.SortTypes = {
11046 * Default sort that does nothing
11047 * @param {Mixed} s The value being converted
11048 * @return {Mixed} The comparison value
11050 none : function(s){
11055 * The regular expression used to strip tags
11059 stripTagsRE : /<\/?[^>]+>/gi,
11062 * Strips all HTML tags to sort on text only
11063 * @param {Mixed} s The value being converted
11064 * @return {String} The comparison value
11066 asText : function(s){
11067 return String(s).replace(this.stripTagsRE, "");
11071 * Strips all HTML tags to sort on text only - Case insensitive
11072 * @param {Mixed} s The value being converted
11073 * @return {String} The comparison value
11075 asUCText : function(s){
11076 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11080 * Case insensitive string
11081 * @param {Mixed} s The value being converted
11082 * @return {String} The comparison value
11084 asUCString : function(s) {
11085 return String(s).toUpperCase();
11090 * @param {Mixed} s The value being converted
11091 * @return {Number} The comparison value
11093 asDate : function(s) {
11097 if(s instanceof Date){
11098 return s.getTime();
11100 return Date.parse(String(s));
11105 * @param {Mixed} s The value being converted
11106 * @return {Float} The comparison value
11108 asFloat : function(s) {
11109 var val = parseFloat(String(s).replace(/,/g, ""));
11118 * @param {Mixed} s The value being converted
11119 * @return {Number} The comparison value
11121 asInt : function(s) {
11122 var val = parseInt(String(s).replace(/,/g, ""));
11130 * Ext JS Library 1.1.1
11131 * Copyright(c) 2006-2007, Ext JS, LLC.
11133 * Originally Released Under LGPL - original licence link has changed is not relivant.
11136 * <script type="text/javascript">
11140 * @class Roo.data.Record
11141 * Instances of this class encapsulate both record <em>definition</em> information, and record
11142 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11143 * to access Records cached in an {@link Roo.data.Store} object.<br>
11145 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11146 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11149 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11151 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11152 * {@link #create}. The parameters are the same.
11153 * @param {Array} data An associative Array of data values keyed by the field name.
11154 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11155 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11156 * not specified an integer id is generated.
11158 Roo.data.Record = function(data, id){
11159 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11164 * Generate a constructor for a specific record layout.
11165 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11166 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11167 * Each field definition object may contain the following properties: <ul>
11168 * <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,
11169 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11170 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11171 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11172 * is being used, then this is a string containing the javascript expression to reference the data relative to
11173 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11174 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11175 * this may be omitted.</p></li>
11176 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11177 * <ul><li>auto (Default, implies no conversion)</li>
11182 * <li>date</li></ul></p></li>
11183 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11184 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11185 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11186 * by the Reader into an object that will be stored in the Record. It is passed the
11187 * following parameters:<ul>
11188 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11190 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11192 * <br>usage:<br><pre><code>
11193 var TopicRecord = Roo.data.Record.create(
11194 {name: 'title', mapping: 'topic_title'},
11195 {name: 'author', mapping: 'username'},
11196 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11197 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11198 {name: 'lastPoster', mapping: 'user2'},
11199 {name: 'excerpt', mapping: 'post_text'}
11202 var myNewRecord = new TopicRecord({
11203 title: 'Do my job please',
11206 lastPost: new Date(),
11207 lastPoster: 'Animal',
11208 excerpt: 'No way dude!'
11210 myStore.add(myNewRecord);
11215 Roo.data.Record.create = function(o){
11216 var f = function(){
11217 f.superclass.constructor.apply(this, arguments);
11219 Roo.extend(f, Roo.data.Record);
11220 var p = f.prototype;
11221 p.fields = new Roo.util.MixedCollection(false, function(field){
11224 for(var i = 0, len = o.length; i < len; i++){
11225 p.fields.add(new Roo.data.Field(o[i]));
11227 f.getField = function(name){
11228 return p.fields.get(name);
11233 Roo.data.Record.AUTO_ID = 1000;
11234 Roo.data.Record.EDIT = 'edit';
11235 Roo.data.Record.REJECT = 'reject';
11236 Roo.data.Record.COMMIT = 'commit';
11238 Roo.data.Record.prototype = {
11240 * Readonly flag - true if this record has been modified.
11249 join : function(store){
11250 this.store = store;
11254 * Set the named field to the specified value.
11255 * @param {String} name The name of the field to set.
11256 * @param {Object} value The value to set the field to.
11258 set : function(name, value){
11259 if(this.data[name] == value){
11263 if(!this.modified){
11264 this.modified = {};
11266 if(typeof this.modified[name] == 'undefined'){
11267 this.modified[name] = this.data[name];
11269 this.data[name] = value;
11270 if(!this.editing && this.store){
11271 this.store.afterEdit(this);
11276 * Get the value of the named field.
11277 * @param {String} name The name of the field to get the value of.
11278 * @return {Object} The value of the field.
11280 get : function(name){
11281 return this.data[name];
11285 beginEdit : function(){
11286 this.editing = true;
11287 this.modified = {};
11291 cancelEdit : function(){
11292 this.editing = false;
11293 delete this.modified;
11297 endEdit : function(){
11298 this.editing = false;
11299 if(this.dirty && this.store){
11300 this.store.afterEdit(this);
11305 * Usually called by the {@link Roo.data.Store} which owns the Record.
11306 * Rejects all changes made to the Record since either creation, or the last commit operation.
11307 * Modified fields are reverted to their original values.
11309 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11310 * of reject operations.
11312 reject : function(){
11313 var m = this.modified;
11315 if(typeof m[n] != "function"){
11316 this.data[n] = m[n];
11319 this.dirty = false;
11320 delete this.modified;
11321 this.editing = false;
11323 this.store.afterReject(this);
11328 * Usually called by the {@link Roo.data.Store} which owns the Record.
11329 * Commits all changes made to the Record since either creation, or the last commit operation.
11331 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11332 * of commit operations.
11334 commit : function(){
11335 this.dirty = false;
11336 delete this.modified;
11337 this.editing = false;
11339 this.store.afterCommit(this);
11344 hasError : function(){
11345 return this.error != null;
11349 clearError : function(){
11354 * Creates a copy of this record.
11355 * @param {String} id (optional) A new record id if you don't want to use this record's id
11358 copy : function(newId) {
11359 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11363 * Ext JS Library 1.1.1
11364 * Copyright(c) 2006-2007, Ext JS, LLC.
11366 * Originally Released Under LGPL - original licence link has changed is not relivant.
11369 * <script type="text/javascript">
11375 * @class Roo.data.Store
11376 * @extends Roo.util.Observable
11377 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11378 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11380 * 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
11381 * has no knowledge of the format of the data returned by the Proxy.<br>
11383 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11384 * instances from the data object. These records are cached and made available through accessor functions.
11386 * Creates a new Store.
11387 * @param {Object} config A config object containing the objects needed for the Store to access data,
11388 * and read the data into Records.
11390 Roo.data.Store = function(config){
11391 this.data = new Roo.util.MixedCollection(false);
11392 this.data.getKey = function(o){
11395 this.baseParams = {};
11397 this.paramNames = {
11402 "multisort" : "_multisort"
11405 if(config && config.data){
11406 this.inlineData = config.data;
11407 delete config.data;
11410 Roo.apply(this, config);
11412 if(this.reader){ // reader passed
11413 this.reader = Roo.factory(this.reader, Roo.data);
11414 this.reader.xmodule = this.xmodule || false;
11415 if(!this.recordType){
11416 this.recordType = this.reader.recordType;
11418 if(this.reader.onMetaChange){
11419 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11423 if(this.recordType){
11424 this.fields = this.recordType.prototype.fields;
11426 this.modified = [];
11430 * @event datachanged
11431 * Fires when the data cache has changed, and a widget which is using this Store
11432 * as a Record cache should refresh its view.
11433 * @param {Store} this
11435 datachanged : true,
11437 * @event metachange
11438 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11439 * @param {Store} this
11440 * @param {Object} meta The JSON metadata
11445 * Fires when Records have been added to the Store
11446 * @param {Store} this
11447 * @param {Roo.data.Record[]} records The array of Records added
11448 * @param {Number} index The index at which the record(s) were added
11453 * Fires when a Record has been removed from the Store
11454 * @param {Store} this
11455 * @param {Roo.data.Record} record The Record that was removed
11456 * @param {Number} index The index at which the record was removed
11461 * Fires when a Record has been updated
11462 * @param {Store} this
11463 * @param {Roo.data.Record} record The Record that was updated
11464 * @param {String} operation The update operation being performed. Value may be one of:
11466 Roo.data.Record.EDIT
11467 Roo.data.Record.REJECT
11468 Roo.data.Record.COMMIT
11474 * Fires when the data cache has been cleared.
11475 * @param {Store} this
11479 * @event beforeload
11480 * Fires before a request is made for a new data object. If the beforeload handler returns false
11481 * the load action will be canceled.
11482 * @param {Store} this
11483 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11487 * @event beforeloadadd
11488 * Fires after a new set of Records has been loaded.
11489 * @param {Store} this
11490 * @param {Roo.data.Record[]} records The Records that were loaded
11491 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11493 beforeloadadd : true,
11496 * Fires after a new set of Records has been loaded, before they are added to the store.
11497 * @param {Store} this
11498 * @param {Roo.data.Record[]} records The Records that were loaded
11499 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11500 * @params {Object} return from reader
11504 * @event loadexception
11505 * Fires if an exception occurs in the Proxy during loading.
11506 * Called with the signature of the Proxy's "loadexception" event.
11507 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11510 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11511 * @param {Object} load options
11512 * @param {Object} jsonData from your request (normally this contains the Exception)
11514 loadexception : true
11518 this.proxy = Roo.factory(this.proxy, Roo.data);
11519 this.proxy.xmodule = this.xmodule || false;
11520 this.relayEvents(this.proxy, ["loadexception"]);
11522 this.sortToggle = {};
11523 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11525 Roo.data.Store.superclass.constructor.call(this);
11527 if(this.inlineData){
11528 this.loadData(this.inlineData);
11529 delete this.inlineData;
11533 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11535 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11536 * without a remote query - used by combo/forms at present.
11540 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11543 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11546 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11547 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11550 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11551 * on any HTTP request
11554 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11557 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11561 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11562 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11564 remoteSort : false,
11567 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11568 * loaded or when a record is removed. (defaults to false).
11570 pruneModifiedRecords : false,
11573 lastOptions : null,
11576 * Add Records to the Store and fires the add event.
11577 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11579 add : function(records){
11580 records = [].concat(records);
11581 for(var i = 0, len = records.length; i < len; i++){
11582 records[i].join(this);
11584 var index = this.data.length;
11585 this.data.addAll(records);
11586 this.fireEvent("add", this, records, index);
11590 * Remove a Record from the Store and fires the remove event.
11591 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11593 remove : function(record){
11594 var index = this.data.indexOf(record);
11595 this.data.removeAt(index);
11597 if(this.pruneModifiedRecords){
11598 this.modified.remove(record);
11600 this.fireEvent("remove", this, record, index);
11604 * Remove all Records from the Store and fires the clear event.
11606 removeAll : function(){
11608 if(this.pruneModifiedRecords){
11609 this.modified = [];
11611 this.fireEvent("clear", this);
11615 * Inserts Records to the Store at the given index and fires the add event.
11616 * @param {Number} index The start index at which to insert the passed Records.
11617 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11619 insert : function(index, records){
11620 records = [].concat(records);
11621 for(var i = 0, len = records.length; i < len; i++){
11622 this.data.insert(index, records[i]);
11623 records[i].join(this);
11625 this.fireEvent("add", this, records, index);
11629 * Get the index within the cache of the passed Record.
11630 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11631 * @return {Number} The index of the passed Record. Returns -1 if not found.
11633 indexOf : function(record){
11634 return this.data.indexOf(record);
11638 * Get the index within the cache of the Record with the passed id.
11639 * @param {String} id The id of the Record to find.
11640 * @return {Number} The index of the Record. Returns -1 if not found.
11642 indexOfId : function(id){
11643 return this.data.indexOfKey(id);
11647 * Get the Record with the specified id.
11648 * @param {String} id The id of the Record to find.
11649 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11651 getById : function(id){
11652 return this.data.key(id);
11656 * Get the Record at the specified index.
11657 * @param {Number} index The index of the Record to find.
11658 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11660 getAt : function(index){
11661 return this.data.itemAt(index);
11665 * Returns a range of Records between specified indices.
11666 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11667 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11668 * @return {Roo.data.Record[]} An array of Records
11670 getRange : function(start, end){
11671 return this.data.getRange(start, end);
11675 storeOptions : function(o){
11676 o = Roo.apply({}, o);
11679 this.lastOptions = o;
11683 * Loads the Record cache from the configured Proxy using the configured Reader.
11685 * If using remote paging, then the first load call must specify the <em>start</em>
11686 * and <em>limit</em> properties in the options.params property to establish the initial
11687 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11689 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11690 * and this call will return before the new data has been loaded. Perform any post-processing
11691 * in a callback function, or in a "load" event handler.</strong>
11693 * @param {Object} options An object containing properties which control loading options:<ul>
11694 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11695 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11696 * passed the following arguments:<ul>
11697 * <li>r : Roo.data.Record[]</li>
11698 * <li>options: Options object from the load call</li>
11699 * <li>success: Boolean success indicator</li></ul></li>
11700 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11701 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11704 load : function(options){
11705 options = options || {};
11706 if(this.fireEvent("beforeload", this, options) !== false){
11707 this.storeOptions(options);
11708 var p = Roo.apply(options.params || {}, this.baseParams);
11709 // if meta was not loaded from remote source.. try requesting it.
11710 if (!this.reader.metaFromRemote) {
11711 p._requestMeta = 1;
11713 if(this.sortInfo && this.remoteSort){
11714 var pn = this.paramNames;
11715 p[pn["sort"]] = this.sortInfo.field;
11716 p[pn["dir"]] = this.sortInfo.direction;
11718 if (this.multiSort) {
11719 var pn = this.paramNames;
11720 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11723 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11728 * Reloads the Record cache from the configured Proxy using the configured Reader and
11729 * the options from the last load operation performed.
11730 * @param {Object} options (optional) An object containing properties which may override the options
11731 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11732 * the most recently used options are reused).
11734 reload : function(options){
11735 this.load(Roo.applyIf(options||{}, this.lastOptions));
11739 // Called as a callback by the Reader during a load operation.
11740 loadRecords : function(o, options, success){
11741 if(!o || success === false){
11742 if(success !== false){
11743 this.fireEvent("load", this, [], options, o);
11745 if(options.callback){
11746 options.callback.call(options.scope || this, [], options, false);
11750 // if data returned failure - throw an exception.
11751 if (o.success === false) {
11752 // show a message if no listener is registered.
11753 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11754 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11756 // loadmask wil be hooked into this..
11757 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11760 var r = o.records, t = o.totalRecords || r.length;
11762 this.fireEvent("beforeloadadd", this, r, options, o);
11764 if(!options || options.add !== true){
11765 if(this.pruneModifiedRecords){
11766 this.modified = [];
11768 for(var i = 0, len = r.length; i < len; i++){
11772 this.data = this.snapshot;
11773 delete this.snapshot;
11776 this.data.addAll(r);
11777 this.totalLength = t;
11779 this.fireEvent("datachanged", this);
11781 this.totalLength = Math.max(t, this.data.length+r.length);
11785 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11787 var e = new Roo.data.Record({});
11789 e.set(this.parent.displayField, this.parent.emptyTitle);
11790 e.set(this.parent.valueField, '');
11795 this.fireEvent("load", this, r, options, o);
11796 if(options.callback){
11797 options.callback.call(options.scope || this, r, options, true);
11803 * Loads data from a passed data block. A Reader which understands the format of the data
11804 * must have been configured in the constructor.
11805 * @param {Object} data The data block from which to read the Records. The format of the data expected
11806 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11807 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11809 loadData : function(o, append){
11810 var r = this.reader.readRecords(o);
11811 this.loadRecords(r, {add: append}, true);
11815 * Gets the number of cached records.
11817 * <em>If using paging, this may not be the total size of the dataset. If the data object
11818 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11819 * the data set size</em>
11821 getCount : function(){
11822 return this.data.length || 0;
11826 * Gets the total number of records in the dataset as returned by the server.
11828 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11829 * the dataset size</em>
11831 getTotalCount : function(){
11832 return this.totalLength || 0;
11836 * Returns the sort state of the Store as an object with two properties:
11838 field {String} The name of the field by which the Records are sorted
11839 direction {String} The sort order, "ASC" or "DESC"
11842 getSortState : function(){
11843 return this.sortInfo;
11847 applySort : function(){
11848 if(this.sortInfo && !this.remoteSort){
11849 var s = this.sortInfo, f = s.field;
11850 var st = this.fields.get(f).sortType;
11851 var fn = function(r1, r2){
11852 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11853 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11855 this.data.sort(s.direction, fn);
11856 if(this.snapshot && this.snapshot != this.data){
11857 this.snapshot.sort(s.direction, fn);
11863 * Sets the default sort column and order to be used by the next load operation.
11864 * @param {String} fieldName The name of the field to sort by.
11865 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11867 setDefaultSort : function(field, dir){
11868 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11872 * Sort the Records.
11873 * If remote sorting is used, the sort is performed on the server, and the cache is
11874 * reloaded. If local sorting is used, the cache is sorted internally.
11875 * @param {String} fieldName The name of the field to sort by.
11876 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11878 sort : function(fieldName, dir){
11879 var f = this.fields.get(fieldName);
11881 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11883 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11884 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11889 this.sortToggle[f.name] = dir;
11890 this.sortInfo = {field: f.name, direction: dir};
11891 if(!this.remoteSort){
11893 this.fireEvent("datachanged", this);
11895 this.load(this.lastOptions);
11900 * Calls the specified function for each of the Records in the cache.
11901 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11902 * Returning <em>false</em> aborts and exits the iteration.
11903 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11905 each : function(fn, scope){
11906 this.data.each(fn, scope);
11910 * Gets all records modified since the last commit. Modified records are persisted across load operations
11911 * (e.g., during paging).
11912 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11914 getModifiedRecords : function(){
11915 return this.modified;
11919 createFilterFn : function(property, value, anyMatch){
11920 if(!value.exec){ // not a regex
11921 value = String(value);
11922 if(value.length == 0){
11925 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11927 return function(r){
11928 return value.test(r.data[property]);
11933 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11934 * @param {String} property A field on your records
11935 * @param {Number} start The record index to start at (defaults to 0)
11936 * @param {Number} end The last record index to include (defaults to length - 1)
11937 * @return {Number} The sum
11939 sum : function(property, start, end){
11940 var rs = this.data.items, v = 0;
11941 start = start || 0;
11942 end = (end || end === 0) ? end : rs.length-1;
11944 for(var i = start; i <= end; i++){
11945 v += (rs[i].data[property] || 0);
11951 * Filter the records by a specified property.
11952 * @param {String} field A field on your records
11953 * @param {String/RegExp} value Either a string that the field
11954 * should start with or a RegExp to test against the field
11955 * @param {Boolean} anyMatch True to match any part not just the beginning
11957 filter : function(property, value, anyMatch){
11958 var fn = this.createFilterFn(property, value, anyMatch);
11959 return fn ? this.filterBy(fn) : this.clearFilter();
11963 * Filter by a function. The specified function will be called with each
11964 * record in this data source. If the function returns true the record is included,
11965 * otherwise it is filtered.
11966 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11967 * @param {Object} scope (optional) The scope of the function (defaults to this)
11969 filterBy : function(fn, scope){
11970 this.snapshot = this.snapshot || this.data;
11971 this.data = this.queryBy(fn, scope||this);
11972 this.fireEvent("datachanged", this);
11976 * Query the records by a specified property.
11977 * @param {String} field A field on your records
11978 * @param {String/RegExp} value Either a string that the field
11979 * should start with or a RegExp to test against the field
11980 * @param {Boolean} anyMatch True to match any part not just the beginning
11981 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11983 query : function(property, value, anyMatch){
11984 var fn = this.createFilterFn(property, value, anyMatch);
11985 return fn ? this.queryBy(fn) : this.data.clone();
11989 * Query by a function. The specified function will be called with each
11990 * record in this data source. If the function returns true the record is included
11992 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11993 * @param {Object} scope (optional) The scope of the function (defaults to this)
11994 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11996 queryBy : function(fn, scope){
11997 var data = this.snapshot || this.data;
11998 return data.filterBy(fn, scope||this);
12002 * Collects unique values for a particular dataIndex from this store.
12003 * @param {String} dataIndex The property to collect
12004 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
12005 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
12006 * @return {Array} An array of the unique values
12008 collect : function(dataIndex, allowNull, bypassFilter){
12009 var d = (bypassFilter === true && this.snapshot) ?
12010 this.snapshot.items : this.data.items;
12011 var v, sv, r = [], l = {};
12012 for(var i = 0, len = d.length; i < len; i++){
12013 v = d[i].data[dataIndex];
12015 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
12024 * Revert to a view of the Record cache with no filtering applied.
12025 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
12027 clearFilter : function(suppressEvent){
12028 if(this.snapshot && this.snapshot != this.data){
12029 this.data = this.snapshot;
12030 delete this.snapshot;
12031 if(suppressEvent !== true){
12032 this.fireEvent("datachanged", this);
12038 afterEdit : function(record){
12039 if(this.modified.indexOf(record) == -1){
12040 this.modified.push(record);
12042 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12046 afterReject : function(record){
12047 this.modified.remove(record);
12048 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12052 afterCommit : function(record){
12053 this.modified.remove(record);
12054 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12058 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12059 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12061 commitChanges : function(){
12062 var m = this.modified.slice(0);
12063 this.modified = [];
12064 for(var i = 0, len = m.length; i < len; i++){
12070 * Cancel outstanding changes on all changed records.
12072 rejectChanges : function(){
12073 var m = this.modified.slice(0);
12074 this.modified = [];
12075 for(var i = 0, len = m.length; i < len; i++){
12080 onMetaChange : function(meta, rtype, o){
12081 this.recordType = rtype;
12082 this.fields = rtype.prototype.fields;
12083 delete this.snapshot;
12084 this.sortInfo = meta.sortInfo || this.sortInfo;
12085 this.modified = [];
12086 this.fireEvent('metachange', this, this.reader.meta);
12089 moveIndex : function(data, type)
12091 var index = this.indexOf(data);
12093 var newIndex = index + type;
12097 this.insert(newIndex, data);
12102 * Ext JS Library 1.1.1
12103 * Copyright(c) 2006-2007, Ext JS, LLC.
12105 * Originally Released Under LGPL - original licence link has changed is not relivant.
12108 * <script type="text/javascript">
12112 * @class Roo.data.SimpleStore
12113 * @extends Roo.data.Store
12114 * Small helper class to make creating Stores from Array data easier.
12115 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12116 * @cfg {Array} fields An array of field definition objects, or field name strings.
12117 * @cfg {Array} data The multi-dimensional array of data
12119 * @param {Object} config
12121 Roo.data.SimpleStore = function(config){
12122 Roo.data.SimpleStore.superclass.constructor.call(this, {
12124 reader: new Roo.data.ArrayReader({
12127 Roo.data.Record.create(config.fields)
12129 proxy : new Roo.data.MemoryProxy(config.data)
12133 Roo.extend(Roo.data.SimpleStore, 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">
12146 * @extends Roo.data.Store
12147 * @class Roo.data.JsonStore
12148 * Small helper class to make creating Stores for JSON data easier. <br/>
12150 var store = new Roo.data.JsonStore({
12151 url: 'get-images.php',
12153 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12156 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12157 * JsonReader and HttpProxy (unless inline data is provided).</b>
12158 * @cfg {Array} fields An array of field definition objects, or field name strings.
12160 * @param {Object} config
12162 Roo.data.JsonStore = function(c){
12163 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12164 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12165 reader: new Roo.data.JsonReader(c, c.fields)
12168 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12170 * Ext JS Library 1.1.1
12171 * Copyright(c) 2006-2007, Ext JS, LLC.
12173 * Originally Released Under LGPL - original licence link has changed is not relivant.
12176 * <script type="text/javascript">
12180 Roo.data.Field = function(config){
12181 if(typeof config == "string"){
12182 config = {name: config};
12184 Roo.apply(this, config);
12187 this.type = "auto";
12190 var st = Roo.data.SortTypes;
12191 // named sortTypes are supported, here we look them up
12192 if(typeof this.sortType == "string"){
12193 this.sortType = st[this.sortType];
12196 // set default sortType for strings and dates
12197 if(!this.sortType){
12200 this.sortType = st.asUCString;
12203 this.sortType = st.asDate;
12206 this.sortType = st.none;
12211 var stripRe = /[\$,%]/g;
12213 // prebuilt conversion function for this field, instead of
12214 // switching every time we're reading a value
12216 var cv, dateFormat = this.dateFormat;
12221 cv = function(v){ return v; };
12224 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12228 return v !== undefined && v !== null && v !== '' ?
12229 parseInt(String(v).replace(stripRe, ""), 10) : '';
12234 return v !== undefined && v !== null && v !== '' ?
12235 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12240 cv = function(v){ return v === true || v === "true" || v == 1; };
12247 if(v instanceof Date){
12251 if(dateFormat == "timestamp"){
12252 return new Date(v*1000);
12254 return Date.parseDate(v, dateFormat);
12256 var parsed = Date.parse(v);
12257 return parsed ? new Date(parsed) : null;
12266 Roo.data.Field.prototype = {
12274 * Ext JS Library 1.1.1
12275 * Copyright(c) 2006-2007, Ext JS, LLC.
12277 * Originally Released Under LGPL - original licence link has changed is not relivant.
12280 * <script type="text/javascript">
12283 // Base class for reading structured data from a data source. This class is intended to be
12284 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12287 * @class Roo.data.DataReader
12288 * Base class for reading structured data from a data source. This class is intended to be
12289 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12292 Roo.data.DataReader = function(meta, recordType){
12296 this.recordType = recordType instanceof Array ?
12297 Roo.data.Record.create(recordType) : recordType;
12300 Roo.data.DataReader.prototype = {
12302 * Create an empty record
12303 * @param {Object} data (optional) - overlay some values
12304 * @return {Roo.data.Record} record created.
12306 newRow : function(d) {
12308 this.recordType.prototype.fields.each(function(c) {
12310 case 'int' : da[c.name] = 0; break;
12311 case 'date' : da[c.name] = new Date(); break;
12312 case 'float' : da[c.name] = 0.0; break;
12313 case 'boolean' : da[c.name] = false; break;
12314 default : da[c.name] = ""; break;
12318 return new this.recordType(Roo.apply(da, d));
12323 * Ext JS Library 1.1.1
12324 * Copyright(c) 2006-2007, Ext JS, LLC.
12326 * Originally Released Under LGPL - original licence link has changed is not relivant.
12329 * <script type="text/javascript">
12333 * @class Roo.data.DataProxy
12334 * @extends Roo.data.Observable
12335 * This class is an abstract base class for implementations which provide retrieval of
12336 * unformatted data objects.<br>
12338 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12339 * (of the appropriate type which knows how to parse the data object) to provide a block of
12340 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12342 * Custom implementations must implement the load method as described in
12343 * {@link Roo.data.HttpProxy#load}.
12345 Roo.data.DataProxy = function(){
12348 * @event beforeload
12349 * Fires before a network request is made to retrieve a data object.
12350 * @param {Object} This DataProxy object.
12351 * @param {Object} params The params parameter to the load function.
12356 * Fires before the load method's callback is called.
12357 * @param {Object} This DataProxy object.
12358 * @param {Object} o The data object.
12359 * @param {Object} arg The callback argument object passed to the load function.
12363 * @event loadexception
12364 * Fires if an Exception occurs during data retrieval.
12365 * @param {Object} This DataProxy object.
12366 * @param {Object} o The data object.
12367 * @param {Object} arg The callback argument object passed to the load function.
12368 * @param {Object} e The Exception.
12370 loadexception : true
12372 Roo.data.DataProxy.superclass.constructor.call(this);
12375 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12378 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12382 * Ext JS Library 1.1.1
12383 * Copyright(c) 2006-2007, Ext JS, LLC.
12385 * Originally Released Under LGPL - original licence link has changed is not relivant.
12388 * <script type="text/javascript">
12391 * @class Roo.data.MemoryProxy
12392 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12393 * to the Reader when its load method is called.
12395 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12397 Roo.data.MemoryProxy = function(data){
12401 Roo.data.MemoryProxy.superclass.constructor.call(this);
12405 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12408 * Load data from the requested source (in this case an in-memory
12409 * data object passed to the constructor), read the data object into
12410 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12411 * process that block using the passed callback.
12412 * @param {Object} params This parameter is not used by the MemoryProxy class.
12413 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12414 * object into a block of Roo.data.Records.
12415 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12416 * The function must be passed <ul>
12417 * <li>The Record block object</li>
12418 * <li>The "arg" argument from the load function</li>
12419 * <li>A boolean success indicator</li>
12421 * @param {Object} scope The scope in which to call the callback
12422 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12424 load : function(params, reader, callback, scope, arg){
12425 params = params || {};
12428 result = reader.readRecords(params.data ? params.data :this.data);
12430 this.fireEvent("loadexception", this, arg, null, e);
12431 callback.call(scope, null, arg, false);
12434 callback.call(scope, result, arg, true);
12438 update : function(params, records){
12443 * Ext JS Library 1.1.1
12444 * Copyright(c) 2006-2007, Ext JS, LLC.
12446 * Originally Released Under LGPL - original licence link has changed is not relivant.
12449 * <script type="text/javascript">
12452 * @class Roo.data.HttpProxy
12453 * @extends Roo.data.DataProxy
12454 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12455 * configured to reference a certain URL.<br><br>
12457 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12458 * from which the running page was served.<br><br>
12460 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12462 * Be aware that to enable the browser to parse an XML document, the server must set
12463 * the Content-Type header in the HTTP response to "text/xml".
12465 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12466 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12467 * will be used to make the request.
12469 Roo.data.HttpProxy = function(conn){
12470 Roo.data.HttpProxy.superclass.constructor.call(this);
12471 // is conn a conn config or a real conn?
12473 this.useAjax = !conn || !conn.events;
12477 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12478 // thse are take from connection...
12481 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12484 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12485 * extra parameters to each request made by this object. (defaults to undefined)
12488 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12489 * to each request made by this object. (defaults to undefined)
12492 * @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)
12495 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12498 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12504 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12508 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12509 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12510 * a finer-grained basis than the DataProxy events.
12512 getConnection : function(){
12513 return this.useAjax ? Roo.Ajax : this.conn;
12517 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12518 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12519 * process that block using the passed callback.
12520 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12521 * for the request to the remote server.
12522 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12523 * object into a block of Roo.data.Records.
12524 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12525 * The function must be passed <ul>
12526 * <li>The Record block object</li>
12527 * <li>The "arg" argument from the load function</li>
12528 * <li>A boolean success indicator</li>
12530 * @param {Object} scope The scope in which to call the callback
12531 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12533 load : function(params, reader, callback, scope, arg){
12534 if(this.fireEvent("beforeload", this, params) !== false){
12536 params : params || {},
12538 callback : callback,
12543 callback : this.loadResponse,
12547 Roo.applyIf(o, this.conn);
12548 if(this.activeRequest){
12549 Roo.Ajax.abort(this.activeRequest);
12551 this.activeRequest = Roo.Ajax.request(o);
12553 this.conn.request(o);
12556 callback.call(scope||this, null, arg, false);
12561 loadResponse : function(o, success, response){
12562 delete this.activeRequest;
12564 this.fireEvent("loadexception", this, o, response);
12565 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12570 result = o.reader.read(response);
12572 this.fireEvent("loadexception", this, o, response, e);
12573 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12577 this.fireEvent("load", this, o, o.request.arg);
12578 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12582 update : function(dataSet){
12587 updateResponse : function(dataSet){
12592 * Ext JS Library 1.1.1
12593 * Copyright(c) 2006-2007, Ext JS, LLC.
12595 * Originally Released Under LGPL - original licence link has changed is not relivant.
12598 * <script type="text/javascript">
12602 * @class Roo.data.ScriptTagProxy
12603 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12604 * other than the originating domain of the running page.<br><br>
12606 * <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
12607 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12609 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12610 * source code that is used as the source inside a <script> tag.<br><br>
12612 * In order for the browser to process the returned data, the server must wrap the data object
12613 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12614 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12615 * depending on whether the callback name was passed:
12618 boolean scriptTag = false;
12619 String cb = request.getParameter("callback");
12622 response.setContentType("text/javascript");
12624 response.setContentType("application/x-json");
12626 Writer out = response.getWriter();
12628 out.write(cb + "(");
12630 out.print(dataBlock.toJsonString());
12637 * @param {Object} config A configuration object.
12639 Roo.data.ScriptTagProxy = function(config){
12640 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12641 Roo.apply(this, config);
12642 this.head = document.getElementsByTagName("head")[0];
12645 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12647 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12649 * @cfg {String} url The URL from which to request the data object.
12652 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12656 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12657 * the server the name of the callback function set up by the load call to process the returned data object.
12658 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12659 * javascript output which calls this named function passing the data object as its only parameter.
12661 callbackParam : "callback",
12663 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12664 * name to the request.
12669 * Load data from the configured URL, read the data object into
12670 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12671 * process that block using the passed callback.
12672 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12673 * for the request to the remote server.
12674 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12675 * object into a block of Roo.data.Records.
12676 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12677 * The function must be passed <ul>
12678 * <li>The Record block object</li>
12679 * <li>The "arg" argument from the load function</li>
12680 * <li>A boolean success indicator</li>
12682 * @param {Object} scope The scope in which to call the callback
12683 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12685 load : function(params, reader, callback, scope, arg){
12686 if(this.fireEvent("beforeload", this, params) !== false){
12688 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12690 var url = this.url;
12691 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12693 url += "&_dc=" + (new Date().getTime());
12695 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12698 cb : "stcCallback"+transId,
12699 scriptId : "stcScript"+transId,
12703 callback : callback,
12709 window[trans.cb] = function(o){
12710 conn.handleResponse(o, trans);
12713 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12715 if(this.autoAbort !== false){
12719 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12721 var script = document.createElement("script");
12722 script.setAttribute("src", url);
12723 script.setAttribute("type", "text/javascript");
12724 script.setAttribute("id", trans.scriptId);
12725 this.head.appendChild(script);
12727 this.trans = trans;
12729 callback.call(scope||this, null, arg, false);
12734 isLoading : function(){
12735 return this.trans ? true : false;
12739 * Abort the current server request.
12741 abort : function(){
12742 if(this.isLoading()){
12743 this.destroyTrans(this.trans);
12748 destroyTrans : function(trans, isLoaded){
12749 this.head.removeChild(document.getElementById(trans.scriptId));
12750 clearTimeout(trans.timeoutId);
12752 window[trans.cb] = undefined;
12754 delete window[trans.cb];
12757 // if hasn't been loaded, wait for load to remove it to prevent script error
12758 window[trans.cb] = function(){
12759 window[trans.cb] = undefined;
12761 delete window[trans.cb];
12768 handleResponse : function(o, trans){
12769 this.trans = false;
12770 this.destroyTrans(trans, true);
12773 result = trans.reader.readRecords(o);
12775 this.fireEvent("loadexception", this, o, trans.arg, e);
12776 trans.callback.call(trans.scope||window, null, trans.arg, false);
12779 this.fireEvent("load", this, o, trans.arg);
12780 trans.callback.call(trans.scope||window, result, trans.arg, true);
12784 handleFailure : function(trans){
12785 this.trans = false;
12786 this.destroyTrans(trans, false);
12787 this.fireEvent("loadexception", this, null, trans.arg);
12788 trans.callback.call(trans.scope||window, null, trans.arg, false);
12792 * Ext JS Library 1.1.1
12793 * Copyright(c) 2006-2007, Ext JS, LLC.
12795 * Originally Released Under LGPL - original licence link has changed is not relivant.
12798 * <script type="text/javascript">
12802 * @class Roo.data.JsonReader
12803 * @extends Roo.data.DataReader
12804 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12805 * based on mappings in a provided Roo.data.Record constructor.
12807 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12808 * in the reply previously.
12813 var RecordDef = Roo.data.Record.create([
12814 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12815 {name: 'occupation'} // This field will use "occupation" as the mapping.
12817 var myReader = new Roo.data.JsonReader({
12818 totalProperty: "results", // The property which contains the total dataset size (optional)
12819 root: "rows", // The property which contains an Array of row objects
12820 id: "id" // The property within each row object that provides an ID for the record (optional)
12824 * This would consume a JSON file like this:
12826 { 'results': 2, 'rows': [
12827 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12828 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12831 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12832 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12833 * paged from the remote server.
12834 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12835 * @cfg {String} root name of the property which contains the Array of row objects.
12836 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12837 * @cfg {Array} fields Array of field definition objects
12839 * Create a new JsonReader
12840 * @param {Object} meta Metadata configuration options
12841 * @param {Object} recordType Either an Array of field definition objects,
12842 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12844 Roo.data.JsonReader = function(meta, recordType){
12847 // set some defaults:
12848 Roo.applyIf(meta, {
12849 totalProperty: 'total',
12850 successProperty : 'success',
12855 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12857 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12860 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12861 * Used by Store query builder to append _requestMeta to params.
12864 metaFromRemote : false,
12866 * This method is only used by a DataProxy which has retrieved data from a remote server.
12867 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12868 * @return {Object} data A data block which is used by an Roo.data.Store object as
12869 * a cache of Roo.data.Records.
12871 read : function(response){
12872 var json = response.responseText;
12874 var o = /* eval:var:o */ eval("("+json+")");
12876 throw {message: "JsonReader.read: Json object not found"};
12882 this.metaFromRemote = true;
12883 this.meta = o.metaData;
12884 this.recordType = Roo.data.Record.create(o.metaData.fields);
12885 this.onMetaChange(this.meta, this.recordType, o);
12887 return this.readRecords(o);
12890 // private function a store will implement
12891 onMetaChange : function(meta, recordType, o){
12898 simpleAccess: function(obj, subsc) {
12905 getJsonAccessor: function(){
12907 return function(expr) {
12909 return(re.test(expr))
12910 ? new Function("obj", "return obj." + expr)
12915 return Roo.emptyFn;
12920 * Create a data block containing Roo.data.Records from an XML document.
12921 * @param {Object} o An object which contains an Array of row objects in the property specified
12922 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12923 * which contains the total size of the dataset.
12924 * @return {Object} data A data block which is used by an Roo.data.Store object as
12925 * a cache of Roo.data.Records.
12927 readRecords : function(o){
12929 * After any data loads, the raw JSON data is available for further custom processing.
12933 var s = this.meta, Record = this.recordType,
12934 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12936 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12938 if(s.totalProperty) {
12939 this.getTotal = this.getJsonAccessor(s.totalProperty);
12941 if(s.successProperty) {
12942 this.getSuccess = this.getJsonAccessor(s.successProperty);
12944 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12946 var g = this.getJsonAccessor(s.id);
12947 this.getId = function(rec) {
12949 return (r === undefined || r === "") ? null : r;
12952 this.getId = function(){return null;};
12955 for(var jj = 0; jj < fl; jj++){
12957 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12958 this.ef[jj] = this.getJsonAccessor(map);
12962 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12963 if(s.totalProperty){
12964 var vt = parseInt(this.getTotal(o), 10);
12969 if(s.successProperty){
12970 var vs = this.getSuccess(o);
12971 if(vs === false || vs === 'false'){
12976 for(var i = 0; i < c; i++){
12979 var id = this.getId(n);
12980 for(var j = 0; j < fl; j++){
12982 var v = this.ef[j](n);
12984 Roo.log('missing convert for ' + f.name);
12988 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12990 var record = new Record(values, id);
12992 records[i] = record;
12998 totalRecords : totalRecords
13003 * Ext JS Library 1.1.1
13004 * Copyright(c) 2006-2007, Ext JS, LLC.
13006 * Originally Released Under LGPL - original licence link has changed is not relivant.
13009 * <script type="text/javascript">
13013 * @class Roo.data.ArrayReader
13014 * @extends Roo.data.DataReader
13015 * Data reader class to create an Array of Roo.data.Record objects from an Array.
13016 * Each element of that Array represents a row of data fields. The
13017 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
13018 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
13022 var RecordDef = Roo.data.Record.create([
13023 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
13024 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
13026 var myReader = new Roo.data.ArrayReader({
13027 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
13031 * This would consume an Array like this:
13033 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13037 * Create a new JsonReader
13038 * @param {Object} meta Metadata configuration options.
13039 * @param {Object|Array} recordType Either an Array of field definition objects
13041 * @cfg {Array} fields Array of field definition objects
13042 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
13043 * as specified to {@link Roo.data.Record#create},
13044 * or an {@link Roo.data.Record} object
13047 * created using {@link Roo.data.Record#create}.
13049 Roo.data.ArrayReader = function(meta, recordType){
13052 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13055 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13057 * Create a data block containing Roo.data.Records from an XML document.
13058 * @param {Object} o An Array of row objects which represents the dataset.
13059 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
13060 * a cache of Roo.data.Records.
13062 readRecords : function(o){
13063 var sid = this.meta ? this.meta.id : null;
13064 var recordType = this.recordType, fields = recordType.prototype.fields;
13067 for(var i = 0; i < root.length; i++){
13070 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13071 for(var j = 0, jlen = fields.length; j < jlen; j++){
13072 var f = fields.items[j];
13073 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13074 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13076 values[f.name] = v;
13078 var record = new recordType(values, id);
13080 records[records.length] = record;
13084 totalRecords : records.length
13093 * @class Roo.bootstrap.ComboBox
13094 * @extends Roo.bootstrap.TriggerField
13095 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13096 * @cfg {Boolean} append (true|false) default false
13097 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13098 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13099 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13100 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13101 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13102 * @cfg {Boolean} animate default true
13103 * @cfg {Boolean} emptyResultText only for touch device
13104 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13105 * @cfg {String} emptyTitle default ''
13107 * Create a new ComboBox.
13108 * @param {Object} config Configuration options
13110 Roo.bootstrap.ComboBox = function(config){
13111 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13115 * Fires when the dropdown list is expanded
13116 * @param {Roo.bootstrap.ComboBox} combo This combo box
13121 * Fires when the dropdown list is collapsed
13122 * @param {Roo.bootstrap.ComboBox} combo This combo box
13126 * @event beforeselect
13127 * Fires before a list item is selected. Return false to cancel the selection.
13128 * @param {Roo.bootstrap.ComboBox} combo This combo box
13129 * @param {Roo.data.Record} record The data record returned from the underlying store
13130 * @param {Number} index The index of the selected item in the dropdown list
13132 'beforeselect' : true,
13135 * Fires when a list item is selected
13136 * @param {Roo.bootstrap.ComboBox} combo This combo box
13137 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13138 * @param {Number} index The index of the selected item in the dropdown list
13142 * @event beforequery
13143 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13144 * The event object passed has these properties:
13145 * @param {Roo.bootstrap.ComboBox} combo This combo box
13146 * @param {String} query The query
13147 * @param {Boolean} forceAll true to force "all" query
13148 * @param {Boolean} cancel true to cancel the query
13149 * @param {Object} e The query event object
13151 'beforequery': true,
13154 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13155 * @param {Roo.bootstrap.ComboBox} combo This combo box
13160 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13161 * @param {Roo.bootstrap.ComboBox} combo This combo box
13162 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13167 * Fires when the remove value from the combobox array
13168 * @param {Roo.bootstrap.ComboBox} combo This combo box
13172 * @event afterremove
13173 * Fires when the remove value from the combobox array
13174 * @param {Roo.bootstrap.ComboBox} combo This combo box
13176 'afterremove' : true,
13178 * @event specialfilter
13179 * Fires when specialfilter
13180 * @param {Roo.bootstrap.ComboBox} combo This combo box
13182 'specialfilter' : true,
13185 * Fires when tick the element
13186 * @param {Roo.bootstrap.ComboBox} combo This combo box
13190 * @event touchviewdisplay
13191 * Fires when touch view require special display (default is using displayField)
13192 * @param {Roo.bootstrap.ComboBox} combo This combo box
13193 * @param {Object} cfg set html .
13195 'touchviewdisplay' : true
13200 this.tickItems = [];
13202 this.selectedIndex = -1;
13203 if(this.mode == 'local'){
13204 if(config.queryDelay === undefined){
13205 this.queryDelay = 10;
13207 if(config.minChars === undefined){
13213 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13216 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13217 * rendering into an Roo.Editor, defaults to false)
13220 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13221 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13224 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13227 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13228 * the dropdown list (defaults to undefined, with no header element)
13232 * @cfg {String/Roo.Template} tpl The template to use to render the output
13236 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13238 listWidth: undefined,
13240 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13241 * mode = 'remote' or 'text' if mode = 'local')
13243 displayField: undefined,
13246 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13247 * mode = 'remote' or 'value' if mode = 'local').
13248 * Note: use of a valueField requires the user make a selection
13249 * in order for a value to be mapped.
13251 valueField: undefined,
13253 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13258 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13259 * field's data value (defaults to the underlying DOM element's name)
13261 hiddenName: undefined,
13263 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13267 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13269 selectedClass: 'active',
13272 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13276 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13277 * anchor positions (defaults to 'tl-bl')
13279 listAlign: 'tl-bl?',
13281 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13285 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13286 * query specified by the allQuery config option (defaults to 'query')
13288 triggerAction: 'query',
13290 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13291 * (defaults to 4, does not apply if editable = false)
13295 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13296 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13300 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13301 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13305 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13306 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13310 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13311 * when editable = true (defaults to false)
13313 selectOnFocus:false,
13315 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13317 queryParam: 'query',
13319 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13320 * when mode = 'remote' (defaults to 'Loading...')
13322 loadingText: 'Loading...',
13324 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13328 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13332 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13333 * traditional select (defaults to true)
13337 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13341 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13345 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13346 * listWidth has a higher value)
13350 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13351 * allow the user to set arbitrary text into the field (defaults to false)
13353 forceSelection:false,
13355 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13356 * if typeAhead = true (defaults to 250)
13358 typeAheadDelay : 250,
13360 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13361 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13363 valueNotFoundText : undefined,
13365 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13367 blockFocus : false,
13370 * @cfg {Boolean} disableClear Disable showing of clear button.
13372 disableClear : false,
13374 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13376 alwaysQuery : false,
13379 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13384 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13386 invalidClass : "has-warning",
13389 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13391 validClass : "has-success",
13394 * @cfg {Boolean} specialFilter (true|false) special filter default false
13396 specialFilter : false,
13399 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13401 mobileTouchView : true,
13404 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13406 useNativeIOS : false,
13409 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13411 mobile_restrict_height : false,
13413 ios_options : false,
13425 btnPosition : 'right',
13426 triggerList : true,
13427 showToggleBtn : true,
13429 emptyResultText: 'Empty',
13430 triggerText : 'Select',
13433 // element that contains real text value.. (when hidden is used..)
13435 getAutoCreate : function()
13440 * Render classic select for iso
13443 if(Roo.isIOS && this.useNativeIOS){
13444 cfg = this.getAutoCreateNativeIOS();
13452 if(Roo.isTouch && this.mobileTouchView){
13453 cfg = this.getAutoCreateTouchView();
13460 if(!this.tickable){
13461 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13466 * ComboBox with tickable selections
13469 var align = this.labelAlign || this.parentLabelAlign();
13472 cls : 'form-group roo-combobox-tickable' //input-group
13475 var btn_text_select = '';
13476 var btn_text_done = '';
13477 var btn_text_cancel = '';
13479 if (this.btn_text_show) {
13480 btn_text_select = 'Select';
13481 btn_text_done = 'Done';
13482 btn_text_cancel = 'Cancel';
13487 cls : 'tickable-buttons',
13492 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13493 //html : this.triggerText
13494 html: btn_text_select
13500 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13502 html: btn_text_done
13508 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13510 html: btn_text_cancel
13516 buttons.cn.unshift({
13518 cls: 'roo-select2-search-field-input'
13524 Roo.each(buttons.cn, function(c){
13526 c.cls += ' btn-' + _this.size;
13529 if (_this.disabled) {
13536 style : 'display: contents',
13541 cls: 'form-hidden-field'
13545 cls: 'roo-select2-choices',
13549 cls: 'roo-select2-search-field',
13560 cls: 'roo-select2-container input-group roo-select2-container-multi',
13566 // cls: 'typeahead typeahead-long dropdown-menu',
13567 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13572 if(this.hasFeedback && !this.allowBlank){
13576 cls: 'glyphicon form-control-feedback'
13579 combobox.cn.push(feedback);
13584 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13585 tooltip : 'This field is required'
13587 if (Roo.bootstrap.version == 4) {
13590 style : 'display:none'
13593 if (align ==='left' && this.fieldLabel.length) {
13595 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13602 cls : 'control-label col-form-label',
13603 html : this.fieldLabel
13615 var labelCfg = cfg.cn[1];
13616 var contentCfg = cfg.cn[2];
13619 if(this.indicatorpos == 'right'){
13625 cls : 'control-label col-form-label',
13629 html : this.fieldLabel
13645 labelCfg = cfg.cn[0];
13646 contentCfg = cfg.cn[1];
13650 if(this.labelWidth > 12){
13651 labelCfg.style = "width: " + this.labelWidth + 'px';
13654 if(this.labelWidth < 13 && this.labelmd == 0){
13655 this.labelmd = this.labelWidth;
13658 if(this.labellg > 0){
13659 labelCfg.cls += ' col-lg-' + this.labellg;
13660 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13663 if(this.labelmd > 0){
13664 labelCfg.cls += ' col-md-' + this.labelmd;
13665 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13668 if(this.labelsm > 0){
13669 labelCfg.cls += ' col-sm-' + this.labelsm;
13670 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13673 if(this.labelxs > 0){
13674 labelCfg.cls += ' col-xs-' + this.labelxs;
13675 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13679 } else if ( this.fieldLabel.length) {
13680 // Roo.log(" label");
13685 //cls : 'input-group-addon',
13686 html : this.fieldLabel
13691 if(this.indicatorpos == 'right'){
13695 //cls : 'input-group-addon',
13696 html : this.fieldLabel
13706 // Roo.log(" no label && no align");
13713 ['xs','sm','md','lg'].map(function(size){
13714 if (settings[size]) {
13715 cfg.cls += ' col-' + size + '-' + settings[size];
13723 _initEventsCalled : false,
13726 initEvents: function()
13728 if (this._initEventsCalled) { // as we call render... prevent looping...
13731 this._initEventsCalled = true;
13734 throw "can not find store for combo";
13737 this.indicator = this.indicatorEl();
13739 this.store = Roo.factory(this.store, Roo.data);
13740 this.store.parent = this;
13742 // if we are building from html. then this element is so complex, that we can not really
13743 // use the rendered HTML.
13744 // so we have to trash and replace the previous code.
13745 if (Roo.XComponent.build_from_html) {
13746 // remove this element....
13747 var e = this.el.dom, k=0;
13748 while (e ) { e = e.previousSibling; ++k;}
13753 this.rendered = false;
13755 this.render(this.parent().getChildContainer(true), k);
13758 if(Roo.isIOS && this.useNativeIOS){
13759 this.initIOSView();
13767 if(Roo.isTouch && this.mobileTouchView){
13768 this.initTouchView();
13773 this.initTickableEvents();
13777 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13779 if(this.hiddenName){
13781 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13783 this.hiddenField.dom.value =
13784 this.hiddenValue !== undefined ? this.hiddenValue :
13785 this.value !== undefined ? this.value : '';
13787 // prevent input submission
13788 this.el.dom.removeAttribute('name');
13789 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13794 // this.el.dom.setAttribute('autocomplete', 'off');
13797 var cls = 'x-combo-list';
13799 //this.list = new Roo.Layer({
13800 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13806 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13807 _this.list.setWidth(lw);
13810 this.list.on('mouseover', this.onViewOver, this);
13811 this.list.on('mousemove', this.onViewMove, this);
13812 this.list.on('scroll', this.onViewScroll, this);
13815 this.list.swallowEvent('mousewheel');
13816 this.assetHeight = 0;
13819 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13820 this.assetHeight += this.header.getHeight();
13823 this.innerList = this.list.createChild({cls:cls+'-inner'});
13824 this.innerList.on('mouseover', this.onViewOver, this);
13825 this.innerList.on('mousemove', this.onViewMove, this);
13826 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13828 if(this.allowBlank && !this.pageSize && !this.disableClear){
13829 this.footer = this.list.createChild({cls:cls+'-ft'});
13830 this.pageTb = new Roo.Toolbar(this.footer);
13834 this.footer = this.list.createChild({cls:cls+'-ft'});
13835 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13836 {pageSize: this.pageSize});
13840 if (this.pageTb && this.allowBlank && !this.disableClear) {
13842 this.pageTb.add(new Roo.Toolbar.Fill(), {
13843 cls: 'x-btn-icon x-btn-clear',
13845 handler: function()
13848 _this.clearValue();
13849 _this.onSelect(false, -1);
13854 this.assetHeight += this.footer.getHeight();
13859 this.tpl = Roo.bootstrap.version == 4 ?
13860 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13861 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13864 this.view = new Roo.View(this.list, this.tpl, {
13865 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13867 //this.view.wrapEl.setDisplayed(false);
13868 this.view.on('click', this.onViewClick, this);
13871 this.store.on('beforeload', this.onBeforeLoad, this);
13872 this.store.on('load', this.onLoad, this);
13873 this.store.on('loadexception', this.onLoadException, this);
13875 if(this.resizable){
13876 this.resizer = new Roo.Resizable(this.list, {
13877 pinned:true, handles:'se'
13879 this.resizer.on('resize', function(r, w, h){
13880 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13881 this.listWidth = w;
13882 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13883 this.restrictHeight();
13885 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13888 if(!this.editable){
13889 this.editable = true;
13890 this.setEditable(false);
13895 if (typeof(this.events.add.listeners) != 'undefined') {
13897 this.addicon = this.wrap.createChild(
13898 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13900 this.addicon.on('click', function(e) {
13901 this.fireEvent('add', this);
13904 if (typeof(this.events.edit.listeners) != 'undefined') {
13906 this.editicon = this.wrap.createChild(
13907 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13908 if (this.addicon) {
13909 this.editicon.setStyle('margin-left', '40px');
13911 this.editicon.on('click', function(e) {
13913 // we fire even if inothing is selected..
13914 this.fireEvent('edit', this, this.lastData );
13920 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13921 "up" : function(e){
13922 this.inKeyMode = true;
13926 "down" : function(e){
13927 if(!this.isExpanded()){
13928 this.onTriggerClick();
13930 this.inKeyMode = true;
13935 "enter" : function(e){
13936 // this.onViewClick();
13940 if(this.fireEvent("specialkey", this, e)){
13941 this.onViewClick(false);
13947 "esc" : function(e){
13951 "tab" : function(e){
13954 if(this.fireEvent("specialkey", this, e)){
13955 this.onViewClick(false);
13963 doRelay : function(foo, bar, hname){
13964 if(hname == 'down' || this.scope.isExpanded()){
13965 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13974 this.queryDelay = Math.max(this.queryDelay || 10,
13975 this.mode == 'local' ? 10 : 250);
13978 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13980 if(this.typeAhead){
13981 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13983 if(this.editable !== false){
13984 this.inputEl().on("keyup", this.onKeyUp, this);
13986 if(this.forceSelection){
13987 this.inputEl().on('blur', this.doForce, this);
13991 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13992 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13996 initTickableEvents: function()
14000 if(this.hiddenName){
14002 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14004 this.hiddenField.dom.value =
14005 this.hiddenValue !== undefined ? this.hiddenValue :
14006 this.value !== undefined ? this.value : '';
14008 // prevent input submission
14009 this.el.dom.removeAttribute('name');
14010 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14015 // this.list = this.el.select('ul.dropdown-menu',true).first();
14017 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14018 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14019 if(this.triggerList){
14020 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
14023 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
14024 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
14026 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
14027 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
14029 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
14030 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
14032 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
14033 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
14034 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
14037 this.cancelBtn.hide();
14042 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14043 _this.list.setWidth(lw);
14046 this.list.on('mouseover', this.onViewOver, this);
14047 this.list.on('mousemove', this.onViewMove, this);
14049 this.list.on('scroll', this.onViewScroll, this);
14052 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14053 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14056 this.view = new Roo.View(this.list, this.tpl, {
14061 selectedClass: this.selectedClass
14064 //this.view.wrapEl.setDisplayed(false);
14065 this.view.on('click', this.onViewClick, this);
14069 this.store.on('beforeload', this.onBeforeLoad, this);
14070 this.store.on('load', this.onLoad, this);
14071 this.store.on('loadexception', this.onLoadException, this);
14074 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14075 "up" : function(e){
14076 this.inKeyMode = true;
14080 "down" : function(e){
14081 this.inKeyMode = true;
14085 "enter" : function(e){
14086 if(this.fireEvent("specialkey", this, e)){
14087 this.onViewClick(false);
14093 "esc" : function(e){
14094 this.onTickableFooterButtonClick(e, false, false);
14097 "tab" : function(e){
14098 this.fireEvent("specialkey", this, e);
14100 this.onTickableFooterButtonClick(e, false, false);
14107 doRelay : function(e, fn, key){
14108 if(this.scope.isExpanded()){
14109 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14118 this.queryDelay = Math.max(this.queryDelay || 10,
14119 this.mode == 'local' ? 10 : 250);
14122 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14124 if(this.typeAhead){
14125 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14128 if(this.editable !== false){
14129 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14132 this.indicator = this.indicatorEl();
14134 if(this.indicator){
14135 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14136 this.indicator.hide();
14141 onDestroy : function(){
14143 this.view.setStore(null);
14144 this.view.el.removeAllListeners();
14145 this.view.el.remove();
14146 this.view.purgeListeners();
14149 this.list.dom.innerHTML = '';
14153 this.store.un('beforeload', this.onBeforeLoad, this);
14154 this.store.un('load', this.onLoad, this);
14155 this.store.un('loadexception', this.onLoadException, this);
14157 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14161 fireKey : function(e){
14162 if(e.isNavKeyPress() && !this.list.isVisible()){
14163 this.fireEvent("specialkey", this, e);
14168 onResize: function(w, h){
14169 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14171 // if(typeof w != 'number'){
14172 // // we do not handle it!?!?
14175 // var tw = this.trigger.getWidth();
14176 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14177 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14179 // this.inputEl().setWidth( this.adjustWidth('input', x));
14181 // //this.trigger.setStyle('left', x+'px');
14183 // if(this.list && this.listWidth === undefined){
14184 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14185 // this.list.setWidth(lw);
14186 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14194 * Allow or prevent the user from directly editing the field text. If false is passed,
14195 * the user will only be able to select from the items defined in the dropdown list. This method
14196 * is the runtime equivalent of setting the 'editable' config option at config time.
14197 * @param {Boolean} value True to allow the user to directly edit the field text
14199 setEditable : function(value){
14200 if(value == this.editable){
14203 this.editable = value;
14205 this.inputEl().dom.setAttribute('readOnly', true);
14206 this.inputEl().on('mousedown', this.onTriggerClick, this);
14207 this.inputEl().addClass('x-combo-noedit');
14209 this.inputEl().dom.setAttribute('readOnly', false);
14210 this.inputEl().un('mousedown', this.onTriggerClick, this);
14211 this.inputEl().removeClass('x-combo-noedit');
14217 onBeforeLoad : function(combo,opts){
14218 if(!this.hasFocus){
14222 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14224 this.restrictHeight();
14225 this.selectedIndex = -1;
14229 onLoad : function(){
14231 this.hasQuery = false;
14233 if(!this.hasFocus){
14237 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14238 this.loading.hide();
14241 if(this.store.getCount() > 0){
14244 this.restrictHeight();
14245 if(this.lastQuery == this.allQuery){
14246 if(this.editable && !this.tickable){
14247 this.inputEl().dom.select();
14251 !this.selectByValue(this.value, true) &&
14254 !this.store.lastOptions ||
14255 typeof(this.store.lastOptions.add) == 'undefined' ||
14256 this.store.lastOptions.add != true
14259 this.select(0, true);
14262 if(this.autoFocus){
14265 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14266 this.taTask.delay(this.typeAheadDelay);
14270 this.onEmptyResults();
14276 onLoadException : function()
14278 this.hasQuery = false;
14280 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14281 this.loading.hide();
14284 if(this.tickable && this.editable){
14289 // only causes errors at present
14290 //Roo.log(this.store.reader.jsonData);
14291 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14293 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14299 onTypeAhead : function(){
14300 if(this.store.getCount() > 0){
14301 var r = this.store.getAt(0);
14302 var newValue = r.data[this.displayField];
14303 var len = newValue.length;
14304 var selStart = this.getRawValue().length;
14306 if(selStart != len){
14307 this.setRawValue(newValue);
14308 this.selectText(selStart, newValue.length);
14314 onSelect : function(record, index){
14316 if(this.fireEvent('beforeselect', this, record, index) !== false){
14318 this.setFromData(index > -1 ? record.data : false);
14321 this.fireEvent('select', this, record, index);
14326 * Returns the currently selected field value or empty string if no value is set.
14327 * @return {String} value The selected value
14329 getValue : function()
14331 if(Roo.isIOS && this.useNativeIOS){
14332 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14336 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14339 if(this.valueField){
14340 return typeof this.value != 'undefined' ? this.value : '';
14342 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14346 getRawValue : function()
14348 if(Roo.isIOS && this.useNativeIOS){
14349 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14352 var v = this.inputEl().getValue();
14358 * Clears any text/value currently set in the field
14360 clearValue : function(){
14362 if(this.hiddenField){
14363 this.hiddenField.dom.value = '';
14366 this.setRawValue('');
14367 this.lastSelectionText = '';
14368 this.lastData = false;
14370 var close = this.closeTriggerEl();
14381 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14382 * will be displayed in the field. If the value does not match the data value of an existing item,
14383 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14384 * Otherwise the field will be blank (although the value will still be set).
14385 * @param {String} value The value to match
14387 setValue : function(v)
14389 if(Roo.isIOS && this.useNativeIOS){
14390 this.setIOSValue(v);
14400 if(this.valueField){
14401 var r = this.findRecord(this.valueField, v);
14403 text = r.data[this.displayField];
14404 }else if(this.valueNotFoundText !== undefined){
14405 text = this.valueNotFoundText;
14408 this.lastSelectionText = text;
14409 if(this.hiddenField){
14410 this.hiddenField.dom.value = v;
14412 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14415 var close = this.closeTriggerEl();
14418 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14424 * @property {Object} the last set data for the element
14429 * Sets the value of the field based on a object which is related to the record format for the store.
14430 * @param {Object} value the value to set as. or false on reset?
14432 setFromData : function(o){
14439 var dv = ''; // display value
14440 var vv = ''; // value value..
14442 if (this.displayField) {
14443 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14445 // this is an error condition!!!
14446 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14449 if(this.valueField){
14450 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14453 var close = this.closeTriggerEl();
14456 if(dv.length || vv * 1 > 0){
14458 this.blockFocus=true;
14464 if(this.hiddenField){
14465 this.hiddenField.dom.value = vv;
14467 this.lastSelectionText = dv;
14468 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14472 // no hidden field.. - we store the value in 'value', but still display
14473 // display field!!!!
14474 this.lastSelectionText = dv;
14475 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14482 reset : function(){
14483 // overridden so that last data is reset..
14490 this.setValue(this.originalValue);
14491 //this.clearInvalid();
14492 this.lastData = false;
14494 this.view.clearSelections();
14500 findRecord : function(prop, value){
14502 if(this.store.getCount() > 0){
14503 this.store.each(function(r){
14504 if(r.data[prop] == value){
14514 getName: function()
14516 // returns hidden if it's set..
14517 if (!this.rendered) {return ''};
14518 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14522 onViewMove : function(e, t){
14523 this.inKeyMode = false;
14527 onViewOver : function(e, t){
14528 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14531 var item = this.view.findItemFromChild(t);
14534 var index = this.view.indexOf(item);
14535 this.select(index, false);
14540 onViewClick : function(view, doFocus, el, e)
14542 var index = this.view.getSelectedIndexes()[0];
14544 var r = this.store.getAt(index);
14548 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14555 Roo.each(this.tickItems, function(v,k){
14557 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14559 _this.tickItems.splice(k, 1);
14561 if(typeof(e) == 'undefined' && view == false){
14562 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14574 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14575 this.tickItems.push(r.data);
14578 if(typeof(e) == 'undefined' && view == false){
14579 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14586 this.onSelect(r, index);
14588 if(doFocus !== false && !this.blockFocus){
14589 this.inputEl().focus();
14594 restrictHeight : function(){
14595 //this.innerList.dom.style.height = '';
14596 //var inner = this.innerList.dom;
14597 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14598 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14599 //this.list.beginUpdate();
14600 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14601 this.list.alignTo(this.inputEl(), this.listAlign);
14602 this.list.alignTo(this.inputEl(), this.listAlign);
14603 //this.list.endUpdate();
14607 onEmptyResults : function(){
14609 if(this.tickable && this.editable){
14610 this.hasFocus = false;
14611 this.restrictHeight();
14619 * Returns true if the dropdown list is expanded, else false.
14621 isExpanded : function(){
14622 return this.list.isVisible();
14626 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14627 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14628 * @param {String} value The data value of the item to select
14629 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14630 * selected item if it is not currently in view (defaults to true)
14631 * @return {Boolean} True if the value matched an item in the list, else false
14633 selectByValue : function(v, scrollIntoView){
14634 if(v !== undefined && v !== null){
14635 var r = this.findRecord(this.valueField || this.displayField, v);
14637 this.select(this.store.indexOf(r), scrollIntoView);
14645 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14646 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14647 * @param {Number} index The zero-based index of the list item to select
14648 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14649 * selected item if it is not currently in view (defaults to true)
14651 select : function(index, scrollIntoView){
14652 this.selectedIndex = index;
14653 this.view.select(index);
14654 if(scrollIntoView !== false){
14655 var el = this.view.getNode(index);
14657 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14660 this.list.scrollChildIntoView(el, false);
14666 selectNext : function(){
14667 var ct = this.store.getCount();
14669 if(this.selectedIndex == -1){
14671 }else if(this.selectedIndex < ct-1){
14672 this.select(this.selectedIndex+1);
14678 selectPrev : function(){
14679 var ct = this.store.getCount();
14681 if(this.selectedIndex == -1){
14683 }else if(this.selectedIndex != 0){
14684 this.select(this.selectedIndex-1);
14690 onKeyUp : function(e){
14691 if(this.editable !== false && !e.isSpecialKey()){
14692 this.lastKey = e.getKey();
14693 this.dqTask.delay(this.queryDelay);
14698 validateBlur : function(){
14699 return !this.list || !this.list.isVisible();
14703 initQuery : function(){
14705 var v = this.getRawValue();
14707 if(this.tickable && this.editable){
14708 v = this.tickableInputEl().getValue();
14715 doForce : function(){
14716 if(this.inputEl().dom.value.length > 0){
14717 this.inputEl().dom.value =
14718 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14724 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14725 * query allowing the query action to be canceled if needed.
14726 * @param {String} query The SQL query to execute
14727 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14728 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14729 * saved in the current store (defaults to false)
14731 doQuery : function(q, forceAll){
14733 if(q === undefined || q === null){
14738 forceAll: forceAll,
14742 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14747 forceAll = qe.forceAll;
14748 if(forceAll === true || (q.length >= this.minChars)){
14750 this.hasQuery = true;
14752 if(this.lastQuery != q || this.alwaysQuery){
14753 this.lastQuery = q;
14754 if(this.mode == 'local'){
14755 this.selectedIndex = -1;
14757 this.store.clearFilter();
14760 if(this.specialFilter){
14761 this.fireEvent('specialfilter', this);
14766 this.store.filter(this.displayField, q);
14769 this.store.fireEvent("datachanged", this.store);
14776 this.store.baseParams[this.queryParam] = q;
14778 var options = {params : this.getParams(q)};
14781 options.add = true;
14782 options.params.start = this.page * this.pageSize;
14785 this.store.load(options);
14788 * this code will make the page width larger, at the beginning, the list not align correctly,
14789 * we should expand the list on onLoad
14790 * so command out it
14795 this.selectedIndex = -1;
14800 this.loadNext = false;
14804 getParams : function(q){
14806 //p[this.queryParam] = q;
14810 p.limit = this.pageSize;
14816 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14818 collapse : function(){
14819 if(!this.isExpanded()){
14825 this.hasFocus = false;
14829 this.cancelBtn.hide();
14830 this.trigger.show();
14833 this.tickableInputEl().dom.value = '';
14834 this.tickableInputEl().blur();
14839 Roo.get(document).un('mousedown', this.collapseIf, this);
14840 Roo.get(document).un('mousewheel', this.collapseIf, this);
14841 if (!this.editable) {
14842 Roo.get(document).un('keydown', this.listKeyPress, this);
14844 this.fireEvent('collapse', this);
14850 collapseIf : function(e){
14851 var in_combo = e.within(this.el);
14852 var in_list = e.within(this.list);
14853 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14855 if (in_combo || in_list || is_list) {
14856 //e.stopPropagation();
14861 this.onTickableFooterButtonClick(e, false, false);
14869 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14871 expand : function(){
14873 if(this.isExpanded() || !this.hasFocus){
14877 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14878 this.list.setWidth(lw);
14884 this.restrictHeight();
14888 this.tickItems = Roo.apply([], this.item);
14891 this.cancelBtn.show();
14892 this.trigger.hide();
14895 this.tickableInputEl().focus();
14900 Roo.get(document).on('mousedown', this.collapseIf, this);
14901 Roo.get(document).on('mousewheel', this.collapseIf, this);
14902 if (!this.editable) {
14903 Roo.get(document).on('keydown', this.listKeyPress, this);
14906 this.fireEvent('expand', this);
14910 // Implements the default empty TriggerField.onTriggerClick function
14911 onTriggerClick : function(e)
14913 Roo.log('trigger click');
14915 if(this.disabled || !this.triggerList){
14920 this.loadNext = false;
14922 if(this.isExpanded()){
14924 if (!this.blockFocus) {
14925 this.inputEl().focus();
14929 this.hasFocus = true;
14930 if(this.triggerAction == 'all') {
14931 this.doQuery(this.allQuery, true);
14933 this.doQuery(this.getRawValue());
14935 if (!this.blockFocus) {
14936 this.inputEl().focus();
14941 onTickableTriggerClick : function(e)
14948 this.loadNext = false;
14949 this.hasFocus = true;
14951 if(this.triggerAction == 'all') {
14952 this.doQuery(this.allQuery, true);
14954 this.doQuery(this.getRawValue());
14958 onSearchFieldClick : function(e)
14960 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14961 this.onTickableFooterButtonClick(e, false, false);
14965 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14970 this.loadNext = false;
14971 this.hasFocus = true;
14973 if(this.triggerAction == 'all') {
14974 this.doQuery(this.allQuery, true);
14976 this.doQuery(this.getRawValue());
14980 listKeyPress : function(e)
14982 //Roo.log('listkeypress');
14983 // scroll to first matching element based on key pres..
14984 if (e.isSpecialKey()) {
14987 var k = String.fromCharCode(e.getKey()).toUpperCase();
14990 var csel = this.view.getSelectedNodes();
14991 var cselitem = false;
14993 var ix = this.view.indexOf(csel[0]);
14994 cselitem = this.store.getAt(ix);
14995 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
15001 this.store.each(function(v) {
15003 // start at existing selection.
15004 if (cselitem.id == v.id) {
15010 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
15011 match = this.store.indexOf(v);
15017 if (match === false) {
15018 return true; // no more action?
15021 this.view.select(match);
15022 var sn = Roo.get(this.view.getSelectedNodes()[0]);
15023 sn.scrollIntoView(sn.dom.parentNode, false);
15026 onViewScroll : function(e, t){
15028 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){
15032 this.hasQuery = true;
15034 this.loading = this.list.select('.loading', true).first();
15036 if(this.loading === null){
15037 this.list.createChild({
15039 cls: 'loading roo-select2-more-results roo-select2-active',
15040 html: 'Loading more results...'
15043 this.loading = this.list.select('.loading', true).first();
15045 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15047 this.loading.hide();
15050 this.loading.show();
15055 this.loadNext = true;
15057 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15062 addItem : function(o)
15064 var dv = ''; // display value
15066 if (this.displayField) {
15067 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15069 // this is an error condition!!!
15070 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15077 var choice = this.choices.createChild({
15079 cls: 'roo-select2-search-choice',
15088 cls: 'roo-select2-search-choice-close fa fa-times',
15093 }, this.searchField);
15095 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15097 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15105 this.inputEl().dom.value = '';
15110 onRemoveItem : function(e, _self, o)
15112 e.preventDefault();
15114 this.lastItem = Roo.apply([], this.item);
15116 var index = this.item.indexOf(o.data) * 1;
15119 Roo.log('not this item?!');
15123 this.item.splice(index, 1);
15128 this.fireEvent('remove', this, e);
15134 syncValue : function()
15136 if(!this.item.length){
15143 Roo.each(this.item, function(i){
15144 if(_this.valueField){
15145 value.push(i[_this.valueField]);
15152 this.value = value.join(',');
15154 if(this.hiddenField){
15155 this.hiddenField.dom.value = this.value;
15158 this.store.fireEvent("datachanged", this.store);
15163 clearItem : function()
15165 if(!this.multiple){
15171 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15179 if(this.tickable && !Roo.isTouch){
15180 this.view.refresh();
15184 inputEl: function ()
15186 if(Roo.isIOS && this.useNativeIOS){
15187 return this.el.select('select.roo-ios-select', true).first();
15190 if(Roo.isTouch && this.mobileTouchView){
15191 return this.el.select('input.form-control',true).first();
15195 return this.searchField;
15198 return this.el.select('input.form-control',true).first();
15201 onTickableFooterButtonClick : function(e, btn, el)
15203 e.preventDefault();
15205 this.lastItem = Roo.apply([], this.item);
15207 if(btn && btn.name == 'cancel'){
15208 this.tickItems = Roo.apply([], this.item);
15217 Roo.each(this.tickItems, function(o){
15225 validate : function()
15227 if(this.getVisibilityEl().hasClass('hidden')){
15231 var v = this.getRawValue();
15234 v = this.getValue();
15237 if(this.disabled || this.allowBlank || v.length){
15242 this.markInvalid();
15246 tickableInputEl : function()
15248 if(!this.tickable || !this.editable){
15249 return this.inputEl();
15252 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15256 getAutoCreateTouchView : function()
15261 cls: 'form-group' //input-group
15267 type : this.inputType,
15268 cls : 'form-control x-combo-noedit',
15269 autocomplete: 'new-password',
15270 placeholder : this.placeholder || '',
15275 input.name = this.name;
15279 input.cls += ' input-' + this.size;
15282 if (this.disabled) {
15283 input.disabled = true;
15294 inputblock.cls += ' input-group';
15296 inputblock.cn.unshift({
15298 cls : 'input-group-addon input-group-prepend input-group-text',
15303 if(this.removable && !this.multiple){
15304 inputblock.cls += ' roo-removable';
15306 inputblock.cn.push({
15309 cls : 'roo-combo-removable-btn close'
15313 if(this.hasFeedback && !this.allowBlank){
15315 inputblock.cls += ' has-feedback';
15317 inputblock.cn.push({
15319 cls: 'glyphicon form-control-feedback'
15326 inputblock.cls += (this.before) ? '' : ' input-group';
15328 inputblock.cn.push({
15330 cls : 'input-group-addon input-group-append input-group-text',
15336 var ibwrap = inputblock;
15341 cls: 'roo-select2-choices',
15345 cls: 'roo-select2-search-field',
15358 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15363 cls: 'form-hidden-field'
15369 if(!this.multiple && this.showToggleBtn){
15376 if (this.caret != false) {
15379 cls: 'fa fa-' + this.caret
15386 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15391 cls: 'combobox-clear',
15405 combobox.cls += ' roo-select2-container-multi';
15408 var align = this.labelAlign || this.parentLabelAlign();
15410 if (align ==='left' && this.fieldLabel.length) {
15415 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15416 tooltip : 'This field is required'
15420 cls : 'control-label col-form-label',
15421 html : this.fieldLabel
15432 var labelCfg = cfg.cn[1];
15433 var contentCfg = cfg.cn[2];
15436 if(this.indicatorpos == 'right'){
15441 cls : 'control-label col-form-label',
15445 html : this.fieldLabel
15449 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15450 tooltip : 'This field is required'
15463 labelCfg = cfg.cn[0];
15464 contentCfg = cfg.cn[1];
15469 if(this.labelWidth > 12){
15470 labelCfg.style = "width: " + this.labelWidth + 'px';
15473 if(this.labelWidth < 13 && this.labelmd == 0){
15474 this.labelmd = this.labelWidth;
15477 if(this.labellg > 0){
15478 labelCfg.cls += ' col-lg-' + this.labellg;
15479 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15482 if(this.labelmd > 0){
15483 labelCfg.cls += ' col-md-' + this.labelmd;
15484 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15487 if(this.labelsm > 0){
15488 labelCfg.cls += ' col-sm-' + this.labelsm;
15489 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15492 if(this.labelxs > 0){
15493 labelCfg.cls += ' col-xs-' + this.labelxs;
15494 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15498 } else if ( this.fieldLabel.length) {
15502 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15503 tooltip : 'This field is required'
15507 cls : 'control-label',
15508 html : this.fieldLabel
15519 if(this.indicatorpos == 'right'){
15523 cls : 'control-label',
15524 html : this.fieldLabel,
15528 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15529 tooltip : 'This field is required'
15546 var settings = this;
15548 ['xs','sm','md','lg'].map(function(size){
15549 if (settings[size]) {
15550 cfg.cls += ' col-' + size + '-' + settings[size];
15557 initTouchView : function()
15559 this.renderTouchView();
15561 this.touchViewEl.on('scroll', function(){
15562 this.el.dom.scrollTop = 0;
15565 this.originalValue = this.getValue();
15567 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15569 this.inputEl().on("click", this.showTouchView, this);
15570 if (this.triggerEl) {
15571 this.triggerEl.on("click", this.showTouchView, this);
15575 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15576 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15578 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15580 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15581 this.store.on('load', this.onTouchViewLoad, this);
15582 this.store.on('loadexception', this.onTouchViewLoadException, this);
15584 if(this.hiddenName){
15586 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15588 this.hiddenField.dom.value =
15589 this.hiddenValue !== undefined ? this.hiddenValue :
15590 this.value !== undefined ? this.value : '';
15592 this.el.dom.removeAttribute('name');
15593 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15597 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15598 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15601 if(this.removable && !this.multiple){
15602 var close = this.closeTriggerEl();
15604 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15605 close.on('click', this.removeBtnClick, this, close);
15609 * fix the bug in Safari iOS8
15611 this.inputEl().on("focus", function(e){
15612 document.activeElement.blur();
15615 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15622 renderTouchView : function()
15624 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15625 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15627 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15628 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15630 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15631 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15632 this.touchViewBodyEl.setStyle('overflow', 'auto');
15634 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15635 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15637 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15638 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15642 showTouchView : function()
15648 this.touchViewHeaderEl.hide();
15650 if(this.modalTitle.length){
15651 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15652 this.touchViewHeaderEl.show();
15655 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15656 this.touchViewEl.show();
15658 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15660 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15661 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15663 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15665 if(this.modalTitle.length){
15666 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15669 this.touchViewBodyEl.setHeight(bodyHeight);
15673 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15675 this.touchViewEl.addClass('in');
15678 if(this._touchViewMask){
15679 Roo.get(document.body).addClass("x-body-masked");
15680 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15681 this._touchViewMask.setStyle('z-index', 10000);
15682 this._touchViewMask.addClass('show');
15685 this.doTouchViewQuery();
15689 hideTouchView : function()
15691 this.touchViewEl.removeClass('in');
15695 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15697 this.touchViewEl.setStyle('display', 'none');
15700 if(this._touchViewMask){
15701 this._touchViewMask.removeClass('show');
15702 Roo.get(document.body).removeClass("x-body-masked");
15706 setTouchViewValue : function()
15713 Roo.each(this.tickItems, function(o){
15718 this.hideTouchView();
15721 doTouchViewQuery : function()
15730 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15734 if(!this.alwaysQuery || this.mode == 'local'){
15735 this.onTouchViewLoad();
15742 onTouchViewBeforeLoad : function(combo,opts)
15748 onTouchViewLoad : function()
15750 if(this.store.getCount() < 1){
15751 this.onTouchViewEmptyResults();
15755 this.clearTouchView();
15757 var rawValue = this.getRawValue();
15759 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15761 this.tickItems = [];
15763 this.store.data.each(function(d, rowIndex){
15764 var row = this.touchViewListGroup.createChild(template);
15766 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15767 row.addClass(d.data.cls);
15770 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15773 html : d.data[this.displayField]
15776 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15777 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15780 row.removeClass('selected');
15781 if(!this.multiple && this.valueField &&
15782 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15785 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15786 row.addClass('selected');
15789 if(this.multiple && this.valueField &&
15790 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15794 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15795 this.tickItems.push(d.data);
15798 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15802 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15804 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15806 if(this.modalTitle.length){
15807 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15810 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15812 if(this.mobile_restrict_height && listHeight < bodyHeight){
15813 this.touchViewBodyEl.setHeight(listHeight);
15818 if(firstChecked && listHeight > bodyHeight){
15819 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15824 onTouchViewLoadException : function()
15826 this.hideTouchView();
15829 onTouchViewEmptyResults : function()
15831 this.clearTouchView();
15833 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15835 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15839 clearTouchView : function()
15841 this.touchViewListGroup.dom.innerHTML = '';
15844 onTouchViewClick : function(e, el, o)
15846 e.preventDefault();
15849 var rowIndex = o.rowIndex;
15851 var r = this.store.getAt(rowIndex);
15853 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15855 if(!this.multiple){
15856 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15857 c.dom.removeAttribute('checked');
15860 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15862 this.setFromData(r.data);
15864 var close = this.closeTriggerEl();
15870 this.hideTouchView();
15872 this.fireEvent('select', this, r, rowIndex);
15877 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15878 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15879 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15883 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15884 this.addItem(r.data);
15885 this.tickItems.push(r.data);
15889 getAutoCreateNativeIOS : function()
15892 cls: 'form-group' //input-group,
15897 cls : 'roo-ios-select'
15901 combobox.name = this.name;
15904 if (this.disabled) {
15905 combobox.disabled = true;
15908 var settings = this;
15910 ['xs','sm','md','lg'].map(function(size){
15911 if (settings[size]) {
15912 cfg.cls += ' col-' + size + '-' + settings[size];
15922 initIOSView : function()
15924 this.store.on('load', this.onIOSViewLoad, this);
15929 onIOSViewLoad : function()
15931 if(this.store.getCount() < 1){
15935 this.clearIOSView();
15937 if(this.allowBlank) {
15939 var default_text = '-- SELECT --';
15941 if(this.placeholder.length){
15942 default_text = this.placeholder;
15945 if(this.emptyTitle.length){
15946 default_text += ' - ' + this.emptyTitle + ' -';
15949 var opt = this.inputEl().createChild({
15952 html : default_text
15956 o[this.valueField] = 0;
15957 o[this.displayField] = default_text;
15959 this.ios_options.push({
15966 this.store.data.each(function(d, rowIndex){
15970 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15971 html = d.data[this.displayField];
15976 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15977 value = d.data[this.valueField];
15986 if(this.value == d.data[this.valueField]){
15987 option['selected'] = true;
15990 var opt = this.inputEl().createChild(option);
15992 this.ios_options.push({
15999 this.inputEl().on('change', function(){
16000 this.fireEvent('select', this);
16005 clearIOSView: function()
16007 this.inputEl().dom.innerHTML = '';
16009 this.ios_options = [];
16012 setIOSValue: function(v)
16016 if(!this.ios_options){
16020 Roo.each(this.ios_options, function(opts){
16022 opts.el.dom.removeAttribute('selected');
16024 if(opts.data[this.valueField] != v){
16028 opts.el.dom.setAttribute('selected', true);
16034 * @cfg {Boolean} grow
16038 * @cfg {Number} growMin
16042 * @cfg {Number} growMax
16051 Roo.apply(Roo.bootstrap.ComboBox, {
16055 cls: 'modal-header',
16077 cls: 'list-group-item',
16081 cls: 'roo-combobox-list-group-item-value'
16085 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16099 listItemCheckbox : {
16101 cls: 'list-group-item',
16105 cls: 'roo-combobox-list-group-item-value'
16109 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16125 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16130 cls: 'modal-footer',
16138 cls: 'col-xs-6 text-left',
16141 cls: 'btn btn-danger roo-touch-view-cancel',
16147 cls: 'col-xs-6 text-right',
16150 cls: 'btn btn-success roo-touch-view-ok',
16161 Roo.apply(Roo.bootstrap.ComboBox, {
16163 touchViewTemplate : {
16165 cls: 'modal fade roo-combobox-touch-view',
16169 cls: 'modal-dialog',
16170 style : 'position:fixed', // we have to fix position....
16174 cls: 'modal-content',
16176 Roo.bootstrap.ComboBox.header,
16177 Roo.bootstrap.ComboBox.body,
16178 Roo.bootstrap.ComboBox.footer
16187 * Ext JS Library 1.1.1
16188 * Copyright(c) 2006-2007, Ext JS, LLC.
16190 * Originally Released Under LGPL - original licence link has changed is not relivant.
16193 * <script type="text/javascript">
16198 * @extends Roo.util.Observable
16199 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16200 * This class also supports single and multi selection modes. <br>
16201 * Create a data model bound view:
16203 var store = new Roo.data.Store(...);
16205 var view = new Roo.View({
16207 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16209 singleSelect: true,
16210 selectedClass: "ydataview-selected",
16214 // listen for node click?
16215 view.on("click", function(vw, index, node, e){
16216 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16220 dataModel.load("foobar.xml");
16222 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16224 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16225 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16227 * Note: old style constructor is still suported (container, template, config)
16230 * Create a new View
16231 * @param {Object} config The config object
16234 Roo.View = function(config, depreciated_tpl, depreciated_config){
16236 this.parent = false;
16238 if (typeof(depreciated_tpl) == 'undefined') {
16239 // new way.. - universal constructor.
16240 Roo.apply(this, config);
16241 this.el = Roo.get(this.el);
16244 this.el = Roo.get(config);
16245 this.tpl = depreciated_tpl;
16246 Roo.apply(this, depreciated_config);
16248 this.wrapEl = this.el.wrap().wrap();
16249 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16252 if(typeof(this.tpl) == "string"){
16253 this.tpl = new Roo.Template(this.tpl);
16255 // support xtype ctors..
16256 this.tpl = new Roo.factory(this.tpl, Roo);
16260 this.tpl.compile();
16265 * @event beforeclick
16266 * Fires before a click is processed. Returns false to cancel the default action.
16267 * @param {Roo.View} this
16268 * @param {Number} index The index of the target node
16269 * @param {HTMLElement} node The target node
16270 * @param {Roo.EventObject} e The raw event object
16272 "beforeclick" : true,
16275 * Fires when a template node is clicked.
16276 * @param {Roo.View} this
16277 * @param {Number} index The index of the target node
16278 * @param {HTMLElement} node The target node
16279 * @param {Roo.EventObject} e The raw event object
16284 * Fires when a template node is double clicked.
16285 * @param {Roo.View} this
16286 * @param {Number} index The index of the target node
16287 * @param {HTMLElement} node The target node
16288 * @param {Roo.EventObject} e The raw event object
16292 * @event contextmenu
16293 * Fires when a template node is right clicked.
16294 * @param {Roo.View} this
16295 * @param {Number} index The index of the target node
16296 * @param {HTMLElement} node The target node
16297 * @param {Roo.EventObject} e The raw event object
16299 "contextmenu" : true,
16301 * @event selectionchange
16302 * Fires when the selected nodes change.
16303 * @param {Roo.View} this
16304 * @param {Array} selections Array of the selected nodes
16306 "selectionchange" : true,
16309 * @event beforeselect
16310 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16311 * @param {Roo.View} this
16312 * @param {HTMLElement} node The node to be selected
16313 * @param {Array} selections Array of currently selected nodes
16315 "beforeselect" : true,
16317 * @event preparedata
16318 * Fires on every row to render, to allow you to change the data.
16319 * @param {Roo.View} this
16320 * @param {Object} data to be rendered (change this)
16322 "preparedata" : true
16330 "click": this.onClick,
16331 "dblclick": this.onDblClick,
16332 "contextmenu": this.onContextMenu,
16336 this.selections = [];
16338 this.cmp = new Roo.CompositeElementLite([]);
16340 this.store = Roo.factory(this.store, Roo.data);
16341 this.setStore(this.store, true);
16344 if ( this.footer && this.footer.xtype) {
16346 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16348 this.footer.dataSource = this.store;
16349 this.footer.container = fctr;
16350 this.footer = Roo.factory(this.footer, Roo);
16351 fctr.insertFirst(this.el);
16353 // this is a bit insane - as the paging toolbar seems to detach the el..
16354 // dom.parentNode.parentNode.parentNode
16355 // they get detached?
16359 Roo.View.superclass.constructor.call(this);
16364 Roo.extend(Roo.View, Roo.util.Observable, {
16367 * @cfg {Roo.data.Store} store Data store to load data from.
16372 * @cfg {String|Roo.Element} el The container element.
16377 * @cfg {String|Roo.Template} tpl The template used by this View
16381 * @cfg {String} dataName the named area of the template to use as the data area
16382 * Works with domtemplates roo-name="name"
16386 * @cfg {String} selectedClass The css class to add to selected nodes
16388 selectedClass : "x-view-selected",
16390 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16395 * @cfg {String} text to display on mask (default Loading)
16399 * @cfg {Boolean} multiSelect Allow multiple selection
16401 multiSelect : false,
16403 * @cfg {Boolean} singleSelect Allow single selection
16405 singleSelect: false,
16408 * @cfg {Boolean} toggleSelect - selecting
16410 toggleSelect : false,
16413 * @cfg {Boolean} tickable - selecting
16418 * Returns the element this view is bound to.
16419 * @return {Roo.Element}
16421 getEl : function(){
16422 return this.wrapEl;
16428 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16430 refresh : function(){
16431 //Roo.log('refresh');
16434 // if we are using something like 'domtemplate', then
16435 // the what gets used is:
16436 // t.applySubtemplate(NAME, data, wrapping data..)
16437 // the outer template then get' applied with
16438 // the store 'extra data'
16439 // and the body get's added to the
16440 // roo-name="data" node?
16441 // <span class='roo-tpl-{name}'></span> ?????
16445 this.clearSelections();
16446 this.el.update("");
16448 var records = this.store.getRange();
16449 if(records.length < 1) {
16451 // is this valid?? = should it render a template??
16453 this.el.update(this.emptyText);
16457 if (this.dataName) {
16458 this.el.update(t.apply(this.store.meta)); //????
16459 el = this.el.child('.roo-tpl-' + this.dataName);
16462 for(var i = 0, len = records.length; i < len; i++){
16463 var data = this.prepareData(records[i].data, i, records[i]);
16464 this.fireEvent("preparedata", this, data, i, records[i]);
16466 var d = Roo.apply({}, data);
16469 Roo.apply(d, {'roo-id' : Roo.id()});
16473 Roo.each(this.parent.item, function(item){
16474 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16477 Roo.apply(d, {'roo-data-checked' : 'checked'});
16481 html[html.length] = Roo.util.Format.trim(
16483 t.applySubtemplate(this.dataName, d, this.store.meta) :
16490 el.update(html.join(""));
16491 this.nodes = el.dom.childNodes;
16492 this.updateIndexes(0);
16497 * Function to override to reformat the data that is sent to
16498 * the template for each node.
16499 * DEPRICATED - use the preparedata event handler.
16500 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16501 * a JSON object for an UpdateManager bound view).
16503 prepareData : function(data, index, record)
16505 this.fireEvent("preparedata", this, data, index, record);
16509 onUpdate : function(ds, record){
16510 // Roo.log('on update');
16511 this.clearSelections();
16512 var index = this.store.indexOf(record);
16513 var n = this.nodes[index];
16514 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16515 n.parentNode.removeChild(n);
16516 this.updateIndexes(index, index);
16522 onAdd : function(ds, records, index)
16524 //Roo.log(['on Add', ds, records, index] );
16525 this.clearSelections();
16526 if(this.nodes.length == 0){
16530 var n = this.nodes[index];
16531 for(var i = 0, len = records.length; i < len; i++){
16532 var d = this.prepareData(records[i].data, i, records[i]);
16534 this.tpl.insertBefore(n, d);
16537 this.tpl.append(this.el, d);
16540 this.updateIndexes(index);
16543 onRemove : function(ds, record, index){
16544 // Roo.log('onRemove');
16545 this.clearSelections();
16546 var el = this.dataName ?
16547 this.el.child('.roo-tpl-' + this.dataName) :
16550 el.dom.removeChild(this.nodes[index]);
16551 this.updateIndexes(index);
16555 * Refresh an individual node.
16556 * @param {Number} index
16558 refreshNode : function(index){
16559 this.onUpdate(this.store, this.store.getAt(index));
16562 updateIndexes : function(startIndex, endIndex){
16563 var ns = this.nodes;
16564 startIndex = startIndex || 0;
16565 endIndex = endIndex || ns.length - 1;
16566 for(var i = startIndex; i <= endIndex; i++){
16567 ns[i].nodeIndex = i;
16572 * Changes the data store this view uses and refresh the view.
16573 * @param {Store} store
16575 setStore : function(store, initial){
16576 if(!initial && this.store){
16577 this.store.un("datachanged", this.refresh);
16578 this.store.un("add", this.onAdd);
16579 this.store.un("remove", this.onRemove);
16580 this.store.un("update", this.onUpdate);
16581 this.store.un("clear", this.refresh);
16582 this.store.un("beforeload", this.onBeforeLoad);
16583 this.store.un("load", this.onLoad);
16584 this.store.un("loadexception", this.onLoad);
16588 store.on("datachanged", this.refresh, this);
16589 store.on("add", this.onAdd, this);
16590 store.on("remove", this.onRemove, this);
16591 store.on("update", this.onUpdate, this);
16592 store.on("clear", this.refresh, this);
16593 store.on("beforeload", this.onBeforeLoad, this);
16594 store.on("load", this.onLoad, this);
16595 store.on("loadexception", this.onLoad, this);
16603 * onbeforeLoad - masks the loading area.
16606 onBeforeLoad : function(store,opts)
16608 //Roo.log('onBeforeLoad');
16610 this.el.update("");
16612 this.el.mask(this.mask ? this.mask : "Loading" );
16614 onLoad : function ()
16621 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16622 * @param {HTMLElement} node
16623 * @return {HTMLElement} The template node
16625 findItemFromChild : function(node){
16626 var el = this.dataName ?
16627 this.el.child('.roo-tpl-' + this.dataName,true) :
16630 if(!node || node.parentNode == el){
16633 var p = node.parentNode;
16634 while(p && p != el){
16635 if(p.parentNode == el){
16644 onClick : function(e){
16645 var item = this.findItemFromChild(e.getTarget());
16647 var index = this.indexOf(item);
16648 if(this.onItemClick(item, index, e) !== false){
16649 this.fireEvent("click", this, index, item, e);
16652 this.clearSelections();
16657 onContextMenu : function(e){
16658 var item = this.findItemFromChild(e.getTarget());
16660 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16665 onDblClick : function(e){
16666 var item = this.findItemFromChild(e.getTarget());
16668 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16672 onItemClick : function(item, index, e)
16674 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16677 if (this.toggleSelect) {
16678 var m = this.isSelected(item) ? 'unselect' : 'select';
16681 _t[m](item, true, false);
16684 if(this.multiSelect || this.singleSelect){
16685 if(this.multiSelect && e.shiftKey && this.lastSelection){
16686 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16688 this.select(item, this.multiSelect && e.ctrlKey);
16689 this.lastSelection = item;
16692 if(!this.tickable){
16693 e.preventDefault();
16701 * Get the number of selected nodes.
16704 getSelectionCount : function(){
16705 return this.selections.length;
16709 * Get the currently selected nodes.
16710 * @return {Array} An array of HTMLElements
16712 getSelectedNodes : function(){
16713 return this.selections;
16717 * Get the indexes of the selected nodes.
16720 getSelectedIndexes : function(){
16721 var indexes = [], s = this.selections;
16722 for(var i = 0, len = s.length; i < len; i++){
16723 indexes.push(s[i].nodeIndex);
16729 * Clear all selections
16730 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16732 clearSelections : function(suppressEvent){
16733 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16734 this.cmp.elements = this.selections;
16735 this.cmp.removeClass(this.selectedClass);
16736 this.selections = [];
16737 if(!suppressEvent){
16738 this.fireEvent("selectionchange", this, this.selections);
16744 * Returns true if the passed node is selected
16745 * @param {HTMLElement/Number} node The node or node index
16746 * @return {Boolean}
16748 isSelected : function(node){
16749 var s = this.selections;
16753 node = this.getNode(node);
16754 return s.indexOf(node) !== -1;
16759 * @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
16760 * @param {Boolean} keepExisting (optional) true to keep existing selections
16761 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16763 select : function(nodeInfo, keepExisting, suppressEvent){
16764 if(nodeInfo instanceof Array){
16766 this.clearSelections(true);
16768 for(var i = 0, len = nodeInfo.length; i < len; i++){
16769 this.select(nodeInfo[i], true, true);
16773 var node = this.getNode(nodeInfo);
16774 if(!node || this.isSelected(node)){
16775 return; // already selected.
16778 this.clearSelections(true);
16781 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16782 Roo.fly(node).addClass(this.selectedClass);
16783 this.selections.push(node);
16784 if(!suppressEvent){
16785 this.fireEvent("selectionchange", this, this.selections);
16793 * @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
16794 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16795 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16797 unselect : function(nodeInfo, keepExisting, suppressEvent)
16799 if(nodeInfo instanceof Array){
16800 Roo.each(this.selections, function(s) {
16801 this.unselect(s, nodeInfo);
16805 var node = this.getNode(nodeInfo);
16806 if(!node || !this.isSelected(node)){
16807 //Roo.log("not selected");
16808 return; // not selected.
16812 Roo.each(this.selections, function(s) {
16814 Roo.fly(node).removeClass(this.selectedClass);
16821 this.selections= ns;
16822 this.fireEvent("selectionchange", this, this.selections);
16826 * Gets a template node.
16827 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16828 * @return {HTMLElement} The node or null if it wasn't found
16830 getNode : function(nodeInfo){
16831 if(typeof nodeInfo == "string"){
16832 return document.getElementById(nodeInfo);
16833 }else if(typeof nodeInfo == "number"){
16834 return this.nodes[nodeInfo];
16840 * Gets a range template nodes.
16841 * @param {Number} startIndex
16842 * @param {Number} endIndex
16843 * @return {Array} An array of nodes
16845 getNodes : function(start, end){
16846 var ns = this.nodes;
16847 start = start || 0;
16848 end = typeof end == "undefined" ? ns.length - 1 : end;
16851 for(var i = start; i <= end; i++){
16855 for(var i = start; i >= end; i--){
16863 * Finds the index of the passed node
16864 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16865 * @return {Number} The index of the node or -1
16867 indexOf : function(node){
16868 node = this.getNode(node);
16869 if(typeof node.nodeIndex == "number"){
16870 return node.nodeIndex;
16872 var ns = this.nodes;
16873 for(var i = 0, len = ns.length; i < len; i++){
16884 * based on jquery fullcalendar
16888 Roo.bootstrap = Roo.bootstrap || {};
16890 * @class Roo.bootstrap.Calendar
16891 * @extends Roo.bootstrap.Component
16892 * Bootstrap Calendar class
16893 * @cfg {Boolean} loadMask (true|false) default false
16894 * @cfg {Object} header generate the user specific header of the calendar, default false
16897 * Create a new Container
16898 * @param {Object} config The config object
16903 Roo.bootstrap.Calendar = function(config){
16904 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16908 * Fires when a date is selected
16909 * @param {DatePicker} this
16910 * @param {Date} date The selected date
16914 * @event monthchange
16915 * Fires when the displayed month changes
16916 * @param {DatePicker} this
16917 * @param {Date} date The selected month
16919 'monthchange': true,
16921 * @event evententer
16922 * Fires when mouse over an event
16923 * @param {Calendar} this
16924 * @param {event} Event
16926 'evententer': true,
16928 * @event eventleave
16929 * Fires when the mouse leaves an
16930 * @param {Calendar} this
16933 'eventleave': true,
16935 * @event eventclick
16936 * Fires when the mouse click an
16937 * @param {Calendar} this
16946 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16949 * @cfg {Number} startDay
16950 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16958 getAutoCreate : function(){
16961 var fc_button = function(name, corner, style, content ) {
16962 return Roo.apply({},{
16964 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16966 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16969 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16980 style : 'width:100%',
16987 cls : 'fc-header-left',
16989 fc_button('prev', 'left', 'arrow', '‹' ),
16990 fc_button('next', 'right', 'arrow', '›' ),
16991 { tag: 'span', cls: 'fc-header-space' },
16992 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
17000 cls : 'fc-header-center',
17004 cls: 'fc-header-title',
17007 html : 'month / year'
17015 cls : 'fc-header-right',
17017 /* fc_button('month', 'left', '', 'month' ),
17018 fc_button('week', '', '', 'week' ),
17019 fc_button('day', 'right', '', 'day' )
17031 header = this.header;
17034 var cal_heads = function() {
17036 // fixme - handle this.
17038 for (var i =0; i < Date.dayNames.length; i++) {
17039 var d = Date.dayNames[i];
17042 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17043 html : d.substring(0,3)
17047 ret[0].cls += ' fc-first';
17048 ret[6].cls += ' fc-last';
17051 var cal_cell = function(n) {
17054 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17059 cls: 'fc-day-number',
17063 cls: 'fc-day-content',
17067 style: 'position: relative;' // height: 17px;
17079 var cal_rows = function() {
17082 for (var r = 0; r < 6; r++) {
17089 for (var i =0; i < Date.dayNames.length; i++) {
17090 var d = Date.dayNames[i];
17091 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17094 row.cn[0].cls+=' fc-first';
17095 row.cn[0].cn[0].style = 'min-height:90px';
17096 row.cn[6].cls+=' fc-last';
17100 ret[0].cls += ' fc-first';
17101 ret[4].cls += ' fc-prev-last';
17102 ret[5].cls += ' fc-last';
17109 cls: 'fc-border-separate',
17110 style : 'width:100%',
17118 cls : 'fc-first fc-last',
17136 cls : 'fc-content',
17137 style : "position: relative;",
17140 cls : 'fc-view fc-view-month fc-grid',
17141 style : 'position: relative',
17142 unselectable : 'on',
17145 cls : 'fc-event-container',
17146 style : 'position:absolute;z-index:8;top:0;left:0;'
17164 initEvents : function()
17167 throw "can not find store for calendar";
17173 style: "text-align:center",
17177 style: "background-color:white;width:50%;margin:250 auto",
17181 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17192 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17194 var size = this.el.select('.fc-content', true).first().getSize();
17195 this.maskEl.setSize(size.width, size.height);
17196 this.maskEl.enableDisplayMode("block");
17197 if(!this.loadMask){
17198 this.maskEl.hide();
17201 this.store = Roo.factory(this.store, Roo.data);
17202 this.store.on('load', this.onLoad, this);
17203 this.store.on('beforeload', this.onBeforeLoad, this);
17207 this.cells = this.el.select('.fc-day',true);
17208 //Roo.log(this.cells);
17209 this.textNodes = this.el.query('.fc-day-number');
17210 this.cells.addClassOnOver('fc-state-hover');
17212 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17213 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17214 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17215 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17217 this.on('monthchange', this.onMonthChange, this);
17219 this.update(new Date().clearTime());
17222 resize : function() {
17223 var sz = this.el.getSize();
17225 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17226 this.el.select('.fc-day-content div',true).setHeight(34);
17231 showPrevMonth : function(e){
17232 this.update(this.activeDate.add("mo", -1));
17234 showToday : function(e){
17235 this.update(new Date().clearTime());
17238 showNextMonth : function(e){
17239 this.update(this.activeDate.add("mo", 1));
17243 showPrevYear : function(){
17244 this.update(this.activeDate.add("y", -1));
17248 showNextYear : function(){
17249 this.update(this.activeDate.add("y", 1));
17254 update : function(date)
17256 var vd = this.activeDate;
17257 this.activeDate = date;
17258 // if(vd && this.el){
17259 // var t = date.getTime();
17260 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17261 // Roo.log('using add remove');
17263 // this.fireEvent('monthchange', this, date);
17265 // this.cells.removeClass("fc-state-highlight");
17266 // this.cells.each(function(c){
17267 // if(c.dateValue == t){
17268 // c.addClass("fc-state-highlight");
17269 // setTimeout(function(){
17270 // try{c.dom.firstChild.focus();}catch(e){}
17280 var days = date.getDaysInMonth();
17282 var firstOfMonth = date.getFirstDateOfMonth();
17283 var startingPos = firstOfMonth.getDay()-this.startDay;
17285 if(startingPos < this.startDay){
17289 var pm = date.add(Date.MONTH, -1);
17290 var prevStart = pm.getDaysInMonth()-startingPos;
17292 this.cells = this.el.select('.fc-day',true);
17293 this.textNodes = this.el.query('.fc-day-number');
17294 this.cells.addClassOnOver('fc-state-hover');
17296 var cells = this.cells.elements;
17297 var textEls = this.textNodes;
17299 Roo.each(cells, function(cell){
17300 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17303 days += startingPos;
17305 // convert everything to numbers so it's fast
17306 var day = 86400000;
17307 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17310 //Roo.log(prevStart);
17312 var today = new Date().clearTime().getTime();
17313 var sel = date.clearTime().getTime();
17314 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17315 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17316 var ddMatch = this.disabledDatesRE;
17317 var ddText = this.disabledDatesText;
17318 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17319 var ddaysText = this.disabledDaysText;
17320 var format = this.format;
17322 var setCellClass = function(cal, cell){
17326 //Roo.log('set Cell Class');
17328 var t = d.getTime();
17332 cell.dateValue = t;
17334 cell.className += " fc-today";
17335 cell.className += " fc-state-highlight";
17336 cell.title = cal.todayText;
17339 // disable highlight in other month..
17340 //cell.className += " fc-state-highlight";
17345 cell.className = " fc-state-disabled";
17346 cell.title = cal.minText;
17350 cell.className = " fc-state-disabled";
17351 cell.title = cal.maxText;
17355 if(ddays.indexOf(d.getDay()) != -1){
17356 cell.title = ddaysText;
17357 cell.className = " fc-state-disabled";
17360 if(ddMatch && format){
17361 var fvalue = d.dateFormat(format);
17362 if(ddMatch.test(fvalue)){
17363 cell.title = ddText.replace("%0", fvalue);
17364 cell.className = " fc-state-disabled";
17368 if (!cell.initialClassName) {
17369 cell.initialClassName = cell.dom.className;
17372 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17377 for(; i < startingPos; i++) {
17378 textEls[i].innerHTML = (++prevStart);
17379 d.setDate(d.getDate()+1);
17381 cells[i].className = "fc-past fc-other-month";
17382 setCellClass(this, cells[i]);
17387 for(; i < days; i++){
17388 intDay = i - startingPos + 1;
17389 textEls[i].innerHTML = (intDay);
17390 d.setDate(d.getDate()+1);
17392 cells[i].className = ''; // "x-date-active";
17393 setCellClass(this, cells[i]);
17397 for(; i < 42; i++) {
17398 textEls[i].innerHTML = (++extraDays);
17399 d.setDate(d.getDate()+1);
17401 cells[i].className = "fc-future fc-other-month";
17402 setCellClass(this, cells[i]);
17405 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17407 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17409 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17410 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17412 if(totalRows != 6){
17413 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17414 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17417 this.fireEvent('monthchange', this, date);
17421 if(!this.internalRender){
17422 var main = this.el.dom.firstChild;
17423 var w = main.offsetWidth;
17424 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17425 Roo.fly(main).setWidth(w);
17426 this.internalRender = true;
17427 // opera does not respect the auto grow header center column
17428 // then, after it gets a width opera refuses to recalculate
17429 // without a second pass
17430 if(Roo.isOpera && !this.secondPass){
17431 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17432 this.secondPass = true;
17433 this.update.defer(10, this, [date]);
17440 findCell : function(dt) {
17441 dt = dt.clearTime().getTime();
17443 this.cells.each(function(c){
17444 //Roo.log("check " +c.dateValue + '?=' + dt);
17445 if(c.dateValue == dt){
17455 findCells : function(ev) {
17456 var s = ev.start.clone().clearTime().getTime();
17458 var e= ev.end.clone().clearTime().getTime();
17461 this.cells.each(function(c){
17462 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17464 if(c.dateValue > e){
17467 if(c.dateValue < s){
17476 // findBestRow: function(cells)
17480 // for (var i =0 ; i < cells.length;i++) {
17481 // ret = Math.max(cells[i].rows || 0,ret);
17488 addItem : function(ev)
17490 // look for vertical location slot in
17491 var cells = this.findCells(ev);
17493 // ev.row = this.findBestRow(cells);
17495 // work out the location.
17499 for(var i =0; i < cells.length; i++) {
17501 cells[i].row = cells[0].row;
17504 cells[i].row = cells[i].row + 1;
17514 if (crow.start.getY() == cells[i].getY()) {
17516 crow.end = cells[i];
17533 cells[0].events.push(ev);
17535 this.calevents.push(ev);
17538 clearEvents: function() {
17540 if(!this.calevents){
17544 Roo.each(this.cells.elements, function(c){
17550 Roo.each(this.calevents, function(e) {
17551 Roo.each(e.els, function(el) {
17552 el.un('mouseenter' ,this.onEventEnter, this);
17553 el.un('mouseleave' ,this.onEventLeave, this);
17558 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17564 renderEvents: function()
17568 this.cells.each(function(c) {
17577 if(c.row != c.events.length){
17578 r = 4 - (4 - (c.row - c.events.length));
17581 c.events = ev.slice(0, r);
17582 c.more = ev.slice(r);
17584 if(c.more.length && c.more.length == 1){
17585 c.events.push(c.more.pop());
17588 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17592 this.cells.each(function(c) {
17594 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17597 for (var e = 0; e < c.events.length; e++){
17598 var ev = c.events[e];
17599 var rows = ev.rows;
17601 for(var i = 0; i < rows.length; i++) {
17603 // how many rows should it span..
17606 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17607 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17609 unselectable : "on",
17612 cls: 'fc-event-inner',
17616 // cls: 'fc-event-time',
17617 // html : cells.length > 1 ? '' : ev.time
17621 cls: 'fc-event-title',
17622 html : String.format('{0}', ev.title)
17629 cls: 'ui-resizable-handle ui-resizable-e',
17630 html : '  '
17637 cfg.cls += ' fc-event-start';
17639 if ((i+1) == rows.length) {
17640 cfg.cls += ' fc-event-end';
17643 var ctr = _this.el.select('.fc-event-container',true).first();
17644 var cg = ctr.createChild(cfg);
17646 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17647 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17649 var r = (c.more.length) ? 1 : 0;
17650 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17651 cg.setWidth(ebox.right - sbox.x -2);
17653 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17654 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17655 cg.on('click', _this.onEventClick, _this, ev);
17666 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17667 style : 'position: absolute',
17668 unselectable : "on",
17671 cls: 'fc-event-inner',
17675 cls: 'fc-event-title',
17683 cls: 'ui-resizable-handle ui-resizable-e',
17684 html : '  '
17690 var ctr = _this.el.select('.fc-event-container',true).first();
17691 var cg = ctr.createChild(cfg);
17693 var sbox = c.select('.fc-day-content',true).first().getBox();
17694 var ebox = c.select('.fc-day-content',true).first().getBox();
17696 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17697 cg.setWidth(ebox.right - sbox.x -2);
17699 cg.on('click', _this.onMoreEventClick, _this, c.more);
17709 onEventEnter: function (e, el,event,d) {
17710 this.fireEvent('evententer', this, el, event);
17713 onEventLeave: function (e, el,event,d) {
17714 this.fireEvent('eventleave', this, el, event);
17717 onEventClick: function (e, el,event,d) {
17718 this.fireEvent('eventclick', this, el, event);
17721 onMonthChange: function () {
17725 onMoreEventClick: function(e, el, more)
17729 this.calpopover.placement = 'right';
17730 this.calpopover.setTitle('More');
17732 this.calpopover.setContent('');
17734 var ctr = this.calpopover.el.select('.popover-content', true).first();
17736 Roo.each(more, function(m){
17738 cls : 'fc-event-hori fc-event-draggable',
17741 var cg = ctr.createChild(cfg);
17743 cg.on('click', _this.onEventClick, _this, m);
17746 this.calpopover.show(el);
17751 onLoad: function ()
17753 this.calevents = [];
17756 if(this.store.getCount() > 0){
17757 this.store.data.each(function(d){
17760 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17761 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17762 time : d.data.start_time,
17763 title : d.data.title,
17764 description : d.data.description,
17765 venue : d.data.venue
17770 this.renderEvents();
17772 if(this.calevents.length && this.loadMask){
17773 this.maskEl.hide();
17777 onBeforeLoad: function()
17779 this.clearEvents();
17781 this.maskEl.show();
17795 * @class Roo.bootstrap.Popover
17796 * @extends Roo.bootstrap.Component
17797 * Bootstrap Popover class
17798 * @cfg {String} html contents of the popover (or false to use children..)
17799 * @cfg {String} title of popover (or false to hide)
17800 * @cfg {String} placement how it is placed
17801 * @cfg {String} trigger click || hover (or false to trigger manually)
17802 * @cfg {String} over what (parent or false to trigger manually.)
17803 * @cfg {Number} delay - delay before showing
17806 * Create a new Popover
17807 * @param {Object} config The config object
17810 Roo.bootstrap.Popover = function(config){
17811 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17817 * After the popover show
17819 * @param {Roo.bootstrap.Popover} this
17824 * After the popover hide
17826 * @param {Roo.bootstrap.Popover} this
17832 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17834 title: 'Fill in a title',
17837 placement : 'right',
17838 trigger : 'hover', // hover
17844 can_build_overlaid : false,
17846 getChildContainer : function()
17848 return this.el.select('.popover-content',true).first();
17851 getAutoCreate : function(){
17854 cls : 'popover roo-dynamic',
17855 style: 'display:block',
17861 cls : 'popover-inner',
17865 cls: 'popover-title popover-header',
17869 cls : 'popover-content popover-body',
17880 setTitle: function(str)
17883 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17885 setContent: function(str)
17888 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17890 // as it get's added to the bottom of the page.
17891 onRender : function(ct, position)
17893 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17895 var cfg = Roo.apply({}, this.getAutoCreate());
17899 cfg.cls += ' ' + this.cls;
17902 cfg.style = this.style;
17904 //Roo.log("adding to ");
17905 this.el = Roo.get(document.body).createChild(cfg, position);
17906 // Roo.log(this.el);
17911 initEvents : function()
17913 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17914 this.el.enableDisplayMode('block');
17916 if (this.over === false) {
17919 if (this.triggers === false) {
17922 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17923 var triggers = this.trigger ? this.trigger.split(' ') : [];
17924 Roo.each(triggers, function(trigger) {
17926 if (trigger == 'click') {
17927 on_el.on('click', this.toggle, this);
17928 } else if (trigger != 'manual') {
17929 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17930 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17932 on_el.on(eventIn ,this.enter, this);
17933 on_el.on(eventOut, this.leave, this);
17944 toggle : function () {
17945 this.hoverState == 'in' ? this.leave() : this.enter();
17948 enter : function () {
17950 clearTimeout(this.timeout);
17952 this.hoverState = 'in';
17954 if (!this.delay || !this.delay.show) {
17959 this.timeout = setTimeout(function () {
17960 if (_t.hoverState == 'in') {
17963 }, this.delay.show)
17966 leave : function() {
17967 clearTimeout(this.timeout);
17969 this.hoverState = 'out';
17971 if (!this.delay || !this.delay.hide) {
17976 this.timeout = setTimeout(function () {
17977 if (_t.hoverState == 'out') {
17980 }, this.delay.hide)
17983 show : function (on_el)
17986 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17990 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17991 if (this.html !== false) {
17992 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17994 this.el.removeClass([
17995 'fade','top','bottom', 'left', 'right','in',
17996 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17998 if (!this.title.length) {
17999 this.el.select('.popover-title',true).hide();
18002 var placement = typeof this.placement == 'function' ?
18003 this.placement.call(this, this.el, on_el) :
18006 var autoToken = /\s?auto?\s?/i;
18007 var autoPlace = autoToken.test(placement);
18009 placement = placement.replace(autoToken, '') || 'top';
18013 //this.el.setXY([0,0]);
18015 this.el.dom.style.display='block';
18016 this.el.addClass(placement);
18018 //this.el.appendTo(on_el);
18020 var p = this.getPosition();
18021 var box = this.el.getBox();
18026 var align = Roo.bootstrap.Popover.alignment[placement];
18029 this.el.alignTo(on_el, align[0],align[1]);
18030 //var arrow = this.el.select('.arrow',true).first();
18031 //arrow.set(align[2],
18033 this.el.addClass('in');
18036 if (this.el.hasClass('fade')) {
18040 this.hoverState = 'in';
18042 this.fireEvent('show', this);
18047 this.el.setXY([0,0]);
18048 this.el.removeClass('in');
18050 this.hoverState = null;
18052 this.fireEvent('hide', this);
18057 Roo.bootstrap.Popover.alignment = {
18058 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18059 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18060 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18061 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18072 * @class Roo.bootstrap.Progress
18073 * @extends Roo.bootstrap.Component
18074 * Bootstrap Progress class
18075 * @cfg {Boolean} striped striped of the progress bar
18076 * @cfg {Boolean} active animated of the progress bar
18080 * Create a new Progress
18081 * @param {Object} config The config object
18084 Roo.bootstrap.Progress = function(config){
18085 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18088 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18093 getAutoCreate : function(){
18101 cfg.cls += ' progress-striped';
18105 cfg.cls += ' active';
18124 * @class Roo.bootstrap.ProgressBar
18125 * @extends Roo.bootstrap.Component
18126 * Bootstrap ProgressBar class
18127 * @cfg {Number} aria_valuenow aria-value now
18128 * @cfg {Number} aria_valuemin aria-value min
18129 * @cfg {Number} aria_valuemax aria-value max
18130 * @cfg {String} label label for the progress bar
18131 * @cfg {String} panel (success | info | warning | danger )
18132 * @cfg {String} role role of the progress bar
18133 * @cfg {String} sr_only text
18137 * Create a new ProgressBar
18138 * @param {Object} config The config object
18141 Roo.bootstrap.ProgressBar = function(config){
18142 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18145 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18149 aria_valuemax : 100,
18155 getAutoCreate : function()
18160 cls: 'progress-bar',
18161 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18173 cfg.role = this.role;
18176 if(this.aria_valuenow){
18177 cfg['aria-valuenow'] = this.aria_valuenow;
18180 if(this.aria_valuemin){
18181 cfg['aria-valuemin'] = this.aria_valuemin;
18184 if(this.aria_valuemax){
18185 cfg['aria-valuemax'] = this.aria_valuemax;
18188 if(this.label && !this.sr_only){
18189 cfg.html = this.label;
18193 cfg.cls += ' progress-bar-' + this.panel;
18199 update : function(aria_valuenow)
18201 this.aria_valuenow = aria_valuenow;
18203 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18218 * @class Roo.bootstrap.TabGroup
18219 * @extends Roo.bootstrap.Column
18220 * Bootstrap Column class
18221 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18222 * @cfg {Boolean} carousel true to make the group behave like a carousel
18223 * @cfg {Boolean} bullets show bullets for the panels
18224 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18225 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18226 * @cfg {Boolean} showarrow (true|false) show arrow default true
18229 * Create a new TabGroup
18230 * @param {Object} config The config object
18233 Roo.bootstrap.TabGroup = function(config){
18234 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18236 this.navId = Roo.id();
18239 Roo.bootstrap.TabGroup.register(this);
18243 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18246 transition : false,
18251 slideOnTouch : false,
18254 getAutoCreate : function()
18256 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18258 cfg.cls += ' tab-content';
18260 if (this.carousel) {
18261 cfg.cls += ' carousel slide';
18264 cls : 'carousel-inner',
18268 if(this.bullets && !Roo.isTouch){
18271 cls : 'carousel-bullets',
18275 if(this.bullets_cls){
18276 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18283 cfg.cn[0].cn.push(bullets);
18286 if(this.showarrow){
18287 cfg.cn[0].cn.push({
18289 class : 'carousel-arrow',
18293 class : 'carousel-prev',
18297 class : 'fa fa-chevron-left'
18303 class : 'carousel-next',
18307 class : 'fa fa-chevron-right'
18320 initEvents: function()
18322 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18323 // this.el.on("touchstart", this.onTouchStart, this);
18326 if(this.autoslide){
18329 this.slideFn = window.setInterval(function() {
18330 _this.showPanelNext();
18334 if(this.showarrow){
18335 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18336 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18342 // onTouchStart : function(e, el, o)
18344 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18348 // this.showPanelNext();
18352 getChildContainer : function()
18354 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18358 * register a Navigation item
18359 * @param {Roo.bootstrap.NavItem} the navitem to add
18361 register : function(item)
18363 this.tabs.push( item);
18364 item.navId = this.navId; // not really needed..
18369 getActivePanel : function()
18372 Roo.each(this.tabs, function(t) {
18382 getPanelByName : function(n)
18385 Roo.each(this.tabs, function(t) {
18386 if (t.tabId == n) {
18394 indexOfPanel : function(p)
18397 Roo.each(this.tabs, function(t,i) {
18398 if (t.tabId == p.tabId) {
18407 * show a specific panel
18408 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18409 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18411 showPanel : function (pan)
18413 if(this.transition || typeof(pan) == 'undefined'){
18414 Roo.log("waiting for the transitionend");
18418 if (typeof(pan) == 'number') {
18419 pan = this.tabs[pan];
18422 if (typeof(pan) == 'string') {
18423 pan = this.getPanelByName(pan);
18426 var cur = this.getActivePanel();
18429 Roo.log('pan or acitve pan is undefined');
18433 if (pan.tabId == this.getActivePanel().tabId) {
18437 if (false === cur.fireEvent('beforedeactivate')) {
18441 if(this.bullets > 0 && !Roo.isTouch){
18442 this.setActiveBullet(this.indexOfPanel(pan));
18445 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18447 //class="carousel-item carousel-item-next carousel-item-left"
18449 this.transition = true;
18450 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18451 var lr = dir == 'next' ? 'left' : 'right';
18452 pan.el.addClass(dir); // or prev
18453 pan.el.addClass('carousel-item-' + dir); // or prev
18454 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18455 cur.el.addClass(lr); // or right
18456 pan.el.addClass(lr);
18457 cur.el.addClass('carousel-item-' +lr); // or right
18458 pan.el.addClass('carousel-item-' +lr);
18462 cur.el.on('transitionend', function() {
18463 Roo.log("trans end?");
18465 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18466 pan.setActive(true);
18468 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18469 cur.setActive(false);
18471 _this.transition = false;
18473 }, this, { single: true } );
18478 cur.setActive(false);
18479 pan.setActive(true);
18484 showPanelNext : function()
18486 var i = this.indexOfPanel(this.getActivePanel());
18488 if (i >= this.tabs.length - 1 && !this.autoslide) {
18492 if (i >= this.tabs.length - 1 && this.autoslide) {
18496 this.showPanel(this.tabs[i+1]);
18499 showPanelPrev : function()
18501 var i = this.indexOfPanel(this.getActivePanel());
18503 if (i < 1 && !this.autoslide) {
18507 if (i < 1 && this.autoslide) {
18508 i = this.tabs.length;
18511 this.showPanel(this.tabs[i-1]);
18515 addBullet: function()
18517 if(!this.bullets || Roo.isTouch){
18520 var ctr = this.el.select('.carousel-bullets',true).first();
18521 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18522 var bullet = ctr.createChild({
18523 cls : 'bullet bullet-' + i
18524 },ctr.dom.lastChild);
18529 bullet.on('click', (function(e, el, o, ii, t){
18531 e.preventDefault();
18533 this.showPanel(ii);
18535 if(this.autoslide && this.slideFn){
18536 clearInterval(this.slideFn);
18537 this.slideFn = window.setInterval(function() {
18538 _this.showPanelNext();
18542 }).createDelegate(this, [i, bullet], true));
18547 setActiveBullet : function(i)
18553 Roo.each(this.el.select('.bullet', true).elements, function(el){
18554 el.removeClass('selected');
18557 var bullet = this.el.select('.bullet-' + i, true).first();
18563 bullet.addClass('selected');
18574 Roo.apply(Roo.bootstrap.TabGroup, {
18578 * register a Navigation Group
18579 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18581 register : function(navgrp)
18583 this.groups[navgrp.navId] = navgrp;
18587 * fetch a Navigation Group based on the navigation ID
18588 * if one does not exist , it will get created.
18589 * @param {string} the navgroup to add
18590 * @returns {Roo.bootstrap.NavGroup} the navgroup
18592 get: function(navId) {
18593 if (typeof(this.groups[navId]) == 'undefined') {
18594 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18596 return this.groups[navId] ;
18611 * @class Roo.bootstrap.TabPanel
18612 * @extends Roo.bootstrap.Component
18613 * Bootstrap TabPanel class
18614 * @cfg {Boolean} active panel active
18615 * @cfg {String} html panel content
18616 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18617 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18618 * @cfg {String} href click to link..
18622 * Create a new TabPanel
18623 * @param {Object} config The config object
18626 Roo.bootstrap.TabPanel = function(config){
18627 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18631 * Fires when the active status changes
18632 * @param {Roo.bootstrap.TabPanel} this
18633 * @param {Boolean} state the new state
18638 * @event beforedeactivate
18639 * Fires before a tab is de-activated - can be used to do validation on a form.
18640 * @param {Roo.bootstrap.TabPanel} this
18641 * @return {Boolean} false if there is an error
18644 'beforedeactivate': true
18647 this.tabId = this.tabId || Roo.id();
18651 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18659 getAutoCreate : function(){
18664 // item is needed for carousel - not sure if it has any effect otherwise
18665 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18666 html: this.html || ''
18670 cfg.cls += ' active';
18674 cfg.tabId = this.tabId;
18682 initEvents: function()
18684 var p = this.parent();
18686 this.navId = this.navId || p.navId;
18688 if (typeof(this.navId) != 'undefined') {
18689 // not really needed.. but just in case.. parent should be a NavGroup.
18690 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18694 var i = tg.tabs.length - 1;
18696 if(this.active && tg.bullets > 0 && i < tg.bullets){
18697 tg.setActiveBullet(i);
18701 this.el.on('click', this.onClick, this);
18704 this.el.on("touchstart", this.onTouchStart, this);
18705 this.el.on("touchmove", this.onTouchMove, this);
18706 this.el.on("touchend", this.onTouchEnd, this);
18711 onRender : function(ct, position)
18713 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18716 setActive : function(state)
18718 Roo.log("panel - set active " + this.tabId + "=" + state);
18720 this.active = state;
18722 this.el.removeClass('active');
18724 } else if (!this.el.hasClass('active')) {
18725 this.el.addClass('active');
18728 this.fireEvent('changed', this, state);
18731 onClick : function(e)
18733 e.preventDefault();
18735 if(!this.href.length){
18739 window.location.href = this.href;
18748 onTouchStart : function(e)
18750 this.swiping = false;
18752 this.startX = e.browserEvent.touches[0].clientX;
18753 this.startY = e.browserEvent.touches[0].clientY;
18756 onTouchMove : function(e)
18758 this.swiping = true;
18760 this.endX = e.browserEvent.touches[0].clientX;
18761 this.endY = e.browserEvent.touches[0].clientY;
18764 onTouchEnd : function(e)
18771 var tabGroup = this.parent();
18773 if(this.endX > this.startX){ // swiping right
18774 tabGroup.showPanelPrev();
18778 if(this.startX > this.endX){ // swiping left
18779 tabGroup.showPanelNext();
18798 * @class Roo.bootstrap.DateField
18799 * @extends Roo.bootstrap.Input
18800 * Bootstrap DateField class
18801 * @cfg {Number} weekStart default 0
18802 * @cfg {String} viewMode default empty, (months|years)
18803 * @cfg {String} minViewMode default empty, (months|years)
18804 * @cfg {Number} startDate default -Infinity
18805 * @cfg {Number} endDate default Infinity
18806 * @cfg {Boolean} todayHighlight default false
18807 * @cfg {Boolean} todayBtn default false
18808 * @cfg {Boolean} calendarWeeks default false
18809 * @cfg {Object} daysOfWeekDisabled default empty
18810 * @cfg {Boolean} singleMode default false (true | false)
18812 * @cfg {Boolean} keyboardNavigation default true
18813 * @cfg {String} language default en
18816 * Create a new DateField
18817 * @param {Object} config The config object
18820 Roo.bootstrap.DateField = function(config){
18821 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18825 * Fires when this field show.
18826 * @param {Roo.bootstrap.DateField} this
18827 * @param {Mixed} date The date value
18832 * Fires when this field hide.
18833 * @param {Roo.bootstrap.DateField} this
18834 * @param {Mixed} date The date value
18839 * Fires when select a date.
18840 * @param {Roo.bootstrap.DateField} this
18841 * @param {Mixed} date The date value
18845 * @event beforeselect
18846 * Fires when before select a date.
18847 * @param {Roo.bootstrap.DateField} this
18848 * @param {Mixed} date The date value
18850 beforeselect : true
18854 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18857 * @cfg {String} format
18858 * The default date format string which can be overriden for localization support. The format must be
18859 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18863 * @cfg {String} altFormats
18864 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18865 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18867 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18875 todayHighlight : false,
18881 keyboardNavigation: true,
18883 calendarWeeks: false,
18885 startDate: -Infinity,
18889 daysOfWeekDisabled: [],
18893 singleMode : false,
18895 UTCDate: function()
18897 return new Date(Date.UTC.apply(Date, arguments));
18900 UTCToday: function()
18902 var today = new Date();
18903 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18906 getDate: function() {
18907 var d = this.getUTCDate();
18908 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18911 getUTCDate: function() {
18915 setDate: function(d) {
18916 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18919 setUTCDate: function(d) {
18921 this.setValue(this.formatDate(this.date));
18924 onRender: function(ct, position)
18927 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18929 this.language = this.language || 'en';
18930 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18931 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18933 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18934 this.format = this.format || 'm/d/y';
18935 this.isInline = false;
18936 this.isInput = true;
18937 this.component = this.el.select('.add-on', true).first() || false;
18938 this.component = (this.component && this.component.length === 0) ? false : this.component;
18939 this.hasInput = this.component && this.inputEl().length;
18941 if (typeof(this.minViewMode === 'string')) {
18942 switch (this.minViewMode) {
18944 this.minViewMode = 1;
18947 this.minViewMode = 2;
18950 this.minViewMode = 0;
18955 if (typeof(this.viewMode === 'string')) {
18956 switch (this.viewMode) {
18969 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18971 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18973 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18975 this.picker().on('mousedown', this.onMousedown, this);
18976 this.picker().on('click', this.onClick, this);
18978 this.picker().addClass('datepicker-dropdown');
18980 this.startViewMode = this.viewMode;
18982 if(this.singleMode){
18983 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18984 v.setVisibilityMode(Roo.Element.DISPLAY);
18988 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18989 v.setStyle('width', '189px');
18993 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18994 if(!this.calendarWeeks){
18999 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19000 v.attr('colspan', function(i, val){
19001 return parseInt(val) + 1;
19006 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
19008 this.setStartDate(this.startDate);
19009 this.setEndDate(this.endDate);
19011 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
19018 if(this.isInline) {
19023 picker : function()
19025 return this.pickerEl;
19026 // return this.el.select('.datepicker', true).first();
19029 fillDow: function()
19031 var dowCnt = this.weekStart;
19040 if(this.calendarWeeks){
19048 while (dowCnt < this.weekStart + 7) {
19052 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19056 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19059 fillMonths: function()
19062 var months = this.picker().select('>.datepicker-months td', true).first();
19064 months.dom.innerHTML = '';
19070 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19073 months.createChild(month);
19080 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;
19082 if (this.date < this.startDate) {
19083 this.viewDate = new Date(this.startDate);
19084 } else if (this.date > this.endDate) {
19085 this.viewDate = new Date(this.endDate);
19087 this.viewDate = new Date(this.date);
19095 var d = new Date(this.viewDate),
19096 year = d.getUTCFullYear(),
19097 month = d.getUTCMonth(),
19098 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19099 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19100 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19101 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19102 currentDate = this.date && this.date.valueOf(),
19103 today = this.UTCToday();
19105 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19107 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19109 // this.picker.select('>tfoot th.today').
19110 // .text(dates[this.language].today)
19111 // .toggle(this.todayBtn !== false);
19113 this.updateNavArrows();
19116 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19118 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19120 prevMonth.setUTCDate(day);
19122 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19124 var nextMonth = new Date(prevMonth);
19126 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19128 nextMonth = nextMonth.valueOf();
19130 var fillMonths = false;
19132 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19134 while(prevMonth.valueOf() <= nextMonth) {
19137 if (prevMonth.getUTCDay() === this.weekStart) {
19139 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19147 if(this.calendarWeeks){
19148 // ISO 8601: First week contains first thursday.
19149 // ISO also states week starts on Monday, but we can be more abstract here.
19151 // Start of current week: based on weekstart/current date
19152 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19153 // Thursday of this week
19154 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19155 // First Thursday of year, year from thursday
19156 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19157 // Calendar week: ms between thursdays, div ms per day, div 7 days
19158 calWeek = (th - yth) / 864e5 / 7 + 1;
19160 fillMonths.cn.push({
19168 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19170 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19173 if (this.todayHighlight &&
19174 prevMonth.getUTCFullYear() == today.getFullYear() &&
19175 prevMonth.getUTCMonth() == today.getMonth() &&
19176 prevMonth.getUTCDate() == today.getDate()) {
19177 clsName += ' today';
19180 if (currentDate && prevMonth.valueOf() === currentDate) {
19181 clsName += ' active';
19184 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19185 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19186 clsName += ' disabled';
19189 fillMonths.cn.push({
19191 cls: 'day ' + clsName,
19192 html: prevMonth.getDate()
19195 prevMonth.setDate(prevMonth.getDate()+1);
19198 var currentYear = this.date && this.date.getUTCFullYear();
19199 var currentMonth = this.date && this.date.getUTCMonth();
19201 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19203 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19204 v.removeClass('active');
19206 if(currentYear === year && k === currentMonth){
19207 v.addClass('active');
19210 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19211 v.addClass('disabled');
19217 year = parseInt(year/10, 10) * 10;
19219 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19221 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19224 for (var i = -1; i < 11; i++) {
19225 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19227 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19235 showMode: function(dir)
19238 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19241 Roo.each(this.picker().select('>div',true).elements, function(v){
19242 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19245 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19250 if(this.isInline) {
19254 this.picker().removeClass(['bottom', 'top']);
19256 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19258 * place to the top of element!
19262 this.picker().addClass('top');
19263 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19268 this.picker().addClass('bottom');
19270 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19273 parseDate : function(value)
19275 if(!value || value instanceof Date){
19278 var v = Date.parseDate(value, this.format);
19279 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19280 v = Date.parseDate(value, 'Y-m-d');
19282 if(!v && this.altFormats){
19283 if(!this.altFormatsArray){
19284 this.altFormatsArray = this.altFormats.split("|");
19286 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19287 v = Date.parseDate(value, this.altFormatsArray[i]);
19293 formatDate : function(date, fmt)
19295 return (!date || !(date instanceof Date)) ?
19296 date : date.dateFormat(fmt || this.format);
19299 onFocus : function()
19301 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19305 onBlur : function()
19307 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19309 var d = this.inputEl().getValue();
19316 showPopup : function()
19318 this.picker().show();
19322 this.fireEvent('showpopup', this, this.date);
19325 hidePopup : function()
19327 if(this.isInline) {
19330 this.picker().hide();
19331 this.viewMode = this.startViewMode;
19334 this.fireEvent('hidepopup', this, this.date);
19338 onMousedown: function(e)
19340 e.stopPropagation();
19341 e.preventDefault();
19346 Roo.bootstrap.DateField.superclass.keyup.call(this);
19350 setValue: function(v)
19352 if(this.fireEvent('beforeselect', this, v) !== false){
19353 var d = new Date(this.parseDate(v) ).clearTime();
19355 if(isNaN(d.getTime())){
19356 this.date = this.viewDate = '';
19357 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19361 v = this.formatDate(d);
19363 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19365 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19369 this.fireEvent('select', this, this.date);
19373 getValue: function()
19375 return this.formatDate(this.date);
19378 fireKey: function(e)
19380 if (!this.picker().isVisible()){
19381 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19387 var dateChanged = false,
19389 newDate, newViewDate;
19394 e.preventDefault();
19398 if (!this.keyboardNavigation) {
19401 dir = e.keyCode == 37 ? -1 : 1;
19404 newDate = this.moveYear(this.date, dir);
19405 newViewDate = this.moveYear(this.viewDate, dir);
19406 } else if (e.shiftKey){
19407 newDate = this.moveMonth(this.date, dir);
19408 newViewDate = this.moveMonth(this.viewDate, dir);
19410 newDate = new Date(this.date);
19411 newDate.setUTCDate(this.date.getUTCDate() + dir);
19412 newViewDate = new Date(this.viewDate);
19413 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19415 if (this.dateWithinRange(newDate)){
19416 this.date = newDate;
19417 this.viewDate = newViewDate;
19418 this.setValue(this.formatDate(this.date));
19420 e.preventDefault();
19421 dateChanged = true;
19426 if (!this.keyboardNavigation) {
19429 dir = e.keyCode == 38 ? -1 : 1;
19431 newDate = this.moveYear(this.date, dir);
19432 newViewDate = this.moveYear(this.viewDate, dir);
19433 } else if (e.shiftKey){
19434 newDate = this.moveMonth(this.date, dir);
19435 newViewDate = this.moveMonth(this.viewDate, dir);
19437 newDate = new Date(this.date);
19438 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19439 newViewDate = new Date(this.viewDate);
19440 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19442 if (this.dateWithinRange(newDate)){
19443 this.date = newDate;
19444 this.viewDate = newViewDate;
19445 this.setValue(this.formatDate(this.date));
19447 e.preventDefault();
19448 dateChanged = true;
19452 this.setValue(this.formatDate(this.date));
19454 e.preventDefault();
19457 this.setValue(this.formatDate(this.date));
19471 onClick: function(e)
19473 e.stopPropagation();
19474 e.preventDefault();
19476 var target = e.getTarget();
19478 if(target.nodeName.toLowerCase() === 'i'){
19479 target = Roo.get(target).dom.parentNode;
19482 var nodeName = target.nodeName;
19483 var className = target.className;
19484 var html = target.innerHTML;
19485 //Roo.log(nodeName);
19487 switch(nodeName.toLowerCase()) {
19489 switch(className) {
19495 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19496 switch(this.viewMode){
19498 this.viewDate = this.moveMonth(this.viewDate, dir);
19502 this.viewDate = this.moveYear(this.viewDate, dir);
19508 var date = new Date();
19509 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19511 this.setValue(this.formatDate(this.date));
19518 if (className.indexOf('disabled') < 0) {
19519 this.viewDate.setUTCDate(1);
19520 if (className.indexOf('month') > -1) {
19521 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19523 var year = parseInt(html, 10) || 0;
19524 this.viewDate.setUTCFullYear(year);
19528 if(this.singleMode){
19529 this.setValue(this.formatDate(this.viewDate));
19540 //Roo.log(className);
19541 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19542 var day = parseInt(html, 10) || 1;
19543 var year = this.viewDate.getUTCFullYear(),
19544 month = this.viewDate.getUTCMonth();
19546 if (className.indexOf('old') > -1) {
19553 } else if (className.indexOf('new') > -1) {
19561 //Roo.log([year,month,day]);
19562 this.date = this.UTCDate(year, month, day,0,0,0,0);
19563 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19565 //Roo.log(this.formatDate(this.date));
19566 this.setValue(this.formatDate(this.date));
19573 setStartDate: function(startDate)
19575 this.startDate = startDate || -Infinity;
19576 if (this.startDate !== -Infinity) {
19577 this.startDate = this.parseDate(this.startDate);
19580 this.updateNavArrows();
19583 setEndDate: function(endDate)
19585 this.endDate = endDate || Infinity;
19586 if (this.endDate !== Infinity) {
19587 this.endDate = this.parseDate(this.endDate);
19590 this.updateNavArrows();
19593 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19595 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19596 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19597 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19599 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19600 return parseInt(d, 10);
19603 this.updateNavArrows();
19606 updateNavArrows: function()
19608 if(this.singleMode){
19612 var d = new Date(this.viewDate),
19613 year = d.getUTCFullYear(),
19614 month = d.getUTCMonth();
19616 Roo.each(this.picker().select('.prev', true).elements, function(v){
19618 switch (this.viewMode) {
19621 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19627 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19634 Roo.each(this.picker().select('.next', true).elements, function(v){
19636 switch (this.viewMode) {
19639 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19645 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19653 moveMonth: function(date, dir)
19658 var new_date = new Date(date.valueOf()),
19659 day = new_date.getUTCDate(),
19660 month = new_date.getUTCMonth(),
19661 mag = Math.abs(dir),
19663 dir = dir > 0 ? 1 : -1;
19666 // If going back one month, make sure month is not current month
19667 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19669 return new_date.getUTCMonth() == month;
19671 // If going forward one month, make sure month is as expected
19672 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19674 return new_date.getUTCMonth() != new_month;
19676 new_month = month + dir;
19677 new_date.setUTCMonth(new_month);
19678 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19679 if (new_month < 0 || new_month > 11) {
19680 new_month = (new_month + 12) % 12;
19683 // For magnitudes >1, move one month at a time...
19684 for (var i=0; i<mag; i++) {
19685 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19686 new_date = this.moveMonth(new_date, dir);
19688 // ...then reset the day, keeping it in the new month
19689 new_month = new_date.getUTCMonth();
19690 new_date.setUTCDate(day);
19692 return new_month != new_date.getUTCMonth();
19695 // Common date-resetting loop -- if date is beyond end of month, make it
19698 new_date.setUTCDate(--day);
19699 new_date.setUTCMonth(new_month);
19704 moveYear: function(date, dir)
19706 return this.moveMonth(date, dir*12);
19709 dateWithinRange: function(date)
19711 return date >= this.startDate && date <= this.endDate;
19717 this.picker().remove();
19720 validateValue : function(value)
19722 if(this.getVisibilityEl().hasClass('hidden')){
19726 if(value.length < 1) {
19727 if(this.allowBlank){
19733 if(value.length < this.minLength){
19736 if(value.length > this.maxLength){
19740 var vt = Roo.form.VTypes;
19741 if(!vt[this.vtype](value, this)){
19745 if(typeof this.validator == "function"){
19746 var msg = this.validator(value);
19752 if(this.regex && !this.regex.test(value)){
19756 if(typeof(this.parseDate(value)) == 'undefined'){
19760 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19764 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19774 this.date = this.viewDate = '';
19776 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19781 Roo.apply(Roo.bootstrap.DateField, {
19792 html: '<i class="fa fa-arrow-left"/>'
19802 html: '<i class="fa fa-arrow-right"/>'
19844 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19845 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19846 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19847 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19848 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19861 navFnc: 'FullYear',
19866 navFnc: 'FullYear',
19871 Roo.apply(Roo.bootstrap.DateField, {
19875 cls: 'datepicker dropdown-menu roo-dynamic',
19879 cls: 'datepicker-days',
19883 cls: 'table-condensed',
19885 Roo.bootstrap.DateField.head,
19889 Roo.bootstrap.DateField.footer
19896 cls: 'datepicker-months',
19900 cls: 'table-condensed',
19902 Roo.bootstrap.DateField.head,
19903 Roo.bootstrap.DateField.content,
19904 Roo.bootstrap.DateField.footer
19911 cls: 'datepicker-years',
19915 cls: 'table-condensed',
19917 Roo.bootstrap.DateField.head,
19918 Roo.bootstrap.DateField.content,
19919 Roo.bootstrap.DateField.footer
19938 * @class Roo.bootstrap.TimeField
19939 * @extends Roo.bootstrap.Input
19940 * Bootstrap DateField class
19944 * Create a new TimeField
19945 * @param {Object} config The config object
19948 Roo.bootstrap.TimeField = function(config){
19949 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19953 * Fires when this field show.
19954 * @param {Roo.bootstrap.DateField} thisthis
19955 * @param {Mixed} date The date value
19960 * Fires when this field hide.
19961 * @param {Roo.bootstrap.DateField} this
19962 * @param {Mixed} date The date value
19967 * Fires when select a date.
19968 * @param {Roo.bootstrap.DateField} this
19969 * @param {Mixed} date The date value
19975 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19978 * @cfg {String} format
19979 * The default time format string which can be overriden for localization support. The format must be
19980 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19984 onRender: function(ct, position)
19987 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19989 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19991 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19993 this.pop = this.picker().select('>.datepicker-time',true).first();
19994 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19996 this.picker().on('mousedown', this.onMousedown, this);
19997 this.picker().on('click', this.onClick, this);
19999 this.picker().addClass('datepicker-dropdown');
20004 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
20005 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
20006 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
20007 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
20008 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
20009 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
20013 fireKey: function(e){
20014 if (!this.picker().isVisible()){
20015 if (e.keyCode == 27) { // allow escape to hide and re-show picker
20021 e.preventDefault();
20029 this.onTogglePeriod();
20032 this.onIncrementMinutes();
20035 this.onDecrementMinutes();
20044 onClick: function(e) {
20045 e.stopPropagation();
20046 e.preventDefault();
20049 picker : function()
20051 return this.el.select('.datepicker', true).first();
20054 fillTime: function()
20056 var time = this.pop.select('tbody', true).first();
20058 time.dom.innerHTML = '';
20073 cls: 'hours-up glyphicon glyphicon-chevron-up'
20093 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20114 cls: 'timepicker-hour',
20129 cls: 'timepicker-minute',
20144 cls: 'btn btn-primary period',
20166 cls: 'hours-down glyphicon glyphicon-chevron-down'
20186 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20204 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20211 var hours = this.time.getHours();
20212 var minutes = this.time.getMinutes();
20225 hours = hours - 12;
20229 hours = '0' + hours;
20233 minutes = '0' + minutes;
20236 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20237 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20238 this.pop.select('button', true).first().dom.innerHTML = period;
20244 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20246 var cls = ['bottom'];
20248 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20255 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20260 this.picker().addClass(cls.join('-'));
20264 Roo.each(cls, function(c){
20266 _this.picker().setTop(_this.inputEl().getHeight());
20270 _this.picker().setTop(0 - _this.picker().getHeight());
20275 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20279 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20286 onFocus : function()
20288 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20292 onBlur : function()
20294 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20300 this.picker().show();
20305 this.fireEvent('show', this, this.date);
20310 this.picker().hide();
20313 this.fireEvent('hide', this, this.date);
20316 setTime : function()
20319 this.setValue(this.time.format(this.format));
20321 this.fireEvent('select', this, this.date);
20326 onMousedown: function(e){
20327 e.stopPropagation();
20328 e.preventDefault();
20331 onIncrementHours: function()
20333 Roo.log('onIncrementHours');
20334 this.time = this.time.add(Date.HOUR, 1);
20339 onDecrementHours: function()
20341 Roo.log('onDecrementHours');
20342 this.time = this.time.add(Date.HOUR, -1);
20346 onIncrementMinutes: function()
20348 Roo.log('onIncrementMinutes');
20349 this.time = this.time.add(Date.MINUTE, 1);
20353 onDecrementMinutes: function()
20355 Roo.log('onDecrementMinutes');
20356 this.time = this.time.add(Date.MINUTE, -1);
20360 onTogglePeriod: function()
20362 Roo.log('onTogglePeriod');
20363 this.time = this.time.add(Date.HOUR, 12);
20370 Roo.apply(Roo.bootstrap.TimeField, {
20400 cls: 'btn btn-info ok',
20412 Roo.apply(Roo.bootstrap.TimeField, {
20416 cls: 'datepicker dropdown-menu',
20420 cls: 'datepicker-time',
20424 cls: 'table-condensed',
20426 Roo.bootstrap.TimeField.content,
20427 Roo.bootstrap.TimeField.footer
20446 * @class Roo.bootstrap.MonthField
20447 * @extends Roo.bootstrap.Input
20448 * Bootstrap MonthField class
20450 * @cfg {String} language default en
20453 * Create a new MonthField
20454 * @param {Object} config The config object
20457 Roo.bootstrap.MonthField = function(config){
20458 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20463 * Fires when this field show.
20464 * @param {Roo.bootstrap.MonthField} this
20465 * @param {Mixed} date The date value
20470 * Fires when this field hide.
20471 * @param {Roo.bootstrap.MonthField} this
20472 * @param {Mixed} date The date value
20477 * Fires when select a date.
20478 * @param {Roo.bootstrap.MonthField} this
20479 * @param {String} oldvalue The old value
20480 * @param {String} newvalue The new value
20486 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20488 onRender: function(ct, position)
20491 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20493 this.language = this.language || 'en';
20494 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20495 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20497 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20498 this.isInline = false;
20499 this.isInput = true;
20500 this.component = this.el.select('.add-on', true).first() || false;
20501 this.component = (this.component && this.component.length === 0) ? false : this.component;
20502 this.hasInput = this.component && this.inputEL().length;
20504 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20506 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20508 this.picker().on('mousedown', this.onMousedown, this);
20509 this.picker().on('click', this.onClick, this);
20511 this.picker().addClass('datepicker-dropdown');
20513 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20514 v.setStyle('width', '189px');
20521 if(this.isInline) {
20527 setValue: function(v, suppressEvent)
20529 var o = this.getValue();
20531 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20535 if(suppressEvent !== true){
20536 this.fireEvent('select', this, o, v);
20541 getValue: function()
20546 onClick: function(e)
20548 e.stopPropagation();
20549 e.preventDefault();
20551 var target = e.getTarget();
20553 if(target.nodeName.toLowerCase() === 'i'){
20554 target = Roo.get(target).dom.parentNode;
20557 var nodeName = target.nodeName;
20558 var className = target.className;
20559 var html = target.innerHTML;
20561 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20565 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20567 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20573 picker : function()
20575 return this.pickerEl;
20578 fillMonths: function()
20581 var months = this.picker().select('>.datepicker-months td', true).first();
20583 months.dom.innerHTML = '';
20589 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20592 months.createChild(month);
20601 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20602 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20605 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20606 e.removeClass('active');
20608 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20609 e.addClass('active');
20616 if(this.isInline) {
20620 this.picker().removeClass(['bottom', 'top']);
20622 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20624 * place to the top of element!
20628 this.picker().addClass('top');
20629 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20634 this.picker().addClass('bottom');
20636 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20639 onFocus : function()
20641 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20645 onBlur : function()
20647 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20649 var d = this.inputEl().getValue();
20658 this.picker().show();
20659 this.picker().select('>.datepicker-months', true).first().show();
20663 this.fireEvent('show', this, this.date);
20668 if(this.isInline) {
20671 this.picker().hide();
20672 this.fireEvent('hide', this, this.date);
20676 onMousedown: function(e)
20678 e.stopPropagation();
20679 e.preventDefault();
20684 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20688 fireKey: function(e)
20690 if (!this.picker().isVisible()){
20691 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20702 e.preventDefault();
20706 dir = e.keyCode == 37 ? -1 : 1;
20708 this.vIndex = this.vIndex + dir;
20710 if(this.vIndex < 0){
20714 if(this.vIndex > 11){
20718 if(isNaN(this.vIndex)){
20722 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20728 dir = e.keyCode == 38 ? -1 : 1;
20730 this.vIndex = this.vIndex + dir * 4;
20732 if(this.vIndex < 0){
20736 if(this.vIndex > 11){
20740 if(isNaN(this.vIndex)){
20744 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20749 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20750 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20754 e.preventDefault();
20757 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20758 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20774 this.picker().remove();
20779 Roo.apply(Roo.bootstrap.MonthField, {
20798 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20799 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20804 Roo.apply(Roo.bootstrap.MonthField, {
20808 cls: 'datepicker dropdown-menu roo-dynamic',
20812 cls: 'datepicker-months',
20816 cls: 'table-condensed',
20818 Roo.bootstrap.DateField.content
20838 * @class Roo.bootstrap.CheckBox
20839 * @extends Roo.bootstrap.Input
20840 * Bootstrap CheckBox class
20842 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20843 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20844 * @cfg {String} boxLabel The text that appears beside the checkbox
20845 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20846 * @cfg {Boolean} checked initnal the element
20847 * @cfg {Boolean} inline inline the element (default false)
20848 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20849 * @cfg {String} tooltip label tooltip
20852 * Create a new CheckBox
20853 * @param {Object} config The config object
20856 Roo.bootstrap.CheckBox = function(config){
20857 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20862 * Fires when the element is checked or unchecked.
20863 * @param {Roo.bootstrap.CheckBox} this This input
20864 * @param {Boolean} checked The new checked value
20869 * Fires when the element is click.
20870 * @param {Roo.bootstrap.CheckBox} this This input
20877 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20879 inputType: 'checkbox',
20888 getAutoCreate : function()
20890 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20896 cfg.cls = 'form-group ' + this.inputType; //input-group
20899 cfg.cls += ' ' + this.inputType + '-inline';
20905 type : this.inputType,
20906 value : this.inputValue,
20907 cls : 'roo-' + this.inputType, //'form-box',
20908 placeholder : this.placeholder || ''
20912 if(this.inputType != 'radio'){
20916 cls : 'roo-hidden-value',
20917 value : this.checked ? this.inputValue : this.valueOff
20922 if (this.weight) { // Validity check?
20923 cfg.cls += " " + this.inputType + "-" + this.weight;
20926 if (this.disabled) {
20927 input.disabled=true;
20931 input.checked = this.checked;
20936 input.name = this.name;
20938 if(this.inputType != 'radio'){
20939 hidden.name = this.name;
20940 input.name = '_hidden_' + this.name;
20945 input.cls += ' input-' + this.size;
20950 ['xs','sm','md','lg'].map(function(size){
20951 if (settings[size]) {
20952 cfg.cls += ' col-' + size + '-' + settings[size];
20956 var inputblock = input;
20958 if (this.before || this.after) {
20961 cls : 'input-group',
20966 inputblock.cn.push({
20968 cls : 'input-group-addon',
20973 inputblock.cn.push(input);
20975 if(this.inputType != 'radio'){
20976 inputblock.cn.push(hidden);
20980 inputblock.cn.push({
20982 cls : 'input-group-addon',
20989 if (align ==='left' && this.fieldLabel.length) {
20990 // Roo.log("left and has label");
20995 cls : 'control-label',
20996 html : this.fieldLabel
21006 if(this.labelWidth > 12){
21007 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
21010 if(this.labelWidth < 13 && this.labelmd == 0){
21011 this.labelmd = this.labelWidth;
21014 if(this.labellg > 0){
21015 cfg.cn[0].cls += ' col-lg-' + this.labellg;
21016 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
21019 if(this.labelmd > 0){
21020 cfg.cn[0].cls += ' col-md-' + this.labelmd;
21021 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
21024 if(this.labelsm > 0){
21025 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
21026 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
21029 if(this.labelxs > 0){
21030 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
21031 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
21034 } else if ( this.fieldLabel.length) {
21035 // Roo.log(" label");
21039 tag: this.boxLabel ? 'span' : 'label',
21041 cls: 'control-label box-input-label',
21042 //cls : 'input-group-addon',
21043 html : this.fieldLabel
21052 // Roo.log(" no label && no align");
21053 cfg.cn = [ inputblock ] ;
21059 var boxLabelCfg = {
21061 //'for': id, // box label is handled by onclick - so no for...
21063 html: this.boxLabel
21067 boxLabelCfg.tooltip = this.tooltip;
21070 cfg.cn.push(boxLabelCfg);
21073 if(this.inputType != 'radio'){
21074 cfg.cn.push(hidden);
21082 * return the real input element.
21084 inputEl: function ()
21086 return this.el.select('input.roo-' + this.inputType,true).first();
21088 hiddenEl: function ()
21090 return this.el.select('input.roo-hidden-value',true).first();
21093 labelEl: function()
21095 return this.el.select('label.control-label',true).first();
21097 /* depricated... */
21101 return this.labelEl();
21104 boxLabelEl: function()
21106 return this.el.select('label.box-label',true).first();
21109 initEvents : function()
21111 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21113 this.inputEl().on('click', this.onClick, this);
21115 if (this.boxLabel) {
21116 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21119 this.startValue = this.getValue();
21122 Roo.bootstrap.CheckBox.register(this);
21126 onClick : function(e)
21128 if(this.fireEvent('click', this, e) !== false){
21129 this.setChecked(!this.checked);
21134 setChecked : function(state,suppressEvent)
21136 this.startValue = this.getValue();
21138 if(this.inputType == 'radio'){
21140 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21141 e.dom.checked = false;
21144 this.inputEl().dom.checked = true;
21146 this.inputEl().dom.value = this.inputValue;
21148 if(suppressEvent !== true){
21149 this.fireEvent('check', this, true);
21157 this.checked = state;
21159 this.inputEl().dom.checked = state;
21162 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21164 if(suppressEvent !== true){
21165 this.fireEvent('check', this, state);
21171 getValue : function()
21173 if(this.inputType == 'radio'){
21174 return this.getGroupValue();
21177 return this.hiddenEl().dom.value;
21181 getGroupValue : function()
21183 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21187 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21190 setValue : function(v,suppressEvent)
21192 if(this.inputType == 'radio'){
21193 this.setGroupValue(v, suppressEvent);
21197 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21202 setGroupValue : function(v, suppressEvent)
21204 this.startValue = this.getValue();
21206 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21207 e.dom.checked = false;
21209 if(e.dom.value == v){
21210 e.dom.checked = true;
21214 if(suppressEvent !== true){
21215 this.fireEvent('check', this, true);
21223 validate : function()
21225 if(this.getVisibilityEl().hasClass('hidden')){
21231 (this.inputType == 'radio' && this.validateRadio()) ||
21232 (this.inputType == 'checkbox' && this.validateCheckbox())
21238 this.markInvalid();
21242 validateRadio : function()
21244 if(this.getVisibilityEl().hasClass('hidden')){
21248 if(this.allowBlank){
21254 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21255 if(!e.dom.checked){
21267 validateCheckbox : function()
21270 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21271 //return (this.getValue() == this.inputValue) ? true : false;
21274 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21282 for(var i in group){
21283 if(group[i].el.isVisible(true)){
21291 for(var i in group){
21296 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21303 * Mark this field as valid
21305 markValid : function()
21309 this.fireEvent('valid', this);
21311 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21314 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21321 if(this.inputType == 'radio'){
21322 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21323 var fg = e.findParent('.form-group', false, true);
21324 if (Roo.bootstrap.version == 3) {
21325 fg.removeClass([_this.invalidClass, _this.validClass]);
21326 fg.addClass(_this.validClass);
21328 fg.removeClass(['is-valid', 'is-invalid']);
21329 fg.addClass('is-valid');
21337 var fg = this.el.findParent('.form-group', false, true);
21338 if (Roo.bootstrap.version == 3) {
21339 fg.removeClass([this.invalidClass, this.validClass]);
21340 fg.addClass(this.validClass);
21342 fg.removeClass(['is-valid', 'is-invalid']);
21343 fg.addClass('is-valid');
21348 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21354 for(var i in group){
21355 var fg = group[i].el.findParent('.form-group', false, true);
21356 if (Roo.bootstrap.version == 3) {
21357 fg.removeClass([this.invalidClass, this.validClass]);
21358 fg.addClass(this.validClass);
21360 fg.removeClass(['is-valid', 'is-invalid']);
21361 fg.addClass('is-valid');
21367 * Mark this field as invalid
21368 * @param {String} msg The validation message
21370 markInvalid : function(msg)
21372 if(this.allowBlank){
21378 this.fireEvent('invalid', this, msg);
21380 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21383 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21387 label.markInvalid();
21390 if(this.inputType == 'radio'){
21392 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21393 var fg = e.findParent('.form-group', false, true);
21394 if (Roo.bootstrap.version == 3) {
21395 fg.removeClass([_this.invalidClass, _this.validClass]);
21396 fg.addClass(_this.invalidClass);
21398 fg.removeClass(['is-invalid', 'is-valid']);
21399 fg.addClass('is-invalid');
21407 var fg = this.el.findParent('.form-group', false, true);
21408 if (Roo.bootstrap.version == 3) {
21409 fg.removeClass([_this.invalidClass, _this.validClass]);
21410 fg.addClass(_this.invalidClass);
21412 fg.removeClass(['is-invalid', 'is-valid']);
21413 fg.addClass('is-invalid');
21418 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21424 for(var i in group){
21425 var fg = group[i].el.findParent('.form-group', false, true);
21426 if (Roo.bootstrap.version == 3) {
21427 fg.removeClass([_this.invalidClass, _this.validClass]);
21428 fg.addClass(_this.invalidClass);
21430 fg.removeClass(['is-invalid', 'is-valid']);
21431 fg.addClass('is-invalid');
21437 clearInvalid : function()
21439 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21441 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21443 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21445 if (label && label.iconEl) {
21446 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21447 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21451 disable : function()
21453 if(this.inputType != 'radio'){
21454 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21461 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21462 _this.getActionEl().addClass(this.disabledClass);
21463 e.dom.disabled = true;
21467 this.disabled = true;
21468 this.fireEvent("disable", this);
21472 enable : function()
21474 if(this.inputType != 'radio'){
21475 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21482 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21483 _this.getActionEl().removeClass(this.disabledClass);
21484 e.dom.disabled = false;
21488 this.disabled = false;
21489 this.fireEvent("enable", this);
21493 setBoxLabel : function(v)
21498 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21504 Roo.apply(Roo.bootstrap.CheckBox, {
21509 * register a CheckBox Group
21510 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21512 register : function(checkbox)
21514 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21515 this.groups[checkbox.groupId] = {};
21518 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21522 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21526 * fetch a CheckBox Group based on the group ID
21527 * @param {string} the group ID
21528 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21530 get: function(groupId) {
21531 if (typeof(this.groups[groupId]) == 'undefined') {
21535 return this.groups[groupId] ;
21548 * @class Roo.bootstrap.Radio
21549 * @extends Roo.bootstrap.Component
21550 * Bootstrap Radio class
21551 * @cfg {String} boxLabel - the label associated
21552 * @cfg {String} value - the value of radio
21555 * Create a new Radio
21556 * @param {Object} config The config object
21558 Roo.bootstrap.Radio = function(config){
21559 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21563 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21569 getAutoCreate : function()
21573 cls : 'form-group radio',
21578 html : this.boxLabel
21586 initEvents : function()
21588 this.parent().register(this);
21590 this.el.on('click', this.onClick, this);
21594 onClick : function(e)
21596 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21597 this.setChecked(true);
21601 setChecked : function(state, suppressEvent)
21603 this.parent().setValue(this.value, suppressEvent);
21607 setBoxLabel : function(v)
21612 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21627 * @class Roo.bootstrap.SecurePass
21628 * @extends Roo.bootstrap.Input
21629 * Bootstrap SecurePass class
21633 * Create a new SecurePass
21634 * @param {Object} config The config object
21637 Roo.bootstrap.SecurePass = function (config) {
21638 // these go here, so the translation tool can replace them..
21640 PwdEmpty: "Please type a password, and then retype it to confirm.",
21641 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21642 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21643 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21644 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21645 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21646 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21647 TooWeak: "Your password is Too Weak."
21649 this.meterLabel = "Password strength:";
21650 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21651 this.meterClass = [
21652 "roo-password-meter-tooweak",
21653 "roo-password-meter-weak",
21654 "roo-password-meter-medium",
21655 "roo-password-meter-strong",
21656 "roo-password-meter-grey"
21661 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21664 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21666 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21668 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21669 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21670 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21671 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21672 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21673 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21674 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21684 * @cfg {String/Object} Label for the strength meter (defaults to
21685 * 'Password strength:')
21690 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21691 * ['Weak', 'Medium', 'Strong'])
21694 pwdStrengths: false,
21707 initEvents: function ()
21709 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21711 if (this.el.is('input[type=password]') && Roo.isSafari) {
21712 this.el.on('keydown', this.SafariOnKeyDown, this);
21715 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21718 onRender: function (ct, position)
21720 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21721 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21722 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21724 this.trigger.createChild({
21729 cls: 'roo-password-meter-grey col-xs-12',
21732 //width: this.meterWidth + 'px'
21736 cls: 'roo-password-meter-text'
21742 if (this.hideTrigger) {
21743 this.trigger.setDisplayed(false);
21745 this.setSize(this.width || '', this.height || '');
21748 onDestroy: function ()
21750 if (this.trigger) {
21751 this.trigger.removeAllListeners();
21752 this.trigger.remove();
21755 this.wrap.remove();
21757 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21760 checkStrength: function ()
21762 var pwd = this.inputEl().getValue();
21763 if (pwd == this._lastPwd) {
21768 if (this.ClientSideStrongPassword(pwd)) {
21770 } else if (this.ClientSideMediumPassword(pwd)) {
21772 } else if (this.ClientSideWeakPassword(pwd)) {
21778 Roo.log('strength1: ' + strength);
21780 //var pm = this.trigger.child('div/div/div').dom;
21781 var pm = this.trigger.child('div/div');
21782 pm.removeClass(this.meterClass);
21783 pm.addClass(this.meterClass[strength]);
21786 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21788 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21790 this._lastPwd = pwd;
21794 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21796 this._lastPwd = '';
21798 var pm = this.trigger.child('div/div');
21799 pm.removeClass(this.meterClass);
21800 pm.addClass('roo-password-meter-grey');
21803 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21806 this.inputEl().dom.type='password';
21809 validateValue: function (value)
21812 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21815 if (value.length == 0) {
21816 if (this.allowBlank) {
21817 this.clearInvalid();
21821 this.markInvalid(this.errors.PwdEmpty);
21822 this.errorMsg = this.errors.PwdEmpty;
21830 if ('[\x21-\x7e]*'.match(value)) {
21831 this.markInvalid(this.errors.PwdBadChar);
21832 this.errorMsg = this.errors.PwdBadChar;
21835 if (value.length < 6) {
21836 this.markInvalid(this.errors.PwdShort);
21837 this.errorMsg = this.errors.PwdShort;
21840 if (value.length > 16) {
21841 this.markInvalid(this.errors.PwdLong);
21842 this.errorMsg = this.errors.PwdLong;
21846 if (this.ClientSideStrongPassword(value)) {
21848 } else if (this.ClientSideMediumPassword(value)) {
21850 } else if (this.ClientSideWeakPassword(value)) {
21857 if (strength < 2) {
21858 //this.markInvalid(this.errors.TooWeak);
21859 this.errorMsg = this.errors.TooWeak;
21864 console.log('strength2: ' + strength);
21866 //var pm = this.trigger.child('div/div/div').dom;
21868 var pm = this.trigger.child('div/div');
21869 pm.removeClass(this.meterClass);
21870 pm.addClass(this.meterClass[strength]);
21872 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21874 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21876 this.errorMsg = '';
21880 CharacterSetChecks: function (type)
21883 this.fResult = false;
21886 isctype: function (character, type)
21889 case this.kCapitalLetter:
21890 if (character >= 'A' && character <= 'Z') {
21895 case this.kSmallLetter:
21896 if (character >= 'a' && character <= 'z') {
21902 if (character >= '0' && character <= '9') {
21907 case this.kPunctuation:
21908 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21919 IsLongEnough: function (pwd, size)
21921 return !(pwd == null || isNaN(size) || pwd.length < size);
21924 SpansEnoughCharacterSets: function (word, nb)
21926 if (!this.IsLongEnough(word, nb))
21931 var characterSetChecks = new Array(
21932 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21933 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21936 for (var index = 0; index < word.length; ++index) {
21937 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21938 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21939 characterSetChecks[nCharSet].fResult = true;
21946 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21947 if (characterSetChecks[nCharSet].fResult) {
21952 if (nCharSets < nb) {
21958 ClientSideStrongPassword: function (pwd)
21960 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21963 ClientSideMediumPassword: function (pwd)
21965 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21968 ClientSideWeakPassword: function (pwd)
21970 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21973 })//<script type="text/javascript">
21976 * Based Ext JS Library 1.1.1
21977 * Copyright(c) 2006-2007, Ext JS, LLC.
21983 * @class Roo.HtmlEditorCore
21984 * @extends Roo.Component
21985 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21987 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21990 Roo.HtmlEditorCore = function(config){
21993 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21998 * @event initialize
21999 * Fires when the editor is fully initialized (including the iframe)
22000 * @param {Roo.HtmlEditorCore} this
22005 * Fires when the editor is first receives the focus. Any insertion must wait
22006 * until after this event.
22007 * @param {Roo.HtmlEditorCore} this
22011 * @event beforesync
22012 * Fires before the textarea is updated with content from the editor iframe. Return false
22013 * to cancel the sync.
22014 * @param {Roo.HtmlEditorCore} this
22015 * @param {String} html
22019 * @event beforepush
22020 * Fires before the iframe editor is updated with content from the textarea. Return false
22021 * to cancel the push.
22022 * @param {Roo.HtmlEditorCore} this
22023 * @param {String} html
22028 * Fires when the textarea is updated with content from the editor iframe.
22029 * @param {Roo.HtmlEditorCore} this
22030 * @param {String} html
22035 * Fires when the iframe editor is updated with content from the textarea.
22036 * @param {Roo.HtmlEditorCore} this
22037 * @param {String} html
22042 * @event editorevent
22043 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22044 * @param {Roo.HtmlEditorCore} this
22050 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22052 // defaults : white / black...
22053 this.applyBlacklists();
22060 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22064 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22070 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22075 * @cfg {Number} height (in pixels)
22079 * @cfg {Number} width (in pixels)
22084 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22087 stylesheets: false,
22092 // private properties
22093 validationEvent : false,
22095 initialized : false,
22097 sourceEditMode : false,
22098 onFocus : Roo.emptyFn,
22100 hideMode:'offsets',
22104 // blacklist + whitelisted elements..
22111 * Protected method that will not generally be called directly. It
22112 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22113 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22115 getDocMarkup : function(){
22119 // inherit styels from page...??
22120 if (this.stylesheets === false) {
22122 Roo.get(document.head).select('style').each(function(node) {
22123 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22126 Roo.get(document.head).select('link').each(function(node) {
22127 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22130 } else if (!this.stylesheets.length) {
22132 st = '<style type="text/css">' +
22133 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22136 st = '<style type="text/css">' +
22141 st += '<style type="text/css">' +
22142 'IMG { cursor: pointer } ' +
22145 var cls = 'roo-htmleditor-body';
22147 if(this.bodyCls.length){
22148 cls += ' ' + this.bodyCls;
22151 return '<html><head>' + st +
22152 //<style type="text/css">' +
22153 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22155 ' </head><body class="' + cls + '"></body></html>';
22159 onRender : function(ct, position)
22162 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22163 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22166 this.el.dom.style.border = '0 none';
22167 this.el.dom.setAttribute('tabIndex', -1);
22168 this.el.addClass('x-hidden hide');
22172 if(Roo.isIE){ // fix IE 1px bogus margin
22173 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22177 this.frameId = Roo.id();
22181 var iframe = this.owner.wrap.createChild({
22183 cls: 'form-control', // bootstrap..
22185 name: this.frameId,
22186 frameBorder : 'no',
22187 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22192 this.iframe = iframe.dom;
22194 this.assignDocWin();
22196 this.doc.designMode = 'on';
22199 this.doc.write(this.getDocMarkup());
22203 var task = { // must defer to wait for browser to be ready
22205 //console.log("run task?" + this.doc.readyState);
22206 this.assignDocWin();
22207 if(this.doc.body || this.doc.readyState == 'complete'){
22209 this.doc.designMode="on";
22213 Roo.TaskMgr.stop(task);
22214 this.initEditor.defer(10, this);
22221 Roo.TaskMgr.start(task);
22226 onResize : function(w, h)
22228 Roo.log('resize: ' +w + ',' + h );
22229 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22233 if(typeof w == 'number'){
22235 this.iframe.style.width = w + 'px';
22237 if(typeof h == 'number'){
22239 this.iframe.style.height = h + 'px';
22241 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22248 * Toggles the editor between standard and source edit mode.
22249 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22251 toggleSourceEdit : function(sourceEditMode){
22253 this.sourceEditMode = sourceEditMode === true;
22255 if(this.sourceEditMode){
22257 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22260 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22261 //this.iframe.className = '';
22264 //this.setSize(this.owner.wrap.getSize());
22265 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22272 * Protected method that will not generally be called directly. If you need/want
22273 * custom HTML cleanup, this is the method you should override.
22274 * @param {String} html The HTML to be cleaned
22275 * return {String} The cleaned HTML
22277 cleanHtml : function(html){
22278 html = String(html);
22279 if(html.length > 5){
22280 if(Roo.isSafari){ // strip safari nonsense
22281 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22284 if(html == ' '){
22291 * HTML Editor -> Textarea
22292 * Protected method that will not generally be called directly. Syncs the contents
22293 * of the editor iframe with the textarea.
22295 syncValue : function(){
22296 if(this.initialized){
22297 var bd = (this.doc.body || this.doc.documentElement);
22298 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22299 var html = bd.innerHTML;
22301 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22302 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22304 html = '<div style="'+m[0]+'">' + html + '</div>';
22307 html = this.cleanHtml(html);
22308 // fix up the special chars.. normaly like back quotes in word...
22309 // however we do not want to do this with chinese..
22310 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22311 var cc = b.charCodeAt();
22313 (cc >= 0x4E00 && cc < 0xA000 ) ||
22314 (cc >= 0x3400 && cc < 0x4E00 ) ||
22315 (cc >= 0xf900 && cc < 0xfb00 )
22321 if(this.owner.fireEvent('beforesync', this, html) !== false){
22322 this.el.dom.value = html;
22323 this.owner.fireEvent('sync', this, html);
22329 * Protected method that will not generally be called directly. Pushes the value of the textarea
22330 * into the iframe editor.
22332 pushValue : function(){
22333 if(this.initialized){
22334 var v = this.el.dom.value.trim();
22336 // if(v.length < 1){
22340 if(this.owner.fireEvent('beforepush', this, v) !== false){
22341 var d = (this.doc.body || this.doc.documentElement);
22343 this.cleanUpPaste();
22344 this.el.dom.value = d.innerHTML;
22345 this.owner.fireEvent('push', this, v);
22351 deferFocus : function(){
22352 this.focus.defer(10, this);
22356 focus : function(){
22357 if(this.win && !this.sourceEditMode){
22364 assignDocWin: function()
22366 var iframe = this.iframe;
22369 this.doc = iframe.contentWindow.document;
22370 this.win = iframe.contentWindow;
22372 // if (!Roo.get(this.frameId)) {
22375 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22376 // this.win = Roo.get(this.frameId).dom.contentWindow;
22378 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22382 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22383 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22388 initEditor : function(){
22389 //console.log("INIT EDITOR");
22390 this.assignDocWin();
22394 this.doc.designMode="on";
22396 this.doc.write(this.getDocMarkup());
22399 var dbody = (this.doc.body || this.doc.documentElement);
22400 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22401 // this copies styles from the containing element into thsi one..
22402 // not sure why we need all of this..
22403 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22405 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22406 //ss['background-attachment'] = 'fixed'; // w3c
22407 dbody.bgProperties = 'fixed'; // ie
22408 //Roo.DomHelper.applyStyles(dbody, ss);
22409 Roo.EventManager.on(this.doc, {
22410 //'mousedown': this.onEditorEvent,
22411 'mouseup': this.onEditorEvent,
22412 'dblclick': this.onEditorEvent,
22413 'click': this.onEditorEvent,
22414 'keyup': this.onEditorEvent,
22419 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22421 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22422 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22424 this.initialized = true;
22426 this.owner.fireEvent('initialize', this);
22431 onDestroy : function(){
22437 //for (var i =0; i < this.toolbars.length;i++) {
22438 // // fixme - ask toolbars for heights?
22439 // this.toolbars[i].onDestroy();
22442 //this.wrap.dom.innerHTML = '';
22443 //this.wrap.remove();
22448 onFirstFocus : function(){
22450 this.assignDocWin();
22453 this.activated = true;
22456 if(Roo.isGecko){ // prevent silly gecko errors
22458 var s = this.win.getSelection();
22459 if(!s.focusNode || s.focusNode.nodeType != 3){
22460 var r = s.getRangeAt(0);
22461 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22466 this.execCmd('useCSS', true);
22467 this.execCmd('styleWithCSS', false);
22470 this.owner.fireEvent('activate', this);
22474 adjustFont: function(btn){
22475 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22476 //if(Roo.isSafari){ // safari
22479 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22480 if(Roo.isSafari){ // safari
22481 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22482 v = (v < 10) ? 10 : v;
22483 v = (v > 48) ? 48 : v;
22484 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22489 v = Math.max(1, v+adjust);
22491 this.execCmd('FontSize', v );
22494 onEditorEvent : function(e)
22496 this.owner.fireEvent('editorevent', this, e);
22497 // this.updateToolbar();
22498 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22501 insertTag : function(tg)
22503 // could be a bit smarter... -> wrap the current selected tRoo..
22504 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22506 range = this.createRange(this.getSelection());
22507 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22508 wrappingNode.appendChild(range.extractContents());
22509 range.insertNode(wrappingNode);
22516 this.execCmd("formatblock", tg);
22520 insertText : function(txt)
22524 var range = this.createRange();
22525 range.deleteContents();
22526 //alert(Sender.getAttribute('label'));
22528 range.insertNode(this.doc.createTextNode(txt));
22534 * Executes a Midas editor command on the editor document and performs necessary focus and
22535 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22536 * @param {String} cmd The Midas command
22537 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22539 relayCmd : function(cmd, value){
22541 this.execCmd(cmd, value);
22542 this.owner.fireEvent('editorevent', this);
22543 //this.updateToolbar();
22544 this.owner.deferFocus();
22548 * Executes a Midas editor command directly on the editor document.
22549 * For visual commands, you should use {@link #relayCmd} instead.
22550 * <b>This should only be called after the editor is initialized.</b>
22551 * @param {String} cmd The Midas command
22552 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22554 execCmd : function(cmd, value){
22555 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22562 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22564 * @param {String} text | dom node..
22566 insertAtCursor : function(text)
22569 if(!this.activated){
22575 var r = this.doc.selection.createRange();
22586 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22590 // from jquery ui (MIT licenced)
22592 var win = this.win;
22594 if (win.getSelection && win.getSelection().getRangeAt) {
22595 range = win.getSelection().getRangeAt(0);
22596 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22597 range.insertNode(node);
22598 } else if (win.document.selection && win.document.selection.createRange) {
22599 // no firefox support
22600 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22601 win.document.selection.createRange().pasteHTML(txt);
22603 // no firefox support
22604 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22605 this.execCmd('InsertHTML', txt);
22614 mozKeyPress : function(e){
22616 var c = e.getCharCode(), cmd;
22619 c = String.fromCharCode(c).toLowerCase();
22633 this.cleanUpPaste.defer(100, this);
22641 e.preventDefault();
22649 fixKeys : function(){ // load time branching for fastest keydown performance
22651 return function(e){
22652 var k = e.getKey(), r;
22655 r = this.doc.selection.createRange();
22658 r.pasteHTML('    ');
22665 r = this.doc.selection.createRange();
22667 var target = r.parentElement();
22668 if(!target || target.tagName.toLowerCase() != 'li'){
22670 r.pasteHTML('<br />');
22676 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22677 this.cleanUpPaste.defer(100, this);
22683 }else if(Roo.isOpera){
22684 return function(e){
22685 var k = e.getKey();
22689 this.execCmd('InsertHTML','    ');
22692 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22693 this.cleanUpPaste.defer(100, this);
22698 }else if(Roo.isSafari){
22699 return function(e){
22700 var k = e.getKey();
22704 this.execCmd('InsertText','\t');
22708 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22709 this.cleanUpPaste.defer(100, this);
22717 getAllAncestors: function()
22719 var p = this.getSelectedNode();
22722 a.push(p); // push blank onto stack..
22723 p = this.getParentElement();
22727 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22731 a.push(this.doc.body);
22735 lastSelNode : false,
22738 getSelection : function()
22740 this.assignDocWin();
22741 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22744 getSelectedNode: function()
22746 // this may only work on Gecko!!!
22748 // should we cache this!!!!
22753 var range = this.createRange(this.getSelection()).cloneRange();
22756 var parent = range.parentElement();
22758 var testRange = range.duplicate();
22759 testRange.moveToElementText(parent);
22760 if (testRange.inRange(range)) {
22763 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22766 parent = parent.parentElement;
22771 // is ancestor a text element.
22772 var ac = range.commonAncestorContainer;
22773 if (ac.nodeType == 3) {
22774 ac = ac.parentNode;
22777 var ar = ac.childNodes;
22780 var other_nodes = [];
22781 var has_other_nodes = false;
22782 for (var i=0;i<ar.length;i++) {
22783 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22786 // fullly contained node.
22788 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22793 // probably selected..
22794 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22795 other_nodes.push(ar[i]);
22799 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22804 has_other_nodes = true;
22806 if (!nodes.length && other_nodes.length) {
22807 nodes= other_nodes;
22809 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22815 createRange: function(sel)
22817 // this has strange effects when using with
22818 // top toolbar - not sure if it's a great idea.
22819 //this.editor.contentWindow.focus();
22820 if (typeof sel != "undefined") {
22822 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22824 return this.doc.createRange();
22827 return this.doc.createRange();
22830 getParentElement: function()
22833 this.assignDocWin();
22834 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22836 var range = this.createRange(sel);
22839 var p = range.commonAncestorContainer;
22840 while (p.nodeType == 3) { // text node
22851 * Range intersection.. the hard stuff...
22855 * [ -- selected range --- ]
22859 * if end is before start or hits it. fail.
22860 * if start is after end or hits it fail.
22862 * if either hits (but other is outside. - then it's not
22868 // @see http://www.thismuchiknow.co.uk/?p=64.
22869 rangeIntersectsNode : function(range, node)
22871 var nodeRange = node.ownerDocument.createRange();
22873 nodeRange.selectNode(node);
22875 nodeRange.selectNodeContents(node);
22878 var rangeStartRange = range.cloneRange();
22879 rangeStartRange.collapse(true);
22881 var rangeEndRange = range.cloneRange();
22882 rangeEndRange.collapse(false);
22884 var nodeStartRange = nodeRange.cloneRange();
22885 nodeStartRange.collapse(true);
22887 var nodeEndRange = nodeRange.cloneRange();
22888 nodeEndRange.collapse(false);
22890 return rangeStartRange.compareBoundaryPoints(
22891 Range.START_TO_START, nodeEndRange) == -1 &&
22892 rangeEndRange.compareBoundaryPoints(
22893 Range.START_TO_START, nodeStartRange) == 1;
22897 rangeCompareNode : function(range, node)
22899 var nodeRange = node.ownerDocument.createRange();
22901 nodeRange.selectNode(node);
22903 nodeRange.selectNodeContents(node);
22907 range.collapse(true);
22909 nodeRange.collapse(true);
22911 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22912 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22914 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22916 var nodeIsBefore = ss == 1;
22917 var nodeIsAfter = ee == -1;
22919 if (nodeIsBefore && nodeIsAfter) {
22922 if (!nodeIsBefore && nodeIsAfter) {
22923 return 1; //right trailed.
22926 if (nodeIsBefore && !nodeIsAfter) {
22927 return 2; // left trailed.
22933 // private? - in a new class?
22934 cleanUpPaste : function()
22936 // cleans up the whole document..
22937 Roo.log('cleanuppaste');
22939 this.cleanUpChildren(this.doc.body);
22940 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22941 if (clean != this.doc.body.innerHTML) {
22942 this.doc.body.innerHTML = clean;
22947 cleanWordChars : function(input) {// change the chars to hex code
22948 var he = Roo.HtmlEditorCore;
22950 var output = input;
22951 Roo.each(he.swapCodes, function(sw) {
22952 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22954 output = output.replace(swapper, sw[1]);
22961 cleanUpChildren : function (n)
22963 if (!n.childNodes.length) {
22966 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22967 this.cleanUpChild(n.childNodes[i]);
22974 cleanUpChild : function (node)
22977 //console.log(node);
22978 if (node.nodeName == "#text") {
22979 // clean up silly Windows -- stuff?
22982 if (node.nodeName == "#comment") {
22983 node.parentNode.removeChild(node);
22984 // clean up silly Windows -- stuff?
22987 var lcname = node.tagName.toLowerCase();
22988 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22989 // whitelist of tags..
22991 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22993 node.parentNode.removeChild(node);
22998 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
23000 // remove <a name=....> as rendering on yahoo mailer is borked with this.
23001 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
23003 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
23004 // remove_keep_children = true;
23007 if (remove_keep_children) {
23008 this.cleanUpChildren(node);
23009 // inserts everything just before this node...
23010 while (node.childNodes.length) {
23011 var cn = node.childNodes[0];
23012 node.removeChild(cn);
23013 node.parentNode.insertBefore(cn, node);
23015 node.parentNode.removeChild(node);
23019 if (!node.attributes || !node.attributes.length) {
23020 this.cleanUpChildren(node);
23024 function cleanAttr(n,v)
23027 if (v.match(/^\./) || v.match(/^\//)) {
23030 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
23033 if (v.match(/^#/)) {
23036 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
23037 node.removeAttribute(n);
23041 var cwhite = this.cwhite;
23042 var cblack = this.cblack;
23044 function cleanStyle(n,v)
23046 if (v.match(/expression/)) { //XSS?? should we even bother..
23047 node.removeAttribute(n);
23051 var parts = v.split(/;/);
23054 Roo.each(parts, function(p) {
23055 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23059 var l = p.split(':').shift().replace(/\s+/g,'');
23060 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23062 if ( cwhite.length && cblack.indexOf(l) > -1) {
23063 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23064 //node.removeAttribute(n);
23068 // only allow 'c whitelisted system attributes'
23069 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23070 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23071 //node.removeAttribute(n);
23081 if (clean.length) {
23082 node.setAttribute(n, clean.join(';'));
23084 node.removeAttribute(n);
23090 for (var i = node.attributes.length-1; i > -1 ; i--) {
23091 var a = node.attributes[i];
23094 if (a.name.toLowerCase().substr(0,2)=='on') {
23095 node.removeAttribute(a.name);
23098 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23099 node.removeAttribute(a.name);
23102 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23103 cleanAttr(a.name,a.value); // fixme..
23106 if (a.name == 'style') {
23107 cleanStyle(a.name,a.value);
23110 /// clean up MS crap..
23111 // tecnically this should be a list of valid class'es..
23114 if (a.name == 'class') {
23115 if (a.value.match(/^Mso/)) {
23116 node.className = '';
23119 if (a.value.match(/^body$/)) {
23120 node.className = '';
23131 this.cleanUpChildren(node);
23137 * Clean up MS wordisms...
23139 cleanWord : function(node)
23144 this.cleanWord(this.doc.body);
23147 if (node.nodeName == "#text") {
23148 // clean up silly Windows -- stuff?
23151 if (node.nodeName == "#comment") {
23152 node.parentNode.removeChild(node);
23153 // clean up silly Windows -- stuff?
23157 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23158 node.parentNode.removeChild(node);
23162 // remove - but keep children..
23163 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23164 while (node.childNodes.length) {
23165 var cn = node.childNodes[0];
23166 node.removeChild(cn);
23167 node.parentNode.insertBefore(cn, node);
23169 node.parentNode.removeChild(node);
23170 this.iterateChildren(node, this.cleanWord);
23174 if (node.className.length) {
23176 var cn = node.className.split(/\W+/);
23178 Roo.each(cn, function(cls) {
23179 if (cls.match(/Mso[a-zA-Z]+/)) {
23184 node.className = cna.length ? cna.join(' ') : '';
23186 node.removeAttribute("class");
23190 if (node.hasAttribute("lang")) {
23191 node.removeAttribute("lang");
23194 if (node.hasAttribute("style")) {
23196 var styles = node.getAttribute("style").split(";");
23198 Roo.each(styles, function(s) {
23199 if (!s.match(/:/)) {
23202 var kv = s.split(":");
23203 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23206 // what ever is left... we allow.
23209 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23210 if (!nstyle.length) {
23211 node.removeAttribute('style');
23214 this.iterateChildren(node, this.cleanWord);
23220 * iterateChildren of a Node, calling fn each time, using this as the scole..
23221 * @param {DomNode} node node to iterate children of.
23222 * @param {Function} fn method of this class to call on each item.
23224 iterateChildren : function(node, fn)
23226 if (!node.childNodes.length) {
23229 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23230 fn.call(this, node.childNodes[i])
23236 * cleanTableWidths.
23238 * Quite often pasting from word etc.. results in tables with column and widths.
23239 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23242 cleanTableWidths : function(node)
23247 this.cleanTableWidths(this.doc.body);
23252 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23255 Roo.log(node.tagName);
23256 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23257 this.iterateChildren(node, this.cleanTableWidths);
23260 if (node.hasAttribute('width')) {
23261 node.removeAttribute('width');
23265 if (node.hasAttribute("style")) {
23268 var styles = node.getAttribute("style").split(";");
23270 Roo.each(styles, function(s) {
23271 if (!s.match(/:/)) {
23274 var kv = s.split(":");
23275 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23278 // what ever is left... we allow.
23281 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23282 if (!nstyle.length) {
23283 node.removeAttribute('style');
23287 this.iterateChildren(node, this.cleanTableWidths);
23295 domToHTML : function(currentElement, depth, nopadtext) {
23297 depth = depth || 0;
23298 nopadtext = nopadtext || false;
23300 if (!currentElement) {
23301 return this.domToHTML(this.doc.body);
23304 //Roo.log(currentElement);
23306 var allText = false;
23307 var nodeName = currentElement.nodeName;
23308 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23310 if (nodeName == '#text') {
23312 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23317 if (nodeName != 'BODY') {
23320 // Prints the node tagName, such as <A>, <IMG>, etc
23323 for(i = 0; i < currentElement.attributes.length;i++) {
23325 var aname = currentElement.attributes.item(i).name;
23326 if (!currentElement.attributes.item(i).value.length) {
23329 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23332 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23341 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23344 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23349 // Traverse the tree
23351 var currentElementChild = currentElement.childNodes.item(i);
23352 var allText = true;
23353 var innerHTML = '';
23355 while (currentElementChild) {
23356 // Formatting code (indent the tree so it looks nice on the screen)
23357 var nopad = nopadtext;
23358 if (lastnode == 'SPAN') {
23362 if (currentElementChild.nodeName == '#text') {
23363 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23364 toadd = nopadtext ? toadd : toadd.trim();
23365 if (!nopad && toadd.length > 80) {
23366 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23368 innerHTML += toadd;
23371 currentElementChild = currentElement.childNodes.item(i);
23377 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23379 // Recursively traverse the tree structure of the child node
23380 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23381 lastnode = currentElementChild.nodeName;
23383 currentElementChild=currentElement.childNodes.item(i);
23389 // The remaining code is mostly for formatting the tree
23390 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23395 ret+= "</"+tagName+">";
23401 applyBlacklists : function()
23403 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23404 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23408 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23409 if (b.indexOf(tag) > -1) {
23412 this.white.push(tag);
23416 Roo.each(w, function(tag) {
23417 if (b.indexOf(tag) > -1) {
23420 if (this.white.indexOf(tag) > -1) {
23423 this.white.push(tag);
23428 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23429 if (w.indexOf(tag) > -1) {
23432 this.black.push(tag);
23436 Roo.each(b, function(tag) {
23437 if (w.indexOf(tag) > -1) {
23440 if (this.black.indexOf(tag) > -1) {
23443 this.black.push(tag);
23448 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23449 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23453 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23454 if (b.indexOf(tag) > -1) {
23457 this.cwhite.push(tag);
23461 Roo.each(w, function(tag) {
23462 if (b.indexOf(tag) > -1) {
23465 if (this.cwhite.indexOf(tag) > -1) {
23468 this.cwhite.push(tag);
23473 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23474 if (w.indexOf(tag) > -1) {
23477 this.cblack.push(tag);
23481 Roo.each(b, function(tag) {
23482 if (w.indexOf(tag) > -1) {
23485 if (this.cblack.indexOf(tag) > -1) {
23488 this.cblack.push(tag);
23493 setStylesheets : function(stylesheets)
23495 if(typeof(stylesheets) == 'string'){
23496 Roo.get(this.iframe.contentDocument.head).createChild({
23498 rel : 'stylesheet',
23507 Roo.each(stylesheets, function(s) {
23512 Roo.get(_this.iframe.contentDocument.head).createChild({
23514 rel : 'stylesheet',
23523 removeStylesheets : function()
23527 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23532 setStyle : function(style)
23534 Roo.get(this.iframe.contentDocument.head).createChild({
23543 // hide stuff that is not compatible
23557 * @event specialkey
23561 * @cfg {String} fieldClass @hide
23564 * @cfg {String} focusClass @hide
23567 * @cfg {String} autoCreate @hide
23570 * @cfg {String} inputType @hide
23573 * @cfg {String} invalidClass @hide
23576 * @cfg {String} invalidText @hide
23579 * @cfg {String} msgFx @hide
23582 * @cfg {String} validateOnBlur @hide
23586 Roo.HtmlEditorCore.white = [
23587 'area', 'br', 'img', 'input', 'hr', 'wbr',
23589 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23590 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23591 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23592 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23593 'table', 'ul', 'xmp',
23595 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23598 'dir', 'menu', 'ol', 'ul', 'dl',
23604 Roo.HtmlEditorCore.black = [
23605 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23607 'base', 'basefont', 'bgsound', 'blink', 'body',
23608 'frame', 'frameset', 'head', 'html', 'ilayer',
23609 'iframe', 'layer', 'link', 'meta', 'object',
23610 'script', 'style' ,'title', 'xml' // clean later..
23612 Roo.HtmlEditorCore.clean = [
23613 'script', 'style', 'title', 'xml'
23615 Roo.HtmlEditorCore.remove = [
23620 Roo.HtmlEditorCore.ablack = [
23624 Roo.HtmlEditorCore.aclean = [
23625 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23629 Roo.HtmlEditorCore.pwhite= [
23630 'http', 'https', 'mailto'
23633 // white listed style attributes.
23634 Roo.HtmlEditorCore.cwhite= [
23635 // 'text-align', /// default is to allow most things..
23641 // black listed style attributes.
23642 Roo.HtmlEditorCore.cblack= [
23643 // 'font-size' -- this can be set by the project
23647 Roo.HtmlEditorCore.swapCodes =[
23666 * @class Roo.bootstrap.HtmlEditor
23667 * @extends Roo.bootstrap.TextArea
23668 * Bootstrap HtmlEditor class
23671 * Create a new HtmlEditor
23672 * @param {Object} config The config object
23675 Roo.bootstrap.HtmlEditor = function(config){
23676 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23677 if (!this.toolbars) {
23678 this.toolbars = [];
23681 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23684 * @event initialize
23685 * Fires when the editor is fully initialized (including the iframe)
23686 * @param {HtmlEditor} this
23691 * Fires when the editor is first receives the focus. Any insertion must wait
23692 * until after this event.
23693 * @param {HtmlEditor} this
23697 * @event beforesync
23698 * Fires before the textarea is updated with content from the editor iframe. Return false
23699 * to cancel the sync.
23700 * @param {HtmlEditor} this
23701 * @param {String} html
23705 * @event beforepush
23706 * Fires before the iframe editor is updated with content from the textarea. Return false
23707 * to cancel the push.
23708 * @param {HtmlEditor} this
23709 * @param {String} html
23714 * Fires when the textarea is updated with content from the editor iframe.
23715 * @param {HtmlEditor} this
23716 * @param {String} html
23721 * Fires when the iframe editor is updated with content from the textarea.
23722 * @param {HtmlEditor} this
23723 * @param {String} html
23727 * @event editmodechange
23728 * Fires when the editor switches edit modes
23729 * @param {HtmlEditor} this
23730 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23732 editmodechange: true,
23734 * @event editorevent
23735 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23736 * @param {HtmlEditor} this
23740 * @event firstfocus
23741 * Fires when on first focus - needed by toolbars..
23742 * @param {HtmlEditor} this
23747 * Auto save the htmlEditor value as a file into Events
23748 * @param {HtmlEditor} this
23752 * @event savedpreview
23753 * preview the saved version of htmlEditor
23754 * @param {HtmlEditor} this
23761 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23765 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23770 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23775 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23780 * @cfg {Number} height (in pixels)
23784 * @cfg {Number} width (in pixels)
23789 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23792 stylesheets: false,
23797 // private properties
23798 validationEvent : false,
23800 initialized : false,
23803 onFocus : Roo.emptyFn,
23805 hideMode:'offsets',
23807 tbContainer : false,
23811 toolbarContainer :function() {
23812 return this.wrap.select('.x-html-editor-tb',true).first();
23816 * Protected method that will not generally be called directly. It
23817 * is called when the editor creates its toolbar. Override this method if you need to
23818 * add custom toolbar buttons.
23819 * @param {HtmlEditor} editor
23821 createToolbar : function(){
23822 Roo.log('renewing');
23823 Roo.log("create toolbars");
23825 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23826 this.toolbars[0].render(this.toolbarContainer());
23830 // if (!editor.toolbars || !editor.toolbars.length) {
23831 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23834 // for (var i =0 ; i < editor.toolbars.length;i++) {
23835 // editor.toolbars[i] = Roo.factory(
23836 // typeof(editor.toolbars[i]) == 'string' ?
23837 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23838 // Roo.bootstrap.HtmlEditor);
23839 // editor.toolbars[i].init(editor);
23845 onRender : function(ct, position)
23847 // Roo.log("Call onRender: " + this.xtype);
23849 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23851 this.wrap = this.inputEl().wrap({
23852 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23855 this.editorcore.onRender(ct, position);
23857 if (this.resizable) {
23858 this.resizeEl = new Roo.Resizable(this.wrap, {
23862 minHeight : this.height,
23863 height: this.height,
23864 handles : this.resizable,
23867 resize : function(r, w, h) {
23868 _t.onResize(w,h); // -something
23874 this.createToolbar(this);
23877 if(!this.width && this.resizable){
23878 this.setSize(this.wrap.getSize());
23880 if (this.resizeEl) {
23881 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23882 // should trigger onReize..
23888 onResize : function(w, h)
23890 Roo.log('resize: ' +w + ',' + h );
23891 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23895 if(this.inputEl() ){
23896 if(typeof w == 'number'){
23897 var aw = w - this.wrap.getFrameWidth('lr');
23898 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23901 if(typeof h == 'number'){
23902 var tbh = -11; // fixme it needs to tool bar size!
23903 for (var i =0; i < this.toolbars.length;i++) {
23904 // fixme - ask toolbars for heights?
23905 tbh += this.toolbars[i].el.getHeight();
23906 //if (this.toolbars[i].footer) {
23907 // tbh += this.toolbars[i].footer.el.getHeight();
23915 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23916 ah -= 5; // knock a few pixes off for look..
23917 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23921 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23922 this.editorcore.onResize(ew,eh);
23927 * Toggles the editor between standard and source edit mode.
23928 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23930 toggleSourceEdit : function(sourceEditMode)
23932 this.editorcore.toggleSourceEdit(sourceEditMode);
23934 if(this.editorcore.sourceEditMode){
23935 Roo.log('editor - showing textarea');
23938 // Roo.log(this.syncValue());
23940 this.inputEl().removeClass(['hide', 'x-hidden']);
23941 this.inputEl().dom.removeAttribute('tabIndex');
23942 this.inputEl().focus();
23944 Roo.log('editor - hiding textarea');
23946 // Roo.log(this.pushValue());
23949 this.inputEl().addClass(['hide', 'x-hidden']);
23950 this.inputEl().dom.setAttribute('tabIndex', -1);
23951 //this.deferFocus();
23954 if(this.resizable){
23955 this.setSize(this.wrap.getSize());
23958 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23961 // private (for BoxComponent)
23962 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23964 // private (for BoxComponent)
23965 getResizeEl : function(){
23969 // private (for BoxComponent)
23970 getPositionEl : function(){
23975 initEvents : function(){
23976 this.originalValue = this.getValue();
23980 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23983 // markInvalid : Roo.emptyFn,
23985 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23988 // clearInvalid : Roo.emptyFn,
23990 setValue : function(v){
23991 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23992 this.editorcore.pushValue();
23997 deferFocus : function(){
23998 this.focus.defer(10, this);
24002 focus : function(){
24003 this.editorcore.focus();
24009 onDestroy : function(){
24015 for (var i =0; i < this.toolbars.length;i++) {
24016 // fixme - ask toolbars for heights?
24017 this.toolbars[i].onDestroy();
24020 this.wrap.dom.innerHTML = '';
24021 this.wrap.remove();
24026 onFirstFocus : function(){
24027 //Roo.log("onFirstFocus");
24028 this.editorcore.onFirstFocus();
24029 for (var i =0; i < this.toolbars.length;i++) {
24030 this.toolbars[i].onFirstFocus();
24036 syncValue : function()
24038 this.editorcore.syncValue();
24041 pushValue : function()
24043 this.editorcore.pushValue();
24047 // hide stuff that is not compatible
24061 * @event specialkey
24065 * @cfg {String} fieldClass @hide
24068 * @cfg {String} focusClass @hide
24071 * @cfg {String} autoCreate @hide
24074 * @cfg {String} inputType @hide
24078 * @cfg {String} invalidText @hide
24081 * @cfg {String} msgFx @hide
24084 * @cfg {String} validateOnBlur @hide
24093 Roo.namespace('Roo.bootstrap.htmleditor');
24095 * @class Roo.bootstrap.HtmlEditorToolbar1
24101 new Roo.bootstrap.HtmlEditor({
24104 new Roo.bootstrap.HtmlEditorToolbar1({
24105 disable : { fonts: 1 , format: 1, ..., ... , ...],
24111 * @cfg {Object} disable List of elements to disable..
24112 * @cfg {Array} btns List of additional buttons.
24116 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24119 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24122 Roo.apply(this, config);
24124 // default disabled, based on 'good practice'..
24125 this.disable = this.disable || {};
24126 Roo.applyIf(this.disable, {
24129 specialElements : true
24131 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24133 this.editor = config.editor;
24134 this.editorcore = config.editor.editorcore;
24136 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24138 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24139 // dont call parent... till later.
24141 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24146 editorcore : false,
24151 "h1","h2","h3","h4","h5","h6",
24153 "abbr", "acronym", "address", "cite", "samp", "var",
24157 onRender : function(ct, position)
24159 // Roo.log("Call onRender: " + this.xtype);
24161 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24163 this.el.dom.style.marginBottom = '0';
24165 var editorcore = this.editorcore;
24166 var editor= this.editor;
24169 var btn = function(id,cmd , toggle, handler, html){
24171 var event = toggle ? 'toggle' : 'click';
24176 xns: Roo.bootstrap,
24180 enableToggle:toggle !== false,
24182 pressed : toggle ? false : null,
24185 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24186 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24192 // var cb_box = function...
24197 xns: Roo.bootstrap,
24202 xns: Roo.bootstrap,
24206 Roo.each(this.formats, function(f) {
24207 style.menu.items.push({
24209 xns: Roo.bootstrap,
24210 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24215 editorcore.insertTag(this.tagname);
24222 children.push(style);
24224 btn('bold',false,true);
24225 btn('italic',false,true);
24226 btn('align-left', 'justifyleft',true);
24227 btn('align-center', 'justifycenter',true);
24228 btn('align-right' , 'justifyright',true);
24229 btn('link', false, false, function(btn) {
24230 //Roo.log("create link?");
24231 var url = prompt(this.createLinkText, this.defaultLinkValue);
24232 if(url && url != 'http:/'+'/'){
24233 this.editorcore.relayCmd('createlink', url);
24236 btn('list','insertunorderedlist',true);
24237 btn('pencil', false,true, function(btn){
24239 this.toggleSourceEdit(btn.pressed);
24242 if (this.editor.btns.length > 0) {
24243 for (var i = 0; i<this.editor.btns.length; i++) {
24244 children.push(this.editor.btns[i]);
24252 xns: Roo.bootstrap,
24257 xns: Roo.bootstrap,
24262 cog.menu.items.push({
24264 xns: Roo.bootstrap,
24265 html : Clean styles,
24270 editorcore.insertTag(this.tagname);
24279 this.xtype = 'NavSimplebar';
24281 for(var i=0;i< children.length;i++) {
24283 this.buttons.add(this.addxtypeChild(children[i]));
24287 editor.on('editorevent', this.updateToolbar, this);
24289 onBtnClick : function(id)
24291 this.editorcore.relayCmd(id);
24292 this.editorcore.focus();
24296 * Protected method that will not generally be called directly. It triggers
24297 * a toolbar update by reading the markup state of the current selection in the editor.
24299 updateToolbar: function(){
24301 if(!this.editorcore.activated){
24302 this.editor.onFirstFocus(); // is this neeed?
24306 var btns = this.buttons;
24307 var doc = this.editorcore.doc;
24308 btns.get('bold').setActive(doc.queryCommandState('bold'));
24309 btns.get('italic').setActive(doc.queryCommandState('italic'));
24310 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24312 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24313 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24314 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24316 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24317 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24320 var ans = this.editorcore.getAllAncestors();
24321 if (this.formatCombo) {
24324 var store = this.formatCombo.store;
24325 this.formatCombo.setValue("");
24326 for (var i =0; i < ans.length;i++) {
24327 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24329 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24337 // hides menus... - so this cant be on a menu...
24338 Roo.bootstrap.MenuMgr.hideAll();
24340 Roo.bootstrap.MenuMgr.hideAll();
24341 //this.editorsyncValue();
24343 onFirstFocus: function() {
24344 this.buttons.each(function(item){
24348 toggleSourceEdit : function(sourceEditMode){
24351 if(sourceEditMode){
24352 Roo.log("disabling buttons");
24353 this.buttons.each( function(item){
24354 if(item.cmd != 'pencil'){
24360 Roo.log("enabling buttons");
24361 if(this.editorcore.initialized){
24362 this.buttons.each( function(item){
24368 Roo.log("calling toggole on editor");
24369 // tell the editor that it's been pressed..
24370 this.editor.toggleSourceEdit(sourceEditMode);
24380 * @class Roo.bootstrap.Table.AbstractSelectionModel
24381 * @extends Roo.util.Observable
24382 * Abstract base class for grid SelectionModels. It provides the interface that should be
24383 * implemented by descendant classes. This class should not be directly instantiated.
24386 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24387 this.locked = false;
24388 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24392 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24393 /** @ignore Called by the grid automatically. Do not call directly. */
24394 init : function(grid){
24400 * Locks the selections.
24403 this.locked = true;
24407 * Unlocks the selections.
24409 unlock : function(){
24410 this.locked = false;
24414 * Returns true if the selections are locked.
24415 * @return {Boolean}
24417 isLocked : function(){
24418 return this.locked;
24422 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24423 * @class Roo.bootstrap.Table.RowSelectionModel
24424 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24425 * It supports multiple selections and keyboard selection/navigation.
24427 * @param {Object} config
24430 Roo.bootstrap.Table.RowSelectionModel = function(config){
24431 Roo.apply(this, config);
24432 this.selections = new Roo.util.MixedCollection(false, function(o){
24437 this.lastActive = false;
24441 * @event selectionchange
24442 * Fires when the selection changes
24443 * @param {SelectionModel} this
24445 "selectionchange" : true,
24447 * @event afterselectionchange
24448 * Fires after the selection changes (eg. by key press or clicking)
24449 * @param {SelectionModel} this
24451 "afterselectionchange" : true,
24453 * @event beforerowselect
24454 * Fires when a row is selected being selected, return false to cancel.
24455 * @param {SelectionModel} this
24456 * @param {Number} rowIndex The selected index
24457 * @param {Boolean} keepExisting False if other selections will be cleared
24459 "beforerowselect" : true,
24462 * Fires when a row is selected.
24463 * @param {SelectionModel} this
24464 * @param {Number} rowIndex The selected index
24465 * @param {Roo.data.Record} r The record
24467 "rowselect" : true,
24469 * @event rowdeselect
24470 * Fires when a row is deselected.
24471 * @param {SelectionModel} this
24472 * @param {Number} rowIndex The selected index
24474 "rowdeselect" : true
24476 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24477 this.locked = false;
24480 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24482 * @cfg {Boolean} singleSelect
24483 * True to allow selection of only one row at a time (defaults to false)
24485 singleSelect : false,
24488 initEvents : function()
24491 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24492 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24493 //}else{ // allow click to work like normal
24494 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24496 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24497 this.grid.on("rowclick", this.handleMouseDown, this);
24499 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24500 "up" : function(e){
24502 this.selectPrevious(e.shiftKey);
24503 }else if(this.last !== false && this.lastActive !== false){
24504 var last = this.last;
24505 this.selectRange(this.last, this.lastActive-1);
24506 this.grid.getView().focusRow(this.lastActive);
24507 if(last !== false){
24511 this.selectFirstRow();
24513 this.fireEvent("afterselectionchange", this);
24515 "down" : function(e){
24517 this.selectNext(e.shiftKey);
24518 }else if(this.last !== false && this.lastActive !== false){
24519 var last = this.last;
24520 this.selectRange(this.last, this.lastActive+1);
24521 this.grid.getView().focusRow(this.lastActive);
24522 if(last !== false){
24526 this.selectFirstRow();
24528 this.fireEvent("afterselectionchange", this);
24532 this.grid.store.on('load', function(){
24533 this.selections.clear();
24536 var view = this.grid.view;
24537 view.on("refresh", this.onRefresh, this);
24538 view.on("rowupdated", this.onRowUpdated, this);
24539 view.on("rowremoved", this.onRemove, this);
24544 onRefresh : function()
24546 var ds = this.grid.store, i, v = this.grid.view;
24547 var s = this.selections;
24548 s.each(function(r){
24549 if((i = ds.indexOfId(r.id)) != -1){
24558 onRemove : function(v, index, r){
24559 this.selections.remove(r);
24563 onRowUpdated : function(v, index, r){
24564 if(this.isSelected(r)){
24565 v.onRowSelect(index);
24571 * @param {Array} records The records to select
24572 * @param {Boolean} keepExisting (optional) True to keep existing selections
24574 selectRecords : function(records, keepExisting)
24577 this.clearSelections();
24579 var ds = this.grid.store;
24580 for(var i = 0, len = records.length; i < len; i++){
24581 this.selectRow(ds.indexOf(records[i]), true);
24586 * Gets the number of selected rows.
24589 getCount : function(){
24590 return this.selections.length;
24594 * Selects the first row in the grid.
24596 selectFirstRow : function(){
24601 * Select the last row.
24602 * @param {Boolean} keepExisting (optional) True to keep existing selections
24604 selectLastRow : function(keepExisting){
24605 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24606 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24610 * Selects the row immediately following the last selected row.
24611 * @param {Boolean} keepExisting (optional) True to keep existing selections
24613 selectNext : function(keepExisting)
24615 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24616 this.selectRow(this.last+1, keepExisting);
24617 this.grid.getView().focusRow(this.last);
24622 * Selects the row that precedes the last selected row.
24623 * @param {Boolean} keepExisting (optional) True to keep existing selections
24625 selectPrevious : function(keepExisting){
24627 this.selectRow(this.last-1, keepExisting);
24628 this.grid.getView().focusRow(this.last);
24633 * Returns the selected records
24634 * @return {Array} Array of selected records
24636 getSelections : function(){
24637 return [].concat(this.selections.items);
24641 * Returns the first selected record.
24644 getSelected : function(){
24645 return this.selections.itemAt(0);
24650 * Clears all selections.
24652 clearSelections : function(fast)
24658 var ds = this.grid.store;
24659 var s = this.selections;
24660 s.each(function(r){
24661 this.deselectRow(ds.indexOfId(r.id));
24665 this.selections.clear();
24672 * Selects all rows.
24674 selectAll : function(){
24678 this.selections.clear();
24679 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24680 this.selectRow(i, true);
24685 * Returns True if there is a selection.
24686 * @return {Boolean}
24688 hasSelection : function(){
24689 return this.selections.length > 0;
24693 * Returns True if the specified row is selected.
24694 * @param {Number/Record} record The record or index of the record to check
24695 * @return {Boolean}
24697 isSelected : function(index){
24698 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24699 return (r && this.selections.key(r.id) ? true : false);
24703 * Returns True if the specified record id is selected.
24704 * @param {String} id The id of record to check
24705 * @return {Boolean}
24707 isIdSelected : function(id){
24708 return (this.selections.key(id) ? true : false);
24713 handleMouseDBClick : function(e, t){
24717 handleMouseDown : function(e, t)
24719 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24720 if(this.isLocked() || rowIndex < 0 ){
24723 if(e.shiftKey && this.last !== false){
24724 var last = this.last;
24725 this.selectRange(last, rowIndex, e.ctrlKey);
24726 this.last = last; // reset the last
24730 var isSelected = this.isSelected(rowIndex);
24731 //Roo.log("select row:" + rowIndex);
24733 this.deselectRow(rowIndex);
24735 this.selectRow(rowIndex, true);
24739 if(e.button !== 0 && isSelected){
24740 alert('rowIndex 2: ' + rowIndex);
24741 view.focusRow(rowIndex);
24742 }else if(e.ctrlKey && isSelected){
24743 this.deselectRow(rowIndex);
24744 }else if(!isSelected){
24745 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24746 view.focusRow(rowIndex);
24750 this.fireEvent("afterselectionchange", this);
24753 handleDragableRowClick : function(grid, rowIndex, e)
24755 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24756 this.selectRow(rowIndex, false);
24757 grid.view.focusRow(rowIndex);
24758 this.fireEvent("afterselectionchange", this);
24763 * Selects multiple rows.
24764 * @param {Array} rows Array of the indexes of the row to select
24765 * @param {Boolean} keepExisting (optional) True to keep existing selections
24767 selectRows : function(rows, keepExisting){
24769 this.clearSelections();
24771 for(var i = 0, len = rows.length; i < len; i++){
24772 this.selectRow(rows[i], true);
24777 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24778 * @param {Number} startRow The index of the first row in the range
24779 * @param {Number} endRow The index of the last row in the range
24780 * @param {Boolean} keepExisting (optional) True to retain existing selections
24782 selectRange : function(startRow, endRow, keepExisting){
24787 this.clearSelections();
24789 if(startRow <= endRow){
24790 for(var i = startRow; i <= endRow; i++){
24791 this.selectRow(i, true);
24794 for(var i = startRow; i >= endRow; i--){
24795 this.selectRow(i, true);
24801 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24802 * @param {Number} startRow The index of the first row in the range
24803 * @param {Number} endRow The index of the last row in the range
24805 deselectRange : function(startRow, endRow, preventViewNotify){
24809 for(var i = startRow; i <= endRow; i++){
24810 this.deselectRow(i, preventViewNotify);
24816 * @param {Number} row The index of the row to select
24817 * @param {Boolean} keepExisting (optional) True to keep existing selections
24819 selectRow : function(index, keepExisting, preventViewNotify)
24821 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24824 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24825 if(!keepExisting || this.singleSelect){
24826 this.clearSelections();
24829 var r = this.grid.store.getAt(index);
24830 //console.log('selectRow - record id :' + r.id);
24832 this.selections.add(r);
24833 this.last = this.lastActive = index;
24834 if(!preventViewNotify){
24835 var proxy = new Roo.Element(
24836 this.grid.getRowDom(index)
24838 proxy.addClass('bg-info info');
24840 this.fireEvent("rowselect", this, index, r);
24841 this.fireEvent("selectionchange", this);
24847 * @param {Number} row The index of the row to deselect
24849 deselectRow : function(index, preventViewNotify)
24854 if(this.last == index){
24857 if(this.lastActive == index){
24858 this.lastActive = false;
24861 var r = this.grid.store.getAt(index);
24866 this.selections.remove(r);
24867 //.console.log('deselectRow - record id :' + r.id);
24868 if(!preventViewNotify){
24870 var proxy = new Roo.Element(
24871 this.grid.getRowDom(index)
24873 proxy.removeClass('bg-info info');
24875 this.fireEvent("rowdeselect", this, index);
24876 this.fireEvent("selectionchange", this);
24880 restoreLast : function(){
24882 this.last = this._last;
24887 acceptsNav : function(row, col, cm){
24888 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24892 onEditorKey : function(field, e){
24893 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24898 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24900 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24902 }else if(k == e.ENTER && !e.ctrlKey){
24906 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24908 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24910 }else if(k == e.ESC){
24914 g.startEditing(newCell[0], newCell[1]);
24920 * Ext JS Library 1.1.1
24921 * Copyright(c) 2006-2007, Ext JS, LLC.
24923 * Originally Released Under LGPL - original licence link has changed is not relivant.
24926 * <script type="text/javascript">
24930 * @class Roo.bootstrap.PagingToolbar
24931 * @extends Roo.bootstrap.NavSimplebar
24932 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24934 * Create a new PagingToolbar
24935 * @param {Object} config The config object
24936 * @param {Roo.data.Store} store
24938 Roo.bootstrap.PagingToolbar = function(config)
24940 // old args format still supported... - xtype is prefered..
24941 // created from xtype...
24943 this.ds = config.dataSource;
24945 if (config.store && !this.ds) {
24946 this.store= Roo.factory(config.store, Roo.data);
24947 this.ds = this.store;
24948 this.ds.xmodule = this.xmodule || false;
24951 this.toolbarItems = [];
24952 if (config.items) {
24953 this.toolbarItems = config.items;
24956 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24961 this.bind(this.ds);
24964 if (Roo.bootstrap.version == 4) {
24965 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24967 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24972 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24974 * @cfg {Roo.data.Store} dataSource
24975 * The underlying data store providing the paged data
24978 * @cfg {String/HTMLElement/Element} container
24979 * container The id or element that will contain the toolbar
24982 * @cfg {Boolean} displayInfo
24983 * True to display the displayMsg (defaults to false)
24986 * @cfg {Number} pageSize
24987 * The number of records to display per page (defaults to 20)
24991 * @cfg {String} displayMsg
24992 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24994 displayMsg : 'Displaying {0} - {1} of {2}',
24996 * @cfg {String} emptyMsg
24997 * The message to display when no records are found (defaults to "No data to display")
24999 emptyMsg : 'No data to display',
25001 * Customizable piece of the default paging text (defaults to "Page")
25004 beforePageText : "Page",
25006 * Customizable piece of the default paging text (defaults to "of %0")
25009 afterPageText : "of {0}",
25011 * Customizable piece of the default paging text (defaults to "First Page")
25014 firstText : "First Page",
25016 * Customizable piece of the default paging text (defaults to "Previous Page")
25019 prevText : "Previous Page",
25021 * Customizable piece of the default paging text (defaults to "Next Page")
25024 nextText : "Next Page",
25026 * Customizable piece of the default paging text (defaults to "Last Page")
25029 lastText : "Last Page",
25031 * Customizable piece of the default paging text (defaults to "Refresh")
25034 refreshText : "Refresh",
25038 onRender : function(ct, position)
25040 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
25041 this.navgroup.parentId = this.id;
25042 this.navgroup.onRender(this.el, null);
25043 // add the buttons to the navgroup
25045 if(this.displayInfo){
25046 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25047 this.displayEl = this.el.select('.x-paging-info', true).first();
25048 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25049 // this.displayEl = navel.el.select('span',true).first();
25055 Roo.each(_this.buttons, function(e){ // this might need to use render????
25056 Roo.factory(e).render(_this.el);
25060 Roo.each(_this.toolbarItems, function(e) {
25061 _this.navgroup.addItem(e);
25065 this.first = this.navgroup.addItem({
25066 tooltip: this.firstText,
25067 cls: "prev btn-outline-secondary",
25068 html : ' <i class="fa fa-step-backward"></i>',
25070 preventDefault: true,
25071 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25074 this.prev = this.navgroup.addItem({
25075 tooltip: this.prevText,
25076 cls: "prev btn-outline-secondary",
25077 html : ' <i class="fa fa-backward"></i>',
25079 preventDefault: true,
25080 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25082 //this.addSeparator();
25085 var field = this.navgroup.addItem( {
25087 cls : 'x-paging-position btn-outline-secondary',
25089 html : this.beforePageText +
25090 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25091 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25094 this.field = field.el.select('input', true).first();
25095 this.field.on("keydown", this.onPagingKeydown, this);
25096 this.field.on("focus", function(){this.dom.select();});
25099 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25100 //this.field.setHeight(18);
25101 //this.addSeparator();
25102 this.next = this.navgroup.addItem({
25103 tooltip: this.nextText,
25104 cls: "next btn-outline-secondary",
25105 html : ' <i class="fa fa-forward"></i>',
25107 preventDefault: true,
25108 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25110 this.last = this.navgroup.addItem({
25111 tooltip: this.lastText,
25112 html : ' <i class="fa fa-step-forward"></i>',
25113 cls: "next btn-outline-secondary",
25115 preventDefault: true,
25116 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25118 //this.addSeparator();
25119 this.loading = this.navgroup.addItem({
25120 tooltip: this.refreshText,
25121 cls: "btn-outline-secondary",
25122 html : ' <i class="fa fa-refresh"></i>',
25123 preventDefault: true,
25124 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25130 updateInfo : function(){
25131 if(this.displayEl){
25132 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25133 var msg = count == 0 ?
25137 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25139 this.displayEl.update(msg);
25144 onLoad : function(ds, r, o)
25146 this.cursor = o.params.start ? o.params.start : 0;
25148 var d = this.getPageData(),
25153 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25154 this.field.dom.value = ap;
25155 this.first.setDisabled(ap == 1);
25156 this.prev.setDisabled(ap == 1);
25157 this.next.setDisabled(ap == ps);
25158 this.last.setDisabled(ap == ps);
25159 this.loading.enable();
25164 getPageData : function(){
25165 var total = this.ds.getTotalCount();
25168 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25169 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25174 onLoadError : function(){
25175 this.loading.enable();
25179 onPagingKeydown : function(e){
25180 var k = e.getKey();
25181 var d = this.getPageData();
25183 var v = this.field.dom.value, pageNum;
25184 if(!v || isNaN(pageNum = parseInt(v, 10))){
25185 this.field.dom.value = d.activePage;
25188 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25189 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25192 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))
25194 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25195 this.field.dom.value = pageNum;
25196 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25199 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25201 var v = this.field.dom.value, pageNum;
25202 var increment = (e.shiftKey) ? 10 : 1;
25203 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25206 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25207 this.field.dom.value = d.activePage;
25210 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25212 this.field.dom.value = parseInt(v, 10) + increment;
25213 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25214 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25221 beforeLoad : function(){
25223 this.loading.disable();
25228 onClick : function(which){
25237 ds.load({params:{start: 0, limit: this.pageSize}});
25240 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25243 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25246 var total = ds.getTotalCount();
25247 var extra = total % this.pageSize;
25248 var lastStart = extra ? (total - extra) : total-this.pageSize;
25249 ds.load({params:{start: lastStart, limit: this.pageSize}});
25252 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25258 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25259 * @param {Roo.data.Store} store The data store to unbind
25261 unbind : function(ds){
25262 ds.un("beforeload", this.beforeLoad, this);
25263 ds.un("load", this.onLoad, this);
25264 ds.un("loadexception", this.onLoadError, this);
25265 ds.un("remove", this.updateInfo, this);
25266 ds.un("add", this.updateInfo, this);
25267 this.ds = undefined;
25271 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25272 * @param {Roo.data.Store} store The data store to bind
25274 bind : function(ds){
25275 ds.on("beforeload", this.beforeLoad, this);
25276 ds.on("load", this.onLoad, this);
25277 ds.on("loadexception", this.onLoadError, this);
25278 ds.on("remove", this.updateInfo, this);
25279 ds.on("add", this.updateInfo, this);
25290 * @class Roo.bootstrap.MessageBar
25291 * @extends Roo.bootstrap.Component
25292 * Bootstrap MessageBar class
25293 * @cfg {String} html contents of the MessageBar
25294 * @cfg {String} weight (info | success | warning | danger) default info
25295 * @cfg {String} beforeClass insert the bar before the given class
25296 * @cfg {Boolean} closable (true | false) default false
25297 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25300 * Create a new Element
25301 * @param {Object} config The config object
25304 Roo.bootstrap.MessageBar = function(config){
25305 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25308 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25314 beforeClass: 'bootstrap-sticky-wrap',
25316 getAutoCreate : function(){
25320 cls: 'alert alert-dismissable alert-' + this.weight,
25325 html: this.html || ''
25331 cfg.cls += ' alert-messages-fixed';
25345 onRender : function(ct, position)
25347 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25350 var cfg = Roo.apply({}, this.getAutoCreate());
25354 cfg.cls += ' ' + this.cls;
25357 cfg.style = this.style;
25359 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25361 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25364 this.el.select('>button.close').on('click', this.hide, this);
25370 if (!this.rendered) {
25376 this.fireEvent('show', this);
25382 if (!this.rendered) {
25388 this.fireEvent('hide', this);
25391 update : function()
25393 // var e = this.el.dom.firstChild;
25395 // if(this.closable){
25396 // e = e.nextSibling;
25399 // e.data = this.html || '';
25401 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25417 * @class Roo.bootstrap.Graph
25418 * @extends Roo.bootstrap.Component
25419 * Bootstrap Graph class
25423 @cfg {String} graphtype bar | vbar | pie
25424 @cfg {number} g_x coodinator | centre x (pie)
25425 @cfg {number} g_y coodinator | centre y (pie)
25426 @cfg {number} g_r radius (pie)
25427 @cfg {number} g_height height of the chart (respected by all elements in the set)
25428 @cfg {number} g_width width of the chart (respected by all elements in the set)
25429 @cfg {Object} title The title of the chart
25432 -opts (object) options for the chart
25434 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25435 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25437 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.
25438 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25440 o stretch (boolean)
25442 -opts (object) options for the pie
25445 o startAngle (number)
25446 o endAngle (number)
25450 * Create a new Input
25451 * @param {Object} config The config object
25454 Roo.bootstrap.Graph = function(config){
25455 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25461 * The img click event for the img.
25462 * @param {Roo.EventObject} e
25468 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25479 //g_colors: this.colors,
25486 getAutoCreate : function(){
25497 onRender : function(ct,position){
25500 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25502 if (typeof(Raphael) == 'undefined') {
25503 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25507 this.raphael = Raphael(this.el.dom);
25509 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25510 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25511 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25512 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25514 r.text(160, 10, "Single Series Chart").attr(txtattr);
25515 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25516 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25517 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25519 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25520 r.barchart(330, 10, 300, 220, data1);
25521 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25522 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25525 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25526 // r.barchart(30, 30, 560, 250, xdata, {
25527 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25528 // axis : "0 0 1 1",
25529 // axisxlabels : xdata
25530 // //yvalues : cols,
25533 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25535 // this.load(null,xdata,{
25536 // axis : "0 0 1 1",
25537 // axisxlabels : xdata
25542 load : function(graphtype,xdata,opts)
25544 this.raphael.clear();
25546 graphtype = this.graphtype;
25551 var r = this.raphael,
25552 fin = function () {
25553 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25555 fout = function () {
25556 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25558 pfin = function() {
25559 this.sector.stop();
25560 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25563 this.label[0].stop();
25564 this.label[0].attr({ r: 7.5 });
25565 this.label[1].attr({ "font-weight": 800 });
25568 pfout = function() {
25569 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25572 this.label[0].animate({ r: 5 }, 500, "bounce");
25573 this.label[1].attr({ "font-weight": 400 });
25579 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25582 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25585 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25586 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25588 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25595 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25600 setTitle: function(o)
25605 initEvents: function() {
25608 this.el.on('click', this.onClick, this);
25612 onClick : function(e)
25614 Roo.log('img onclick');
25615 this.fireEvent('click', this, e);
25627 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25630 * @class Roo.bootstrap.dash.NumberBox
25631 * @extends Roo.bootstrap.Component
25632 * Bootstrap NumberBox class
25633 * @cfg {String} headline Box headline
25634 * @cfg {String} content Box content
25635 * @cfg {String} icon Box icon
25636 * @cfg {String} footer Footer text
25637 * @cfg {String} fhref Footer href
25640 * Create a new NumberBox
25641 * @param {Object} config The config object
25645 Roo.bootstrap.dash.NumberBox = function(config){
25646 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25650 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25659 getAutoCreate : function(){
25663 cls : 'small-box ',
25671 cls : 'roo-headline',
25672 html : this.headline
25676 cls : 'roo-content',
25677 html : this.content
25691 cls : 'ion ' + this.icon
25700 cls : 'small-box-footer',
25701 href : this.fhref || '#',
25705 cfg.cn.push(footer);
25712 onRender : function(ct,position){
25713 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25720 setHeadline: function (value)
25722 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25725 setFooter: function (value, href)
25727 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25730 this.el.select('a.small-box-footer',true).first().attr('href', href);
25735 setContent: function (value)
25737 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25740 initEvents: function()
25754 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25757 * @class Roo.bootstrap.dash.TabBox
25758 * @extends Roo.bootstrap.Component
25759 * Bootstrap TabBox class
25760 * @cfg {String} title Title of the TabBox
25761 * @cfg {String} icon Icon of the TabBox
25762 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25763 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25766 * Create a new TabBox
25767 * @param {Object} config The config object
25771 Roo.bootstrap.dash.TabBox = function(config){
25772 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25777 * When a pane is added
25778 * @param {Roo.bootstrap.dash.TabPane} pane
25782 * @event activatepane
25783 * When a pane is activated
25784 * @param {Roo.bootstrap.dash.TabPane} pane
25786 "activatepane" : true
25794 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25799 tabScrollable : false,
25801 getChildContainer : function()
25803 return this.el.select('.tab-content', true).first();
25806 getAutoCreate : function(){
25810 cls: 'pull-left header',
25818 cls: 'fa ' + this.icon
25824 cls: 'nav nav-tabs pull-right',
25830 if(this.tabScrollable){
25837 cls: 'nav nav-tabs pull-right',
25848 cls: 'nav-tabs-custom',
25853 cls: 'tab-content no-padding',
25861 initEvents : function()
25863 //Roo.log('add add pane handler');
25864 this.on('addpane', this.onAddPane, this);
25867 * Updates the box title
25868 * @param {String} html to set the title to.
25870 setTitle : function(value)
25872 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25874 onAddPane : function(pane)
25876 this.panes.push(pane);
25877 //Roo.log('addpane');
25879 // tabs are rendere left to right..
25880 if(!this.showtabs){
25884 var ctr = this.el.select('.nav-tabs', true).first();
25887 var existing = ctr.select('.nav-tab',true);
25888 var qty = existing.getCount();;
25891 var tab = ctr.createChild({
25893 cls : 'nav-tab' + (qty ? '' : ' active'),
25901 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25904 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25906 pane.el.addClass('active');
25911 onTabClick : function(ev,un,ob,pane)
25913 //Roo.log('tab - prev default');
25914 ev.preventDefault();
25917 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25918 pane.tab.addClass('active');
25919 //Roo.log(pane.title);
25920 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25921 // technically we should have a deactivate event.. but maybe add later.
25922 // and it should not de-activate the selected tab...
25923 this.fireEvent('activatepane', pane);
25924 pane.el.addClass('active');
25925 pane.fireEvent('activate');
25930 getActivePane : function()
25933 Roo.each(this.panes, function(p) {
25934 if(p.el.hasClass('active')){
25955 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25957 * @class Roo.bootstrap.TabPane
25958 * @extends Roo.bootstrap.Component
25959 * Bootstrap TabPane class
25960 * @cfg {Boolean} active (false | true) Default false
25961 * @cfg {String} title title of panel
25965 * Create a new TabPane
25966 * @param {Object} config The config object
25969 Roo.bootstrap.dash.TabPane = function(config){
25970 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25976 * When a pane is activated
25977 * @param {Roo.bootstrap.dash.TabPane} pane
25984 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25989 // the tabBox that this is attached to.
25992 getAutoCreate : function()
26000 cfg.cls += ' active';
26005 initEvents : function()
26007 //Roo.log('trigger add pane handler');
26008 this.parent().fireEvent('addpane', this)
26012 * Updates the tab title
26013 * @param {String} html to set the title to.
26015 setTitle: function(str)
26021 this.tab.select('a', true).first().dom.innerHTML = str;
26038 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26041 * @class Roo.bootstrap.menu.Menu
26042 * @extends Roo.bootstrap.Component
26043 * Bootstrap Menu class - container for Menu
26044 * @cfg {String} html Text of the menu
26045 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26046 * @cfg {String} icon Font awesome icon
26047 * @cfg {String} pos Menu align to (top | bottom) default bottom
26051 * Create a new Menu
26052 * @param {Object} config The config object
26056 Roo.bootstrap.menu.Menu = function(config){
26057 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26061 * @event beforeshow
26062 * Fires before this menu is displayed
26063 * @param {Roo.bootstrap.menu.Menu} this
26067 * @event beforehide
26068 * Fires before this menu is hidden
26069 * @param {Roo.bootstrap.menu.Menu} this
26074 * Fires after this menu is displayed
26075 * @param {Roo.bootstrap.menu.Menu} this
26080 * Fires after this menu is hidden
26081 * @param {Roo.bootstrap.menu.Menu} this
26086 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26087 * @param {Roo.bootstrap.menu.Menu} this
26088 * @param {Roo.EventObject} e
26095 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26099 weight : 'default',
26104 getChildContainer : function() {
26105 if(this.isSubMenu){
26109 return this.el.select('ul.dropdown-menu', true).first();
26112 getAutoCreate : function()
26117 cls : 'roo-menu-text',
26125 cls : 'fa ' + this.icon
26136 cls : 'dropdown-button btn btn-' + this.weight,
26141 cls : 'dropdown-toggle btn btn-' + this.weight,
26151 cls : 'dropdown-menu'
26157 if(this.pos == 'top'){
26158 cfg.cls += ' dropup';
26161 if(this.isSubMenu){
26164 cls : 'dropdown-menu'
26171 onRender : function(ct, position)
26173 this.isSubMenu = ct.hasClass('dropdown-submenu');
26175 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26178 initEvents : function()
26180 if(this.isSubMenu){
26184 this.hidden = true;
26186 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26187 this.triggerEl.on('click', this.onTriggerPress, this);
26189 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26190 this.buttonEl.on('click', this.onClick, this);
26196 if(this.isSubMenu){
26200 return this.el.select('ul.dropdown-menu', true).first();
26203 onClick : function(e)
26205 this.fireEvent("click", this, e);
26208 onTriggerPress : function(e)
26210 if (this.isVisible()) {
26217 isVisible : function(){
26218 return !this.hidden;
26223 this.fireEvent("beforeshow", this);
26225 this.hidden = false;
26226 this.el.addClass('open');
26228 Roo.get(document).on("mouseup", this.onMouseUp, this);
26230 this.fireEvent("show", this);
26237 this.fireEvent("beforehide", this);
26239 this.hidden = true;
26240 this.el.removeClass('open');
26242 Roo.get(document).un("mouseup", this.onMouseUp);
26244 this.fireEvent("hide", this);
26247 onMouseUp : function()
26261 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26264 * @class Roo.bootstrap.menu.Item
26265 * @extends Roo.bootstrap.Component
26266 * Bootstrap MenuItem class
26267 * @cfg {Boolean} submenu (true | false) default false
26268 * @cfg {String} html text of the item
26269 * @cfg {String} href the link
26270 * @cfg {Boolean} disable (true | false) default false
26271 * @cfg {Boolean} preventDefault (true | false) default true
26272 * @cfg {String} icon Font awesome icon
26273 * @cfg {String} pos Submenu align to (left | right) default right
26277 * Create a new Item
26278 * @param {Object} config The config object
26282 Roo.bootstrap.menu.Item = function(config){
26283 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26287 * Fires when the mouse is hovering over this menu
26288 * @param {Roo.bootstrap.menu.Item} this
26289 * @param {Roo.EventObject} e
26294 * Fires when the mouse exits this menu
26295 * @param {Roo.bootstrap.menu.Item} this
26296 * @param {Roo.EventObject} e
26302 * The raw click event for the entire grid.
26303 * @param {Roo.EventObject} e
26309 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26314 preventDefault: true,
26319 getAutoCreate : function()
26324 cls : 'roo-menu-item-text',
26332 cls : 'fa ' + this.icon
26341 href : this.href || '#',
26348 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26352 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26354 if(this.pos == 'left'){
26355 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26362 initEvents : function()
26364 this.el.on('mouseover', this.onMouseOver, this);
26365 this.el.on('mouseout', this.onMouseOut, this);
26367 this.el.select('a', true).first().on('click', this.onClick, this);
26371 onClick : function(e)
26373 if(this.preventDefault){
26374 e.preventDefault();
26377 this.fireEvent("click", this, e);
26380 onMouseOver : function(e)
26382 if(this.submenu && this.pos == 'left'){
26383 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26386 this.fireEvent("mouseover", this, e);
26389 onMouseOut : function(e)
26391 this.fireEvent("mouseout", this, e);
26403 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26406 * @class Roo.bootstrap.menu.Separator
26407 * @extends Roo.bootstrap.Component
26408 * Bootstrap Separator class
26411 * Create a new Separator
26412 * @param {Object} config The config object
26416 Roo.bootstrap.menu.Separator = function(config){
26417 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26420 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26422 getAutoCreate : function(){
26443 * @class Roo.bootstrap.Tooltip
26444 * Bootstrap Tooltip class
26445 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26446 * to determine which dom element triggers the tooltip.
26448 * It needs to add support for additional attributes like tooltip-position
26451 * Create a new Toolti
26452 * @param {Object} config The config object
26455 Roo.bootstrap.Tooltip = function(config){
26456 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26458 this.alignment = Roo.bootstrap.Tooltip.alignment;
26460 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26461 this.alignment = config.alignment;
26466 Roo.apply(Roo.bootstrap.Tooltip, {
26468 * @function init initialize tooltip monitoring.
26472 currentTip : false,
26473 currentRegion : false,
26479 Roo.get(document).on('mouseover', this.enter ,this);
26480 Roo.get(document).on('mouseout', this.leave, this);
26483 this.currentTip = new Roo.bootstrap.Tooltip();
26486 enter : function(ev)
26488 var dom = ev.getTarget();
26490 //Roo.log(['enter',dom]);
26491 var el = Roo.fly(dom);
26492 if (this.currentEl) {
26494 //Roo.log(this.currentEl);
26495 //Roo.log(this.currentEl.contains(dom));
26496 if (this.currentEl == el) {
26499 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26505 if (this.currentTip.el) {
26506 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26510 if(!el || el.dom == document){
26516 // you can not look for children, as if el is the body.. then everythign is the child..
26517 if (!el.attr('tooltip')) { //
26518 if (!el.select("[tooltip]").elements.length) {
26521 // is the mouse over this child...?
26522 bindEl = el.select("[tooltip]").first();
26523 var xy = ev.getXY();
26524 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26525 //Roo.log("not in region.");
26528 //Roo.log("child element over..");
26531 this.currentEl = bindEl;
26532 this.currentTip.bind(bindEl);
26533 this.currentRegion = Roo.lib.Region.getRegion(dom);
26534 this.currentTip.enter();
26537 leave : function(ev)
26539 var dom = ev.getTarget();
26540 //Roo.log(['leave',dom]);
26541 if (!this.currentEl) {
26546 if (dom != this.currentEl.dom) {
26549 var xy = ev.getXY();
26550 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26553 // only activate leave if mouse cursor is outside... bounding box..
26558 if (this.currentTip) {
26559 this.currentTip.leave();
26561 //Roo.log('clear currentEl');
26562 this.currentEl = false;
26567 'left' : ['r-l', [-2,0], 'right'],
26568 'right' : ['l-r', [2,0], 'left'],
26569 'bottom' : ['t-b', [0,2], 'top'],
26570 'top' : [ 'b-t', [0,-2], 'bottom']
26576 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26581 delay : null, // can be { show : 300 , hide: 500}
26585 hoverState : null, //???
26587 placement : 'bottom',
26591 getAutoCreate : function(){
26598 cls : 'tooltip-arrow'
26601 cls : 'tooltip-inner'
26608 bind : function(el)
26614 enter : function () {
26616 if (this.timeout != null) {
26617 clearTimeout(this.timeout);
26620 this.hoverState = 'in';
26621 //Roo.log("enter - show");
26622 if (!this.delay || !this.delay.show) {
26627 this.timeout = setTimeout(function () {
26628 if (_t.hoverState == 'in') {
26631 }, this.delay.show);
26635 clearTimeout(this.timeout);
26637 this.hoverState = 'out';
26638 if (!this.delay || !this.delay.hide) {
26644 this.timeout = setTimeout(function () {
26645 //Roo.log("leave - timeout");
26647 if (_t.hoverState == 'out') {
26649 Roo.bootstrap.Tooltip.currentEl = false;
26654 show : function (msg)
26657 this.render(document.body);
26660 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26662 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26664 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26666 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26668 var placement = typeof this.placement == 'function' ?
26669 this.placement.call(this, this.el, on_el) :
26672 var autoToken = /\s?auto?\s?/i;
26673 var autoPlace = autoToken.test(placement);
26675 placement = placement.replace(autoToken, '') || 'top';
26679 //this.el.setXY([0,0]);
26681 //this.el.dom.style.display='block';
26683 //this.el.appendTo(on_el);
26685 var p = this.getPosition();
26686 var box = this.el.getBox();
26692 var align = this.alignment[placement];
26694 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26696 if(placement == 'top' || placement == 'bottom'){
26698 placement = 'right';
26701 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26702 placement = 'left';
26705 var scroll = Roo.select('body', true).first().getScroll();
26707 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26711 align = this.alignment[placement];
26714 this.el.alignTo(this.bindEl, align[0],align[1]);
26715 //var arrow = this.el.select('.arrow',true).first();
26716 //arrow.set(align[2],
26718 this.el.addClass(placement);
26720 this.el.addClass('in fade');
26722 this.hoverState = null;
26724 if (this.el.hasClass('fade')) {
26735 //this.el.setXY([0,0]);
26736 this.el.removeClass('in');
26752 * @class Roo.bootstrap.LocationPicker
26753 * @extends Roo.bootstrap.Component
26754 * Bootstrap LocationPicker class
26755 * @cfg {Number} latitude Position when init default 0
26756 * @cfg {Number} longitude Position when init default 0
26757 * @cfg {Number} zoom default 15
26758 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26759 * @cfg {Boolean} mapTypeControl default false
26760 * @cfg {Boolean} disableDoubleClickZoom default false
26761 * @cfg {Boolean} scrollwheel default true
26762 * @cfg {Boolean} streetViewControl default false
26763 * @cfg {Number} radius default 0
26764 * @cfg {String} locationName
26765 * @cfg {Boolean} draggable default true
26766 * @cfg {Boolean} enableAutocomplete default false
26767 * @cfg {Boolean} enableReverseGeocode default true
26768 * @cfg {String} markerTitle
26771 * Create a new LocationPicker
26772 * @param {Object} config The config object
26776 Roo.bootstrap.LocationPicker = function(config){
26778 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26783 * Fires when the picker initialized.
26784 * @param {Roo.bootstrap.LocationPicker} this
26785 * @param {Google Location} location
26789 * @event positionchanged
26790 * Fires when the picker position changed.
26791 * @param {Roo.bootstrap.LocationPicker} this
26792 * @param {Google Location} location
26794 positionchanged : true,
26797 * Fires when the map resize.
26798 * @param {Roo.bootstrap.LocationPicker} this
26803 * Fires when the map show.
26804 * @param {Roo.bootstrap.LocationPicker} this
26809 * Fires when the map hide.
26810 * @param {Roo.bootstrap.LocationPicker} this
26815 * Fires when click the map.
26816 * @param {Roo.bootstrap.LocationPicker} this
26817 * @param {Map event} e
26821 * @event mapRightClick
26822 * Fires when right click the map.
26823 * @param {Roo.bootstrap.LocationPicker} this
26824 * @param {Map event} e
26826 mapRightClick : true,
26828 * @event markerClick
26829 * Fires when click the marker.
26830 * @param {Roo.bootstrap.LocationPicker} this
26831 * @param {Map event} e
26833 markerClick : true,
26835 * @event markerRightClick
26836 * Fires when right click the marker.
26837 * @param {Roo.bootstrap.LocationPicker} this
26838 * @param {Map event} e
26840 markerRightClick : true,
26842 * @event OverlayViewDraw
26843 * Fires when OverlayView Draw
26844 * @param {Roo.bootstrap.LocationPicker} this
26846 OverlayViewDraw : true,
26848 * @event OverlayViewOnAdd
26849 * Fires when OverlayView Draw
26850 * @param {Roo.bootstrap.LocationPicker} this
26852 OverlayViewOnAdd : true,
26854 * @event OverlayViewOnRemove
26855 * Fires when OverlayView Draw
26856 * @param {Roo.bootstrap.LocationPicker} this
26858 OverlayViewOnRemove : true,
26860 * @event OverlayViewShow
26861 * Fires when OverlayView Draw
26862 * @param {Roo.bootstrap.LocationPicker} this
26863 * @param {Pixel} cpx
26865 OverlayViewShow : true,
26867 * @event OverlayViewHide
26868 * Fires when OverlayView Draw
26869 * @param {Roo.bootstrap.LocationPicker} this
26871 OverlayViewHide : true,
26873 * @event loadexception
26874 * Fires when load google lib failed.
26875 * @param {Roo.bootstrap.LocationPicker} this
26877 loadexception : true
26882 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26884 gMapContext: false,
26890 mapTypeControl: false,
26891 disableDoubleClickZoom: false,
26893 streetViewControl: false,
26897 enableAutocomplete: false,
26898 enableReverseGeocode: true,
26901 getAutoCreate: function()
26906 cls: 'roo-location-picker'
26912 initEvents: function(ct, position)
26914 if(!this.el.getWidth() || this.isApplied()){
26918 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26923 initial: function()
26925 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26926 this.fireEvent('loadexception', this);
26930 if(!this.mapTypeId){
26931 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26934 this.gMapContext = this.GMapContext();
26936 this.initOverlayView();
26938 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26942 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26943 _this.setPosition(_this.gMapContext.marker.position);
26946 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26947 _this.fireEvent('mapClick', this, event);
26951 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26952 _this.fireEvent('mapRightClick', this, event);
26956 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26957 _this.fireEvent('markerClick', this, event);
26961 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26962 _this.fireEvent('markerRightClick', this, event);
26966 this.setPosition(this.gMapContext.location);
26968 this.fireEvent('initial', this, this.gMapContext.location);
26971 initOverlayView: function()
26975 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26979 _this.fireEvent('OverlayViewDraw', _this);
26984 _this.fireEvent('OverlayViewOnAdd', _this);
26987 onRemove: function()
26989 _this.fireEvent('OverlayViewOnRemove', _this);
26992 show: function(cpx)
26994 _this.fireEvent('OverlayViewShow', _this, cpx);
26999 _this.fireEvent('OverlayViewHide', _this);
27005 fromLatLngToContainerPixel: function(event)
27007 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
27010 isApplied: function()
27012 return this.getGmapContext() == false ? false : true;
27015 getGmapContext: function()
27017 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
27020 GMapContext: function()
27022 var position = new google.maps.LatLng(this.latitude, this.longitude);
27024 var _map = new google.maps.Map(this.el.dom, {
27027 mapTypeId: this.mapTypeId,
27028 mapTypeControl: this.mapTypeControl,
27029 disableDoubleClickZoom: this.disableDoubleClickZoom,
27030 scrollwheel: this.scrollwheel,
27031 streetViewControl: this.streetViewControl,
27032 locationName: this.locationName,
27033 draggable: this.draggable,
27034 enableAutocomplete: this.enableAutocomplete,
27035 enableReverseGeocode: this.enableReverseGeocode
27038 var _marker = new google.maps.Marker({
27039 position: position,
27041 title: this.markerTitle,
27042 draggable: this.draggable
27049 location: position,
27050 radius: this.radius,
27051 locationName: this.locationName,
27052 addressComponents: {
27053 formatted_address: null,
27054 addressLine1: null,
27055 addressLine2: null,
27057 streetNumber: null,
27061 stateOrProvince: null
27064 domContainer: this.el.dom,
27065 geodecoder: new google.maps.Geocoder()
27069 drawCircle: function(center, radius, options)
27071 if (this.gMapContext.circle != null) {
27072 this.gMapContext.circle.setMap(null);
27076 options = Roo.apply({}, options, {
27077 strokeColor: "#0000FF",
27078 strokeOpacity: .35,
27080 fillColor: "#0000FF",
27084 options.map = this.gMapContext.map;
27085 options.radius = radius;
27086 options.center = center;
27087 this.gMapContext.circle = new google.maps.Circle(options);
27088 return this.gMapContext.circle;
27094 setPosition: function(location)
27096 this.gMapContext.location = location;
27097 this.gMapContext.marker.setPosition(location);
27098 this.gMapContext.map.panTo(location);
27099 this.drawCircle(location, this.gMapContext.radius, {});
27103 if (this.gMapContext.settings.enableReverseGeocode) {
27104 this.gMapContext.geodecoder.geocode({
27105 latLng: this.gMapContext.location
27106 }, function(results, status) {
27108 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27109 _this.gMapContext.locationName = results[0].formatted_address;
27110 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27112 _this.fireEvent('positionchanged', this, location);
27119 this.fireEvent('positionchanged', this, location);
27124 google.maps.event.trigger(this.gMapContext.map, "resize");
27126 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27128 this.fireEvent('resize', this);
27131 setPositionByLatLng: function(latitude, longitude)
27133 this.setPosition(new google.maps.LatLng(latitude, longitude));
27136 getCurrentPosition: function()
27139 latitude: this.gMapContext.location.lat(),
27140 longitude: this.gMapContext.location.lng()
27144 getAddressName: function()
27146 return this.gMapContext.locationName;
27149 getAddressComponents: function()
27151 return this.gMapContext.addressComponents;
27154 address_component_from_google_geocode: function(address_components)
27158 for (var i = 0; i < address_components.length; i++) {
27159 var component = address_components[i];
27160 if (component.types.indexOf("postal_code") >= 0) {
27161 result.postalCode = component.short_name;
27162 } else if (component.types.indexOf("street_number") >= 0) {
27163 result.streetNumber = component.short_name;
27164 } else if (component.types.indexOf("route") >= 0) {
27165 result.streetName = component.short_name;
27166 } else if (component.types.indexOf("neighborhood") >= 0) {
27167 result.city = component.short_name;
27168 } else if (component.types.indexOf("locality") >= 0) {
27169 result.city = component.short_name;
27170 } else if (component.types.indexOf("sublocality") >= 0) {
27171 result.district = component.short_name;
27172 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27173 result.stateOrProvince = component.short_name;
27174 } else if (component.types.indexOf("country") >= 0) {
27175 result.country = component.short_name;
27179 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27180 result.addressLine2 = "";
27184 setZoomLevel: function(zoom)
27186 this.gMapContext.map.setZoom(zoom);
27199 this.fireEvent('show', this);
27210 this.fireEvent('hide', this);
27215 Roo.apply(Roo.bootstrap.LocationPicker, {
27217 OverlayView : function(map, options)
27219 options = options || {};
27226 * @class Roo.bootstrap.Alert
27227 * @extends Roo.bootstrap.Component
27228 * Bootstrap Alert class - shows an alert area box
27230 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
27231 Enter a valid email address
27234 * @cfg {String} title The title of alert
27235 * @cfg {String} html The content of alert
27236 * @cfg {String} weight ( success | info | warning | danger )
27237 * @cfg {String} faicon font-awesomeicon
27240 * Create a new alert
27241 * @param {Object} config The config object
27245 Roo.bootstrap.Alert = function(config){
27246 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27250 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27257 getAutoCreate : function()
27266 cls : 'roo-alert-icon'
27271 cls : 'roo-alert-title',
27276 cls : 'roo-alert-text',
27283 cfg.cn[0].cls += ' fa ' + this.faicon;
27287 cfg.cls += ' alert-' + this.weight;
27293 initEvents: function()
27295 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27298 setTitle : function(str)
27300 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27303 setText : function(str)
27305 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27308 setWeight : function(weight)
27311 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27314 this.weight = weight;
27316 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27319 setIcon : function(icon)
27322 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27325 this.faicon = icon;
27327 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27348 * @class Roo.bootstrap.UploadCropbox
27349 * @extends Roo.bootstrap.Component
27350 * Bootstrap UploadCropbox class
27351 * @cfg {String} emptyText show when image has been loaded
27352 * @cfg {String} rotateNotify show when image too small to rotate
27353 * @cfg {Number} errorTimeout default 3000
27354 * @cfg {Number} minWidth default 300
27355 * @cfg {Number} minHeight default 300
27356 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27357 * @cfg {Boolean} isDocument (true|false) default false
27358 * @cfg {String} url action url
27359 * @cfg {String} paramName default 'imageUpload'
27360 * @cfg {String} method default POST
27361 * @cfg {Boolean} loadMask (true|false) default true
27362 * @cfg {Boolean} loadingText default 'Loading...'
27365 * Create a new UploadCropbox
27366 * @param {Object} config The config object
27369 Roo.bootstrap.UploadCropbox = function(config){
27370 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27374 * @event beforeselectfile
27375 * Fire before select file
27376 * @param {Roo.bootstrap.UploadCropbox} this
27378 "beforeselectfile" : true,
27381 * Fire after initEvent
27382 * @param {Roo.bootstrap.UploadCropbox} this
27387 * Fire after initEvent
27388 * @param {Roo.bootstrap.UploadCropbox} this
27389 * @param {String} data
27394 * Fire when preparing the file data
27395 * @param {Roo.bootstrap.UploadCropbox} this
27396 * @param {Object} file
27401 * Fire when get exception
27402 * @param {Roo.bootstrap.UploadCropbox} this
27403 * @param {XMLHttpRequest} xhr
27405 "exception" : true,
27407 * @event beforeloadcanvas
27408 * Fire before load the canvas
27409 * @param {Roo.bootstrap.UploadCropbox} this
27410 * @param {String} src
27412 "beforeloadcanvas" : true,
27415 * Fire when trash image
27416 * @param {Roo.bootstrap.UploadCropbox} this
27421 * Fire when download the image
27422 * @param {Roo.bootstrap.UploadCropbox} this
27426 * @event footerbuttonclick
27427 * Fire when footerbuttonclick
27428 * @param {Roo.bootstrap.UploadCropbox} this
27429 * @param {String} type
27431 "footerbuttonclick" : true,
27435 * @param {Roo.bootstrap.UploadCropbox} this
27440 * Fire when rotate the image
27441 * @param {Roo.bootstrap.UploadCropbox} this
27442 * @param {String} pos
27447 * Fire when inspect the file
27448 * @param {Roo.bootstrap.UploadCropbox} this
27449 * @param {Object} file
27454 * Fire when xhr upload the file
27455 * @param {Roo.bootstrap.UploadCropbox} this
27456 * @param {Object} data
27461 * Fire when arrange the file data
27462 * @param {Roo.bootstrap.UploadCropbox} this
27463 * @param {Object} formData
27468 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27471 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27473 emptyText : 'Click to upload image',
27474 rotateNotify : 'Image is too small to rotate',
27475 errorTimeout : 3000,
27489 cropType : 'image/jpeg',
27491 canvasLoaded : false,
27492 isDocument : false,
27494 paramName : 'imageUpload',
27496 loadingText : 'Loading...',
27499 getAutoCreate : function()
27503 cls : 'roo-upload-cropbox',
27507 cls : 'roo-upload-cropbox-selector',
27512 cls : 'roo-upload-cropbox-body',
27513 style : 'cursor:pointer',
27517 cls : 'roo-upload-cropbox-preview'
27521 cls : 'roo-upload-cropbox-thumb'
27525 cls : 'roo-upload-cropbox-empty-notify',
27526 html : this.emptyText
27530 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27531 html : this.rotateNotify
27537 cls : 'roo-upload-cropbox-footer',
27540 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27550 onRender : function(ct, position)
27552 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27554 if (this.buttons.length) {
27556 Roo.each(this.buttons, function(bb) {
27558 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27560 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27566 this.maskEl = this.el;
27570 initEvents : function()
27572 this.urlAPI = (window.createObjectURL && window) ||
27573 (window.URL && URL.revokeObjectURL && URL) ||
27574 (window.webkitURL && webkitURL);
27576 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27577 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27579 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27580 this.selectorEl.hide();
27582 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27583 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27585 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27586 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27587 this.thumbEl.hide();
27589 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27590 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27592 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27593 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27594 this.errorEl.hide();
27596 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27597 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27598 this.footerEl.hide();
27600 this.setThumbBoxSize();
27606 this.fireEvent('initial', this);
27613 window.addEventListener("resize", function() { _this.resize(); } );
27615 this.bodyEl.on('click', this.beforeSelectFile, this);
27618 this.bodyEl.on('touchstart', this.onTouchStart, this);
27619 this.bodyEl.on('touchmove', this.onTouchMove, this);
27620 this.bodyEl.on('touchend', this.onTouchEnd, this);
27624 this.bodyEl.on('mousedown', this.onMouseDown, this);
27625 this.bodyEl.on('mousemove', this.onMouseMove, this);
27626 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27627 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27628 Roo.get(document).on('mouseup', this.onMouseUp, this);
27631 this.selectorEl.on('change', this.onFileSelected, this);
27637 this.baseScale = 1;
27639 this.baseRotate = 1;
27640 this.dragable = false;
27641 this.pinching = false;
27644 this.cropData = false;
27645 this.notifyEl.dom.innerHTML = this.emptyText;
27647 this.selectorEl.dom.value = '';
27651 resize : function()
27653 if(this.fireEvent('resize', this) != false){
27654 this.setThumbBoxPosition();
27655 this.setCanvasPosition();
27659 onFooterButtonClick : function(e, el, o, type)
27662 case 'rotate-left' :
27663 this.onRotateLeft(e);
27665 case 'rotate-right' :
27666 this.onRotateRight(e);
27669 this.beforeSelectFile(e);
27684 this.fireEvent('footerbuttonclick', this, type);
27687 beforeSelectFile : function(e)
27689 e.preventDefault();
27691 if(this.fireEvent('beforeselectfile', this) != false){
27692 this.selectorEl.dom.click();
27696 onFileSelected : function(e)
27698 e.preventDefault();
27700 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27704 var file = this.selectorEl.dom.files[0];
27706 if(this.fireEvent('inspect', this, file) != false){
27707 this.prepare(file);
27712 trash : function(e)
27714 this.fireEvent('trash', this);
27717 download : function(e)
27719 this.fireEvent('download', this);
27722 loadCanvas : function(src)
27724 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27728 this.imageEl = document.createElement('img');
27732 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27734 this.imageEl.src = src;
27738 onLoadCanvas : function()
27740 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27741 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27743 this.bodyEl.un('click', this.beforeSelectFile, this);
27745 this.notifyEl.hide();
27746 this.thumbEl.show();
27747 this.footerEl.show();
27749 this.baseRotateLevel();
27751 if(this.isDocument){
27752 this.setThumbBoxSize();
27755 this.setThumbBoxPosition();
27757 this.baseScaleLevel();
27763 this.canvasLoaded = true;
27766 this.maskEl.unmask();
27771 setCanvasPosition : function()
27773 if(!this.canvasEl){
27777 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27778 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27780 this.previewEl.setLeft(pw);
27781 this.previewEl.setTop(ph);
27785 onMouseDown : function(e)
27789 this.dragable = true;
27790 this.pinching = false;
27792 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27793 this.dragable = false;
27797 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27798 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27802 onMouseMove : function(e)
27806 if(!this.canvasLoaded){
27810 if (!this.dragable){
27814 var minX = Math.ceil(this.thumbEl.getLeft(true));
27815 var minY = Math.ceil(this.thumbEl.getTop(true));
27817 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27818 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27820 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27821 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27823 x = x - this.mouseX;
27824 y = y - this.mouseY;
27826 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27827 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27829 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27830 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27832 this.previewEl.setLeft(bgX);
27833 this.previewEl.setTop(bgY);
27835 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27836 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27839 onMouseUp : function(e)
27843 this.dragable = false;
27846 onMouseWheel : function(e)
27850 this.startScale = this.scale;
27852 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27854 if(!this.zoomable()){
27855 this.scale = this.startScale;
27864 zoomable : function()
27866 var minScale = this.thumbEl.getWidth() / this.minWidth;
27868 if(this.minWidth < this.minHeight){
27869 minScale = this.thumbEl.getHeight() / this.minHeight;
27872 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27873 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27877 (this.rotate == 0 || this.rotate == 180) &&
27879 width > this.imageEl.OriginWidth ||
27880 height > this.imageEl.OriginHeight ||
27881 (width < this.minWidth && height < this.minHeight)
27889 (this.rotate == 90 || this.rotate == 270) &&
27891 width > this.imageEl.OriginWidth ||
27892 height > this.imageEl.OriginHeight ||
27893 (width < this.minHeight && height < this.minWidth)
27900 !this.isDocument &&
27901 (this.rotate == 0 || this.rotate == 180) &&
27903 width < this.minWidth ||
27904 width > this.imageEl.OriginWidth ||
27905 height < this.minHeight ||
27906 height > this.imageEl.OriginHeight
27913 !this.isDocument &&
27914 (this.rotate == 90 || this.rotate == 270) &&
27916 width < this.minHeight ||
27917 width > this.imageEl.OriginWidth ||
27918 height < this.minWidth ||
27919 height > this.imageEl.OriginHeight
27929 onRotateLeft : function(e)
27931 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27933 var minScale = this.thumbEl.getWidth() / this.minWidth;
27935 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27936 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27938 this.startScale = this.scale;
27940 while (this.getScaleLevel() < minScale){
27942 this.scale = this.scale + 1;
27944 if(!this.zoomable()){
27949 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27950 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27955 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27962 this.scale = this.startScale;
27964 this.onRotateFail();
27969 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27971 if(this.isDocument){
27972 this.setThumbBoxSize();
27973 this.setThumbBoxPosition();
27974 this.setCanvasPosition();
27979 this.fireEvent('rotate', this, 'left');
27983 onRotateRight : function(e)
27985 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27987 var minScale = this.thumbEl.getWidth() / this.minWidth;
27989 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27990 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27992 this.startScale = this.scale;
27994 while (this.getScaleLevel() < minScale){
27996 this.scale = this.scale + 1;
27998 if(!this.zoomable()){
28003 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
28004 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
28009 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28016 this.scale = this.startScale;
28018 this.onRotateFail();
28023 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28025 if(this.isDocument){
28026 this.setThumbBoxSize();
28027 this.setThumbBoxPosition();
28028 this.setCanvasPosition();
28033 this.fireEvent('rotate', this, 'right');
28036 onRotateFail : function()
28038 this.errorEl.show(true);
28042 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28047 this.previewEl.dom.innerHTML = '';
28049 var canvasEl = document.createElement("canvas");
28051 var contextEl = canvasEl.getContext("2d");
28053 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28054 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28055 var center = this.imageEl.OriginWidth / 2;
28057 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28058 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28059 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28060 center = this.imageEl.OriginHeight / 2;
28063 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28065 contextEl.translate(center, center);
28066 contextEl.rotate(this.rotate * Math.PI / 180);
28068 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28070 this.canvasEl = document.createElement("canvas");
28072 this.contextEl = this.canvasEl.getContext("2d");
28074 switch (this.rotate) {
28077 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28078 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28080 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28085 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28086 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28088 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28089 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);
28093 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28098 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28099 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28101 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28102 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);
28106 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);
28111 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28112 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28114 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28115 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28119 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);
28126 this.previewEl.appendChild(this.canvasEl);
28128 this.setCanvasPosition();
28133 if(!this.canvasLoaded){
28137 var imageCanvas = document.createElement("canvas");
28139 var imageContext = imageCanvas.getContext("2d");
28141 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28142 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28144 var center = imageCanvas.width / 2;
28146 imageContext.translate(center, center);
28148 imageContext.rotate(this.rotate * Math.PI / 180);
28150 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28152 var canvas = document.createElement("canvas");
28154 var context = canvas.getContext("2d");
28156 canvas.width = this.minWidth;
28157 canvas.height = this.minHeight;
28159 switch (this.rotate) {
28162 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28163 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28165 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28166 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28168 var targetWidth = this.minWidth - 2 * x;
28169 var targetHeight = this.minHeight - 2 * y;
28173 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28174 scale = targetWidth / width;
28177 if(x > 0 && y == 0){
28178 scale = targetHeight / height;
28181 if(x > 0 && y > 0){
28182 scale = targetWidth / width;
28184 if(width < height){
28185 scale = targetHeight / height;
28189 context.scale(scale, scale);
28191 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28192 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28194 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28195 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28197 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28202 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28203 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28205 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28206 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28208 var targetWidth = this.minWidth - 2 * x;
28209 var targetHeight = this.minHeight - 2 * y;
28213 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28214 scale = targetWidth / width;
28217 if(x > 0 && y == 0){
28218 scale = targetHeight / height;
28221 if(x > 0 && y > 0){
28222 scale = targetWidth / width;
28224 if(width < height){
28225 scale = targetHeight / height;
28229 context.scale(scale, scale);
28231 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28232 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28234 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28235 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28237 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28239 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28244 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28245 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28247 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28248 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28250 var targetWidth = this.minWidth - 2 * x;
28251 var targetHeight = this.minHeight - 2 * y;
28255 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28256 scale = targetWidth / width;
28259 if(x > 0 && y == 0){
28260 scale = targetHeight / height;
28263 if(x > 0 && y > 0){
28264 scale = targetWidth / width;
28266 if(width < height){
28267 scale = targetHeight / height;
28271 context.scale(scale, scale);
28273 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28274 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28276 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28277 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28279 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28280 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28282 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28287 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28288 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28290 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28291 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28293 var targetWidth = this.minWidth - 2 * x;
28294 var targetHeight = this.minHeight - 2 * y;
28298 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28299 scale = targetWidth / width;
28302 if(x > 0 && y == 0){
28303 scale = targetHeight / height;
28306 if(x > 0 && y > 0){
28307 scale = targetWidth / width;
28309 if(width < height){
28310 scale = targetHeight / height;
28314 context.scale(scale, scale);
28316 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28317 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28319 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28320 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28322 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28324 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28331 this.cropData = canvas.toDataURL(this.cropType);
28333 if(this.fireEvent('crop', this, this.cropData) !== false){
28334 this.process(this.file, this.cropData);
28341 setThumbBoxSize : function()
28345 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28346 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28347 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28349 this.minWidth = width;
28350 this.minHeight = height;
28352 if(this.rotate == 90 || this.rotate == 270){
28353 this.minWidth = height;
28354 this.minHeight = width;
28359 width = Math.ceil(this.minWidth * height / this.minHeight);
28361 if(this.minWidth > this.minHeight){
28363 height = Math.ceil(this.minHeight * width / this.minWidth);
28366 this.thumbEl.setStyle({
28367 width : width + 'px',
28368 height : height + 'px'
28375 setThumbBoxPosition : function()
28377 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28378 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28380 this.thumbEl.setLeft(x);
28381 this.thumbEl.setTop(y);
28385 baseRotateLevel : function()
28387 this.baseRotate = 1;
28390 typeof(this.exif) != 'undefined' &&
28391 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28392 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28394 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28397 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28401 baseScaleLevel : function()
28405 if(this.isDocument){
28407 if(this.baseRotate == 6 || this.baseRotate == 8){
28409 height = this.thumbEl.getHeight();
28410 this.baseScale = height / this.imageEl.OriginWidth;
28412 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28413 width = this.thumbEl.getWidth();
28414 this.baseScale = width / this.imageEl.OriginHeight;
28420 height = this.thumbEl.getHeight();
28421 this.baseScale = height / this.imageEl.OriginHeight;
28423 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28424 width = this.thumbEl.getWidth();
28425 this.baseScale = width / this.imageEl.OriginWidth;
28431 if(this.baseRotate == 6 || this.baseRotate == 8){
28433 width = this.thumbEl.getHeight();
28434 this.baseScale = width / this.imageEl.OriginHeight;
28436 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28437 height = this.thumbEl.getWidth();
28438 this.baseScale = height / this.imageEl.OriginHeight;
28441 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28442 height = this.thumbEl.getWidth();
28443 this.baseScale = height / this.imageEl.OriginHeight;
28445 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28446 width = this.thumbEl.getHeight();
28447 this.baseScale = width / this.imageEl.OriginWidth;
28454 width = this.thumbEl.getWidth();
28455 this.baseScale = width / this.imageEl.OriginWidth;
28457 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28458 height = this.thumbEl.getHeight();
28459 this.baseScale = height / this.imageEl.OriginHeight;
28462 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28464 height = this.thumbEl.getHeight();
28465 this.baseScale = height / this.imageEl.OriginHeight;
28467 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28468 width = this.thumbEl.getWidth();
28469 this.baseScale = width / this.imageEl.OriginWidth;
28477 getScaleLevel : function()
28479 return this.baseScale * Math.pow(1.1, this.scale);
28482 onTouchStart : function(e)
28484 if(!this.canvasLoaded){
28485 this.beforeSelectFile(e);
28489 var touches = e.browserEvent.touches;
28495 if(touches.length == 1){
28496 this.onMouseDown(e);
28500 if(touches.length != 2){
28506 for(var i = 0, finger; finger = touches[i]; i++){
28507 coords.push(finger.pageX, finger.pageY);
28510 var x = Math.pow(coords[0] - coords[2], 2);
28511 var y = Math.pow(coords[1] - coords[3], 2);
28513 this.startDistance = Math.sqrt(x + y);
28515 this.startScale = this.scale;
28517 this.pinching = true;
28518 this.dragable = false;
28522 onTouchMove : function(e)
28524 if(!this.pinching && !this.dragable){
28528 var touches = e.browserEvent.touches;
28535 this.onMouseMove(e);
28541 for(var i = 0, finger; finger = touches[i]; i++){
28542 coords.push(finger.pageX, finger.pageY);
28545 var x = Math.pow(coords[0] - coords[2], 2);
28546 var y = Math.pow(coords[1] - coords[3], 2);
28548 this.endDistance = Math.sqrt(x + y);
28550 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28552 if(!this.zoomable()){
28553 this.scale = this.startScale;
28561 onTouchEnd : function(e)
28563 this.pinching = false;
28564 this.dragable = false;
28568 process : function(file, crop)
28571 this.maskEl.mask(this.loadingText);
28574 this.xhr = new XMLHttpRequest();
28576 file.xhr = this.xhr;
28578 this.xhr.open(this.method, this.url, true);
28581 "Accept": "application/json",
28582 "Cache-Control": "no-cache",
28583 "X-Requested-With": "XMLHttpRequest"
28586 for (var headerName in headers) {
28587 var headerValue = headers[headerName];
28589 this.xhr.setRequestHeader(headerName, headerValue);
28595 this.xhr.onload = function()
28597 _this.xhrOnLoad(_this.xhr);
28600 this.xhr.onerror = function()
28602 _this.xhrOnError(_this.xhr);
28605 var formData = new FormData();
28607 formData.append('returnHTML', 'NO');
28610 formData.append('crop', crop);
28613 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28614 formData.append(this.paramName, file, file.name);
28617 if(typeof(file.filename) != 'undefined'){
28618 formData.append('filename', file.filename);
28621 if(typeof(file.mimetype) != 'undefined'){
28622 formData.append('mimetype', file.mimetype);
28625 if(this.fireEvent('arrange', this, formData) != false){
28626 this.xhr.send(formData);
28630 xhrOnLoad : function(xhr)
28633 this.maskEl.unmask();
28636 if (xhr.readyState !== 4) {
28637 this.fireEvent('exception', this, xhr);
28641 var response = Roo.decode(xhr.responseText);
28643 if(!response.success){
28644 this.fireEvent('exception', this, xhr);
28648 var response = Roo.decode(xhr.responseText);
28650 this.fireEvent('upload', this, response);
28654 xhrOnError : function()
28657 this.maskEl.unmask();
28660 Roo.log('xhr on error');
28662 var response = Roo.decode(xhr.responseText);
28668 prepare : function(file)
28671 this.maskEl.mask(this.loadingText);
28677 if(typeof(file) === 'string'){
28678 this.loadCanvas(file);
28682 if(!file || !this.urlAPI){
28687 this.cropType = file.type;
28691 if(this.fireEvent('prepare', this, this.file) != false){
28693 var reader = new FileReader();
28695 reader.onload = function (e) {
28696 if (e.target.error) {
28697 Roo.log(e.target.error);
28701 var buffer = e.target.result,
28702 dataView = new DataView(buffer),
28704 maxOffset = dataView.byteLength - 4,
28708 if (dataView.getUint16(0) === 0xffd8) {
28709 while (offset < maxOffset) {
28710 markerBytes = dataView.getUint16(offset);
28712 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28713 markerLength = dataView.getUint16(offset + 2) + 2;
28714 if (offset + markerLength > dataView.byteLength) {
28715 Roo.log('Invalid meta data: Invalid segment size.');
28719 if(markerBytes == 0xffe1){
28720 _this.parseExifData(
28727 offset += markerLength;
28737 var url = _this.urlAPI.createObjectURL(_this.file);
28739 _this.loadCanvas(url);
28744 reader.readAsArrayBuffer(this.file);
28750 parseExifData : function(dataView, offset, length)
28752 var tiffOffset = offset + 10,
28756 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28757 // No Exif data, might be XMP data instead
28761 // Check for the ASCII code for "Exif" (0x45786966):
28762 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28763 // No Exif data, might be XMP data instead
28766 if (tiffOffset + 8 > dataView.byteLength) {
28767 Roo.log('Invalid Exif data: Invalid segment size.');
28770 // Check for the two null bytes:
28771 if (dataView.getUint16(offset + 8) !== 0x0000) {
28772 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28775 // Check the byte alignment:
28776 switch (dataView.getUint16(tiffOffset)) {
28778 littleEndian = true;
28781 littleEndian = false;
28784 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28787 // Check for the TIFF tag marker (0x002A):
28788 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28789 Roo.log('Invalid Exif data: Missing TIFF marker.');
28792 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28793 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28795 this.parseExifTags(
28798 tiffOffset + dirOffset,
28803 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28808 if (dirOffset + 6 > dataView.byteLength) {
28809 Roo.log('Invalid Exif data: Invalid directory offset.');
28812 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28813 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28814 if (dirEndOffset + 4 > dataView.byteLength) {
28815 Roo.log('Invalid Exif data: Invalid directory size.');
28818 for (i = 0; i < tagsNumber; i += 1) {
28822 dirOffset + 2 + 12 * i, // tag offset
28826 // Return the offset to the next directory:
28827 return dataView.getUint32(dirEndOffset, littleEndian);
28830 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28832 var tag = dataView.getUint16(offset, littleEndian);
28834 this.exif[tag] = this.getExifValue(
28838 dataView.getUint16(offset + 2, littleEndian), // tag type
28839 dataView.getUint32(offset + 4, littleEndian), // tag length
28844 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28846 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28855 Roo.log('Invalid Exif data: Invalid tag type.');
28859 tagSize = tagType.size * length;
28860 // Determine if the value is contained in the dataOffset bytes,
28861 // or if the value at the dataOffset is a pointer to the actual data:
28862 dataOffset = tagSize > 4 ?
28863 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28864 if (dataOffset + tagSize > dataView.byteLength) {
28865 Roo.log('Invalid Exif data: Invalid data offset.');
28868 if (length === 1) {
28869 return tagType.getValue(dataView, dataOffset, littleEndian);
28872 for (i = 0; i < length; i += 1) {
28873 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28876 if (tagType.ascii) {
28878 // Concatenate the chars:
28879 for (i = 0; i < values.length; i += 1) {
28881 // Ignore the terminating NULL byte(s):
28882 if (c === '\u0000') {
28894 Roo.apply(Roo.bootstrap.UploadCropbox, {
28896 'Orientation': 0x0112
28900 1: 0, //'top-left',
28902 3: 180, //'bottom-right',
28903 // 4: 'bottom-left',
28905 6: 90, //'right-top',
28906 // 7: 'right-bottom',
28907 8: 270 //'left-bottom'
28911 // byte, 8-bit unsigned int:
28913 getValue: function (dataView, dataOffset) {
28914 return dataView.getUint8(dataOffset);
28918 // ascii, 8-bit byte:
28920 getValue: function (dataView, dataOffset) {
28921 return String.fromCharCode(dataView.getUint8(dataOffset));
28926 // short, 16 bit int:
28928 getValue: function (dataView, dataOffset, littleEndian) {
28929 return dataView.getUint16(dataOffset, littleEndian);
28933 // long, 32 bit int:
28935 getValue: function (dataView, dataOffset, littleEndian) {
28936 return dataView.getUint32(dataOffset, littleEndian);
28940 // rational = two long values, first is numerator, second is denominator:
28942 getValue: function (dataView, dataOffset, littleEndian) {
28943 return dataView.getUint32(dataOffset, littleEndian) /
28944 dataView.getUint32(dataOffset + 4, littleEndian);
28948 // slong, 32 bit signed int:
28950 getValue: function (dataView, dataOffset, littleEndian) {
28951 return dataView.getInt32(dataOffset, littleEndian);
28955 // srational, two slongs, first is numerator, second is denominator:
28957 getValue: function (dataView, dataOffset, littleEndian) {
28958 return dataView.getInt32(dataOffset, littleEndian) /
28959 dataView.getInt32(dataOffset + 4, littleEndian);
28969 cls : 'btn-group roo-upload-cropbox-rotate-left',
28970 action : 'rotate-left',
28974 cls : 'btn btn-default',
28975 html : '<i class="fa fa-undo"></i>'
28981 cls : 'btn-group roo-upload-cropbox-picture',
28982 action : 'picture',
28986 cls : 'btn btn-default',
28987 html : '<i class="fa fa-picture-o"></i>'
28993 cls : 'btn-group roo-upload-cropbox-rotate-right',
28994 action : 'rotate-right',
28998 cls : 'btn btn-default',
28999 html : '<i class="fa fa-repeat"></i>'
29007 cls : 'btn-group roo-upload-cropbox-rotate-left',
29008 action : 'rotate-left',
29012 cls : 'btn btn-default',
29013 html : '<i class="fa fa-undo"></i>'
29019 cls : 'btn-group roo-upload-cropbox-download',
29020 action : 'download',
29024 cls : 'btn btn-default',
29025 html : '<i class="fa fa-download"></i>'
29031 cls : 'btn-group roo-upload-cropbox-crop',
29036 cls : 'btn btn-default',
29037 html : '<i class="fa fa-crop"></i>'
29043 cls : 'btn-group roo-upload-cropbox-trash',
29048 cls : 'btn btn-default',
29049 html : '<i class="fa fa-trash"></i>'
29055 cls : 'btn-group roo-upload-cropbox-rotate-right',
29056 action : 'rotate-right',
29060 cls : 'btn btn-default',
29061 html : '<i class="fa fa-repeat"></i>'
29069 cls : 'btn-group roo-upload-cropbox-rotate-left',
29070 action : 'rotate-left',
29074 cls : 'btn btn-default',
29075 html : '<i class="fa fa-undo"></i>'
29081 cls : 'btn-group roo-upload-cropbox-rotate-right',
29082 action : 'rotate-right',
29086 cls : 'btn btn-default',
29087 html : '<i class="fa fa-repeat"></i>'
29100 * @class Roo.bootstrap.DocumentManager
29101 * @extends Roo.bootstrap.Component
29102 * Bootstrap DocumentManager class
29103 * @cfg {String} paramName default 'imageUpload'
29104 * @cfg {String} toolTipName default 'filename'
29105 * @cfg {String} method default POST
29106 * @cfg {String} url action url
29107 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29108 * @cfg {Boolean} multiple multiple upload default true
29109 * @cfg {Number} thumbSize default 300
29110 * @cfg {String} fieldLabel
29111 * @cfg {Number} labelWidth default 4
29112 * @cfg {String} labelAlign (left|top) default left
29113 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29114 * @cfg {Number} labellg set the width of label (1-12)
29115 * @cfg {Number} labelmd set the width of label (1-12)
29116 * @cfg {Number} labelsm set the width of label (1-12)
29117 * @cfg {Number} labelxs set the width of label (1-12)
29120 * Create a new DocumentManager
29121 * @param {Object} config The config object
29124 Roo.bootstrap.DocumentManager = function(config){
29125 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29128 this.delegates = [];
29133 * Fire when initial the DocumentManager
29134 * @param {Roo.bootstrap.DocumentManager} this
29139 * inspect selected file
29140 * @param {Roo.bootstrap.DocumentManager} this
29141 * @param {File} file
29146 * Fire when xhr load exception
29147 * @param {Roo.bootstrap.DocumentManager} this
29148 * @param {XMLHttpRequest} xhr
29150 "exception" : true,
29152 * @event afterupload
29153 * Fire when xhr load exception
29154 * @param {Roo.bootstrap.DocumentManager} this
29155 * @param {XMLHttpRequest} xhr
29157 "afterupload" : true,
29160 * prepare the form data
29161 * @param {Roo.bootstrap.DocumentManager} this
29162 * @param {Object} formData
29167 * Fire when remove the file
29168 * @param {Roo.bootstrap.DocumentManager} this
29169 * @param {Object} file
29174 * Fire after refresh the file
29175 * @param {Roo.bootstrap.DocumentManager} this
29180 * Fire after click the image
29181 * @param {Roo.bootstrap.DocumentManager} this
29182 * @param {Object} file
29187 * Fire when upload a image and editable set to true
29188 * @param {Roo.bootstrap.DocumentManager} this
29189 * @param {Object} file
29193 * @event beforeselectfile
29194 * Fire before select file
29195 * @param {Roo.bootstrap.DocumentManager} this
29197 "beforeselectfile" : true,
29200 * Fire before process file
29201 * @param {Roo.bootstrap.DocumentManager} this
29202 * @param {Object} file
29206 * @event previewrendered
29207 * Fire when preview rendered
29208 * @param {Roo.bootstrap.DocumentManager} this
29209 * @param {Object} file
29211 "previewrendered" : true,
29214 "previewResize" : true
29219 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29228 paramName : 'imageUpload',
29229 toolTipName : 'filename',
29232 labelAlign : 'left',
29242 getAutoCreate : function()
29244 var managerWidget = {
29246 cls : 'roo-document-manager',
29250 cls : 'roo-document-manager-selector',
29255 cls : 'roo-document-manager-uploader',
29259 cls : 'roo-document-manager-upload-btn',
29260 html : '<i class="fa fa-plus"></i>'
29271 cls : 'column col-md-12',
29276 if(this.fieldLabel.length){
29281 cls : 'column col-md-12',
29282 html : this.fieldLabel
29286 cls : 'column col-md-12',
29291 if(this.labelAlign == 'left'){
29296 html : this.fieldLabel
29305 if(this.labelWidth > 12){
29306 content[0].style = "width: " + this.labelWidth + 'px';
29309 if(this.labelWidth < 13 && this.labelmd == 0){
29310 this.labelmd = this.labelWidth;
29313 if(this.labellg > 0){
29314 content[0].cls += ' col-lg-' + this.labellg;
29315 content[1].cls += ' col-lg-' + (12 - this.labellg);
29318 if(this.labelmd > 0){
29319 content[0].cls += ' col-md-' + this.labelmd;
29320 content[1].cls += ' col-md-' + (12 - this.labelmd);
29323 if(this.labelsm > 0){
29324 content[0].cls += ' col-sm-' + this.labelsm;
29325 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29328 if(this.labelxs > 0){
29329 content[0].cls += ' col-xs-' + this.labelxs;
29330 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29338 cls : 'row clearfix',
29346 initEvents : function()
29348 this.managerEl = this.el.select('.roo-document-manager', true).first();
29349 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29351 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29352 this.selectorEl.hide();
29355 this.selectorEl.attr('multiple', 'multiple');
29358 this.selectorEl.on('change', this.onFileSelected, this);
29360 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29361 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29363 this.uploader.on('click', this.onUploaderClick, this);
29365 this.renderProgressDialog();
29369 window.addEventListener("resize", function() { _this.refresh(); } );
29371 this.fireEvent('initial', this);
29374 renderProgressDialog : function()
29378 this.progressDialog = new Roo.bootstrap.Modal({
29379 cls : 'roo-document-manager-progress-dialog',
29380 allow_close : false,
29391 btnclick : function() {
29392 _this.uploadCancel();
29398 this.progressDialog.render(Roo.get(document.body));
29400 this.progress = new Roo.bootstrap.Progress({
29401 cls : 'roo-document-manager-progress',
29406 this.progress.render(this.progressDialog.getChildContainer());
29408 this.progressBar = new Roo.bootstrap.ProgressBar({
29409 cls : 'roo-document-manager-progress-bar',
29412 aria_valuemax : 12,
29416 this.progressBar.render(this.progress.getChildContainer());
29419 onUploaderClick : function(e)
29421 e.preventDefault();
29423 if(this.fireEvent('beforeselectfile', this) != false){
29424 this.selectorEl.dom.click();
29429 onFileSelected : function(e)
29431 e.preventDefault();
29433 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29437 Roo.each(this.selectorEl.dom.files, function(file){
29438 if(this.fireEvent('inspect', this, file) != false){
29439 this.files.push(file);
29449 this.selectorEl.dom.value = '';
29451 if(!this.files || !this.files.length){
29455 if(this.boxes > 0 && this.files.length > this.boxes){
29456 this.files = this.files.slice(0, this.boxes);
29459 this.uploader.show();
29461 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29462 this.uploader.hide();
29471 Roo.each(this.files, function(file){
29473 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29474 var f = this.renderPreview(file);
29479 if(file.type.indexOf('image') != -1){
29480 this.delegates.push(
29482 _this.process(file);
29483 }).createDelegate(this)
29491 _this.process(file);
29492 }).createDelegate(this)
29497 this.files = files;
29499 this.delegates = this.delegates.concat(docs);
29501 if(!this.delegates.length){
29506 this.progressBar.aria_valuemax = this.delegates.length;
29513 arrange : function()
29515 if(!this.delegates.length){
29516 this.progressDialog.hide();
29521 var delegate = this.delegates.shift();
29523 this.progressDialog.show();
29525 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29527 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29532 refresh : function()
29534 this.uploader.show();
29536 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29537 this.uploader.hide();
29540 Roo.isTouch ? this.closable(false) : this.closable(true);
29542 this.fireEvent('refresh', this);
29545 onRemove : function(e, el, o)
29547 e.preventDefault();
29549 this.fireEvent('remove', this, o);
29553 remove : function(o)
29557 Roo.each(this.files, function(file){
29558 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29567 this.files = files;
29574 Roo.each(this.files, function(file){
29579 file.target.remove();
29588 onClick : function(e, el, o)
29590 e.preventDefault();
29592 this.fireEvent('click', this, o);
29596 closable : function(closable)
29598 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29600 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29612 xhrOnLoad : function(xhr)
29614 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29618 if (xhr.readyState !== 4) {
29620 this.fireEvent('exception', this, xhr);
29624 var response = Roo.decode(xhr.responseText);
29626 if(!response.success){
29628 this.fireEvent('exception', this, xhr);
29632 var file = this.renderPreview(response.data);
29634 this.files.push(file);
29638 this.fireEvent('afterupload', this, xhr);
29642 xhrOnError : function(xhr)
29644 Roo.log('xhr on error');
29646 var response = Roo.decode(xhr.responseText);
29653 process : function(file)
29655 if(this.fireEvent('process', this, file) !== false){
29656 if(this.editable && file.type.indexOf('image') != -1){
29657 this.fireEvent('edit', this, file);
29661 this.uploadStart(file, false);
29668 uploadStart : function(file, crop)
29670 this.xhr = new XMLHttpRequest();
29672 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29677 file.xhr = this.xhr;
29679 this.managerEl.createChild({
29681 cls : 'roo-document-manager-loading',
29685 tooltip : file.name,
29686 cls : 'roo-document-manager-thumb',
29687 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29693 this.xhr.open(this.method, this.url, true);
29696 "Accept": "application/json",
29697 "Cache-Control": "no-cache",
29698 "X-Requested-With": "XMLHttpRequest"
29701 for (var headerName in headers) {
29702 var headerValue = headers[headerName];
29704 this.xhr.setRequestHeader(headerName, headerValue);
29710 this.xhr.onload = function()
29712 _this.xhrOnLoad(_this.xhr);
29715 this.xhr.onerror = function()
29717 _this.xhrOnError(_this.xhr);
29720 var formData = new FormData();
29722 formData.append('returnHTML', 'NO');
29725 formData.append('crop', crop);
29728 formData.append(this.paramName, file, file.name);
29735 if(this.fireEvent('prepare', this, formData, options) != false){
29737 if(options.manually){
29741 this.xhr.send(formData);
29745 this.uploadCancel();
29748 uploadCancel : function()
29754 this.delegates = [];
29756 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29763 renderPreview : function(file)
29765 if(typeof(file.target) != 'undefined' && file.target){
29769 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29771 var previewEl = this.managerEl.createChild({
29773 cls : 'roo-document-manager-preview',
29777 tooltip : file[this.toolTipName],
29778 cls : 'roo-document-manager-thumb',
29779 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29784 html : '<i class="fa fa-times-circle"></i>'
29789 var close = previewEl.select('button.close', true).first();
29791 close.on('click', this.onRemove, this, file);
29793 file.target = previewEl;
29795 var image = previewEl.select('img', true).first();
29799 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29801 image.on('click', this.onClick, this, file);
29803 this.fireEvent('previewrendered', this, file);
29809 onPreviewLoad : function(file, image)
29811 if(typeof(file.target) == 'undefined' || !file.target){
29815 var width = image.dom.naturalWidth || image.dom.width;
29816 var height = image.dom.naturalHeight || image.dom.height;
29818 if(!this.previewResize) {
29822 if(width > height){
29823 file.target.addClass('wide');
29827 file.target.addClass('tall');
29832 uploadFromSource : function(file, crop)
29834 this.xhr = new XMLHttpRequest();
29836 this.managerEl.createChild({
29838 cls : 'roo-document-manager-loading',
29842 tooltip : file.name,
29843 cls : 'roo-document-manager-thumb',
29844 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29850 this.xhr.open(this.method, this.url, true);
29853 "Accept": "application/json",
29854 "Cache-Control": "no-cache",
29855 "X-Requested-With": "XMLHttpRequest"
29858 for (var headerName in headers) {
29859 var headerValue = headers[headerName];
29861 this.xhr.setRequestHeader(headerName, headerValue);
29867 this.xhr.onload = function()
29869 _this.xhrOnLoad(_this.xhr);
29872 this.xhr.onerror = function()
29874 _this.xhrOnError(_this.xhr);
29877 var formData = new FormData();
29879 formData.append('returnHTML', 'NO');
29881 formData.append('crop', crop);
29883 if(typeof(file.filename) != 'undefined'){
29884 formData.append('filename', file.filename);
29887 if(typeof(file.mimetype) != 'undefined'){
29888 formData.append('mimetype', file.mimetype);
29893 if(this.fireEvent('prepare', this, formData) != false){
29894 this.xhr.send(formData);
29904 * @class Roo.bootstrap.DocumentViewer
29905 * @extends Roo.bootstrap.Component
29906 * Bootstrap DocumentViewer class
29907 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29908 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29911 * Create a new DocumentViewer
29912 * @param {Object} config The config object
29915 Roo.bootstrap.DocumentViewer = function(config){
29916 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29921 * Fire after initEvent
29922 * @param {Roo.bootstrap.DocumentViewer} this
29928 * @param {Roo.bootstrap.DocumentViewer} this
29933 * Fire after download button
29934 * @param {Roo.bootstrap.DocumentViewer} this
29939 * Fire after trash button
29940 * @param {Roo.bootstrap.DocumentViewer} this
29947 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29949 showDownload : true,
29953 getAutoCreate : function()
29957 cls : 'roo-document-viewer',
29961 cls : 'roo-document-viewer-body',
29965 cls : 'roo-document-viewer-thumb',
29969 cls : 'roo-document-viewer-image'
29977 cls : 'roo-document-viewer-footer',
29980 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29984 cls : 'btn-group roo-document-viewer-download',
29988 cls : 'btn btn-default',
29989 html : '<i class="fa fa-download"></i>'
29995 cls : 'btn-group roo-document-viewer-trash',
29999 cls : 'btn btn-default',
30000 html : '<i class="fa fa-trash"></i>'
30013 initEvents : function()
30015 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
30016 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
30018 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
30019 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
30021 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
30022 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
30024 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
30025 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
30027 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
30028 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
30030 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
30031 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
30033 this.bodyEl.on('click', this.onClick, this);
30034 this.downloadBtn.on('click', this.onDownload, this);
30035 this.trashBtn.on('click', this.onTrash, this);
30037 this.downloadBtn.hide();
30038 this.trashBtn.hide();
30040 if(this.showDownload){
30041 this.downloadBtn.show();
30044 if(this.showTrash){
30045 this.trashBtn.show();
30048 if(!this.showDownload && !this.showTrash) {
30049 this.footerEl.hide();
30054 initial : function()
30056 this.fireEvent('initial', this);
30060 onClick : function(e)
30062 e.preventDefault();
30064 this.fireEvent('click', this);
30067 onDownload : function(e)
30069 e.preventDefault();
30071 this.fireEvent('download', this);
30074 onTrash : function(e)
30076 e.preventDefault();
30078 this.fireEvent('trash', this);
30090 * @class Roo.bootstrap.NavProgressBar
30091 * @extends Roo.bootstrap.Component
30092 * Bootstrap NavProgressBar class
30095 * Create a new nav progress bar
30096 * @param {Object} config The config object
30099 Roo.bootstrap.NavProgressBar = function(config){
30100 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30102 this.bullets = this.bullets || [];
30104 // Roo.bootstrap.NavProgressBar.register(this);
30108 * Fires when the active item changes
30109 * @param {Roo.bootstrap.NavProgressBar} this
30110 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30111 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30118 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30123 getAutoCreate : function()
30125 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30129 cls : 'roo-navigation-bar-group',
30133 cls : 'roo-navigation-top-bar'
30137 cls : 'roo-navigation-bullets-bar',
30141 cls : 'roo-navigation-bar'
30148 cls : 'roo-navigation-bottom-bar'
30158 initEvents: function()
30163 onRender : function(ct, position)
30165 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30167 if(this.bullets.length){
30168 Roo.each(this.bullets, function(b){
30177 addItem : function(cfg)
30179 var item = new Roo.bootstrap.NavProgressItem(cfg);
30181 item.parentId = this.id;
30182 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30185 var top = new Roo.bootstrap.Element({
30187 cls : 'roo-navigation-bar-text'
30190 var bottom = new Roo.bootstrap.Element({
30192 cls : 'roo-navigation-bar-text'
30195 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30196 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30198 var topText = new Roo.bootstrap.Element({
30200 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30203 var bottomText = new Roo.bootstrap.Element({
30205 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30208 topText.onRender(top.el, null);
30209 bottomText.onRender(bottom.el, null);
30212 item.bottomEl = bottom;
30215 this.barItems.push(item);
30220 getActive : function()
30222 var active = false;
30224 Roo.each(this.barItems, function(v){
30226 if (!v.isActive()) {
30238 setActiveItem : function(item)
30242 Roo.each(this.barItems, function(v){
30243 if (v.rid == item.rid) {
30247 if (v.isActive()) {
30248 v.setActive(false);
30253 item.setActive(true);
30255 this.fireEvent('changed', this, item, prev);
30258 getBarItem: function(rid)
30262 Roo.each(this.barItems, function(e) {
30263 if (e.rid != rid) {
30274 indexOfItem : function(item)
30278 Roo.each(this.barItems, function(v, i){
30280 if (v.rid != item.rid) {
30291 setActiveNext : function()
30293 var i = this.indexOfItem(this.getActive());
30295 if (i > this.barItems.length) {
30299 this.setActiveItem(this.barItems[i+1]);
30302 setActivePrev : function()
30304 var i = this.indexOfItem(this.getActive());
30310 this.setActiveItem(this.barItems[i-1]);
30313 format : function()
30315 if(!this.barItems.length){
30319 var width = 100 / this.barItems.length;
30321 Roo.each(this.barItems, function(i){
30322 i.el.setStyle('width', width + '%');
30323 i.topEl.el.setStyle('width', width + '%');
30324 i.bottomEl.el.setStyle('width', width + '%');
30333 * Nav Progress Item
30338 * @class Roo.bootstrap.NavProgressItem
30339 * @extends Roo.bootstrap.Component
30340 * Bootstrap NavProgressItem class
30341 * @cfg {String} rid the reference id
30342 * @cfg {Boolean} active (true|false) Is item active default false
30343 * @cfg {Boolean} disabled (true|false) Is item active default false
30344 * @cfg {String} html
30345 * @cfg {String} position (top|bottom) text position default bottom
30346 * @cfg {String} icon show icon instead of number
30349 * Create a new NavProgressItem
30350 * @param {Object} config The config object
30352 Roo.bootstrap.NavProgressItem = function(config){
30353 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30358 * The raw click event for the entire grid.
30359 * @param {Roo.bootstrap.NavProgressItem} this
30360 * @param {Roo.EventObject} e
30367 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30373 position : 'bottom',
30376 getAutoCreate : function()
30378 var iconCls = 'roo-navigation-bar-item-icon';
30380 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30384 cls: 'roo-navigation-bar-item',
30394 cfg.cls += ' active';
30397 cfg.cls += ' disabled';
30403 disable : function()
30405 this.setDisabled(true);
30408 enable : function()
30410 this.setDisabled(false);
30413 initEvents: function()
30415 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30417 this.iconEl.on('click', this.onClick, this);
30420 onClick : function(e)
30422 e.preventDefault();
30428 if(this.fireEvent('click', this, e) === false){
30432 this.parent().setActiveItem(this);
30435 isActive: function ()
30437 return this.active;
30440 setActive : function(state)
30442 if(this.active == state){
30446 this.active = state;
30449 this.el.addClass('active');
30453 this.el.removeClass('active');
30458 setDisabled : function(state)
30460 if(this.disabled == state){
30464 this.disabled = state;
30467 this.el.addClass('disabled');
30471 this.el.removeClass('disabled');
30474 tooltipEl : function()
30476 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30489 * @class Roo.bootstrap.FieldLabel
30490 * @extends Roo.bootstrap.Component
30491 * Bootstrap FieldLabel class
30492 * @cfg {String} html contents of the element
30493 * @cfg {String} tag tag of the element default label
30494 * @cfg {String} cls class of the element
30495 * @cfg {String} target label target
30496 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30497 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30498 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30499 * @cfg {String} iconTooltip default "This field is required"
30500 * @cfg {String} indicatorpos (left|right) default left
30503 * Create a new FieldLabel
30504 * @param {Object} config The config object
30507 Roo.bootstrap.FieldLabel = function(config){
30508 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30513 * Fires after the field has been marked as invalid.
30514 * @param {Roo.form.FieldLabel} this
30515 * @param {String} msg The validation message
30520 * Fires after the field has been validated with no errors.
30521 * @param {Roo.form.FieldLabel} this
30527 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30534 invalidClass : 'has-warning',
30535 validClass : 'has-success',
30536 iconTooltip : 'This field is required',
30537 indicatorpos : 'left',
30539 getAutoCreate : function(){
30542 if (!this.allowBlank) {
30548 cls : 'roo-bootstrap-field-label ' + this.cls,
30553 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30554 tooltip : this.iconTooltip
30563 if(this.indicatorpos == 'right'){
30566 cls : 'roo-bootstrap-field-label ' + this.cls,
30575 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30576 tooltip : this.iconTooltip
30585 initEvents: function()
30587 Roo.bootstrap.Element.superclass.initEvents.call(this);
30589 this.indicator = this.indicatorEl();
30591 if(this.indicator){
30592 this.indicator.removeClass('visible');
30593 this.indicator.addClass('invisible');
30596 Roo.bootstrap.FieldLabel.register(this);
30599 indicatorEl : function()
30601 var indicator = this.el.select('i.roo-required-indicator',true).first();
30612 * Mark this field as valid
30614 markValid : function()
30616 if(this.indicator){
30617 this.indicator.removeClass('visible');
30618 this.indicator.addClass('invisible');
30620 if (Roo.bootstrap.version == 3) {
30621 this.el.removeClass(this.invalidClass);
30622 this.el.addClass(this.validClass);
30624 this.el.removeClass('is-invalid');
30625 this.el.addClass('is-valid');
30629 this.fireEvent('valid', this);
30633 * Mark this field as invalid
30634 * @param {String} msg The validation message
30636 markInvalid : function(msg)
30638 if(this.indicator){
30639 this.indicator.removeClass('invisible');
30640 this.indicator.addClass('visible');
30642 if (Roo.bootstrap.version == 3) {
30643 this.el.removeClass(this.validClass);
30644 this.el.addClass(this.invalidClass);
30646 this.el.removeClass('is-valid');
30647 this.el.addClass('is-invalid');
30651 this.fireEvent('invalid', this, msg);
30657 Roo.apply(Roo.bootstrap.FieldLabel, {
30662 * register a FieldLabel Group
30663 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30665 register : function(label)
30667 if(this.groups.hasOwnProperty(label.target)){
30671 this.groups[label.target] = label;
30675 * fetch a FieldLabel Group based on the target
30676 * @param {string} target
30677 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30679 get: function(target) {
30680 if (typeof(this.groups[target]) == 'undefined') {
30684 return this.groups[target] ;
30693 * page DateSplitField.
30699 * @class Roo.bootstrap.DateSplitField
30700 * @extends Roo.bootstrap.Component
30701 * Bootstrap DateSplitField class
30702 * @cfg {string} fieldLabel - the label associated
30703 * @cfg {Number} labelWidth set the width of label (0-12)
30704 * @cfg {String} labelAlign (top|left)
30705 * @cfg {Boolean} dayAllowBlank (true|false) default false
30706 * @cfg {Boolean} monthAllowBlank (true|false) default false
30707 * @cfg {Boolean} yearAllowBlank (true|false) default false
30708 * @cfg {string} dayPlaceholder
30709 * @cfg {string} monthPlaceholder
30710 * @cfg {string} yearPlaceholder
30711 * @cfg {string} dayFormat default 'd'
30712 * @cfg {string} monthFormat default 'm'
30713 * @cfg {string} yearFormat default 'Y'
30714 * @cfg {Number} labellg set the width of label (1-12)
30715 * @cfg {Number} labelmd set the width of label (1-12)
30716 * @cfg {Number} labelsm set the width of label (1-12)
30717 * @cfg {Number} labelxs set the width of label (1-12)
30721 * Create a new DateSplitField
30722 * @param {Object} config The config object
30725 Roo.bootstrap.DateSplitField = function(config){
30726 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30732 * getting the data of years
30733 * @param {Roo.bootstrap.DateSplitField} this
30734 * @param {Object} years
30739 * getting the data of days
30740 * @param {Roo.bootstrap.DateSplitField} this
30741 * @param {Object} days
30746 * Fires after the field has been marked as invalid.
30747 * @param {Roo.form.Field} this
30748 * @param {String} msg The validation message
30753 * Fires after the field has been validated with no errors.
30754 * @param {Roo.form.Field} this
30760 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30763 labelAlign : 'top',
30765 dayAllowBlank : false,
30766 monthAllowBlank : false,
30767 yearAllowBlank : false,
30768 dayPlaceholder : '',
30769 monthPlaceholder : '',
30770 yearPlaceholder : '',
30774 isFormField : true,
30780 getAutoCreate : function()
30784 cls : 'row roo-date-split-field-group',
30789 cls : 'form-hidden-field roo-date-split-field-group-value',
30795 var labelCls = 'col-md-12';
30796 var contentCls = 'col-md-4';
30798 if(this.fieldLabel){
30802 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30806 html : this.fieldLabel
30811 if(this.labelAlign == 'left'){
30813 if(this.labelWidth > 12){
30814 label.style = "width: " + this.labelWidth + 'px';
30817 if(this.labelWidth < 13 && this.labelmd == 0){
30818 this.labelmd = this.labelWidth;
30821 if(this.labellg > 0){
30822 labelCls = ' col-lg-' + this.labellg;
30823 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30826 if(this.labelmd > 0){
30827 labelCls = ' col-md-' + this.labelmd;
30828 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30831 if(this.labelsm > 0){
30832 labelCls = ' col-sm-' + this.labelsm;
30833 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30836 if(this.labelxs > 0){
30837 labelCls = ' col-xs-' + this.labelxs;
30838 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30842 label.cls += ' ' + labelCls;
30844 cfg.cn.push(label);
30847 Roo.each(['day', 'month', 'year'], function(t){
30850 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30857 inputEl: function ()
30859 return this.el.select('.roo-date-split-field-group-value', true).first();
30862 onRender : function(ct, position)
30866 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30868 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30870 this.dayField = new Roo.bootstrap.ComboBox({
30871 allowBlank : this.dayAllowBlank,
30872 alwaysQuery : true,
30873 displayField : 'value',
30876 forceSelection : true,
30878 placeholder : this.dayPlaceholder,
30879 selectOnFocus : true,
30880 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30881 triggerAction : 'all',
30883 valueField : 'value',
30884 store : new Roo.data.SimpleStore({
30885 data : (function() {
30887 _this.fireEvent('days', _this, days);
30890 fields : [ 'value' ]
30893 select : function (_self, record, index)
30895 _this.setValue(_this.getValue());
30900 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30902 this.monthField = new Roo.bootstrap.MonthField({
30903 after : '<i class=\"fa fa-calendar\"></i>',
30904 allowBlank : this.monthAllowBlank,
30905 placeholder : this.monthPlaceholder,
30908 render : function (_self)
30910 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30911 e.preventDefault();
30915 select : function (_self, oldvalue, newvalue)
30917 _this.setValue(_this.getValue());
30922 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30924 this.yearField = new Roo.bootstrap.ComboBox({
30925 allowBlank : this.yearAllowBlank,
30926 alwaysQuery : true,
30927 displayField : 'value',
30930 forceSelection : true,
30932 placeholder : this.yearPlaceholder,
30933 selectOnFocus : true,
30934 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30935 triggerAction : 'all',
30937 valueField : 'value',
30938 store : new Roo.data.SimpleStore({
30939 data : (function() {
30941 _this.fireEvent('years', _this, years);
30944 fields : [ 'value' ]
30947 select : function (_self, record, index)
30949 _this.setValue(_this.getValue());
30954 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30957 setValue : function(v, format)
30959 this.inputEl.dom.value = v;
30961 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30963 var d = Date.parseDate(v, f);
30970 this.setDay(d.format(this.dayFormat));
30971 this.setMonth(d.format(this.monthFormat));
30972 this.setYear(d.format(this.yearFormat));
30979 setDay : function(v)
30981 this.dayField.setValue(v);
30982 this.inputEl.dom.value = this.getValue();
30987 setMonth : function(v)
30989 this.monthField.setValue(v, true);
30990 this.inputEl.dom.value = this.getValue();
30995 setYear : function(v)
30997 this.yearField.setValue(v);
30998 this.inputEl.dom.value = this.getValue();
31003 getDay : function()
31005 return this.dayField.getValue();
31008 getMonth : function()
31010 return this.monthField.getValue();
31013 getYear : function()
31015 return this.yearField.getValue();
31018 getValue : function()
31020 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
31022 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
31032 this.inputEl.dom.value = '';
31037 validate : function()
31039 var d = this.dayField.validate();
31040 var m = this.monthField.validate();
31041 var y = this.yearField.validate();
31046 (!this.dayAllowBlank && !d) ||
31047 (!this.monthAllowBlank && !m) ||
31048 (!this.yearAllowBlank && !y)
31053 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31062 this.markInvalid();
31067 markValid : function()
31070 var label = this.el.select('label', true).first();
31071 var icon = this.el.select('i.fa-star', true).first();
31077 this.fireEvent('valid', this);
31081 * Mark this field as invalid
31082 * @param {String} msg The validation message
31084 markInvalid : function(msg)
31087 var label = this.el.select('label', true).first();
31088 var icon = this.el.select('i.fa-star', true).first();
31090 if(label && !icon){
31091 this.el.select('.roo-date-split-field-label', true).createChild({
31093 cls : 'text-danger fa fa-lg fa-star',
31094 tooltip : 'This field is required',
31095 style : 'margin-right:5px;'
31099 this.fireEvent('invalid', this, msg);
31102 clearInvalid : function()
31104 var label = this.el.select('label', true).first();
31105 var icon = this.el.select('i.fa-star', true).first();
31111 this.fireEvent('valid', this);
31114 getName: function()
31124 * http://masonry.desandro.com
31126 * The idea is to render all the bricks based on vertical width...
31128 * The original code extends 'outlayer' - we might need to use that....
31134 * @class Roo.bootstrap.LayoutMasonry
31135 * @extends Roo.bootstrap.Component
31136 * Bootstrap Layout Masonry class
31139 * Create a new Element
31140 * @param {Object} config The config object
31143 Roo.bootstrap.LayoutMasonry = function(config){
31145 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31149 Roo.bootstrap.LayoutMasonry.register(this);
31155 * Fire after layout the items
31156 * @param {Roo.bootstrap.LayoutMasonry} this
31157 * @param {Roo.EventObject} e
31164 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31167 * @cfg {Boolean} isLayoutInstant = no animation?
31169 isLayoutInstant : false, // needed?
31172 * @cfg {Number} boxWidth width of the columns
31177 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31182 * @cfg {Number} padWidth padding below box..
31187 * @cfg {Number} gutter gutter width..
31192 * @cfg {Number} maxCols maximum number of columns
31198 * @cfg {Boolean} isAutoInitial defalut true
31200 isAutoInitial : true,
31205 * @cfg {Boolean} isHorizontal defalut false
31207 isHorizontal : false,
31209 currentSize : null,
31215 bricks: null, //CompositeElement
31219 _isLayoutInited : false,
31221 // isAlternative : false, // only use for vertical layout...
31224 * @cfg {Number} alternativePadWidth padding below box..
31226 alternativePadWidth : 50,
31228 selectedBrick : [],
31230 getAutoCreate : function(){
31232 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31236 cls: 'blog-masonary-wrapper ' + this.cls,
31238 cls : 'mas-boxes masonary'
31245 getChildContainer: function( )
31247 if (this.boxesEl) {
31248 return this.boxesEl;
31251 this.boxesEl = this.el.select('.mas-boxes').first();
31253 return this.boxesEl;
31257 initEvents : function()
31261 if(this.isAutoInitial){
31262 Roo.log('hook children rendered');
31263 this.on('childrenrendered', function() {
31264 Roo.log('children rendered');
31270 initial : function()
31272 this.selectedBrick = [];
31274 this.currentSize = this.el.getBox(true);
31276 Roo.EventManager.onWindowResize(this.resize, this);
31278 if(!this.isAutoInitial){
31286 //this.layout.defer(500,this);
31290 resize : function()
31292 var cs = this.el.getBox(true);
31295 this.currentSize.width == cs.width &&
31296 this.currentSize.x == cs.x &&
31297 this.currentSize.height == cs.height &&
31298 this.currentSize.y == cs.y
31300 Roo.log("no change in with or X or Y");
31304 this.currentSize = cs;
31310 layout : function()
31312 this._resetLayout();
31314 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31316 this.layoutItems( isInstant );
31318 this._isLayoutInited = true;
31320 this.fireEvent('layout', this);
31324 _resetLayout : function()
31326 if(this.isHorizontal){
31327 this.horizontalMeasureColumns();
31331 this.verticalMeasureColumns();
31335 verticalMeasureColumns : function()
31337 this.getContainerWidth();
31339 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31340 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31344 var boxWidth = this.boxWidth + this.padWidth;
31346 if(this.containerWidth < this.boxWidth){
31347 boxWidth = this.containerWidth
31350 var containerWidth = this.containerWidth;
31352 var cols = Math.floor(containerWidth / boxWidth);
31354 this.cols = Math.max( cols, 1 );
31356 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31358 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31360 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31362 this.colWidth = boxWidth + avail - this.padWidth;
31364 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31365 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31368 horizontalMeasureColumns : function()
31370 this.getContainerWidth();
31372 var boxWidth = this.boxWidth;
31374 if(this.containerWidth < boxWidth){
31375 boxWidth = this.containerWidth;
31378 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31380 this.el.setHeight(boxWidth);
31384 getContainerWidth : function()
31386 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31389 layoutItems : function( isInstant )
31391 Roo.log(this.bricks);
31393 var items = Roo.apply([], this.bricks);
31395 if(this.isHorizontal){
31396 this._horizontalLayoutItems( items , isInstant );
31400 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31401 // this._verticalAlternativeLayoutItems( items , isInstant );
31405 this._verticalLayoutItems( items , isInstant );
31409 _verticalLayoutItems : function ( items , isInstant)
31411 if ( !items || !items.length ) {
31416 ['xs', 'xs', 'xs', 'tall'],
31417 ['xs', 'xs', 'tall'],
31418 ['xs', 'xs', 'sm'],
31419 ['xs', 'xs', 'xs'],
31425 ['sm', 'xs', 'xs'],
31429 ['tall', 'xs', 'xs', 'xs'],
31430 ['tall', 'xs', 'xs'],
31442 Roo.each(items, function(item, k){
31444 switch (item.size) {
31445 // these layouts take up a full box,
31456 boxes.push([item]);
31479 var filterPattern = function(box, length)
31487 var pattern = box.slice(0, length);
31491 Roo.each(pattern, function(i){
31492 format.push(i.size);
31495 Roo.each(standard, function(s){
31497 if(String(s) != String(format)){
31506 if(!match && length == 1){
31511 filterPattern(box, length - 1);
31515 queue.push(pattern);
31517 box = box.slice(length, box.length);
31519 filterPattern(box, 4);
31525 Roo.each(boxes, function(box, k){
31531 if(box.length == 1){
31536 filterPattern(box, 4);
31540 this._processVerticalLayoutQueue( queue, isInstant );
31544 // _verticalAlternativeLayoutItems : function( items , isInstant )
31546 // if ( !items || !items.length ) {
31550 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31554 _horizontalLayoutItems : function ( items , isInstant)
31556 if ( !items || !items.length || items.length < 3) {
31562 var eItems = items.slice(0, 3);
31564 items = items.slice(3, items.length);
31567 ['xs', 'xs', 'xs', 'wide'],
31568 ['xs', 'xs', 'wide'],
31569 ['xs', 'xs', 'sm'],
31570 ['xs', 'xs', 'xs'],
31576 ['sm', 'xs', 'xs'],
31580 ['wide', 'xs', 'xs', 'xs'],
31581 ['wide', 'xs', 'xs'],
31594 Roo.each(items, function(item, k){
31596 switch (item.size) {
31607 boxes.push([item]);
31631 var filterPattern = function(box, length)
31639 var pattern = box.slice(0, length);
31643 Roo.each(pattern, function(i){
31644 format.push(i.size);
31647 Roo.each(standard, function(s){
31649 if(String(s) != String(format)){
31658 if(!match && length == 1){
31663 filterPattern(box, length - 1);
31667 queue.push(pattern);
31669 box = box.slice(length, box.length);
31671 filterPattern(box, 4);
31677 Roo.each(boxes, function(box, k){
31683 if(box.length == 1){
31688 filterPattern(box, 4);
31695 var pos = this.el.getBox(true);
31699 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31701 var hit_end = false;
31703 Roo.each(queue, function(box){
31707 Roo.each(box, function(b){
31709 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31719 Roo.each(box, function(b){
31721 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31724 mx = Math.max(mx, b.x);
31728 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31732 Roo.each(box, function(b){
31734 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31748 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31751 /** Sets position of item in DOM
31752 * @param {Element} item
31753 * @param {Number} x - horizontal position
31754 * @param {Number} y - vertical position
31755 * @param {Boolean} isInstant - disables transitions
31757 _processVerticalLayoutQueue : function( queue, isInstant )
31759 var pos = this.el.getBox(true);
31764 for (var i = 0; i < this.cols; i++){
31768 Roo.each(queue, function(box, k){
31770 var col = k % this.cols;
31772 Roo.each(box, function(b,kk){
31774 b.el.position('absolute');
31776 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31777 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31779 if(b.size == 'md-left' || b.size == 'md-right'){
31780 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31781 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31784 b.el.setWidth(width);
31785 b.el.setHeight(height);
31787 b.el.select('iframe',true).setSize(width,height);
31791 for (var i = 0; i < this.cols; i++){
31793 if(maxY[i] < maxY[col]){
31798 col = Math.min(col, i);
31802 x = pos.x + col * (this.colWidth + this.padWidth);
31806 var positions = [];
31808 switch (box.length){
31810 positions = this.getVerticalOneBoxColPositions(x, y, box);
31813 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31816 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31819 positions = this.getVerticalFourBoxColPositions(x, y, box);
31825 Roo.each(box, function(b,kk){
31827 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31829 var sz = b.el.getSize();
31831 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31839 for (var i = 0; i < this.cols; i++){
31840 mY = Math.max(mY, maxY[i]);
31843 this.el.setHeight(mY - pos.y);
31847 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31849 // var pos = this.el.getBox(true);
31852 // var maxX = pos.right;
31854 // var maxHeight = 0;
31856 // Roo.each(items, function(item, k){
31860 // item.el.position('absolute');
31862 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31864 // item.el.setWidth(width);
31866 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31868 // item.el.setHeight(height);
31871 // item.el.setXY([x, y], isInstant ? false : true);
31873 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31876 // y = y + height + this.alternativePadWidth;
31878 // maxHeight = maxHeight + height + this.alternativePadWidth;
31882 // this.el.setHeight(maxHeight);
31886 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31888 var pos = this.el.getBox(true);
31893 var maxX = pos.right;
31895 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31897 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31899 Roo.each(queue, function(box, k){
31901 Roo.each(box, function(b, kk){
31903 b.el.position('absolute');
31905 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31906 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31908 if(b.size == 'md-left' || b.size == 'md-right'){
31909 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31910 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31913 b.el.setWidth(width);
31914 b.el.setHeight(height);
31922 var positions = [];
31924 switch (box.length){
31926 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31929 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31932 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31935 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31941 Roo.each(box, function(b,kk){
31943 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31945 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31953 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31955 Roo.each(eItems, function(b,k){
31957 b.size = (k == 0) ? 'sm' : 'xs';
31958 b.x = (k == 0) ? 2 : 1;
31959 b.y = (k == 0) ? 2 : 1;
31961 b.el.position('absolute');
31963 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31965 b.el.setWidth(width);
31967 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31969 b.el.setHeight(height);
31973 var positions = [];
31976 x : maxX - this.unitWidth * 2 - this.gutter,
31981 x : maxX - this.unitWidth,
31982 y : minY + (this.unitWidth + this.gutter) * 2
31986 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31990 Roo.each(eItems, function(b,k){
31992 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31998 getVerticalOneBoxColPositions : function(x, y, box)
32002 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
32004 if(box[0].size == 'md-left'){
32008 if(box[0].size == 'md-right'){
32013 x : x + (this.unitWidth + this.gutter) * rand,
32020 getVerticalTwoBoxColPositions : function(x, y, box)
32024 if(box[0].size == 'xs'){
32028 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
32032 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32046 x : x + (this.unitWidth + this.gutter) * 2,
32047 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32054 getVerticalThreeBoxColPositions : function(x, y, box)
32058 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32066 x : x + (this.unitWidth + this.gutter) * 1,
32071 x : x + (this.unitWidth + this.gutter) * 2,
32079 if(box[0].size == 'xs' && box[1].size == 'xs'){
32088 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32092 x : x + (this.unitWidth + this.gutter) * 1,
32106 x : x + (this.unitWidth + this.gutter) * 2,
32111 x : x + (this.unitWidth + this.gutter) * 2,
32112 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32119 getVerticalFourBoxColPositions : function(x, y, box)
32123 if(box[0].size == 'xs'){
32132 y : y + (this.unitHeight + this.gutter) * 1
32137 y : y + (this.unitHeight + this.gutter) * 2
32141 x : x + (this.unitWidth + this.gutter) * 1,
32155 x : x + (this.unitWidth + this.gutter) * 2,
32160 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32161 y : y + (this.unitHeight + this.gutter) * 1
32165 x : x + (this.unitWidth + this.gutter) * 2,
32166 y : y + (this.unitWidth + this.gutter) * 2
32173 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32177 if(box[0].size == 'md-left'){
32179 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32186 if(box[0].size == 'md-right'){
32188 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32189 y : minY + (this.unitWidth + this.gutter) * 1
32195 var rand = Math.floor(Math.random() * (4 - box[0].y));
32198 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32199 y : minY + (this.unitWidth + this.gutter) * rand
32206 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32210 if(box[0].size == 'xs'){
32213 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32218 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32219 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32227 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32232 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32233 y : minY + (this.unitWidth + this.gutter) * 2
32240 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32244 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32247 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32252 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32253 y : minY + (this.unitWidth + this.gutter) * 1
32257 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32258 y : minY + (this.unitWidth + this.gutter) * 2
32265 if(box[0].size == 'xs' && box[1].size == 'xs'){
32268 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32273 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32278 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32279 y : minY + (this.unitWidth + this.gutter) * 1
32287 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32292 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32293 y : minY + (this.unitWidth + this.gutter) * 2
32297 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32298 y : minY + (this.unitWidth + this.gutter) * 2
32305 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32309 if(box[0].size == 'xs'){
32312 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32317 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32322 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),
32327 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32328 y : minY + (this.unitWidth + this.gutter) * 1
32336 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32341 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32342 y : minY + (this.unitWidth + this.gutter) * 2
32346 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32347 y : minY + (this.unitWidth + this.gutter) * 2
32351 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),
32352 y : minY + (this.unitWidth + this.gutter) * 2
32360 * remove a Masonry Brick
32361 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32363 removeBrick : function(brick_id)
32369 for (var i = 0; i<this.bricks.length; i++) {
32370 if (this.bricks[i].id == brick_id) {
32371 this.bricks.splice(i,1);
32372 this.el.dom.removeChild(Roo.get(brick_id).dom);
32379 * adds a Masonry Brick
32380 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32382 addBrick : function(cfg)
32384 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32385 //this.register(cn);
32386 cn.parentId = this.id;
32387 cn.render(this.el);
32392 * register a Masonry Brick
32393 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32396 register : function(brick)
32398 this.bricks.push(brick);
32399 brick.masonryId = this.id;
32403 * clear all the Masonry Brick
32405 clearAll : function()
32408 //this.getChildContainer().dom.innerHTML = "";
32409 this.el.dom.innerHTML = '';
32412 getSelected : function()
32414 if (!this.selectedBrick) {
32418 return this.selectedBrick;
32422 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32426 * register a Masonry Layout
32427 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32430 register : function(layout)
32432 this.groups[layout.id] = layout;
32435 * fetch a Masonry Layout based on the masonry layout ID
32436 * @param {string} the masonry layout to add
32437 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32440 get: function(layout_id) {
32441 if (typeof(this.groups[layout_id]) == 'undefined') {
32444 return this.groups[layout_id] ;
32456 * http://masonry.desandro.com
32458 * The idea is to render all the bricks based on vertical width...
32460 * The original code extends 'outlayer' - we might need to use that....
32466 * @class Roo.bootstrap.LayoutMasonryAuto
32467 * @extends Roo.bootstrap.Component
32468 * Bootstrap Layout Masonry class
32471 * Create a new Element
32472 * @param {Object} config The config object
32475 Roo.bootstrap.LayoutMasonryAuto = function(config){
32476 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32479 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32482 * @cfg {Boolean} isFitWidth - resize the width..
32484 isFitWidth : false, // options..
32486 * @cfg {Boolean} isOriginLeft = left align?
32488 isOriginLeft : true,
32490 * @cfg {Boolean} isOriginTop = top align?
32492 isOriginTop : false,
32494 * @cfg {Boolean} isLayoutInstant = no animation?
32496 isLayoutInstant : false, // needed?
32498 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32500 isResizingContainer : true,
32502 * @cfg {Number} columnWidth width of the columns
32508 * @cfg {Number} maxCols maximum number of columns
32513 * @cfg {Number} padHeight padding below box..
32519 * @cfg {Boolean} isAutoInitial defalut true
32522 isAutoInitial : true,
32528 initialColumnWidth : 0,
32529 currentSize : null,
32531 colYs : null, // array.
32538 bricks: null, //CompositeElement
32539 cols : 0, // array?
32540 // element : null, // wrapped now this.el
32541 _isLayoutInited : null,
32544 getAutoCreate : function(){
32548 cls: 'blog-masonary-wrapper ' + this.cls,
32550 cls : 'mas-boxes masonary'
32557 getChildContainer: function( )
32559 if (this.boxesEl) {
32560 return this.boxesEl;
32563 this.boxesEl = this.el.select('.mas-boxes').first();
32565 return this.boxesEl;
32569 initEvents : function()
32573 if(this.isAutoInitial){
32574 Roo.log('hook children rendered');
32575 this.on('childrenrendered', function() {
32576 Roo.log('children rendered');
32583 initial : function()
32585 this.reloadItems();
32587 this.currentSize = this.el.getBox(true);
32589 /// was window resize... - let's see if this works..
32590 Roo.EventManager.onWindowResize(this.resize, this);
32592 if(!this.isAutoInitial){
32597 this.layout.defer(500,this);
32600 reloadItems: function()
32602 this.bricks = this.el.select('.masonry-brick', true);
32604 this.bricks.each(function(b) {
32605 //Roo.log(b.getSize());
32606 if (!b.attr('originalwidth')) {
32607 b.attr('originalwidth', b.getSize().width);
32612 Roo.log(this.bricks.elements.length);
32615 resize : function()
32618 var cs = this.el.getBox(true);
32620 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32621 Roo.log("no change in with or X");
32624 this.currentSize = cs;
32628 layout : function()
32631 this._resetLayout();
32632 //this._manageStamps();
32634 // don't animate first layout
32635 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32636 this.layoutItems( isInstant );
32638 // flag for initalized
32639 this._isLayoutInited = true;
32642 layoutItems : function( isInstant )
32644 //var items = this._getItemsForLayout( this.items );
32645 // original code supports filtering layout items.. we just ignore it..
32647 this._layoutItems( this.bricks , isInstant );
32649 this._postLayout();
32651 _layoutItems : function ( items , isInstant)
32653 //this.fireEvent( 'layout', this, items );
32656 if ( !items || !items.elements.length ) {
32657 // no items, emit event with empty array
32662 items.each(function(item) {
32663 Roo.log("layout item");
32665 // get x/y object from method
32666 var position = this._getItemLayoutPosition( item );
32668 position.item = item;
32669 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32670 queue.push( position );
32673 this._processLayoutQueue( queue );
32675 /** Sets position of item in DOM
32676 * @param {Element} item
32677 * @param {Number} x - horizontal position
32678 * @param {Number} y - vertical position
32679 * @param {Boolean} isInstant - disables transitions
32681 _processLayoutQueue : function( queue )
32683 for ( var i=0, len = queue.length; i < len; i++ ) {
32684 var obj = queue[i];
32685 obj.item.position('absolute');
32686 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32692 * Any logic you want to do after each layout,
32693 * i.e. size the container
32695 _postLayout : function()
32697 this.resizeContainer();
32700 resizeContainer : function()
32702 if ( !this.isResizingContainer ) {
32705 var size = this._getContainerSize();
32707 this.el.setSize(size.width,size.height);
32708 this.boxesEl.setSize(size.width,size.height);
32714 _resetLayout : function()
32716 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32717 this.colWidth = this.el.getWidth();
32718 //this.gutter = this.el.getWidth();
32720 this.measureColumns();
32726 this.colYs.push( 0 );
32732 measureColumns : function()
32734 this.getContainerWidth();
32735 // if columnWidth is 0, default to outerWidth of first item
32736 if ( !this.columnWidth ) {
32737 var firstItem = this.bricks.first();
32738 Roo.log(firstItem);
32739 this.columnWidth = this.containerWidth;
32740 if (firstItem && firstItem.attr('originalwidth') ) {
32741 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32743 // columnWidth fall back to item of first element
32744 Roo.log("set column width?");
32745 this.initialColumnWidth = this.columnWidth ;
32747 // if first elem has no width, default to size of container
32752 if (this.initialColumnWidth) {
32753 this.columnWidth = this.initialColumnWidth;
32758 // column width is fixed at the top - however if container width get's smaller we should
32761 // this bit calcs how man columns..
32763 var columnWidth = this.columnWidth += this.gutter;
32765 // calculate columns
32766 var containerWidth = this.containerWidth + this.gutter;
32768 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32769 // fix rounding errors, typically with gutters
32770 var excess = columnWidth - containerWidth % columnWidth;
32773 // if overshoot is less than a pixel, round up, otherwise floor it
32774 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32775 cols = Math[ mathMethod ]( cols );
32776 this.cols = Math.max( cols, 1 );
32777 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32779 // padding positioning..
32780 var totalColWidth = this.cols * this.columnWidth;
32781 var padavail = this.containerWidth - totalColWidth;
32782 // so for 2 columns - we need 3 'pads'
32784 var padNeeded = (1+this.cols) * this.padWidth;
32786 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32788 this.columnWidth += padExtra
32789 //this.padWidth = Math.floor(padavail / ( this.cols));
32791 // adjust colum width so that padding is fixed??
32793 // we have 3 columns ... total = width * 3
32794 // we have X left over... that should be used by
32796 //if (this.expandC) {
32804 getContainerWidth : function()
32806 /* // container is parent if fit width
32807 var container = this.isFitWidth ? this.element.parentNode : this.element;
32808 // check that this.size and size are there
32809 // IE8 triggers resize on body size change, so they might not be
32811 var size = getSize( container ); //FIXME
32812 this.containerWidth = size && size.innerWidth; //FIXME
32815 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32819 _getItemLayoutPosition : function( item ) // what is item?
32821 // we resize the item to our columnWidth..
32823 item.setWidth(this.columnWidth);
32824 item.autoBoxAdjust = false;
32826 var sz = item.getSize();
32828 // how many columns does this brick span
32829 var remainder = this.containerWidth % this.columnWidth;
32831 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32832 // round if off by 1 pixel, otherwise use ceil
32833 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32834 colSpan = Math.min( colSpan, this.cols );
32836 // normally this should be '1' as we dont' currently allow multi width columns..
32838 var colGroup = this._getColGroup( colSpan );
32839 // get the minimum Y value from the columns
32840 var minimumY = Math.min.apply( Math, colGroup );
32841 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32843 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32845 // position the brick
32847 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32848 y: this.currentSize.y + minimumY + this.padHeight
32852 // apply setHeight to necessary columns
32853 var setHeight = minimumY + sz.height + this.padHeight;
32854 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32856 var setSpan = this.cols + 1 - colGroup.length;
32857 for ( var i = 0; i < setSpan; i++ ) {
32858 this.colYs[ shortColIndex + i ] = setHeight ;
32865 * @param {Number} colSpan - number of columns the element spans
32866 * @returns {Array} colGroup
32868 _getColGroup : function( colSpan )
32870 if ( colSpan < 2 ) {
32871 // if brick spans only one column, use all the column Ys
32876 // how many different places could this brick fit horizontally
32877 var groupCount = this.cols + 1 - colSpan;
32878 // for each group potential horizontal position
32879 for ( var i = 0; i < groupCount; i++ ) {
32880 // make an array of colY values for that one group
32881 var groupColYs = this.colYs.slice( i, i + colSpan );
32882 // and get the max value of the array
32883 colGroup[i] = Math.max.apply( Math, groupColYs );
32888 _manageStamp : function( stamp )
32890 var stampSize = stamp.getSize();
32891 var offset = stamp.getBox();
32892 // get the columns that this stamp affects
32893 var firstX = this.isOriginLeft ? offset.x : offset.right;
32894 var lastX = firstX + stampSize.width;
32895 var firstCol = Math.floor( firstX / this.columnWidth );
32896 firstCol = Math.max( 0, firstCol );
32898 var lastCol = Math.floor( lastX / this.columnWidth );
32899 // lastCol should not go over if multiple of columnWidth #425
32900 lastCol -= lastX % this.columnWidth ? 0 : 1;
32901 lastCol = Math.min( this.cols - 1, lastCol );
32903 // set colYs to bottom of the stamp
32904 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32907 for ( var i = firstCol; i <= lastCol; i++ ) {
32908 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32913 _getContainerSize : function()
32915 this.maxY = Math.max.apply( Math, this.colYs );
32920 if ( this.isFitWidth ) {
32921 size.width = this._getContainerFitWidth();
32927 _getContainerFitWidth : function()
32929 var unusedCols = 0;
32930 // count unused columns
32933 if ( this.colYs[i] !== 0 ) {
32938 // fit container to columns that have been used
32939 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32942 needsResizeLayout : function()
32944 var previousWidth = this.containerWidth;
32945 this.getContainerWidth();
32946 return previousWidth !== this.containerWidth;
32961 * @class Roo.bootstrap.MasonryBrick
32962 * @extends Roo.bootstrap.Component
32963 * Bootstrap MasonryBrick class
32966 * Create a new MasonryBrick
32967 * @param {Object} config The config object
32970 Roo.bootstrap.MasonryBrick = function(config){
32972 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32974 Roo.bootstrap.MasonryBrick.register(this);
32980 * When a MasonryBrick is clcik
32981 * @param {Roo.bootstrap.MasonryBrick} this
32982 * @param {Roo.EventObject} e
32988 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32991 * @cfg {String} title
32995 * @cfg {String} html
32999 * @cfg {String} bgimage
33003 * @cfg {String} videourl
33007 * @cfg {String} cls
33011 * @cfg {String} href
33015 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
33020 * @cfg {String} placetitle (center|bottom)
33025 * @cfg {Boolean} isFitContainer defalut true
33027 isFitContainer : true,
33030 * @cfg {Boolean} preventDefault defalut false
33032 preventDefault : false,
33035 * @cfg {Boolean} inverse defalut false
33037 maskInverse : false,
33039 getAutoCreate : function()
33041 if(!this.isFitContainer){
33042 return this.getSplitAutoCreate();
33045 var cls = 'masonry-brick masonry-brick-full';
33047 if(this.href.length){
33048 cls += ' masonry-brick-link';
33051 if(this.bgimage.length){
33052 cls += ' masonry-brick-image';
33055 if(this.maskInverse){
33056 cls += ' mask-inverse';
33059 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33060 cls += ' enable-mask';
33064 cls += ' masonry-' + this.size + '-brick';
33067 if(this.placetitle.length){
33069 switch (this.placetitle) {
33071 cls += ' masonry-center-title';
33074 cls += ' masonry-bottom-title';
33081 if(!this.html.length && !this.bgimage.length){
33082 cls += ' masonry-center-title';
33085 if(!this.html.length && this.bgimage.length){
33086 cls += ' masonry-bottom-title';
33091 cls += ' ' + this.cls;
33095 tag: (this.href.length) ? 'a' : 'div',
33100 cls: 'masonry-brick-mask'
33104 cls: 'masonry-brick-paragraph',
33110 if(this.href.length){
33111 cfg.href = this.href;
33114 var cn = cfg.cn[1].cn;
33116 if(this.title.length){
33119 cls: 'masonry-brick-title',
33124 if(this.html.length){
33127 cls: 'masonry-brick-text',
33132 if (!this.title.length && !this.html.length) {
33133 cfg.cn[1].cls += ' hide';
33136 if(this.bgimage.length){
33139 cls: 'masonry-brick-image-view',
33144 if(this.videourl.length){
33145 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33146 // youtube support only?
33149 cls: 'masonry-brick-image-view',
33152 allowfullscreen : true
33160 getSplitAutoCreate : function()
33162 var cls = 'masonry-brick masonry-brick-split';
33164 if(this.href.length){
33165 cls += ' masonry-brick-link';
33168 if(this.bgimage.length){
33169 cls += ' masonry-brick-image';
33173 cls += ' masonry-' + this.size + '-brick';
33176 switch (this.placetitle) {
33178 cls += ' masonry-center-title';
33181 cls += ' masonry-bottom-title';
33184 if(!this.bgimage.length){
33185 cls += ' masonry-center-title';
33188 if(this.bgimage.length){
33189 cls += ' masonry-bottom-title';
33195 cls += ' ' + this.cls;
33199 tag: (this.href.length) ? 'a' : 'div',
33204 cls: 'masonry-brick-split-head',
33208 cls: 'masonry-brick-paragraph',
33215 cls: 'masonry-brick-split-body',
33221 if(this.href.length){
33222 cfg.href = this.href;
33225 if(this.title.length){
33226 cfg.cn[0].cn[0].cn.push({
33228 cls: 'masonry-brick-title',
33233 if(this.html.length){
33234 cfg.cn[1].cn.push({
33236 cls: 'masonry-brick-text',
33241 if(this.bgimage.length){
33242 cfg.cn[0].cn.push({
33244 cls: 'masonry-brick-image-view',
33249 if(this.videourl.length){
33250 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33251 // youtube support only?
33252 cfg.cn[0].cn.cn.push({
33254 cls: 'masonry-brick-image-view',
33257 allowfullscreen : true
33264 initEvents: function()
33266 switch (this.size) {
33299 this.el.on('touchstart', this.onTouchStart, this);
33300 this.el.on('touchmove', this.onTouchMove, this);
33301 this.el.on('touchend', this.onTouchEnd, this);
33302 this.el.on('contextmenu', this.onContextMenu, this);
33304 this.el.on('mouseenter' ,this.enter, this);
33305 this.el.on('mouseleave', this.leave, this);
33306 this.el.on('click', this.onClick, this);
33309 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33310 this.parent().bricks.push(this);
33315 onClick: function(e, el)
33317 var time = this.endTimer - this.startTimer;
33318 // Roo.log(e.preventDefault());
33321 e.preventDefault();
33326 if(!this.preventDefault){
33330 e.preventDefault();
33332 if (this.activeClass != '') {
33333 this.selectBrick();
33336 this.fireEvent('click', this, e);
33339 enter: function(e, el)
33341 e.preventDefault();
33343 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33347 if(this.bgimage.length && this.html.length){
33348 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33352 leave: function(e, el)
33354 e.preventDefault();
33356 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33360 if(this.bgimage.length && this.html.length){
33361 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33365 onTouchStart: function(e, el)
33367 // e.preventDefault();
33369 this.touchmoved = false;
33371 if(!this.isFitContainer){
33375 if(!this.bgimage.length || !this.html.length){
33379 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33381 this.timer = new Date().getTime();
33385 onTouchMove: function(e, el)
33387 this.touchmoved = true;
33390 onContextMenu : function(e,el)
33392 e.preventDefault();
33393 e.stopPropagation();
33397 onTouchEnd: function(e, el)
33399 // e.preventDefault();
33401 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33408 if(!this.bgimage.length || !this.html.length){
33410 if(this.href.length){
33411 window.location.href = this.href;
33417 if(!this.isFitContainer){
33421 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33423 window.location.href = this.href;
33426 //selection on single brick only
33427 selectBrick : function() {
33429 if (!this.parentId) {
33433 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33434 var index = m.selectedBrick.indexOf(this.id);
33437 m.selectedBrick.splice(index,1);
33438 this.el.removeClass(this.activeClass);
33442 for(var i = 0; i < m.selectedBrick.length; i++) {
33443 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33444 b.el.removeClass(b.activeClass);
33447 m.selectedBrick = [];
33449 m.selectedBrick.push(this.id);
33450 this.el.addClass(this.activeClass);
33454 isSelected : function(){
33455 return this.el.hasClass(this.activeClass);
33460 Roo.apply(Roo.bootstrap.MasonryBrick, {
33463 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33465 * register a Masonry Brick
33466 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33469 register : function(brick)
33471 //this.groups[brick.id] = brick;
33472 this.groups.add(brick.id, brick);
33475 * fetch a masonry brick based on the masonry brick ID
33476 * @param {string} the masonry brick to add
33477 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33480 get: function(brick_id)
33482 // if (typeof(this.groups[brick_id]) == 'undefined') {
33485 // return this.groups[brick_id] ;
33487 if(this.groups.key(brick_id)) {
33488 return this.groups.key(brick_id);
33506 * @class Roo.bootstrap.Brick
33507 * @extends Roo.bootstrap.Component
33508 * Bootstrap Brick class
33511 * Create a new Brick
33512 * @param {Object} config The config object
33515 Roo.bootstrap.Brick = function(config){
33516 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33522 * When a Brick is click
33523 * @param {Roo.bootstrap.Brick} this
33524 * @param {Roo.EventObject} e
33530 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33533 * @cfg {String} title
33537 * @cfg {String} html
33541 * @cfg {String} bgimage
33545 * @cfg {String} cls
33549 * @cfg {String} href
33553 * @cfg {String} video
33557 * @cfg {Boolean} square
33561 getAutoCreate : function()
33563 var cls = 'roo-brick';
33565 if(this.href.length){
33566 cls += ' roo-brick-link';
33569 if(this.bgimage.length){
33570 cls += ' roo-brick-image';
33573 if(!this.html.length && !this.bgimage.length){
33574 cls += ' roo-brick-center-title';
33577 if(!this.html.length && this.bgimage.length){
33578 cls += ' roo-brick-bottom-title';
33582 cls += ' ' + this.cls;
33586 tag: (this.href.length) ? 'a' : 'div',
33591 cls: 'roo-brick-paragraph',
33597 if(this.href.length){
33598 cfg.href = this.href;
33601 var cn = cfg.cn[0].cn;
33603 if(this.title.length){
33606 cls: 'roo-brick-title',
33611 if(this.html.length){
33614 cls: 'roo-brick-text',
33621 if(this.bgimage.length){
33624 cls: 'roo-brick-image-view',
33632 initEvents: function()
33634 if(this.title.length || this.html.length){
33635 this.el.on('mouseenter' ,this.enter, this);
33636 this.el.on('mouseleave', this.leave, this);
33639 Roo.EventManager.onWindowResize(this.resize, this);
33641 if(this.bgimage.length){
33642 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33643 this.imageEl.on('load', this.onImageLoad, this);
33650 onImageLoad : function()
33655 resize : function()
33657 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33659 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33661 if(this.bgimage.length){
33662 var image = this.el.select('.roo-brick-image-view', true).first();
33664 image.setWidth(paragraph.getWidth());
33667 image.setHeight(paragraph.getWidth());
33670 this.el.setHeight(image.getHeight());
33671 paragraph.setHeight(image.getHeight());
33677 enter: function(e, el)
33679 e.preventDefault();
33681 if(this.bgimage.length){
33682 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33683 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33687 leave: function(e, el)
33689 e.preventDefault();
33691 if(this.bgimage.length){
33692 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33693 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33708 * @class Roo.bootstrap.NumberField
33709 * @extends Roo.bootstrap.Input
33710 * Bootstrap NumberField class
33716 * Create a new NumberField
33717 * @param {Object} config The config object
33720 Roo.bootstrap.NumberField = function(config){
33721 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33724 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33727 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33729 allowDecimals : true,
33731 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33733 decimalSeparator : ".",
33735 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33737 decimalPrecision : 2,
33739 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33741 allowNegative : true,
33744 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33748 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33750 minValue : Number.NEGATIVE_INFINITY,
33752 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33754 maxValue : Number.MAX_VALUE,
33756 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33758 minText : "The minimum value for this field is {0}",
33760 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33762 maxText : "The maximum value for this field is {0}",
33764 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33765 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33767 nanText : "{0} is not a valid number",
33769 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33771 thousandsDelimiter : false,
33773 * @cfg {String} valueAlign alignment of value
33775 valueAlign : "left",
33777 getAutoCreate : function()
33779 var hiddenInput = {
33783 cls: 'hidden-number-input'
33787 hiddenInput.name = this.name;
33792 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33794 this.name = hiddenInput.name;
33796 if(cfg.cn.length > 0) {
33797 cfg.cn.push(hiddenInput);
33804 initEvents : function()
33806 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33808 var allowed = "0123456789";
33810 if(this.allowDecimals){
33811 allowed += this.decimalSeparator;
33814 if(this.allowNegative){
33818 if(this.thousandsDelimiter) {
33822 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33824 var keyPress = function(e){
33826 var k = e.getKey();
33828 var c = e.getCharCode();
33831 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33832 allowed.indexOf(String.fromCharCode(c)) === -1
33838 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33842 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33847 this.el.on("keypress", keyPress, this);
33850 validateValue : function(value)
33853 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33857 var num = this.parseValue(value);
33860 this.markInvalid(String.format(this.nanText, value));
33864 if(num < this.minValue){
33865 this.markInvalid(String.format(this.minText, this.minValue));
33869 if(num > this.maxValue){
33870 this.markInvalid(String.format(this.maxText, this.maxValue));
33877 getValue : function()
33879 var v = this.hiddenEl().getValue();
33881 return this.fixPrecision(this.parseValue(v));
33884 parseValue : function(value)
33886 if(this.thousandsDelimiter) {
33888 r = new RegExp(",", "g");
33889 value = value.replace(r, "");
33892 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33893 return isNaN(value) ? '' : value;
33896 fixPrecision : function(value)
33898 if(this.thousandsDelimiter) {
33900 r = new RegExp(",", "g");
33901 value = value.replace(r, "");
33904 var nan = isNaN(value);
33906 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33907 return nan ? '' : value;
33909 return parseFloat(value).toFixed(this.decimalPrecision);
33912 setValue : function(v)
33914 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33920 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33922 this.inputEl().dom.value = (v == '') ? '' :
33923 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33925 if(!this.allowZero && v === '0') {
33926 this.hiddenEl().dom.value = '';
33927 this.inputEl().dom.value = '';
33934 decimalPrecisionFcn : function(v)
33936 return Math.floor(v);
33939 beforeBlur : function()
33941 var v = this.parseValue(this.getRawValue());
33943 if(v || v === 0 || v === ''){
33948 hiddenEl : function()
33950 return this.el.select('input.hidden-number-input',true).first();
33962 * @class Roo.bootstrap.DocumentSlider
33963 * @extends Roo.bootstrap.Component
33964 * Bootstrap DocumentSlider class
33967 * Create a new DocumentViewer
33968 * @param {Object} config The config object
33971 Roo.bootstrap.DocumentSlider = function(config){
33972 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33979 * Fire after initEvent
33980 * @param {Roo.bootstrap.DocumentSlider} this
33985 * Fire after update
33986 * @param {Roo.bootstrap.DocumentSlider} this
33992 * @param {Roo.bootstrap.DocumentSlider} this
33998 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
34004 getAutoCreate : function()
34008 cls : 'roo-document-slider',
34012 cls : 'roo-document-slider-header',
34016 cls : 'roo-document-slider-header-title'
34022 cls : 'roo-document-slider-body',
34026 cls : 'roo-document-slider-prev',
34030 cls : 'fa fa-chevron-left'
34036 cls : 'roo-document-slider-thumb',
34040 cls : 'roo-document-slider-image'
34046 cls : 'roo-document-slider-next',
34050 cls : 'fa fa-chevron-right'
34062 initEvents : function()
34064 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34065 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34067 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34068 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34070 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34071 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34073 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34074 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34076 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34077 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34079 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34080 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34082 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34083 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34085 this.thumbEl.on('click', this.onClick, this);
34087 this.prevIndicator.on('click', this.prev, this);
34089 this.nextIndicator.on('click', this.next, this);
34093 initial : function()
34095 if(this.files.length){
34096 this.indicator = 1;
34100 this.fireEvent('initial', this);
34103 update : function()
34105 this.imageEl.attr('src', this.files[this.indicator - 1]);
34107 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34109 this.prevIndicator.show();
34111 if(this.indicator == 1){
34112 this.prevIndicator.hide();
34115 this.nextIndicator.show();
34117 if(this.indicator == this.files.length){
34118 this.nextIndicator.hide();
34121 this.thumbEl.scrollTo('top');
34123 this.fireEvent('update', this);
34126 onClick : function(e)
34128 e.preventDefault();
34130 this.fireEvent('click', this);
34135 e.preventDefault();
34137 this.indicator = Math.max(1, this.indicator - 1);
34144 e.preventDefault();
34146 this.indicator = Math.min(this.files.length, this.indicator + 1);
34160 * @class Roo.bootstrap.RadioSet
34161 * @extends Roo.bootstrap.Input
34162 * Bootstrap RadioSet class
34163 * @cfg {String} indicatorpos (left|right) default left
34164 * @cfg {Boolean} inline (true|false) inline the element (default true)
34165 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34167 * Create a new RadioSet
34168 * @param {Object} config The config object
34171 Roo.bootstrap.RadioSet = function(config){
34173 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34177 Roo.bootstrap.RadioSet.register(this);
34182 * Fires when the element is checked or unchecked.
34183 * @param {Roo.bootstrap.RadioSet} this This radio
34184 * @param {Roo.bootstrap.Radio} item The checked item
34189 * Fires when the element is click.
34190 * @param {Roo.bootstrap.RadioSet} this This radio set
34191 * @param {Roo.bootstrap.Radio} item The checked item
34192 * @param {Roo.EventObject} e The event object
34199 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34207 indicatorpos : 'left',
34209 getAutoCreate : function()
34213 cls : 'roo-radio-set-label',
34217 html : this.fieldLabel
34221 if (Roo.bootstrap.version == 3) {
34224 if(this.indicatorpos == 'left'){
34227 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34228 tooltip : 'This field is required'
34233 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34234 tooltip : 'This field is required'
34240 cls : 'roo-radio-set-items'
34243 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34245 if (align === 'left' && this.fieldLabel.length) {
34248 cls : "roo-radio-set-right",
34254 if(this.labelWidth > 12){
34255 label.style = "width: " + this.labelWidth + 'px';
34258 if(this.labelWidth < 13 && this.labelmd == 0){
34259 this.labelmd = this.labelWidth;
34262 if(this.labellg > 0){
34263 label.cls += ' col-lg-' + this.labellg;
34264 items.cls += ' col-lg-' + (12 - this.labellg);
34267 if(this.labelmd > 0){
34268 label.cls += ' col-md-' + this.labelmd;
34269 items.cls += ' col-md-' + (12 - this.labelmd);
34272 if(this.labelsm > 0){
34273 label.cls += ' col-sm-' + this.labelsm;
34274 items.cls += ' col-sm-' + (12 - this.labelsm);
34277 if(this.labelxs > 0){
34278 label.cls += ' col-xs-' + this.labelxs;
34279 items.cls += ' col-xs-' + (12 - this.labelxs);
34285 cls : 'roo-radio-set',
34289 cls : 'roo-radio-set-input',
34292 value : this.value ? this.value : ''
34299 if(this.weight.length){
34300 cfg.cls += ' roo-radio-' + this.weight;
34304 cfg.cls += ' roo-radio-set-inline';
34308 ['xs','sm','md','lg'].map(function(size){
34309 if (settings[size]) {
34310 cfg.cls += ' col-' + size + '-' + settings[size];
34318 initEvents : function()
34320 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34321 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34323 if(!this.fieldLabel.length){
34324 this.labelEl.hide();
34327 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34328 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34330 this.indicator = this.indicatorEl();
34332 if(this.indicator){
34333 this.indicator.addClass('invisible');
34336 this.originalValue = this.getValue();
34340 inputEl: function ()
34342 return this.el.select('.roo-radio-set-input', true).first();
34345 getChildContainer : function()
34347 return this.itemsEl;
34350 register : function(item)
34352 this.radioes.push(item);
34356 validate : function()
34358 if(this.getVisibilityEl().hasClass('hidden')){
34364 Roo.each(this.radioes, function(i){
34373 if(this.allowBlank) {
34377 if(this.disabled || valid){
34382 this.markInvalid();
34387 markValid : function()
34389 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34390 this.indicatorEl().removeClass('visible');
34391 this.indicatorEl().addClass('invisible');
34395 if (Roo.bootstrap.version == 3) {
34396 this.el.removeClass([this.invalidClass, this.validClass]);
34397 this.el.addClass(this.validClass);
34399 this.el.removeClass(['is-invalid','is-valid']);
34400 this.el.addClass(['is-valid']);
34402 this.fireEvent('valid', this);
34405 markInvalid : function(msg)
34407 if(this.allowBlank || this.disabled){
34411 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34412 this.indicatorEl().removeClass('invisible');
34413 this.indicatorEl().addClass('visible');
34415 if (Roo.bootstrap.version == 3) {
34416 this.el.removeClass([this.invalidClass, this.validClass]);
34417 this.el.addClass(this.invalidClass);
34419 this.el.removeClass(['is-invalid','is-valid']);
34420 this.el.addClass(['is-invalid']);
34423 this.fireEvent('invalid', this, msg);
34427 setValue : function(v, suppressEvent)
34429 if(this.value === v){
34436 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34439 Roo.each(this.radioes, function(i){
34441 i.el.removeClass('checked');
34444 Roo.each(this.radioes, function(i){
34446 if(i.value === v || i.value.toString() === v.toString()){
34448 i.el.addClass('checked');
34450 if(suppressEvent !== true){
34451 this.fireEvent('check', this, i);
34462 clearInvalid : function(){
34464 if(!this.el || this.preventMark){
34468 this.el.removeClass([this.invalidClass]);
34470 this.fireEvent('valid', this);
34475 Roo.apply(Roo.bootstrap.RadioSet, {
34479 register : function(set)
34481 this.groups[set.name] = set;
34484 get: function(name)
34486 if (typeof(this.groups[name]) == 'undefined') {
34490 return this.groups[name] ;
34496 * Ext JS Library 1.1.1
34497 * Copyright(c) 2006-2007, Ext JS, LLC.
34499 * Originally Released Under LGPL - original licence link has changed is not relivant.
34502 * <script type="text/javascript">
34507 * @class Roo.bootstrap.SplitBar
34508 * @extends Roo.util.Observable
34509 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34513 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34514 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34515 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34516 split.minSize = 100;
34517 split.maxSize = 600;
34518 split.animate = true;
34519 split.on('moved', splitterMoved);
34522 * Create a new SplitBar
34523 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34524 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34525 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34526 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34527 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34528 position of the SplitBar).
34530 Roo.bootstrap.SplitBar = function(cfg){
34535 // dragElement : elm
34536 // resizingElement: el,
34538 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34539 // placement : Roo.bootstrap.SplitBar.LEFT ,
34540 // existingProxy ???
34543 this.el = Roo.get(cfg.dragElement, true);
34544 this.el.dom.unselectable = "on";
34546 this.resizingEl = Roo.get(cfg.resizingElement, true);
34550 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34551 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34554 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34557 * The minimum size of the resizing element. (Defaults to 0)
34563 * The maximum size of the resizing element. (Defaults to 2000)
34566 this.maxSize = 2000;
34569 * Whether to animate the transition to the new size
34572 this.animate = false;
34575 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34578 this.useShim = false;
34583 if(!cfg.existingProxy){
34585 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34587 this.proxy = Roo.get(cfg.existingProxy).dom;
34590 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34593 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34596 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34599 this.dragSpecs = {};
34602 * @private The adapter to use to positon and resize elements
34604 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34605 this.adapter.init(this);
34607 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34609 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34610 this.el.addClass("roo-splitbar-h");
34613 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34614 this.el.addClass("roo-splitbar-v");
34620 * Fires when the splitter is moved (alias for {@link #event-moved})
34621 * @param {Roo.bootstrap.SplitBar} this
34622 * @param {Number} newSize the new width or height
34627 * Fires when the splitter is moved
34628 * @param {Roo.bootstrap.SplitBar} this
34629 * @param {Number} newSize the new width or height
34633 * @event beforeresize
34634 * Fires before the splitter is dragged
34635 * @param {Roo.bootstrap.SplitBar} this
34637 "beforeresize" : true,
34639 "beforeapply" : true
34642 Roo.util.Observable.call(this);
34645 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34646 onStartProxyDrag : function(x, y){
34647 this.fireEvent("beforeresize", this);
34649 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34651 o.enableDisplayMode("block");
34652 // all splitbars share the same overlay
34653 Roo.bootstrap.SplitBar.prototype.overlay = o;
34655 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34656 this.overlay.show();
34657 Roo.get(this.proxy).setDisplayed("block");
34658 var size = this.adapter.getElementSize(this);
34659 this.activeMinSize = this.getMinimumSize();;
34660 this.activeMaxSize = this.getMaximumSize();;
34661 var c1 = size - this.activeMinSize;
34662 var c2 = Math.max(this.activeMaxSize - size, 0);
34663 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34664 this.dd.resetConstraints();
34665 this.dd.setXConstraint(
34666 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34667 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34669 this.dd.setYConstraint(0, 0);
34671 this.dd.resetConstraints();
34672 this.dd.setXConstraint(0, 0);
34673 this.dd.setYConstraint(
34674 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34675 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34678 this.dragSpecs.startSize = size;
34679 this.dragSpecs.startPoint = [x, y];
34680 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34684 * @private Called after the drag operation by the DDProxy
34686 onEndProxyDrag : function(e){
34687 Roo.get(this.proxy).setDisplayed(false);
34688 var endPoint = Roo.lib.Event.getXY(e);
34690 this.overlay.hide();
34693 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34694 newSize = this.dragSpecs.startSize +
34695 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34696 endPoint[0] - this.dragSpecs.startPoint[0] :
34697 this.dragSpecs.startPoint[0] - endPoint[0]
34700 newSize = this.dragSpecs.startSize +
34701 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34702 endPoint[1] - this.dragSpecs.startPoint[1] :
34703 this.dragSpecs.startPoint[1] - endPoint[1]
34706 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34707 if(newSize != this.dragSpecs.startSize){
34708 if(this.fireEvent('beforeapply', this, newSize) !== false){
34709 this.adapter.setElementSize(this, newSize);
34710 this.fireEvent("moved", this, newSize);
34711 this.fireEvent("resize", this, newSize);
34717 * Get the adapter this SplitBar uses
34718 * @return The adapter object
34720 getAdapter : function(){
34721 return this.adapter;
34725 * Set the adapter this SplitBar uses
34726 * @param {Object} adapter A SplitBar adapter object
34728 setAdapter : function(adapter){
34729 this.adapter = adapter;
34730 this.adapter.init(this);
34734 * Gets the minimum size for the resizing element
34735 * @return {Number} The minimum size
34737 getMinimumSize : function(){
34738 return this.minSize;
34742 * Sets the minimum size for the resizing element
34743 * @param {Number} minSize The minimum size
34745 setMinimumSize : function(minSize){
34746 this.minSize = minSize;
34750 * Gets the maximum size for the resizing element
34751 * @return {Number} The maximum size
34753 getMaximumSize : function(){
34754 return this.maxSize;
34758 * Sets the maximum size for the resizing element
34759 * @param {Number} maxSize The maximum size
34761 setMaximumSize : function(maxSize){
34762 this.maxSize = maxSize;
34766 * Sets the initialize size for the resizing element
34767 * @param {Number} size The initial size
34769 setCurrentSize : function(size){
34770 var oldAnimate = this.animate;
34771 this.animate = false;
34772 this.adapter.setElementSize(this, size);
34773 this.animate = oldAnimate;
34777 * Destroy this splitbar.
34778 * @param {Boolean} removeEl True to remove the element
34780 destroy : function(removeEl){
34782 this.shim.remove();
34785 this.proxy.parentNode.removeChild(this.proxy);
34793 * @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.
34795 Roo.bootstrap.SplitBar.createProxy = function(dir){
34796 var proxy = new Roo.Element(document.createElement("div"));
34797 proxy.unselectable();
34798 var cls = 'roo-splitbar-proxy';
34799 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34800 document.body.appendChild(proxy.dom);
34805 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34806 * Default Adapter. It assumes the splitter and resizing element are not positioned
34807 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34809 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34812 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34813 // do nothing for now
34814 init : function(s){
34818 * Called before drag operations to get the current size of the resizing element.
34819 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34821 getElementSize : function(s){
34822 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34823 return s.resizingEl.getWidth();
34825 return s.resizingEl.getHeight();
34830 * Called after drag operations to set the size of the resizing element.
34831 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34832 * @param {Number} newSize The new size to set
34833 * @param {Function} onComplete A function to be invoked when resizing is complete
34835 setElementSize : function(s, newSize, onComplete){
34836 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34838 s.resizingEl.setWidth(newSize);
34840 onComplete(s, newSize);
34843 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34848 s.resizingEl.setHeight(newSize);
34850 onComplete(s, newSize);
34853 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34860 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34861 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34862 * Adapter that moves the splitter element to align with the resized sizing element.
34863 * Used with an absolute positioned SplitBar.
34864 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34865 * document.body, make sure you assign an id to the body element.
34867 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34868 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34869 this.container = Roo.get(container);
34872 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34873 init : function(s){
34874 this.basic.init(s);
34877 getElementSize : function(s){
34878 return this.basic.getElementSize(s);
34881 setElementSize : function(s, newSize, onComplete){
34882 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34885 moveSplitter : function(s){
34886 var yes = Roo.bootstrap.SplitBar;
34887 switch(s.placement){
34889 s.el.setX(s.resizingEl.getRight());
34892 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34895 s.el.setY(s.resizingEl.getBottom());
34898 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34905 * Orientation constant - Create a vertical SplitBar
34909 Roo.bootstrap.SplitBar.VERTICAL = 1;
34912 * Orientation constant - Create a horizontal SplitBar
34916 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34919 * Placement constant - The resizing element is to the left of the splitter element
34923 Roo.bootstrap.SplitBar.LEFT = 1;
34926 * Placement constant - The resizing element is to the right of the splitter element
34930 Roo.bootstrap.SplitBar.RIGHT = 2;
34933 * Placement constant - The resizing element is positioned above the splitter element
34937 Roo.bootstrap.SplitBar.TOP = 3;
34940 * Placement constant - The resizing element is positioned under splitter element
34944 Roo.bootstrap.SplitBar.BOTTOM = 4;
34945 Roo.namespace("Roo.bootstrap.layout");/*
34947 * Ext JS Library 1.1.1
34948 * Copyright(c) 2006-2007, Ext JS, LLC.
34950 * Originally Released Under LGPL - original licence link has changed is not relivant.
34953 * <script type="text/javascript">
34957 * @class Roo.bootstrap.layout.Manager
34958 * @extends Roo.bootstrap.Component
34959 * Base class for layout managers.
34961 Roo.bootstrap.layout.Manager = function(config)
34963 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34969 /** false to disable window resize monitoring @type Boolean */
34970 this.monitorWindowResize = true;
34975 * Fires when a layout is performed.
34976 * @param {Roo.LayoutManager} this
34980 * @event regionresized
34981 * Fires when the user resizes a region.
34982 * @param {Roo.LayoutRegion} region The resized region
34983 * @param {Number} newSize The new size (width for east/west, height for north/south)
34985 "regionresized" : true,
34987 * @event regioncollapsed
34988 * Fires when a region is collapsed.
34989 * @param {Roo.LayoutRegion} region The collapsed region
34991 "regioncollapsed" : true,
34993 * @event regionexpanded
34994 * Fires when a region is expanded.
34995 * @param {Roo.LayoutRegion} region The expanded region
34997 "regionexpanded" : true
34999 this.updating = false;
35002 this.el = Roo.get(config.el);
35008 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
35013 monitorWindowResize : true,
35019 onRender : function(ct, position)
35022 this.el = Roo.get(ct);
35025 //this.fireEvent('render',this);
35029 initEvents: function()
35033 // ie scrollbar fix
35034 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
35035 document.body.scroll = "no";
35036 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
35037 this.el.position('relative');
35039 this.id = this.el.id;
35040 this.el.addClass("roo-layout-container");
35041 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35042 if(this.el.dom != document.body ) {
35043 this.el.on('resize', this.layout,this);
35044 this.el.on('show', this.layout,this);
35050 * Returns true if this layout is currently being updated
35051 * @return {Boolean}
35053 isUpdating : function(){
35054 return this.updating;
35058 * Suspend the LayoutManager from doing auto-layouts while
35059 * making multiple add or remove calls
35061 beginUpdate : function(){
35062 this.updating = true;
35066 * Restore auto-layouts and optionally disable the manager from performing a layout
35067 * @param {Boolean} noLayout true to disable a layout update
35069 endUpdate : function(noLayout){
35070 this.updating = false;
35076 layout: function(){
35080 onRegionResized : function(region, newSize){
35081 this.fireEvent("regionresized", region, newSize);
35085 onRegionCollapsed : function(region){
35086 this.fireEvent("regioncollapsed", region);
35089 onRegionExpanded : function(region){
35090 this.fireEvent("regionexpanded", region);
35094 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35095 * performs box-model adjustments.
35096 * @return {Object} The size as an object {width: (the width), height: (the height)}
35098 getViewSize : function()
35101 if(this.el.dom != document.body){
35102 size = this.el.getSize();
35104 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35106 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35107 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35112 * Returns the Element this layout is bound to.
35113 * @return {Roo.Element}
35115 getEl : function(){
35120 * Returns the specified region.
35121 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35122 * @return {Roo.LayoutRegion}
35124 getRegion : function(target){
35125 return this.regions[target.toLowerCase()];
35128 onWindowResize : function(){
35129 if(this.monitorWindowResize){
35136 * Ext JS Library 1.1.1
35137 * Copyright(c) 2006-2007, Ext JS, LLC.
35139 * Originally Released Under LGPL - original licence link has changed is not relivant.
35142 * <script type="text/javascript">
35145 * @class Roo.bootstrap.layout.Border
35146 * @extends Roo.bootstrap.layout.Manager
35147 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35148 * please see: examples/bootstrap/nested.html<br><br>
35150 <b>The container the layout is rendered into can be either the body element or any other element.
35151 If it is not the body element, the container needs to either be an absolute positioned element,
35152 or you will need to add "position:relative" to the css of the container. You will also need to specify
35153 the container size if it is not the body element.</b>
35156 * Create a new Border
35157 * @param {Object} config Configuration options
35159 Roo.bootstrap.layout.Border = function(config){
35160 config = config || {};
35161 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35165 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35166 if(config[region]){
35167 config[region].region = region;
35168 this.addRegion(config[region]);
35174 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35176 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35178 parent : false, // this might point to a 'nest' or a ???
35181 * Creates and adds a new region if it doesn't already exist.
35182 * @param {String} target The target region key (north, south, east, west or center).
35183 * @param {Object} config The regions config object
35184 * @return {BorderLayoutRegion} The new region
35186 addRegion : function(config)
35188 if(!this.regions[config.region]){
35189 var r = this.factory(config);
35190 this.bindRegion(r);
35192 return this.regions[config.region];
35196 bindRegion : function(r){
35197 this.regions[r.config.region] = r;
35199 r.on("visibilitychange", this.layout, this);
35200 r.on("paneladded", this.layout, this);
35201 r.on("panelremoved", this.layout, this);
35202 r.on("invalidated", this.layout, this);
35203 r.on("resized", this.onRegionResized, this);
35204 r.on("collapsed", this.onRegionCollapsed, this);
35205 r.on("expanded", this.onRegionExpanded, this);
35209 * Performs a layout update.
35211 layout : function()
35213 if(this.updating) {
35217 // render all the rebions if they have not been done alreayd?
35218 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35219 if(this.regions[region] && !this.regions[region].bodyEl){
35220 this.regions[region].onRender(this.el)
35224 var size = this.getViewSize();
35225 var w = size.width;
35226 var h = size.height;
35231 //var x = 0, y = 0;
35233 var rs = this.regions;
35234 var north = rs["north"];
35235 var south = rs["south"];
35236 var west = rs["west"];
35237 var east = rs["east"];
35238 var center = rs["center"];
35239 //if(this.hideOnLayout){ // not supported anymore
35240 //c.el.setStyle("display", "none");
35242 if(north && north.isVisible()){
35243 var b = north.getBox();
35244 var m = north.getMargins();
35245 b.width = w - (m.left+m.right);
35248 centerY = b.height + b.y + m.bottom;
35249 centerH -= centerY;
35250 north.updateBox(this.safeBox(b));
35252 if(south && south.isVisible()){
35253 var b = south.getBox();
35254 var m = south.getMargins();
35255 b.width = w - (m.left+m.right);
35257 var totalHeight = (b.height + m.top + m.bottom);
35258 b.y = h - totalHeight + m.top;
35259 centerH -= totalHeight;
35260 south.updateBox(this.safeBox(b));
35262 if(west && west.isVisible()){
35263 var b = west.getBox();
35264 var m = west.getMargins();
35265 b.height = centerH - (m.top+m.bottom);
35267 b.y = centerY + m.top;
35268 var totalWidth = (b.width + m.left + m.right);
35269 centerX += totalWidth;
35270 centerW -= totalWidth;
35271 west.updateBox(this.safeBox(b));
35273 if(east && east.isVisible()){
35274 var b = east.getBox();
35275 var m = east.getMargins();
35276 b.height = centerH - (m.top+m.bottom);
35277 var totalWidth = (b.width + m.left + m.right);
35278 b.x = w - totalWidth + m.left;
35279 b.y = centerY + m.top;
35280 centerW -= totalWidth;
35281 east.updateBox(this.safeBox(b));
35284 var m = center.getMargins();
35286 x: centerX + m.left,
35287 y: centerY + m.top,
35288 width: centerW - (m.left+m.right),
35289 height: centerH - (m.top+m.bottom)
35291 //if(this.hideOnLayout){
35292 //center.el.setStyle("display", "block");
35294 center.updateBox(this.safeBox(centerBox));
35297 this.fireEvent("layout", this);
35301 safeBox : function(box){
35302 box.width = Math.max(0, box.width);
35303 box.height = Math.max(0, box.height);
35308 * Adds a ContentPanel (or subclass) to this layout.
35309 * @param {String} target The target region key (north, south, east, west or center).
35310 * @param {Roo.ContentPanel} panel The panel to add
35311 * @return {Roo.ContentPanel} The added panel
35313 add : function(target, panel){
35315 target = target.toLowerCase();
35316 return this.regions[target].add(panel);
35320 * Remove a ContentPanel (or subclass) to this layout.
35321 * @param {String} target The target region key (north, south, east, west or center).
35322 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35323 * @return {Roo.ContentPanel} The removed panel
35325 remove : function(target, panel){
35326 target = target.toLowerCase();
35327 return this.regions[target].remove(panel);
35331 * Searches all regions for a panel with the specified id
35332 * @param {String} panelId
35333 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35335 findPanel : function(panelId){
35336 var rs = this.regions;
35337 for(var target in rs){
35338 if(typeof rs[target] != "function"){
35339 var p = rs[target].getPanel(panelId);
35349 * Searches all regions for a panel with the specified id and activates (shows) it.
35350 * @param {String/ContentPanel} panelId The panels id or the panel itself
35351 * @return {Roo.ContentPanel} The shown panel or null
35353 showPanel : function(panelId) {
35354 var rs = this.regions;
35355 for(var target in rs){
35356 var r = rs[target];
35357 if(typeof r != "function"){
35358 if(r.hasPanel(panelId)){
35359 return r.showPanel(panelId);
35367 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35368 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35371 restoreState : function(provider){
35373 provider = Roo.state.Manager;
35375 var sm = new Roo.LayoutStateManager();
35376 sm.init(this, provider);
35382 * Adds a xtype elements to the layout.
35386 xtype : 'ContentPanel',
35393 xtype : 'NestedLayoutPanel',
35399 items : [ ... list of content panels or nested layout panels.. ]
35403 * @param {Object} cfg Xtype definition of item to add.
35405 addxtype : function(cfg)
35407 // basically accepts a pannel...
35408 // can accept a layout region..!?!?
35409 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35412 // theory? children can only be panels??
35414 //if (!cfg.xtype.match(/Panel$/)) {
35419 if (typeof(cfg.region) == 'undefined') {
35420 Roo.log("Failed to add Panel, region was not set");
35424 var region = cfg.region;
35430 xitems = cfg.items;
35435 if ( region == 'center') {
35436 Roo.log("Center: " + cfg.title);
35442 case 'Content': // ContentPanel (el, cfg)
35443 case 'Scroll': // ContentPanel (el, cfg)
35445 cfg.autoCreate = cfg.autoCreate || true;
35446 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35448 // var el = this.el.createChild();
35449 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35452 this.add(region, ret);
35456 case 'TreePanel': // our new panel!
35457 cfg.el = this.el.createChild();
35458 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35459 this.add(region, ret);
35464 // create a new Layout (which is a Border Layout...
35466 var clayout = cfg.layout;
35467 clayout.el = this.el.createChild();
35468 clayout.items = clayout.items || [];
35472 // replace this exitems with the clayout ones..
35473 xitems = clayout.items;
35475 // force background off if it's in center...
35476 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35477 cfg.background = false;
35479 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35482 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35483 //console.log('adding nested layout panel ' + cfg.toSource());
35484 this.add(region, ret);
35485 nb = {}; /// find first...
35490 // needs grid and region
35492 //var el = this.getRegion(region).el.createChild();
35494 *var el = this.el.createChild();
35495 // create the grid first...
35496 cfg.grid.container = el;
35497 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35500 if (region == 'center' && this.active ) {
35501 cfg.background = false;
35504 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35506 this.add(region, ret);
35508 if (cfg.background) {
35509 // render grid on panel activation (if panel background)
35510 ret.on('activate', function(gp) {
35511 if (!gp.grid.rendered) {
35512 // gp.grid.render(el);
35516 // cfg.grid.render(el);
35522 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35523 // it was the old xcomponent building that caused this before.
35524 // espeically if border is the top element in the tree.
35534 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35536 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35537 this.add(region, ret);
35541 throw "Can not add '" + cfg.xtype + "' to Border";
35547 this.beginUpdate();
35551 Roo.each(xitems, function(i) {
35552 region = nb && i.region ? i.region : false;
35554 var add = ret.addxtype(i);
35557 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35558 if (!i.background) {
35559 abn[region] = nb[region] ;
35566 // make the last non-background panel active..
35567 //if (nb) { Roo.log(abn); }
35570 for(var r in abn) {
35571 region = this.getRegion(r);
35573 // tried using nb[r], but it does not work..
35575 region.showPanel(abn[r]);
35586 factory : function(cfg)
35589 var validRegions = Roo.bootstrap.layout.Border.regions;
35591 var target = cfg.region;
35594 var r = Roo.bootstrap.layout;
35598 return new r.North(cfg);
35600 return new r.South(cfg);
35602 return new r.East(cfg);
35604 return new r.West(cfg);
35606 return new r.Center(cfg);
35608 throw 'Layout region "'+target+'" not supported.';
35615 * Ext JS Library 1.1.1
35616 * Copyright(c) 2006-2007, Ext JS, LLC.
35618 * Originally Released Under LGPL - original licence link has changed is not relivant.
35621 * <script type="text/javascript">
35625 * @class Roo.bootstrap.layout.Basic
35626 * @extends Roo.util.Observable
35627 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35628 * and does not have a titlebar, tabs or any other features. All it does is size and position
35629 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35630 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35631 * @cfg {string} region the region that it inhabits..
35632 * @cfg {bool} skipConfig skip config?
35636 Roo.bootstrap.layout.Basic = function(config){
35638 this.mgr = config.mgr;
35640 this.position = config.region;
35642 var skipConfig = config.skipConfig;
35646 * @scope Roo.BasicLayoutRegion
35650 * @event beforeremove
35651 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35652 * @param {Roo.LayoutRegion} this
35653 * @param {Roo.ContentPanel} panel The panel
35654 * @param {Object} e The cancel event object
35656 "beforeremove" : true,
35658 * @event invalidated
35659 * Fires when the layout for this region is changed.
35660 * @param {Roo.LayoutRegion} this
35662 "invalidated" : true,
35664 * @event visibilitychange
35665 * Fires when this region is shown or hidden
35666 * @param {Roo.LayoutRegion} this
35667 * @param {Boolean} visibility true or false
35669 "visibilitychange" : true,
35671 * @event paneladded
35672 * Fires when a panel is added.
35673 * @param {Roo.LayoutRegion} this
35674 * @param {Roo.ContentPanel} panel The panel
35676 "paneladded" : true,
35678 * @event panelremoved
35679 * Fires when a panel is removed.
35680 * @param {Roo.LayoutRegion} this
35681 * @param {Roo.ContentPanel} panel The panel
35683 "panelremoved" : true,
35685 * @event beforecollapse
35686 * Fires when this region before collapse.
35687 * @param {Roo.LayoutRegion} this
35689 "beforecollapse" : true,
35692 * Fires when this region is collapsed.
35693 * @param {Roo.LayoutRegion} this
35695 "collapsed" : true,
35698 * Fires when this region is expanded.
35699 * @param {Roo.LayoutRegion} this
35704 * Fires when this region is slid into view.
35705 * @param {Roo.LayoutRegion} this
35707 "slideshow" : true,
35710 * Fires when this region slides out of view.
35711 * @param {Roo.LayoutRegion} this
35713 "slidehide" : true,
35715 * @event panelactivated
35716 * Fires when a panel is activated.
35717 * @param {Roo.LayoutRegion} this
35718 * @param {Roo.ContentPanel} panel The activated panel
35720 "panelactivated" : true,
35723 * Fires when the user resizes this region.
35724 * @param {Roo.LayoutRegion} this
35725 * @param {Number} newSize The new size (width for east/west, height for north/south)
35729 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35730 this.panels = new Roo.util.MixedCollection();
35731 this.panels.getKey = this.getPanelId.createDelegate(this);
35733 this.activePanel = null;
35734 // ensure listeners are added...
35736 if (config.listeners || config.events) {
35737 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35738 listeners : config.listeners || {},
35739 events : config.events || {}
35743 if(skipConfig !== true){
35744 this.applyConfig(config);
35748 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35750 getPanelId : function(p){
35754 applyConfig : function(config){
35755 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35756 this.config = config;
35761 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35762 * the width, for horizontal (north, south) the height.
35763 * @param {Number} newSize The new width or height
35765 resizeTo : function(newSize){
35766 var el = this.el ? this.el :
35767 (this.activePanel ? this.activePanel.getEl() : null);
35769 switch(this.position){
35772 el.setWidth(newSize);
35773 this.fireEvent("resized", this, newSize);
35777 el.setHeight(newSize);
35778 this.fireEvent("resized", this, newSize);
35784 getBox : function(){
35785 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35788 getMargins : function(){
35789 return this.margins;
35792 updateBox : function(box){
35794 var el = this.activePanel.getEl();
35795 el.dom.style.left = box.x + "px";
35796 el.dom.style.top = box.y + "px";
35797 this.activePanel.setSize(box.width, box.height);
35801 * Returns the container element for this region.
35802 * @return {Roo.Element}
35804 getEl : function(){
35805 return this.activePanel;
35809 * Returns true if this region is currently visible.
35810 * @return {Boolean}
35812 isVisible : function(){
35813 return this.activePanel ? true : false;
35816 setActivePanel : function(panel){
35817 panel = this.getPanel(panel);
35818 if(this.activePanel && this.activePanel != panel){
35819 this.activePanel.setActiveState(false);
35820 this.activePanel.getEl().setLeftTop(-10000,-10000);
35822 this.activePanel = panel;
35823 panel.setActiveState(true);
35825 panel.setSize(this.box.width, this.box.height);
35827 this.fireEvent("panelactivated", this, panel);
35828 this.fireEvent("invalidated");
35832 * Show the specified panel.
35833 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35834 * @return {Roo.ContentPanel} The shown panel or null
35836 showPanel : function(panel){
35837 panel = this.getPanel(panel);
35839 this.setActivePanel(panel);
35845 * Get the active panel for this region.
35846 * @return {Roo.ContentPanel} The active panel or null
35848 getActivePanel : function(){
35849 return this.activePanel;
35853 * Add the passed ContentPanel(s)
35854 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35855 * @return {Roo.ContentPanel} The panel added (if only one was added)
35857 add : function(panel){
35858 if(arguments.length > 1){
35859 for(var i = 0, len = arguments.length; i < len; i++) {
35860 this.add(arguments[i]);
35864 if(this.hasPanel(panel)){
35865 this.showPanel(panel);
35868 var el = panel.getEl();
35869 if(el.dom.parentNode != this.mgr.el.dom){
35870 this.mgr.el.dom.appendChild(el.dom);
35872 if(panel.setRegion){
35873 panel.setRegion(this);
35875 this.panels.add(panel);
35876 el.setStyle("position", "absolute");
35877 if(!panel.background){
35878 this.setActivePanel(panel);
35879 if(this.config.initialSize && this.panels.getCount()==1){
35880 this.resizeTo(this.config.initialSize);
35883 this.fireEvent("paneladded", this, panel);
35888 * Returns true if the panel is in this region.
35889 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35890 * @return {Boolean}
35892 hasPanel : function(panel){
35893 if(typeof panel == "object"){ // must be panel obj
35894 panel = panel.getId();
35896 return this.getPanel(panel) ? true : false;
35900 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35901 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35902 * @param {Boolean} preservePanel Overrides the config preservePanel option
35903 * @return {Roo.ContentPanel} The panel that was removed
35905 remove : function(panel, preservePanel){
35906 panel = this.getPanel(panel);
35911 this.fireEvent("beforeremove", this, panel, e);
35912 if(e.cancel === true){
35915 var panelId = panel.getId();
35916 this.panels.removeKey(panelId);
35921 * Returns the panel specified or null if it's not in this region.
35922 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35923 * @return {Roo.ContentPanel}
35925 getPanel : function(id){
35926 if(typeof id == "object"){ // must be panel obj
35929 return this.panels.get(id);
35933 * Returns this regions position (north/south/east/west/center).
35936 getPosition: function(){
35937 return this.position;
35941 * Ext JS Library 1.1.1
35942 * Copyright(c) 2006-2007, Ext JS, LLC.
35944 * Originally Released Under LGPL - original licence link has changed is not relivant.
35947 * <script type="text/javascript">
35951 * @class Roo.bootstrap.layout.Region
35952 * @extends Roo.bootstrap.layout.Basic
35953 * This class represents a region in a layout manager.
35955 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35956 * @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})
35957 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35958 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35959 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35960 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35961 * @cfg {String} title The title for the region (overrides panel titles)
35962 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35963 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35964 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35965 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35966 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35967 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35968 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35969 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35970 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35971 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35973 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35974 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35975 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35976 * @cfg {Number} width For East/West panels
35977 * @cfg {Number} height For North/South panels
35978 * @cfg {Boolean} split To show the splitter
35979 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35981 * @cfg {string} cls Extra CSS classes to add to region
35983 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35984 * @cfg {string} region the region that it inhabits..
35987 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35988 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35990 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35991 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35992 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35994 Roo.bootstrap.layout.Region = function(config)
35996 this.applyConfig(config);
35998 var mgr = config.mgr;
35999 var pos = config.region;
36000 config.skipConfig = true;
36001 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
36004 this.onRender(mgr.el);
36007 this.visible = true;
36008 this.collapsed = false;
36009 this.unrendered_panels = [];
36012 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
36014 position: '', // set by wrapper (eg. north/south etc..)
36015 unrendered_panels : null, // unrendered panels.
36017 tabPosition : false,
36019 mgr: false, // points to 'Border'
36022 createBody : function(){
36023 /** This region's body element
36024 * @type Roo.Element */
36025 this.bodyEl = this.el.createChild({
36027 cls: "roo-layout-panel-body tab-content" // bootstrap added...
36031 onRender: function(ctr, pos)
36033 var dh = Roo.DomHelper;
36034 /** This region's container element
36035 * @type Roo.Element */
36036 this.el = dh.append(ctr.dom, {
36038 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
36040 /** This region's title element
36041 * @type Roo.Element */
36043 this.titleEl = dh.append(this.el.dom, {
36045 unselectable: "on",
36046 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36048 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36049 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36053 this.titleEl.enableDisplayMode();
36054 /** This region's title text element
36055 * @type HTMLElement */
36056 this.titleTextEl = this.titleEl.dom.firstChild;
36057 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36059 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36060 this.closeBtn.enableDisplayMode();
36061 this.closeBtn.on("click", this.closeClicked, this);
36062 this.closeBtn.hide();
36064 this.createBody(this.config);
36065 if(this.config.hideWhenEmpty){
36067 this.on("paneladded", this.validateVisibility, this);
36068 this.on("panelremoved", this.validateVisibility, this);
36070 if(this.autoScroll){
36071 this.bodyEl.setStyle("overflow", "auto");
36073 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36075 //if(c.titlebar !== false){
36076 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36077 this.titleEl.hide();
36079 this.titleEl.show();
36080 if(this.config.title){
36081 this.titleTextEl.innerHTML = this.config.title;
36085 if(this.config.collapsed){
36086 this.collapse(true);
36088 if(this.config.hidden){
36092 if (this.unrendered_panels && this.unrendered_panels.length) {
36093 for (var i =0;i< this.unrendered_panels.length; i++) {
36094 this.add(this.unrendered_panels[i]);
36096 this.unrendered_panels = null;
36102 applyConfig : function(c)
36105 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36106 var dh = Roo.DomHelper;
36107 if(c.titlebar !== false){
36108 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36109 this.collapseBtn.on("click", this.collapse, this);
36110 this.collapseBtn.enableDisplayMode();
36112 if(c.showPin === true || this.showPin){
36113 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36114 this.stickBtn.enableDisplayMode();
36115 this.stickBtn.on("click", this.expand, this);
36116 this.stickBtn.hide();
36121 /** This region's collapsed element
36122 * @type Roo.Element */
36125 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36126 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36129 if(c.floatable !== false){
36130 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36131 this.collapsedEl.on("click", this.collapseClick, this);
36134 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36135 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36136 id: "message", unselectable: "on", style:{"float":"left"}});
36137 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36139 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36140 this.expandBtn.on("click", this.expand, this);
36144 if(this.collapseBtn){
36145 this.collapseBtn.setVisible(c.collapsible == true);
36148 this.cmargins = c.cmargins || this.cmargins ||
36149 (this.position == "west" || this.position == "east" ?
36150 {top: 0, left: 2, right:2, bottom: 0} :
36151 {top: 2, left: 0, right:0, bottom: 2});
36153 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36156 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36158 this.autoScroll = c.autoScroll || false;
36163 this.duration = c.duration || .30;
36164 this.slideDuration = c.slideDuration || .45;
36169 * Returns true if this region is currently visible.
36170 * @return {Boolean}
36172 isVisible : function(){
36173 return this.visible;
36177 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36178 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36180 //setCollapsedTitle : function(title){
36181 // title = title || " ";
36182 // if(this.collapsedTitleTextEl){
36183 // this.collapsedTitleTextEl.innerHTML = title;
36187 getBox : function(){
36189 // if(!this.collapsed){
36190 b = this.el.getBox(false, true);
36192 // b = this.collapsedEl.getBox(false, true);
36197 getMargins : function(){
36198 return this.margins;
36199 //return this.collapsed ? this.cmargins : this.margins;
36202 highlight : function(){
36203 this.el.addClass("x-layout-panel-dragover");
36206 unhighlight : function(){
36207 this.el.removeClass("x-layout-panel-dragover");
36210 updateBox : function(box)
36212 if (!this.bodyEl) {
36213 return; // not rendered yet..
36217 if(!this.collapsed){
36218 this.el.dom.style.left = box.x + "px";
36219 this.el.dom.style.top = box.y + "px";
36220 this.updateBody(box.width, box.height);
36222 this.collapsedEl.dom.style.left = box.x + "px";
36223 this.collapsedEl.dom.style.top = box.y + "px";
36224 this.collapsedEl.setSize(box.width, box.height);
36227 this.tabs.autoSizeTabs();
36231 updateBody : function(w, h)
36234 this.el.setWidth(w);
36235 w -= this.el.getBorderWidth("rl");
36236 if(this.config.adjustments){
36237 w += this.config.adjustments[0];
36240 if(h !== null && h > 0){
36241 this.el.setHeight(h);
36242 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36243 h -= this.el.getBorderWidth("tb");
36244 if(this.config.adjustments){
36245 h += this.config.adjustments[1];
36247 this.bodyEl.setHeight(h);
36249 h = this.tabs.syncHeight(h);
36252 if(this.panelSize){
36253 w = w !== null ? w : this.panelSize.width;
36254 h = h !== null ? h : this.panelSize.height;
36256 if(this.activePanel){
36257 var el = this.activePanel.getEl();
36258 w = w !== null ? w : el.getWidth();
36259 h = h !== null ? h : el.getHeight();
36260 this.panelSize = {width: w, height: h};
36261 this.activePanel.setSize(w, h);
36263 if(Roo.isIE && this.tabs){
36264 this.tabs.el.repaint();
36269 * Returns the container element for this region.
36270 * @return {Roo.Element}
36272 getEl : function(){
36277 * Hides this region.
36280 //if(!this.collapsed){
36281 this.el.dom.style.left = "-2000px";
36284 // this.collapsedEl.dom.style.left = "-2000px";
36285 // this.collapsedEl.hide();
36287 this.visible = false;
36288 this.fireEvent("visibilitychange", this, false);
36292 * Shows this region if it was previously hidden.
36295 //if(!this.collapsed){
36298 // this.collapsedEl.show();
36300 this.visible = true;
36301 this.fireEvent("visibilitychange", this, true);
36304 closeClicked : function(){
36305 if(this.activePanel){
36306 this.remove(this.activePanel);
36310 collapseClick : function(e){
36312 e.stopPropagation();
36315 e.stopPropagation();
36321 * Collapses this region.
36322 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36325 collapse : function(skipAnim, skipCheck = false){
36326 if(this.collapsed) {
36330 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36332 this.collapsed = true;
36334 this.split.el.hide();
36336 if(this.config.animate && skipAnim !== true){
36337 this.fireEvent("invalidated", this);
36338 this.animateCollapse();
36340 this.el.setLocation(-20000,-20000);
36342 this.collapsedEl.show();
36343 this.fireEvent("collapsed", this);
36344 this.fireEvent("invalidated", this);
36350 animateCollapse : function(){
36355 * Expands this region if it was previously collapsed.
36356 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36357 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36360 expand : function(e, skipAnim){
36362 e.stopPropagation();
36364 if(!this.collapsed || this.el.hasActiveFx()) {
36368 this.afterSlideIn();
36371 this.collapsed = false;
36372 if(this.config.animate && skipAnim !== true){
36373 this.animateExpand();
36377 this.split.el.show();
36379 this.collapsedEl.setLocation(-2000,-2000);
36380 this.collapsedEl.hide();
36381 this.fireEvent("invalidated", this);
36382 this.fireEvent("expanded", this);
36386 animateExpand : function(){
36390 initTabs : function()
36392 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36394 var ts = new Roo.bootstrap.panel.Tabs({
36395 el: this.bodyEl.dom,
36397 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36398 disableTooltips: this.config.disableTabTips,
36399 toolbar : this.config.toolbar
36402 if(this.config.hideTabs){
36403 ts.stripWrap.setDisplayed(false);
36406 ts.resizeTabs = this.config.resizeTabs === true;
36407 ts.minTabWidth = this.config.minTabWidth || 40;
36408 ts.maxTabWidth = this.config.maxTabWidth || 250;
36409 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36410 ts.monitorResize = false;
36411 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36412 ts.bodyEl.addClass('roo-layout-tabs-body');
36413 this.panels.each(this.initPanelAsTab, this);
36416 initPanelAsTab : function(panel){
36417 var ti = this.tabs.addTab(
36421 this.config.closeOnTab && panel.isClosable(),
36424 if(panel.tabTip !== undefined){
36425 ti.setTooltip(panel.tabTip);
36427 ti.on("activate", function(){
36428 this.setActivePanel(panel);
36431 if(this.config.closeOnTab){
36432 ti.on("beforeclose", function(t, e){
36434 this.remove(panel);
36438 panel.tabItem = ti;
36443 updatePanelTitle : function(panel, title)
36445 if(this.activePanel == panel){
36446 this.updateTitle(title);
36449 var ti = this.tabs.getTab(panel.getEl().id);
36451 if(panel.tabTip !== undefined){
36452 ti.setTooltip(panel.tabTip);
36457 updateTitle : function(title){
36458 if(this.titleTextEl && !this.config.title){
36459 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36463 setActivePanel : function(panel)
36465 panel = this.getPanel(panel);
36466 if(this.activePanel && this.activePanel != panel){
36467 if(this.activePanel.setActiveState(false) === false){
36471 this.activePanel = panel;
36472 panel.setActiveState(true);
36473 if(this.panelSize){
36474 panel.setSize(this.panelSize.width, this.panelSize.height);
36477 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36479 this.updateTitle(panel.getTitle());
36481 this.fireEvent("invalidated", this);
36483 this.fireEvent("panelactivated", this, panel);
36487 * Shows the specified panel.
36488 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36489 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36491 showPanel : function(panel)
36493 panel = this.getPanel(panel);
36496 var tab = this.tabs.getTab(panel.getEl().id);
36497 if(tab.isHidden()){
36498 this.tabs.unhideTab(tab.id);
36502 this.setActivePanel(panel);
36509 * Get the active panel for this region.
36510 * @return {Roo.ContentPanel} The active panel or null
36512 getActivePanel : function(){
36513 return this.activePanel;
36516 validateVisibility : function(){
36517 if(this.panels.getCount() < 1){
36518 this.updateTitle(" ");
36519 this.closeBtn.hide();
36522 if(!this.isVisible()){
36529 * Adds the passed ContentPanel(s) to this region.
36530 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36531 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36533 add : function(panel)
36535 if(arguments.length > 1){
36536 for(var i = 0, len = arguments.length; i < len; i++) {
36537 this.add(arguments[i]);
36542 // if we have not been rendered yet, then we can not really do much of this..
36543 if (!this.bodyEl) {
36544 this.unrendered_panels.push(panel);
36551 if(this.hasPanel(panel)){
36552 this.showPanel(panel);
36555 panel.setRegion(this);
36556 this.panels.add(panel);
36557 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36558 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36559 // and hide them... ???
36560 this.bodyEl.dom.appendChild(panel.getEl().dom);
36561 if(panel.background !== true){
36562 this.setActivePanel(panel);
36564 this.fireEvent("paneladded", this, panel);
36571 this.initPanelAsTab(panel);
36575 if(panel.background !== true){
36576 this.tabs.activate(panel.getEl().id);
36578 this.fireEvent("paneladded", this, panel);
36583 * Hides the tab for the specified panel.
36584 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36586 hidePanel : function(panel){
36587 if(this.tabs && (panel = this.getPanel(panel))){
36588 this.tabs.hideTab(panel.getEl().id);
36593 * Unhides the tab for a previously hidden panel.
36594 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36596 unhidePanel : function(panel){
36597 if(this.tabs && (panel = this.getPanel(panel))){
36598 this.tabs.unhideTab(panel.getEl().id);
36602 clearPanels : function(){
36603 while(this.panels.getCount() > 0){
36604 this.remove(this.panels.first());
36609 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36610 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36611 * @param {Boolean} preservePanel Overrides the config preservePanel option
36612 * @return {Roo.ContentPanel} The panel that was removed
36614 remove : function(panel, preservePanel)
36616 panel = this.getPanel(panel);
36621 this.fireEvent("beforeremove", this, panel, e);
36622 if(e.cancel === true){
36625 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36626 var panelId = panel.getId();
36627 this.panels.removeKey(panelId);
36629 document.body.appendChild(panel.getEl().dom);
36632 this.tabs.removeTab(panel.getEl().id);
36633 }else if (!preservePanel){
36634 this.bodyEl.dom.removeChild(panel.getEl().dom);
36636 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36637 var p = this.panels.first();
36638 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36639 tempEl.appendChild(p.getEl().dom);
36640 this.bodyEl.update("");
36641 this.bodyEl.dom.appendChild(p.getEl().dom);
36643 this.updateTitle(p.getTitle());
36645 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36646 this.setActivePanel(p);
36648 panel.setRegion(null);
36649 if(this.activePanel == panel){
36650 this.activePanel = null;
36652 if(this.config.autoDestroy !== false && preservePanel !== true){
36653 try{panel.destroy();}catch(e){}
36655 this.fireEvent("panelremoved", this, panel);
36660 * Returns the TabPanel component used by this region
36661 * @return {Roo.TabPanel}
36663 getTabs : function(){
36667 createTool : function(parentEl, className){
36668 var btn = Roo.DomHelper.append(parentEl, {
36670 cls: "x-layout-tools-button",
36673 cls: "roo-layout-tools-button-inner " + className,
36677 btn.addClassOnOver("roo-layout-tools-button-over");
36682 * Ext JS Library 1.1.1
36683 * Copyright(c) 2006-2007, Ext JS, LLC.
36685 * Originally Released Under LGPL - original licence link has changed is not relivant.
36688 * <script type="text/javascript">
36694 * @class Roo.SplitLayoutRegion
36695 * @extends Roo.LayoutRegion
36696 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36698 Roo.bootstrap.layout.Split = function(config){
36699 this.cursor = config.cursor;
36700 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36703 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36705 splitTip : "Drag to resize.",
36706 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36707 useSplitTips : false,
36709 applyConfig : function(config){
36710 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36713 onRender : function(ctr,pos) {
36715 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36716 if(!this.config.split){
36721 var splitEl = Roo.DomHelper.append(ctr.dom, {
36723 id: this.el.id + "-split",
36724 cls: "roo-layout-split roo-layout-split-"+this.position,
36727 /** The SplitBar for this region
36728 * @type Roo.SplitBar */
36729 // does not exist yet...
36730 Roo.log([this.position, this.orientation]);
36732 this.split = new Roo.bootstrap.SplitBar({
36733 dragElement : splitEl,
36734 resizingElement: this.el,
36735 orientation : this.orientation
36738 this.split.on("moved", this.onSplitMove, this);
36739 this.split.useShim = this.config.useShim === true;
36740 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36741 if(this.useSplitTips){
36742 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36744 //if(config.collapsible){
36745 // this.split.el.on("dblclick", this.collapse, this);
36748 if(typeof this.config.minSize != "undefined"){
36749 this.split.minSize = this.config.minSize;
36751 if(typeof this.config.maxSize != "undefined"){
36752 this.split.maxSize = this.config.maxSize;
36754 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36755 this.hideSplitter();
36760 getHMaxSize : function(){
36761 var cmax = this.config.maxSize || 10000;
36762 var center = this.mgr.getRegion("center");
36763 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36766 getVMaxSize : function(){
36767 var cmax = this.config.maxSize || 10000;
36768 var center = this.mgr.getRegion("center");
36769 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36772 onSplitMove : function(split, newSize){
36773 this.fireEvent("resized", this, newSize);
36777 * Returns the {@link Roo.SplitBar} for this region.
36778 * @return {Roo.SplitBar}
36780 getSplitBar : function(){
36785 this.hideSplitter();
36786 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36789 hideSplitter : function(){
36791 this.split.el.setLocation(-2000,-2000);
36792 this.split.el.hide();
36798 this.split.el.show();
36800 Roo.bootstrap.layout.Split.superclass.show.call(this);
36803 beforeSlide: function(){
36804 if(Roo.isGecko){// firefox overflow auto bug workaround
36805 this.bodyEl.clip();
36807 this.tabs.bodyEl.clip();
36809 if(this.activePanel){
36810 this.activePanel.getEl().clip();
36812 if(this.activePanel.beforeSlide){
36813 this.activePanel.beforeSlide();
36819 afterSlide : function(){
36820 if(Roo.isGecko){// firefox overflow auto bug workaround
36821 this.bodyEl.unclip();
36823 this.tabs.bodyEl.unclip();
36825 if(this.activePanel){
36826 this.activePanel.getEl().unclip();
36827 if(this.activePanel.afterSlide){
36828 this.activePanel.afterSlide();
36834 initAutoHide : function(){
36835 if(this.autoHide !== false){
36836 if(!this.autoHideHd){
36837 var st = new Roo.util.DelayedTask(this.slideIn, this);
36838 this.autoHideHd = {
36839 "mouseout": function(e){
36840 if(!e.within(this.el, true)){
36844 "mouseover" : function(e){
36850 this.el.on(this.autoHideHd);
36854 clearAutoHide : function(){
36855 if(this.autoHide !== false){
36856 this.el.un("mouseout", this.autoHideHd.mouseout);
36857 this.el.un("mouseover", this.autoHideHd.mouseover);
36861 clearMonitor : function(){
36862 Roo.get(document).un("click", this.slideInIf, this);
36865 // these names are backwards but not changed for compat
36866 slideOut : function(){
36867 if(this.isSlid || this.el.hasActiveFx()){
36870 this.isSlid = true;
36871 if(this.collapseBtn){
36872 this.collapseBtn.hide();
36874 this.closeBtnState = this.closeBtn.getStyle('display');
36875 this.closeBtn.hide();
36877 this.stickBtn.show();
36880 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36881 this.beforeSlide();
36882 this.el.setStyle("z-index", 10001);
36883 this.el.slideIn(this.getSlideAnchor(), {
36884 callback: function(){
36886 this.initAutoHide();
36887 Roo.get(document).on("click", this.slideInIf, this);
36888 this.fireEvent("slideshow", this);
36895 afterSlideIn : function(){
36896 this.clearAutoHide();
36897 this.isSlid = false;
36898 this.clearMonitor();
36899 this.el.setStyle("z-index", "");
36900 if(this.collapseBtn){
36901 this.collapseBtn.show();
36903 this.closeBtn.setStyle('display', this.closeBtnState);
36905 this.stickBtn.hide();
36907 this.fireEvent("slidehide", this);
36910 slideIn : function(cb){
36911 if(!this.isSlid || this.el.hasActiveFx()){
36915 this.isSlid = false;
36916 this.beforeSlide();
36917 this.el.slideOut(this.getSlideAnchor(), {
36918 callback: function(){
36919 this.el.setLeftTop(-10000, -10000);
36921 this.afterSlideIn();
36929 slideInIf : function(e){
36930 if(!e.within(this.el)){
36935 animateCollapse : function(){
36936 this.beforeSlide();
36937 this.el.setStyle("z-index", 20000);
36938 var anchor = this.getSlideAnchor();
36939 this.el.slideOut(anchor, {
36940 callback : function(){
36941 this.el.setStyle("z-index", "");
36942 this.collapsedEl.slideIn(anchor, {duration:.3});
36944 this.el.setLocation(-10000,-10000);
36946 this.fireEvent("collapsed", this);
36953 animateExpand : function(){
36954 this.beforeSlide();
36955 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36956 this.el.setStyle("z-index", 20000);
36957 this.collapsedEl.hide({
36960 this.el.slideIn(this.getSlideAnchor(), {
36961 callback : function(){
36962 this.el.setStyle("z-index", "");
36965 this.split.el.show();
36967 this.fireEvent("invalidated", this);
36968 this.fireEvent("expanded", this);
36996 getAnchor : function(){
36997 return this.anchors[this.position];
37000 getCollapseAnchor : function(){
37001 return this.canchors[this.position];
37004 getSlideAnchor : function(){
37005 return this.sanchors[this.position];
37008 getAlignAdj : function(){
37009 var cm = this.cmargins;
37010 switch(this.position){
37026 getExpandAdj : function(){
37027 var c = this.collapsedEl, cm = this.cmargins;
37028 switch(this.position){
37030 return [-(cm.right+c.getWidth()+cm.left), 0];
37033 return [cm.right+c.getWidth()+cm.left, 0];
37036 return [0, -(cm.top+cm.bottom+c.getHeight())];
37039 return [0, cm.top+cm.bottom+c.getHeight()];
37045 * Ext JS Library 1.1.1
37046 * Copyright(c) 2006-2007, Ext JS, LLC.
37048 * Originally Released Under LGPL - original licence link has changed is not relivant.
37051 * <script type="text/javascript">
37054 * These classes are private internal classes
37056 Roo.bootstrap.layout.Center = function(config){
37057 config.region = "center";
37058 Roo.bootstrap.layout.Region.call(this, config);
37059 this.visible = true;
37060 this.minWidth = config.minWidth || 20;
37061 this.minHeight = config.minHeight || 20;
37064 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37066 // center panel can't be hidden
37070 // center panel can't be hidden
37073 getMinWidth: function(){
37074 return this.minWidth;
37077 getMinHeight: function(){
37078 return this.minHeight;
37092 Roo.bootstrap.layout.North = function(config)
37094 config.region = 'north';
37095 config.cursor = 'n-resize';
37097 Roo.bootstrap.layout.Split.call(this, config);
37101 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37102 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37103 this.split.el.addClass("roo-layout-split-v");
37105 var size = config.initialSize || config.height;
37106 if(typeof size != "undefined"){
37107 this.el.setHeight(size);
37110 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37112 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37116 getBox : function(){
37117 if(this.collapsed){
37118 return this.collapsedEl.getBox();
37120 var box = this.el.getBox();
37122 box.height += this.split.el.getHeight();
37127 updateBox : function(box){
37128 if(this.split && !this.collapsed){
37129 box.height -= this.split.el.getHeight();
37130 this.split.el.setLeft(box.x);
37131 this.split.el.setTop(box.y+box.height);
37132 this.split.el.setWidth(box.width);
37134 if(this.collapsed){
37135 this.updateBody(box.width, null);
37137 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37145 Roo.bootstrap.layout.South = function(config){
37146 config.region = 'south';
37147 config.cursor = 's-resize';
37148 Roo.bootstrap.layout.Split.call(this, config);
37150 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37151 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37152 this.split.el.addClass("roo-layout-split-v");
37154 var size = config.initialSize || config.height;
37155 if(typeof size != "undefined"){
37156 this.el.setHeight(size);
37160 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37161 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37162 getBox : function(){
37163 if(this.collapsed){
37164 return this.collapsedEl.getBox();
37166 var box = this.el.getBox();
37168 var sh = this.split.el.getHeight();
37175 updateBox : function(box){
37176 if(this.split && !this.collapsed){
37177 var sh = this.split.el.getHeight();
37180 this.split.el.setLeft(box.x);
37181 this.split.el.setTop(box.y-sh);
37182 this.split.el.setWidth(box.width);
37184 if(this.collapsed){
37185 this.updateBody(box.width, null);
37187 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37191 Roo.bootstrap.layout.East = function(config){
37192 config.region = "east";
37193 config.cursor = "e-resize";
37194 Roo.bootstrap.layout.Split.call(this, config);
37196 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37197 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37198 this.split.el.addClass("roo-layout-split-h");
37200 var size = config.initialSize || config.width;
37201 if(typeof size != "undefined"){
37202 this.el.setWidth(size);
37205 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37206 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37207 getBox : function(){
37208 if(this.collapsed){
37209 return this.collapsedEl.getBox();
37211 var box = this.el.getBox();
37213 var sw = this.split.el.getWidth();
37220 updateBox : function(box){
37221 if(this.split && !this.collapsed){
37222 var sw = this.split.el.getWidth();
37224 this.split.el.setLeft(box.x);
37225 this.split.el.setTop(box.y);
37226 this.split.el.setHeight(box.height);
37229 if(this.collapsed){
37230 this.updateBody(null, box.height);
37232 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37236 Roo.bootstrap.layout.West = function(config){
37237 config.region = "west";
37238 config.cursor = "w-resize";
37240 Roo.bootstrap.layout.Split.call(this, config);
37242 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37243 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37244 this.split.el.addClass("roo-layout-split-h");
37248 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37249 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37251 onRender: function(ctr, pos)
37253 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37254 var size = this.config.initialSize || this.config.width;
37255 if(typeof size != "undefined"){
37256 this.el.setWidth(size);
37260 getBox : function(){
37261 if(this.collapsed){
37262 return this.collapsedEl.getBox();
37264 var box = this.el.getBox();
37266 box.width += this.split.el.getWidth();
37271 updateBox : function(box){
37272 if(this.split && !this.collapsed){
37273 var sw = this.split.el.getWidth();
37275 this.split.el.setLeft(box.x+box.width);
37276 this.split.el.setTop(box.y);
37277 this.split.el.setHeight(box.height);
37279 if(this.collapsed){
37280 this.updateBody(null, box.height);
37282 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37284 });Roo.namespace("Roo.bootstrap.panel");/*
37286 * Ext JS Library 1.1.1
37287 * Copyright(c) 2006-2007, Ext JS, LLC.
37289 * Originally Released Under LGPL - original licence link has changed is not relivant.
37292 * <script type="text/javascript">
37295 * @class Roo.ContentPanel
37296 * @extends Roo.util.Observable
37297 * A basic ContentPanel element.
37298 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37299 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37300 * @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
37301 * @cfg {Boolean} closable True if the panel can be closed/removed
37302 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37303 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37304 * @cfg {Toolbar} toolbar A toolbar for this panel
37305 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37306 * @cfg {String} title The title for this panel
37307 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37308 * @cfg {String} url Calls {@link #setUrl} with this value
37309 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37310 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37311 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37312 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37313 * @cfg {Boolean} badges render the badges
37316 * Create a new ContentPanel.
37317 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37318 * @param {String/Object} config A string to set only the title or a config object
37319 * @param {String} content (optional) Set the HTML content for this panel
37320 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37322 Roo.bootstrap.panel.Content = function( config){
37324 this.tpl = config.tpl || false;
37326 var el = config.el;
37327 var content = config.content;
37329 if(config.autoCreate){ // xtype is available if this is called from factory
37332 this.el = Roo.get(el);
37333 if(!this.el && config && config.autoCreate){
37334 if(typeof config.autoCreate == "object"){
37335 if(!config.autoCreate.id){
37336 config.autoCreate.id = config.id||el;
37338 this.el = Roo.DomHelper.append(document.body,
37339 config.autoCreate, true);
37341 var elcfg = { tag: "div",
37342 cls: "roo-layout-inactive-content",
37346 elcfg.html = config.html;
37350 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37353 this.closable = false;
37354 this.loaded = false;
37355 this.active = false;
37358 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37360 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37362 this.wrapEl = this.el; //this.el.wrap();
37364 if (config.toolbar.items) {
37365 ti = config.toolbar.items ;
37366 delete config.toolbar.items ;
37370 this.toolbar.render(this.wrapEl, 'before');
37371 for(var i =0;i < ti.length;i++) {
37372 // Roo.log(['add child', items[i]]);
37373 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37375 this.toolbar.items = nitems;
37376 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37377 delete config.toolbar;
37381 // xtype created footer. - not sure if will work as we normally have to render first..
37382 if (this.footer && !this.footer.el && this.footer.xtype) {
37383 if (!this.wrapEl) {
37384 this.wrapEl = this.el.wrap();
37387 this.footer.container = this.wrapEl.createChild();
37389 this.footer = Roo.factory(this.footer, Roo);
37394 if(typeof config == "string"){
37395 this.title = config;
37397 Roo.apply(this, config);
37401 this.resizeEl = Roo.get(this.resizeEl, true);
37403 this.resizeEl = this.el;
37405 // handle view.xtype
37413 * Fires when this panel is activated.
37414 * @param {Roo.ContentPanel} this
37418 * @event deactivate
37419 * Fires when this panel is activated.
37420 * @param {Roo.ContentPanel} this
37422 "deactivate" : true,
37426 * Fires when this panel is resized if fitToFrame is true.
37427 * @param {Roo.ContentPanel} this
37428 * @param {Number} width The width after any component adjustments
37429 * @param {Number} height The height after any component adjustments
37435 * Fires when this tab is created
37436 * @param {Roo.ContentPanel} this
37447 if(this.autoScroll){
37448 this.resizeEl.setStyle("overflow", "auto");
37450 // fix randome scrolling
37451 //this.el.on('scroll', function() {
37452 // Roo.log('fix random scolling');
37453 // this.scrollTo('top',0);
37456 content = content || this.content;
37458 this.setContent(content);
37460 if(config && config.url){
37461 this.setUrl(this.url, this.params, this.loadOnce);
37466 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37468 if (this.view && typeof(this.view.xtype) != 'undefined') {
37469 this.view.el = this.el.appendChild(document.createElement("div"));
37470 this.view = Roo.factory(this.view);
37471 this.view.render && this.view.render(false, '');
37475 this.fireEvent('render', this);
37478 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37482 setRegion : function(region){
37483 this.region = region;
37484 this.setActiveClass(region && !this.background);
37488 setActiveClass: function(state)
37491 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37492 this.el.setStyle('position','relative');
37494 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37495 this.el.setStyle('position', 'absolute');
37500 * Returns the toolbar for this Panel if one was configured.
37501 * @return {Roo.Toolbar}
37503 getToolbar : function(){
37504 return this.toolbar;
37507 setActiveState : function(active)
37509 this.active = active;
37510 this.setActiveClass(active);
37512 if(this.fireEvent("deactivate", this) === false){
37517 this.fireEvent("activate", this);
37521 * Updates this panel's element
37522 * @param {String} content The new content
37523 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37525 setContent : function(content, loadScripts){
37526 this.el.update(content, loadScripts);
37529 ignoreResize : function(w, h){
37530 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37533 this.lastSize = {width: w, height: h};
37538 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37539 * @return {Roo.UpdateManager} The UpdateManager
37541 getUpdateManager : function(){
37542 return this.el.getUpdateManager();
37545 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37546 * @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:
37549 url: "your-url.php",
37550 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37551 callback: yourFunction,
37552 scope: yourObject, //(optional scope)
37555 text: "Loading...",
37560 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37561 * 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.
37562 * @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}
37563 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37564 * @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.
37565 * @return {Roo.ContentPanel} this
37568 var um = this.el.getUpdateManager();
37569 um.update.apply(um, arguments);
37575 * 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.
37576 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37577 * @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)
37578 * @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)
37579 * @return {Roo.UpdateManager} The UpdateManager
37581 setUrl : function(url, params, loadOnce){
37582 if(this.refreshDelegate){
37583 this.removeListener("activate", this.refreshDelegate);
37585 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37586 this.on("activate", this.refreshDelegate);
37587 return this.el.getUpdateManager();
37590 _handleRefresh : function(url, params, loadOnce){
37591 if(!loadOnce || !this.loaded){
37592 var updater = this.el.getUpdateManager();
37593 updater.update(url, params, this._setLoaded.createDelegate(this));
37597 _setLoaded : function(){
37598 this.loaded = true;
37602 * Returns this panel's id
37605 getId : function(){
37610 * Returns this panel's element - used by regiosn to add.
37611 * @return {Roo.Element}
37613 getEl : function(){
37614 return this.wrapEl || this.el;
37619 adjustForComponents : function(width, height)
37621 //Roo.log('adjustForComponents ');
37622 if(this.resizeEl != this.el){
37623 width -= this.el.getFrameWidth('lr');
37624 height -= this.el.getFrameWidth('tb');
37627 var te = this.toolbar.getEl();
37628 te.setWidth(width);
37629 height -= te.getHeight();
37632 var te = this.footer.getEl();
37633 te.setWidth(width);
37634 height -= te.getHeight();
37638 if(this.adjustments){
37639 width += this.adjustments[0];
37640 height += this.adjustments[1];
37642 return {"width": width, "height": height};
37645 setSize : function(width, height){
37646 if(this.fitToFrame && !this.ignoreResize(width, height)){
37647 if(this.fitContainer && this.resizeEl != this.el){
37648 this.el.setSize(width, height);
37650 var size = this.adjustForComponents(width, height);
37651 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37652 this.fireEvent('resize', this, size.width, size.height);
37657 * Returns this panel's title
37660 getTitle : function(){
37662 if (typeof(this.title) != 'object') {
37667 for (var k in this.title) {
37668 if (!this.title.hasOwnProperty(k)) {
37672 if (k.indexOf('-') >= 0) {
37673 var s = k.split('-');
37674 for (var i = 0; i<s.length; i++) {
37675 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37678 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37685 * Set this panel's title
37686 * @param {String} title
37688 setTitle : function(title){
37689 this.title = title;
37691 this.region.updatePanelTitle(this, title);
37696 * Returns true is this panel was configured to be closable
37697 * @return {Boolean}
37699 isClosable : function(){
37700 return this.closable;
37703 beforeSlide : function(){
37705 this.resizeEl.clip();
37708 afterSlide : function(){
37710 this.resizeEl.unclip();
37714 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37715 * Will fail silently if the {@link #setUrl} method has not been called.
37716 * This does not activate the panel, just updates its content.
37718 refresh : function(){
37719 if(this.refreshDelegate){
37720 this.loaded = false;
37721 this.refreshDelegate();
37726 * Destroys this panel
37728 destroy : function(){
37729 this.el.removeAllListeners();
37730 var tempEl = document.createElement("span");
37731 tempEl.appendChild(this.el.dom);
37732 tempEl.innerHTML = "";
37738 * form - if the content panel contains a form - this is a reference to it.
37739 * @type {Roo.form.Form}
37743 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37744 * This contains a reference to it.
37750 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37760 * @param {Object} cfg Xtype definition of item to add.
37764 getChildContainer: function () {
37765 return this.getEl();
37770 var ret = new Roo.factory(cfg);
37775 if (cfg.xtype.match(/^Form$/)) {
37778 //if (this.footer) {
37779 // el = this.footer.container.insertSibling(false, 'before');
37781 el = this.el.createChild();
37784 this.form = new Roo.form.Form(cfg);
37787 if ( this.form.allItems.length) {
37788 this.form.render(el.dom);
37792 // should only have one of theses..
37793 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37794 // views.. should not be just added - used named prop 'view''
37796 cfg.el = this.el.appendChild(document.createElement("div"));
37799 var ret = new Roo.factory(cfg);
37801 ret.render && ret.render(false, ''); // render blank..
37811 * @class Roo.bootstrap.panel.Grid
37812 * @extends Roo.bootstrap.panel.Content
37814 * Create a new GridPanel.
37815 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37816 * @param {Object} config A the config object
37822 Roo.bootstrap.panel.Grid = function(config)
37826 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37827 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37829 config.el = this.wrapper;
37830 //this.el = this.wrapper;
37832 if (config.container) {
37833 // ctor'ed from a Border/panel.grid
37836 this.wrapper.setStyle("overflow", "hidden");
37837 this.wrapper.addClass('roo-grid-container');
37842 if(config.toolbar){
37843 var tool_el = this.wrapper.createChild();
37844 this.toolbar = Roo.factory(config.toolbar);
37846 if (config.toolbar.items) {
37847 ti = config.toolbar.items ;
37848 delete config.toolbar.items ;
37852 this.toolbar.render(tool_el);
37853 for(var i =0;i < ti.length;i++) {
37854 // Roo.log(['add child', items[i]]);
37855 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37857 this.toolbar.items = nitems;
37859 delete config.toolbar;
37862 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37863 config.grid.scrollBody = true;;
37864 config.grid.monitorWindowResize = false; // turn off autosizing
37865 config.grid.autoHeight = false;
37866 config.grid.autoWidth = false;
37868 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37870 if (config.background) {
37871 // render grid on panel activation (if panel background)
37872 this.on('activate', function(gp) {
37873 if (!gp.grid.rendered) {
37874 gp.grid.render(this.wrapper);
37875 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37880 this.grid.render(this.wrapper);
37881 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37884 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37885 // ??? needed ??? config.el = this.wrapper;
37890 // xtype created footer. - not sure if will work as we normally have to render first..
37891 if (this.footer && !this.footer.el && this.footer.xtype) {
37893 var ctr = this.grid.getView().getFooterPanel(true);
37894 this.footer.dataSource = this.grid.dataSource;
37895 this.footer = Roo.factory(this.footer, Roo);
37896 this.footer.render(ctr);
37906 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37907 getId : function(){
37908 return this.grid.id;
37912 * Returns the grid for this panel
37913 * @return {Roo.bootstrap.Table}
37915 getGrid : function(){
37919 setSize : function(width, height){
37920 if(!this.ignoreResize(width, height)){
37921 var grid = this.grid;
37922 var size = this.adjustForComponents(width, height);
37923 var gridel = grid.getGridEl();
37924 gridel.setSize(size.width, size.height);
37926 var thd = grid.getGridEl().select('thead',true).first();
37927 var tbd = grid.getGridEl().select('tbody', true).first();
37929 tbd.setSize(width, height - thd.getHeight());
37938 beforeSlide : function(){
37939 this.grid.getView().scroller.clip();
37942 afterSlide : function(){
37943 this.grid.getView().scroller.unclip();
37946 destroy : function(){
37947 this.grid.destroy();
37949 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37954 * @class Roo.bootstrap.panel.Nest
37955 * @extends Roo.bootstrap.panel.Content
37957 * Create a new Panel, that can contain a layout.Border.
37960 * @param {Roo.BorderLayout} layout The layout for this panel
37961 * @param {String/Object} config A string to set only the title or a config object
37963 Roo.bootstrap.panel.Nest = function(config)
37965 // construct with only one argument..
37966 /* FIXME - implement nicer consturctors
37967 if (layout.layout) {
37969 layout = config.layout;
37970 delete config.layout;
37972 if (layout.xtype && !layout.getEl) {
37973 // then layout needs constructing..
37974 layout = Roo.factory(layout, Roo);
37978 config.el = config.layout.getEl();
37980 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37982 config.layout.monitorWindowResize = false; // turn off autosizing
37983 this.layout = config.layout;
37984 this.layout.getEl().addClass("roo-layout-nested-layout");
37985 this.layout.parent = this;
37992 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37994 setSize : function(width, height){
37995 if(!this.ignoreResize(width, height)){
37996 var size = this.adjustForComponents(width, height);
37997 var el = this.layout.getEl();
37998 if (size.height < 1) {
37999 el.setWidth(size.width);
38001 el.setSize(size.width, size.height);
38003 var touch = el.dom.offsetWidth;
38004 this.layout.layout();
38005 // ie requires a double layout on the first pass
38006 if(Roo.isIE && !this.initialized){
38007 this.initialized = true;
38008 this.layout.layout();
38013 // activate all subpanels if not currently active..
38015 setActiveState : function(active){
38016 this.active = active;
38017 this.setActiveClass(active);
38020 this.fireEvent("deactivate", this);
38024 this.fireEvent("activate", this);
38025 // not sure if this should happen before or after..
38026 if (!this.layout) {
38027 return; // should not happen..
38030 for (var r in this.layout.regions) {
38031 reg = this.layout.getRegion(r);
38032 if (reg.getActivePanel()) {
38033 //reg.showPanel(reg.getActivePanel()); // force it to activate..
38034 reg.setActivePanel(reg.getActivePanel());
38037 if (!reg.panels.length) {
38040 reg.showPanel(reg.getPanel(0));
38049 * Returns the nested BorderLayout for this panel
38050 * @return {Roo.BorderLayout}
38052 getLayout : function(){
38053 return this.layout;
38057 * Adds a xtype elements to the layout of the nested panel
38061 xtype : 'ContentPanel',
38068 xtype : 'NestedLayoutPanel',
38074 items : [ ... list of content panels or nested layout panels.. ]
38078 * @param {Object} cfg Xtype definition of item to add.
38080 addxtype : function(cfg) {
38081 return this.layout.addxtype(cfg);
38086 * Ext JS Library 1.1.1
38087 * Copyright(c) 2006-2007, Ext JS, LLC.
38089 * Originally Released Under LGPL - original licence link has changed is not relivant.
38092 * <script type="text/javascript">
38095 * @class Roo.TabPanel
38096 * @extends Roo.util.Observable
38097 * A lightweight tab container.
38101 // basic tabs 1, built from existing content
38102 var tabs = new Roo.TabPanel("tabs1");
38103 tabs.addTab("script", "View Script");
38104 tabs.addTab("markup", "View Markup");
38105 tabs.activate("script");
38107 // more advanced tabs, built from javascript
38108 var jtabs = new Roo.TabPanel("jtabs");
38109 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38111 // set up the UpdateManager
38112 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38113 var updater = tab2.getUpdateManager();
38114 updater.setDefaultUrl("ajax1.htm");
38115 tab2.on('activate', updater.refresh, updater, true);
38117 // Use setUrl for Ajax loading
38118 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38119 tab3.setUrl("ajax2.htm", null, true);
38122 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38125 jtabs.activate("jtabs-1");
38128 * Create a new TabPanel.
38129 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38130 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38132 Roo.bootstrap.panel.Tabs = function(config){
38134 * The container element for this TabPanel.
38135 * @type Roo.Element
38137 this.el = Roo.get(config.el);
38140 if(typeof config == "boolean"){
38141 this.tabPosition = config ? "bottom" : "top";
38143 Roo.apply(this, config);
38147 if(this.tabPosition == "bottom"){
38148 // if tabs are at the bottom = create the body first.
38149 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38150 this.el.addClass("roo-tabs-bottom");
38152 // next create the tabs holders
38154 if (this.tabPosition == "west"){
38156 var reg = this.region; // fake it..
38158 if (!reg.mgr.parent) {
38161 reg = reg.mgr.parent.region;
38163 Roo.log("got nest?");
38165 if (reg.mgr.getRegion('west')) {
38166 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38167 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38168 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38169 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38170 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38178 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38179 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38180 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38181 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38186 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38189 // finally - if tabs are at the top, then create the body last..
38190 if(this.tabPosition != "bottom"){
38191 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38192 * @type Roo.Element
38194 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38195 this.el.addClass("roo-tabs-top");
38199 this.bodyEl.setStyle("position", "relative");
38201 this.active = null;
38202 this.activateDelegate = this.activate.createDelegate(this);
38207 * Fires when the active tab changes
38208 * @param {Roo.TabPanel} this
38209 * @param {Roo.TabPanelItem} activePanel The new active tab
38213 * @event beforetabchange
38214 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38215 * @param {Roo.TabPanel} this
38216 * @param {Object} e Set cancel to true on this object to cancel the tab change
38217 * @param {Roo.TabPanelItem} tab The tab being changed to
38219 "beforetabchange" : true
38222 Roo.EventManager.onWindowResize(this.onResize, this);
38223 this.cpad = this.el.getPadding("lr");
38224 this.hiddenCount = 0;
38227 // toolbar on the tabbar support...
38228 if (this.toolbar) {
38229 alert("no toolbar support yet");
38230 this.toolbar = false;
38232 var tcfg = this.toolbar;
38233 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38234 this.toolbar = new Roo.Toolbar(tcfg);
38235 if (Roo.isSafari) {
38236 var tbl = tcfg.container.child('table', true);
38237 tbl.setAttribute('width', '100%');
38245 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38248 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38250 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38252 tabPosition : "top",
38254 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38256 currentTabWidth : 0,
38258 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38262 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38266 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38268 preferredTabWidth : 175,
38270 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38272 resizeTabs : false,
38274 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38276 monitorResize : true,
38278 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38280 toolbar : false, // set by caller..
38282 region : false, /// set by caller
38284 disableTooltips : true, // not used yet...
38287 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38288 * @param {String} id The id of the div to use <b>or create</b>
38289 * @param {String} text The text for the tab
38290 * @param {String} content (optional) Content to put in the TabPanelItem body
38291 * @param {Boolean} closable (optional) True to create a close icon on the tab
38292 * @return {Roo.TabPanelItem} The created TabPanelItem
38294 addTab : function(id, text, content, closable, tpl)
38296 var item = new Roo.bootstrap.panel.TabItem({
38300 closable : closable,
38303 this.addTabItem(item);
38305 item.setContent(content);
38311 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38312 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38313 * @return {Roo.TabPanelItem}
38315 getTab : function(id){
38316 return this.items[id];
38320 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38321 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38323 hideTab : function(id){
38324 var t = this.items[id];
38327 this.hiddenCount++;
38328 this.autoSizeTabs();
38333 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38334 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38336 unhideTab : function(id){
38337 var t = this.items[id];
38339 t.setHidden(false);
38340 this.hiddenCount--;
38341 this.autoSizeTabs();
38346 * Adds an existing {@link Roo.TabPanelItem}.
38347 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38349 addTabItem : function(item)
38351 this.items[item.id] = item;
38352 this.items.push(item);
38353 this.autoSizeTabs();
38354 // if(this.resizeTabs){
38355 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38356 // this.autoSizeTabs();
38358 // item.autoSize();
38363 * Removes a {@link Roo.TabPanelItem}.
38364 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38366 removeTab : function(id){
38367 var items = this.items;
38368 var tab = items[id];
38369 if(!tab) { return; }
38370 var index = items.indexOf(tab);
38371 if(this.active == tab && items.length > 1){
38372 var newTab = this.getNextAvailable(index);
38377 this.stripEl.dom.removeChild(tab.pnode.dom);
38378 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38379 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38381 items.splice(index, 1);
38382 delete this.items[tab.id];
38383 tab.fireEvent("close", tab);
38384 tab.purgeListeners();
38385 this.autoSizeTabs();
38388 getNextAvailable : function(start){
38389 var items = this.items;
38391 // look for a next tab that will slide over to
38392 // replace the one being removed
38393 while(index < items.length){
38394 var item = items[++index];
38395 if(item && !item.isHidden()){
38399 // if one isn't found select the previous tab (on the left)
38402 var item = items[--index];
38403 if(item && !item.isHidden()){
38411 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38412 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38414 disableTab : function(id){
38415 var tab = this.items[id];
38416 if(tab && this.active != tab){
38422 * Enables a {@link Roo.TabPanelItem} that is disabled.
38423 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38425 enableTab : function(id){
38426 var tab = this.items[id];
38431 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38432 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38433 * @return {Roo.TabPanelItem} The TabPanelItem.
38435 activate : function(id)
38437 //Roo.log('activite:' + id);
38439 var tab = this.items[id];
38443 if(tab == this.active || tab.disabled){
38447 this.fireEvent("beforetabchange", this, e, tab);
38448 if(e.cancel !== true && !tab.disabled){
38450 this.active.hide();
38452 this.active = this.items[id];
38453 this.active.show();
38454 this.fireEvent("tabchange", this, this.active);
38460 * Gets the active {@link Roo.TabPanelItem}.
38461 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38463 getActiveTab : function(){
38464 return this.active;
38468 * Updates the tab body element to fit the height of the container element
38469 * for overflow scrolling
38470 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38472 syncHeight : function(targetHeight){
38473 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38474 var bm = this.bodyEl.getMargins();
38475 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38476 this.bodyEl.setHeight(newHeight);
38480 onResize : function(){
38481 if(this.monitorResize){
38482 this.autoSizeTabs();
38487 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38489 beginUpdate : function(){
38490 this.updating = true;
38494 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38496 endUpdate : function(){
38497 this.updating = false;
38498 this.autoSizeTabs();
38502 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38504 autoSizeTabs : function()
38506 var count = this.items.length;
38507 var vcount = count - this.hiddenCount;
38510 this.stripEl.hide();
38512 this.stripEl.show();
38515 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38520 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38521 var availWidth = Math.floor(w / vcount);
38522 var b = this.stripBody;
38523 if(b.getWidth() > w){
38524 var tabs = this.items;
38525 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38526 if(availWidth < this.minTabWidth){
38527 /*if(!this.sleft){ // incomplete scrolling code
38528 this.createScrollButtons();
38531 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38534 if(this.currentTabWidth < this.preferredTabWidth){
38535 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38541 * Returns the number of tabs in this TabPanel.
38544 getCount : function(){
38545 return this.items.length;
38549 * Resizes all the tabs to the passed width
38550 * @param {Number} The new width
38552 setTabWidth : function(width){
38553 this.currentTabWidth = width;
38554 for(var i = 0, len = this.items.length; i < len; i++) {
38555 if(!this.items[i].isHidden()) {
38556 this.items[i].setWidth(width);
38562 * Destroys this TabPanel
38563 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38565 destroy : function(removeEl){
38566 Roo.EventManager.removeResizeListener(this.onResize, this);
38567 for(var i = 0, len = this.items.length; i < len; i++){
38568 this.items[i].purgeListeners();
38570 if(removeEl === true){
38571 this.el.update("");
38576 createStrip : function(container)
38578 var strip = document.createElement("nav");
38579 strip.className = Roo.bootstrap.version == 4 ?
38580 "navbar-light bg-light" :
38581 "navbar navbar-default"; //"x-tabs-wrap";
38582 container.appendChild(strip);
38586 createStripList : function(strip)
38588 // div wrapper for retard IE
38589 // returns the "tr" element.
38590 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38591 //'<div class="x-tabs-strip-wrap">'+
38592 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38593 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38594 return strip.firstChild; //.firstChild.firstChild.firstChild;
38596 createBody : function(container)
38598 var body = document.createElement("div");
38599 Roo.id(body, "tab-body");
38600 //Roo.fly(body).addClass("x-tabs-body");
38601 Roo.fly(body).addClass("tab-content");
38602 container.appendChild(body);
38605 createItemBody :function(bodyEl, id){
38606 var body = Roo.getDom(id);
38608 body = document.createElement("div");
38611 //Roo.fly(body).addClass("x-tabs-item-body");
38612 Roo.fly(body).addClass("tab-pane");
38613 bodyEl.insertBefore(body, bodyEl.firstChild);
38617 createStripElements : function(stripEl, text, closable, tpl)
38619 var td = document.createElement("li"); // was td..
38620 td.className = 'nav-item';
38622 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38625 stripEl.appendChild(td);
38627 td.className = "x-tabs-closable";
38628 if(!this.closeTpl){
38629 this.closeTpl = new Roo.Template(
38630 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38631 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38632 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38635 var el = this.closeTpl.overwrite(td, {"text": text});
38636 var close = el.getElementsByTagName("div")[0];
38637 var inner = el.getElementsByTagName("em")[0];
38638 return {"el": el, "close": close, "inner": inner};
38641 // not sure what this is..
38642 // if(!this.tabTpl){
38643 //this.tabTpl = new Roo.Template(
38644 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38645 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38647 // this.tabTpl = new Roo.Template(
38648 // '<a href="#">' +
38649 // '<span unselectable="on"' +
38650 // (this.disableTooltips ? '' : ' title="{text}"') +
38651 // ' >{text}</span></a>'
38657 var template = tpl || this.tabTpl || false;
38660 template = new Roo.Template(
38661 Roo.bootstrap.version == 4 ?
38663 '<a class="nav-link" href="#" unselectable="on"' +
38664 (this.disableTooltips ? '' : ' title="{text}"') +
38667 '<a class="nav-link" href="#">' +
38668 '<span unselectable="on"' +
38669 (this.disableTooltips ? '' : ' title="{text}"') +
38670 ' >{text}</span></a>'
38675 switch (typeof(template)) {
38679 template = new Roo.Template(template);
38685 var el = template.overwrite(td, {"text": text});
38687 var inner = el.getElementsByTagName("span")[0];
38689 return {"el": el, "inner": inner};
38697 * @class Roo.TabPanelItem
38698 * @extends Roo.util.Observable
38699 * Represents an individual item (tab plus body) in a TabPanel.
38700 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38701 * @param {String} id The id of this TabPanelItem
38702 * @param {String} text The text for the tab of this TabPanelItem
38703 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38705 Roo.bootstrap.panel.TabItem = function(config){
38707 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38708 * @type Roo.TabPanel
38710 this.tabPanel = config.panel;
38712 * The id for this TabPanelItem
38715 this.id = config.id;
38717 this.disabled = false;
38719 this.text = config.text;
38721 this.loaded = false;
38722 this.closable = config.closable;
38725 * The body element for this TabPanelItem.
38726 * @type Roo.Element
38728 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38729 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38730 this.bodyEl.setStyle("display", "block");
38731 this.bodyEl.setStyle("zoom", "1");
38732 //this.hideAction();
38734 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38736 this.el = Roo.get(els.el);
38737 this.inner = Roo.get(els.inner, true);
38738 this.textEl = Roo.bootstrap.version == 4 ?
38739 this.el : Roo.get(this.el.dom.firstChild, true);
38741 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38742 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38745 // this.el.on("mousedown", this.onTabMouseDown, this);
38746 this.el.on("click", this.onTabClick, this);
38748 if(config.closable){
38749 var c = Roo.get(els.close, true);
38750 c.dom.title = this.closeText;
38751 c.addClassOnOver("close-over");
38752 c.on("click", this.closeClick, this);
38758 * Fires when this tab becomes the active tab.
38759 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38760 * @param {Roo.TabPanelItem} this
38764 * @event beforeclose
38765 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38766 * @param {Roo.TabPanelItem} this
38767 * @param {Object} e Set cancel to true on this object to cancel the close.
38769 "beforeclose": true,
38772 * Fires when this tab is closed.
38773 * @param {Roo.TabPanelItem} this
38777 * @event deactivate
38778 * Fires when this tab is no longer the active tab.
38779 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38780 * @param {Roo.TabPanelItem} this
38782 "deactivate" : true
38784 this.hidden = false;
38786 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38789 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38791 purgeListeners : function(){
38792 Roo.util.Observable.prototype.purgeListeners.call(this);
38793 this.el.removeAllListeners();
38796 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38799 this.status_node.addClass("active");
38802 this.tabPanel.stripWrap.repaint();
38804 this.fireEvent("activate", this.tabPanel, this);
38808 * Returns true if this tab is the active tab.
38809 * @return {Boolean}
38811 isActive : function(){
38812 return this.tabPanel.getActiveTab() == this;
38816 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38819 this.status_node.removeClass("active");
38821 this.fireEvent("deactivate", this.tabPanel, this);
38824 hideAction : function(){
38825 this.bodyEl.hide();
38826 this.bodyEl.setStyle("position", "absolute");
38827 this.bodyEl.setLeft("-20000px");
38828 this.bodyEl.setTop("-20000px");
38831 showAction : function(){
38832 this.bodyEl.setStyle("position", "relative");
38833 this.bodyEl.setTop("");
38834 this.bodyEl.setLeft("");
38835 this.bodyEl.show();
38839 * Set the tooltip for the tab.
38840 * @param {String} tooltip The tab's tooltip
38842 setTooltip : function(text){
38843 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38844 this.textEl.dom.qtip = text;
38845 this.textEl.dom.removeAttribute('title');
38847 this.textEl.dom.title = text;
38851 onTabClick : function(e){
38852 e.preventDefault();
38853 this.tabPanel.activate(this.id);
38856 onTabMouseDown : function(e){
38857 e.preventDefault();
38858 this.tabPanel.activate(this.id);
38861 getWidth : function(){
38862 return this.inner.getWidth();
38865 setWidth : function(width){
38866 var iwidth = width - this.linode.getPadding("lr");
38867 this.inner.setWidth(iwidth);
38868 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38869 this.linode.setWidth(width);
38873 * Show or hide the tab
38874 * @param {Boolean} hidden True to hide or false to show.
38876 setHidden : function(hidden){
38877 this.hidden = hidden;
38878 this.linode.setStyle("display", hidden ? "none" : "");
38882 * Returns true if this tab is "hidden"
38883 * @return {Boolean}
38885 isHidden : function(){
38886 return this.hidden;
38890 * Returns the text for this tab
38893 getText : function(){
38897 autoSize : function(){
38898 //this.el.beginMeasure();
38899 this.textEl.setWidth(1);
38901 * #2804 [new] Tabs in Roojs
38902 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38904 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38905 //this.el.endMeasure();
38909 * Sets the text for the tab (Note: this also sets the tooltip text)
38910 * @param {String} text The tab's text and tooltip
38912 setText : function(text){
38914 this.textEl.update(text);
38915 this.setTooltip(text);
38916 //if(!this.tabPanel.resizeTabs){
38917 // this.autoSize();
38921 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38923 activate : function(){
38924 this.tabPanel.activate(this.id);
38928 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38930 disable : function(){
38931 if(this.tabPanel.active != this){
38932 this.disabled = true;
38933 this.status_node.addClass("disabled");
38938 * Enables this TabPanelItem if it was previously disabled.
38940 enable : function(){
38941 this.disabled = false;
38942 this.status_node.removeClass("disabled");
38946 * Sets the content for this TabPanelItem.
38947 * @param {String} content The content
38948 * @param {Boolean} loadScripts true to look for and load scripts
38950 setContent : function(content, loadScripts){
38951 this.bodyEl.update(content, loadScripts);
38955 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38956 * @return {Roo.UpdateManager} The UpdateManager
38958 getUpdateManager : function(){
38959 return this.bodyEl.getUpdateManager();
38963 * Set a URL to be used to load the content for this TabPanelItem.
38964 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38965 * @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)
38966 * @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)
38967 * @return {Roo.UpdateManager} The UpdateManager
38969 setUrl : function(url, params, loadOnce){
38970 if(this.refreshDelegate){
38971 this.un('activate', this.refreshDelegate);
38973 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38974 this.on("activate", this.refreshDelegate);
38975 return this.bodyEl.getUpdateManager();
38979 _handleRefresh : function(url, params, loadOnce){
38980 if(!loadOnce || !this.loaded){
38981 var updater = this.bodyEl.getUpdateManager();
38982 updater.update(url, params, this._setLoaded.createDelegate(this));
38987 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38988 * Will fail silently if the setUrl method has not been called.
38989 * This does not activate the panel, just updates its content.
38991 refresh : function(){
38992 if(this.refreshDelegate){
38993 this.loaded = false;
38994 this.refreshDelegate();
38999 _setLoaded : function(){
39000 this.loaded = true;
39004 closeClick : function(e){
39007 this.fireEvent("beforeclose", this, o);
39008 if(o.cancel !== true){
39009 this.tabPanel.removeTab(this.id);
39013 * The text displayed in the tooltip for the close icon.
39016 closeText : "Close this tab"
39019 * This script refer to:
39020 * Title: International Telephone Input
39021 * Author: Jack O'Connor
39022 * Code version: v12.1.12
39023 * Availability: https://github.com/jackocnr/intl-tel-input.git
39026 Roo.bootstrap.PhoneInputData = function() {
39029 "Afghanistan (افغانستان)",
39034 "Albania (Shqipëri)",
39039 "Algeria (الجزائر)",
39064 "Antigua and Barbuda",
39074 "Armenia (Հայաստան)",
39090 "Austria (Österreich)",
39095 "Azerbaijan (Azərbaycan)",
39105 "Bahrain (البحرين)",
39110 "Bangladesh (বাংলাদেশ)",
39120 "Belarus (Беларусь)",
39125 "Belgium (België)",
39155 "Bosnia and Herzegovina (Босна и Херцеговина)",
39170 "British Indian Ocean Territory",
39175 "British Virgin Islands",
39185 "Bulgaria (България)",
39195 "Burundi (Uburundi)",
39200 "Cambodia (កម្ពុជា)",
39205 "Cameroon (Cameroun)",
39214 ["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"]
39217 "Cape Verde (Kabu Verdi)",
39222 "Caribbean Netherlands",
39233 "Central African Republic (République centrafricaine)",
39253 "Christmas Island",
39259 "Cocos (Keeling) Islands",
39270 "Comoros (جزر القمر)",
39275 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39280 "Congo (Republic) (Congo-Brazzaville)",
39300 "Croatia (Hrvatska)",
39321 "Czech Republic (Česká republika)",
39326 "Denmark (Danmark)",
39341 "Dominican Republic (República Dominicana)",
39345 ["809", "829", "849"]
39363 "Equatorial Guinea (Guinea Ecuatorial)",
39383 "Falkland Islands (Islas Malvinas)",
39388 "Faroe Islands (Føroyar)",
39409 "French Guiana (Guyane française)",
39414 "French Polynesia (Polynésie française)",
39429 "Georgia (საქართველო)",
39434 "Germany (Deutschland)",
39454 "Greenland (Kalaallit Nunaat)",
39491 "Guinea-Bissau (Guiné Bissau)",
39516 "Hungary (Magyarország)",
39521 "Iceland (Ísland)",
39541 "Iraq (العراق)",
39557 "Israel (ישראל)",
39584 "Jordan (الأردن)",
39589 "Kazakhstan (Казахстан)",
39610 "Kuwait (الكويت)",
39615 "Kyrgyzstan (Кыргызстан)",
39625 "Latvia (Latvija)",
39630 "Lebanon (لبنان)",
39645 "Libya (ليبيا)",
39655 "Lithuania (Lietuva)",
39670 "Macedonia (FYROM) (Македонија)",
39675 "Madagascar (Madagasikara)",
39705 "Marshall Islands",
39715 "Mauritania (موريتانيا)",
39720 "Mauritius (Moris)",
39741 "Moldova (Republica Moldova)",
39751 "Mongolia (Монгол)",
39756 "Montenegro (Crna Gora)",
39766 "Morocco (المغرب)",
39772 "Mozambique (Moçambique)",
39777 "Myanmar (Burma) (မြန်မာ)",
39782 "Namibia (Namibië)",
39797 "Netherlands (Nederland)",
39802 "New Caledonia (Nouvelle-Calédonie)",
39837 "North Korea (조선 민주주의 인민 공화국)",
39842 "Northern Mariana Islands",
39858 "Pakistan (پاکستان)",
39868 "Palestine (فلسطين)",
39878 "Papua New Guinea",
39920 "Réunion (La Réunion)",
39926 "Romania (România)",
39942 "Saint Barthélemy",
39953 "Saint Kitts and Nevis",
39963 "Saint Martin (Saint-Martin (partie française))",
39969 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39974 "Saint Vincent and the Grenadines",
39989 "São Tomé and Príncipe (São Tomé e Príncipe)",
39994 "Saudi Arabia (المملكة العربية السعودية)",
39999 "Senegal (Sénégal)",
40029 "Slovakia (Slovensko)",
40034 "Slovenia (Slovenija)",
40044 "Somalia (Soomaaliya)",
40054 "South Korea (대한민국)",
40059 "South Sudan (جنوب السودان)",
40069 "Sri Lanka (ශ්රී ලංකාව)",
40074 "Sudan (السودان)",
40084 "Svalbard and Jan Mayen",
40095 "Sweden (Sverige)",
40100 "Switzerland (Schweiz)",
40105 "Syria (سوريا)",
40150 "Trinidad and Tobago",
40155 "Tunisia (تونس)",
40160 "Turkey (Türkiye)",
40170 "Turks and Caicos Islands",
40180 "U.S. Virgin Islands",
40190 "Ukraine (Україна)",
40195 "United Arab Emirates (الإمارات العربية المتحدة)",
40217 "Uzbekistan (Oʻzbekiston)",
40227 "Vatican City (Città del Vaticano)",
40238 "Vietnam (Việt Nam)",
40243 "Wallis and Futuna (Wallis-et-Futuna)",
40248 "Western Sahara (الصحراء الغربية)",
40254 "Yemen (اليمن)",
40278 * This script refer to:
40279 * Title: International Telephone Input
40280 * Author: Jack O'Connor
40281 * Code version: v12.1.12
40282 * Availability: https://github.com/jackocnr/intl-tel-input.git
40286 * @class Roo.bootstrap.PhoneInput
40287 * @extends Roo.bootstrap.TriggerField
40288 * An input with International dial-code selection
40290 * @cfg {String} defaultDialCode default '+852'
40291 * @cfg {Array} preferedCountries default []
40294 * Create a new PhoneInput.
40295 * @param {Object} config Configuration options
40298 Roo.bootstrap.PhoneInput = function(config) {
40299 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40302 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40304 listWidth: undefined,
40306 selectedClass: 'active',
40308 invalidClass : "has-warning",
40310 validClass: 'has-success',
40312 allowed: '0123456789',
40317 * @cfg {String} defaultDialCode The default dial code when initializing the input
40319 defaultDialCode: '+852',
40322 * @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
40324 preferedCountries: false,
40326 getAutoCreate : function()
40328 var data = Roo.bootstrap.PhoneInputData();
40329 var align = this.labelAlign || this.parentLabelAlign();
40332 this.allCountries = [];
40333 this.dialCodeMapping = [];
40335 for (var i = 0; i < data.length; i++) {
40337 this.allCountries[i] = {
40341 priority: c[3] || 0,
40342 areaCodes: c[4] || null
40344 this.dialCodeMapping[c[2]] = {
40347 priority: c[3] || 0,
40348 areaCodes: c[4] || null
40360 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40361 maxlength: this.max_length,
40362 cls : 'form-control tel-input',
40363 autocomplete: 'new-password'
40366 var hiddenInput = {
40369 cls: 'hidden-tel-input'
40373 hiddenInput.name = this.name;
40376 if (this.disabled) {
40377 input.disabled = true;
40380 var flag_container = {
40397 cls: this.hasFeedback ? 'has-feedback' : '',
40403 cls: 'dial-code-holder',
40410 cls: 'roo-select2-container input-group',
40417 if (this.fieldLabel.length) {
40420 tooltip: 'This field is required'
40426 cls: 'control-label',
40432 html: this.fieldLabel
40435 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40441 if(this.indicatorpos == 'right') {
40442 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40449 if(align == 'left') {
40457 if(this.labelWidth > 12){
40458 label.style = "width: " + this.labelWidth + 'px';
40460 if(this.labelWidth < 13 && this.labelmd == 0){
40461 this.labelmd = this.labelWidth;
40463 if(this.labellg > 0){
40464 label.cls += ' col-lg-' + this.labellg;
40465 input.cls += ' col-lg-' + (12 - this.labellg);
40467 if(this.labelmd > 0){
40468 label.cls += ' col-md-' + this.labelmd;
40469 container.cls += ' col-md-' + (12 - this.labelmd);
40471 if(this.labelsm > 0){
40472 label.cls += ' col-sm-' + this.labelsm;
40473 container.cls += ' col-sm-' + (12 - this.labelsm);
40475 if(this.labelxs > 0){
40476 label.cls += ' col-xs-' + this.labelxs;
40477 container.cls += ' col-xs-' + (12 - this.labelxs);
40487 var settings = this;
40489 ['xs','sm','md','lg'].map(function(size){
40490 if (settings[size]) {
40491 cfg.cls += ' col-' + size + '-' + settings[size];
40495 this.store = new Roo.data.Store({
40496 proxy : new Roo.data.MemoryProxy({}),
40497 reader : new Roo.data.JsonReader({
40508 'name' : 'dialCode',
40512 'name' : 'priority',
40516 'name' : 'areaCodes',
40523 if(!this.preferedCountries) {
40524 this.preferedCountries = [
40531 var p = this.preferedCountries.reverse();
40534 for (var i = 0; i < p.length; i++) {
40535 for (var j = 0; j < this.allCountries.length; j++) {
40536 if(this.allCountries[j].iso2 == p[i]) {
40537 var t = this.allCountries[j];
40538 this.allCountries.splice(j,1);
40539 this.allCountries.unshift(t);
40545 this.store.proxy.data = {
40547 data: this.allCountries
40553 initEvents : function()
40556 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40558 this.indicator = this.indicatorEl();
40559 this.flag = this.flagEl();
40560 this.dialCodeHolder = this.dialCodeHolderEl();
40562 this.trigger = this.el.select('div.flag-box',true).first();
40563 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40568 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40569 _this.list.setWidth(lw);
40572 this.list.on('mouseover', this.onViewOver, this);
40573 this.list.on('mousemove', this.onViewMove, this);
40574 this.inputEl().on("keyup", this.onKeyUp, this);
40575 this.inputEl().on("keypress", this.onKeyPress, this);
40577 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40579 this.view = new Roo.View(this.list, this.tpl, {
40580 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40583 this.view.on('click', this.onViewClick, this);
40584 this.setValue(this.defaultDialCode);
40587 onTriggerClick : function(e)
40589 Roo.log('trigger click');
40594 if(this.isExpanded()){
40596 this.hasFocus = false;
40598 this.store.load({});
40599 this.hasFocus = true;
40604 isExpanded : function()
40606 return this.list.isVisible();
40609 collapse : function()
40611 if(!this.isExpanded()){
40615 Roo.get(document).un('mousedown', this.collapseIf, this);
40616 Roo.get(document).un('mousewheel', this.collapseIf, this);
40617 this.fireEvent('collapse', this);
40621 expand : function()
40625 if(this.isExpanded() || !this.hasFocus){
40629 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40630 this.list.setWidth(lw);
40633 this.restrictHeight();
40635 Roo.get(document).on('mousedown', this.collapseIf, this);
40636 Roo.get(document).on('mousewheel', this.collapseIf, this);
40638 this.fireEvent('expand', this);
40641 restrictHeight : function()
40643 this.list.alignTo(this.inputEl(), this.listAlign);
40644 this.list.alignTo(this.inputEl(), this.listAlign);
40647 onViewOver : function(e, t)
40649 if(this.inKeyMode){
40652 var item = this.view.findItemFromChild(t);
40655 var index = this.view.indexOf(item);
40656 this.select(index, false);
40661 onViewClick : function(view, doFocus, el, e)
40663 var index = this.view.getSelectedIndexes()[0];
40665 var r = this.store.getAt(index);
40668 this.onSelect(r, index);
40670 if(doFocus !== false && !this.blockFocus){
40671 this.inputEl().focus();
40675 onViewMove : function(e, t)
40677 this.inKeyMode = false;
40680 select : function(index, scrollIntoView)
40682 this.selectedIndex = index;
40683 this.view.select(index);
40684 if(scrollIntoView !== false){
40685 var el = this.view.getNode(index);
40687 this.list.scrollChildIntoView(el, false);
40692 createList : function()
40694 this.list = Roo.get(document.body).createChild({
40696 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40697 style: 'display:none'
40700 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40703 collapseIf : function(e)
40705 var in_combo = e.within(this.el);
40706 var in_list = e.within(this.list);
40707 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40709 if (in_combo || in_list || is_list) {
40715 onSelect : function(record, index)
40717 if(this.fireEvent('beforeselect', this, record, index) !== false){
40719 this.setFlagClass(record.data.iso2);
40720 this.setDialCode(record.data.dialCode);
40721 this.hasFocus = false;
40723 this.fireEvent('select', this, record, index);
40727 flagEl : function()
40729 var flag = this.el.select('div.flag',true).first();
40736 dialCodeHolderEl : function()
40738 var d = this.el.select('input.dial-code-holder',true).first();
40745 setDialCode : function(v)
40747 this.dialCodeHolder.dom.value = '+'+v;
40750 setFlagClass : function(n)
40752 this.flag.dom.className = 'flag '+n;
40755 getValue : function()
40757 var v = this.inputEl().getValue();
40758 if(this.dialCodeHolder) {
40759 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40764 setValue : function(v)
40766 var d = this.getDialCode(v);
40768 //invalid dial code
40769 if(v.length == 0 || !d || d.length == 0) {
40771 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40772 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40778 this.setFlagClass(this.dialCodeMapping[d].iso2);
40779 this.setDialCode(d);
40780 this.inputEl().dom.value = v.replace('+'+d,'');
40781 this.hiddenEl().dom.value = this.getValue();
40786 getDialCode : function(v)
40790 if (v.length == 0) {
40791 return this.dialCodeHolder.dom.value;
40795 if (v.charAt(0) != "+") {
40798 var numericChars = "";
40799 for (var i = 1; i < v.length; i++) {
40800 var c = v.charAt(i);
40803 if (this.dialCodeMapping[numericChars]) {
40804 dialCode = v.substr(1, i);
40806 if (numericChars.length == 4) {
40816 this.setValue(this.defaultDialCode);
40820 hiddenEl : function()
40822 return this.el.select('input.hidden-tel-input',true).first();
40825 // after setting val
40826 onKeyUp : function(e){
40827 this.setValue(this.getValue());
40830 onKeyPress : function(e){
40831 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40838 * @class Roo.bootstrap.MoneyField
40839 * @extends Roo.bootstrap.ComboBox
40840 * Bootstrap MoneyField class
40843 * Create a new MoneyField.
40844 * @param {Object} config Configuration options
40847 Roo.bootstrap.MoneyField = function(config) {
40849 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40853 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40856 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40858 allowDecimals : true,
40860 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40862 decimalSeparator : ".",
40864 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40866 decimalPrecision : 0,
40868 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40870 allowNegative : true,
40872 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40876 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40878 minValue : Number.NEGATIVE_INFINITY,
40880 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40882 maxValue : Number.MAX_VALUE,
40884 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40886 minText : "The minimum value for this field is {0}",
40888 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40890 maxText : "The maximum value for this field is {0}",
40892 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40893 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40895 nanText : "{0} is not a valid number",
40897 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40901 * @cfg {String} defaults currency of the MoneyField
40902 * value should be in lkey
40904 defaultCurrency : false,
40906 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40908 thousandsDelimiter : false,
40910 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40921 getAutoCreate : function()
40923 var align = this.labelAlign || this.parentLabelAlign();
40935 cls : 'form-control roo-money-amount-input',
40936 autocomplete: 'new-password'
40939 var hiddenInput = {
40943 cls: 'hidden-number-input'
40946 if(this.max_length) {
40947 input.maxlength = this.max_length;
40951 hiddenInput.name = this.name;
40954 if (this.disabled) {
40955 input.disabled = true;
40958 var clg = 12 - this.inputlg;
40959 var cmd = 12 - this.inputmd;
40960 var csm = 12 - this.inputsm;
40961 var cxs = 12 - this.inputxs;
40965 cls : 'row roo-money-field',
40969 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40973 cls: 'roo-select2-container input-group',
40977 cls : 'form-control roo-money-currency-input',
40978 autocomplete: 'new-password',
40980 name : this.currencyName
40984 cls : 'input-group-addon',
40998 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
41002 cls: this.hasFeedback ? 'has-feedback' : '',
41013 if (this.fieldLabel.length) {
41016 tooltip: 'This field is required'
41022 cls: 'control-label',
41028 html: this.fieldLabel
41031 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
41037 if(this.indicatorpos == 'right') {
41038 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41045 if(align == 'left') {
41053 if(this.labelWidth > 12){
41054 label.style = "width: " + this.labelWidth + 'px';
41056 if(this.labelWidth < 13 && this.labelmd == 0){
41057 this.labelmd = this.labelWidth;
41059 if(this.labellg > 0){
41060 label.cls += ' col-lg-' + this.labellg;
41061 input.cls += ' col-lg-' + (12 - this.labellg);
41063 if(this.labelmd > 0){
41064 label.cls += ' col-md-' + this.labelmd;
41065 container.cls += ' col-md-' + (12 - this.labelmd);
41067 if(this.labelsm > 0){
41068 label.cls += ' col-sm-' + this.labelsm;
41069 container.cls += ' col-sm-' + (12 - this.labelsm);
41071 if(this.labelxs > 0){
41072 label.cls += ' col-xs-' + this.labelxs;
41073 container.cls += ' col-xs-' + (12 - this.labelxs);
41084 var settings = this;
41086 ['xs','sm','md','lg'].map(function(size){
41087 if (settings[size]) {
41088 cfg.cls += ' col-' + size + '-' + settings[size];
41095 initEvents : function()
41097 this.indicator = this.indicatorEl();
41099 this.initCurrencyEvent();
41101 this.initNumberEvent();
41104 initCurrencyEvent : function()
41107 throw "can not find store for combo";
41110 this.store = Roo.factory(this.store, Roo.data);
41111 this.store.parent = this;
41115 this.triggerEl = this.el.select('.input-group-addon', true).first();
41117 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41122 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41123 _this.list.setWidth(lw);
41126 this.list.on('mouseover', this.onViewOver, this);
41127 this.list.on('mousemove', this.onViewMove, this);
41128 this.list.on('scroll', this.onViewScroll, this);
41131 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41134 this.view = new Roo.View(this.list, this.tpl, {
41135 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41138 this.view.on('click', this.onViewClick, this);
41140 this.store.on('beforeload', this.onBeforeLoad, this);
41141 this.store.on('load', this.onLoad, this);
41142 this.store.on('loadexception', this.onLoadException, this);
41144 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41145 "up" : function(e){
41146 this.inKeyMode = true;
41150 "down" : function(e){
41151 if(!this.isExpanded()){
41152 this.onTriggerClick();
41154 this.inKeyMode = true;
41159 "enter" : function(e){
41162 if(this.fireEvent("specialkey", this, e)){
41163 this.onViewClick(false);
41169 "esc" : function(e){
41173 "tab" : function(e){
41176 if(this.fireEvent("specialkey", this, e)){
41177 this.onViewClick(false);
41185 doRelay : function(foo, bar, hname){
41186 if(hname == 'down' || this.scope.isExpanded()){
41187 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41195 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41199 initNumberEvent : function(e)
41201 this.inputEl().on("keydown" , this.fireKey, this);
41202 this.inputEl().on("focus", this.onFocus, this);
41203 this.inputEl().on("blur", this.onBlur, this);
41205 this.inputEl().relayEvent('keyup', this);
41207 if(this.indicator){
41208 this.indicator.addClass('invisible');
41211 this.originalValue = this.getValue();
41213 if(this.validationEvent == 'keyup'){
41214 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41215 this.inputEl().on('keyup', this.filterValidation, this);
41217 else if(this.validationEvent !== false){
41218 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41221 if(this.selectOnFocus){
41222 this.on("focus", this.preFocus, this);
41225 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41226 this.inputEl().on("keypress", this.filterKeys, this);
41228 this.inputEl().relayEvent('keypress', this);
41231 var allowed = "0123456789";
41233 if(this.allowDecimals){
41234 allowed += this.decimalSeparator;
41237 if(this.allowNegative){
41241 if(this.thousandsDelimiter) {
41245 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41247 var keyPress = function(e){
41249 var k = e.getKey();
41251 var c = e.getCharCode();
41254 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41255 allowed.indexOf(String.fromCharCode(c)) === -1
41261 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41265 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41270 this.inputEl().on("keypress", keyPress, this);
41274 onTriggerClick : function(e)
41281 this.loadNext = false;
41283 if(this.isExpanded()){
41288 this.hasFocus = true;
41290 if(this.triggerAction == 'all') {
41291 this.doQuery(this.allQuery, true);
41295 this.doQuery(this.getRawValue());
41298 getCurrency : function()
41300 var v = this.currencyEl().getValue();
41305 restrictHeight : function()
41307 this.list.alignTo(this.currencyEl(), this.listAlign);
41308 this.list.alignTo(this.currencyEl(), this.listAlign);
41311 onViewClick : function(view, doFocus, el, e)
41313 var index = this.view.getSelectedIndexes()[0];
41315 var r = this.store.getAt(index);
41318 this.onSelect(r, index);
41322 onSelect : function(record, index){
41324 if(this.fireEvent('beforeselect', this, record, index) !== false){
41326 this.setFromCurrencyData(index > -1 ? record.data : false);
41330 this.fireEvent('select', this, record, index);
41334 setFromCurrencyData : function(o)
41338 this.lastCurrency = o;
41340 if (this.currencyField) {
41341 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41343 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41346 this.lastSelectionText = currency;
41348 //setting default currency
41349 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41350 this.setCurrency(this.defaultCurrency);
41354 this.setCurrency(currency);
41357 setFromData : function(o)
41361 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41363 this.setFromCurrencyData(c);
41368 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41370 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41373 this.setValue(value);
41377 setCurrency : function(v)
41379 this.currencyValue = v;
41382 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41387 setValue : function(v)
41389 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41395 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41397 this.inputEl().dom.value = (v == '') ? '' :
41398 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41400 if(!this.allowZero && v === '0') {
41401 this.hiddenEl().dom.value = '';
41402 this.inputEl().dom.value = '';
41409 getRawValue : function()
41411 var v = this.inputEl().getValue();
41416 getValue : function()
41418 return this.fixPrecision(this.parseValue(this.getRawValue()));
41421 parseValue : function(value)
41423 if(this.thousandsDelimiter) {
41425 r = new RegExp(",", "g");
41426 value = value.replace(r, "");
41429 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41430 return isNaN(value) ? '' : value;
41434 fixPrecision : function(value)
41436 if(this.thousandsDelimiter) {
41438 r = new RegExp(",", "g");
41439 value = value.replace(r, "");
41442 var nan = isNaN(value);
41444 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41445 return nan ? '' : value;
41447 return parseFloat(value).toFixed(this.decimalPrecision);
41450 decimalPrecisionFcn : function(v)
41452 return Math.floor(v);
41455 validateValue : function(value)
41457 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41461 var num = this.parseValue(value);
41464 this.markInvalid(String.format(this.nanText, value));
41468 if(num < this.minValue){
41469 this.markInvalid(String.format(this.minText, this.minValue));
41473 if(num > this.maxValue){
41474 this.markInvalid(String.format(this.maxText, this.maxValue));
41481 validate : function()
41483 if(this.disabled || this.allowBlank){
41488 var currency = this.getCurrency();
41490 if(this.validateValue(this.getRawValue()) && currency.length){
41495 this.markInvalid();
41499 getName: function()
41504 beforeBlur : function()
41510 var v = this.parseValue(this.getRawValue());
41517 onBlur : function()
41521 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41522 //this.el.removeClass(this.focusClass);
41525 this.hasFocus = false;
41527 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41531 var v = this.getValue();
41533 if(String(v) !== String(this.startValue)){
41534 this.fireEvent('change', this, v, this.startValue);
41537 this.fireEvent("blur", this);
41540 inputEl : function()
41542 return this.el.select('.roo-money-amount-input', true).first();
41545 currencyEl : function()
41547 return this.el.select('.roo-money-currency-input', true).first();
41550 hiddenEl : function()
41552 return this.el.select('input.hidden-number-input',true).first();
41556 * @class Roo.bootstrap.BezierSignature
41557 * @extends Roo.bootstrap.Component
41558 * Bootstrap BezierSignature class
41559 * This script refer to:
41560 * Title: Signature Pad
41562 * Availability: https://github.com/szimek/signature_pad
41565 * Create a new BezierSignature
41566 * @param {Object} config The config object
41569 Roo.bootstrap.BezierSignature = function(config){
41570 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41576 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
41583 mouse_btn_down: true,
41586 * @cfg {int} canvas height
41588 canvas_height: '200px',
41591 * @cfg {float|function} Radius of a single dot.
41596 * @cfg {float} Minimum width of a line. Defaults to 0.5.
41601 * @cfg {float} Maximum width of a line. Defaults to 2.5.
41606 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41611 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41616 * @cfg {string} Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images.
41618 bg_color: 'rgba(0, 0, 0, 0)',
41621 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41623 dot_color: 'black',
41626 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41628 velocity_filter_weight: 0.7,
41631 * @cfg {function} Callback when stroke begin.
41636 * @cfg {function} Callback when stroke end.
41640 getAutoCreate : function()
41642 var cls = 'roo-signature column';
41645 cls += ' ' + this.cls;
41655 for(var i = 0; i < col_sizes.length; i++) {
41656 if(this[col_sizes[i]]) {
41657 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41667 cls: 'roo-signature-body',
41671 cls: 'roo-signature-body-canvas',
41672 height: this.canvas_height,
41673 width: this.canvas_width
41680 style: 'display: none'
41688 initEvents: function()
41690 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41692 var canvas = this.canvasEl();
41694 // mouse && touch event swapping...
41695 canvas.dom.style.touchAction = 'none';
41696 canvas.dom.style.msTouchAction = 'none';
41698 this.mouse_btn_down = false;
41699 canvas.on('mousedown', this._handleMouseDown, this);
41700 canvas.on('mousemove', this._handleMouseMove, this);
41701 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41703 if (window.PointerEvent) {
41704 canvas.on('pointerdown', this._handleMouseDown, this);
41705 canvas.on('pointermove', this._handleMouseMove, this);
41706 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41709 if ('ontouchstart' in window) {
41710 canvas.on('touchstart', this._handleTouchStart, this);
41711 canvas.on('touchmove', this._handleTouchMove, this);
41712 canvas.on('touchend', this._handleTouchEnd, this);
41715 Roo.EventManager.onWindowResize(this.resize, this, true);
41717 // file input event
41718 this.fileEl().on('change', this.uploadImage, this);
41725 resize: function(){
41727 var canvas = this.canvasEl().dom;
41728 var ctx = this.canvasElCtx();
41729 var img_data = false;
41731 if(canvas.width > 0) {
41732 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41734 // setting canvas width will clean img data
41737 var style = window.getComputedStyle ?
41738 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41740 var padding_left = parseInt(style.paddingLeft) || 0;
41741 var padding_right = parseInt(style.paddingRight) || 0;
41743 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41746 ctx.putImageData(img_data, 0, 0);
41750 _handleMouseDown: function(e)
41752 if (e.browserEvent.which === 1) {
41753 this.mouse_btn_down = true;
41754 this.strokeBegin(e);
41758 _handleMouseMove: function (e)
41760 if (this.mouse_btn_down) {
41761 this.strokeMoveUpdate(e);
41765 _handleMouseUp: function (e)
41767 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41768 this.mouse_btn_down = false;
41773 _handleTouchStart: function (e) {
41775 e.preventDefault();
41776 if (e.browserEvent.targetTouches.length === 1) {
41777 // var touch = e.browserEvent.changedTouches[0];
41778 // this.strokeBegin(touch);
41780 this.strokeBegin(e); // assume e catching the correct xy...
41784 _handleTouchMove: function (e) {
41785 e.preventDefault();
41786 // var touch = event.targetTouches[0];
41787 // _this._strokeMoveUpdate(touch);
41788 this.strokeMoveUpdate(e);
41791 _handleTouchEnd: function (e) {
41792 var wasCanvasTouched = e.target === this.canvasEl().dom;
41793 if (wasCanvasTouched) {
41794 e.preventDefault();
41795 // var touch = event.changedTouches[0];
41796 // _this._strokeEnd(touch);
41801 reset: function () {
41802 this._lastPoints = [];
41803 this._lastVelocity = 0;
41804 this._lastWidth = (this.min_width + this.max_width) / 2;
41805 this.canvasElCtx().fillStyle = this.dot_color;
41808 strokeMoveUpdate: function(e)
41810 this.strokeUpdate(e);
41812 if (this.throttle) {
41813 this.throttleStroke(this.strokeUpdate, this.throttle);
41816 this.strokeUpdate(e);
41820 strokeBegin: function(e)
41822 var newPointGroup = {
41823 color: this.dot_color,
41827 if (typeof this.onBegin === 'function') {
41831 this.curve_data.push(newPointGroup);
41833 this.strokeUpdate(e);
41836 strokeUpdate: function(e)
41838 var rect = this.canvasEl().dom.getBoundingClientRect();
41839 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41840 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41841 var lastPoints = lastPointGroup.points;
41842 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41843 var isLastPointTooClose = lastPoint
41844 ? point.distanceTo(lastPoint) <= this.min_distance
41846 var color = lastPointGroup.color;
41847 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41848 var curve = this.addPoint(point);
41850 this.drawDot({color: color, point: point});
41853 this.drawCurve({color: color, curve: curve});
41863 strokeEnd: function(e)
41865 this.strokeUpdate(e);
41866 if (typeof this.onEnd === 'function') {
41871 addPoint: function (point) {
41872 var _lastPoints = this._lastPoints;
41873 _lastPoints.push(point);
41874 if (_lastPoints.length > 2) {
41875 if (_lastPoints.length === 3) {
41876 _lastPoints.unshift(_lastPoints[0]);
41878 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41879 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41880 _lastPoints.shift();
41886 calculateCurveWidths: function (startPoint, endPoint) {
41887 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41888 (1 - this.velocity_filter_weight) * this._lastVelocity;
41890 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41893 start: this._lastWidth
41896 this._lastVelocity = velocity;
41897 this._lastWidth = newWidth;
41901 drawDot: function (_a) {
41902 var color = _a.color, point = _a.point;
41903 var ctx = this.canvasElCtx();
41904 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41906 this.drawCurveSegment(point.x, point.y, width);
41908 ctx.fillStyle = color;
41912 drawCurve: function (_a) {
41913 var color = _a.color, curve = _a.curve;
41914 var ctx = this.canvasElCtx();
41915 var widthDelta = curve.endWidth - curve.startWidth;
41916 var drawSteps = Math.floor(curve.length()) * 2;
41918 ctx.fillStyle = color;
41919 for (var i = 0; i < drawSteps; i += 1) {
41920 var t = i / drawSteps;
41926 var x = uuu * curve.startPoint.x;
41927 x += 3 * uu * t * curve.control1.x;
41928 x += 3 * u * tt * curve.control2.x;
41929 x += ttt * curve.endPoint.x;
41930 var y = uuu * curve.startPoint.y;
41931 y += 3 * uu * t * curve.control1.y;
41932 y += 3 * u * tt * curve.control2.y;
41933 y += ttt * curve.endPoint.y;
41934 var width = curve.startWidth + ttt * widthDelta;
41935 this.drawCurveSegment(x, y, width);
41941 drawCurveSegment: function (x, y, width) {
41942 var ctx = this.canvasElCtx();
41944 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41945 this.is_empty = false;
41950 var ctx = this.canvasElCtx();
41951 var canvas = this.canvasEl().dom;
41952 ctx.fillStyle = this.bg_color;
41953 ctx.clearRect(0, 0, canvas.width, canvas.height);
41954 ctx.fillRect(0, 0, canvas.width, canvas.height);
41955 this.curve_data = [];
41957 this.is_empty = true;
41962 return this.el.select('input',true).first();
41965 canvasEl: function()
41967 return this.el.select('canvas',true).first();
41970 canvasElCtx: function()
41972 return this.el.select('canvas',true).first().dom.getContext('2d');
41975 getImage: function(type)
41977 if(this.is_empty) {
41982 return this.canvasEl().dom.toDataURL('image/'+type, 1);
41985 drawFromImage: function(img_src)
41987 var img = new Image();
41989 img.onload = function(){
41990 this.canvasElCtx().drawImage(img, 0, 0);
41995 this.is_empty = false;
41998 selectImage: function()
42000 this.fileEl().dom.click();
42003 uploadImage: function(e)
42005 var reader = new FileReader();
42007 reader.onload = function(e){
42008 var img = new Image();
42009 img.onload = function(){
42011 this.canvasElCtx().drawImage(img, 0, 0);
42013 img.src = e.target.result;
42016 reader.readAsDataURL(e.target.files[0]);
42019 // Bezier Point Constructor
42020 Point: (function () {
42021 function Point(x, y, time) {
42024 this.time = time || Date.now();
42026 Point.prototype.distanceTo = function (start) {
42027 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
42029 Point.prototype.equals = function (other) {
42030 return this.x === other.x && this.y === other.y && this.time === other.time;
42032 Point.prototype.velocityFrom = function (start) {
42033 return this.time !== start.time
42034 ? this.distanceTo(start) / (this.time - start.time)
42041 // Bezier Constructor
42042 Bezier: (function () {
42043 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
42044 this.startPoint = startPoint;
42045 this.control2 = control2;
42046 this.control1 = control1;
42047 this.endPoint = endPoint;
42048 this.startWidth = startWidth;
42049 this.endWidth = endWidth;
42051 Bezier.fromPoints = function (points, widths, scope) {
42052 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42053 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42054 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42056 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42057 var dx1 = s1.x - s2.x;
42058 var dy1 = s1.y - s2.y;
42059 var dx2 = s2.x - s3.x;
42060 var dy2 = s2.y - s3.y;
42061 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42062 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42063 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42064 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42065 var dxm = m1.x - m2.x;
42066 var dym = m1.y - m2.y;
42067 var k = l2 / (l1 + l2);
42068 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42069 var tx = s2.x - cm.x;
42070 var ty = s2.y - cm.y;
42072 c1: new scope.Point(m1.x + tx, m1.y + ty),
42073 c2: new scope.Point(m2.x + tx, m2.y + ty)
42076 Bezier.prototype.length = function () {
42081 for (var i = 0; i <= steps; i += 1) {
42083 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42084 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42086 var xdiff = cx - px;
42087 var ydiff = cy - py;
42088 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42095 Bezier.prototype.point = function (t, start, c1, c2, end) {
42096 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42097 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42098 + (3.0 * c2 * (1.0 - t) * t * t)
42099 + (end * t * t * t);
42104 throttleStroke: function(fn, wait) {
42105 if (wait === void 0) { wait = 250; }
42107 var timeout = null;
42111 var later = function () {
42112 previous = Date.now();
42114 result = fn.apply(storedContext, storedArgs);
42116 storedContext = null;
42120 return function wrapper() {
42122 for (var _i = 0; _i < arguments.length; _i++) {
42123 args[_i] = arguments[_i];
42125 var now = Date.now();
42126 var remaining = wait - (now - previous);
42127 storedContext = this;
42129 if (remaining <= 0 || remaining > wait) {
42131 clearTimeout(timeout);
42135 result = fn.apply(storedContext, storedArgs);
42137 storedContext = null;
42141 else if (!timeout) {
42142 timeout = window.setTimeout(later, remaining);