2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets[0], function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
585 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
586 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
587 * @cfg {String} size ( lg | sm | xs)
588 * @cfg {String} tag ( a | input | submit)
589 * @cfg {String} href empty or href
590 * @cfg {Boolean} disabled default false;
591 * @cfg {Boolean} isClose default false;
592 * @cfg {String} glyphicon depricated - use fa
593 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
594 * @cfg {String} badge text for badge
595 * @cfg {String} theme (default|glow)
596 * @cfg {Boolean} inverse dark themed version
597 * @cfg {Boolean} toggle is it a slidy toggle button
598 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
599 * @cfg {String} ontext text for on slidy toggle state
600 * @cfg {String} offtext text for off slidy toggle state
601 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
602 * @cfg {Boolean} removeClass remove the standard class..
603 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
606 * Create a new button
607 * @param {Object} config The config object
611 Roo.bootstrap.Button = function(config){
612 Roo.bootstrap.Button.superclass.constructor.call(this, config);
613 this.weightClass = ["btn-default btn-outline-secondary",
625 * When a butotn is pressed
626 * @param {Roo.bootstrap.Button} btn
627 * @param {Roo.EventObject} e
632 * After the button has been toggles
633 * @param {Roo.bootstrap.Button} btn
634 * @param {Roo.EventObject} e
635 * @param {boolean} pressed (also available as button.pressed)
641 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
662 preventDefault: true,
670 getAutoCreate : function(){
678 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
679 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
684 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
686 if (this.toggle == true) {
689 cls: 'slider-frame roo-button',
694 'data-off-text':'OFF',
695 cls: 'slider-button',
701 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
702 cfg.cls += ' '+this.weight;
711 cfg["aria-hidden"] = true;
713 cfg.html = "×";
719 if (this.theme==='default') {
720 cfg.cls = 'btn roo-button';
722 //if (this.parentType != 'Navbar') {
723 this.weight = this.weight.length ? this.weight : 'default';
725 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
727 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
728 var weight = this.weight == 'default' ? 'secondary' : this.weight;
729 cfg.cls += ' btn-' + outline + weight;
730 if (this.weight == 'default') {
732 cfg.cls += ' btn-' + this.weight;
735 } else if (this.theme==='glow') {
738 cfg.cls = 'btn-glow roo-button';
740 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
742 cfg.cls += ' ' + this.weight;
748 this.cls += ' inverse';
752 if (this.active || this.pressed === true) {
753 cfg.cls += ' active';
757 cfg.disabled = 'disabled';
761 Roo.log('changing to ul' );
763 this.glyphicon = 'caret';
764 if (Roo.bootstrap.version == 4) {
765 this.fa = 'caret-down';
770 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
772 //gsRoo.log(this.parentType);
773 if (this.parentType === 'Navbar' && !this.parent().bar) {
774 Roo.log('changing to li?');
783 href : this.href || '#'
786 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
787 cfg.cls += ' dropdown';
794 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
796 if (this.glyphicon) {
797 cfg.html = ' ' + cfg.html;
802 cls: 'glyphicon glyphicon-' + this.glyphicon
807 cfg.html = ' ' + cfg.html;
812 cls: 'fa fas fa-' + this.fa
822 // cfg.cls='btn roo-button';
826 var value = cfg.html;
831 cls: 'glyphicon glyphicon-' + this.glyphicon,
838 cls: 'fa fas fa-' + this.fa,
843 var bw = this.badge_weight.length ? this.badge_weight :
844 (this.weight.length ? this.weight : 'secondary');
845 bw = bw == 'default' ? 'secondary' : bw;
851 cls: 'badge badge-' + bw,
860 cfg.cls += ' dropdown';
861 cfg.html = typeof(cfg.html) != 'undefined' ?
862 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
865 if (cfg.tag !== 'a' && this.href !== '') {
866 throw "Tag must be a to set href.";
867 } else if (this.href.length > 0) {
868 cfg.href = this.href;
871 if(this.removeClass){
876 cfg.target = this.target;
881 initEvents: function() {
882 // Roo.log('init events?');
883 // Roo.log(this.el.dom);
886 if (typeof (this.menu) != 'undefined') {
887 this.menu.parentType = this.xtype;
888 this.menu.triggerEl = this.el;
889 this.addxtype(Roo.apply({}, this.menu));
893 if (this.el.hasClass('roo-button')) {
894 this.el.on('click', this.onClick, this);
896 this.el.select('.roo-button').on('click', this.onClick, this);
899 if(this.removeClass){
900 this.el.on('click', this.onClick, this);
903 this.el.enableDisplayMode();
906 onClick : function(e)
912 Roo.log('button on click ');
913 if(this.preventDefault){
917 if (this.pressed === true || this.pressed === false) {
918 this.toggleActive(e);
922 this.fireEvent('click', this, e);
926 * Enables this button
930 this.disabled = false;
931 this.el.removeClass('disabled');
935 * Disable this button
939 this.disabled = true;
940 this.el.addClass('disabled');
943 * sets the active state on/off,
944 * @param {Boolean} state (optional) Force a particular state
946 setActive : function(v) {
948 this.el[v ? 'addClass' : 'removeClass']('active');
952 * toggles the current active state
954 toggleActive : function(e)
956 this.setActive(!this.pressed);
957 this.fireEvent('toggle', this, e, !this.pressed);
960 * get the current active state
961 * @return {boolean} true if it's active
963 isActive : function()
965 return this.el.hasClass('active');
968 * set the text of the first selected button
970 setText : function(str)
972 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
975 * get the text of the first selected button
979 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
982 setWeight : function(str)
984 this.el.removeClass(this.weightClass);
986 var outline = this.outline ? 'outline-' : '';
987 if (str == 'default') {
988 this.el.addClass('btn-default btn-outline-secondary');
991 this.el.addClass('btn-' + outline + str);
1005 * @class Roo.bootstrap.Column
1006 * @extends Roo.bootstrap.Component
1007 * Bootstrap Column class
1008 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1009 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1010 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1011 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1012 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1013 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1014 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1015 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1018 * @cfg {Boolean} hidden (true|false) hide the element
1019 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1020 * @cfg {String} fa (ban|check|...) font awesome icon
1021 * @cfg {Number} fasize (1|2|....) font awsome size
1023 * @cfg {String} icon (info-sign|check|...) glyphicon name
1025 * @cfg {String} html content of column.
1028 * Create a new Column
1029 * @param {Object} config The config object
1032 Roo.bootstrap.Column = function(config){
1033 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1036 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1054 getAutoCreate : function(){
1055 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1063 ['xs','sm','md','lg'].map(function(size){
1064 //Roo.log( size + ':' + settings[size]);
1066 if (settings[size+'off'] !== false) {
1067 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1070 if (settings[size] === false) {
1074 if (!settings[size]) { // 0 = hidden
1075 cfg.cls += ' hidden-' + size;
1078 cfg.cls += ' col-' + size + '-' + settings[size];
1083 cfg.cls += ' hidden';
1086 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1087 cfg.cls +=' alert alert-' + this.alert;
1091 if (this.html.length) {
1092 cfg.html = this.html;
1096 if (this.fasize > 1) {
1097 fasize = ' fa-' + this.fasize + 'x';
1099 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1104 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1123 * @class Roo.bootstrap.Container
1124 * @extends Roo.bootstrap.Component
1125 * Bootstrap Container class
1126 * @cfg {Boolean} jumbotron is it a jumbotron element
1127 * @cfg {String} html content of element
1128 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1129 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1130 * @cfg {String} header content of header (for panel)
1131 * @cfg {String} footer content of footer (for panel)
1132 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1133 * @cfg {String} tag (header|aside|section) type of HTML tag.
1134 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1135 * @cfg {String} fa font awesome icon
1136 * @cfg {String} icon (info-sign|check|...) glyphicon name
1137 * @cfg {Boolean} hidden (true|false) hide the element
1138 * @cfg {Boolean} expandable (true|false) default false
1139 * @cfg {Boolean} expanded (true|false) default true
1140 * @cfg {String} rheader contet on the right of header
1141 * @cfg {Boolean} clickable (true|false) default false
1145 * Create a new Container
1146 * @param {Object} config The config object
1149 Roo.bootstrap.Container = function(config){
1150 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1156 * After the panel has been expand
1158 * @param {Roo.bootstrap.Container} this
1163 * After the panel has been collapsed
1165 * @param {Roo.bootstrap.Container} this
1170 * When a element is chick
1171 * @param {Roo.bootstrap.Container} this
1172 * @param {Roo.EventObject} e
1178 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1196 getChildContainer : function() {
1202 if (this.panel.length) {
1203 return this.el.select('.panel-body',true).first();
1210 getAutoCreate : function(){
1213 tag : this.tag || 'div',
1217 if (this.jumbotron) {
1218 cfg.cls = 'jumbotron';
1223 // - this is applied by the parent..
1225 // cfg.cls = this.cls + '';
1228 if (this.sticky.length) {
1230 var bd = Roo.get(document.body);
1231 if (!bd.hasClass('bootstrap-sticky')) {
1232 bd.addClass('bootstrap-sticky');
1233 Roo.select('html',true).setStyle('height', '100%');
1236 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1240 if (this.well.length) {
1241 switch (this.well) {
1244 cfg.cls +=' well well-' +this.well;
1253 cfg.cls += ' hidden';
1257 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1258 cfg.cls +=' alert alert-' + this.alert;
1263 if (this.panel.length) {
1264 cfg.cls += ' panel panel-' + this.panel;
1266 if (this.header.length) {
1270 if(this.expandable){
1272 cfg.cls = cfg.cls + ' expandable';
1276 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1284 cls : 'panel-title',
1285 html : (this.expandable ? ' ' : '') + this.header
1289 cls: 'panel-header-right',
1295 cls : 'panel-heading',
1296 style : this.expandable ? 'cursor: pointer' : '',
1304 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1309 if (this.footer.length) {
1311 cls : 'panel-footer',
1320 body.html = this.html || cfg.html;
1321 // prefix with the icons..
1323 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1326 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1331 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1332 cfg.cls = 'container';
1338 initEvents: function()
1340 if(this.expandable){
1341 var headerEl = this.headerEl();
1344 headerEl.on('click', this.onToggleClick, this);
1349 this.el.on('click', this.onClick, this);
1354 onToggleClick : function()
1356 var headerEl = this.headerEl();
1372 if(this.fireEvent('expand', this)) {
1374 this.expanded = true;
1376 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1378 this.el.select('.panel-body',true).first().removeClass('hide');
1380 var toggleEl = this.toggleEl();
1386 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1391 collapse : function()
1393 if(this.fireEvent('collapse', this)) {
1395 this.expanded = false;
1397 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1398 this.el.select('.panel-body',true).first().addClass('hide');
1400 var toggleEl = this.toggleEl();
1406 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1410 toggleEl : function()
1412 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1416 return this.el.select('.panel-heading .fa',true).first();
1419 headerEl : function()
1421 if(!this.el || !this.panel.length || !this.header.length){
1425 return this.el.select('.panel-heading',true).first()
1430 if(!this.el || !this.panel.length){
1434 return this.el.select('.panel-body',true).first()
1437 titleEl : function()
1439 if(!this.el || !this.panel.length || !this.header.length){
1443 return this.el.select('.panel-title',true).first();
1446 setTitle : function(v)
1448 var titleEl = this.titleEl();
1454 titleEl.dom.innerHTML = v;
1457 getTitle : function()
1460 var titleEl = this.titleEl();
1466 return titleEl.dom.innerHTML;
1469 setRightTitle : function(v)
1471 var t = this.el.select('.panel-header-right',true).first();
1477 t.dom.innerHTML = v;
1480 onClick : function(e)
1484 this.fireEvent('click', this, e);
1497 * @class Roo.bootstrap.Img
1498 * @extends Roo.bootstrap.Component
1499 * Bootstrap Img class
1500 * @cfg {Boolean} imgResponsive false | true
1501 * @cfg {String} border rounded | circle | thumbnail
1502 * @cfg {String} src image source
1503 * @cfg {String} alt image alternative text
1504 * @cfg {String} href a tag href
1505 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1506 * @cfg {String} xsUrl xs image source
1507 * @cfg {String} smUrl sm image source
1508 * @cfg {String} mdUrl md image source
1509 * @cfg {String} lgUrl lg image source
1512 * Create a new Input
1513 * @param {Object} config The config object
1516 Roo.bootstrap.Img = function(config){
1517 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1523 * The img click event for the img.
1524 * @param {Roo.EventObject} e
1530 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1532 imgResponsive: true,
1542 getAutoCreate : function()
1544 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1545 return this.createSingleImg();
1550 cls: 'roo-image-responsive-group',
1555 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1557 if(!_this[size + 'Url']){
1563 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1564 html: _this.html || cfg.html,
1565 src: _this[size + 'Url']
1568 img.cls += ' roo-image-responsive-' + size;
1570 var s = ['xs', 'sm', 'md', 'lg'];
1572 s.splice(s.indexOf(size), 1);
1574 Roo.each(s, function(ss){
1575 img.cls += ' hidden-' + ss;
1578 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1579 cfg.cls += ' img-' + _this.border;
1583 cfg.alt = _this.alt;
1596 a.target = _this.target;
1600 cfg.cn.push((_this.href) ? a : img);
1607 createSingleImg : function()
1611 cls: (this.imgResponsive) ? 'img-responsive' : '',
1613 src : 'about:blank' // just incase src get's set to undefined?!?
1616 cfg.html = this.html || cfg.html;
1618 cfg.src = this.src || cfg.src;
1620 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1621 cfg.cls += ' img-' + this.border;
1638 a.target = this.target;
1643 return (this.href) ? a : cfg;
1646 initEvents: function()
1649 this.el.on('click', this.onClick, this);
1654 onClick : function(e)
1656 Roo.log('img onclick');
1657 this.fireEvent('click', this, e);
1660 * Sets the url of the image - used to update it
1661 * @param {String} url the url of the image
1664 setSrc : function(url)
1668 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1669 this.el.dom.src = url;
1673 this.el.select('img', true).first().dom.src = url;
1689 * @class Roo.bootstrap.Link
1690 * @extends Roo.bootstrap.Component
1691 * Bootstrap Link Class
1692 * @cfg {String} alt image alternative text
1693 * @cfg {String} href a tag href
1694 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1695 * @cfg {String} html the content of the link.
1696 * @cfg {String} anchor name for the anchor link
1697 * @cfg {String} fa - favicon
1699 * @cfg {Boolean} preventDefault (true | false) default false
1703 * Create a new Input
1704 * @param {Object} config The config object
1707 Roo.bootstrap.Link = function(config){
1708 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1714 * The img click event for the img.
1715 * @param {Roo.EventObject} e
1721 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1725 preventDefault: false,
1731 getAutoCreate : function()
1733 var html = this.html || '';
1735 if (this.fa !== false) {
1736 html = '<i class="fa fa-' + this.fa + '"></i>';
1741 // anchor's do not require html/href...
1742 if (this.anchor === false) {
1744 cfg.href = this.href || '#';
1746 cfg.name = this.anchor;
1747 if (this.html !== false || this.fa !== false) {
1750 if (this.href !== false) {
1751 cfg.href = this.href;
1755 if(this.alt !== false){
1760 if(this.target !== false) {
1761 cfg.target = this.target;
1767 initEvents: function() {
1769 if(!this.href || this.preventDefault){
1770 this.el.on('click', this.onClick, this);
1774 onClick : function(e)
1776 if(this.preventDefault){
1779 //Roo.log('img onclick');
1780 this.fireEvent('click', this, e);
1793 * @class Roo.bootstrap.Header
1794 * @extends Roo.bootstrap.Component
1795 * Bootstrap Header class
1796 * @cfg {String} html content of header
1797 * @cfg {Number} level (1|2|3|4|5|6) default 1
1800 * Create a new Header
1801 * @param {Object} config The config object
1805 Roo.bootstrap.Header = function(config){
1806 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1809 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1817 getAutoCreate : function(){
1822 tag: 'h' + (1 *this.level),
1823 html: this.html || ''
1835 * Ext JS Library 1.1.1
1836 * Copyright(c) 2006-2007, Ext JS, LLC.
1838 * Originally Released Under LGPL - original licence link has changed is not relivant.
1841 * <script type="text/javascript">
1845 * @class Roo.bootstrap.MenuMgr
1846 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1849 Roo.bootstrap.MenuMgr = function(){
1850 var menus, active, groups = {}, attached = false, lastShow = new Date();
1852 // private - called when first menu is created
1855 active = new Roo.util.MixedCollection();
1856 Roo.get(document).addKeyListener(27, function(){
1857 if(active.length > 0){
1865 if(active && active.length > 0){
1866 var c = active.clone();
1876 if(active.length < 1){
1877 Roo.get(document).un("mouseup", onMouseDown);
1885 var last = active.last();
1886 lastShow = new Date();
1889 Roo.get(document).on("mouseup", onMouseDown);
1894 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1895 m.parentMenu.activeChild = m;
1896 }else if(last && last.isVisible()){
1897 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1902 function onBeforeHide(m){
1904 m.activeChild.hide();
1906 if(m.autoHideTimer){
1907 clearTimeout(m.autoHideTimer);
1908 delete m.autoHideTimer;
1913 function onBeforeShow(m){
1914 var pm = m.parentMenu;
1915 if(!pm && !m.allowOtherMenus){
1917 }else if(pm && pm.activeChild && active != m){
1918 pm.activeChild.hide();
1922 // private this should really trigger on mouseup..
1923 function onMouseDown(e){
1924 Roo.log("on Mouse Up");
1926 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1927 Roo.log("MenuManager hideAll");
1936 function onBeforeCheck(mi, state){
1938 var g = groups[mi.group];
1939 for(var i = 0, l = g.length; i < l; i++){
1941 g[i].setChecked(false);
1950 * Hides all menus that are currently visible
1952 hideAll : function(){
1957 register : function(menu){
1961 menus[menu.id] = menu;
1962 menu.on("beforehide", onBeforeHide);
1963 menu.on("hide", onHide);
1964 menu.on("beforeshow", onBeforeShow);
1965 menu.on("show", onShow);
1967 if(g && menu.events["checkchange"]){
1971 groups[g].push(menu);
1972 menu.on("checkchange", onCheck);
1977 * Returns a {@link Roo.menu.Menu} object
1978 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1979 * be used to generate and return a new Menu instance.
1981 get : function(menu){
1982 if(typeof menu == "string"){ // menu id
1984 }else if(menu.events){ // menu instance
1987 /*else if(typeof menu.length == 'number'){ // array of menu items?
1988 return new Roo.bootstrap.Menu({items:menu});
1989 }else{ // otherwise, must be a config
1990 return new Roo.bootstrap.Menu(menu);
1997 unregister : function(menu){
1998 delete menus[menu.id];
1999 menu.un("beforehide", onBeforeHide);
2000 menu.un("hide", onHide);
2001 menu.un("beforeshow", onBeforeShow);
2002 menu.un("show", onShow);
2004 if(g && menu.events["checkchange"]){
2005 groups[g].remove(menu);
2006 menu.un("checkchange", onCheck);
2011 registerCheckable : function(menuItem){
2012 var g = menuItem.group;
2017 groups[g].push(menuItem);
2018 menuItem.on("beforecheckchange", onBeforeCheck);
2023 unregisterCheckable : function(menuItem){
2024 var g = menuItem.group;
2026 groups[g].remove(menuItem);
2027 menuItem.un("beforecheckchange", onBeforeCheck);
2039 * @class Roo.bootstrap.Menu
2040 * @extends Roo.bootstrap.Component
2041 * Bootstrap Menu class - container for MenuItems
2042 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2043 * @cfg {bool} hidden if the menu should be hidden when rendered.
2044 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2045 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2049 * @param {Object} config The config object
2053 Roo.bootstrap.Menu = function(config){
2054 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2055 if (this.registerMenu && this.type != 'treeview') {
2056 Roo.bootstrap.MenuMgr.register(this);
2063 * Fires before this menu is displayed (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 c.cls += ' hidden-' + size;
6875 c.cls += ' col-' + size + '-' + config[size];
6885 renderBody : function()
6895 colspan : this.cm.getColumnCount()
6905 renderFooter : function()
6915 colspan : this.cm.getColumnCount()
6929 // Roo.log('ds onload');
6934 var ds = this.store;
6936 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6937 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6938 if (_this.store.sortInfo) {
6940 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6941 e.select('i', true).addClass(['glyphicon-arrow-up']);
6944 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6945 e.select('i', true).addClass(['glyphicon-arrow-down']);
6950 var tbody = this.mainBody;
6952 if(ds.getCount() > 0){
6953 ds.data.each(function(d,rowIndex){
6954 var row = this.renderRow(cm, ds, rowIndex);
6956 tbody.createChild(row);
6960 if(row.cellObjects.length){
6961 Roo.each(row.cellObjects, function(r){
6962 _this.renderCellObject(r);
6969 var tfoot = this.el.select('tfoot', true).first();
6971 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6973 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6975 var total = this.ds.getTotalCount();
6977 if(this.footer.pageSize < total){
6978 this.mainFoot.show();
6982 Roo.each(this.el.select('tbody td', true).elements, function(e){
6983 e.on('mouseover', _this.onMouseover, _this);
6986 Roo.each(this.el.select('tbody td', true).elements, function(e){
6987 e.on('mouseout', _this.onMouseout, _this);
6989 this.fireEvent('rowsrendered', this);
6995 onUpdate : function(ds,record)
6997 this.refreshRow(record);
7001 onRemove : function(ds, record, index, isUpdate){
7002 if(isUpdate !== true){
7003 this.fireEvent("beforerowremoved", this, index, record);
7005 var bt = this.mainBody.dom;
7007 var rows = this.el.select('tbody > tr', true).elements;
7009 if(typeof(rows[index]) != 'undefined'){
7010 bt.removeChild(rows[index].dom);
7013 // if(bt.rows[index]){
7014 // bt.removeChild(bt.rows[index]);
7017 if(isUpdate !== true){
7018 //this.stripeRows(index);
7019 //this.syncRowHeights(index, index);
7021 this.fireEvent("rowremoved", this, index, record);
7025 onAdd : function(ds, records, rowIndex)
7027 //Roo.log('on Add called');
7028 // - note this does not handle multiple adding very well..
7029 var bt = this.mainBody.dom;
7030 for (var i =0 ; i < records.length;i++) {
7031 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7032 //Roo.log(records[i]);
7033 //Roo.log(this.store.getAt(rowIndex+i));
7034 this.insertRow(this.store, rowIndex + i, false);
7041 refreshRow : function(record){
7042 var ds = this.store, index;
7043 if(typeof record == 'number'){
7045 record = ds.getAt(index);
7047 index = ds.indexOf(record);
7049 this.insertRow(ds, index, true);
7051 this.onRemove(ds, record, index+1, true);
7053 //this.syncRowHeights(index, index);
7055 this.fireEvent("rowupdated", this, index, record);
7058 insertRow : function(dm, rowIndex, isUpdate){
7061 this.fireEvent("beforerowsinserted", this, rowIndex);
7063 //var s = this.getScrollState();
7064 var row = this.renderRow(this.cm, this.store, rowIndex);
7065 // insert before rowIndex..
7066 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7070 if(row.cellObjects.length){
7071 Roo.each(row.cellObjects, function(r){
7072 _this.renderCellObject(r);
7077 this.fireEvent("rowsinserted", this, rowIndex);
7078 //this.syncRowHeights(firstRow, lastRow);
7079 //this.stripeRows(firstRow);
7086 getRowDom : function(rowIndex)
7088 var rows = this.el.select('tbody > tr', true).elements;
7090 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7093 // returns the object tree for a tr..
7096 renderRow : function(cm, ds, rowIndex)
7098 var d = ds.getAt(rowIndex);
7102 cls : 'x-row-' + rowIndex,
7106 var cellObjects = [];
7108 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7109 var config = cm.config[i];
7111 var renderer = cm.getRenderer(i);
7115 if(typeof(renderer) !== 'undefined'){
7116 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7118 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7119 // and are rendered into the cells after the row is rendered - using the id for the element.
7121 if(typeof(value) === 'object'){
7131 rowIndex : rowIndex,
7136 this.fireEvent('rowclass', this, rowcfg);
7140 cls : rowcfg.rowClass + ' x-col-' + i,
7142 html: (typeof(value) === 'object') ? '' : value
7149 if(typeof(config.colspan) != 'undefined'){
7150 td.colspan = config.colspan;
7153 if(typeof(config.hidden) != 'undefined' && config.hidden){
7154 td.style += ' display:none;';
7157 if(typeof(config.align) != 'undefined' && config.align.length){
7158 td.style += ' text-align:' + config.align + ';';
7160 if(typeof(config.valign) != 'undefined' && config.valign.length){
7161 td.style += ' vertical-align:' + config.valign + ';';
7164 if(typeof(config.width) != 'undefined'){
7165 td.style += ' width:' + config.width + 'px;';
7168 if(typeof(config.cursor) != 'undefined'){
7169 td.style += ' cursor:' + config.cursor + ';';
7172 if(typeof(config.cls) != 'undefined'){
7173 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7176 ['xs','sm','md','lg'].map(function(size){
7178 if(typeof(config[size]) == 'undefined'){
7182 if (!config[size]) { // 0 = hidden
7183 td.cls += ' hidden-' + size;
7187 td.cls += ' col-' + size + '-' + config[size];
7195 row.cellObjects = cellObjects;
7203 onBeforeLoad : function()
7212 this.el.select('tbody', true).first().dom.innerHTML = '';
7215 * Show or hide a row.
7216 * @param {Number} rowIndex to show or hide
7217 * @param {Boolean} state hide
7219 setRowVisibility : function(rowIndex, state)
7221 var bt = this.mainBody.dom;
7223 var rows = this.el.select('tbody > tr', true).elements;
7225 if(typeof(rows[rowIndex]) == 'undefined'){
7228 rows[rowIndex].dom.style.display = state ? '' : 'none';
7232 getSelectionModel : function(){
7234 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7236 return this.selModel;
7239 * Render the Roo.bootstrap object from renderder
7241 renderCellObject : function(r)
7245 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7247 var t = r.cfg.render(r.container);
7250 Roo.each(r.cfg.cn, function(c){
7252 container: t.getChildContainer(),
7255 _this.renderCellObject(child);
7260 getRowIndex : function(row)
7264 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7275 * Returns the grid's underlying element = used by panel.Grid
7276 * @return {Element} The element
7278 getGridEl : function(){
7282 * Forces a resize - used by panel.Grid
7283 * @return {Element} The element
7285 autoSize : function()
7287 //var ctr = Roo.get(this.container.dom.parentElement);
7288 var ctr = Roo.get(this.el.dom);
7290 var thd = this.getGridEl().select('thead',true).first();
7291 var tbd = this.getGridEl().select('tbody', true).first();
7292 var tfd = this.getGridEl().select('tfoot', true).first();
7294 var cw = ctr.getWidth();
7298 tbd.setSize(ctr.getWidth(),
7299 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7301 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7304 cw = Math.max(cw, this.totalWidth);
7305 this.getGridEl().select('tr',true).setWidth(cw);
7306 // resize 'expandable coloumn?
7308 return; // we doe not have a view in this design..
7311 onBodyScroll: function()
7313 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7315 this.mainHead.setStyle({
7316 'position' : 'relative',
7317 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7323 var scrollHeight = this.mainBody.dom.scrollHeight;
7325 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7327 var height = this.mainBody.getHeight();
7329 if(scrollHeight - height == scrollTop) {
7331 var total = this.ds.getTotalCount();
7333 if(this.footer.cursor + this.footer.pageSize < total){
7335 this.footer.ds.load({
7337 start : this.footer.cursor + this.footer.pageSize,
7338 limit : this.footer.pageSize
7348 onHeaderChange : function()
7350 var header = this.renderHeader();
7351 var table = this.el.select('table', true).first();
7353 this.mainHead.remove();
7354 this.mainHead = table.createChild(header, this.mainBody, false);
7357 onHiddenChange : function(colModel, colIndex, hidden)
7359 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7360 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7362 this.CSS.updateRule(thSelector, "display", "");
7363 this.CSS.updateRule(tdSelector, "display", "");
7366 this.CSS.updateRule(thSelector, "display", "none");
7367 this.CSS.updateRule(tdSelector, "display", "none");
7370 this.onHeaderChange();
7374 setColumnWidth: function(col_index, width)
7376 // width = "md-2 xs-2..."
7377 if(!this.colModel.config[col_index]) {
7381 var w = width.split(" ");
7383 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7385 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7388 for(var j = 0; j < w.length; j++) {
7394 var size_cls = w[j].split("-");
7396 if(!Number.isInteger(size_cls[1] * 1)) {
7400 if(!this.colModel.config[col_index][size_cls[0]]) {
7404 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7408 h_row[0].classList.replace(
7409 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7410 "col-"+size_cls[0]+"-"+size_cls[1]
7413 for(var i = 0; i < rows.length; i++) {
7415 var size_cls = w[j].split("-");
7417 if(!Number.isInteger(size_cls[1] * 1)) {
7421 if(!this.colModel.config[col_index][size_cls[0]]) {
7425 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7429 rows[i].classList.replace(
7430 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7431 "col-"+size_cls[0]+"-"+size_cls[1]
7435 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7450 * @class Roo.bootstrap.TableCell
7451 * @extends Roo.bootstrap.Component
7452 * Bootstrap TableCell class
7453 * @cfg {String} html cell contain text
7454 * @cfg {String} cls cell class
7455 * @cfg {String} tag cell tag (td|th) default td
7456 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7457 * @cfg {String} align Aligns the content in a cell
7458 * @cfg {String} axis Categorizes cells
7459 * @cfg {String} bgcolor Specifies the background color of a cell
7460 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7461 * @cfg {Number} colspan Specifies the number of columns a cell should span
7462 * @cfg {String} headers Specifies one or more header cells a cell is related to
7463 * @cfg {Number} height Sets the height of a cell
7464 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7465 * @cfg {Number} rowspan Sets the number of rows a cell should span
7466 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7467 * @cfg {String} valign Vertical aligns the content in a cell
7468 * @cfg {Number} width Specifies the width of a cell
7471 * Create a new TableCell
7472 * @param {Object} config The config object
7475 Roo.bootstrap.TableCell = function(config){
7476 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7479 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7499 getAutoCreate : function(){
7500 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7520 cfg.align=this.align
7526 cfg.bgcolor=this.bgcolor
7529 cfg.charoff=this.charoff
7532 cfg.colspan=this.colspan
7535 cfg.headers=this.headers
7538 cfg.height=this.height
7541 cfg.nowrap=this.nowrap
7544 cfg.rowspan=this.rowspan
7547 cfg.scope=this.scope
7550 cfg.valign=this.valign
7553 cfg.width=this.width
7572 * @class Roo.bootstrap.TableRow
7573 * @extends Roo.bootstrap.Component
7574 * Bootstrap TableRow class
7575 * @cfg {String} cls row class
7576 * @cfg {String} align Aligns the content in a table row
7577 * @cfg {String} bgcolor Specifies a background color for a table row
7578 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7579 * @cfg {String} valign Vertical aligns the content in a table row
7582 * Create a new TableRow
7583 * @param {Object} config The config object
7586 Roo.bootstrap.TableRow = function(config){
7587 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7590 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7598 getAutoCreate : function(){
7599 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7609 cfg.align = this.align;
7612 cfg.bgcolor = this.bgcolor;
7615 cfg.charoff = this.charoff;
7618 cfg.valign = this.valign;
7636 * @class Roo.bootstrap.TableBody
7637 * @extends Roo.bootstrap.Component
7638 * Bootstrap TableBody class
7639 * @cfg {String} cls element class
7640 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7641 * @cfg {String} align Aligns the content inside the element
7642 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7643 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7646 * Create a new TableBody
7647 * @param {Object} config The config object
7650 Roo.bootstrap.TableBody = function(config){
7651 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7654 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7662 getAutoCreate : function(){
7663 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7677 cfg.align = this.align;
7680 cfg.charoff = this.charoff;
7683 cfg.valign = this.valign;
7690 // initEvents : function()
7697 // this.store = Roo.factory(this.store, Roo.data);
7698 // this.store.on('load', this.onLoad, this);
7700 // this.store.load();
7704 // onLoad: function ()
7706 // this.fireEvent('load', this);
7716 * Ext JS Library 1.1.1
7717 * Copyright(c) 2006-2007, Ext JS, LLC.
7719 * Originally Released Under LGPL - original licence link has changed is not relivant.
7722 * <script type="text/javascript">
7725 // as we use this in bootstrap.
7726 Roo.namespace('Roo.form');
7728 * @class Roo.form.Action
7729 * Internal Class used to handle form actions
7731 * @param {Roo.form.BasicForm} el The form element or its id
7732 * @param {Object} config Configuration options
7737 // define the action interface
7738 Roo.form.Action = function(form, options){
7740 this.options = options || {};
7743 * Client Validation Failed
7746 Roo.form.Action.CLIENT_INVALID = 'client';
7748 * Server Validation Failed
7751 Roo.form.Action.SERVER_INVALID = 'server';
7753 * Connect to Server Failed
7756 Roo.form.Action.CONNECT_FAILURE = 'connect';
7758 * Reading Data from Server Failed
7761 Roo.form.Action.LOAD_FAILURE = 'load';
7763 Roo.form.Action.prototype = {
7765 failureType : undefined,
7766 response : undefined,
7770 run : function(options){
7775 success : function(response){
7780 handleResponse : function(response){
7784 // default connection failure
7785 failure : function(response){
7787 this.response = response;
7788 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7789 this.form.afterAction(this, false);
7792 processResponse : function(response){
7793 this.response = response;
7794 if(!response.responseText){
7797 this.result = this.handleResponse(response);
7801 // utility functions used internally
7802 getUrl : function(appendParams){
7803 var url = this.options.url || this.form.url || this.form.el.dom.action;
7805 var p = this.getParams();
7807 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7813 getMethod : function(){
7814 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7817 getParams : function(){
7818 var bp = this.form.baseParams;
7819 var p = this.options.params;
7821 if(typeof p == "object"){
7822 p = Roo.urlEncode(Roo.applyIf(p, bp));
7823 }else if(typeof p == 'string' && bp){
7824 p += '&' + Roo.urlEncode(bp);
7827 p = Roo.urlEncode(bp);
7832 createCallback : function(){
7834 success: this.success,
7835 failure: this.failure,
7837 timeout: (this.form.timeout*1000),
7838 upload: this.form.fileUpload ? this.success : undefined
7843 Roo.form.Action.Submit = function(form, options){
7844 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7847 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7850 haveProgress : false,
7851 uploadComplete : false,
7853 // uploadProgress indicator.
7854 uploadProgress : function()
7856 if (!this.form.progressUrl) {
7860 if (!this.haveProgress) {
7861 Roo.MessageBox.progress("Uploading", "Uploading");
7863 if (this.uploadComplete) {
7864 Roo.MessageBox.hide();
7868 this.haveProgress = true;
7870 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7872 var c = new Roo.data.Connection();
7874 url : this.form.progressUrl,
7879 success : function(req){
7880 //console.log(data);
7884 rdata = Roo.decode(req.responseText)
7886 Roo.log("Invalid data from server..");
7890 if (!rdata || !rdata.success) {
7892 Roo.MessageBox.alert(Roo.encode(rdata));
7895 var data = rdata.data;
7897 if (this.uploadComplete) {
7898 Roo.MessageBox.hide();
7903 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7904 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7907 this.uploadProgress.defer(2000,this);
7910 failure: function(data) {
7911 Roo.log('progress url failed ');
7922 // run get Values on the form, so it syncs any secondary forms.
7923 this.form.getValues();
7925 var o = this.options;
7926 var method = this.getMethod();
7927 var isPost = method == 'POST';
7928 if(o.clientValidation === false || this.form.isValid()){
7930 if (this.form.progressUrl) {
7931 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7932 (new Date() * 1) + '' + Math.random());
7937 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7938 form:this.form.el.dom,
7939 url:this.getUrl(!isPost),
7941 params:isPost ? this.getParams() : null,
7942 isUpload: this.form.fileUpload,
7943 formData : this.form.formData
7946 this.uploadProgress();
7948 }else if (o.clientValidation !== false){ // client validation failed
7949 this.failureType = Roo.form.Action.CLIENT_INVALID;
7950 this.form.afterAction(this, false);
7954 success : function(response)
7956 this.uploadComplete= true;
7957 if (this.haveProgress) {
7958 Roo.MessageBox.hide();
7962 var result = this.processResponse(response);
7963 if(result === true || result.success){
7964 this.form.afterAction(this, true);
7968 this.form.markInvalid(result.errors);
7969 this.failureType = Roo.form.Action.SERVER_INVALID;
7971 this.form.afterAction(this, false);
7973 failure : function(response)
7975 this.uploadComplete= true;
7976 if (this.haveProgress) {
7977 Roo.MessageBox.hide();
7980 this.response = response;
7981 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7982 this.form.afterAction(this, false);
7985 handleResponse : function(response){
7986 if(this.form.errorReader){
7987 var rs = this.form.errorReader.read(response);
7990 for(var i = 0, len = rs.records.length; i < len; i++) {
7991 var r = rs.records[i];
7995 if(errors.length < 1){
7999 success : rs.success,
8005 ret = Roo.decode(response.responseText);
8009 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
8019 Roo.form.Action.Load = function(form, options){
8020 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
8021 this.reader = this.form.reader;
8024 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8029 Roo.Ajax.request(Roo.apply(
8030 this.createCallback(), {
8031 method:this.getMethod(),
8032 url:this.getUrl(false),
8033 params:this.getParams()
8037 success : function(response){
8039 var result = this.processResponse(response);
8040 if(result === true || !result.success || !result.data){
8041 this.failureType = Roo.form.Action.LOAD_FAILURE;
8042 this.form.afterAction(this, false);
8045 this.form.clearInvalid();
8046 this.form.setValues(result.data);
8047 this.form.afterAction(this, true);
8050 handleResponse : function(response){
8051 if(this.form.reader){
8052 var rs = this.form.reader.read(response);
8053 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8055 success : rs.success,
8059 return Roo.decode(response.responseText);
8063 Roo.form.Action.ACTION_TYPES = {
8064 'load' : Roo.form.Action.Load,
8065 'submit' : Roo.form.Action.Submit
8074 * @class Roo.bootstrap.Form
8075 * @extends Roo.bootstrap.Component
8076 * Bootstrap Form class
8077 * @cfg {String} method GET | POST (default POST)
8078 * @cfg {String} labelAlign top | left (default top)
8079 * @cfg {String} align left | right - for navbars
8080 * @cfg {Boolean} loadMask load mask when submit (default true)
8085 * @param {Object} config The config object
8089 Roo.bootstrap.Form = function(config){
8091 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8093 Roo.bootstrap.Form.popover.apply();
8097 * @event clientvalidation
8098 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8099 * @param {Form} this
8100 * @param {Boolean} valid true if the form has passed client-side validation
8102 clientvalidation: true,
8104 * @event beforeaction
8105 * Fires before any action is performed. Return false to cancel the action.
8106 * @param {Form} this
8107 * @param {Action} action The action to be performed
8111 * @event actionfailed
8112 * Fires when an action fails.
8113 * @param {Form} this
8114 * @param {Action} action The action that failed
8116 actionfailed : true,
8118 * @event actioncomplete
8119 * Fires when an action is completed.
8120 * @param {Form} this
8121 * @param {Action} action The action that completed
8123 actioncomplete : true
8127 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8130 * @cfg {String} method
8131 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8136 * The URL to use for form actions if one isn't supplied in the action options.
8139 * @cfg {Boolean} fileUpload
8140 * Set to true if this form is a file upload.
8144 * @cfg {Object} baseParams
8145 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8149 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8153 * @cfg {Sting} align (left|right) for navbar forms
8158 activeAction : null,
8161 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8162 * element by passing it or its id or mask the form itself by passing in true.
8165 waitMsgTarget : false,
8170 * @cfg {Boolean} errorMask (true|false) default false
8175 * @cfg {Number} maskOffset Default 100
8180 * @cfg {Boolean} maskBody
8184 getAutoCreate : function(){
8188 method : this.method || 'POST',
8189 id : this.id || Roo.id(),
8192 if (this.parent().xtype.match(/^Nav/)) {
8193 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8197 if (this.labelAlign == 'left' ) {
8198 cfg.cls += ' form-horizontal';
8204 initEvents : function()
8206 this.el.on('submit', this.onSubmit, this);
8207 // this was added as random key presses on the form where triggering form submit.
8208 this.el.on('keypress', function(e) {
8209 if (e.getCharCode() != 13) {
8212 // we might need to allow it for textareas.. and some other items.
8213 // check e.getTarget().
8215 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8219 Roo.log("keypress blocked");
8227 onSubmit : function(e){
8232 * Returns true if client-side validation on the form is successful.
8235 isValid : function(){
8236 var items = this.getItems();
8240 items.each(function(f){
8246 Roo.log('invalid field: ' + f.name);
8250 if(!target && f.el.isVisible(true)){
8256 if(this.errorMask && !valid){
8257 Roo.bootstrap.Form.popover.mask(this, target);
8264 * Returns true if any fields in this form have changed since their original load.
8267 isDirty : function(){
8269 var items = this.getItems();
8270 items.each(function(f){
8280 * Performs a predefined action (submit or load) or custom actions you define on this form.
8281 * @param {String} actionName The name of the action type
8282 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8283 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8284 * accept other config options):
8286 Property Type Description
8287 ---------------- --------------- ----------------------------------------------------------------------------------
8288 url String The url for the action (defaults to the form's url)
8289 method String The form method to use (defaults to the form's method, or POST if not defined)
8290 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8291 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8292 validate the form on the client (defaults to false)
8294 * @return {BasicForm} this
8296 doAction : function(action, options){
8297 if(typeof action == 'string'){
8298 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8300 if(this.fireEvent('beforeaction', this, action) !== false){
8301 this.beforeAction(action);
8302 action.run.defer(100, action);
8308 beforeAction : function(action){
8309 var o = action.options;
8314 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8316 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8319 // not really supported yet.. ??
8321 //if(this.waitMsgTarget === true){
8322 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8323 //}else if(this.waitMsgTarget){
8324 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8325 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8327 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8333 afterAction : function(action, success){
8334 this.activeAction = null;
8335 var o = action.options;
8340 Roo.get(document.body).unmask();
8346 //if(this.waitMsgTarget === true){
8347 // this.el.unmask();
8348 //}else if(this.waitMsgTarget){
8349 // this.waitMsgTarget.unmask();
8351 // Roo.MessageBox.updateProgress(1);
8352 // Roo.MessageBox.hide();
8359 Roo.callback(o.success, o.scope, [this, action]);
8360 this.fireEvent('actioncomplete', this, action);
8364 // failure condition..
8365 // we have a scenario where updates need confirming.
8366 // eg. if a locking scenario exists..
8367 // we look for { errors : { needs_confirm : true }} in the response.
8369 (typeof(action.result) != 'undefined') &&
8370 (typeof(action.result.errors) != 'undefined') &&
8371 (typeof(action.result.errors.needs_confirm) != 'undefined')
8374 Roo.log("not supported yet");
8377 Roo.MessageBox.confirm(
8378 "Change requires confirmation",
8379 action.result.errorMsg,
8384 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8394 Roo.callback(o.failure, o.scope, [this, action]);
8395 // show an error message if no failed handler is set..
8396 if (!this.hasListener('actionfailed')) {
8397 Roo.log("need to add dialog support");
8399 Roo.MessageBox.alert("Error",
8400 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8401 action.result.errorMsg :
8402 "Saving Failed, please check your entries or try again"
8407 this.fireEvent('actionfailed', this, action);
8412 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8413 * @param {String} id The value to search for
8416 findField : function(id){
8417 var items = this.getItems();
8418 var field = items.get(id);
8420 items.each(function(f){
8421 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8428 return field || null;
8431 * Mark fields in this form invalid in bulk.
8432 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8433 * @return {BasicForm} this
8435 markInvalid : function(errors){
8436 if(errors instanceof Array){
8437 for(var i = 0, len = errors.length; i < len; i++){
8438 var fieldError = errors[i];
8439 var f = this.findField(fieldError.id);
8441 f.markInvalid(fieldError.msg);
8447 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8448 field.markInvalid(errors[id]);
8452 //Roo.each(this.childForms || [], function (f) {
8453 // f.markInvalid(errors);
8460 * Set values for fields in this form in bulk.
8461 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8462 * @return {BasicForm} this
8464 setValues : function(values){
8465 if(values instanceof Array){ // array of objects
8466 for(var i = 0, len = values.length; i < len; i++){
8468 var f = this.findField(v.id);
8470 f.setValue(v.value);
8471 if(this.trackResetOnLoad){
8472 f.originalValue = f.getValue();
8476 }else{ // object hash
8479 if(typeof values[id] != 'function' && (field = this.findField(id))){
8481 if (field.setFromData &&
8483 field.displayField &&
8484 // combos' with local stores can
8485 // be queried via setValue()
8486 // to set their value..
8487 (field.store && !field.store.isLocal)
8491 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8492 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8493 field.setFromData(sd);
8495 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8497 field.setFromData(values);
8500 field.setValue(values[id]);
8504 if(this.trackResetOnLoad){
8505 field.originalValue = field.getValue();
8511 //Roo.each(this.childForms || [], function (f) {
8512 // f.setValues(values);
8519 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8520 * they are returned as an array.
8521 * @param {Boolean} asString
8524 getValues : function(asString){
8525 //if (this.childForms) {
8526 // copy values from the child forms
8527 // Roo.each(this.childForms, function (f) {
8528 // this.setValues(f.getValues());
8534 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8535 if(asString === true){
8538 return Roo.urlDecode(fs);
8542 * Returns the fields in this form as an object with key/value pairs.
8543 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8546 getFieldValues : function(with_hidden)
8548 var items = this.getItems();
8550 items.each(function(f){
8556 var v = f.getValue();
8558 if (f.inputType =='radio') {
8559 if (typeof(ret[f.getName()]) == 'undefined') {
8560 ret[f.getName()] = ''; // empty..
8563 if (!f.el.dom.checked) {
8571 if(f.xtype == 'MoneyField'){
8572 ret[f.currencyName] = f.getCurrency();
8575 // not sure if this supported any more..
8576 if ((typeof(v) == 'object') && f.getRawValue) {
8577 v = f.getRawValue() ; // dates..
8579 // combo boxes where name != hiddenName...
8580 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8581 ret[f.name] = f.getRawValue();
8583 ret[f.getName()] = v;
8590 * Clears all invalid messages in this form.
8591 * @return {BasicForm} this
8593 clearInvalid : function(){
8594 var items = this.getItems();
8596 items.each(function(f){
8605 * @return {BasicForm} this
8608 var items = this.getItems();
8609 items.each(function(f){
8613 Roo.each(this.childForms || [], function (f) {
8621 getItems : function()
8623 var r=new Roo.util.MixedCollection(false, function(o){
8624 return o.id || (o.id = Roo.id());
8626 var iter = function(el) {
8633 Roo.each(el.items,function(e) {
8642 hideFields : function(items)
8644 Roo.each(items, function(i){
8646 var f = this.findField(i);
8657 showFields : function(items)
8659 Roo.each(items, function(i){
8661 var f = this.findField(i);
8674 Roo.apply(Roo.bootstrap.Form, {
8701 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8702 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8703 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8704 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8707 this.maskEl.top.enableDisplayMode("block");
8708 this.maskEl.left.enableDisplayMode("block");
8709 this.maskEl.bottom.enableDisplayMode("block");
8710 this.maskEl.right.enableDisplayMode("block");
8712 this.toolTip = new Roo.bootstrap.Tooltip({
8713 cls : 'roo-form-error-popover',
8715 'left' : ['r-l', [-2,0], 'right'],
8716 'right' : ['l-r', [2,0], 'left'],
8717 'bottom' : ['tl-bl', [0,2], 'top'],
8718 'top' : [ 'bl-tl', [0,-2], 'bottom']
8722 this.toolTip.render(Roo.get(document.body));
8724 this.toolTip.el.enableDisplayMode("block");
8726 Roo.get(document.body).on('click', function(){
8730 Roo.get(document.body).on('touchstart', function(){
8734 this.isApplied = true
8737 mask : function(form, target)
8741 this.target = target;
8743 if(!this.form.errorMask || !target.el){
8747 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8749 Roo.log(scrollable);
8751 var ot = this.target.el.calcOffsetsTo(scrollable);
8753 var scrollTo = ot[1] - this.form.maskOffset;
8755 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8757 scrollable.scrollTo('top', scrollTo);
8759 var box = this.target.el.getBox();
8761 var zIndex = Roo.bootstrap.Modal.zIndex++;
8764 this.maskEl.top.setStyle('position', 'absolute');
8765 this.maskEl.top.setStyle('z-index', zIndex);
8766 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8767 this.maskEl.top.setLeft(0);
8768 this.maskEl.top.setTop(0);
8769 this.maskEl.top.show();
8771 this.maskEl.left.setStyle('position', 'absolute');
8772 this.maskEl.left.setStyle('z-index', zIndex);
8773 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8774 this.maskEl.left.setLeft(0);
8775 this.maskEl.left.setTop(box.y - this.padding);
8776 this.maskEl.left.show();
8778 this.maskEl.bottom.setStyle('position', 'absolute');
8779 this.maskEl.bottom.setStyle('z-index', zIndex);
8780 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8781 this.maskEl.bottom.setLeft(0);
8782 this.maskEl.bottom.setTop(box.bottom + this.padding);
8783 this.maskEl.bottom.show();
8785 this.maskEl.right.setStyle('position', 'absolute');
8786 this.maskEl.right.setStyle('z-index', zIndex);
8787 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8788 this.maskEl.right.setLeft(box.right + this.padding);
8789 this.maskEl.right.setTop(box.y - this.padding);
8790 this.maskEl.right.show();
8792 this.toolTip.bindEl = this.target.el;
8794 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8796 var tip = this.target.blankText;
8798 if(this.target.getValue() !== '' ) {
8800 if (this.target.invalidText.length) {
8801 tip = this.target.invalidText;
8802 } else if (this.target.regexText.length){
8803 tip = this.target.regexText;
8807 this.toolTip.show(tip);
8809 this.intervalID = window.setInterval(function() {
8810 Roo.bootstrap.Form.popover.unmask();
8813 window.onwheel = function(){ return false;};
8815 (function(){ this.isMasked = true; }).defer(500, this);
8821 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8825 this.maskEl.top.setStyle('position', 'absolute');
8826 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8827 this.maskEl.top.hide();
8829 this.maskEl.left.setStyle('position', 'absolute');
8830 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8831 this.maskEl.left.hide();
8833 this.maskEl.bottom.setStyle('position', 'absolute');
8834 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8835 this.maskEl.bottom.hide();
8837 this.maskEl.right.setStyle('position', 'absolute');
8838 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8839 this.maskEl.right.hide();
8841 this.toolTip.hide();
8843 this.toolTip.el.hide();
8845 window.onwheel = function(){ return true;};
8847 if(this.intervalID){
8848 window.clearInterval(this.intervalID);
8849 this.intervalID = false;
8852 this.isMasked = false;
8862 * Ext JS Library 1.1.1
8863 * Copyright(c) 2006-2007, Ext JS, LLC.
8865 * Originally Released Under LGPL - original licence link has changed is not relivant.
8868 * <script type="text/javascript">
8871 * @class Roo.form.VTypes
8872 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8875 Roo.form.VTypes = function(){
8876 // closure these in so they are only created once.
8877 var alpha = /^[a-zA-Z_]+$/;
8878 var alphanum = /^[a-zA-Z0-9_]+$/;
8879 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8880 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8882 // All these messages and functions are configurable
8885 * The function used to validate email addresses
8886 * @param {String} value The email address
8888 'email' : function(v){
8889 return email.test(v);
8892 * The error text to display when the email validation function returns false
8895 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8897 * The keystroke filter mask to be applied on email input
8900 'emailMask' : /[a-z0-9_\.\-@]/i,
8903 * The function used to validate URLs
8904 * @param {String} value The URL
8906 'url' : function(v){
8910 * The error text to display when the url validation function returns false
8913 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8916 * The function used to validate alpha values
8917 * @param {String} value The value
8919 'alpha' : function(v){
8920 return alpha.test(v);
8923 * The error text to display when the alpha validation function returns false
8926 'alphaText' : 'This field should only contain letters and _',
8928 * The keystroke filter mask to be applied on alpha input
8931 'alphaMask' : /[a-z_]/i,
8934 * The function used to validate alphanumeric values
8935 * @param {String} value The value
8937 'alphanum' : function(v){
8938 return alphanum.test(v);
8941 * The error text to display when the alphanumeric validation function returns false
8944 'alphanumText' : 'This field should only contain letters, numbers and _',
8946 * The keystroke filter mask to be applied on alphanumeric input
8949 'alphanumMask' : /[a-z0-9_]/i
8959 * @class Roo.bootstrap.Input
8960 * @extends Roo.bootstrap.Component
8961 * Bootstrap Input class
8962 * @cfg {Boolean} disabled is it disabled
8963 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8964 * @cfg {String} name name of the input
8965 * @cfg {string} fieldLabel - the label associated
8966 * @cfg {string} placeholder - placeholder to put in text.
8967 * @cfg {string} before - input group add on before
8968 * @cfg {string} after - input group add on after
8969 * @cfg {string} size - (lg|sm) or leave empty..
8970 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8971 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8972 * @cfg {Number} md colspan out of 12 for computer-sized screens
8973 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8974 * @cfg {string} value default value of the input
8975 * @cfg {Number} labelWidth set the width of label
8976 * @cfg {Number} labellg set the width of label (1-12)
8977 * @cfg {Number} labelmd set the width of label (1-12)
8978 * @cfg {Number} labelsm set the width of label (1-12)
8979 * @cfg {Number} labelxs set the width of label (1-12)
8980 * @cfg {String} labelAlign (top|left)
8981 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8982 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8983 * @cfg {String} indicatorpos (left|right) default left
8984 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8985 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8987 * @cfg {String} align (left|center|right) Default left
8988 * @cfg {Boolean} forceFeedback (true|false) Default false
8991 * Create a new Input
8992 * @param {Object} config The config object
8995 Roo.bootstrap.Input = function(config){
8997 Roo.bootstrap.Input.superclass.constructor.call(this, config);
9002 * Fires when this field receives input focus.
9003 * @param {Roo.form.Field} this
9008 * Fires when this field loses input focus.
9009 * @param {Roo.form.Field} this
9014 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
9015 * {@link Roo.EventObject#getKey} to determine which key was pressed.
9016 * @param {Roo.form.Field} this
9017 * @param {Roo.EventObject} e The event object
9022 * Fires just before the field blurs if the field value has changed.
9023 * @param {Roo.form.Field} this
9024 * @param {Mixed} newValue The new value
9025 * @param {Mixed} oldValue The original value
9030 * Fires after the field has been marked as invalid.
9031 * @param {Roo.form.Field} this
9032 * @param {String} msg The validation message
9037 * Fires after the field has been validated with no errors.
9038 * @param {Roo.form.Field} this
9043 * Fires after the key up
9044 * @param {Roo.form.Field} this
9045 * @param {Roo.EventObject} e The event Object
9051 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9053 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9054 automatic validation (defaults to "keyup").
9056 validationEvent : "keyup",
9058 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9060 validateOnBlur : true,
9062 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9064 validationDelay : 250,
9066 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9068 focusClass : "x-form-focus", // not needed???
9072 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9074 invalidClass : "has-warning",
9077 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9079 validClass : "has-success",
9082 * @cfg {Boolean} hasFeedback (true|false) default true
9087 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9089 invalidFeedbackClass : "glyphicon-warning-sign",
9092 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9094 validFeedbackClass : "glyphicon-ok",
9097 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9099 selectOnFocus : false,
9102 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9106 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9111 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9113 disableKeyFilter : false,
9116 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9120 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9124 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9126 blankText : "Please complete this mandatory field",
9129 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9133 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9135 maxLength : Number.MAX_VALUE,
9137 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9139 minLengthText : "The minimum length for this field is {0}",
9141 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9143 maxLengthText : "The maximum length for this field is {0}",
9147 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9148 * If available, this function will be called only after the basic validators all return true, and will be passed the
9149 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9153 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9154 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9155 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9159 * @cfg {String} regexText -- Depricated - use Invalid Text
9164 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9170 autocomplete: false,
9189 formatedValue : false,
9190 forceFeedback : false,
9192 indicatorpos : 'left',
9202 parentLabelAlign : function()
9205 while (parent.parent()) {
9206 parent = parent.parent();
9207 if (typeof(parent.labelAlign) !='undefined') {
9208 return parent.labelAlign;
9215 getAutoCreate : function()
9217 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9223 if(this.inputType != 'hidden'){
9224 cfg.cls = 'form-group' //input-group
9230 type : this.inputType,
9232 cls : 'form-control',
9233 placeholder : this.placeholder || '',
9234 autocomplete : this.autocomplete || 'new-password'
9237 if(this.capture.length){
9238 input.capture = this.capture;
9241 if(this.accept.length){
9242 input.accept = this.accept + "/*";
9246 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9249 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9250 input.maxLength = this.maxLength;
9253 if (this.disabled) {
9254 input.disabled=true;
9257 if (this.readOnly) {
9258 input.readonly=true;
9262 input.name = this.name;
9266 input.cls += ' input-' + this.size;
9270 ['xs','sm','md','lg'].map(function(size){
9271 if (settings[size]) {
9272 cfg.cls += ' col-' + size + '-' + settings[size];
9276 var inputblock = input;
9280 cls: 'glyphicon form-control-feedback'
9283 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9286 cls : 'has-feedback',
9294 if (this.before || this.after) {
9297 cls : 'input-group',
9301 if (this.before && typeof(this.before) == 'string') {
9303 inputblock.cn.push({
9305 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9309 if (this.before && typeof(this.before) == 'object') {
9310 this.before = Roo.factory(this.before);
9312 inputblock.cn.push({
9314 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9315 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9319 inputblock.cn.push(input);
9321 if (this.after && typeof(this.after) == 'string') {
9322 inputblock.cn.push({
9324 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9328 if (this.after && typeof(this.after) == 'object') {
9329 this.after = Roo.factory(this.after);
9331 inputblock.cn.push({
9333 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9334 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9338 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9339 inputblock.cls += ' has-feedback';
9340 inputblock.cn.push(feedback);
9345 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9346 tooltip : 'This field is required'
9348 if (Roo.bootstrap.version == 4) {
9351 style : 'display-none'
9354 if (align ==='left' && this.fieldLabel.length) {
9356 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9363 cls : 'control-label col-form-label',
9364 html : this.fieldLabel
9375 var labelCfg = cfg.cn[1];
9376 var contentCfg = cfg.cn[2];
9378 if(this.indicatorpos == 'right'){
9383 cls : 'control-label col-form-label',
9387 html : this.fieldLabel
9401 labelCfg = cfg.cn[0];
9402 contentCfg = cfg.cn[1];
9406 if(this.labelWidth > 12){
9407 labelCfg.style = "width: " + this.labelWidth + 'px';
9410 if(this.labelWidth < 13 && this.labelmd == 0){
9411 this.labelmd = this.labelWidth;
9414 if(this.labellg > 0){
9415 labelCfg.cls += ' col-lg-' + this.labellg;
9416 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9419 if(this.labelmd > 0){
9420 labelCfg.cls += ' col-md-' + this.labelmd;
9421 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9424 if(this.labelsm > 0){
9425 labelCfg.cls += ' col-sm-' + this.labelsm;
9426 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9429 if(this.labelxs > 0){
9430 labelCfg.cls += ' col-xs-' + this.labelxs;
9431 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9435 } else if ( this.fieldLabel.length) {
9440 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9441 tooltip : 'This field is required'
9445 //cls : 'input-group-addon',
9446 html : this.fieldLabel
9454 if(this.indicatorpos == 'right'){
9459 //cls : 'input-group-addon',
9460 html : this.fieldLabel
9465 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9466 tooltip : 'This field is required'
9486 if (this.parentType === 'Navbar' && this.parent().bar) {
9487 cfg.cls += ' navbar-form';
9490 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9491 // on BS4 we do this only if not form
9492 cfg.cls += ' navbar-form';
9500 * return the real input element.
9502 inputEl: function ()
9504 return this.el.select('input.form-control',true).first();
9507 tooltipEl : function()
9509 return this.inputEl();
9512 indicatorEl : function()
9514 if (Roo.bootstrap.version == 4) {
9515 return false; // not enabled in v4 yet.
9518 var indicator = this.el.select('i.roo-required-indicator',true).first();
9528 setDisabled : function(v)
9530 var i = this.inputEl().dom;
9532 i.removeAttribute('disabled');
9536 i.setAttribute('disabled','true');
9538 initEvents : function()
9541 this.inputEl().on("keydown" , this.fireKey, this);
9542 this.inputEl().on("focus", this.onFocus, this);
9543 this.inputEl().on("blur", this.onBlur, this);
9545 this.inputEl().relayEvent('keyup', this);
9547 this.indicator = this.indicatorEl();
9550 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9553 // reference to original value for reset
9554 this.originalValue = this.getValue();
9555 //Roo.form.TextField.superclass.initEvents.call(this);
9556 if(this.validationEvent == 'keyup'){
9557 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9558 this.inputEl().on('keyup', this.filterValidation, this);
9560 else if(this.validationEvent !== false){
9561 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9564 if(this.selectOnFocus){
9565 this.on("focus", this.preFocus, this);
9568 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9569 this.inputEl().on("keypress", this.filterKeys, this);
9571 this.inputEl().relayEvent('keypress', this);
9574 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9575 this.el.on("click", this.autoSize, this);
9578 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9579 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9582 if (typeof(this.before) == 'object') {
9583 this.before.render(this.el.select('.roo-input-before',true).first());
9585 if (typeof(this.after) == 'object') {
9586 this.after.render(this.el.select('.roo-input-after',true).first());
9589 this.inputEl().on('change', this.onChange, this);
9592 filterValidation : function(e){
9593 if(!e.isNavKeyPress()){
9594 this.validationTask.delay(this.validationDelay);
9598 * Validates the field value
9599 * @return {Boolean} True if the value is valid, else false
9601 validate : function(){
9602 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9603 if(this.disabled || this.validateValue(this.getRawValue())){
9614 * Validates a value according to the field's validation rules and marks the field as invalid
9615 * if the validation fails
9616 * @param {Mixed} value The value to validate
9617 * @return {Boolean} True if the value is valid, else false
9619 validateValue : function(value)
9621 if(this.getVisibilityEl().hasClass('hidden')){
9625 if(value.length < 1) { // if it's blank
9626 if(this.allowBlank){
9632 if(value.length < this.minLength){
9635 if(value.length > this.maxLength){
9639 var vt = Roo.form.VTypes;
9640 if(!vt[this.vtype](value, this)){
9644 if(typeof this.validator == "function"){
9645 var msg = this.validator(value);
9649 if (typeof(msg) == 'string') {
9650 this.invalidText = msg;
9654 if(this.regex && !this.regex.test(value)){
9662 fireKey : function(e){
9663 //Roo.log('field ' + e.getKey());
9664 if(e.isNavKeyPress()){
9665 this.fireEvent("specialkey", this, e);
9668 focus : function (selectText){
9670 this.inputEl().focus();
9671 if(selectText === true){
9672 this.inputEl().dom.select();
9678 onFocus : function(){
9679 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9680 // this.el.addClass(this.focusClass);
9683 this.hasFocus = true;
9684 this.startValue = this.getValue();
9685 this.fireEvent("focus", this);
9689 beforeBlur : Roo.emptyFn,
9693 onBlur : function(){
9695 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9696 //this.el.removeClass(this.focusClass);
9698 this.hasFocus = false;
9699 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9702 var v = this.getValue();
9703 if(String(v) !== String(this.startValue)){
9704 this.fireEvent('change', this, v, this.startValue);
9706 this.fireEvent("blur", this);
9709 onChange : function(e)
9711 var v = this.getValue();
9712 if(String(v) !== String(this.startValue)){
9713 this.fireEvent('change', this, v, this.startValue);
9719 * Resets the current field value to the originally loaded value and clears any validation messages
9722 this.setValue(this.originalValue);
9726 * Returns the name of the field
9727 * @return {Mixed} name The name field
9729 getName: function(){
9733 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9734 * @return {Mixed} value The field value
9736 getValue : function(){
9738 var v = this.inputEl().getValue();
9743 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9744 * @return {Mixed} value The field value
9746 getRawValue : function(){
9747 var v = this.inputEl().getValue();
9753 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9754 * @param {Mixed} value The value to set
9756 setRawValue : function(v){
9757 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9760 selectText : function(start, end){
9761 var v = this.getRawValue();
9763 start = start === undefined ? 0 : start;
9764 end = end === undefined ? v.length : end;
9765 var d = this.inputEl().dom;
9766 if(d.setSelectionRange){
9767 d.setSelectionRange(start, end);
9768 }else if(d.createTextRange){
9769 var range = d.createTextRange();
9770 range.moveStart("character", start);
9771 range.moveEnd("character", v.length-end);
9778 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9779 * @param {Mixed} value The value to set
9781 setValue : function(v){
9784 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9790 processValue : function(value){
9791 if(this.stripCharsRe){
9792 var newValue = value.replace(this.stripCharsRe, '');
9793 if(newValue !== value){
9794 this.setRawValue(newValue);
9801 preFocus : function(){
9803 if(this.selectOnFocus){
9804 this.inputEl().dom.select();
9807 filterKeys : function(e){
9809 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9812 var c = e.getCharCode(), cc = String.fromCharCode(c);
9813 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9816 if(!this.maskRe.test(cc)){
9821 * Clear any invalid styles/messages for this field
9823 clearInvalid : function(){
9825 if(!this.el || this.preventMark){ // not rendered
9830 this.el.removeClass([this.invalidClass, 'is-invalid']);
9832 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9834 var feedback = this.el.select('.form-control-feedback', true).first();
9837 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9843 this.indicator.removeClass('visible');
9844 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9847 this.fireEvent('valid', this);
9851 * Mark this field as valid
9853 markValid : function()
9855 if(!this.el || this.preventMark){ // not rendered...
9859 this.el.removeClass([this.invalidClass, this.validClass]);
9860 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9862 var feedback = this.el.select('.form-control-feedback', true).first();
9865 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9869 this.indicator.removeClass('visible');
9870 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9877 if(this.allowBlank && !this.getRawValue().length){
9880 if (Roo.bootstrap.version == 3) {
9881 this.el.addClass(this.validClass);
9883 this.inputEl().addClass('is-valid');
9886 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9888 var feedback = this.el.select('.form-control-feedback', true).first();
9891 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9892 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9897 this.fireEvent('valid', this);
9901 * Mark this field as invalid
9902 * @param {String} msg The validation message
9904 markInvalid : function(msg)
9906 if(!this.el || this.preventMark){ // not rendered
9910 this.el.removeClass([this.invalidClass, this.validClass]);
9911 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9913 var feedback = this.el.select('.form-control-feedback', true).first();
9916 this.el.select('.form-control-feedback', true).first().removeClass(
9917 [this.invalidFeedbackClass, this.validFeedbackClass]);
9924 if(this.allowBlank && !this.getRawValue().length){
9929 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9930 this.indicator.addClass('visible');
9932 if (Roo.bootstrap.version == 3) {
9933 this.el.addClass(this.invalidClass);
9935 this.inputEl().addClass('is-invalid');
9940 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9942 var feedback = this.el.select('.form-control-feedback', true).first();
9945 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9947 if(this.getValue().length || this.forceFeedback){
9948 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9955 this.fireEvent('invalid', this, msg);
9958 SafariOnKeyDown : function(event)
9960 // this is a workaround for a password hang bug on chrome/ webkit.
9961 if (this.inputEl().dom.type != 'password') {
9965 var isSelectAll = false;
9967 if(this.inputEl().dom.selectionEnd > 0){
9968 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9970 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9971 event.preventDefault();
9976 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9978 event.preventDefault();
9979 // this is very hacky as keydown always get's upper case.
9981 var cc = String.fromCharCode(event.getCharCode());
9982 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9986 adjustWidth : function(tag, w){
9987 tag = tag.toLowerCase();
9988 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9989 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9993 if(tag == 'textarea'){
9996 }else if(Roo.isOpera){
10000 if(tag == 'textarea'){
10008 setFieldLabel : function(v)
10010 if(!this.rendered){
10014 if(this.indicatorEl()){
10015 var ar = this.el.select('label > span',true);
10017 if (ar.elements.length) {
10018 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10019 this.fieldLabel = v;
10023 var br = this.el.select('label',true);
10025 if(br.elements.length) {
10026 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10027 this.fieldLabel = v;
10031 Roo.log('Cannot Found any of label > span || label in input');
10035 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10036 this.fieldLabel = v;
10051 * @class Roo.bootstrap.TextArea
10052 * @extends Roo.bootstrap.Input
10053 * Bootstrap TextArea class
10054 * @cfg {Number} cols Specifies the visible width of a text area
10055 * @cfg {Number} rows Specifies the visible number of lines in a text area
10056 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10057 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10058 * @cfg {string} html text
10061 * Create a new TextArea
10062 * @param {Object} config The config object
10065 Roo.bootstrap.TextArea = function(config){
10066 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10070 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10080 getAutoCreate : function(){
10082 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10088 if(this.inputType != 'hidden'){
10089 cfg.cls = 'form-group' //input-group
10097 value : this.value || '',
10098 html: this.html || '',
10099 cls : 'form-control',
10100 placeholder : this.placeholder || ''
10104 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10105 input.maxLength = this.maxLength;
10109 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10113 input.cols = this.cols;
10116 if (this.readOnly) {
10117 input.readonly = true;
10121 input.name = this.name;
10125 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10129 ['xs','sm','md','lg'].map(function(size){
10130 if (settings[size]) {
10131 cfg.cls += ' col-' + size + '-' + settings[size];
10135 var inputblock = input;
10137 if(this.hasFeedback && !this.allowBlank){
10141 cls: 'glyphicon form-control-feedback'
10145 cls : 'has-feedback',
10154 if (this.before || this.after) {
10157 cls : 'input-group',
10161 inputblock.cn.push({
10163 cls : 'input-group-addon',
10168 inputblock.cn.push(input);
10170 if(this.hasFeedback && !this.allowBlank){
10171 inputblock.cls += ' has-feedback';
10172 inputblock.cn.push(feedback);
10176 inputblock.cn.push({
10178 cls : 'input-group-addon',
10185 if (align ==='left' && this.fieldLabel.length) {
10190 cls : 'control-label',
10191 html : this.fieldLabel
10202 if(this.labelWidth > 12){
10203 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10206 if(this.labelWidth < 13 && this.labelmd == 0){
10207 this.labelmd = this.labelWidth;
10210 if(this.labellg > 0){
10211 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10212 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10215 if(this.labelmd > 0){
10216 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10217 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10220 if(this.labelsm > 0){
10221 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10222 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10225 if(this.labelxs > 0){
10226 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10227 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10230 } else if ( this.fieldLabel.length) {
10235 //cls : 'input-group-addon',
10236 html : this.fieldLabel
10254 if (this.disabled) {
10255 input.disabled=true;
10262 * return the real textarea element.
10264 inputEl: function ()
10266 return this.el.select('textarea.form-control',true).first();
10270 * Clear any invalid styles/messages for this field
10272 clearInvalid : function()
10275 if(!this.el || this.preventMark){ // not rendered
10279 var label = this.el.select('label', true).first();
10280 var icon = this.el.select('i.fa-star', true).first();
10285 this.el.removeClass( this.validClass);
10286 this.inputEl().removeClass('is-invalid');
10288 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10290 var feedback = this.el.select('.form-control-feedback', true).first();
10293 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10298 this.fireEvent('valid', this);
10302 * Mark this field as valid
10304 markValid : function()
10306 if(!this.el || this.preventMark){ // not rendered
10310 this.el.removeClass([this.invalidClass, this.validClass]);
10311 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10313 var feedback = this.el.select('.form-control-feedback', true).first();
10316 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10319 if(this.disabled || this.allowBlank){
10323 var label = this.el.select('label', true).first();
10324 var icon = this.el.select('i.fa-star', true).first();
10329 if (Roo.bootstrap.version == 3) {
10330 this.el.addClass(this.validClass);
10332 this.inputEl().addClass('is-valid');
10336 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10338 var feedback = this.el.select('.form-control-feedback', true).first();
10341 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10342 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10347 this.fireEvent('valid', this);
10351 * Mark this field as invalid
10352 * @param {String} msg The validation message
10354 markInvalid : function(msg)
10356 if(!this.el || this.preventMark){ // not rendered
10360 this.el.removeClass([this.invalidClass, this.validClass]);
10361 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10363 var feedback = this.el.select('.form-control-feedback', true).first();
10366 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10369 if(this.disabled || this.allowBlank){
10373 var label = this.el.select('label', true).first();
10374 var icon = this.el.select('i.fa-star', true).first();
10376 if(!this.getValue().length && label && !icon){
10377 this.el.createChild({
10379 cls : 'text-danger fa fa-lg fa-star',
10380 tooltip : 'This field is required',
10381 style : 'margin-right:5px;'
10385 if (Roo.bootstrap.version == 3) {
10386 this.el.addClass(this.invalidClass);
10388 this.inputEl().addClass('is-invalid');
10391 // fixme ... this may be depricated need to test..
10392 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10394 var feedback = this.el.select('.form-control-feedback', true).first();
10397 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10399 if(this.getValue().length || this.forceFeedback){
10400 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10407 this.fireEvent('invalid', this, msg);
10415 * trigger field - base class for combo..
10420 * @class Roo.bootstrap.TriggerField
10421 * @extends Roo.bootstrap.Input
10422 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10423 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10424 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10425 * for which you can provide a custom implementation. For example:
10427 var trigger = new Roo.bootstrap.TriggerField();
10428 trigger.onTriggerClick = myTriggerFn;
10429 trigger.applyTo('my-field');
10432 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10433 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10434 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10435 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10436 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10439 * Create a new TriggerField.
10440 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10441 * to the base TextField)
10443 Roo.bootstrap.TriggerField = function(config){
10444 this.mimicing = false;
10445 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10448 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10450 * @cfg {String} triggerClass A CSS class to apply to the trigger
10453 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10458 * @cfg {Boolean} removable (true|false) special filter default false
10462 /** @cfg {Boolean} grow @hide */
10463 /** @cfg {Number} growMin @hide */
10464 /** @cfg {Number} growMax @hide */
10470 autoSize: Roo.emptyFn,
10474 deferHeight : true,
10477 actionMode : 'wrap',
10482 getAutoCreate : function(){
10484 var align = this.labelAlign || this.parentLabelAlign();
10489 cls: 'form-group' //input-group
10496 type : this.inputType,
10497 cls : 'form-control',
10498 autocomplete: 'new-password',
10499 placeholder : this.placeholder || ''
10503 input.name = this.name;
10506 input.cls += ' input-' + this.size;
10509 if (this.disabled) {
10510 input.disabled=true;
10513 var inputblock = input;
10515 if(this.hasFeedback && !this.allowBlank){
10519 cls: 'glyphicon form-control-feedback'
10522 if(this.removable && !this.editable && !this.tickable){
10524 cls : 'has-feedback',
10530 cls : 'roo-combo-removable-btn close'
10537 cls : 'has-feedback',
10546 if(this.removable && !this.editable && !this.tickable){
10548 cls : 'roo-removable',
10554 cls : 'roo-combo-removable-btn close'
10561 if (this.before || this.after) {
10564 cls : 'input-group',
10568 inputblock.cn.push({
10570 cls : 'input-group-addon input-group-prepend input-group-text',
10575 inputblock.cn.push(input);
10577 if(this.hasFeedback && !this.allowBlank){
10578 inputblock.cls += ' has-feedback';
10579 inputblock.cn.push(feedback);
10583 inputblock.cn.push({
10585 cls : 'input-group-addon input-group-append input-group-text',
10594 var ibwrap = inputblock;
10599 cls: 'roo-select2-choices',
10603 cls: 'roo-select2-search-field',
10615 cls: 'roo-select2-container input-group',
10620 cls: 'form-hidden-field'
10626 if(!this.multiple && this.showToggleBtn){
10632 if (this.caret != false) {
10635 cls: 'fa fa-' + this.caret
10642 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10647 cls: 'combobox-clear',
10661 combobox.cls += ' roo-select2-container-multi';
10665 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10666 tooltip : 'This field is required'
10668 if (Roo.bootstrap.version == 4) {
10671 style : 'display:none'
10676 if (align ==='left' && this.fieldLabel.length) {
10678 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10685 cls : 'control-label',
10686 html : this.fieldLabel
10698 var labelCfg = cfg.cn[1];
10699 var contentCfg = cfg.cn[2];
10701 if(this.indicatorpos == 'right'){
10706 cls : 'control-label',
10710 html : this.fieldLabel
10724 labelCfg = cfg.cn[0];
10725 contentCfg = cfg.cn[1];
10728 if(this.labelWidth > 12){
10729 labelCfg.style = "width: " + this.labelWidth + 'px';
10732 if(this.labelWidth < 13 && this.labelmd == 0){
10733 this.labelmd = this.labelWidth;
10736 if(this.labellg > 0){
10737 labelCfg.cls += ' col-lg-' + this.labellg;
10738 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10741 if(this.labelmd > 0){
10742 labelCfg.cls += ' col-md-' + this.labelmd;
10743 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10746 if(this.labelsm > 0){
10747 labelCfg.cls += ' col-sm-' + this.labelsm;
10748 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10751 if(this.labelxs > 0){
10752 labelCfg.cls += ' col-xs-' + this.labelxs;
10753 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10756 } else if ( this.fieldLabel.length) {
10757 // Roo.log(" label");
10762 //cls : 'input-group-addon',
10763 html : this.fieldLabel
10771 if(this.indicatorpos == 'right'){
10779 html : this.fieldLabel
10793 // Roo.log(" no label && no align");
10800 ['xs','sm','md','lg'].map(function(size){
10801 if (settings[size]) {
10802 cfg.cls += ' col-' + size + '-' + settings[size];
10813 onResize : function(w, h){
10814 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10815 // if(typeof w == 'number'){
10816 // var x = w - this.trigger.getWidth();
10817 // this.inputEl().setWidth(this.adjustWidth('input', x));
10818 // this.trigger.setStyle('left', x+'px');
10823 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10826 getResizeEl : function(){
10827 return this.inputEl();
10831 getPositionEl : function(){
10832 return this.inputEl();
10836 alignErrorIcon : function(){
10837 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10841 initEvents : function(){
10845 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10846 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10847 if(!this.multiple && this.showToggleBtn){
10848 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10849 if(this.hideTrigger){
10850 this.trigger.setDisplayed(false);
10852 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10856 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10859 if(this.removable && !this.editable && !this.tickable){
10860 var close = this.closeTriggerEl();
10863 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10864 close.on('click', this.removeBtnClick, this, close);
10868 //this.trigger.addClassOnOver('x-form-trigger-over');
10869 //this.trigger.addClassOnClick('x-form-trigger-click');
10872 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10876 closeTriggerEl : function()
10878 var close = this.el.select('.roo-combo-removable-btn', true).first();
10879 return close ? close : false;
10882 removeBtnClick : function(e, h, el)
10884 e.preventDefault();
10886 if(this.fireEvent("remove", this) !== false){
10888 this.fireEvent("afterremove", this)
10892 createList : function()
10894 this.list = Roo.get(document.body).createChild({
10895 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10896 cls: 'typeahead typeahead-long dropdown-menu',
10897 style: 'display:none'
10900 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10905 initTrigger : function(){
10910 onDestroy : function(){
10912 this.trigger.removeAllListeners();
10913 // this.trigger.remove();
10916 // this.wrap.remove();
10918 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10922 onFocus : function(){
10923 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10925 if(!this.mimicing){
10926 this.wrap.addClass('x-trigger-wrap-focus');
10927 this.mimicing = true;
10928 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10929 if(this.monitorTab){
10930 this.el.on("keydown", this.checkTab, this);
10937 checkTab : function(e){
10938 if(e.getKey() == e.TAB){
10939 this.triggerBlur();
10944 onBlur : function(){
10949 mimicBlur : function(e, t){
10951 if(!this.wrap.contains(t) && this.validateBlur()){
10952 this.triggerBlur();
10958 triggerBlur : function(){
10959 this.mimicing = false;
10960 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10961 if(this.monitorTab){
10962 this.el.un("keydown", this.checkTab, this);
10964 //this.wrap.removeClass('x-trigger-wrap-focus');
10965 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10969 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10970 validateBlur : function(e, t){
10975 onDisable : function(){
10976 this.inputEl().dom.disabled = true;
10977 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10979 // this.wrap.addClass('x-item-disabled');
10984 onEnable : function(){
10985 this.inputEl().dom.disabled = false;
10986 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10988 // this.el.removeClass('x-item-disabled');
10993 onShow : function(){
10994 var ae = this.getActionEl();
10997 ae.dom.style.display = '';
10998 ae.dom.style.visibility = 'visible';
11004 onHide : function(){
11005 var ae = this.getActionEl();
11006 ae.dom.style.display = 'none';
11010 * The function that should handle the trigger's click event. This method does nothing by default until overridden
11011 * by an implementing function.
11013 * @param {EventObject} e
11015 onTriggerClick : Roo.emptyFn
11019 * Ext JS Library 1.1.1
11020 * Copyright(c) 2006-2007, Ext JS, LLC.
11022 * Originally Released Under LGPL - original licence link has changed is not relivant.
11025 * <script type="text/javascript">
11030 * @class Roo.data.SortTypes
11032 * Defines the default sorting (casting?) comparison functions used when sorting data.
11034 Roo.data.SortTypes = {
11036 * Default sort that does nothing
11037 * @param {Mixed} s The value being converted
11038 * @return {Mixed} The comparison value
11040 none : function(s){
11045 * The regular expression used to strip tags
11049 stripTagsRE : /<\/?[^>]+>/gi,
11052 * Strips all HTML tags to sort on text only
11053 * @param {Mixed} s The value being converted
11054 * @return {String} The comparison value
11056 asText : function(s){
11057 return String(s).replace(this.stripTagsRE, "");
11061 * Strips all HTML tags to sort on text only - Case insensitive
11062 * @param {Mixed} s The value being converted
11063 * @return {String} The comparison value
11065 asUCText : function(s){
11066 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11070 * Case insensitive string
11071 * @param {Mixed} s The value being converted
11072 * @return {String} The comparison value
11074 asUCString : function(s) {
11075 return String(s).toUpperCase();
11080 * @param {Mixed} s The value being converted
11081 * @return {Number} The comparison value
11083 asDate : function(s) {
11087 if(s instanceof Date){
11088 return s.getTime();
11090 return Date.parse(String(s));
11095 * @param {Mixed} s The value being converted
11096 * @return {Float} The comparison value
11098 asFloat : function(s) {
11099 var val = parseFloat(String(s).replace(/,/g, ""));
11108 * @param {Mixed} s The value being converted
11109 * @return {Number} The comparison value
11111 asInt : function(s) {
11112 var val = parseInt(String(s).replace(/,/g, ""));
11120 * Ext JS Library 1.1.1
11121 * Copyright(c) 2006-2007, Ext JS, LLC.
11123 * Originally Released Under LGPL - original licence link has changed is not relivant.
11126 * <script type="text/javascript">
11130 * @class Roo.data.Record
11131 * Instances of this class encapsulate both record <em>definition</em> information, and record
11132 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11133 * to access Records cached in an {@link Roo.data.Store} object.<br>
11135 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11136 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11139 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11141 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11142 * {@link #create}. The parameters are the same.
11143 * @param {Array} data An associative Array of data values keyed by the field name.
11144 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11145 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11146 * not specified an integer id is generated.
11148 Roo.data.Record = function(data, id){
11149 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11154 * Generate a constructor for a specific record layout.
11155 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11156 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11157 * Each field definition object may contain the following properties: <ul>
11158 * <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,
11159 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11160 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11161 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11162 * is being used, then this is a string containing the javascript expression to reference the data relative to
11163 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11164 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11165 * this may be omitted.</p></li>
11166 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11167 * <ul><li>auto (Default, implies no conversion)</li>
11172 * <li>date</li></ul></p></li>
11173 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11174 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11175 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11176 * by the Reader into an object that will be stored in the Record. It is passed the
11177 * following parameters:<ul>
11178 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11180 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11182 * <br>usage:<br><pre><code>
11183 var TopicRecord = Roo.data.Record.create(
11184 {name: 'title', mapping: 'topic_title'},
11185 {name: 'author', mapping: 'username'},
11186 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11187 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11188 {name: 'lastPoster', mapping: 'user2'},
11189 {name: 'excerpt', mapping: 'post_text'}
11192 var myNewRecord = new TopicRecord({
11193 title: 'Do my job please',
11196 lastPost: new Date(),
11197 lastPoster: 'Animal',
11198 excerpt: 'No way dude!'
11200 myStore.add(myNewRecord);
11205 Roo.data.Record.create = function(o){
11206 var f = function(){
11207 f.superclass.constructor.apply(this, arguments);
11209 Roo.extend(f, Roo.data.Record);
11210 var p = f.prototype;
11211 p.fields = new Roo.util.MixedCollection(false, function(field){
11214 for(var i = 0, len = o.length; i < len; i++){
11215 p.fields.add(new Roo.data.Field(o[i]));
11217 f.getField = function(name){
11218 return p.fields.get(name);
11223 Roo.data.Record.AUTO_ID = 1000;
11224 Roo.data.Record.EDIT = 'edit';
11225 Roo.data.Record.REJECT = 'reject';
11226 Roo.data.Record.COMMIT = 'commit';
11228 Roo.data.Record.prototype = {
11230 * Readonly flag - true if this record has been modified.
11239 join : function(store){
11240 this.store = store;
11244 * Set the named field to the specified value.
11245 * @param {String} name The name of the field to set.
11246 * @param {Object} value The value to set the field to.
11248 set : function(name, value){
11249 if(this.data[name] == value){
11253 if(!this.modified){
11254 this.modified = {};
11256 if(typeof this.modified[name] == 'undefined'){
11257 this.modified[name] = this.data[name];
11259 this.data[name] = value;
11260 if(!this.editing && this.store){
11261 this.store.afterEdit(this);
11266 * Get the value of the named field.
11267 * @param {String} name The name of the field to get the value of.
11268 * @return {Object} The value of the field.
11270 get : function(name){
11271 return this.data[name];
11275 beginEdit : function(){
11276 this.editing = true;
11277 this.modified = {};
11281 cancelEdit : function(){
11282 this.editing = false;
11283 delete this.modified;
11287 endEdit : function(){
11288 this.editing = false;
11289 if(this.dirty && this.store){
11290 this.store.afterEdit(this);
11295 * Usually called by the {@link Roo.data.Store} which owns the Record.
11296 * Rejects all changes made to the Record since either creation, or the last commit operation.
11297 * Modified fields are reverted to their original values.
11299 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11300 * of reject operations.
11302 reject : function(){
11303 var m = this.modified;
11305 if(typeof m[n] != "function"){
11306 this.data[n] = m[n];
11309 this.dirty = false;
11310 delete this.modified;
11311 this.editing = false;
11313 this.store.afterReject(this);
11318 * Usually called by the {@link Roo.data.Store} which owns the Record.
11319 * Commits all changes made to the Record since either creation, or the last commit operation.
11321 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11322 * of commit operations.
11324 commit : function(){
11325 this.dirty = false;
11326 delete this.modified;
11327 this.editing = false;
11329 this.store.afterCommit(this);
11334 hasError : function(){
11335 return this.error != null;
11339 clearError : function(){
11344 * Creates a copy of this record.
11345 * @param {String} id (optional) A new record id if you don't want to use this record's id
11348 copy : function(newId) {
11349 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11353 * Ext JS Library 1.1.1
11354 * Copyright(c) 2006-2007, Ext JS, LLC.
11356 * Originally Released Under LGPL - original licence link has changed is not relivant.
11359 * <script type="text/javascript">
11365 * @class Roo.data.Store
11366 * @extends Roo.util.Observable
11367 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11368 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11370 * 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
11371 * has no knowledge of the format of the data returned by the Proxy.<br>
11373 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11374 * instances from the data object. These records are cached and made available through accessor functions.
11376 * Creates a new Store.
11377 * @param {Object} config A config object containing the objects needed for the Store to access data,
11378 * and read the data into Records.
11380 Roo.data.Store = function(config){
11381 this.data = new Roo.util.MixedCollection(false);
11382 this.data.getKey = function(o){
11385 this.baseParams = {};
11387 this.paramNames = {
11392 "multisort" : "_multisort"
11395 if(config && config.data){
11396 this.inlineData = config.data;
11397 delete config.data;
11400 Roo.apply(this, config);
11402 if(this.reader){ // reader passed
11403 this.reader = Roo.factory(this.reader, Roo.data);
11404 this.reader.xmodule = this.xmodule || false;
11405 if(!this.recordType){
11406 this.recordType = this.reader.recordType;
11408 if(this.reader.onMetaChange){
11409 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11413 if(this.recordType){
11414 this.fields = this.recordType.prototype.fields;
11416 this.modified = [];
11420 * @event datachanged
11421 * Fires when the data cache has changed, and a widget which is using this Store
11422 * as a Record cache should refresh its view.
11423 * @param {Store} this
11425 datachanged : true,
11427 * @event metachange
11428 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11429 * @param {Store} this
11430 * @param {Object} meta The JSON metadata
11435 * Fires when Records have been added to the Store
11436 * @param {Store} this
11437 * @param {Roo.data.Record[]} records The array of Records added
11438 * @param {Number} index The index at which the record(s) were added
11443 * Fires when a Record has been removed from the Store
11444 * @param {Store} this
11445 * @param {Roo.data.Record} record The Record that was removed
11446 * @param {Number} index The index at which the record was removed
11451 * Fires when a Record has been updated
11452 * @param {Store} this
11453 * @param {Roo.data.Record} record The Record that was updated
11454 * @param {String} operation The update operation being performed. Value may be one of:
11456 Roo.data.Record.EDIT
11457 Roo.data.Record.REJECT
11458 Roo.data.Record.COMMIT
11464 * Fires when the data cache has been cleared.
11465 * @param {Store} this
11469 * @event beforeload
11470 * Fires before a request is made for a new data object. If the beforeload handler returns false
11471 * the load action will be canceled.
11472 * @param {Store} this
11473 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11477 * @event beforeloadadd
11478 * Fires after a new set of Records has been loaded.
11479 * @param {Store} this
11480 * @param {Roo.data.Record[]} records The Records that were loaded
11481 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11483 beforeloadadd : true,
11486 * Fires after a new set of Records has been loaded, before they are added to the store.
11487 * @param {Store} this
11488 * @param {Roo.data.Record[]} records The Records that were loaded
11489 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11490 * @params {Object} return from reader
11494 * @event loadexception
11495 * Fires if an exception occurs in the Proxy during loading.
11496 * Called with the signature of the Proxy's "loadexception" event.
11497 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11500 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11501 * @param {Object} load options
11502 * @param {Object} jsonData from your request (normally this contains the Exception)
11504 loadexception : true
11508 this.proxy = Roo.factory(this.proxy, Roo.data);
11509 this.proxy.xmodule = this.xmodule || false;
11510 this.relayEvents(this.proxy, ["loadexception"]);
11512 this.sortToggle = {};
11513 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11515 Roo.data.Store.superclass.constructor.call(this);
11517 if(this.inlineData){
11518 this.loadData(this.inlineData);
11519 delete this.inlineData;
11523 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11525 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11526 * without a remote query - used by combo/forms at present.
11530 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11533 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11536 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11537 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11540 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11541 * on any HTTP request
11544 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11547 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11551 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11552 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11554 remoteSort : false,
11557 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11558 * loaded or when a record is removed. (defaults to false).
11560 pruneModifiedRecords : false,
11563 lastOptions : null,
11566 * Add Records to the Store and fires the add event.
11567 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11569 add : function(records){
11570 records = [].concat(records);
11571 for(var i = 0, len = records.length; i < len; i++){
11572 records[i].join(this);
11574 var index = this.data.length;
11575 this.data.addAll(records);
11576 this.fireEvent("add", this, records, index);
11580 * Remove a Record from the Store and fires the remove event.
11581 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11583 remove : function(record){
11584 var index = this.data.indexOf(record);
11585 this.data.removeAt(index);
11587 if(this.pruneModifiedRecords){
11588 this.modified.remove(record);
11590 this.fireEvent("remove", this, record, index);
11594 * Remove all Records from the Store and fires the clear event.
11596 removeAll : function(){
11598 if(this.pruneModifiedRecords){
11599 this.modified = [];
11601 this.fireEvent("clear", this);
11605 * Inserts Records to the Store at the given index and fires the add event.
11606 * @param {Number} index The start index at which to insert the passed Records.
11607 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11609 insert : function(index, records){
11610 records = [].concat(records);
11611 for(var i = 0, len = records.length; i < len; i++){
11612 this.data.insert(index, records[i]);
11613 records[i].join(this);
11615 this.fireEvent("add", this, records, index);
11619 * Get the index within the cache of the passed Record.
11620 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11621 * @return {Number} The index of the passed Record. Returns -1 if not found.
11623 indexOf : function(record){
11624 return this.data.indexOf(record);
11628 * Get the index within the cache of the Record with the passed id.
11629 * @param {String} id The id of the Record to find.
11630 * @return {Number} The index of the Record. Returns -1 if not found.
11632 indexOfId : function(id){
11633 return this.data.indexOfKey(id);
11637 * Get the Record with the specified id.
11638 * @param {String} id The id of the Record to find.
11639 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11641 getById : function(id){
11642 return this.data.key(id);
11646 * Get the Record at the specified index.
11647 * @param {Number} index The index of the Record to find.
11648 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11650 getAt : function(index){
11651 return this.data.itemAt(index);
11655 * Returns a range of Records between specified indices.
11656 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11657 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11658 * @return {Roo.data.Record[]} An array of Records
11660 getRange : function(start, end){
11661 return this.data.getRange(start, end);
11665 storeOptions : function(o){
11666 o = Roo.apply({}, o);
11669 this.lastOptions = o;
11673 * Loads the Record cache from the configured Proxy using the configured Reader.
11675 * If using remote paging, then the first load call must specify the <em>start</em>
11676 * and <em>limit</em> properties in the options.params property to establish the initial
11677 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11679 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11680 * and this call will return before the new data has been loaded. Perform any post-processing
11681 * in a callback function, or in a "load" event handler.</strong>
11683 * @param {Object} options An object containing properties which control loading options:<ul>
11684 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11685 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11686 * passed the following arguments:<ul>
11687 * <li>r : Roo.data.Record[]</li>
11688 * <li>options: Options object from the load call</li>
11689 * <li>success: Boolean success indicator</li></ul></li>
11690 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11691 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11694 load : function(options){
11695 options = options || {};
11696 if(this.fireEvent("beforeload", this, options) !== false){
11697 this.storeOptions(options);
11698 var p = Roo.apply(options.params || {}, this.baseParams);
11699 // if meta was not loaded from remote source.. try requesting it.
11700 if (!this.reader.metaFromRemote) {
11701 p._requestMeta = 1;
11703 if(this.sortInfo && this.remoteSort){
11704 var pn = this.paramNames;
11705 p[pn["sort"]] = this.sortInfo.field;
11706 p[pn["dir"]] = this.sortInfo.direction;
11708 if (this.multiSort) {
11709 var pn = this.paramNames;
11710 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11713 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11718 * Reloads the Record cache from the configured Proxy using the configured Reader and
11719 * the options from the last load operation performed.
11720 * @param {Object} options (optional) An object containing properties which may override the options
11721 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11722 * the most recently used options are reused).
11724 reload : function(options){
11725 this.load(Roo.applyIf(options||{}, this.lastOptions));
11729 // Called as a callback by the Reader during a load operation.
11730 loadRecords : function(o, options, success){
11731 if(!o || success === false){
11732 if(success !== false){
11733 this.fireEvent("load", this, [], options, o);
11735 if(options.callback){
11736 options.callback.call(options.scope || this, [], options, false);
11740 // if data returned failure - throw an exception.
11741 if (o.success === false) {
11742 // show a message if no listener is registered.
11743 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11744 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11746 // loadmask wil be hooked into this..
11747 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11750 var r = o.records, t = o.totalRecords || r.length;
11752 this.fireEvent("beforeloadadd", this, r, options, o);
11754 if(!options || options.add !== true){
11755 if(this.pruneModifiedRecords){
11756 this.modified = [];
11758 for(var i = 0, len = r.length; i < len; i++){
11762 this.data = this.snapshot;
11763 delete this.snapshot;
11766 this.data.addAll(r);
11767 this.totalLength = t;
11769 this.fireEvent("datachanged", this);
11771 this.totalLength = Math.max(t, this.data.length+r.length);
11775 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11777 var e = new Roo.data.Record({});
11779 e.set(this.parent.displayField, this.parent.emptyTitle);
11780 e.set(this.parent.valueField, '');
11785 this.fireEvent("load", this, r, options, o);
11786 if(options.callback){
11787 options.callback.call(options.scope || this, r, options, true);
11793 * Loads data from a passed data block. A Reader which understands the format of the data
11794 * must have been configured in the constructor.
11795 * @param {Object} data The data block from which to read the Records. The format of the data expected
11796 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11797 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11799 loadData : function(o, append){
11800 var r = this.reader.readRecords(o);
11801 this.loadRecords(r, {add: append}, true);
11805 * Gets the number of cached records.
11807 * <em>If using paging, this may not be the total size of the dataset. If the data object
11808 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11809 * the data set size</em>
11811 getCount : function(){
11812 return this.data.length || 0;
11816 * Gets the total number of records in the dataset as returned by the server.
11818 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11819 * the dataset size</em>
11821 getTotalCount : function(){
11822 return this.totalLength || 0;
11826 * Returns the sort state of the Store as an object with two properties:
11828 field {String} The name of the field by which the Records are sorted
11829 direction {String} The sort order, "ASC" or "DESC"
11832 getSortState : function(){
11833 return this.sortInfo;
11837 applySort : function(){
11838 if(this.sortInfo && !this.remoteSort){
11839 var s = this.sortInfo, f = s.field;
11840 var st = this.fields.get(f).sortType;
11841 var fn = function(r1, r2){
11842 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11843 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11845 this.data.sort(s.direction, fn);
11846 if(this.snapshot && this.snapshot != this.data){
11847 this.snapshot.sort(s.direction, fn);
11853 * Sets the default sort column and order to be used by the next load operation.
11854 * @param {String} fieldName The name of the field to sort by.
11855 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11857 setDefaultSort : function(field, dir){
11858 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11862 * Sort the Records.
11863 * If remote sorting is used, the sort is performed on the server, and the cache is
11864 * reloaded. If local sorting is used, the cache is sorted internally.
11865 * @param {String} fieldName The name of the field to sort by.
11866 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11868 sort : function(fieldName, dir){
11869 var f = this.fields.get(fieldName);
11871 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11873 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11874 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11879 this.sortToggle[f.name] = dir;
11880 this.sortInfo = {field: f.name, direction: dir};
11881 if(!this.remoteSort){
11883 this.fireEvent("datachanged", this);
11885 this.load(this.lastOptions);
11890 * Calls the specified function for each of the Records in the cache.
11891 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11892 * Returning <em>false</em> aborts and exits the iteration.
11893 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11895 each : function(fn, scope){
11896 this.data.each(fn, scope);
11900 * Gets all records modified since the last commit. Modified records are persisted across load operations
11901 * (e.g., during paging).
11902 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11904 getModifiedRecords : function(){
11905 return this.modified;
11909 createFilterFn : function(property, value, anyMatch){
11910 if(!value.exec){ // not a regex
11911 value = String(value);
11912 if(value.length == 0){
11915 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11917 return function(r){
11918 return value.test(r.data[property]);
11923 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11924 * @param {String} property A field on your records
11925 * @param {Number} start The record index to start at (defaults to 0)
11926 * @param {Number} end The last record index to include (defaults to length - 1)
11927 * @return {Number} The sum
11929 sum : function(property, start, end){
11930 var rs = this.data.items, v = 0;
11931 start = start || 0;
11932 end = (end || end === 0) ? end : rs.length-1;
11934 for(var i = start; i <= end; i++){
11935 v += (rs[i].data[property] || 0);
11941 * Filter the records by a specified property.
11942 * @param {String} field A field on your records
11943 * @param {String/RegExp} value Either a string that the field
11944 * should start with or a RegExp to test against the field
11945 * @param {Boolean} anyMatch True to match any part not just the beginning
11947 filter : function(property, value, anyMatch){
11948 var fn = this.createFilterFn(property, value, anyMatch);
11949 return fn ? this.filterBy(fn) : this.clearFilter();
11953 * Filter by a function. The specified function will be called with each
11954 * record in this data source. If the function returns true the record is included,
11955 * otherwise it is filtered.
11956 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11957 * @param {Object} scope (optional) The scope of the function (defaults to this)
11959 filterBy : function(fn, scope){
11960 this.snapshot = this.snapshot || this.data;
11961 this.data = this.queryBy(fn, scope||this);
11962 this.fireEvent("datachanged", this);
11966 * Query the records by a specified property.
11967 * @param {String} field A field on your records
11968 * @param {String/RegExp} value Either a string that the field
11969 * should start with or a RegExp to test against the field
11970 * @param {Boolean} anyMatch True to match any part not just the beginning
11971 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11973 query : function(property, value, anyMatch){
11974 var fn = this.createFilterFn(property, value, anyMatch);
11975 return fn ? this.queryBy(fn) : this.data.clone();
11979 * Query by a function. The specified function will be called with each
11980 * record in this data source. If the function returns true the record is included
11982 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11983 * @param {Object} scope (optional) The scope of the function (defaults to this)
11984 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11986 queryBy : function(fn, scope){
11987 var data = this.snapshot || this.data;
11988 return data.filterBy(fn, scope||this);
11992 * Collects unique values for a particular dataIndex from this store.
11993 * @param {String} dataIndex The property to collect
11994 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11995 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11996 * @return {Array} An array of the unique values
11998 collect : function(dataIndex, allowNull, bypassFilter){
11999 var d = (bypassFilter === true && this.snapshot) ?
12000 this.snapshot.items : this.data.items;
12001 var v, sv, r = [], l = {};
12002 for(var i = 0, len = d.length; i < len; i++){
12003 v = d[i].data[dataIndex];
12005 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
12014 * Revert to a view of the Record cache with no filtering applied.
12015 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
12017 clearFilter : function(suppressEvent){
12018 if(this.snapshot && this.snapshot != this.data){
12019 this.data = this.snapshot;
12020 delete this.snapshot;
12021 if(suppressEvent !== true){
12022 this.fireEvent("datachanged", this);
12028 afterEdit : function(record){
12029 if(this.modified.indexOf(record) == -1){
12030 this.modified.push(record);
12032 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12036 afterReject : function(record){
12037 this.modified.remove(record);
12038 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12042 afterCommit : function(record){
12043 this.modified.remove(record);
12044 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12048 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12049 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12051 commitChanges : function(){
12052 var m = this.modified.slice(0);
12053 this.modified = [];
12054 for(var i = 0, len = m.length; i < len; i++){
12060 * Cancel outstanding changes on all changed records.
12062 rejectChanges : function(){
12063 var m = this.modified.slice(0);
12064 this.modified = [];
12065 for(var i = 0, len = m.length; i < len; i++){
12070 onMetaChange : function(meta, rtype, o){
12071 this.recordType = rtype;
12072 this.fields = rtype.prototype.fields;
12073 delete this.snapshot;
12074 this.sortInfo = meta.sortInfo || this.sortInfo;
12075 this.modified = [];
12076 this.fireEvent('metachange', this, this.reader.meta);
12079 moveIndex : function(data, type)
12081 var index = this.indexOf(data);
12083 var newIndex = index + type;
12087 this.insert(newIndex, data);
12092 * Ext JS Library 1.1.1
12093 * Copyright(c) 2006-2007, Ext JS, LLC.
12095 * Originally Released Under LGPL - original licence link has changed is not relivant.
12098 * <script type="text/javascript">
12102 * @class Roo.data.SimpleStore
12103 * @extends Roo.data.Store
12104 * Small helper class to make creating Stores from Array data easier.
12105 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12106 * @cfg {Array} fields An array of field definition objects, or field name strings.
12107 * @cfg {Array} data The multi-dimensional array of data
12109 * @param {Object} config
12111 Roo.data.SimpleStore = function(config){
12112 Roo.data.SimpleStore.superclass.constructor.call(this, {
12114 reader: new Roo.data.ArrayReader({
12117 Roo.data.Record.create(config.fields)
12119 proxy : new Roo.data.MemoryProxy(config.data)
12123 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12125 * Ext JS Library 1.1.1
12126 * Copyright(c) 2006-2007, Ext JS, LLC.
12128 * Originally Released Under LGPL - original licence link has changed is not relivant.
12131 * <script type="text/javascript">
12136 * @extends Roo.data.Store
12137 * @class Roo.data.JsonStore
12138 * Small helper class to make creating Stores for JSON data easier. <br/>
12140 var store = new Roo.data.JsonStore({
12141 url: 'get-images.php',
12143 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12146 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12147 * JsonReader and HttpProxy (unless inline data is provided).</b>
12148 * @cfg {Array} fields An array of field definition objects, or field name strings.
12150 * @param {Object} config
12152 Roo.data.JsonStore = function(c){
12153 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12154 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12155 reader: new Roo.data.JsonReader(c, c.fields)
12158 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12160 * Ext JS Library 1.1.1
12161 * Copyright(c) 2006-2007, Ext JS, LLC.
12163 * Originally Released Under LGPL - original licence link has changed is not relivant.
12166 * <script type="text/javascript">
12170 Roo.data.Field = function(config){
12171 if(typeof config == "string"){
12172 config = {name: config};
12174 Roo.apply(this, config);
12177 this.type = "auto";
12180 var st = Roo.data.SortTypes;
12181 // named sortTypes are supported, here we look them up
12182 if(typeof this.sortType == "string"){
12183 this.sortType = st[this.sortType];
12186 // set default sortType for strings and dates
12187 if(!this.sortType){
12190 this.sortType = st.asUCString;
12193 this.sortType = st.asDate;
12196 this.sortType = st.none;
12201 var stripRe = /[\$,%]/g;
12203 // prebuilt conversion function for this field, instead of
12204 // switching every time we're reading a value
12206 var cv, dateFormat = this.dateFormat;
12211 cv = function(v){ return v; };
12214 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12218 return v !== undefined && v !== null && v !== '' ?
12219 parseInt(String(v).replace(stripRe, ""), 10) : '';
12224 return v !== undefined && v !== null && v !== '' ?
12225 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12230 cv = function(v){ return v === true || v === "true" || v == 1; };
12237 if(v instanceof Date){
12241 if(dateFormat == "timestamp"){
12242 return new Date(v*1000);
12244 return Date.parseDate(v, dateFormat);
12246 var parsed = Date.parse(v);
12247 return parsed ? new Date(parsed) : null;
12256 Roo.data.Field.prototype = {
12264 * Ext JS Library 1.1.1
12265 * Copyright(c) 2006-2007, Ext JS, LLC.
12267 * Originally Released Under LGPL - original licence link has changed is not relivant.
12270 * <script type="text/javascript">
12273 // Base class for reading structured data from a data source. This class is intended to be
12274 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12277 * @class Roo.data.DataReader
12278 * Base class for reading structured data from a data source. This class is intended to be
12279 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12282 Roo.data.DataReader = function(meta, recordType){
12286 this.recordType = recordType instanceof Array ?
12287 Roo.data.Record.create(recordType) : recordType;
12290 Roo.data.DataReader.prototype = {
12292 * Create an empty record
12293 * @param {Object} data (optional) - overlay some values
12294 * @return {Roo.data.Record} record created.
12296 newRow : function(d) {
12298 this.recordType.prototype.fields.each(function(c) {
12300 case 'int' : da[c.name] = 0; break;
12301 case 'date' : da[c.name] = new Date(); break;
12302 case 'float' : da[c.name] = 0.0; break;
12303 case 'boolean' : da[c.name] = false; break;
12304 default : da[c.name] = ""; break;
12308 return new this.recordType(Roo.apply(da, d));
12313 * Ext JS Library 1.1.1
12314 * Copyright(c) 2006-2007, Ext JS, LLC.
12316 * Originally Released Under LGPL - original licence link has changed is not relivant.
12319 * <script type="text/javascript">
12323 * @class Roo.data.DataProxy
12324 * @extends Roo.data.Observable
12325 * This class is an abstract base class for implementations which provide retrieval of
12326 * unformatted data objects.<br>
12328 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12329 * (of the appropriate type which knows how to parse the data object) to provide a block of
12330 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12332 * Custom implementations must implement the load method as described in
12333 * {@link Roo.data.HttpProxy#load}.
12335 Roo.data.DataProxy = function(){
12338 * @event beforeload
12339 * Fires before a network request is made to retrieve a data object.
12340 * @param {Object} This DataProxy object.
12341 * @param {Object} params The params parameter to the load function.
12346 * Fires before the load method's callback is called.
12347 * @param {Object} This DataProxy object.
12348 * @param {Object} o The data object.
12349 * @param {Object} arg The callback argument object passed to the load function.
12353 * @event loadexception
12354 * Fires if an Exception occurs during data retrieval.
12355 * @param {Object} This DataProxy object.
12356 * @param {Object} o The data object.
12357 * @param {Object} arg The callback argument object passed to the load function.
12358 * @param {Object} e The Exception.
12360 loadexception : true
12362 Roo.data.DataProxy.superclass.constructor.call(this);
12365 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12368 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12372 * Ext JS Library 1.1.1
12373 * Copyright(c) 2006-2007, Ext JS, LLC.
12375 * Originally Released Under LGPL - original licence link has changed is not relivant.
12378 * <script type="text/javascript">
12381 * @class Roo.data.MemoryProxy
12382 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12383 * to the Reader when its load method is called.
12385 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12387 Roo.data.MemoryProxy = function(data){
12391 Roo.data.MemoryProxy.superclass.constructor.call(this);
12395 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12398 * Load data from the requested source (in this case an in-memory
12399 * data object passed to the constructor), read the data object into
12400 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12401 * process that block using the passed callback.
12402 * @param {Object} params This parameter is not used by the MemoryProxy class.
12403 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12404 * object into a block of Roo.data.Records.
12405 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12406 * The function must be passed <ul>
12407 * <li>The Record block object</li>
12408 * <li>The "arg" argument from the load function</li>
12409 * <li>A boolean success indicator</li>
12411 * @param {Object} scope The scope in which to call the callback
12412 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12414 load : function(params, reader, callback, scope, arg){
12415 params = params || {};
12418 result = reader.readRecords(params.data ? params.data :this.data);
12420 this.fireEvent("loadexception", this, arg, null, e);
12421 callback.call(scope, null, arg, false);
12424 callback.call(scope, result, arg, true);
12428 update : function(params, records){
12433 * Ext JS Library 1.1.1
12434 * Copyright(c) 2006-2007, Ext JS, LLC.
12436 * Originally Released Under LGPL - original licence link has changed is not relivant.
12439 * <script type="text/javascript">
12442 * @class Roo.data.HttpProxy
12443 * @extends Roo.data.DataProxy
12444 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12445 * configured to reference a certain URL.<br><br>
12447 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12448 * from which the running page was served.<br><br>
12450 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12452 * Be aware that to enable the browser to parse an XML document, the server must set
12453 * the Content-Type header in the HTTP response to "text/xml".
12455 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12456 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12457 * will be used to make the request.
12459 Roo.data.HttpProxy = function(conn){
12460 Roo.data.HttpProxy.superclass.constructor.call(this);
12461 // is conn a conn config or a real conn?
12463 this.useAjax = !conn || !conn.events;
12467 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12468 // thse are take from connection...
12471 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12474 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12475 * extra parameters to each request made by this object. (defaults to undefined)
12478 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12479 * to each request made by this object. (defaults to undefined)
12482 * @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)
12485 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12488 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12494 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12498 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12499 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12500 * a finer-grained basis than the DataProxy events.
12502 getConnection : function(){
12503 return this.useAjax ? Roo.Ajax : this.conn;
12507 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12508 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12509 * process that block using the passed callback.
12510 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12511 * for the request to the remote server.
12512 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12513 * object into a block of Roo.data.Records.
12514 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12515 * The function must be passed <ul>
12516 * <li>The Record block object</li>
12517 * <li>The "arg" argument from the load function</li>
12518 * <li>A boolean success indicator</li>
12520 * @param {Object} scope The scope in which to call the callback
12521 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12523 load : function(params, reader, callback, scope, arg){
12524 if(this.fireEvent("beforeload", this, params) !== false){
12526 params : params || {},
12528 callback : callback,
12533 callback : this.loadResponse,
12537 Roo.applyIf(o, this.conn);
12538 if(this.activeRequest){
12539 Roo.Ajax.abort(this.activeRequest);
12541 this.activeRequest = Roo.Ajax.request(o);
12543 this.conn.request(o);
12546 callback.call(scope||this, null, arg, false);
12551 loadResponse : function(o, success, response){
12552 delete this.activeRequest;
12554 this.fireEvent("loadexception", this, o, response);
12555 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12560 result = o.reader.read(response);
12562 this.fireEvent("loadexception", this, o, response, e);
12563 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12567 this.fireEvent("load", this, o, o.request.arg);
12568 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12572 update : function(dataSet){
12577 updateResponse : function(dataSet){
12582 * Ext JS Library 1.1.1
12583 * Copyright(c) 2006-2007, Ext JS, LLC.
12585 * Originally Released Under LGPL - original licence link has changed is not relivant.
12588 * <script type="text/javascript">
12592 * @class Roo.data.ScriptTagProxy
12593 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12594 * other than the originating domain of the running page.<br><br>
12596 * <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
12597 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12599 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12600 * source code that is used as the source inside a <script> tag.<br><br>
12602 * In order for the browser to process the returned data, the server must wrap the data object
12603 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12604 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12605 * depending on whether the callback name was passed:
12608 boolean scriptTag = false;
12609 String cb = request.getParameter("callback");
12612 response.setContentType("text/javascript");
12614 response.setContentType("application/x-json");
12616 Writer out = response.getWriter();
12618 out.write(cb + "(");
12620 out.print(dataBlock.toJsonString());
12627 * @param {Object} config A configuration object.
12629 Roo.data.ScriptTagProxy = function(config){
12630 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12631 Roo.apply(this, config);
12632 this.head = document.getElementsByTagName("head")[0];
12635 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12637 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12639 * @cfg {String} url The URL from which to request the data object.
12642 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12646 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12647 * the server the name of the callback function set up by the load call to process the returned data object.
12648 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12649 * javascript output which calls this named function passing the data object as its only parameter.
12651 callbackParam : "callback",
12653 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12654 * name to the request.
12659 * Load data from the configured URL, read the data object into
12660 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12661 * process that block using the passed callback.
12662 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12663 * for the request to the remote server.
12664 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12665 * object into a block of Roo.data.Records.
12666 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12667 * The function must be passed <ul>
12668 * <li>The Record block object</li>
12669 * <li>The "arg" argument from the load function</li>
12670 * <li>A boolean success indicator</li>
12672 * @param {Object} scope The scope in which to call the callback
12673 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12675 load : function(params, reader, callback, scope, arg){
12676 if(this.fireEvent("beforeload", this, params) !== false){
12678 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12680 var url = this.url;
12681 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12683 url += "&_dc=" + (new Date().getTime());
12685 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12688 cb : "stcCallback"+transId,
12689 scriptId : "stcScript"+transId,
12693 callback : callback,
12699 window[trans.cb] = function(o){
12700 conn.handleResponse(o, trans);
12703 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12705 if(this.autoAbort !== false){
12709 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12711 var script = document.createElement("script");
12712 script.setAttribute("src", url);
12713 script.setAttribute("type", "text/javascript");
12714 script.setAttribute("id", trans.scriptId);
12715 this.head.appendChild(script);
12717 this.trans = trans;
12719 callback.call(scope||this, null, arg, false);
12724 isLoading : function(){
12725 return this.trans ? true : false;
12729 * Abort the current server request.
12731 abort : function(){
12732 if(this.isLoading()){
12733 this.destroyTrans(this.trans);
12738 destroyTrans : function(trans, isLoaded){
12739 this.head.removeChild(document.getElementById(trans.scriptId));
12740 clearTimeout(trans.timeoutId);
12742 window[trans.cb] = undefined;
12744 delete window[trans.cb];
12747 // if hasn't been loaded, wait for load to remove it to prevent script error
12748 window[trans.cb] = function(){
12749 window[trans.cb] = undefined;
12751 delete window[trans.cb];
12758 handleResponse : function(o, trans){
12759 this.trans = false;
12760 this.destroyTrans(trans, true);
12763 result = trans.reader.readRecords(o);
12765 this.fireEvent("loadexception", this, o, trans.arg, e);
12766 trans.callback.call(trans.scope||window, null, trans.arg, false);
12769 this.fireEvent("load", this, o, trans.arg);
12770 trans.callback.call(trans.scope||window, result, trans.arg, true);
12774 handleFailure : function(trans){
12775 this.trans = false;
12776 this.destroyTrans(trans, false);
12777 this.fireEvent("loadexception", this, null, trans.arg);
12778 trans.callback.call(trans.scope||window, null, trans.arg, false);
12782 * Ext JS Library 1.1.1
12783 * Copyright(c) 2006-2007, Ext JS, LLC.
12785 * Originally Released Under LGPL - original licence link has changed is not relivant.
12788 * <script type="text/javascript">
12792 * @class Roo.data.JsonReader
12793 * @extends Roo.data.DataReader
12794 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12795 * based on mappings in a provided Roo.data.Record constructor.
12797 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12798 * in the reply previously.
12803 var RecordDef = Roo.data.Record.create([
12804 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12805 {name: 'occupation'} // This field will use "occupation" as the mapping.
12807 var myReader = new Roo.data.JsonReader({
12808 totalProperty: "results", // The property which contains the total dataset size (optional)
12809 root: "rows", // The property which contains an Array of row objects
12810 id: "id" // The property within each row object that provides an ID for the record (optional)
12814 * This would consume a JSON file like this:
12816 { 'results': 2, 'rows': [
12817 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12818 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12821 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12822 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12823 * paged from the remote server.
12824 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12825 * @cfg {String} root name of the property which contains the Array of row objects.
12826 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12827 * @cfg {Array} fields Array of field definition objects
12829 * Create a new JsonReader
12830 * @param {Object} meta Metadata configuration options
12831 * @param {Object} recordType Either an Array of field definition objects,
12832 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12834 Roo.data.JsonReader = function(meta, recordType){
12837 // set some defaults:
12838 Roo.applyIf(meta, {
12839 totalProperty: 'total',
12840 successProperty : 'success',
12845 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12847 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12850 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12851 * Used by Store query builder to append _requestMeta to params.
12854 metaFromRemote : false,
12856 * This method is only used by a DataProxy which has retrieved data from a remote server.
12857 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12858 * @return {Object} data A data block which is used by an Roo.data.Store object as
12859 * a cache of Roo.data.Records.
12861 read : function(response){
12862 var json = response.responseText;
12864 var o = /* eval:var:o */ eval("("+json+")");
12866 throw {message: "JsonReader.read: Json object not found"};
12872 this.metaFromRemote = true;
12873 this.meta = o.metaData;
12874 this.recordType = Roo.data.Record.create(o.metaData.fields);
12875 this.onMetaChange(this.meta, this.recordType, o);
12877 return this.readRecords(o);
12880 // private function a store will implement
12881 onMetaChange : function(meta, recordType, o){
12888 simpleAccess: function(obj, subsc) {
12895 getJsonAccessor: function(){
12897 return function(expr) {
12899 return(re.test(expr))
12900 ? new Function("obj", "return obj." + expr)
12905 return Roo.emptyFn;
12910 * Create a data block containing Roo.data.Records from an XML document.
12911 * @param {Object} o An object which contains an Array of row objects in the property specified
12912 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12913 * which contains the total size of the dataset.
12914 * @return {Object} data A data block which is used by an Roo.data.Store object as
12915 * a cache of Roo.data.Records.
12917 readRecords : function(o){
12919 * After any data loads, the raw JSON data is available for further custom processing.
12923 var s = this.meta, Record = this.recordType,
12924 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12926 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12928 if(s.totalProperty) {
12929 this.getTotal = this.getJsonAccessor(s.totalProperty);
12931 if(s.successProperty) {
12932 this.getSuccess = this.getJsonAccessor(s.successProperty);
12934 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12936 var g = this.getJsonAccessor(s.id);
12937 this.getId = function(rec) {
12939 return (r === undefined || r === "") ? null : r;
12942 this.getId = function(){return null;};
12945 for(var jj = 0; jj < fl; jj++){
12947 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12948 this.ef[jj] = this.getJsonAccessor(map);
12952 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12953 if(s.totalProperty){
12954 var vt = parseInt(this.getTotal(o), 10);
12959 if(s.successProperty){
12960 var vs = this.getSuccess(o);
12961 if(vs === false || vs === 'false'){
12966 for(var i = 0; i < c; i++){
12969 var id = this.getId(n);
12970 for(var j = 0; j < fl; j++){
12972 var v = this.ef[j](n);
12974 Roo.log('missing convert for ' + f.name);
12978 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12980 var record = new Record(values, id);
12982 records[i] = record;
12988 totalRecords : totalRecords
12993 * Ext JS Library 1.1.1
12994 * Copyright(c) 2006-2007, Ext JS, LLC.
12996 * Originally Released Under LGPL - original licence link has changed is not relivant.
12999 * <script type="text/javascript">
13003 * @class Roo.data.ArrayReader
13004 * @extends Roo.data.DataReader
13005 * Data reader class to create an Array of Roo.data.Record objects from an Array.
13006 * Each element of that Array represents a row of data fields. The
13007 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
13008 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
13012 var RecordDef = Roo.data.Record.create([
13013 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
13014 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
13016 var myReader = new Roo.data.ArrayReader({
13017 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
13021 * This would consume an Array like this:
13023 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13027 * Create a new JsonReader
13028 * @param {Object} meta Metadata configuration options.
13029 * @param {Object|Array} recordType Either an Array of field definition objects
13031 * @cfg {Array} fields Array of field definition objects
13032 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
13033 * as specified to {@link Roo.data.Record#create},
13034 * or an {@link Roo.data.Record} object
13037 * created using {@link Roo.data.Record#create}.
13039 Roo.data.ArrayReader = function(meta, recordType){
13042 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13045 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13047 * Create a data block containing Roo.data.Records from an XML document.
13048 * @param {Object} o An Array of row objects which represents the dataset.
13049 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
13050 * a cache of Roo.data.Records.
13052 readRecords : function(o){
13053 var sid = this.meta ? this.meta.id : null;
13054 var recordType = this.recordType, fields = recordType.prototype.fields;
13057 for(var i = 0; i < root.length; i++){
13060 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13061 for(var j = 0, jlen = fields.length; j < jlen; j++){
13062 var f = fields.items[j];
13063 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13064 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13066 values[f.name] = v;
13068 var record = new recordType(values, id);
13070 records[records.length] = record;
13074 totalRecords : records.length
13083 * @class Roo.bootstrap.ComboBox
13084 * @extends Roo.bootstrap.TriggerField
13085 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13086 * @cfg {Boolean} append (true|false) default false
13087 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13088 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13089 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13090 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13091 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13092 * @cfg {Boolean} animate default true
13093 * @cfg {Boolean} emptyResultText only for touch device
13094 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13095 * @cfg {String} emptyTitle default ''
13097 * Create a new ComboBox.
13098 * @param {Object} config Configuration options
13100 Roo.bootstrap.ComboBox = function(config){
13101 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13105 * Fires when the dropdown list is expanded
13106 * @param {Roo.bootstrap.ComboBox} combo This combo box
13111 * Fires when the dropdown list is collapsed
13112 * @param {Roo.bootstrap.ComboBox} combo This combo box
13116 * @event beforeselect
13117 * Fires before a list item is selected. Return false to cancel the selection.
13118 * @param {Roo.bootstrap.ComboBox} combo This combo box
13119 * @param {Roo.data.Record} record The data record returned from the underlying store
13120 * @param {Number} index The index of the selected item in the dropdown list
13122 'beforeselect' : true,
13125 * Fires when a list item is selected
13126 * @param {Roo.bootstrap.ComboBox} combo This combo box
13127 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13128 * @param {Number} index The index of the selected item in the dropdown list
13132 * @event beforequery
13133 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13134 * The event object passed has these properties:
13135 * @param {Roo.bootstrap.ComboBox} combo This combo box
13136 * @param {String} query The query
13137 * @param {Boolean} forceAll true to force "all" query
13138 * @param {Boolean} cancel true to cancel the query
13139 * @param {Object} e The query event object
13141 'beforequery': true,
13144 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13145 * @param {Roo.bootstrap.ComboBox} combo This combo box
13150 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13151 * @param {Roo.bootstrap.ComboBox} combo This combo box
13152 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13157 * Fires when the remove value from the combobox array
13158 * @param {Roo.bootstrap.ComboBox} combo This combo box
13162 * @event afterremove
13163 * Fires when the remove value from the combobox array
13164 * @param {Roo.bootstrap.ComboBox} combo This combo box
13166 'afterremove' : true,
13168 * @event specialfilter
13169 * Fires when specialfilter
13170 * @param {Roo.bootstrap.ComboBox} combo This combo box
13172 'specialfilter' : true,
13175 * Fires when tick the element
13176 * @param {Roo.bootstrap.ComboBox} combo This combo box
13180 * @event touchviewdisplay
13181 * Fires when touch view require special display (default is using displayField)
13182 * @param {Roo.bootstrap.ComboBox} combo This combo box
13183 * @param {Object} cfg set html .
13185 'touchviewdisplay' : true
13190 this.tickItems = [];
13192 this.selectedIndex = -1;
13193 if(this.mode == 'local'){
13194 if(config.queryDelay === undefined){
13195 this.queryDelay = 10;
13197 if(config.minChars === undefined){
13203 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13206 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13207 * rendering into an Roo.Editor, defaults to false)
13210 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13211 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13214 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13217 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13218 * the dropdown list (defaults to undefined, with no header element)
13222 * @cfg {String/Roo.Template} tpl The template to use to render the output
13226 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13228 listWidth: undefined,
13230 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13231 * mode = 'remote' or 'text' if mode = 'local')
13233 displayField: undefined,
13236 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13237 * mode = 'remote' or 'value' if mode = 'local').
13238 * Note: use of a valueField requires the user make a selection
13239 * in order for a value to be mapped.
13241 valueField: undefined,
13243 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13248 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13249 * field's data value (defaults to the underlying DOM element's name)
13251 hiddenName: undefined,
13253 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13257 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13259 selectedClass: 'active',
13262 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13266 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13267 * anchor positions (defaults to 'tl-bl')
13269 listAlign: 'tl-bl?',
13271 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13275 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13276 * query specified by the allQuery config option (defaults to 'query')
13278 triggerAction: 'query',
13280 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13281 * (defaults to 4, does not apply if editable = false)
13285 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13286 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13290 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13291 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13295 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13296 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13300 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13301 * when editable = true (defaults to false)
13303 selectOnFocus:false,
13305 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13307 queryParam: 'query',
13309 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13310 * when mode = 'remote' (defaults to 'Loading...')
13312 loadingText: 'Loading...',
13314 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13318 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13322 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13323 * traditional select (defaults to true)
13327 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13331 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13335 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13336 * listWidth has a higher value)
13340 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13341 * allow the user to set arbitrary text into the field (defaults to false)
13343 forceSelection:false,
13345 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13346 * if typeAhead = true (defaults to 250)
13348 typeAheadDelay : 250,
13350 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13351 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13353 valueNotFoundText : undefined,
13355 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13357 blockFocus : false,
13360 * @cfg {Boolean} disableClear Disable showing of clear button.
13362 disableClear : false,
13364 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13366 alwaysQuery : false,
13369 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13374 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13376 invalidClass : "has-warning",
13379 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13381 validClass : "has-success",
13384 * @cfg {Boolean} specialFilter (true|false) special filter default false
13386 specialFilter : false,
13389 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13391 mobileTouchView : true,
13394 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13396 useNativeIOS : false,
13399 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13401 mobile_restrict_height : false,
13403 ios_options : false,
13415 btnPosition : 'right',
13416 triggerList : true,
13417 showToggleBtn : true,
13419 emptyResultText: 'Empty',
13420 triggerText : 'Select',
13423 // element that contains real text value.. (when hidden is used..)
13425 getAutoCreate : function()
13430 * Render classic select for iso
13433 if(Roo.isIOS && this.useNativeIOS){
13434 cfg = this.getAutoCreateNativeIOS();
13442 if(Roo.isTouch && this.mobileTouchView){
13443 cfg = this.getAutoCreateTouchView();
13450 if(!this.tickable){
13451 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13456 * ComboBox with tickable selections
13459 var align = this.labelAlign || this.parentLabelAlign();
13462 cls : 'form-group roo-combobox-tickable' //input-group
13465 var btn_text_select = '';
13466 var btn_text_done = '';
13467 var btn_text_cancel = '';
13469 if (this.btn_text_show) {
13470 btn_text_select = 'Select';
13471 btn_text_done = 'Done';
13472 btn_text_cancel = 'Cancel';
13477 cls : 'tickable-buttons',
13482 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13483 //html : this.triggerText
13484 html: btn_text_select
13490 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13492 html: btn_text_done
13498 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13500 html: btn_text_cancel
13506 buttons.cn.unshift({
13508 cls: 'roo-select2-search-field-input'
13514 Roo.each(buttons.cn, function(c){
13516 c.cls += ' btn-' + _this.size;
13519 if (_this.disabled) {
13526 style : 'display: contents',
13531 cls: 'form-hidden-field'
13535 cls: 'roo-select2-choices',
13539 cls: 'roo-select2-search-field',
13550 cls: 'roo-select2-container input-group roo-select2-container-multi',
13556 // cls: 'typeahead typeahead-long dropdown-menu',
13557 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13562 if(this.hasFeedback && !this.allowBlank){
13566 cls: 'glyphicon form-control-feedback'
13569 combobox.cn.push(feedback);
13574 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13575 tooltip : 'This field is required'
13577 if (Roo.bootstrap.version == 4) {
13580 style : 'display:none'
13583 if (align ==='left' && this.fieldLabel.length) {
13585 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13592 cls : 'control-label col-form-label',
13593 html : this.fieldLabel
13605 var labelCfg = cfg.cn[1];
13606 var contentCfg = cfg.cn[2];
13609 if(this.indicatorpos == 'right'){
13615 cls : 'control-label col-form-label',
13619 html : this.fieldLabel
13635 labelCfg = cfg.cn[0];
13636 contentCfg = cfg.cn[1];
13640 if(this.labelWidth > 12){
13641 labelCfg.style = "width: " + this.labelWidth + 'px';
13644 if(this.labelWidth < 13 && this.labelmd == 0){
13645 this.labelmd = this.labelWidth;
13648 if(this.labellg > 0){
13649 labelCfg.cls += ' col-lg-' + this.labellg;
13650 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13653 if(this.labelmd > 0){
13654 labelCfg.cls += ' col-md-' + this.labelmd;
13655 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13658 if(this.labelsm > 0){
13659 labelCfg.cls += ' col-sm-' + this.labelsm;
13660 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13663 if(this.labelxs > 0){
13664 labelCfg.cls += ' col-xs-' + this.labelxs;
13665 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13669 } else if ( this.fieldLabel.length) {
13670 // Roo.log(" label");
13675 //cls : 'input-group-addon',
13676 html : this.fieldLabel
13681 if(this.indicatorpos == 'right'){
13685 //cls : 'input-group-addon',
13686 html : this.fieldLabel
13696 // Roo.log(" no label && no align");
13703 ['xs','sm','md','lg'].map(function(size){
13704 if (settings[size]) {
13705 cfg.cls += ' col-' + size + '-' + settings[size];
13713 _initEventsCalled : false,
13716 initEvents: function()
13718 if (this._initEventsCalled) { // as we call render... prevent looping...
13721 this._initEventsCalled = true;
13724 throw "can not find store for combo";
13727 this.indicator = this.indicatorEl();
13729 this.store = Roo.factory(this.store, Roo.data);
13730 this.store.parent = this;
13732 // if we are building from html. then this element is so complex, that we can not really
13733 // use the rendered HTML.
13734 // so we have to trash and replace the previous code.
13735 if (Roo.XComponent.build_from_html) {
13736 // remove this element....
13737 var e = this.el.dom, k=0;
13738 while (e ) { e = e.previousSibling; ++k;}
13743 this.rendered = false;
13745 this.render(this.parent().getChildContainer(true), k);
13748 if(Roo.isIOS && this.useNativeIOS){
13749 this.initIOSView();
13757 if(Roo.isTouch && this.mobileTouchView){
13758 this.initTouchView();
13763 this.initTickableEvents();
13767 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13769 if(this.hiddenName){
13771 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13773 this.hiddenField.dom.value =
13774 this.hiddenValue !== undefined ? this.hiddenValue :
13775 this.value !== undefined ? this.value : '';
13777 // prevent input submission
13778 this.el.dom.removeAttribute('name');
13779 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13784 // this.el.dom.setAttribute('autocomplete', 'off');
13787 var cls = 'x-combo-list';
13789 //this.list = new Roo.Layer({
13790 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13796 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13797 _this.list.setWidth(lw);
13800 this.list.on('mouseover', this.onViewOver, this);
13801 this.list.on('mousemove', this.onViewMove, this);
13802 this.list.on('scroll', this.onViewScroll, this);
13805 this.list.swallowEvent('mousewheel');
13806 this.assetHeight = 0;
13809 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13810 this.assetHeight += this.header.getHeight();
13813 this.innerList = this.list.createChild({cls:cls+'-inner'});
13814 this.innerList.on('mouseover', this.onViewOver, this);
13815 this.innerList.on('mousemove', this.onViewMove, this);
13816 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13818 if(this.allowBlank && !this.pageSize && !this.disableClear){
13819 this.footer = this.list.createChild({cls:cls+'-ft'});
13820 this.pageTb = new Roo.Toolbar(this.footer);
13824 this.footer = this.list.createChild({cls:cls+'-ft'});
13825 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13826 {pageSize: this.pageSize});
13830 if (this.pageTb && this.allowBlank && !this.disableClear) {
13832 this.pageTb.add(new Roo.Toolbar.Fill(), {
13833 cls: 'x-btn-icon x-btn-clear',
13835 handler: function()
13838 _this.clearValue();
13839 _this.onSelect(false, -1);
13844 this.assetHeight += this.footer.getHeight();
13849 this.tpl = Roo.bootstrap.version == 4 ?
13850 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13851 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13854 this.view = new Roo.View(this.list, this.tpl, {
13855 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13857 //this.view.wrapEl.setDisplayed(false);
13858 this.view.on('click', this.onViewClick, this);
13861 this.store.on('beforeload', this.onBeforeLoad, this);
13862 this.store.on('load', this.onLoad, this);
13863 this.store.on('loadexception', this.onLoadException, this);
13865 if(this.resizable){
13866 this.resizer = new Roo.Resizable(this.list, {
13867 pinned:true, handles:'se'
13869 this.resizer.on('resize', function(r, w, h){
13870 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13871 this.listWidth = w;
13872 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13873 this.restrictHeight();
13875 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13878 if(!this.editable){
13879 this.editable = true;
13880 this.setEditable(false);
13885 if (typeof(this.events.add.listeners) != 'undefined') {
13887 this.addicon = this.wrap.createChild(
13888 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13890 this.addicon.on('click', function(e) {
13891 this.fireEvent('add', this);
13894 if (typeof(this.events.edit.listeners) != 'undefined') {
13896 this.editicon = this.wrap.createChild(
13897 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13898 if (this.addicon) {
13899 this.editicon.setStyle('margin-left', '40px');
13901 this.editicon.on('click', function(e) {
13903 // we fire even if inothing is selected..
13904 this.fireEvent('edit', this, this.lastData );
13910 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13911 "up" : function(e){
13912 this.inKeyMode = true;
13916 "down" : function(e){
13917 if(!this.isExpanded()){
13918 this.onTriggerClick();
13920 this.inKeyMode = true;
13925 "enter" : function(e){
13926 // this.onViewClick();
13930 if(this.fireEvent("specialkey", this, e)){
13931 this.onViewClick(false);
13937 "esc" : function(e){
13941 "tab" : function(e){
13944 if(this.fireEvent("specialkey", this, e)){
13945 this.onViewClick(false);
13953 doRelay : function(foo, bar, hname){
13954 if(hname == 'down' || this.scope.isExpanded()){
13955 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13964 this.queryDelay = Math.max(this.queryDelay || 10,
13965 this.mode == 'local' ? 10 : 250);
13968 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13970 if(this.typeAhead){
13971 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13973 if(this.editable !== false){
13974 this.inputEl().on("keyup", this.onKeyUp, this);
13976 if(this.forceSelection){
13977 this.inputEl().on('blur', this.doForce, this);
13981 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13982 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13986 initTickableEvents: function()
13990 if(this.hiddenName){
13992 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13994 this.hiddenField.dom.value =
13995 this.hiddenValue !== undefined ? this.hiddenValue :
13996 this.value !== undefined ? this.value : '';
13998 // prevent input submission
13999 this.el.dom.removeAttribute('name');
14000 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14005 // this.list = this.el.select('ul.dropdown-menu',true).first();
14007 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14008 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14009 if(this.triggerList){
14010 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
14013 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
14014 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
14016 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
14017 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
14019 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
14020 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
14022 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
14023 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
14024 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
14027 this.cancelBtn.hide();
14032 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14033 _this.list.setWidth(lw);
14036 this.list.on('mouseover', this.onViewOver, this);
14037 this.list.on('mousemove', this.onViewMove, this);
14039 this.list.on('scroll', this.onViewScroll, this);
14042 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14043 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14046 this.view = new Roo.View(this.list, this.tpl, {
14051 selectedClass: this.selectedClass
14054 //this.view.wrapEl.setDisplayed(false);
14055 this.view.on('click', this.onViewClick, this);
14059 this.store.on('beforeload', this.onBeforeLoad, this);
14060 this.store.on('load', this.onLoad, this);
14061 this.store.on('loadexception', this.onLoadException, this);
14064 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14065 "up" : function(e){
14066 this.inKeyMode = true;
14070 "down" : function(e){
14071 this.inKeyMode = true;
14075 "enter" : function(e){
14076 if(this.fireEvent("specialkey", this, e)){
14077 this.onViewClick(false);
14083 "esc" : function(e){
14084 this.onTickableFooterButtonClick(e, false, false);
14087 "tab" : function(e){
14088 this.fireEvent("specialkey", this, e);
14090 this.onTickableFooterButtonClick(e, false, false);
14097 doRelay : function(e, fn, key){
14098 if(this.scope.isExpanded()){
14099 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14108 this.queryDelay = Math.max(this.queryDelay || 10,
14109 this.mode == 'local' ? 10 : 250);
14112 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14114 if(this.typeAhead){
14115 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14118 if(this.editable !== false){
14119 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14122 this.indicator = this.indicatorEl();
14124 if(this.indicator){
14125 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14126 this.indicator.hide();
14131 onDestroy : function(){
14133 this.view.setStore(null);
14134 this.view.el.removeAllListeners();
14135 this.view.el.remove();
14136 this.view.purgeListeners();
14139 this.list.dom.innerHTML = '';
14143 this.store.un('beforeload', this.onBeforeLoad, this);
14144 this.store.un('load', this.onLoad, this);
14145 this.store.un('loadexception', this.onLoadException, this);
14147 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14151 fireKey : function(e){
14152 if(e.isNavKeyPress() && !this.list.isVisible()){
14153 this.fireEvent("specialkey", this, e);
14158 onResize: function(w, h){
14159 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14161 // if(typeof w != 'number'){
14162 // // we do not handle it!?!?
14165 // var tw = this.trigger.getWidth();
14166 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14167 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14169 // this.inputEl().setWidth( this.adjustWidth('input', x));
14171 // //this.trigger.setStyle('left', x+'px');
14173 // if(this.list && this.listWidth === undefined){
14174 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14175 // this.list.setWidth(lw);
14176 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14184 * Allow or prevent the user from directly editing the field text. If false is passed,
14185 * the user will only be able to select from the items defined in the dropdown list. This method
14186 * is the runtime equivalent of setting the 'editable' config option at config time.
14187 * @param {Boolean} value True to allow the user to directly edit the field text
14189 setEditable : function(value){
14190 if(value == this.editable){
14193 this.editable = value;
14195 this.inputEl().dom.setAttribute('readOnly', true);
14196 this.inputEl().on('mousedown', this.onTriggerClick, this);
14197 this.inputEl().addClass('x-combo-noedit');
14199 this.inputEl().dom.setAttribute('readOnly', false);
14200 this.inputEl().un('mousedown', this.onTriggerClick, this);
14201 this.inputEl().removeClass('x-combo-noedit');
14207 onBeforeLoad : function(combo,opts){
14208 if(!this.hasFocus){
14212 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14214 this.restrictHeight();
14215 this.selectedIndex = -1;
14219 onLoad : function(){
14221 this.hasQuery = false;
14223 if(!this.hasFocus){
14227 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14228 this.loading.hide();
14231 if(this.store.getCount() > 0){
14234 this.restrictHeight();
14235 if(this.lastQuery == this.allQuery){
14236 if(this.editable && !this.tickable){
14237 this.inputEl().dom.select();
14241 !this.selectByValue(this.value, true) &&
14244 !this.store.lastOptions ||
14245 typeof(this.store.lastOptions.add) == 'undefined' ||
14246 this.store.lastOptions.add != true
14249 this.select(0, true);
14252 if(this.autoFocus){
14255 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14256 this.taTask.delay(this.typeAheadDelay);
14260 this.onEmptyResults();
14266 onLoadException : function()
14268 this.hasQuery = false;
14270 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14271 this.loading.hide();
14274 if(this.tickable && this.editable){
14279 // only causes errors at present
14280 //Roo.log(this.store.reader.jsonData);
14281 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14283 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14289 onTypeAhead : function(){
14290 if(this.store.getCount() > 0){
14291 var r = this.store.getAt(0);
14292 var newValue = r.data[this.displayField];
14293 var len = newValue.length;
14294 var selStart = this.getRawValue().length;
14296 if(selStart != len){
14297 this.setRawValue(newValue);
14298 this.selectText(selStart, newValue.length);
14304 onSelect : function(record, index){
14306 if(this.fireEvent('beforeselect', this, record, index) !== false){
14308 this.setFromData(index > -1 ? record.data : false);
14311 this.fireEvent('select', this, record, index);
14316 * Returns the currently selected field value or empty string if no value is set.
14317 * @return {String} value The selected value
14319 getValue : function()
14321 if(Roo.isIOS && this.useNativeIOS){
14322 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14326 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14329 if(this.valueField){
14330 return typeof this.value != 'undefined' ? this.value : '';
14332 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14336 getRawValue : function()
14338 if(Roo.isIOS && this.useNativeIOS){
14339 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14342 var v = this.inputEl().getValue();
14348 * Clears any text/value currently set in the field
14350 clearValue : function(){
14352 if(this.hiddenField){
14353 this.hiddenField.dom.value = '';
14356 this.setRawValue('');
14357 this.lastSelectionText = '';
14358 this.lastData = false;
14360 var close = this.closeTriggerEl();
14371 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14372 * will be displayed in the field. If the value does not match the data value of an existing item,
14373 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14374 * Otherwise the field will be blank (although the value will still be set).
14375 * @param {String} value The value to match
14377 setValue : function(v)
14379 if(Roo.isIOS && this.useNativeIOS){
14380 this.setIOSValue(v);
14390 if(this.valueField){
14391 var r = this.findRecord(this.valueField, v);
14393 text = r.data[this.displayField];
14394 }else if(this.valueNotFoundText !== undefined){
14395 text = this.valueNotFoundText;
14398 this.lastSelectionText = text;
14399 if(this.hiddenField){
14400 this.hiddenField.dom.value = v;
14402 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14405 var close = this.closeTriggerEl();
14408 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14414 * @property {Object} the last set data for the element
14419 * Sets the value of the field based on a object which is related to the record format for the store.
14420 * @param {Object} value the value to set as. or false on reset?
14422 setFromData : function(o){
14429 var dv = ''; // display value
14430 var vv = ''; // value value..
14432 if (this.displayField) {
14433 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14435 // this is an error condition!!!
14436 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14439 if(this.valueField){
14440 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14443 var close = this.closeTriggerEl();
14446 if(dv.length || vv * 1 > 0){
14448 this.blockFocus=true;
14454 if(this.hiddenField){
14455 this.hiddenField.dom.value = vv;
14457 this.lastSelectionText = dv;
14458 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14462 // no hidden field.. - we store the value in 'value', but still display
14463 // display field!!!!
14464 this.lastSelectionText = dv;
14465 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14472 reset : function(){
14473 // overridden so that last data is reset..
14480 this.setValue(this.originalValue);
14481 //this.clearInvalid();
14482 this.lastData = false;
14484 this.view.clearSelections();
14490 findRecord : function(prop, value){
14492 if(this.store.getCount() > 0){
14493 this.store.each(function(r){
14494 if(r.data[prop] == value){
14504 getName: function()
14506 // returns hidden if it's set..
14507 if (!this.rendered) {return ''};
14508 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14512 onViewMove : function(e, t){
14513 this.inKeyMode = false;
14517 onViewOver : function(e, t){
14518 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14521 var item = this.view.findItemFromChild(t);
14524 var index = this.view.indexOf(item);
14525 this.select(index, false);
14530 onViewClick : function(view, doFocus, el, e)
14532 var index = this.view.getSelectedIndexes()[0];
14534 var r = this.store.getAt(index);
14538 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14545 Roo.each(this.tickItems, function(v,k){
14547 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14549 _this.tickItems.splice(k, 1);
14551 if(typeof(e) == 'undefined' && view == false){
14552 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14564 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14565 this.tickItems.push(r.data);
14568 if(typeof(e) == 'undefined' && view == false){
14569 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14576 this.onSelect(r, index);
14578 if(doFocus !== false && !this.blockFocus){
14579 this.inputEl().focus();
14584 restrictHeight : function(){
14585 //this.innerList.dom.style.height = '';
14586 //var inner = this.innerList.dom;
14587 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14588 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14589 //this.list.beginUpdate();
14590 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14591 this.list.alignTo(this.inputEl(), this.listAlign);
14592 this.list.alignTo(this.inputEl(), this.listAlign);
14593 //this.list.endUpdate();
14597 onEmptyResults : function(){
14599 if(this.tickable && this.editable){
14600 this.hasFocus = false;
14601 this.restrictHeight();
14609 * Returns true if the dropdown list is expanded, else false.
14611 isExpanded : function(){
14612 return this.list.isVisible();
14616 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14617 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14618 * @param {String} value The data value of the item to select
14619 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14620 * selected item if it is not currently in view (defaults to true)
14621 * @return {Boolean} True if the value matched an item in the list, else false
14623 selectByValue : function(v, scrollIntoView){
14624 if(v !== undefined && v !== null){
14625 var r = this.findRecord(this.valueField || this.displayField, v);
14627 this.select(this.store.indexOf(r), scrollIntoView);
14635 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14636 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14637 * @param {Number} index The zero-based index of the list item to select
14638 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14639 * selected item if it is not currently in view (defaults to true)
14641 select : function(index, scrollIntoView){
14642 this.selectedIndex = index;
14643 this.view.select(index);
14644 if(scrollIntoView !== false){
14645 var el = this.view.getNode(index);
14647 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14650 this.list.scrollChildIntoView(el, false);
14656 selectNext : function(){
14657 var ct = this.store.getCount();
14659 if(this.selectedIndex == -1){
14661 }else if(this.selectedIndex < ct-1){
14662 this.select(this.selectedIndex+1);
14668 selectPrev : function(){
14669 var ct = this.store.getCount();
14671 if(this.selectedIndex == -1){
14673 }else if(this.selectedIndex != 0){
14674 this.select(this.selectedIndex-1);
14680 onKeyUp : function(e){
14681 if(this.editable !== false && !e.isSpecialKey()){
14682 this.lastKey = e.getKey();
14683 this.dqTask.delay(this.queryDelay);
14688 validateBlur : function(){
14689 return !this.list || !this.list.isVisible();
14693 initQuery : function(){
14695 var v = this.getRawValue();
14697 if(this.tickable && this.editable){
14698 v = this.tickableInputEl().getValue();
14705 doForce : function(){
14706 if(this.inputEl().dom.value.length > 0){
14707 this.inputEl().dom.value =
14708 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14714 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14715 * query allowing the query action to be canceled if needed.
14716 * @param {String} query The SQL query to execute
14717 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14718 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14719 * saved in the current store (defaults to false)
14721 doQuery : function(q, forceAll){
14723 if(q === undefined || q === null){
14728 forceAll: forceAll,
14732 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14737 forceAll = qe.forceAll;
14738 if(forceAll === true || (q.length >= this.minChars)){
14740 this.hasQuery = true;
14742 if(this.lastQuery != q || this.alwaysQuery){
14743 this.lastQuery = q;
14744 if(this.mode == 'local'){
14745 this.selectedIndex = -1;
14747 this.store.clearFilter();
14750 if(this.specialFilter){
14751 this.fireEvent('specialfilter', this);
14756 this.store.filter(this.displayField, q);
14759 this.store.fireEvent("datachanged", this.store);
14766 this.store.baseParams[this.queryParam] = q;
14768 var options = {params : this.getParams(q)};
14771 options.add = true;
14772 options.params.start = this.page * this.pageSize;
14775 this.store.load(options);
14778 * this code will make the page width larger, at the beginning, the list not align correctly,
14779 * we should expand the list on onLoad
14780 * so command out it
14785 this.selectedIndex = -1;
14790 this.loadNext = false;
14794 getParams : function(q){
14796 //p[this.queryParam] = q;
14800 p.limit = this.pageSize;
14806 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14808 collapse : function(){
14809 if(!this.isExpanded()){
14815 this.hasFocus = false;
14819 this.cancelBtn.hide();
14820 this.trigger.show();
14823 this.tickableInputEl().dom.value = '';
14824 this.tickableInputEl().blur();
14829 Roo.get(document).un('mousedown', this.collapseIf, this);
14830 Roo.get(document).un('mousewheel', this.collapseIf, this);
14831 if (!this.editable) {
14832 Roo.get(document).un('keydown', this.listKeyPress, this);
14834 this.fireEvent('collapse', this);
14840 collapseIf : function(e){
14841 var in_combo = e.within(this.el);
14842 var in_list = e.within(this.list);
14843 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14845 if (in_combo || in_list || is_list) {
14846 //e.stopPropagation();
14851 this.onTickableFooterButtonClick(e, false, false);
14859 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14861 expand : function(){
14863 if(this.isExpanded() || !this.hasFocus){
14867 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14868 this.list.setWidth(lw);
14874 this.restrictHeight();
14878 this.tickItems = Roo.apply([], this.item);
14881 this.cancelBtn.show();
14882 this.trigger.hide();
14885 this.tickableInputEl().focus();
14890 Roo.get(document).on('mousedown', this.collapseIf, this);
14891 Roo.get(document).on('mousewheel', this.collapseIf, this);
14892 if (!this.editable) {
14893 Roo.get(document).on('keydown', this.listKeyPress, this);
14896 this.fireEvent('expand', this);
14900 // Implements the default empty TriggerField.onTriggerClick function
14901 onTriggerClick : function(e)
14903 Roo.log('trigger click');
14905 if(this.disabled || !this.triggerList){
14910 this.loadNext = false;
14912 if(this.isExpanded()){
14914 if (!this.blockFocus) {
14915 this.inputEl().focus();
14919 this.hasFocus = true;
14920 if(this.triggerAction == 'all') {
14921 this.doQuery(this.allQuery, true);
14923 this.doQuery(this.getRawValue());
14925 if (!this.blockFocus) {
14926 this.inputEl().focus();
14931 onTickableTriggerClick : function(e)
14938 this.loadNext = false;
14939 this.hasFocus = true;
14941 if(this.triggerAction == 'all') {
14942 this.doQuery(this.allQuery, true);
14944 this.doQuery(this.getRawValue());
14948 onSearchFieldClick : function(e)
14950 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14951 this.onTickableFooterButtonClick(e, false, false);
14955 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14960 this.loadNext = false;
14961 this.hasFocus = true;
14963 if(this.triggerAction == 'all') {
14964 this.doQuery(this.allQuery, true);
14966 this.doQuery(this.getRawValue());
14970 listKeyPress : function(e)
14972 //Roo.log('listkeypress');
14973 // scroll to first matching element based on key pres..
14974 if (e.isSpecialKey()) {
14977 var k = String.fromCharCode(e.getKey()).toUpperCase();
14980 var csel = this.view.getSelectedNodes();
14981 var cselitem = false;
14983 var ix = this.view.indexOf(csel[0]);
14984 cselitem = this.store.getAt(ix);
14985 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14991 this.store.each(function(v) {
14993 // start at existing selection.
14994 if (cselitem.id == v.id) {
15000 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
15001 match = this.store.indexOf(v);
15007 if (match === false) {
15008 return true; // no more action?
15011 this.view.select(match);
15012 var sn = Roo.get(this.view.getSelectedNodes()[0]);
15013 sn.scrollIntoView(sn.dom.parentNode, false);
15016 onViewScroll : function(e, t){
15018 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){
15022 this.hasQuery = true;
15024 this.loading = this.list.select('.loading', true).first();
15026 if(this.loading === null){
15027 this.list.createChild({
15029 cls: 'loading roo-select2-more-results roo-select2-active',
15030 html: 'Loading more results...'
15033 this.loading = this.list.select('.loading', true).first();
15035 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15037 this.loading.hide();
15040 this.loading.show();
15045 this.loadNext = true;
15047 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15052 addItem : function(o)
15054 var dv = ''; // display value
15056 if (this.displayField) {
15057 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15059 // this is an error condition!!!
15060 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15067 var choice = this.choices.createChild({
15069 cls: 'roo-select2-search-choice',
15078 cls: 'roo-select2-search-choice-close fa fa-times',
15083 }, this.searchField);
15085 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15087 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15095 this.inputEl().dom.value = '';
15100 onRemoveItem : function(e, _self, o)
15102 e.preventDefault();
15104 this.lastItem = Roo.apply([], this.item);
15106 var index = this.item.indexOf(o.data) * 1;
15109 Roo.log('not this item?!');
15113 this.item.splice(index, 1);
15118 this.fireEvent('remove', this, e);
15124 syncValue : function()
15126 if(!this.item.length){
15133 Roo.each(this.item, function(i){
15134 if(_this.valueField){
15135 value.push(i[_this.valueField]);
15142 this.value = value.join(',');
15144 if(this.hiddenField){
15145 this.hiddenField.dom.value = this.value;
15148 this.store.fireEvent("datachanged", this.store);
15153 clearItem : function()
15155 if(!this.multiple){
15161 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15169 if(this.tickable && !Roo.isTouch){
15170 this.view.refresh();
15174 inputEl: function ()
15176 if(Roo.isIOS && this.useNativeIOS){
15177 return this.el.select('select.roo-ios-select', true).first();
15180 if(Roo.isTouch && this.mobileTouchView){
15181 return this.el.select('input.form-control',true).first();
15185 return this.searchField;
15188 return this.el.select('input.form-control',true).first();
15191 onTickableFooterButtonClick : function(e, btn, el)
15193 e.preventDefault();
15195 this.lastItem = Roo.apply([], this.item);
15197 if(btn && btn.name == 'cancel'){
15198 this.tickItems = Roo.apply([], this.item);
15207 Roo.each(this.tickItems, function(o){
15215 validate : function()
15217 if(this.getVisibilityEl().hasClass('hidden')){
15221 var v = this.getRawValue();
15224 v = this.getValue();
15227 if(this.disabled || this.allowBlank || v.length){
15232 this.markInvalid();
15236 tickableInputEl : function()
15238 if(!this.tickable || !this.editable){
15239 return this.inputEl();
15242 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15246 getAutoCreateTouchView : function()
15251 cls: 'form-group' //input-group
15257 type : this.inputType,
15258 cls : 'form-control x-combo-noedit',
15259 autocomplete: 'new-password',
15260 placeholder : this.placeholder || '',
15265 input.name = this.name;
15269 input.cls += ' input-' + this.size;
15272 if (this.disabled) {
15273 input.disabled = true;
15284 inputblock.cls += ' input-group';
15286 inputblock.cn.unshift({
15288 cls : 'input-group-addon input-group-prepend input-group-text',
15293 if(this.removable && !this.multiple){
15294 inputblock.cls += ' roo-removable';
15296 inputblock.cn.push({
15299 cls : 'roo-combo-removable-btn close'
15303 if(this.hasFeedback && !this.allowBlank){
15305 inputblock.cls += ' has-feedback';
15307 inputblock.cn.push({
15309 cls: 'glyphicon form-control-feedback'
15316 inputblock.cls += (this.before) ? '' : ' input-group';
15318 inputblock.cn.push({
15320 cls : 'input-group-addon input-group-append input-group-text',
15326 var ibwrap = inputblock;
15331 cls: 'roo-select2-choices',
15335 cls: 'roo-select2-search-field',
15348 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15353 cls: 'form-hidden-field'
15359 if(!this.multiple && this.showToggleBtn){
15366 if (this.caret != false) {
15369 cls: 'fa fa-' + this.caret
15376 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15381 cls: 'combobox-clear',
15395 combobox.cls += ' roo-select2-container-multi';
15398 var align = this.labelAlign || this.parentLabelAlign();
15400 if (align ==='left' && this.fieldLabel.length) {
15405 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15406 tooltip : 'This field is required'
15410 cls : 'control-label col-form-label',
15411 html : this.fieldLabel
15422 var labelCfg = cfg.cn[1];
15423 var contentCfg = cfg.cn[2];
15426 if(this.indicatorpos == 'right'){
15431 cls : 'control-label col-form-label',
15435 html : this.fieldLabel
15439 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15440 tooltip : 'This field is required'
15453 labelCfg = cfg.cn[0];
15454 contentCfg = cfg.cn[1];
15459 if(this.labelWidth > 12){
15460 labelCfg.style = "width: " + this.labelWidth + 'px';
15463 if(this.labelWidth < 13 && this.labelmd == 0){
15464 this.labelmd = this.labelWidth;
15467 if(this.labellg > 0){
15468 labelCfg.cls += ' col-lg-' + this.labellg;
15469 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15472 if(this.labelmd > 0){
15473 labelCfg.cls += ' col-md-' + this.labelmd;
15474 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15477 if(this.labelsm > 0){
15478 labelCfg.cls += ' col-sm-' + this.labelsm;
15479 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15482 if(this.labelxs > 0){
15483 labelCfg.cls += ' col-xs-' + this.labelxs;
15484 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15488 } else if ( this.fieldLabel.length) {
15492 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15493 tooltip : 'This field is required'
15497 cls : 'control-label',
15498 html : this.fieldLabel
15509 if(this.indicatorpos == 'right'){
15513 cls : 'control-label',
15514 html : this.fieldLabel,
15518 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15519 tooltip : 'This field is required'
15536 var settings = this;
15538 ['xs','sm','md','lg'].map(function(size){
15539 if (settings[size]) {
15540 cfg.cls += ' col-' + size + '-' + settings[size];
15547 initTouchView : function()
15549 this.renderTouchView();
15551 this.touchViewEl.on('scroll', function(){
15552 this.el.dom.scrollTop = 0;
15555 this.originalValue = this.getValue();
15557 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15559 this.inputEl().on("click", this.showTouchView, this);
15560 if (this.triggerEl) {
15561 this.triggerEl.on("click", this.showTouchView, this);
15565 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15566 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15568 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15570 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15571 this.store.on('load', this.onTouchViewLoad, this);
15572 this.store.on('loadexception', this.onTouchViewLoadException, this);
15574 if(this.hiddenName){
15576 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15578 this.hiddenField.dom.value =
15579 this.hiddenValue !== undefined ? this.hiddenValue :
15580 this.value !== undefined ? this.value : '';
15582 this.el.dom.removeAttribute('name');
15583 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15587 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15588 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15591 if(this.removable && !this.multiple){
15592 var close = this.closeTriggerEl();
15594 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15595 close.on('click', this.removeBtnClick, this, close);
15599 * fix the bug in Safari iOS8
15601 this.inputEl().on("focus", function(e){
15602 document.activeElement.blur();
15605 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15612 renderTouchView : function()
15614 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15615 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15617 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15618 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15620 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15621 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15622 this.touchViewBodyEl.setStyle('overflow', 'auto');
15624 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15625 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15627 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15628 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15632 showTouchView : function()
15638 this.touchViewHeaderEl.hide();
15640 if(this.modalTitle.length){
15641 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15642 this.touchViewHeaderEl.show();
15645 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15646 this.touchViewEl.show();
15648 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15650 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15651 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15653 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15655 if(this.modalTitle.length){
15656 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15659 this.touchViewBodyEl.setHeight(bodyHeight);
15663 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15665 this.touchViewEl.addClass('in');
15668 if(this._touchViewMask){
15669 Roo.get(document.body).addClass("x-body-masked");
15670 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15671 this._touchViewMask.setStyle('z-index', 10000);
15672 this._touchViewMask.addClass('show');
15675 this.doTouchViewQuery();
15679 hideTouchView : function()
15681 this.touchViewEl.removeClass('in');
15685 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15687 this.touchViewEl.setStyle('display', 'none');
15690 if(this._touchViewMask){
15691 this._touchViewMask.removeClass('show');
15692 Roo.get(document.body).removeClass("x-body-masked");
15696 setTouchViewValue : function()
15703 Roo.each(this.tickItems, function(o){
15708 this.hideTouchView();
15711 doTouchViewQuery : function()
15720 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15724 if(!this.alwaysQuery || this.mode == 'local'){
15725 this.onTouchViewLoad();
15732 onTouchViewBeforeLoad : function(combo,opts)
15738 onTouchViewLoad : function()
15740 if(this.store.getCount() < 1){
15741 this.onTouchViewEmptyResults();
15745 this.clearTouchView();
15747 var rawValue = this.getRawValue();
15749 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15751 this.tickItems = [];
15753 this.store.data.each(function(d, rowIndex){
15754 var row = this.touchViewListGroup.createChild(template);
15756 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15757 row.addClass(d.data.cls);
15760 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15763 html : d.data[this.displayField]
15766 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15767 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15770 row.removeClass('selected');
15771 if(!this.multiple && this.valueField &&
15772 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15775 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15776 row.addClass('selected');
15779 if(this.multiple && this.valueField &&
15780 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15784 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15785 this.tickItems.push(d.data);
15788 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15792 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15794 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15796 if(this.modalTitle.length){
15797 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15800 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15802 if(this.mobile_restrict_height && listHeight < bodyHeight){
15803 this.touchViewBodyEl.setHeight(listHeight);
15808 if(firstChecked && listHeight > bodyHeight){
15809 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15814 onTouchViewLoadException : function()
15816 this.hideTouchView();
15819 onTouchViewEmptyResults : function()
15821 this.clearTouchView();
15823 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15825 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15829 clearTouchView : function()
15831 this.touchViewListGroup.dom.innerHTML = '';
15834 onTouchViewClick : function(e, el, o)
15836 e.preventDefault();
15839 var rowIndex = o.rowIndex;
15841 var r = this.store.getAt(rowIndex);
15843 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15845 if(!this.multiple){
15846 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15847 c.dom.removeAttribute('checked');
15850 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15852 this.setFromData(r.data);
15854 var close = this.closeTriggerEl();
15860 this.hideTouchView();
15862 this.fireEvent('select', this, r, rowIndex);
15867 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15868 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15869 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15873 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15874 this.addItem(r.data);
15875 this.tickItems.push(r.data);
15879 getAutoCreateNativeIOS : function()
15882 cls: 'form-group' //input-group,
15887 cls : 'roo-ios-select'
15891 combobox.name = this.name;
15894 if (this.disabled) {
15895 combobox.disabled = true;
15898 var settings = this;
15900 ['xs','sm','md','lg'].map(function(size){
15901 if (settings[size]) {
15902 cfg.cls += ' col-' + size + '-' + settings[size];
15912 initIOSView : function()
15914 this.store.on('load', this.onIOSViewLoad, this);
15919 onIOSViewLoad : function()
15921 if(this.store.getCount() < 1){
15925 this.clearIOSView();
15927 if(this.allowBlank) {
15929 var default_text = '-- SELECT --';
15931 if(this.placeholder.length){
15932 default_text = this.placeholder;
15935 if(this.emptyTitle.length){
15936 default_text += ' - ' + this.emptyTitle + ' -';
15939 var opt = this.inputEl().createChild({
15942 html : default_text
15946 o[this.valueField] = 0;
15947 o[this.displayField] = default_text;
15949 this.ios_options.push({
15956 this.store.data.each(function(d, rowIndex){
15960 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15961 html = d.data[this.displayField];
15966 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15967 value = d.data[this.valueField];
15976 if(this.value == d.data[this.valueField]){
15977 option['selected'] = true;
15980 var opt = this.inputEl().createChild(option);
15982 this.ios_options.push({
15989 this.inputEl().on('change', function(){
15990 this.fireEvent('select', this);
15995 clearIOSView: function()
15997 this.inputEl().dom.innerHTML = '';
15999 this.ios_options = [];
16002 setIOSValue: function(v)
16006 if(!this.ios_options){
16010 Roo.each(this.ios_options, function(opts){
16012 opts.el.dom.removeAttribute('selected');
16014 if(opts.data[this.valueField] != v){
16018 opts.el.dom.setAttribute('selected', true);
16024 * @cfg {Boolean} grow
16028 * @cfg {Number} growMin
16032 * @cfg {Number} growMax
16041 Roo.apply(Roo.bootstrap.ComboBox, {
16045 cls: 'modal-header',
16067 cls: 'list-group-item',
16071 cls: 'roo-combobox-list-group-item-value'
16075 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16089 listItemCheckbox : {
16091 cls: 'list-group-item',
16095 cls: 'roo-combobox-list-group-item-value'
16099 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16115 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16120 cls: 'modal-footer',
16128 cls: 'col-xs-6 text-left',
16131 cls: 'btn btn-danger roo-touch-view-cancel',
16137 cls: 'col-xs-6 text-right',
16140 cls: 'btn btn-success roo-touch-view-ok',
16151 Roo.apply(Roo.bootstrap.ComboBox, {
16153 touchViewTemplate : {
16155 cls: 'modal fade roo-combobox-touch-view',
16159 cls: 'modal-dialog',
16160 style : 'position:fixed', // we have to fix position....
16164 cls: 'modal-content',
16166 Roo.bootstrap.ComboBox.header,
16167 Roo.bootstrap.ComboBox.body,
16168 Roo.bootstrap.ComboBox.footer
16177 * Ext JS Library 1.1.1
16178 * Copyright(c) 2006-2007, Ext JS, LLC.
16180 * Originally Released Under LGPL - original licence link has changed is not relivant.
16183 * <script type="text/javascript">
16188 * @extends Roo.util.Observable
16189 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16190 * This class also supports single and multi selection modes. <br>
16191 * Create a data model bound view:
16193 var store = new Roo.data.Store(...);
16195 var view = new Roo.View({
16197 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16199 singleSelect: true,
16200 selectedClass: "ydataview-selected",
16204 // listen for node click?
16205 view.on("click", function(vw, index, node, e){
16206 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16210 dataModel.load("foobar.xml");
16212 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16214 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16215 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16217 * Note: old style constructor is still suported (container, template, config)
16220 * Create a new View
16221 * @param {Object} config The config object
16224 Roo.View = function(config, depreciated_tpl, depreciated_config){
16226 this.parent = false;
16228 if (typeof(depreciated_tpl) == 'undefined') {
16229 // new way.. - universal constructor.
16230 Roo.apply(this, config);
16231 this.el = Roo.get(this.el);
16234 this.el = Roo.get(config);
16235 this.tpl = depreciated_tpl;
16236 Roo.apply(this, depreciated_config);
16238 this.wrapEl = this.el.wrap().wrap();
16239 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16242 if(typeof(this.tpl) == "string"){
16243 this.tpl = new Roo.Template(this.tpl);
16245 // support xtype ctors..
16246 this.tpl = new Roo.factory(this.tpl, Roo);
16250 this.tpl.compile();
16255 * @event beforeclick
16256 * Fires before a click is processed. Returns false to cancel the default action.
16257 * @param {Roo.View} this
16258 * @param {Number} index The index of the target node
16259 * @param {HTMLElement} node The target node
16260 * @param {Roo.EventObject} e The raw event object
16262 "beforeclick" : true,
16265 * Fires when a template node is clicked.
16266 * @param {Roo.View} this
16267 * @param {Number} index The index of the target node
16268 * @param {HTMLElement} node The target node
16269 * @param {Roo.EventObject} e The raw event object
16274 * Fires when a template node is double clicked.
16275 * @param {Roo.View} this
16276 * @param {Number} index The index of the target node
16277 * @param {HTMLElement} node The target node
16278 * @param {Roo.EventObject} e The raw event object
16282 * @event contextmenu
16283 * Fires when a template node is right clicked.
16284 * @param {Roo.View} this
16285 * @param {Number} index The index of the target node
16286 * @param {HTMLElement} node The target node
16287 * @param {Roo.EventObject} e The raw event object
16289 "contextmenu" : true,
16291 * @event selectionchange
16292 * Fires when the selected nodes change.
16293 * @param {Roo.View} this
16294 * @param {Array} selections Array of the selected nodes
16296 "selectionchange" : true,
16299 * @event beforeselect
16300 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16301 * @param {Roo.View} this
16302 * @param {HTMLElement} node The node to be selected
16303 * @param {Array} selections Array of currently selected nodes
16305 "beforeselect" : true,
16307 * @event preparedata
16308 * Fires on every row to render, to allow you to change the data.
16309 * @param {Roo.View} this
16310 * @param {Object} data to be rendered (change this)
16312 "preparedata" : true
16320 "click": this.onClick,
16321 "dblclick": this.onDblClick,
16322 "contextmenu": this.onContextMenu,
16326 this.selections = [];
16328 this.cmp = new Roo.CompositeElementLite([]);
16330 this.store = Roo.factory(this.store, Roo.data);
16331 this.setStore(this.store, true);
16334 if ( this.footer && this.footer.xtype) {
16336 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16338 this.footer.dataSource = this.store;
16339 this.footer.container = fctr;
16340 this.footer = Roo.factory(this.footer, Roo);
16341 fctr.insertFirst(this.el);
16343 // this is a bit insane - as the paging toolbar seems to detach the el..
16344 // dom.parentNode.parentNode.parentNode
16345 // they get detached?
16349 Roo.View.superclass.constructor.call(this);
16354 Roo.extend(Roo.View, Roo.util.Observable, {
16357 * @cfg {Roo.data.Store} store Data store to load data from.
16362 * @cfg {String|Roo.Element} el The container element.
16367 * @cfg {String|Roo.Template} tpl The template used by this View
16371 * @cfg {String} dataName the named area of the template to use as the data area
16372 * Works with domtemplates roo-name="name"
16376 * @cfg {String} selectedClass The css class to add to selected nodes
16378 selectedClass : "x-view-selected",
16380 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16385 * @cfg {String} text to display on mask (default Loading)
16389 * @cfg {Boolean} multiSelect Allow multiple selection
16391 multiSelect : false,
16393 * @cfg {Boolean} singleSelect Allow single selection
16395 singleSelect: false,
16398 * @cfg {Boolean} toggleSelect - selecting
16400 toggleSelect : false,
16403 * @cfg {Boolean} tickable - selecting
16408 * Returns the element this view is bound to.
16409 * @return {Roo.Element}
16411 getEl : function(){
16412 return this.wrapEl;
16418 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16420 refresh : function(){
16421 //Roo.log('refresh');
16424 // if we are using something like 'domtemplate', then
16425 // the what gets used is:
16426 // t.applySubtemplate(NAME, data, wrapping data..)
16427 // the outer template then get' applied with
16428 // the store 'extra data'
16429 // and the body get's added to the
16430 // roo-name="data" node?
16431 // <span class='roo-tpl-{name}'></span> ?????
16435 this.clearSelections();
16436 this.el.update("");
16438 var records = this.store.getRange();
16439 if(records.length < 1) {
16441 // is this valid?? = should it render a template??
16443 this.el.update(this.emptyText);
16447 if (this.dataName) {
16448 this.el.update(t.apply(this.store.meta)); //????
16449 el = this.el.child('.roo-tpl-' + this.dataName);
16452 for(var i = 0, len = records.length; i < len; i++){
16453 var data = this.prepareData(records[i].data, i, records[i]);
16454 this.fireEvent("preparedata", this, data, i, records[i]);
16456 var d = Roo.apply({}, data);
16459 Roo.apply(d, {'roo-id' : Roo.id()});
16463 Roo.each(this.parent.item, function(item){
16464 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16467 Roo.apply(d, {'roo-data-checked' : 'checked'});
16471 html[html.length] = Roo.util.Format.trim(
16473 t.applySubtemplate(this.dataName, d, this.store.meta) :
16480 el.update(html.join(""));
16481 this.nodes = el.dom.childNodes;
16482 this.updateIndexes(0);
16487 * Function to override to reformat the data that is sent to
16488 * the template for each node.
16489 * DEPRICATED - use the preparedata event handler.
16490 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16491 * a JSON object for an UpdateManager bound view).
16493 prepareData : function(data, index, record)
16495 this.fireEvent("preparedata", this, data, index, record);
16499 onUpdate : function(ds, record){
16500 // Roo.log('on update');
16501 this.clearSelections();
16502 var index = this.store.indexOf(record);
16503 var n = this.nodes[index];
16504 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16505 n.parentNode.removeChild(n);
16506 this.updateIndexes(index, index);
16512 onAdd : function(ds, records, index)
16514 //Roo.log(['on Add', ds, records, index] );
16515 this.clearSelections();
16516 if(this.nodes.length == 0){
16520 var n = this.nodes[index];
16521 for(var i = 0, len = records.length; i < len; i++){
16522 var d = this.prepareData(records[i].data, i, records[i]);
16524 this.tpl.insertBefore(n, d);
16527 this.tpl.append(this.el, d);
16530 this.updateIndexes(index);
16533 onRemove : function(ds, record, index){
16534 // Roo.log('onRemove');
16535 this.clearSelections();
16536 var el = this.dataName ?
16537 this.el.child('.roo-tpl-' + this.dataName) :
16540 el.dom.removeChild(this.nodes[index]);
16541 this.updateIndexes(index);
16545 * Refresh an individual node.
16546 * @param {Number} index
16548 refreshNode : function(index){
16549 this.onUpdate(this.store, this.store.getAt(index));
16552 updateIndexes : function(startIndex, endIndex){
16553 var ns = this.nodes;
16554 startIndex = startIndex || 0;
16555 endIndex = endIndex || ns.length - 1;
16556 for(var i = startIndex; i <= endIndex; i++){
16557 ns[i].nodeIndex = i;
16562 * Changes the data store this view uses and refresh the view.
16563 * @param {Store} store
16565 setStore : function(store, initial){
16566 if(!initial && this.store){
16567 this.store.un("datachanged", this.refresh);
16568 this.store.un("add", this.onAdd);
16569 this.store.un("remove", this.onRemove);
16570 this.store.un("update", this.onUpdate);
16571 this.store.un("clear", this.refresh);
16572 this.store.un("beforeload", this.onBeforeLoad);
16573 this.store.un("load", this.onLoad);
16574 this.store.un("loadexception", this.onLoad);
16578 store.on("datachanged", this.refresh, this);
16579 store.on("add", this.onAdd, this);
16580 store.on("remove", this.onRemove, this);
16581 store.on("update", this.onUpdate, this);
16582 store.on("clear", this.refresh, this);
16583 store.on("beforeload", this.onBeforeLoad, this);
16584 store.on("load", this.onLoad, this);
16585 store.on("loadexception", this.onLoad, this);
16593 * onbeforeLoad - masks the loading area.
16596 onBeforeLoad : function(store,opts)
16598 //Roo.log('onBeforeLoad');
16600 this.el.update("");
16602 this.el.mask(this.mask ? this.mask : "Loading" );
16604 onLoad : function ()
16611 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16612 * @param {HTMLElement} node
16613 * @return {HTMLElement} The template node
16615 findItemFromChild : function(node){
16616 var el = this.dataName ?
16617 this.el.child('.roo-tpl-' + this.dataName,true) :
16620 if(!node || node.parentNode == el){
16623 var p = node.parentNode;
16624 while(p && p != el){
16625 if(p.parentNode == el){
16634 onClick : function(e){
16635 var item = this.findItemFromChild(e.getTarget());
16637 var index = this.indexOf(item);
16638 if(this.onItemClick(item, index, e) !== false){
16639 this.fireEvent("click", this, index, item, e);
16642 this.clearSelections();
16647 onContextMenu : function(e){
16648 var item = this.findItemFromChild(e.getTarget());
16650 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16655 onDblClick : function(e){
16656 var item = this.findItemFromChild(e.getTarget());
16658 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16662 onItemClick : function(item, index, e)
16664 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16667 if (this.toggleSelect) {
16668 var m = this.isSelected(item) ? 'unselect' : 'select';
16671 _t[m](item, true, false);
16674 if(this.multiSelect || this.singleSelect){
16675 if(this.multiSelect && e.shiftKey && this.lastSelection){
16676 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16678 this.select(item, this.multiSelect && e.ctrlKey);
16679 this.lastSelection = item;
16682 if(!this.tickable){
16683 e.preventDefault();
16691 * Get the number of selected nodes.
16694 getSelectionCount : function(){
16695 return this.selections.length;
16699 * Get the currently selected nodes.
16700 * @return {Array} An array of HTMLElements
16702 getSelectedNodes : function(){
16703 return this.selections;
16707 * Get the indexes of the selected nodes.
16710 getSelectedIndexes : function(){
16711 var indexes = [], s = this.selections;
16712 for(var i = 0, len = s.length; i < len; i++){
16713 indexes.push(s[i].nodeIndex);
16719 * Clear all selections
16720 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16722 clearSelections : function(suppressEvent){
16723 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16724 this.cmp.elements = this.selections;
16725 this.cmp.removeClass(this.selectedClass);
16726 this.selections = [];
16727 if(!suppressEvent){
16728 this.fireEvent("selectionchange", this, this.selections);
16734 * Returns true if the passed node is selected
16735 * @param {HTMLElement/Number} node The node or node index
16736 * @return {Boolean}
16738 isSelected : function(node){
16739 var s = this.selections;
16743 node = this.getNode(node);
16744 return s.indexOf(node) !== -1;
16749 * @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
16750 * @param {Boolean} keepExisting (optional) true to keep existing selections
16751 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16753 select : function(nodeInfo, keepExisting, suppressEvent){
16754 if(nodeInfo instanceof Array){
16756 this.clearSelections(true);
16758 for(var i = 0, len = nodeInfo.length; i < len; i++){
16759 this.select(nodeInfo[i], true, true);
16763 var node = this.getNode(nodeInfo);
16764 if(!node || this.isSelected(node)){
16765 return; // already selected.
16768 this.clearSelections(true);
16771 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16772 Roo.fly(node).addClass(this.selectedClass);
16773 this.selections.push(node);
16774 if(!suppressEvent){
16775 this.fireEvent("selectionchange", this, this.selections);
16783 * @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
16784 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16785 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16787 unselect : function(nodeInfo, keepExisting, suppressEvent)
16789 if(nodeInfo instanceof Array){
16790 Roo.each(this.selections, function(s) {
16791 this.unselect(s, nodeInfo);
16795 var node = this.getNode(nodeInfo);
16796 if(!node || !this.isSelected(node)){
16797 //Roo.log("not selected");
16798 return; // not selected.
16802 Roo.each(this.selections, function(s) {
16804 Roo.fly(node).removeClass(this.selectedClass);
16811 this.selections= ns;
16812 this.fireEvent("selectionchange", this, this.selections);
16816 * Gets a template node.
16817 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16818 * @return {HTMLElement} The node or null if it wasn't found
16820 getNode : function(nodeInfo){
16821 if(typeof nodeInfo == "string"){
16822 return document.getElementById(nodeInfo);
16823 }else if(typeof nodeInfo == "number"){
16824 return this.nodes[nodeInfo];
16830 * Gets a range template nodes.
16831 * @param {Number} startIndex
16832 * @param {Number} endIndex
16833 * @return {Array} An array of nodes
16835 getNodes : function(start, end){
16836 var ns = this.nodes;
16837 start = start || 0;
16838 end = typeof end == "undefined" ? ns.length - 1 : end;
16841 for(var i = start; i <= end; i++){
16845 for(var i = start; i >= end; i--){
16853 * Finds the index of the passed node
16854 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16855 * @return {Number} The index of the node or -1
16857 indexOf : function(node){
16858 node = this.getNode(node);
16859 if(typeof node.nodeIndex == "number"){
16860 return node.nodeIndex;
16862 var ns = this.nodes;
16863 for(var i = 0, len = ns.length; i < len; i++){
16874 * based on jquery fullcalendar
16878 Roo.bootstrap = Roo.bootstrap || {};
16880 * @class Roo.bootstrap.Calendar
16881 * @extends Roo.bootstrap.Component
16882 * Bootstrap Calendar class
16883 * @cfg {Boolean} loadMask (true|false) default false
16884 * @cfg {Object} header generate the user specific header of the calendar, default false
16887 * Create a new Container
16888 * @param {Object} config The config object
16893 Roo.bootstrap.Calendar = function(config){
16894 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16898 * Fires when a date is selected
16899 * @param {DatePicker} this
16900 * @param {Date} date The selected date
16904 * @event monthchange
16905 * Fires when the displayed month changes
16906 * @param {DatePicker} this
16907 * @param {Date} date The selected month
16909 'monthchange': true,
16911 * @event evententer
16912 * Fires when mouse over an event
16913 * @param {Calendar} this
16914 * @param {event} Event
16916 'evententer': true,
16918 * @event eventleave
16919 * Fires when the mouse leaves an
16920 * @param {Calendar} this
16923 'eventleave': true,
16925 * @event eventclick
16926 * Fires when the mouse click an
16927 * @param {Calendar} this
16936 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16939 * @cfg {Number} startDay
16940 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16948 getAutoCreate : function(){
16951 var fc_button = function(name, corner, style, content ) {
16952 return Roo.apply({},{
16954 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16956 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16959 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16970 style : 'width:100%',
16977 cls : 'fc-header-left',
16979 fc_button('prev', 'left', 'arrow', '‹' ),
16980 fc_button('next', 'right', 'arrow', '›' ),
16981 { tag: 'span', cls: 'fc-header-space' },
16982 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16990 cls : 'fc-header-center',
16994 cls: 'fc-header-title',
16997 html : 'month / year'
17005 cls : 'fc-header-right',
17007 /* fc_button('month', 'left', '', 'month' ),
17008 fc_button('week', '', '', 'week' ),
17009 fc_button('day', 'right', '', 'day' )
17021 header = this.header;
17024 var cal_heads = function() {
17026 // fixme - handle this.
17028 for (var i =0; i < Date.dayNames.length; i++) {
17029 var d = Date.dayNames[i];
17032 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17033 html : d.substring(0,3)
17037 ret[0].cls += ' fc-first';
17038 ret[6].cls += ' fc-last';
17041 var cal_cell = function(n) {
17044 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17049 cls: 'fc-day-number',
17053 cls: 'fc-day-content',
17057 style: 'position: relative;' // height: 17px;
17069 var cal_rows = function() {
17072 for (var r = 0; r < 6; r++) {
17079 for (var i =0; i < Date.dayNames.length; i++) {
17080 var d = Date.dayNames[i];
17081 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17084 row.cn[0].cls+=' fc-first';
17085 row.cn[0].cn[0].style = 'min-height:90px';
17086 row.cn[6].cls+=' fc-last';
17090 ret[0].cls += ' fc-first';
17091 ret[4].cls += ' fc-prev-last';
17092 ret[5].cls += ' fc-last';
17099 cls: 'fc-border-separate',
17100 style : 'width:100%',
17108 cls : 'fc-first fc-last',
17126 cls : 'fc-content',
17127 style : "position: relative;",
17130 cls : 'fc-view fc-view-month fc-grid',
17131 style : 'position: relative',
17132 unselectable : 'on',
17135 cls : 'fc-event-container',
17136 style : 'position:absolute;z-index:8;top:0;left:0;'
17154 initEvents : function()
17157 throw "can not find store for calendar";
17163 style: "text-align:center",
17167 style: "background-color:white;width:50%;margin:250 auto",
17171 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17182 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17184 var size = this.el.select('.fc-content', true).first().getSize();
17185 this.maskEl.setSize(size.width, size.height);
17186 this.maskEl.enableDisplayMode("block");
17187 if(!this.loadMask){
17188 this.maskEl.hide();
17191 this.store = Roo.factory(this.store, Roo.data);
17192 this.store.on('load', this.onLoad, this);
17193 this.store.on('beforeload', this.onBeforeLoad, this);
17197 this.cells = this.el.select('.fc-day',true);
17198 //Roo.log(this.cells);
17199 this.textNodes = this.el.query('.fc-day-number');
17200 this.cells.addClassOnOver('fc-state-hover');
17202 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17203 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17204 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17205 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17207 this.on('monthchange', this.onMonthChange, this);
17209 this.update(new Date().clearTime());
17212 resize : function() {
17213 var sz = this.el.getSize();
17215 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17216 this.el.select('.fc-day-content div',true).setHeight(34);
17221 showPrevMonth : function(e){
17222 this.update(this.activeDate.add("mo", -1));
17224 showToday : function(e){
17225 this.update(new Date().clearTime());
17228 showNextMonth : function(e){
17229 this.update(this.activeDate.add("mo", 1));
17233 showPrevYear : function(){
17234 this.update(this.activeDate.add("y", -1));
17238 showNextYear : function(){
17239 this.update(this.activeDate.add("y", 1));
17244 update : function(date)
17246 var vd = this.activeDate;
17247 this.activeDate = date;
17248 // if(vd && this.el){
17249 // var t = date.getTime();
17250 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17251 // Roo.log('using add remove');
17253 // this.fireEvent('monthchange', this, date);
17255 // this.cells.removeClass("fc-state-highlight");
17256 // this.cells.each(function(c){
17257 // if(c.dateValue == t){
17258 // c.addClass("fc-state-highlight");
17259 // setTimeout(function(){
17260 // try{c.dom.firstChild.focus();}catch(e){}
17270 var days = date.getDaysInMonth();
17272 var firstOfMonth = date.getFirstDateOfMonth();
17273 var startingPos = firstOfMonth.getDay()-this.startDay;
17275 if(startingPos < this.startDay){
17279 var pm = date.add(Date.MONTH, -1);
17280 var prevStart = pm.getDaysInMonth()-startingPos;
17282 this.cells = this.el.select('.fc-day',true);
17283 this.textNodes = this.el.query('.fc-day-number');
17284 this.cells.addClassOnOver('fc-state-hover');
17286 var cells = this.cells.elements;
17287 var textEls = this.textNodes;
17289 Roo.each(cells, function(cell){
17290 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17293 days += startingPos;
17295 // convert everything to numbers so it's fast
17296 var day = 86400000;
17297 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17300 //Roo.log(prevStart);
17302 var today = new Date().clearTime().getTime();
17303 var sel = date.clearTime().getTime();
17304 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17305 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17306 var ddMatch = this.disabledDatesRE;
17307 var ddText = this.disabledDatesText;
17308 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17309 var ddaysText = this.disabledDaysText;
17310 var format = this.format;
17312 var setCellClass = function(cal, cell){
17316 //Roo.log('set Cell Class');
17318 var t = d.getTime();
17322 cell.dateValue = t;
17324 cell.className += " fc-today";
17325 cell.className += " fc-state-highlight";
17326 cell.title = cal.todayText;
17329 // disable highlight in other month..
17330 //cell.className += " fc-state-highlight";
17335 cell.className = " fc-state-disabled";
17336 cell.title = cal.minText;
17340 cell.className = " fc-state-disabled";
17341 cell.title = cal.maxText;
17345 if(ddays.indexOf(d.getDay()) != -1){
17346 cell.title = ddaysText;
17347 cell.className = " fc-state-disabled";
17350 if(ddMatch && format){
17351 var fvalue = d.dateFormat(format);
17352 if(ddMatch.test(fvalue)){
17353 cell.title = ddText.replace("%0", fvalue);
17354 cell.className = " fc-state-disabled";
17358 if (!cell.initialClassName) {
17359 cell.initialClassName = cell.dom.className;
17362 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17367 for(; i < startingPos; i++) {
17368 textEls[i].innerHTML = (++prevStart);
17369 d.setDate(d.getDate()+1);
17371 cells[i].className = "fc-past fc-other-month";
17372 setCellClass(this, cells[i]);
17377 for(; i < days; i++){
17378 intDay = i - startingPos + 1;
17379 textEls[i].innerHTML = (intDay);
17380 d.setDate(d.getDate()+1);
17382 cells[i].className = ''; // "x-date-active";
17383 setCellClass(this, cells[i]);
17387 for(; i < 42; i++) {
17388 textEls[i].innerHTML = (++extraDays);
17389 d.setDate(d.getDate()+1);
17391 cells[i].className = "fc-future fc-other-month";
17392 setCellClass(this, cells[i]);
17395 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17397 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17399 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17400 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17402 if(totalRows != 6){
17403 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17404 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17407 this.fireEvent('monthchange', this, date);
17411 if(!this.internalRender){
17412 var main = this.el.dom.firstChild;
17413 var w = main.offsetWidth;
17414 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17415 Roo.fly(main).setWidth(w);
17416 this.internalRender = true;
17417 // opera does not respect the auto grow header center column
17418 // then, after it gets a width opera refuses to recalculate
17419 // without a second pass
17420 if(Roo.isOpera && !this.secondPass){
17421 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17422 this.secondPass = true;
17423 this.update.defer(10, this, [date]);
17430 findCell : function(dt) {
17431 dt = dt.clearTime().getTime();
17433 this.cells.each(function(c){
17434 //Roo.log("check " +c.dateValue + '?=' + dt);
17435 if(c.dateValue == dt){
17445 findCells : function(ev) {
17446 var s = ev.start.clone().clearTime().getTime();
17448 var e= ev.end.clone().clearTime().getTime();
17451 this.cells.each(function(c){
17452 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17454 if(c.dateValue > e){
17457 if(c.dateValue < s){
17466 // findBestRow: function(cells)
17470 // for (var i =0 ; i < cells.length;i++) {
17471 // ret = Math.max(cells[i].rows || 0,ret);
17478 addItem : function(ev)
17480 // look for vertical location slot in
17481 var cells = this.findCells(ev);
17483 // ev.row = this.findBestRow(cells);
17485 // work out the location.
17489 for(var i =0; i < cells.length; i++) {
17491 cells[i].row = cells[0].row;
17494 cells[i].row = cells[i].row + 1;
17504 if (crow.start.getY() == cells[i].getY()) {
17506 crow.end = cells[i];
17523 cells[0].events.push(ev);
17525 this.calevents.push(ev);
17528 clearEvents: function() {
17530 if(!this.calevents){
17534 Roo.each(this.cells.elements, function(c){
17540 Roo.each(this.calevents, function(e) {
17541 Roo.each(e.els, function(el) {
17542 el.un('mouseenter' ,this.onEventEnter, this);
17543 el.un('mouseleave' ,this.onEventLeave, this);
17548 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17554 renderEvents: function()
17558 this.cells.each(function(c) {
17567 if(c.row != c.events.length){
17568 r = 4 - (4 - (c.row - c.events.length));
17571 c.events = ev.slice(0, r);
17572 c.more = ev.slice(r);
17574 if(c.more.length && c.more.length == 1){
17575 c.events.push(c.more.pop());
17578 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17582 this.cells.each(function(c) {
17584 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17587 for (var e = 0; e < c.events.length; e++){
17588 var ev = c.events[e];
17589 var rows = ev.rows;
17591 for(var i = 0; i < rows.length; i++) {
17593 // how many rows should it span..
17596 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17597 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17599 unselectable : "on",
17602 cls: 'fc-event-inner',
17606 // cls: 'fc-event-time',
17607 // html : cells.length > 1 ? '' : ev.time
17611 cls: 'fc-event-title',
17612 html : String.format('{0}', ev.title)
17619 cls: 'ui-resizable-handle ui-resizable-e',
17620 html : '  '
17627 cfg.cls += ' fc-event-start';
17629 if ((i+1) == rows.length) {
17630 cfg.cls += ' fc-event-end';
17633 var ctr = _this.el.select('.fc-event-container',true).first();
17634 var cg = ctr.createChild(cfg);
17636 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17637 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17639 var r = (c.more.length) ? 1 : 0;
17640 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17641 cg.setWidth(ebox.right - sbox.x -2);
17643 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17644 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17645 cg.on('click', _this.onEventClick, _this, ev);
17656 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17657 style : 'position: absolute',
17658 unselectable : "on",
17661 cls: 'fc-event-inner',
17665 cls: 'fc-event-title',
17673 cls: 'ui-resizable-handle ui-resizable-e',
17674 html : '  '
17680 var ctr = _this.el.select('.fc-event-container',true).first();
17681 var cg = ctr.createChild(cfg);
17683 var sbox = c.select('.fc-day-content',true).first().getBox();
17684 var ebox = c.select('.fc-day-content',true).first().getBox();
17686 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17687 cg.setWidth(ebox.right - sbox.x -2);
17689 cg.on('click', _this.onMoreEventClick, _this, c.more);
17699 onEventEnter: function (e, el,event,d) {
17700 this.fireEvent('evententer', this, el, event);
17703 onEventLeave: function (e, el,event,d) {
17704 this.fireEvent('eventleave', this, el, event);
17707 onEventClick: function (e, el,event,d) {
17708 this.fireEvent('eventclick', this, el, event);
17711 onMonthChange: function () {
17715 onMoreEventClick: function(e, el, more)
17719 this.calpopover.placement = 'right';
17720 this.calpopover.setTitle('More');
17722 this.calpopover.setContent('');
17724 var ctr = this.calpopover.el.select('.popover-content', true).first();
17726 Roo.each(more, function(m){
17728 cls : 'fc-event-hori fc-event-draggable',
17731 var cg = ctr.createChild(cfg);
17733 cg.on('click', _this.onEventClick, _this, m);
17736 this.calpopover.show(el);
17741 onLoad: function ()
17743 this.calevents = [];
17746 if(this.store.getCount() > 0){
17747 this.store.data.each(function(d){
17750 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17751 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17752 time : d.data.start_time,
17753 title : d.data.title,
17754 description : d.data.description,
17755 venue : d.data.venue
17760 this.renderEvents();
17762 if(this.calevents.length && this.loadMask){
17763 this.maskEl.hide();
17767 onBeforeLoad: function()
17769 this.clearEvents();
17771 this.maskEl.show();
17785 * @class Roo.bootstrap.Popover
17786 * @extends Roo.bootstrap.Component
17787 * Bootstrap Popover class
17788 * @cfg {String} html contents of the popover (or false to use children..)
17789 * @cfg {String} title of popover (or false to hide)
17790 * @cfg {String} placement how it is placed
17791 * @cfg {String} trigger click || hover (or false to trigger manually)
17792 * @cfg {String} over what (parent or false to trigger manually.)
17793 * @cfg {Number} delay - delay before showing
17796 * Create a new Popover
17797 * @param {Object} config The config object
17800 Roo.bootstrap.Popover = function(config){
17801 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17807 * After the popover show
17809 * @param {Roo.bootstrap.Popover} this
17814 * After the popover hide
17816 * @param {Roo.bootstrap.Popover} this
17822 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17824 title: 'Fill in a title',
17827 placement : 'right',
17828 trigger : 'hover', // hover
17834 can_build_overlaid : false,
17836 getChildContainer : function()
17838 return this.el.select('.popover-content',true).first();
17841 getAutoCreate : function(){
17844 cls : 'popover roo-dynamic',
17845 style: 'display:block',
17851 cls : 'popover-inner',
17855 cls: 'popover-title popover-header',
17859 cls : 'popover-content popover-body',
17870 setTitle: function(str)
17873 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17875 setContent: function(str)
17878 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17880 // as it get's added to the bottom of the page.
17881 onRender : function(ct, position)
17883 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17885 var cfg = Roo.apply({}, this.getAutoCreate());
17889 cfg.cls += ' ' + this.cls;
17892 cfg.style = this.style;
17894 //Roo.log("adding to ");
17895 this.el = Roo.get(document.body).createChild(cfg, position);
17896 // Roo.log(this.el);
17901 initEvents : function()
17903 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17904 this.el.enableDisplayMode('block');
17906 if (this.over === false) {
17909 if (this.triggers === false) {
17912 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17913 var triggers = this.trigger ? this.trigger.split(' ') : [];
17914 Roo.each(triggers, function(trigger) {
17916 if (trigger == 'click') {
17917 on_el.on('click', this.toggle, this);
17918 } else if (trigger != 'manual') {
17919 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17920 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17922 on_el.on(eventIn ,this.enter, this);
17923 on_el.on(eventOut, this.leave, this);
17934 toggle : function () {
17935 this.hoverState == 'in' ? this.leave() : this.enter();
17938 enter : function () {
17940 clearTimeout(this.timeout);
17942 this.hoverState = 'in';
17944 if (!this.delay || !this.delay.show) {
17949 this.timeout = setTimeout(function () {
17950 if (_t.hoverState == 'in') {
17953 }, this.delay.show)
17956 leave : function() {
17957 clearTimeout(this.timeout);
17959 this.hoverState = 'out';
17961 if (!this.delay || !this.delay.hide) {
17966 this.timeout = setTimeout(function () {
17967 if (_t.hoverState == 'out') {
17970 }, this.delay.hide)
17973 show : function (on_el)
17976 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17980 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17981 if (this.html !== false) {
17982 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17984 this.el.removeClass([
17985 'fade','top','bottom', 'left', 'right','in',
17986 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17988 if (!this.title.length) {
17989 this.el.select('.popover-title',true).hide();
17992 var placement = typeof this.placement == 'function' ?
17993 this.placement.call(this, this.el, on_el) :
17996 var autoToken = /\s?auto?\s?/i;
17997 var autoPlace = autoToken.test(placement);
17999 placement = placement.replace(autoToken, '') || 'top';
18003 //this.el.setXY([0,0]);
18005 this.el.dom.style.display='block';
18006 this.el.addClass(placement);
18008 //this.el.appendTo(on_el);
18010 var p = this.getPosition();
18011 var box = this.el.getBox();
18016 var align = Roo.bootstrap.Popover.alignment[placement];
18019 this.el.alignTo(on_el, align[0],align[1]);
18020 //var arrow = this.el.select('.arrow',true).first();
18021 //arrow.set(align[2],
18023 this.el.addClass('in');
18026 if (this.el.hasClass('fade')) {
18030 this.hoverState = 'in';
18032 this.fireEvent('show', this);
18037 this.el.setXY([0,0]);
18038 this.el.removeClass('in');
18040 this.hoverState = null;
18042 this.fireEvent('hide', this);
18047 Roo.bootstrap.Popover.alignment = {
18048 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18049 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18050 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18051 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18062 * @class Roo.bootstrap.Progress
18063 * @extends Roo.bootstrap.Component
18064 * Bootstrap Progress class
18065 * @cfg {Boolean} striped striped of the progress bar
18066 * @cfg {Boolean} active animated of the progress bar
18070 * Create a new Progress
18071 * @param {Object} config The config object
18074 Roo.bootstrap.Progress = function(config){
18075 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18078 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18083 getAutoCreate : function(){
18091 cfg.cls += ' progress-striped';
18095 cfg.cls += ' active';
18114 * @class Roo.bootstrap.ProgressBar
18115 * @extends Roo.bootstrap.Component
18116 * Bootstrap ProgressBar class
18117 * @cfg {Number} aria_valuenow aria-value now
18118 * @cfg {Number} aria_valuemin aria-value min
18119 * @cfg {Number} aria_valuemax aria-value max
18120 * @cfg {String} label label for the progress bar
18121 * @cfg {String} panel (success | info | warning | danger )
18122 * @cfg {String} role role of the progress bar
18123 * @cfg {String} sr_only text
18127 * Create a new ProgressBar
18128 * @param {Object} config The config object
18131 Roo.bootstrap.ProgressBar = function(config){
18132 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18135 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18139 aria_valuemax : 100,
18145 getAutoCreate : function()
18150 cls: 'progress-bar',
18151 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18163 cfg.role = this.role;
18166 if(this.aria_valuenow){
18167 cfg['aria-valuenow'] = this.aria_valuenow;
18170 if(this.aria_valuemin){
18171 cfg['aria-valuemin'] = this.aria_valuemin;
18174 if(this.aria_valuemax){
18175 cfg['aria-valuemax'] = this.aria_valuemax;
18178 if(this.label && !this.sr_only){
18179 cfg.html = this.label;
18183 cfg.cls += ' progress-bar-' + this.panel;
18189 update : function(aria_valuenow)
18191 this.aria_valuenow = aria_valuenow;
18193 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18208 * @class Roo.bootstrap.TabGroup
18209 * @extends Roo.bootstrap.Column
18210 * Bootstrap Column class
18211 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18212 * @cfg {Boolean} carousel true to make the group behave like a carousel
18213 * @cfg {Boolean} bullets show bullets for the panels
18214 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18215 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18216 * @cfg {Boolean} showarrow (true|false) show arrow default true
18219 * Create a new TabGroup
18220 * @param {Object} config The config object
18223 Roo.bootstrap.TabGroup = function(config){
18224 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18226 this.navId = Roo.id();
18229 Roo.bootstrap.TabGroup.register(this);
18233 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18236 transition : false,
18241 slideOnTouch : false,
18244 getAutoCreate : function()
18246 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18248 cfg.cls += ' tab-content';
18250 if (this.carousel) {
18251 cfg.cls += ' carousel slide';
18254 cls : 'carousel-inner',
18258 if(this.bullets && !Roo.isTouch){
18261 cls : 'carousel-bullets',
18265 if(this.bullets_cls){
18266 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18273 cfg.cn[0].cn.push(bullets);
18276 if(this.showarrow){
18277 cfg.cn[0].cn.push({
18279 class : 'carousel-arrow',
18283 class : 'carousel-prev',
18287 class : 'fa fa-chevron-left'
18293 class : 'carousel-next',
18297 class : 'fa fa-chevron-right'
18310 initEvents: function()
18312 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18313 // this.el.on("touchstart", this.onTouchStart, this);
18316 if(this.autoslide){
18319 this.slideFn = window.setInterval(function() {
18320 _this.showPanelNext();
18324 if(this.showarrow){
18325 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18326 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18332 // onTouchStart : function(e, el, o)
18334 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18338 // this.showPanelNext();
18342 getChildContainer : function()
18344 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18348 * register a Navigation item
18349 * @param {Roo.bootstrap.NavItem} the navitem to add
18351 register : function(item)
18353 this.tabs.push( item);
18354 item.navId = this.navId; // not really needed..
18359 getActivePanel : function()
18362 Roo.each(this.tabs, function(t) {
18372 getPanelByName : function(n)
18375 Roo.each(this.tabs, function(t) {
18376 if (t.tabId == n) {
18384 indexOfPanel : function(p)
18387 Roo.each(this.tabs, function(t,i) {
18388 if (t.tabId == p.tabId) {
18397 * show a specific panel
18398 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18399 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18401 showPanel : function (pan)
18403 if(this.transition || typeof(pan) == 'undefined'){
18404 Roo.log("waiting for the transitionend");
18408 if (typeof(pan) == 'number') {
18409 pan = this.tabs[pan];
18412 if (typeof(pan) == 'string') {
18413 pan = this.getPanelByName(pan);
18416 var cur = this.getActivePanel();
18419 Roo.log('pan or acitve pan is undefined');
18423 if (pan.tabId == this.getActivePanel().tabId) {
18427 if (false === cur.fireEvent('beforedeactivate')) {
18431 if(this.bullets > 0 && !Roo.isTouch){
18432 this.setActiveBullet(this.indexOfPanel(pan));
18435 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18437 //class="carousel-item carousel-item-next carousel-item-left"
18439 this.transition = true;
18440 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18441 var lr = dir == 'next' ? 'left' : 'right';
18442 pan.el.addClass(dir); // or prev
18443 pan.el.addClass('carousel-item-' + dir); // or prev
18444 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18445 cur.el.addClass(lr); // or right
18446 pan.el.addClass(lr);
18447 cur.el.addClass('carousel-item-' +lr); // or right
18448 pan.el.addClass('carousel-item-' +lr);
18452 cur.el.on('transitionend', function() {
18453 Roo.log("trans end?");
18455 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18456 pan.setActive(true);
18458 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18459 cur.setActive(false);
18461 _this.transition = false;
18463 }, this, { single: true } );
18468 cur.setActive(false);
18469 pan.setActive(true);
18474 showPanelNext : function()
18476 var i = this.indexOfPanel(this.getActivePanel());
18478 if (i >= this.tabs.length - 1 && !this.autoslide) {
18482 if (i >= this.tabs.length - 1 && this.autoslide) {
18486 this.showPanel(this.tabs[i+1]);
18489 showPanelPrev : function()
18491 var i = this.indexOfPanel(this.getActivePanel());
18493 if (i < 1 && !this.autoslide) {
18497 if (i < 1 && this.autoslide) {
18498 i = this.tabs.length;
18501 this.showPanel(this.tabs[i-1]);
18505 addBullet: function()
18507 if(!this.bullets || Roo.isTouch){
18510 var ctr = this.el.select('.carousel-bullets',true).first();
18511 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18512 var bullet = ctr.createChild({
18513 cls : 'bullet bullet-' + i
18514 },ctr.dom.lastChild);
18519 bullet.on('click', (function(e, el, o, ii, t){
18521 e.preventDefault();
18523 this.showPanel(ii);
18525 if(this.autoslide && this.slideFn){
18526 clearInterval(this.slideFn);
18527 this.slideFn = window.setInterval(function() {
18528 _this.showPanelNext();
18532 }).createDelegate(this, [i, bullet], true));
18537 setActiveBullet : function(i)
18543 Roo.each(this.el.select('.bullet', true).elements, function(el){
18544 el.removeClass('selected');
18547 var bullet = this.el.select('.bullet-' + i, true).first();
18553 bullet.addClass('selected');
18564 Roo.apply(Roo.bootstrap.TabGroup, {
18568 * register a Navigation Group
18569 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18571 register : function(navgrp)
18573 this.groups[navgrp.navId] = navgrp;
18577 * fetch a Navigation Group based on the navigation ID
18578 * if one does not exist , it will get created.
18579 * @param {string} the navgroup to add
18580 * @returns {Roo.bootstrap.NavGroup} the navgroup
18582 get: function(navId) {
18583 if (typeof(this.groups[navId]) == 'undefined') {
18584 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18586 return this.groups[navId] ;
18601 * @class Roo.bootstrap.TabPanel
18602 * @extends Roo.bootstrap.Component
18603 * Bootstrap TabPanel class
18604 * @cfg {Boolean} active panel active
18605 * @cfg {String} html panel content
18606 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18607 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18608 * @cfg {String} href click to link..
18612 * Create a new TabPanel
18613 * @param {Object} config The config object
18616 Roo.bootstrap.TabPanel = function(config){
18617 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18621 * Fires when the active status changes
18622 * @param {Roo.bootstrap.TabPanel} this
18623 * @param {Boolean} state the new state
18628 * @event beforedeactivate
18629 * Fires before a tab is de-activated - can be used to do validation on a form.
18630 * @param {Roo.bootstrap.TabPanel} this
18631 * @return {Boolean} false if there is an error
18634 'beforedeactivate': true
18637 this.tabId = this.tabId || Roo.id();
18641 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18649 getAutoCreate : function(){
18654 // item is needed for carousel - not sure if it has any effect otherwise
18655 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18656 html: this.html || ''
18660 cfg.cls += ' active';
18664 cfg.tabId = this.tabId;
18672 initEvents: function()
18674 var p = this.parent();
18676 this.navId = this.navId || p.navId;
18678 if (typeof(this.navId) != 'undefined') {
18679 // not really needed.. but just in case.. parent should be a NavGroup.
18680 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18684 var i = tg.tabs.length - 1;
18686 if(this.active && tg.bullets > 0 && i < tg.bullets){
18687 tg.setActiveBullet(i);
18691 this.el.on('click', this.onClick, this);
18694 this.el.on("touchstart", this.onTouchStart, this);
18695 this.el.on("touchmove", this.onTouchMove, this);
18696 this.el.on("touchend", this.onTouchEnd, this);
18701 onRender : function(ct, position)
18703 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18706 setActive : function(state)
18708 Roo.log("panel - set active " + this.tabId + "=" + state);
18710 this.active = state;
18712 this.el.removeClass('active');
18714 } else if (!this.el.hasClass('active')) {
18715 this.el.addClass('active');
18718 this.fireEvent('changed', this, state);
18721 onClick : function(e)
18723 e.preventDefault();
18725 if(!this.href.length){
18729 window.location.href = this.href;
18738 onTouchStart : function(e)
18740 this.swiping = false;
18742 this.startX = e.browserEvent.touches[0].clientX;
18743 this.startY = e.browserEvent.touches[0].clientY;
18746 onTouchMove : function(e)
18748 this.swiping = true;
18750 this.endX = e.browserEvent.touches[0].clientX;
18751 this.endY = e.browserEvent.touches[0].clientY;
18754 onTouchEnd : function(e)
18761 var tabGroup = this.parent();
18763 if(this.endX > this.startX){ // swiping right
18764 tabGroup.showPanelPrev();
18768 if(this.startX > this.endX){ // swiping left
18769 tabGroup.showPanelNext();
18788 * @class Roo.bootstrap.DateField
18789 * @extends Roo.bootstrap.Input
18790 * Bootstrap DateField class
18791 * @cfg {Number} weekStart default 0
18792 * @cfg {String} viewMode default empty, (months|years)
18793 * @cfg {String} minViewMode default empty, (months|years)
18794 * @cfg {Number} startDate default -Infinity
18795 * @cfg {Number} endDate default Infinity
18796 * @cfg {Boolean} todayHighlight default false
18797 * @cfg {Boolean} todayBtn default false
18798 * @cfg {Boolean} calendarWeeks default false
18799 * @cfg {Object} daysOfWeekDisabled default empty
18800 * @cfg {Boolean} singleMode default false (true | false)
18802 * @cfg {Boolean} keyboardNavigation default true
18803 * @cfg {String} language default en
18806 * Create a new DateField
18807 * @param {Object} config The config object
18810 Roo.bootstrap.DateField = function(config){
18811 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18815 * Fires when this field show.
18816 * @param {Roo.bootstrap.DateField} this
18817 * @param {Mixed} date The date value
18822 * Fires when this field hide.
18823 * @param {Roo.bootstrap.DateField} this
18824 * @param {Mixed} date The date value
18829 * Fires when select a date.
18830 * @param {Roo.bootstrap.DateField} this
18831 * @param {Mixed} date The date value
18835 * @event beforeselect
18836 * Fires when before select a date.
18837 * @param {Roo.bootstrap.DateField} this
18838 * @param {Mixed} date The date value
18840 beforeselect : true
18844 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18847 * @cfg {String} format
18848 * The default date format string which can be overriden for localization support. The format must be
18849 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18853 * @cfg {String} altFormats
18854 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18855 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18857 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18865 todayHighlight : false,
18871 keyboardNavigation: true,
18873 calendarWeeks: false,
18875 startDate: -Infinity,
18879 daysOfWeekDisabled: [],
18883 singleMode : false,
18885 UTCDate: function()
18887 return new Date(Date.UTC.apply(Date, arguments));
18890 UTCToday: function()
18892 var today = new Date();
18893 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18896 getDate: function() {
18897 var d = this.getUTCDate();
18898 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18901 getUTCDate: function() {
18905 setDate: function(d) {
18906 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18909 setUTCDate: function(d) {
18911 this.setValue(this.formatDate(this.date));
18914 onRender: function(ct, position)
18917 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18919 this.language = this.language || 'en';
18920 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18921 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18923 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18924 this.format = this.format || 'm/d/y';
18925 this.isInline = false;
18926 this.isInput = true;
18927 this.component = this.el.select('.add-on', true).first() || false;
18928 this.component = (this.component && this.component.length === 0) ? false : this.component;
18929 this.hasInput = this.component && this.inputEl().length;
18931 if (typeof(this.minViewMode === 'string')) {
18932 switch (this.minViewMode) {
18934 this.minViewMode = 1;
18937 this.minViewMode = 2;
18940 this.minViewMode = 0;
18945 if (typeof(this.viewMode === 'string')) {
18946 switch (this.viewMode) {
18959 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18961 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18963 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18965 this.picker().on('mousedown', this.onMousedown, this);
18966 this.picker().on('click', this.onClick, this);
18968 this.picker().addClass('datepicker-dropdown');
18970 this.startViewMode = this.viewMode;
18972 if(this.singleMode){
18973 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18974 v.setVisibilityMode(Roo.Element.DISPLAY);
18978 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18979 v.setStyle('width', '189px');
18983 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18984 if(!this.calendarWeeks){
18989 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18990 v.attr('colspan', function(i, val){
18991 return parseInt(val) + 1;
18996 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18998 this.setStartDate(this.startDate);
18999 this.setEndDate(this.endDate);
19001 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
19008 if(this.isInline) {
19013 picker : function()
19015 return this.pickerEl;
19016 // return this.el.select('.datepicker', true).first();
19019 fillDow: function()
19021 var dowCnt = this.weekStart;
19030 if(this.calendarWeeks){
19038 while (dowCnt < this.weekStart + 7) {
19042 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19046 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19049 fillMonths: function()
19052 var months = this.picker().select('>.datepicker-months td', true).first();
19054 months.dom.innerHTML = '';
19060 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19063 months.createChild(month);
19070 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;
19072 if (this.date < this.startDate) {
19073 this.viewDate = new Date(this.startDate);
19074 } else if (this.date > this.endDate) {
19075 this.viewDate = new Date(this.endDate);
19077 this.viewDate = new Date(this.date);
19085 var d = new Date(this.viewDate),
19086 year = d.getUTCFullYear(),
19087 month = d.getUTCMonth(),
19088 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19089 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19090 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19091 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19092 currentDate = this.date && this.date.valueOf(),
19093 today = this.UTCToday();
19095 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19097 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19099 // this.picker.select('>tfoot th.today').
19100 // .text(dates[this.language].today)
19101 // .toggle(this.todayBtn !== false);
19103 this.updateNavArrows();
19106 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19108 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19110 prevMonth.setUTCDate(day);
19112 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19114 var nextMonth = new Date(prevMonth);
19116 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19118 nextMonth = nextMonth.valueOf();
19120 var fillMonths = false;
19122 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19124 while(prevMonth.valueOf() <= nextMonth) {
19127 if (prevMonth.getUTCDay() === this.weekStart) {
19129 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19137 if(this.calendarWeeks){
19138 // ISO 8601: First week contains first thursday.
19139 // ISO also states week starts on Monday, but we can be more abstract here.
19141 // Start of current week: based on weekstart/current date
19142 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19143 // Thursday of this week
19144 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19145 // First Thursday of year, year from thursday
19146 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19147 // Calendar week: ms between thursdays, div ms per day, div 7 days
19148 calWeek = (th - yth) / 864e5 / 7 + 1;
19150 fillMonths.cn.push({
19158 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19160 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19163 if (this.todayHighlight &&
19164 prevMonth.getUTCFullYear() == today.getFullYear() &&
19165 prevMonth.getUTCMonth() == today.getMonth() &&
19166 prevMonth.getUTCDate() == today.getDate()) {
19167 clsName += ' today';
19170 if (currentDate && prevMonth.valueOf() === currentDate) {
19171 clsName += ' active';
19174 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19175 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19176 clsName += ' disabled';
19179 fillMonths.cn.push({
19181 cls: 'day ' + clsName,
19182 html: prevMonth.getDate()
19185 prevMonth.setDate(prevMonth.getDate()+1);
19188 var currentYear = this.date && this.date.getUTCFullYear();
19189 var currentMonth = this.date && this.date.getUTCMonth();
19191 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19193 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19194 v.removeClass('active');
19196 if(currentYear === year && k === currentMonth){
19197 v.addClass('active');
19200 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19201 v.addClass('disabled');
19207 year = parseInt(year/10, 10) * 10;
19209 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19211 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19214 for (var i = -1; i < 11; i++) {
19215 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19217 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19225 showMode: function(dir)
19228 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19231 Roo.each(this.picker().select('>div',true).elements, function(v){
19232 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19235 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19240 if(this.isInline) {
19244 this.picker().removeClass(['bottom', 'top']);
19246 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19248 * place to the top of element!
19252 this.picker().addClass('top');
19253 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19258 this.picker().addClass('bottom');
19260 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19263 parseDate : function(value)
19265 if(!value || value instanceof Date){
19268 var v = Date.parseDate(value, this.format);
19269 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19270 v = Date.parseDate(value, 'Y-m-d');
19272 if(!v && this.altFormats){
19273 if(!this.altFormatsArray){
19274 this.altFormatsArray = this.altFormats.split("|");
19276 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19277 v = Date.parseDate(value, this.altFormatsArray[i]);
19283 formatDate : function(date, fmt)
19285 return (!date || !(date instanceof Date)) ?
19286 date : date.dateFormat(fmt || this.format);
19289 onFocus : function()
19291 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19295 onBlur : function()
19297 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19299 var d = this.inputEl().getValue();
19306 showPopup : function()
19308 this.picker().show();
19312 this.fireEvent('showpopup', this, this.date);
19315 hidePopup : function()
19317 if(this.isInline) {
19320 this.picker().hide();
19321 this.viewMode = this.startViewMode;
19324 this.fireEvent('hidepopup', this, this.date);
19328 onMousedown: function(e)
19330 e.stopPropagation();
19331 e.preventDefault();
19336 Roo.bootstrap.DateField.superclass.keyup.call(this);
19340 setValue: function(v)
19342 if(this.fireEvent('beforeselect', this, v) !== false){
19343 var d = new Date(this.parseDate(v) ).clearTime();
19345 if(isNaN(d.getTime())){
19346 this.date = this.viewDate = '';
19347 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19351 v = this.formatDate(d);
19353 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19355 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19359 this.fireEvent('select', this, this.date);
19363 getValue: function()
19365 return this.formatDate(this.date);
19368 fireKey: function(e)
19370 if (!this.picker().isVisible()){
19371 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19377 var dateChanged = false,
19379 newDate, newViewDate;
19384 e.preventDefault();
19388 if (!this.keyboardNavigation) {
19391 dir = e.keyCode == 37 ? -1 : 1;
19394 newDate = this.moveYear(this.date, dir);
19395 newViewDate = this.moveYear(this.viewDate, dir);
19396 } else if (e.shiftKey){
19397 newDate = this.moveMonth(this.date, dir);
19398 newViewDate = this.moveMonth(this.viewDate, dir);
19400 newDate = new Date(this.date);
19401 newDate.setUTCDate(this.date.getUTCDate() + dir);
19402 newViewDate = new Date(this.viewDate);
19403 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19405 if (this.dateWithinRange(newDate)){
19406 this.date = newDate;
19407 this.viewDate = newViewDate;
19408 this.setValue(this.formatDate(this.date));
19410 e.preventDefault();
19411 dateChanged = true;
19416 if (!this.keyboardNavigation) {
19419 dir = e.keyCode == 38 ? -1 : 1;
19421 newDate = this.moveYear(this.date, dir);
19422 newViewDate = this.moveYear(this.viewDate, dir);
19423 } else if (e.shiftKey){
19424 newDate = this.moveMonth(this.date, dir);
19425 newViewDate = this.moveMonth(this.viewDate, dir);
19427 newDate = new Date(this.date);
19428 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19429 newViewDate = new Date(this.viewDate);
19430 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19432 if (this.dateWithinRange(newDate)){
19433 this.date = newDate;
19434 this.viewDate = newViewDate;
19435 this.setValue(this.formatDate(this.date));
19437 e.preventDefault();
19438 dateChanged = true;
19442 this.setValue(this.formatDate(this.date));
19444 e.preventDefault();
19447 this.setValue(this.formatDate(this.date));
19461 onClick: function(e)
19463 e.stopPropagation();
19464 e.preventDefault();
19466 var target = e.getTarget();
19468 if(target.nodeName.toLowerCase() === 'i'){
19469 target = Roo.get(target).dom.parentNode;
19472 var nodeName = target.nodeName;
19473 var className = target.className;
19474 var html = target.innerHTML;
19475 //Roo.log(nodeName);
19477 switch(nodeName.toLowerCase()) {
19479 switch(className) {
19485 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19486 switch(this.viewMode){
19488 this.viewDate = this.moveMonth(this.viewDate, dir);
19492 this.viewDate = this.moveYear(this.viewDate, dir);
19498 var date = new Date();
19499 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19501 this.setValue(this.formatDate(this.date));
19508 if (className.indexOf('disabled') < 0) {
19509 this.viewDate.setUTCDate(1);
19510 if (className.indexOf('month') > -1) {
19511 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19513 var year = parseInt(html, 10) || 0;
19514 this.viewDate.setUTCFullYear(year);
19518 if(this.singleMode){
19519 this.setValue(this.formatDate(this.viewDate));
19530 //Roo.log(className);
19531 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19532 var day = parseInt(html, 10) || 1;
19533 var year = this.viewDate.getUTCFullYear(),
19534 month = this.viewDate.getUTCMonth();
19536 if (className.indexOf('old') > -1) {
19543 } else if (className.indexOf('new') > -1) {
19551 //Roo.log([year,month,day]);
19552 this.date = this.UTCDate(year, month, day,0,0,0,0);
19553 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19555 //Roo.log(this.formatDate(this.date));
19556 this.setValue(this.formatDate(this.date));
19563 setStartDate: function(startDate)
19565 this.startDate = startDate || -Infinity;
19566 if (this.startDate !== -Infinity) {
19567 this.startDate = this.parseDate(this.startDate);
19570 this.updateNavArrows();
19573 setEndDate: function(endDate)
19575 this.endDate = endDate || Infinity;
19576 if (this.endDate !== Infinity) {
19577 this.endDate = this.parseDate(this.endDate);
19580 this.updateNavArrows();
19583 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19585 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19586 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19587 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19589 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19590 return parseInt(d, 10);
19593 this.updateNavArrows();
19596 updateNavArrows: function()
19598 if(this.singleMode){
19602 var d = new Date(this.viewDate),
19603 year = d.getUTCFullYear(),
19604 month = d.getUTCMonth();
19606 Roo.each(this.picker().select('.prev', true).elements, function(v){
19608 switch (this.viewMode) {
19611 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19617 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19624 Roo.each(this.picker().select('.next', true).elements, function(v){
19626 switch (this.viewMode) {
19629 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19635 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19643 moveMonth: function(date, dir)
19648 var new_date = new Date(date.valueOf()),
19649 day = new_date.getUTCDate(),
19650 month = new_date.getUTCMonth(),
19651 mag = Math.abs(dir),
19653 dir = dir > 0 ? 1 : -1;
19656 // If going back one month, make sure month is not current month
19657 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19659 return new_date.getUTCMonth() == month;
19661 // If going forward one month, make sure month is as expected
19662 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19664 return new_date.getUTCMonth() != new_month;
19666 new_month = month + dir;
19667 new_date.setUTCMonth(new_month);
19668 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19669 if (new_month < 0 || new_month > 11) {
19670 new_month = (new_month + 12) % 12;
19673 // For magnitudes >1, move one month at a time...
19674 for (var i=0; i<mag; i++) {
19675 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19676 new_date = this.moveMonth(new_date, dir);
19678 // ...then reset the day, keeping it in the new month
19679 new_month = new_date.getUTCMonth();
19680 new_date.setUTCDate(day);
19682 return new_month != new_date.getUTCMonth();
19685 // Common date-resetting loop -- if date is beyond end of month, make it
19688 new_date.setUTCDate(--day);
19689 new_date.setUTCMonth(new_month);
19694 moveYear: function(date, dir)
19696 return this.moveMonth(date, dir*12);
19699 dateWithinRange: function(date)
19701 return date >= this.startDate && date <= this.endDate;
19707 this.picker().remove();
19710 validateValue : function(value)
19712 if(this.getVisibilityEl().hasClass('hidden')){
19716 if(value.length < 1) {
19717 if(this.allowBlank){
19723 if(value.length < this.minLength){
19726 if(value.length > this.maxLength){
19730 var vt = Roo.form.VTypes;
19731 if(!vt[this.vtype](value, this)){
19735 if(typeof this.validator == "function"){
19736 var msg = this.validator(value);
19742 if(this.regex && !this.regex.test(value)){
19746 if(typeof(this.parseDate(value)) == 'undefined'){
19750 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19754 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19764 this.date = this.viewDate = '';
19766 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19771 Roo.apply(Roo.bootstrap.DateField, {
19782 html: '<i class="fa fa-arrow-left"/>'
19792 html: '<i class="fa fa-arrow-right"/>'
19834 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19835 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19836 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19837 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19838 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19851 navFnc: 'FullYear',
19856 navFnc: 'FullYear',
19861 Roo.apply(Roo.bootstrap.DateField, {
19865 cls: 'datepicker dropdown-menu roo-dynamic',
19869 cls: 'datepicker-days',
19873 cls: 'table-condensed',
19875 Roo.bootstrap.DateField.head,
19879 Roo.bootstrap.DateField.footer
19886 cls: 'datepicker-months',
19890 cls: 'table-condensed',
19892 Roo.bootstrap.DateField.head,
19893 Roo.bootstrap.DateField.content,
19894 Roo.bootstrap.DateField.footer
19901 cls: 'datepicker-years',
19905 cls: 'table-condensed',
19907 Roo.bootstrap.DateField.head,
19908 Roo.bootstrap.DateField.content,
19909 Roo.bootstrap.DateField.footer
19928 * @class Roo.bootstrap.TimeField
19929 * @extends Roo.bootstrap.Input
19930 * Bootstrap DateField class
19934 * Create a new TimeField
19935 * @param {Object} config The config object
19938 Roo.bootstrap.TimeField = function(config){
19939 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19943 * Fires when this field show.
19944 * @param {Roo.bootstrap.DateField} thisthis
19945 * @param {Mixed} date The date value
19950 * Fires when this field hide.
19951 * @param {Roo.bootstrap.DateField} this
19952 * @param {Mixed} date The date value
19957 * Fires when select a date.
19958 * @param {Roo.bootstrap.DateField} this
19959 * @param {Mixed} date The date value
19965 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19968 * @cfg {String} format
19969 * The default time format string which can be overriden for localization support. The format must be
19970 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19974 onRender: function(ct, position)
19977 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19979 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19981 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19983 this.pop = this.picker().select('>.datepicker-time',true).first();
19984 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19986 this.picker().on('mousedown', this.onMousedown, this);
19987 this.picker().on('click', this.onClick, this);
19989 this.picker().addClass('datepicker-dropdown');
19994 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19995 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19996 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19997 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19998 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19999 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
20003 fireKey: function(e){
20004 if (!this.picker().isVisible()){
20005 if (e.keyCode == 27) { // allow escape to hide and re-show picker
20011 e.preventDefault();
20019 this.onTogglePeriod();
20022 this.onIncrementMinutes();
20025 this.onDecrementMinutes();
20034 onClick: function(e) {
20035 e.stopPropagation();
20036 e.preventDefault();
20039 picker : function()
20041 return this.el.select('.datepicker', true).first();
20044 fillTime: function()
20046 var time = this.pop.select('tbody', true).first();
20048 time.dom.innerHTML = '';
20063 cls: 'hours-up glyphicon glyphicon-chevron-up'
20083 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20104 cls: 'timepicker-hour',
20119 cls: 'timepicker-minute',
20134 cls: 'btn btn-primary period',
20156 cls: 'hours-down glyphicon glyphicon-chevron-down'
20176 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20194 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20201 var hours = this.time.getHours();
20202 var minutes = this.time.getMinutes();
20215 hours = hours - 12;
20219 hours = '0' + hours;
20223 minutes = '0' + minutes;
20226 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20227 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20228 this.pop.select('button', true).first().dom.innerHTML = period;
20234 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20236 var cls = ['bottom'];
20238 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20245 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20250 this.picker().addClass(cls.join('-'));
20254 Roo.each(cls, function(c){
20256 _this.picker().setTop(_this.inputEl().getHeight());
20260 _this.picker().setTop(0 - _this.picker().getHeight());
20265 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20269 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20276 onFocus : function()
20278 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20282 onBlur : function()
20284 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20290 this.picker().show();
20295 this.fireEvent('show', this, this.date);
20300 this.picker().hide();
20303 this.fireEvent('hide', this, this.date);
20306 setTime : function()
20309 this.setValue(this.time.format(this.format));
20311 this.fireEvent('select', this, this.date);
20316 onMousedown: function(e){
20317 e.stopPropagation();
20318 e.preventDefault();
20321 onIncrementHours: function()
20323 Roo.log('onIncrementHours');
20324 this.time = this.time.add(Date.HOUR, 1);
20329 onDecrementHours: function()
20331 Roo.log('onDecrementHours');
20332 this.time = this.time.add(Date.HOUR, -1);
20336 onIncrementMinutes: function()
20338 Roo.log('onIncrementMinutes');
20339 this.time = this.time.add(Date.MINUTE, 1);
20343 onDecrementMinutes: function()
20345 Roo.log('onDecrementMinutes');
20346 this.time = this.time.add(Date.MINUTE, -1);
20350 onTogglePeriod: function()
20352 Roo.log('onTogglePeriod');
20353 this.time = this.time.add(Date.HOUR, 12);
20360 Roo.apply(Roo.bootstrap.TimeField, {
20390 cls: 'btn btn-info ok',
20402 Roo.apply(Roo.bootstrap.TimeField, {
20406 cls: 'datepicker dropdown-menu',
20410 cls: 'datepicker-time',
20414 cls: 'table-condensed',
20416 Roo.bootstrap.TimeField.content,
20417 Roo.bootstrap.TimeField.footer
20436 * @class Roo.bootstrap.MonthField
20437 * @extends Roo.bootstrap.Input
20438 * Bootstrap MonthField class
20440 * @cfg {String} language default en
20443 * Create a new MonthField
20444 * @param {Object} config The config object
20447 Roo.bootstrap.MonthField = function(config){
20448 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20453 * Fires when this field show.
20454 * @param {Roo.bootstrap.MonthField} this
20455 * @param {Mixed} date The date value
20460 * Fires when this field hide.
20461 * @param {Roo.bootstrap.MonthField} this
20462 * @param {Mixed} date The date value
20467 * Fires when select a date.
20468 * @param {Roo.bootstrap.MonthField} this
20469 * @param {String} oldvalue The old value
20470 * @param {String} newvalue The new value
20476 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20478 onRender: function(ct, position)
20481 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20483 this.language = this.language || 'en';
20484 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20485 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20487 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20488 this.isInline = false;
20489 this.isInput = true;
20490 this.component = this.el.select('.add-on', true).first() || false;
20491 this.component = (this.component && this.component.length === 0) ? false : this.component;
20492 this.hasInput = this.component && this.inputEL().length;
20494 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20496 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20498 this.picker().on('mousedown', this.onMousedown, this);
20499 this.picker().on('click', this.onClick, this);
20501 this.picker().addClass('datepicker-dropdown');
20503 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20504 v.setStyle('width', '189px');
20511 if(this.isInline) {
20517 setValue: function(v, suppressEvent)
20519 var o = this.getValue();
20521 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20525 if(suppressEvent !== true){
20526 this.fireEvent('select', this, o, v);
20531 getValue: function()
20536 onClick: function(e)
20538 e.stopPropagation();
20539 e.preventDefault();
20541 var target = e.getTarget();
20543 if(target.nodeName.toLowerCase() === 'i'){
20544 target = Roo.get(target).dom.parentNode;
20547 var nodeName = target.nodeName;
20548 var className = target.className;
20549 var html = target.innerHTML;
20551 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20555 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20557 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20563 picker : function()
20565 return this.pickerEl;
20568 fillMonths: function()
20571 var months = this.picker().select('>.datepicker-months td', true).first();
20573 months.dom.innerHTML = '';
20579 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20582 months.createChild(month);
20591 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20592 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20595 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20596 e.removeClass('active');
20598 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20599 e.addClass('active');
20606 if(this.isInline) {
20610 this.picker().removeClass(['bottom', 'top']);
20612 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20614 * place to the top of element!
20618 this.picker().addClass('top');
20619 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20624 this.picker().addClass('bottom');
20626 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20629 onFocus : function()
20631 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20635 onBlur : function()
20637 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20639 var d = this.inputEl().getValue();
20648 this.picker().show();
20649 this.picker().select('>.datepicker-months', true).first().show();
20653 this.fireEvent('show', this, this.date);
20658 if(this.isInline) {
20661 this.picker().hide();
20662 this.fireEvent('hide', this, this.date);
20666 onMousedown: function(e)
20668 e.stopPropagation();
20669 e.preventDefault();
20674 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20678 fireKey: function(e)
20680 if (!this.picker().isVisible()){
20681 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20692 e.preventDefault();
20696 dir = e.keyCode == 37 ? -1 : 1;
20698 this.vIndex = this.vIndex + dir;
20700 if(this.vIndex < 0){
20704 if(this.vIndex > 11){
20708 if(isNaN(this.vIndex)){
20712 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20718 dir = e.keyCode == 38 ? -1 : 1;
20720 this.vIndex = this.vIndex + dir * 4;
20722 if(this.vIndex < 0){
20726 if(this.vIndex > 11){
20730 if(isNaN(this.vIndex)){
20734 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20739 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20740 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20744 e.preventDefault();
20747 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20748 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20764 this.picker().remove();
20769 Roo.apply(Roo.bootstrap.MonthField, {
20788 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20789 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20794 Roo.apply(Roo.bootstrap.MonthField, {
20798 cls: 'datepicker dropdown-menu roo-dynamic',
20802 cls: 'datepicker-months',
20806 cls: 'table-condensed',
20808 Roo.bootstrap.DateField.content
20828 * @class Roo.bootstrap.CheckBox
20829 * @extends Roo.bootstrap.Input
20830 * Bootstrap CheckBox class
20832 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20833 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20834 * @cfg {String} boxLabel The text that appears beside the checkbox
20835 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20836 * @cfg {Boolean} checked initnal the element
20837 * @cfg {Boolean} inline inline the element (default false)
20838 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20839 * @cfg {String} tooltip label tooltip
20842 * Create a new CheckBox
20843 * @param {Object} config The config object
20846 Roo.bootstrap.CheckBox = function(config){
20847 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20852 * Fires when the element is checked or unchecked.
20853 * @param {Roo.bootstrap.CheckBox} this This input
20854 * @param {Boolean} checked The new checked value
20859 * Fires when the element is click.
20860 * @param {Roo.bootstrap.CheckBox} this This input
20867 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20869 inputType: 'checkbox',
20878 getAutoCreate : function()
20880 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20886 cfg.cls = 'form-group ' + this.inputType; //input-group
20889 cfg.cls += ' ' + this.inputType + '-inline';
20895 type : this.inputType,
20896 value : this.inputValue,
20897 cls : 'roo-' + this.inputType, //'form-box',
20898 placeholder : this.placeholder || ''
20902 if(this.inputType != 'radio'){
20906 cls : 'roo-hidden-value',
20907 value : this.checked ? this.inputValue : this.valueOff
20912 if (this.weight) { // Validity check?
20913 cfg.cls += " " + this.inputType + "-" + this.weight;
20916 if (this.disabled) {
20917 input.disabled=true;
20921 input.checked = this.checked;
20926 input.name = this.name;
20928 if(this.inputType != 'radio'){
20929 hidden.name = this.name;
20930 input.name = '_hidden_' + this.name;
20935 input.cls += ' input-' + this.size;
20940 ['xs','sm','md','lg'].map(function(size){
20941 if (settings[size]) {
20942 cfg.cls += ' col-' + size + '-' + settings[size];
20946 var inputblock = input;
20948 if (this.before || this.after) {
20951 cls : 'input-group',
20956 inputblock.cn.push({
20958 cls : 'input-group-addon',
20963 inputblock.cn.push(input);
20965 if(this.inputType != 'radio'){
20966 inputblock.cn.push(hidden);
20970 inputblock.cn.push({
20972 cls : 'input-group-addon',
20979 if (align ==='left' && this.fieldLabel.length) {
20980 // Roo.log("left and has label");
20985 cls : 'control-label',
20986 html : this.fieldLabel
20996 if(this.labelWidth > 12){
20997 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
21000 if(this.labelWidth < 13 && this.labelmd == 0){
21001 this.labelmd = this.labelWidth;
21004 if(this.labellg > 0){
21005 cfg.cn[0].cls += ' col-lg-' + this.labellg;
21006 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
21009 if(this.labelmd > 0){
21010 cfg.cn[0].cls += ' col-md-' + this.labelmd;
21011 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
21014 if(this.labelsm > 0){
21015 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
21016 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
21019 if(this.labelxs > 0){
21020 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
21021 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
21024 } else if ( this.fieldLabel.length) {
21025 // Roo.log(" label");
21029 tag: this.boxLabel ? 'span' : 'label',
21031 cls: 'control-label box-input-label',
21032 //cls : 'input-group-addon',
21033 html : this.fieldLabel
21042 // Roo.log(" no label && no align");
21043 cfg.cn = [ inputblock ] ;
21049 var boxLabelCfg = {
21051 //'for': id, // box label is handled by onclick - so no for...
21053 html: this.boxLabel
21057 boxLabelCfg.tooltip = this.tooltip;
21060 cfg.cn.push(boxLabelCfg);
21063 if(this.inputType != 'radio'){
21064 cfg.cn.push(hidden);
21072 * return the real input element.
21074 inputEl: function ()
21076 return this.el.select('input.roo-' + this.inputType,true).first();
21078 hiddenEl: function ()
21080 return this.el.select('input.roo-hidden-value',true).first();
21083 labelEl: function()
21085 return this.el.select('label.control-label',true).first();
21087 /* depricated... */
21091 return this.labelEl();
21094 boxLabelEl: function()
21096 return this.el.select('label.box-label',true).first();
21099 initEvents : function()
21101 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21103 this.inputEl().on('click', this.onClick, this);
21105 if (this.boxLabel) {
21106 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21109 this.startValue = this.getValue();
21112 Roo.bootstrap.CheckBox.register(this);
21116 onClick : function(e)
21118 if(this.fireEvent('click', this, e) !== false){
21119 this.setChecked(!this.checked);
21124 setChecked : function(state,suppressEvent)
21126 this.startValue = this.getValue();
21128 if(this.inputType == 'radio'){
21130 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21131 e.dom.checked = false;
21134 this.inputEl().dom.checked = true;
21136 this.inputEl().dom.value = this.inputValue;
21138 if(suppressEvent !== true){
21139 this.fireEvent('check', this, true);
21147 this.checked = state;
21149 this.inputEl().dom.checked = state;
21152 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21154 if(suppressEvent !== true){
21155 this.fireEvent('check', this, state);
21161 getValue : function()
21163 if(this.inputType == 'radio'){
21164 return this.getGroupValue();
21167 return this.hiddenEl().dom.value;
21171 getGroupValue : function()
21173 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21177 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21180 setValue : function(v,suppressEvent)
21182 if(this.inputType == 'radio'){
21183 this.setGroupValue(v, suppressEvent);
21187 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21192 setGroupValue : function(v, suppressEvent)
21194 this.startValue = this.getValue();
21196 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21197 e.dom.checked = false;
21199 if(e.dom.value == v){
21200 e.dom.checked = true;
21204 if(suppressEvent !== true){
21205 this.fireEvent('check', this, true);
21213 validate : function()
21215 if(this.getVisibilityEl().hasClass('hidden')){
21221 (this.inputType == 'radio' && this.validateRadio()) ||
21222 (this.inputType == 'checkbox' && this.validateCheckbox())
21228 this.markInvalid();
21232 validateRadio : function()
21234 if(this.getVisibilityEl().hasClass('hidden')){
21238 if(this.allowBlank){
21244 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21245 if(!e.dom.checked){
21257 validateCheckbox : function()
21260 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21261 //return (this.getValue() == this.inputValue) ? true : false;
21264 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21272 for(var i in group){
21273 if(group[i].el.isVisible(true)){
21281 for(var i in group){
21286 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21293 * Mark this field as valid
21295 markValid : function()
21299 this.fireEvent('valid', this);
21301 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21304 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21311 if(this.inputType == 'radio'){
21312 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21313 var fg = e.findParent('.form-group', false, true);
21314 if (Roo.bootstrap.version == 3) {
21315 fg.removeClass([_this.invalidClass, _this.validClass]);
21316 fg.addClass(_this.validClass);
21318 fg.removeClass(['is-valid', 'is-invalid']);
21319 fg.addClass('is-valid');
21327 var fg = this.el.findParent('.form-group', false, true);
21328 if (Roo.bootstrap.version == 3) {
21329 fg.removeClass([this.invalidClass, this.validClass]);
21330 fg.addClass(this.validClass);
21332 fg.removeClass(['is-valid', 'is-invalid']);
21333 fg.addClass('is-valid');
21338 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21344 for(var i in group){
21345 var fg = group[i].el.findParent('.form-group', false, true);
21346 if (Roo.bootstrap.version == 3) {
21347 fg.removeClass([this.invalidClass, this.validClass]);
21348 fg.addClass(this.validClass);
21350 fg.removeClass(['is-valid', 'is-invalid']);
21351 fg.addClass('is-valid');
21357 * Mark this field as invalid
21358 * @param {String} msg The validation message
21360 markInvalid : function(msg)
21362 if(this.allowBlank){
21368 this.fireEvent('invalid', this, msg);
21370 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21373 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21377 label.markInvalid();
21380 if(this.inputType == 'radio'){
21382 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21383 var fg = e.findParent('.form-group', false, true);
21384 if (Roo.bootstrap.version == 3) {
21385 fg.removeClass([_this.invalidClass, _this.validClass]);
21386 fg.addClass(_this.invalidClass);
21388 fg.removeClass(['is-invalid', 'is-valid']);
21389 fg.addClass('is-invalid');
21397 var fg = this.el.findParent('.form-group', false, true);
21398 if (Roo.bootstrap.version == 3) {
21399 fg.removeClass([_this.invalidClass, _this.validClass]);
21400 fg.addClass(_this.invalidClass);
21402 fg.removeClass(['is-invalid', 'is-valid']);
21403 fg.addClass('is-invalid');
21408 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21414 for(var i in group){
21415 var fg = group[i].el.findParent('.form-group', false, true);
21416 if (Roo.bootstrap.version == 3) {
21417 fg.removeClass([_this.invalidClass, _this.validClass]);
21418 fg.addClass(_this.invalidClass);
21420 fg.removeClass(['is-invalid', 'is-valid']);
21421 fg.addClass('is-invalid');
21427 clearInvalid : function()
21429 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21431 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21433 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21435 if (label && label.iconEl) {
21436 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21437 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21441 disable : function()
21443 if(this.inputType != 'radio'){
21444 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21451 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21452 _this.getActionEl().addClass(this.disabledClass);
21453 e.dom.disabled = true;
21457 this.disabled = true;
21458 this.fireEvent("disable", this);
21462 enable : function()
21464 if(this.inputType != 'radio'){
21465 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21472 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21473 _this.getActionEl().removeClass(this.disabledClass);
21474 e.dom.disabled = false;
21478 this.disabled = false;
21479 this.fireEvent("enable", this);
21483 setBoxLabel : function(v)
21488 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21494 Roo.apply(Roo.bootstrap.CheckBox, {
21499 * register a CheckBox Group
21500 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21502 register : function(checkbox)
21504 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21505 this.groups[checkbox.groupId] = {};
21508 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21512 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21516 * fetch a CheckBox Group based on the group ID
21517 * @param {string} the group ID
21518 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21520 get: function(groupId) {
21521 if (typeof(this.groups[groupId]) == 'undefined') {
21525 return this.groups[groupId] ;
21538 * @class Roo.bootstrap.Radio
21539 * @extends Roo.bootstrap.Component
21540 * Bootstrap Radio class
21541 * @cfg {String} boxLabel - the label associated
21542 * @cfg {String} value - the value of radio
21545 * Create a new Radio
21546 * @param {Object} config The config object
21548 Roo.bootstrap.Radio = function(config){
21549 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21553 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21559 getAutoCreate : function()
21563 cls : 'form-group radio',
21568 html : this.boxLabel
21576 initEvents : function()
21578 this.parent().register(this);
21580 this.el.on('click', this.onClick, this);
21584 onClick : function(e)
21586 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21587 this.setChecked(true);
21591 setChecked : function(state, suppressEvent)
21593 this.parent().setValue(this.value, suppressEvent);
21597 setBoxLabel : function(v)
21602 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21617 * @class Roo.bootstrap.SecurePass
21618 * @extends Roo.bootstrap.Input
21619 * Bootstrap SecurePass class
21623 * Create a new SecurePass
21624 * @param {Object} config The config object
21627 Roo.bootstrap.SecurePass = function (config) {
21628 // these go here, so the translation tool can replace them..
21630 PwdEmpty: "Please type a password, and then retype it to confirm.",
21631 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21632 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21633 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21634 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21635 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21636 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21637 TooWeak: "Your password is Too Weak."
21639 this.meterLabel = "Password strength:";
21640 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21641 this.meterClass = [
21642 "roo-password-meter-tooweak",
21643 "roo-password-meter-weak",
21644 "roo-password-meter-medium",
21645 "roo-password-meter-strong",
21646 "roo-password-meter-grey"
21651 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21654 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21656 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21658 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21659 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21660 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21661 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21662 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21663 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21664 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21674 * @cfg {String/Object} Label for the strength meter (defaults to
21675 * 'Password strength:')
21680 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21681 * ['Weak', 'Medium', 'Strong'])
21684 pwdStrengths: false,
21697 initEvents: function ()
21699 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21701 if (this.el.is('input[type=password]') && Roo.isSafari) {
21702 this.el.on('keydown', this.SafariOnKeyDown, this);
21705 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21708 onRender: function (ct, position)
21710 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21711 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21712 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21714 this.trigger.createChild({
21719 cls: 'roo-password-meter-grey col-xs-12',
21722 //width: this.meterWidth + 'px'
21726 cls: 'roo-password-meter-text'
21732 if (this.hideTrigger) {
21733 this.trigger.setDisplayed(false);
21735 this.setSize(this.width || '', this.height || '');
21738 onDestroy: function ()
21740 if (this.trigger) {
21741 this.trigger.removeAllListeners();
21742 this.trigger.remove();
21745 this.wrap.remove();
21747 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21750 checkStrength: function ()
21752 var pwd = this.inputEl().getValue();
21753 if (pwd == this._lastPwd) {
21758 if (this.ClientSideStrongPassword(pwd)) {
21760 } else if (this.ClientSideMediumPassword(pwd)) {
21762 } else if (this.ClientSideWeakPassword(pwd)) {
21768 Roo.log('strength1: ' + strength);
21770 //var pm = this.trigger.child('div/div/div').dom;
21771 var pm = this.trigger.child('div/div');
21772 pm.removeClass(this.meterClass);
21773 pm.addClass(this.meterClass[strength]);
21776 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21778 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21780 this._lastPwd = pwd;
21784 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21786 this._lastPwd = '';
21788 var pm = this.trigger.child('div/div');
21789 pm.removeClass(this.meterClass);
21790 pm.addClass('roo-password-meter-grey');
21793 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21796 this.inputEl().dom.type='password';
21799 validateValue: function (value)
21802 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21805 if (value.length == 0) {
21806 if (this.allowBlank) {
21807 this.clearInvalid();
21811 this.markInvalid(this.errors.PwdEmpty);
21812 this.errorMsg = this.errors.PwdEmpty;
21820 if ('[\x21-\x7e]*'.match(value)) {
21821 this.markInvalid(this.errors.PwdBadChar);
21822 this.errorMsg = this.errors.PwdBadChar;
21825 if (value.length < 6) {
21826 this.markInvalid(this.errors.PwdShort);
21827 this.errorMsg = this.errors.PwdShort;
21830 if (value.length > 16) {
21831 this.markInvalid(this.errors.PwdLong);
21832 this.errorMsg = this.errors.PwdLong;
21836 if (this.ClientSideStrongPassword(value)) {
21838 } else if (this.ClientSideMediumPassword(value)) {
21840 } else if (this.ClientSideWeakPassword(value)) {
21847 if (strength < 2) {
21848 //this.markInvalid(this.errors.TooWeak);
21849 this.errorMsg = this.errors.TooWeak;
21854 console.log('strength2: ' + strength);
21856 //var pm = this.trigger.child('div/div/div').dom;
21858 var pm = this.trigger.child('div/div');
21859 pm.removeClass(this.meterClass);
21860 pm.addClass(this.meterClass[strength]);
21862 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21864 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21866 this.errorMsg = '';
21870 CharacterSetChecks: function (type)
21873 this.fResult = false;
21876 isctype: function (character, type)
21879 case this.kCapitalLetter:
21880 if (character >= 'A' && character <= 'Z') {
21885 case this.kSmallLetter:
21886 if (character >= 'a' && character <= 'z') {
21892 if (character >= '0' && character <= '9') {
21897 case this.kPunctuation:
21898 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21909 IsLongEnough: function (pwd, size)
21911 return !(pwd == null || isNaN(size) || pwd.length < size);
21914 SpansEnoughCharacterSets: function (word, nb)
21916 if (!this.IsLongEnough(word, nb))
21921 var characterSetChecks = new Array(
21922 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21923 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21926 for (var index = 0; index < word.length; ++index) {
21927 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21928 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21929 characterSetChecks[nCharSet].fResult = true;
21936 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21937 if (characterSetChecks[nCharSet].fResult) {
21942 if (nCharSets < nb) {
21948 ClientSideStrongPassword: function (pwd)
21950 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21953 ClientSideMediumPassword: function (pwd)
21955 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21958 ClientSideWeakPassword: function (pwd)
21960 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21963 })//<script type="text/javascript">
21966 * Based Ext JS Library 1.1.1
21967 * Copyright(c) 2006-2007, Ext JS, LLC.
21973 * @class Roo.HtmlEditorCore
21974 * @extends Roo.Component
21975 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21977 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21980 Roo.HtmlEditorCore = function(config){
21983 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21988 * @event initialize
21989 * Fires when the editor is fully initialized (including the iframe)
21990 * @param {Roo.HtmlEditorCore} this
21995 * Fires when the editor is first receives the focus. Any insertion must wait
21996 * until after this event.
21997 * @param {Roo.HtmlEditorCore} this
22001 * @event beforesync
22002 * Fires before the textarea is updated with content from the editor iframe. Return false
22003 * to cancel the sync.
22004 * @param {Roo.HtmlEditorCore} this
22005 * @param {String} html
22009 * @event beforepush
22010 * Fires before the iframe editor is updated with content from the textarea. Return false
22011 * to cancel the push.
22012 * @param {Roo.HtmlEditorCore} this
22013 * @param {String} html
22018 * Fires when the textarea is updated with content from the editor iframe.
22019 * @param {Roo.HtmlEditorCore} this
22020 * @param {String} html
22025 * Fires when the iframe editor is updated with content from the textarea.
22026 * @param {Roo.HtmlEditorCore} this
22027 * @param {String} html
22032 * @event editorevent
22033 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22034 * @param {Roo.HtmlEditorCore} this
22040 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22042 // defaults : white / black...
22043 this.applyBlacklists();
22050 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22054 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22060 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22065 * @cfg {Number} height (in pixels)
22069 * @cfg {Number} width (in pixels)
22074 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22077 stylesheets: false,
22082 // private properties
22083 validationEvent : false,
22085 initialized : false,
22087 sourceEditMode : false,
22088 onFocus : Roo.emptyFn,
22090 hideMode:'offsets',
22094 // blacklist + whitelisted elements..
22101 * Protected method that will not generally be called directly. It
22102 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22103 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22105 getDocMarkup : function(){
22109 // inherit styels from page...??
22110 if (this.stylesheets === false) {
22112 Roo.get(document.head).select('style').each(function(node) {
22113 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22116 Roo.get(document.head).select('link').each(function(node) {
22117 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22120 } else if (!this.stylesheets.length) {
22122 st = '<style type="text/css">' +
22123 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22126 st = '<style type="text/css">' +
22131 st += '<style type="text/css">' +
22132 'IMG { cursor: pointer } ' +
22135 var cls = 'roo-htmleditor-body';
22137 if(this.bodyCls.length){
22138 cls += ' ' + this.bodyCls;
22141 return '<html><head>' + st +
22142 //<style type="text/css">' +
22143 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22145 ' </head><body class="' + cls + '"></body></html>';
22149 onRender : function(ct, position)
22152 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22153 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22156 this.el.dom.style.border = '0 none';
22157 this.el.dom.setAttribute('tabIndex', -1);
22158 this.el.addClass('x-hidden hide');
22162 if(Roo.isIE){ // fix IE 1px bogus margin
22163 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22167 this.frameId = Roo.id();
22171 var iframe = this.owner.wrap.createChild({
22173 cls: 'form-control', // bootstrap..
22175 name: this.frameId,
22176 frameBorder : 'no',
22177 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22182 this.iframe = iframe.dom;
22184 this.assignDocWin();
22186 this.doc.designMode = 'on';
22189 this.doc.write(this.getDocMarkup());
22193 var task = { // must defer to wait for browser to be ready
22195 //console.log("run task?" + this.doc.readyState);
22196 this.assignDocWin();
22197 if(this.doc.body || this.doc.readyState == 'complete'){
22199 this.doc.designMode="on";
22203 Roo.TaskMgr.stop(task);
22204 this.initEditor.defer(10, this);
22211 Roo.TaskMgr.start(task);
22216 onResize : function(w, h)
22218 Roo.log('resize: ' +w + ',' + h );
22219 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22223 if(typeof w == 'number'){
22225 this.iframe.style.width = w + 'px';
22227 if(typeof h == 'number'){
22229 this.iframe.style.height = h + 'px';
22231 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22238 * Toggles the editor between standard and source edit mode.
22239 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22241 toggleSourceEdit : function(sourceEditMode){
22243 this.sourceEditMode = sourceEditMode === true;
22245 if(this.sourceEditMode){
22247 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22250 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22251 //this.iframe.className = '';
22254 //this.setSize(this.owner.wrap.getSize());
22255 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22262 * Protected method that will not generally be called directly. If you need/want
22263 * custom HTML cleanup, this is the method you should override.
22264 * @param {String} html The HTML to be cleaned
22265 * return {String} The cleaned HTML
22267 cleanHtml : function(html){
22268 html = String(html);
22269 if(html.length > 5){
22270 if(Roo.isSafari){ // strip safari nonsense
22271 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22274 if(html == ' '){
22281 * HTML Editor -> Textarea
22282 * Protected method that will not generally be called directly. Syncs the contents
22283 * of the editor iframe with the textarea.
22285 syncValue : function(){
22286 if(this.initialized){
22287 var bd = (this.doc.body || this.doc.documentElement);
22288 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22289 var html = bd.innerHTML;
22291 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22292 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22294 html = '<div style="'+m[0]+'">' + html + '</div>';
22297 html = this.cleanHtml(html);
22298 // fix up the special chars.. normaly like back quotes in word...
22299 // however we do not want to do this with chinese..
22300 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22301 var cc = b.charCodeAt();
22303 (cc >= 0x4E00 && cc < 0xA000 ) ||
22304 (cc >= 0x3400 && cc < 0x4E00 ) ||
22305 (cc >= 0xf900 && cc < 0xfb00 )
22311 if(this.owner.fireEvent('beforesync', this, html) !== false){
22312 this.el.dom.value = html;
22313 this.owner.fireEvent('sync', this, html);
22319 * Protected method that will not generally be called directly. Pushes the value of the textarea
22320 * into the iframe editor.
22322 pushValue : function(){
22323 if(this.initialized){
22324 var v = this.el.dom.value.trim();
22326 // if(v.length < 1){
22330 if(this.owner.fireEvent('beforepush', this, v) !== false){
22331 var d = (this.doc.body || this.doc.documentElement);
22333 this.cleanUpPaste();
22334 this.el.dom.value = d.innerHTML;
22335 this.owner.fireEvent('push', this, v);
22341 deferFocus : function(){
22342 this.focus.defer(10, this);
22346 focus : function(){
22347 if(this.win && !this.sourceEditMode){
22354 assignDocWin: function()
22356 var iframe = this.iframe;
22359 this.doc = iframe.contentWindow.document;
22360 this.win = iframe.contentWindow;
22362 // if (!Roo.get(this.frameId)) {
22365 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22366 // this.win = Roo.get(this.frameId).dom.contentWindow;
22368 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22372 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22373 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22378 initEditor : function(){
22379 //console.log("INIT EDITOR");
22380 this.assignDocWin();
22384 this.doc.designMode="on";
22386 this.doc.write(this.getDocMarkup());
22389 var dbody = (this.doc.body || this.doc.documentElement);
22390 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22391 // this copies styles from the containing element into thsi one..
22392 // not sure why we need all of this..
22393 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22395 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22396 //ss['background-attachment'] = 'fixed'; // w3c
22397 dbody.bgProperties = 'fixed'; // ie
22398 //Roo.DomHelper.applyStyles(dbody, ss);
22399 Roo.EventManager.on(this.doc, {
22400 //'mousedown': this.onEditorEvent,
22401 'mouseup': this.onEditorEvent,
22402 'dblclick': this.onEditorEvent,
22403 'click': this.onEditorEvent,
22404 'keyup': this.onEditorEvent,
22409 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22411 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22412 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22414 this.initialized = true;
22416 this.owner.fireEvent('initialize', this);
22421 onDestroy : function(){
22427 //for (var i =0; i < this.toolbars.length;i++) {
22428 // // fixme - ask toolbars for heights?
22429 // this.toolbars[i].onDestroy();
22432 //this.wrap.dom.innerHTML = '';
22433 //this.wrap.remove();
22438 onFirstFocus : function(){
22440 this.assignDocWin();
22443 this.activated = true;
22446 if(Roo.isGecko){ // prevent silly gecko errors
22448 var s = this.win.getSelection();
22449 if(!s.focusNode || s.focusNode.nodeType != 3){
22450 var r = s.getRangeAt(0);
22451 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22456 this.execCmd('useCSS', true);
22457 this.execCmd('styleWithCSS', false);
22460 this.owner.fireEvent('activate', this);
22464 adjustFont: function(btn){
22465 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22466 //if(Roo.isSafari){ // safari
22469 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22470 if(Roo.isSafari){ // safari
22471 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22472 v = (v < 10) ? 10 : v;
22473 v = (v > 48) ? 48 : v;
22474 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22479 v = Math.max(1, v+adjust);
22481 this.execCmd('FontSize', v );
22484 onEditorEvent : function(e)
22486 this.owner.fireEvent('editorevent', this, e);
22487 // this.updateToolbar();
22488 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22491 insertTag : function(tg)
22493 // could be a bit smarter... -> wrap the current selected tRoo..
22494 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22496 range = this.createRange(this.getSelection());
22497 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22498 wrappingNode.appendChild(range.extractContents());
22499 range.insertNode(wrappingNode);
22506 this.execCmd("formatblock", tg);
22510 insertText : function(txt)
22514 var range = this.createRange();
22515 range.deleteContents();
22516 //alert(Sender.getAttribute('label'));
22518 range.insertNode(this.doc.createTextNode(txt));
22524 * Executes a Midas editor command on the editor document and performs necessary focus and
22525 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22526 * @param {String} cmd The Midas command
22527 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22529 relayCmd : function(cmd, value){
22531 this.execCmd(cmd, value);
22532 this.owner.fireEvent('editorevent', this);
22533 //this.updateToolbar();
22534 this.owner.deferFocus();
22538 * Executes a Midas editor command directly on the editor document.
22539 * For visual commands, you should use {@link #relayCmd} instead.
22540 * <b>This should only be called after the editor is initialized.</b>
22541 * @param {String} cmd The Midas command
22542 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22544 execCmd : function(cmd, value){
22545 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22552 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22554 * @param {String} text | dom node..
22556 insertAtCursor : function(text)
22559 if(!this.activated){
22565 var r = this.doc.selection.createRange();
22576 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22580 // from jquery ui (MIT licenced)
22582 var win = this.win;
22584 if (win.getSelection && win.getSelection().getRangeAt) {
22585 range = win.getSelection().getRangeAt(0);
22586 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22587 range.insertNode(node);
22588 } else if (win.document.selection && win.document.selection.createRange) {
22589 // no firefox support
22590 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22591 win.document.selection.createRange().pasteHTML(txt);
22593 // no firefox support
22594 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22595 this.execCmd('InsertHTML', txt);
22604 mozKeyPress : function(e){
22606 var c = e.getCharCode(), cmd;
22609 c = String.fromCharCode(c).toLowerCase();
22623 this.cleanUpPaste.defer(100, this);
22631 e.preventDefault();
22639 fixKeys : function(){ // load time branching for fastest keydown performance
22641 return function(e){
22642 var k = e.getKey(), r;
22645 r = this.doc.selection.createRange();
22648 r.pasteHTML('    ');
22655 r = this.doc.selection.createRange();
22657 var target = r.parentElement();
22658 if(!target || target.tagName.toLowerCase() != 'li'){
22660 r.pasteHTML('<br />');
22666 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22667 this.cleanUpPaste.defer(100, this);
22673 }else if(Roo.isOpera){
22674 return function(e){
22675 var k = e.getKey();
22679 this.execCmd('InsertHTML','    ');
22682 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22683 this.cleanUpPaste.defer(100, this);
22688 }else if(Roo.isSafari){
22689 return function(e){
22690 var k = e.getKey();
22694 this.execCmd('InsertText','\t');
22698 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22699 this.cleanUpPaste.defer(100, this);
22707 getAllAncestors: function()
22709 var p = this.getSelectedNode();
22712 a.push(p); // push blank onto stack..
22713 p = this.getParentElement();
22717 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22721 a.push(this.doc.body);
22725 lastSelNode : false,
22728 getSelection : function()
22730 this.assignDocWin();
22731 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22734 getSelectedNode: function()
22736 // this may only work on Gecko!!!
22738 // should we cache this!!!!
22743 var range = this.createRange(this.getSelection()).cloneRange();
22746 var parent = range.parentElement();
22748 var testRange = range.duplicate();
22749 testRange.moveToElementText(parent);
22750 if (testRange.inRange(range)) {
22753 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22756 parent = parent.parentElement;
22761 // is ancestor a text element.
22762 var ac = range.commonAncestorContainer;
22763 if (ac.nodeType == 3) {
22764 ac = ac.parentNode;
22767 var ar = ac.childNodes;
22770 var other_nodes = [];
22771 var has_other_nodes = false;
22772 for (var i=0;i<ar.length;i++) {
22773 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22776 // fullly contained node.
22778 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22783 // probably selected..
22784 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22785 other_nodes.push(ar[i]);
22789 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22794 has_other_nodes = true;
22796 if (!nodes.length && other_nodes.length) {
22797 nodes= other_nodes;
22799 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22805 createRange: function(sel)
22807 // this has strange effects when using with
22808 // top toolbar - not sure if it's a great idea.
22809 //this.editor.contentWindow.focus();
22810 if (typeof sel != "undefined") {
22812 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22814 return this.doc.createRange();
22817 return this.doc.createRange();
22820 getParentElement: function()
22823 this.assignDocWin();
22824 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22826 var range = this.createRange(sel);
22829 var p = range.commonAncestorContainer;
22830 while (p.nodeType == 3) { // text node
22841 * Range intersection.. the hard stuff...
22845 * [ -- selected range --- ]
22849 * if end is before start or hits it. fail.
22850 * if start is after end or hits it fail.
22852 * if either hits (but other is outside. - then it's not
22858 // @see http://www.thismuchiknow.co.uk/?p=64.
22859 rangeIntersectsNode : function(range, node)
22861 var nodeRange = node.ownerDocument.createRange();
22863 nodeRange.selectNode(node);
22865 nodeRange.selectNodeContents(node);
22868 var rangeStartRange = range.cloneRange();
22869 rangeStartRange.collapse(true);
22871 var rangeEndRange = range.cloneRange();
22872 rangeEndRange.collapse(false);
22874 var nodeStartRange = nodeRange.cloneRange();
22875 nodeStartRange.collapse(true);
22877 var nodeEndRange = nodeRange.cloneRange();
22878 nodeEndRange.collapse(false);
22880 return rangeStartRange.compareBoundaryPoints(
22881 Range.START_TO_START, nodeEndRange) == -1 &&
22882 rangeEndRange.compareBoundaryPoints(
22883 Range.START_TO_START, nodeStartRange) == 1;
22887 rangeCompareNode : function(range, node)
22889 var nodeRange = node.ownerDocument.createRange();
22891 nodeRange.selectNode(node);
22893 nodeRange.selectNodeContents(node);
22897 range.collapse(true);
22899 nodeRange.collapse(true);
22901 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22902 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22904 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22906 var nodeIsBefore = ss == 1;
22907 var nodeIsAfter = ee == -1;
22909 if (nodeIsBefore && nodeIsAfter) {
22912 if (!nodeIsBefore && nodeIsAfter) {
22913 return 1; //right trailed.
22916 if (nodeIsBefore && !nodeIsAfter) {
22917 return 2; // left trailed.
22923 // private? - in a new class?
22924 cleanUpPaste : function()
22926 // cleans up the whole document..
22927 Roo.log('cleanuppaste');
22929 this.cleanUpChildren(this.doc.body);
22930 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22931 if (clean != this.doc.body.innerHTML) {
22932 this.doc.body.innerHTML = clean;
22937 cleanWordChars : function(input) {// change the chars to hex code
22938 var he = Roo.HtmlEditorCore;
22940 var output = input;
22941 Roo.each(he.swapCodes, function(sw) {
22942 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22944 output = output.replace(swapper, sw[1]);
22951 cleanUpChildren : function (n)
22953 if (!n.childNodes.length) {
22956 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22957 this.cleanUpChild(n.childNodes[i]);
22964 cleanUpChild : function (node)
22967 //console.log(node);
22968 if (node.nodeName == "#text") {
22969 // clean up silly Windows -- stuff?
22972 if (node.nodeName == "#comment") {
22973 node.parentNode.removeChild(node);
22974 // clean up silly Windows -- stuff?
22977 var lcname = node.tagName.toLowerCase();
22978 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22979 // whitelist of tags..
22981 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22983 node.parentNode.removeChild(node);
22988 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22990 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22991 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22993 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22994 // remove_keep_children = true;
22997 if (remove_keep_children) {
22998 this.cleanUpChildren(node);
22999 // inserts everything just before this node...
23000 while (node.childNodes.length) {
23001 var cn = node.childNodes[0];
23002 node.removeChild(cn);
23003 node.parentNode.insertBefore(cn, node);
23005 node.parentNode.removeChild(node);
23009 if (!node.attributes || !node.attributes.length) {
23010 this.cleanUpChildren(node);
23014 function cleanAttr(n,v)
23017 if (v.match(/^\./) || v.match(/^\//)) {
23020 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
23023 if (v.match(/^#/)) {
23026 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
23027 node.removeAttribute(n);
23031 var cwhite = this.cwhite;
23032 var cblack = this.cblack;
23034 function cleanStyle(n,v)
23036 if (v.match(/expression/)) { //XSS?? should we even bother..
23037 node.removeAttribute(n);
23041 var parts = v.split(/;/);
23044 Roo.each(parts, function(p) {
23045 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23049 var l = p.split(':').shift().replace(/\s+/g,'');
23050 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23052 if ( cwhite.length && cblack.indexOf(l) > -1) {
23053 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23054 //node.removeAttribute(n);
23058 // only allow 'c whitelisted system attributes'
23059 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23060 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23061 //node.removeAttribute(n);
23071 if (clean.length) {
23072 node.setAttribute(n, clean.join(';'));
23074 node.removeAttribute(n);
23080 for (var i = node.attributes.length-1; i > -1 ; i--) {
23081 var a = node.attributes[i];
23084 if (a.name.toLowerCase().substr(0,2)=='on') {
23085 node.removeAttribute(a.name);
23088 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23089 node.removeAttribute(a.name);
23092 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23093 cleanAttr(a.name,a.value); // fixme..
23096 if (a.name == 'style') {
23097 cleanStyle(a.name,a.value);
23100 /// clean up MS crap..
23101 // tecnically this should be a list of valid class'es..
23104 if (a.name == 'class') {
23105 if (a.value.match(/^Mso/)) {
23106 node.className = '';
23109 if (a.value.match(/^body$/)) {
23110 node.className = '';
23121 this.cleanUpChildren(node);
23127 * Clean up MS wordisms...
23129 cleanWord : function(node)
23134 this.cleanWord(this.doc.body);
23137 if (node.nodeName == "#text") {
23138 // clean up silly Windows -- stuff?
23141 if (node.nodeName == "#comment") {
23142 node.parentNode.removeChild(node);
23143 // clean up silly Windows -- stuff?
23147 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23148 node.parentNode.removeChild(node);
23152 // remove - but keep children..
23153 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23154 while (node.childNodes.length) {
23155 var cn = node.childNodes[0];
23156 node.removeChild(cn);
23157 node.parentNode.insertBefore(cn, node);
23159 node.parentNode.removeChild(node);
23160 this.iterateChildren(node, this.cleanWord);
23164 if (node.className.length) {
23166 var cn = node.className.split(/\W+/);
23168 Roo.each(cn, function(cls) {
23169 if (cls.match(/Mso[a-zA-Z]+/)) {
23174 node.className = cna.length ? cna.join(' ') : '';
23176 node.removeAttribute("class");
23180 if (node.hasAttribute("lang")) {
23181 node.removeAttribute("lang");
23184 if (node.hasAttribute("style")) {
23186 var styles = node.getAttribute("style").split(";");
23188 Roo.each(styles, function(s) {
23189 if (!s.match(/:/)) {
23192 var kv = s.split(":");
23193 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23196 // what ever is left... we allow.
23199 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23200 if (!nstyle.length) {
23201 node.removeAttribute('style');
23204 this.iterateChildren(node, this.cleanWord);
23210 * iterateChildren of a Node, calling fn each time, using this as the scole..
23211 * @param {DomNode} node node to iterate children of.
23212 * @param {Function} fn method of this class to call on each item.
23214 iterateChildren : function(node, fn)
23216 if (!node.childNodes.length) {
23219 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23220 fn.call(this, node.childNodes[i])
23226 * cleanTableWidths.
23228 * Quite often pasting from word etc.. results in tables with column and widths.
23229 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23232 cleanTableWidths : function(node)
23237 this.cleanTableWidths(this.doc.body);
23242 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23245 Roo.log(node.tagName);
23246 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23247 this.iterateChildren(node, this.cleanTableWidths);
23250 if (node.hasAttribute('width')) {
23251 node.removeAttribute('width');
23255 if (node.hasAttribute("style")) {
23258 var styles = node.getAttribute("style").split(";");
23260 Roo.each(styles, function(s) {
23261 if (!s.match(/:/)) {
23264 var kv = s.split(":");
23265 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23268 // what ever is left... we allow.
23271 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23272 if (!nstyle.length) {
23273 node.removeAttribute('style');
23277 this.iterateChildren(node, this.cleanTableWidths);
23285 domToHTML : function(currentElement, depth, nopadtext) {
23287 depth = depth || 0;
23288 nopadtext = nopadtext || false;
23290 if (!currentElement) {
23291 return this.domToHTML(this.doc.body);
23294 //Roo.log(currentElement);
23296 var allText = false;
23297 var nodeName = currentElement.nodeName;
23298 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23300 if (nodeName == '#text') {
23302 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23307 if (nodeName != 'BODY') {
23310 // Prints the node tagName, such as <A>, <IMG>, etc
23313 for(i = 0; i < currentElement.attributes.length;i++) {
23315 var aname = currentElement.attributes.item(i).name;
23316 if (!currentElement.attributes.item(i).value.length) {
23319 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23322 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23331 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23334 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23339 // Traverse the tree
23341 var currentElementChild = currentElement.childNodes.item(i);
23342 var allText = true;
23343 var innerHTML = '';
23345 while (currentElementChild) {
23346 // Formatting code (indent the tree so it looks nice on the screen)
23347 var nopad = nopadtext;
23348 if (lastnode == 'SPAN') {
23352 if (currentElementChild.nodeName == '#text') {
23353 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23354 toadd = nopadtext ? toadd : toadd.trim();
23355 if (!nopad && toadd.length > 80) {
23356 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23358 innerHTML += toadd;
23361 currentElementChild = currentElement.childNodes.item(i);
23367 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23369 // Recursively traverse the tree structure of the child node
23370 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23371 lastnode = currentElementChild.nodeName;
23373 currentElementChild=currentElement.childNodes.item(i);
23379 // The remaining code is mostly for formatting the tree
23380 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23385 ret+= "</"+tagName+">";
23391 applyBlacklists : function()
23393 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23394 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23398 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23399 if (b.indexOf(tag) > -1) {
23402 this.white.push(tag);
23406 Roo.each(w, function(tag) {
23407 if (b.indexOf(tag) > -1) {
23410 if (this.white.indexOf(tag) > -1) {
23413 this.white.push(tag);
23418 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23419 if (w.indexOf(tag) > -1) {
23422 this.black.push(tag);
23426 Roo.each(b, function(tag) {
23427 if (w.indexOf(tag) > -1) {
23430 if (this.black.indexOf(tag) > -1) {
23433 this.black.push(tag);
23438 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23439 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23443 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23444 if (b.indexOf(tag) > -1) {
23447 this.cwhite.push(tag);
23451 Roo.each(w, function(tag) {
23452 if (b.indexOf(tag) > -1) {
23455 if (this.cwhite.indexOf(tag) > -1) {
23458 this.cwhite.push(tag);
23463 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23464 if (w.indexOf(tag) > -1) {
23467 this.cblack.push(tag);
23471 Roo.each(b, function(tag) {
23472 if (w.indexOf(tag) > -1) {
23475 if (this.cblack.indexOf(tag) > -1) {
23478 this.cblack.push(tag);
23483 setStylesheets : function(stylesheets)
23485 if(typeof(stylesheets) == 'string'){
23486 Roo.get(this.iframe.contentDocument.head).createChild({
23488 rel : 'stylesheet',
23497 Roo.each(stylesheets, function(s) {
23502 Roo.get(_this.iframe.contentDocument.head).createChild({
23504 rel : 'stylesheet',
23513 removeStylesheets : function()
23517 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23522 setStyle : function(style)
23524 Roo.get(this.iframe.contentDocument.head).createChild({
23533 // hide stuff that is not compatible
23547 * @event specialkey
23551 * @cfg {String} fieldClass @hide
23554 * @cfg {String} focusClass @hide
23557 * @cfg {String} autoCreate @hide
23560 * @cfg {String} inputType @hide
23563 * @cfg {String} invalidClass @hide
23566 * @cfg {String} invalidText @hide
23569 * @cfg {String} msgFx @hide
23572 * @cfg {String} validateOnBlur @hide
23576 Roo.HtmlEditorCore.white = [
23577 'area', 'br', 'img', 'input', 'hr', 'wbr',
23579 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23580 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23581 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23582 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23583 'table', 'ul', 'xmp',
23585 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23588 'dir', 'menu', 'ol', 'ul', 'dl',
23594 Roo.HtmlEditorCore.black = [
23595 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23597 'base', 'basefont', 'bgsound', 'blink', 'body',
23598 'frame', 'frameset', 'head', 'html', 'ilayer',
23599 'iframe', 'layer', 'link', 'meta', 'object',
23600 'script', 'style' ,'title', 'xml' // clean later..
23602 Roo.HtmlEditorCore.clean = [
23603 'script', 'style', 'title', 'xml'
23605 Roo.HtmlEditorCore.remove = [
23610 Roo.HtmlEditorCore.ablack = [
23614 Roo.HtmlEditorCore.aclean = [
23615 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23619 Roo.HtmlEditorCore.pwhite= [
23620 'http', 'https', 'mailto'
23623 // white listed style attributes.
23624 Roo.HtmlEditorCore.cwhite= [
23625 // 'text-align', /// default is to allow most things..
23631 // black listed style attributes.
23632 Roo.HtmlEditorCore.cblack= [
23633 // 'font-size' -- this can be set by the project
23637 Roo.HtmlEditorCore.swapCodes =[
23656 * @class Roo.bootstrap.HtmlEditor
23657 * @extends Roo.bootstrap.TextArea
23658 * Bootstrap HtmlEditor class
23661 * Create a new HtmlEditor
23662 * @param {Object} config The config object
23665 Roo.bootstrap.HtmlEditor = function(config){
23666 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23667 if (!this.toolbars) {
23668 this.toolbars = [];
23671 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23674 * @event initialize
23675 * Fires when the editor is fully initialized (including the iframe)
23676 * @param {HtmlEditor} this
23681 * Fires when the editor is first receives the focus. Any insertion must wait
23682 * until after this event.
23683 * @param {HtmlEditor} this
23687 * @event beforesync
23688 * Fires before the textarea is updated with content from the editor iframe. Return false
23689 * to cancel the sync.
23690 * @param {HtmlEditor} this
23691 * @param {String} html
23695 * @event beforepush
23696 * Fires before the iframe editor is updated with content from the textarea. Return false
23697 * to cancel the push.
23698 * @param {HtmlEditor} this
23699 * @param {String} html
23704 * Fires when the textarea is updated with content from the editor iframe.
23705 * @param {HtmlEditor} this
23706 * @param {String} html
23711 * Fires when the iframe editor is updated with content from the textarea.
23712 * @param {HtmlEditor} this
23713 * @param {String} html
23717 * @event editmodechange
23718 * Fires when the editor switches edit modes
23719 * @param {HtmlEditor} this
23720 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23722 editmodechange: true,
23724 * @event editorevent
23725 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23726 * @param {HtmlEditor} this
23730 * @event firstfocus
23731 * Fires when on first focus - needed by toolbars..
23732 * @param {HtmlEditor} this
23737 * Auto save the htmlEditor value as a file into Events
23738 * @param {HtmlEditor} this
23742 * @event savedpreview
23743 * preview the saved version of htmlEditor
23744 * @param {HtmlEditor} this
23751 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23755 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23760 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23765 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23770 * @cfg {Number} height (in pixels)
23774 * @cfg {Number} width (in pixels)
23779 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23782 stylesheets: false,
23787 // private properties
23788 validationEvent : false,
23790 initialized : false,
23793 onFocus : Roo.emptyFn,
23795 hideMode:'offsets',
23797 tbContainer : false,
23801 toolbarContainer :function() {
23802 return this.wrap.select('.x-html-editor-tb',true).first();
23806 * Protected method that will not generally be called directly. It
23807 * is called when the editor creates its toolbar. Override this method if you need to
23808 * add custom toolbar buttons.
23809 * @param {HtmlEditor} editor
23811 createToolbar : function(){
23812 Roo.log('renewing');
23813 Roo.log("create toolbars");
23815 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23816 this.toolbars[0].render(this.toolbarContainer());
23820 // if (!editor.toolbars || !editor.toolbars.length) {
23821 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23824 // for (var i =0 ; i < editor.toolbars.length;i++) {
23825 // editor.toolbars[i] = Roo.factory(
23826 // typeof(editor.toolbars[i]) == 'string' ?
23827 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23828 // Roo.bootstrap.HtmlEditor);
23829 // editor.toolbars[i].init(editor);
23835 onRender : function(ct, position)
23837 // Roo.log("Call onRender: " + this.xtype);
23839 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23841 this.wrap = this.inputEl().wrap({
23842 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23845 this.editorcore.onRender(ct, position);
23847 if (this.resizable) {
23848 this.resizeEl = new Roo.Resizable(this.wrap, {
23852 minHeight : this.height,
23853 height: this.height,
23854 handles : this.resizable,
23857 resize : function(r, w, h) {
23858 _t.onResize(w,h); // -something
23864 this.createToolbar(this);
23867 if(!this.width && this.resizable){
23868 this.setSize(this.wrap.getSize());
23870 if (this.resizeEl) {
23871 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23872 // should trigger onReize..
23878 onResize : function(w, h)
23880 Roo.log('resize: ' +w + ',' + h );
23881 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23885 if(this.inputEl() ){
23886 if(typeof w == 'number'){
23887 var aw = w - this.wrap.getFrameWidth('lr');
23888 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23891 if(typeof h == 'number'){
23892 var tbh = -11; // fixme it needs to tool bar size!
23893 for (var i =0; i < this.toolbars.length;i++) {
23894 // fixme - ask toolbars for heights?
23895 tbh += this.toolbars[i].el.getHeight();
23896 //if (this.toolbars[i].footer) {
23897 // tbh += this.toolbars[i].footer.el.getHeight();
23905 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23906 ah -= 5; // knock a few pixes off for look..
23907 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23911 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23912 this.editorcore.onResize(ew,eh);
23917 * Toggles the editor between standard and source edit mode.
23918 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23920 toggleSourceEdit : function(sourceEditMode)
23922 this.editorcore.toggleSourceEdit(sourceEditMode);
23924 if(this.editorcore.sourceEditMode){
23925 Roo.log('editor - showing textarea');
23928 // Roo.log(this.syncValue());
23930 this.inputEl().removeClass(['hide', 'x-hidden']);
23931 this.inputEl().dom.removeAttribute('tabIndex');
23932 this.inputEl().focus();
23934 Roo.log('editor - hiding textarea');
23936 // Roo.log(this.pushValue());
23939 this.inputEl().addClass(['hide', 'x-hidden']);
23940 this.inputEl().dom.setAttribute('tabIndex', -1);
23941 //this.deferFocus();
23944 if(this.resizable){
23945 this.setSize(this.wrap.getSize());
23948 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23951 // private (for BoxComponent)
23952 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23954 // private (for BoxComponent)
23955 getResizeEl : function(){
23959 // private (for BoxComponent)
23960 getPositionEl : function(){
23965 initEvents : function(){
23966 this.originalValue = this.getValue();
23970 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23973 // markInvalid : Roo.emptyFn,
23975 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23978 // clearInvalid : Roo.emptyFn,
23980 setValue : function(v){
23981 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23982 this.editorcore.pushValue();
23987 deferFocus : function(){
23988 this.focus.defer(10, this);
23992 focus : function(){
23993 this.editorcore.focus();
23999 onDestroy : function(){
24005 for (var i =0; i < this.toolbars.length;i++) {
24006 // fixme - ask toolbars for heights?
24007 this.toolbars[i].onDestroy();
24010 this.wrap.dom.innerHTML = '';
24011 this.wrap.remove();
24016 onFirstFocus : function(){
24017 //Roo.log("onFirstFocus");
24018 this.editorcore.onFirstFocus();
24019 for (var i =0; i < this.toolbars.length;i++) {
24020 this.toolbars[i].onFirstFocus();
24026 syncValue : function()
24028 this.editorcore.syncValue();
24031 pushValue : function()
24033 this.editorcore.pushValue();
24037 // hide stuff that is not compatible
24051 * @event specialkey
24055 * @cfg {String} fieldClass @hide
24058 * @cfg {String} focusClass @hide
24061 * @cfg {String} autoCreate @hide
24064 * @cfg {String} inputType @hide
24068 * @cfg {String} invalidText @hide
24071 * @cfg {String} msgFx @hide
24074 * @cfg {String} validateOnBlur @hide
24083 Roo.namespace('Roo.bootstrap.htmleditor');
24085 * @class Roo.bootstrap.HtmlEditorToolbar1
24091 new Roo.bootstrap.HtmlEditor({
24094 new Roo.bootstrap.HtmlEditorToolbar1({
24095 disable : { fonts: 1 , format: 1, ..., ... , ...],
24101 * @cfg {Object} disable List of elements to disable..
24102 * @cfg {Array} btns List of additional buttons.
24106 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24109 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24112 Roo.apply(this, config);
24114 // default disabled, based on 'good practice'..
24115 this.disable = this.disable || {};
24116 Roo.applyIf(this.disable, {
24119 specialElements : true
24121 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24123 this.editor = config.editor;
24124 this.editorcore = config.editor.editorcore;
24126 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24128 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24129 // dont call parent... till later.
24131 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24136 editorcore : false,
24141 "h1","h2","h3","h4","h5","h6",
24143 "abbr", "acronym", "address", "cite", "samp", "var",
24147 onRender : function(ct, position)
24149 // Roo.log("Call onRender: " + this.xtype);
24151 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24153 this.el.dom.style.marginBottom = '0';
24155 var editorcore = this.editorcore;
24156 var editor= this.editor;
24159 var btn = function(id,cmd , toggle, handler, html){
24161 var event = toggle ? 'toggle' : 'click';
24166 xns: Roo.bootstrap,
24170 enableToggle:toggle !== false,
24172 pressed : toggle ? false : null,
24175 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24176 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24182 // var cb_box = function...
24187 xns: Roo.bootstrap,
24192 xns: Roo.bootstrap,
24196 Roo.each(this.formats, function(f) {
24197 style.menu.items.push({
24199 xns: Roo.bootstrap,
24200 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24205 editorcore.insertTag(this.tagname);
24212 children.push(style);
24214 btn('bold',false,true);
24215 btn('italic',false,true);
24216 btn('align-left', 'justifyleft',true);
24217 btn('align-center', 'justifycenter',true);
24218 btn('align-right' , 'justifyright',true);
24219 btn('link', false, false, function(btn) {
24220 //Roo.log("create link?");
24221 var url = prompt(this.createLinkText, this.defaultLinkValue);
24222 if(url && url != 'http:/'+'/'){
24223 this.editorcore.relayCmd('createlink', url);
24226 btn('list','insertunorderedlist',true);
24227 btn('pencil', false,true, function(btn){
24229 this.toggleSourceEdit(btn.pressed);
24232 if (this.editor.btns.length > 0) {
24233 for (var i = 0; i<this.editor.btns.length; i++) {
24234 children.push(this.editor.btns[i]);
24242 xns: Roo.bootstrap,
24247 xns: Roo.bootstrap,
24252 cog.menu.items.push({
24254 xns: Roo.bootstrap,
24255 html : Clean styles,
24260 editorcore.insertTag(this.tagname);
24269 this.xtype = 'NavSimplebar';
24271 for(var i=0;i< children.length;i++) {
24273 this.buttons.add(this.addxtypeChild(children[i]));
24277 editor.on('editorevent', this.updateToolbar, this);
24279 onBtnClick : function(id)
24281 this.editorcore.relayCmd(id);
24282 this.editorcore.focus();
24286 * Protected method that will not generally be called directly. It triggers
24287 * a toolbar update by reading the markup state of the current selection in the editor.
24289 updateToolbar: function(){
24291 if(!this.editorcore.activated){
24292 this.editor.onFirstFocus(); // is this neeed?
24296 var btns = this.buttons;
24297 var doc = this.editorcore.doc;
24298 btns.get('bold').setActive(doc.queryCommandState('bold'));
24299 btns.get('italic').setActive(doc.queryCommandState('italic'));
24300 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24302 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24303 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24304 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24306 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24307 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24310 var ans = this.editorcore.getAllAncestors();
24311 if (this.formatCombo) {
24314 var store = this.formatCombo.store;
24315 this.formatCombo.setValue("");
24316 for (var i =0; i < ans.length;i++) {
24317 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24319 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24327 // hides menus... - so this cant be on a menu...
24328 Roo.bootstrap.MenuMgr.hideAll();
24330 Roo.bootstrap.MenuMgr.hideAll();
24331 //this.editorsyncValue();
24333 onFirstFocus: function() {
24334 this.buttons.each(function(item){
24338 toggleSourceEdit : function(sourceEditMode){
24341 if(sourceEditMode){
24342 Roo.log("disabling buttons");
24343 this.buttons.each( function(item){
24344 if(item.cmd != 'pencil'){
24350 Roo.log("enabling buttons");
24351 if(this.editorcore.initialized){
24352 this.buttons.each( function(item){
24358 Roo.log("calling toggole on editor");
24359 // tell the editor that it's been pressed..
24360 this.editor.toggleSourceEdit(sourceEditMode);
24370 * @class Roo.bootstrap.Table.AbstractSelectionModel
24371 * @extends Roo.util.Observable
24372 * Abstract base class for grid SelectionModels. It provides the interface that should be
24373 * implemented by descendant classes. This class should not be directly instantiated.
24376 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24377 this.locked = false;
24378 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24382 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24383 /** @ignore Called by the grid automatically. Do not call directly. */
24384 init : function(grid){
24390 * Locks the selections.
24393 this.locked = true;
24397 * Unlocks the selections.
24399 unlock : function(){
24400 this.locked = false;
24404 * Returns true if the selections are locked.
24405 * @return {Boolean}
24407 isLocked : function(){
24408 return this.locked;
24412 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24413 * @class Roo.bootstrap.Table.RowSelectionModel
24414 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24415 * It supports multiple selections and keyboard selection/navigation.
24417 * @param {Object} config
24420 Roo.bootstrap.Table.RowSelectionModel = function(config){
24421 Roo.apply(this, config);
24422 this.selections = new Roo.util.MixedCollection(false, function(o){
24427 this.lastActive = false;
24431 * @event selectionchange
24432 * Fires when the selection changes
24433 * @param {SelectionModel} this
24435 "selectionchange" : true,
24437 * @event afterselectionchange
24438 * Fires after the selection changes (eg. by key press or clicking)
24439 * @param {SelectionModel} this
24441 "afterselectionchange" : true,
24443 * @event beforerowselect
24444 * Fires when a row is selected being selected, return false to cancel.
24445 * @param {SelectionModel} this
24446 * @param {Number} rowIndex The selected index
24447 * @param {Boolean} keepExisting False if other selections will be cleared
24449 "beforerowselect" : true,
24452 * Fires when a row is selected.
24453 * @param {SelectionModel} this
24454 * @param {Number} rowIndex The selected index
24455 * @param {Roo.data.Record} r The record
24457 "rowselect" : true,
24459 * @event rowdeselect
24460 * Fires when a row is deselected.
24461 * @param {SelectionModel} this
24462 * @param {Number} rowIndex The selected index
24464 "rowdeselect" : true
24466 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24467 this.locked = false;
24470 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24472 * @cfg {Boolean} singleSelect
24473 * True to allow selection of only one row at a time (defaults to false)
24475 singleSelect : false,
24478 initEvents : function()
24481 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24482 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24483 //}else{ // allow click to work like normal
24484 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24486 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24487 this.grid.on("rowclick", this.handleMouseDown, this);
24489 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24490 "up" : function(e){
24492 this.selectPrevious(e.shiftKey);
24493 }else if(this.last !== false && this.lastActive !== false){
24494 var last = this.last;
24495 this.selectRange(this.last, this.lastActive-1);
24496 this.grid.getView().focusRow(this.lastActive);
24497 if(last !== false){
24501 this.selectFirstRow();
24503 this.fireEvent("afterselectionchange", this);
24505 "down" : function(e){
24507 this.selectNext(e.shiftKey);
24508 }else if(this.last !== false && this.lastActive !== false){
24509 var last = this.last;
24510 this.selectRange(this.last, this.lastActive+1);
24511 this.grid.getView().focusRow(this.lastActive);
24512 if(last !== false){
24516 this.selectFirstRow();
24518 this.fireEvent("afterselectionchange", this);
24522 this.grid.store.on('load', function(){
24523 this.selections.clear();
24526 var view = this.grid.view;
24527 view.on("refresh", this.onRefresh, this);
24528 view.on("rowupdated", this.onRowUpdated, this);
24529 view.on("rowremoved", this.onRemove, this);
24534 onRefresh : function()
24536 var ds = this.grid.store, i, v = this.grid.view;
24537 var s = this.selections;
24538 s.each(function(r){
24539 if((i = ds.indexOfId(r.id)) != -1){
24548 onRemove : function(v, index, r){
24549 this.selections.remove(r);
24553 onRowUpdated : function(v, index, r){
24554 if(this.isSelected(r)){
24555 v.onRowSelect(index);
24561 * @param {Array} records The records to select
24562 * @param {Boolean} keepExisting (optional) True to keep existing selections
24564 selectRecords : function(records, keepExisting)
24567 this.clearSelections();
24569 var ds = this.grid.store;
24570 for(var i = 0, len = records.length; i < len; i++){
24571 this.selectRow(ds.indexOf(records[i]), true);
24576 * Gets the number of selected rows.
24579 getCount : function(){
24580 return this.selections.length;
24584 * Selects the first row in the grid.
24586 selectFirstRow : function(){
24591 * Select the last row.
24592 * @param {Boolean} keepExisting (optional) True to keep existing selections
24594 selectLastRow : function(keepExisting){
24595 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24596 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24600 * Selects the row immediately following the last selected row.
24601 * @param {Boolean} keepExisting (optional) True to keep existing selections
24603 selectNext : function(keepExisting)
24605 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24606 this.selectRow(this.last+1, keepExisting);
24607 this.grid.getView().focusRow(this.last);
24612 * Selects the row that precedes the last selected row.
24613 * @param {Boolean} keepExisting (optional) True to keep existing selections
24615 selectPrevious : function(keepExisting){
24617 this.selectRow(this.last-1, keepExisting);
24618 this.grid.getView().focusRow(this.last);
24623 * Returns the selected records
24624 * @return {Array} Array of selected records
24626 getSelections : function(){
24627 return [].concat(this.selections.items);
24631 * Returns the first selected record.
24634 getSelected : function(){
24635 return this.selections.itemAt(0);
24640 * Clears all selections.
24642 clearSelections : function(fast)
24648 var ds = this.grid.store;
24649 var s = this.selections;
24650 s.each(function(r){
24651 this.deselectRow(ds.indexOfId(r.id));
24655 this.selections.clear();
24662 * Selects all rows.
24664 selectAll : function(){
24668 this.selections.clear();
24669 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24670 this.selectRow(i, true);
24675 * Returns True if there is a selection.
24676 * @return {Boolean}
24678 hasSelection : function(){
24679 return this.selections.length > 0;
24683 * Returns True if the specified row is selected.
24684 * @param {Number/Record} record The record or index of the record to check
24685 * @return {Boolean}
24687 isSelected : function(index){
24688 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24689 return (r && this.selections.key(r.id) ? true : false);
24693 * Returns True if the specified record id is selected.
24694 * @param {String} id The id of record to check
24695 * @return {Boolean}
24697 isIdSelected : function(id){
24698 return (this.selections.key(id) ? true : false);
24703 handleMouseDBClick : function(e, t){
24707 handleMouseDown : function(e, t)
24709 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24710 if(this.isLocked() || rowIndex < 0 ){
24713 if(e.shiftKey && this.last !== false){
24714 var last = this.last;
24715 this.selectRange(last, rowIndex, e.ctrlKey);
24716 this.last = last; // reset the last
24720 var isSelected = this.isSelected(rowIndex);
24721 //Roo.log("select row:" + rowIndex);
24723 this.deselectRow(rowIndex);
24725 this.selectRow(rowIndex, true);
24729 if(e.button !== 0 && isSelected){
24730 alert('rowIndex 2: ' + rowIndex);
24731 view.focusRow(rowIndex);
24732 }else if(e.ctrlKey && isSelected){
24733 this.deselectRow(rowIndex);
24734 }else if(!isSelected){
24735 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24736 view.focusRow(rowIndex);
24740 this.fireEvent("afterselectionchange", this);
24743 handleDragableRowClick : function(grid, rowIndex, e)
24745 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24746 this.selectRow(rowIndex, false);
24747 grid.view.focusRow(rowIndex);
24748 this.fireEvent("afterselectionchange", this);
24753 * Selects multiple rows.
24754 * @param {Array} rows Array of the indexes of the row to select
24755 * @param {Boolean} keepExisting (optional) True to keep existing selections
24757 selectRows : function(rows, keepExisting){
24759 this.clearSelections();
24761 for(var i = 0, len = rows.length; i < len; i++){
24762 this.selectRow(rows[i], true);
24767 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24768 * @param {Number} startRow The index of the first row in the range
24769 * @param {Number} endRow The index of the last row in the range
24770 * @param {Boolean} keepExisting (optional) True to retain existing selections
24772 selectRange : function(startRow, endRow, keepExisting){
24777 this.clearSelections();
24779 if(startRow <= endRow){
24780 for(var i = startRow; i <= endRow; i++){
24781 this.selectRow(i, true);
24784 for(var i = startRow; i >= endRow; i--){
24785 this.selectRow(i, true);
24791 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24792 * @param {Number} startRow The index of the first row in the range
24793 * @param {Number} endRow The index of the last row in the range
24795 deselectRange : function(startRow, endRow, preventViewNotify){
24799 for(var i = startRow; i <= endRow; i++){
24800 this.deselectRow(i, preventViewNotify);
24806 * @param {Number} row The index of the row to select
24807 * @param {Boolean} keepExisting (optional) True to keep existing selections
24809 selectRow : function(index, keepExisting, preventViewNotify)
24811 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24814 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24815 if(!keepExisting || this.singleSelect){
24816 this.clearSelections();
24819 var r = this.grid.store.getAt(index);
24820 //console.log('selectRow - record id :' + r.id);
24822 this.selections.add(r);
24823 this.last = this.lastActive = index;
24824 if(!preventViewNotify){
24825 var proxy = new Roo.Element(
24826 this.grid.getRowDom(index)
24828 proxy.addClass('bg-info info');
24830 this.fireEvent("rowselect", this, index, r);
24831 this.fireEvent("selectionchange", this);
24837 * @param {Number} row The index of the row to deselect
24839 deselectRow : function(index, preventViewNotify)
24844 if(this.last == index){
24847 if(this.lastActive == index){
24848 this.lastActive = false;
24851 var r = this.grid.store.getAt(index);
24856 this.selections.remove(r);
24857 //.console.log('deselectRow - record id :' + r.id);
24858 if(!preventViewNotify){
24860 var proxy = new Roo.Element(
24861 this.grid.getRowDom(index)
24863 proxy.removeClass('bg-info info');
24865 this.fireEvent("rowdeselect", this, index);
24866 this.fireEvent("selectionchange", this);
24870 restoreLast : function(){
24872 this.last = this._last;
24877 acceptsNav : function(row, col, cm){
24878 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24882 onEditorKey : function(field, e){
24883 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24888 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24890 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24892 }else if(k == e.ENTER && !e.ctrlKey){
24896 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24898 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24900 }else if(k == e.ESC){
24904 g.startEditing(newCell[0], newCell[1]);
24910 * Ext JS Library 1.1.1
24911 * Copyright(c) 2006-2007, Ext JS, LLC.
24913 * Originally Released Under LGPL - original licence link has changed is not relivant.
24916 * <script type="text/javascript">
24920 * @class Roo.bootstrap.PagingToolbar
24921 * @extends Roo.bootstrap.NavSimplebar
24922 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24924 * Create a new PagingToolbar
24925 * @param {Object} config The config object
24926 * @param {Roo.data.Store} store
24928 Roo.bootstrap.PagingToolbar = function(config)
24930 // old args format still supported... - xtype is prefered..
24931 // created from xtype...
24933 this.ds = config.dataSource;
24935 if (config.store && !this.ds) {
24936 this.store= Roo.factory(config.store, Roo.data);
24937 this.ds = this.store;
24938 this.ds.xmodule = this.xmodule || false;
24941 this.toolbarItems = [];
24942 if (config.items) {
24943 this.toolbarItems = config.items;
24946 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24951 this.bind(this.ds);
24954 if (Roo.bootstrap.version == 4) {
24955 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24957 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24962 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24964 * @cfg {Roo.data.Store} dataSource
24965 * The underlying data store providing the paged data
24968 * @cfg {String/HTMLElement/Element} container
24969 * container The id or element that will contain the toolbar
24972 * @cfg {Boolean} displayInfo
24973 * True to display the displayMsg (defaults to false)
24976 * @cfg {Number} pageSize
24977 * The number of records to display per page (defaults to 20)
24981 * @cfg {String} displayMsg
24982 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24984 displayMsg : 'Displaying {0} - {1} of {2}',
24986 * @cfg {String} emptyMsg
24987 * The message to display when no records are found (defaults to "No data to display")
24989 emptyMsg : 'No data to display',
24991 * Customizable piece of the default paging text (defaults to "Page")
24994 beforePageText : "Page",
24996 * Customizable piece of the default paging text (defaults to "of %0")
24999 afterPageText : "of {0}",
25001 * Customizable piece of the default paging text (defaults to "First Page")
25004 firstText : "First Page",
25006 * Customizable piece of the default paging text (defaults to "Previous Page")
25009 prevText : "Previous Page",
25011 * Customizable piece of the default paging text (defaults to "Next Page")
25014 nextText : "Next Page",
25016 * Customizable piece of the default paging text (defaults to "Last Page")
25019 lastText : "Last Page",
25021 * Customizable piece of the default paging text (defaults to "Refresh")
25024 refreshText : "Refresh",
25028 onRender : function(ct, position)
25030 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
25031 this.navgroup.parentId = this.id;
25032 this.navgroup.onRender(this.el, null);
25033 // add the buttons to the navgroup
25035 if(this.displayInfo){
25036 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25037 this.displayEl = this.el.select('.x-paging-info', true).first();
25038 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25039 // this.displayEl = navel.el.select('span',true).first();
25045 Roo.each(_this.buttons, function(e){ // this might need to use render????
25046 Roo.factory(e).render(_this.el);
25050 Roo.each(_this.toolbarItems, function(e) {
25051 _this.navgroup.addItem(e);
25055 this.first = this.navgroup.addItem({
25056 tooltip: this.firstText,
25057 cls: "prev btn-outline-secondary",
25058 html : ' <i class="fa fa-step-backward"></i>',
25060 preventDefault: true,
25061 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25064 this.prev = this.navgroup.addItem({
25065 tooltip: this.prevText,
25066 cls: "prev btn-outline-secondary",
25067 html : ' <i class="fa fa-backward"></i>',
25069 preventDefault: true,
25070 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25072 //this.addSeparator();
25075 var field = this.navgroup.addItem( {
25077 cls : 'x-paging-position btn-outline-secondary',
25079 html : this.beforePageText +
25080 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25081 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25084 this.field = field.el.select('input', true).first();
25085 this.field.on("keydown", this.onPagingKeydown, this);
25086 this.field.on("focus", function(){this.dom.select();});
25089 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25090 //this.field.setHeight(18);
25091 //this.addSeparator();
25092 this.next = this.navgroup.addItem({
25093 tooltip: this.nextText,
25094 cls: "next btn-outline-secondary",
25095 html : ' <i class="fa fa-forward"></i>',
25097 preventDefault: true,
25098 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25100 this.last = this.navgroup.addItem({
25101 tooltip: this.lastText,
25102 html : ' <i class="fa fa-step-forward"></i>',
25103 cls: "next btn-outline-secondary",
25105 preventDefault: true,
25106 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25108 //this.addSeparator();
25109 this.loading = this.navgroup.addItem({
25110 tooltip: this.refreshText,
25111 cls: "btn-outline-secondary",
25112 html : ' <i class="fa fa-refresh"></i>',
25113 preventDefault: true,
25114 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25120 updateInfo : function(){
25121 if(this.displayEl){
25122 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25123 var msg = count == 0 ?
25127 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25129 this.displayEl.update(msg);
25134 onLoad : function(ds, r, o)
25136 this.cursor = o.params.start ? o.params.start : 0;
25138 var d = this.getPageData(),
25143 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25144 this.field.dom.value = ap;
25145 this.first.setDisabled(ap == 1);
25146 this.prev.setDisabled(ap == 1);
25147 this.next.setDisabled(ap == ps);
25148 this.last.setDisabled(ap == ps);
25149 this.loading.enable();
25154 getPageData : function(){
25155 var total = this.ds.getTotalCount();
25158 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25159 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25164 onLoadError : function(){
25165 this.loading.enable();
25169 onPagingKeydown : function(e){
25170 var k = e.getKey();
25171 var d = this.getPageData();
25173 var v = this.field.dom.value, pageNum;
25174 if(!v || isNaN(pageNum = parseInt(v, 10))){
25175 this.field.dom.value = d.activePage;
25178 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25179 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25182 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))
25184 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25185 this.field.dom.value = pageNum;
25186 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25189 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25191 var v = this.field.dom.value, pageNum;
25192 var increment = (e.shiftKey) ? 10 : 1;
25193 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25196 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25197 this.field.dom.value = d.activePage;
25200 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25202 this.field.dom.value = parseInt(v, 10) + increment;
25203 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25204 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25211 beforeLoad : function(){
25213 this.loading.disable();
25218 onClick : function(which){
25227 ds.load({params:{start: 0, limit: this.pageSize}});
25230 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25233 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25236 var total = ds.getTotalCount();
25237 var extra = total % this.pageSize;
25238 var lastStart = extra ? (total - extra) : total-this.pageSize;
25239 ds.load({params:{start: lastStart, limit: this.pageSize}});
25242 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25248 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25249 * @param {Roo.data.Store} store The data store to unbind
25251 unbind : function(ds){
25252 ds.un("beforeload", this.beforeLoad, this);
25253 ds.un("load", this.onLoad, this);
25254 ds.un("loadexception", this.onLoadError, this);
25255 ds.un("remove", this.updateInfo, this);
25256 ds.un("add", this.updateInfo, this);
25257 this.ds = undefined;
25261 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25262 * @param {Roo.data.Store} store The data store to bind
25264 bind : function(ds){
25265 ds.on("beforeload", this.beforeLoad, this);
25266 ds.on("load", this.onLoad, this);
25267 ds.on("loadexception", this.onLoadError, this);
25268 ds.on("remove", this.updateInfo, this);
25269 ds.on("add", this.updateInfo, this);
25280 * @class Roo.bootstrap.MessageBar
25281 * @extends Roo.bootstrap.Component
25282 * Bootstrap MessageBar class
25283 * @cfg {String} html contents of the MessageBar
25284 * @cfg {String} weight (info | success | warning | danger) default info
25285 * @cfg {String} beforeClass insert the bar before the given class
25286 * @cfg {Boolean} closable (true | false) default false
25287 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25290 * Create a new Element
25291 * @param {Object} config The config object
25294 Roo.bootstrap.MessageBar = function(config){
25295 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25298 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25304 beforeClass: 'bootstrap-sticky-wrap',
25306 getAutoCreate : function(){
25310 cls: 'alert alert-dismissable alert-' + this.weight,
25315 html: this.html || ''
25321 cfg.cls += ' alert-messages-fixed';
25335 onRender : function(ct, position)
25337 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25340 var cfg = Roo.apply({}, this.getAutoCreate());
25344 cfg.cls += ' ' + this.cls;
25347 cfg.style = this.style;
25349 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25351 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25354 this.el.select('>button.close').on('click', this.hide, this);
25360 if (!this.rendered) {
25366 this.fireEvent('show', this);
25372 if (!this.rendered) {
25378 this.fireEvent('hide', this);
25381 update : function()
25383 // var e = this.el.dom.firstChild;
25385 // if(this.closable){
25386 // e = e.nextSibling;
25389 // e.data = this.html || '';
25391 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25407 * @class Roo.bootstrap.Graph
25408 * @extends Roo.bootstrap.Component
25409 * Bootstrap Graph class
25413 @cfg {String} graphtype bar | vbar | pie
25414 @cfg {number} g_x coodinator | centre x (pie)
25415 @cfg {number} g_y coodinator | centre y (pie)
25416 @cfg {number} g_r radius (pie)
25417 @cfg {number} g_height height of the chart (respected by all elements in the set)
25418 @cfg {number} g_width width of the chart (respected by all elements in the set)
25419 @cfg {Object} title The title of the chart
25422 -opts (object) options for the chart
25424 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25425 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25427 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.
25428 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25430 o stretch (boolean)
25432 -opts (object) options for the pie
25435 o startAngle (number)
25436 o endAngle (number)
25440 * Create a new Input
25441 * @param {Object} config The config object
25444 Roo.bootstrap.Graph = function(config){
25445 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25451 * The img click event for the img.
25452 * @param {Roo.EventObject} e
25458 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25469 //g_colors: this.colors,
25476 getAutoCreate : function(){
25487 onRender : function(ct,position){
25490 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25492 if (typeof(Raphael) == 'undefined') {
25493 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25497 this.raphael = Raphael(this.el.dom);
25499 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25500 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25501 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25502 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25504 r.text(160, 10, "Single Series Chart").attr(txtattr);
25505 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25506 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25507 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25509 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25510 r.barchart(330, 10, 300, 220, data1);
25511 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25512 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25515 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25516 // r.barchart(30, 30, 560, 250, xdata, {
25517 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25518 // axis : "0 0 1 1",
25519 // axisxlabels : xdata
25520 // //yvalues : cols,
25523 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25525 // this.load(null,xdata,{
25526 // axis : "0 0 1 1",
25527 // axisxlabels : xdata
25532 load : function(graphtype,xdata,opts)
25534 this.raphael.clear();
25536 graphtype = this.graphtype;
25541 var r = this.raphael,
25542 fin = function () {
25543 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25545 fout = function () {
25546 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25548 pfin = function() {
25549 this.sector.stop();
25550 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25553 this.label[0].stop();
25554 this.label[0].attr({ r: 7.5 });
25555 this.label[1].attr({ "font-weight": 800 });
25558 pfout = function() {
25559 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25562 this.label[0].animate({ r: 5 }, 500, "bounce");
25563 this.label[1].attr({ "font-weight": 400 });
25569 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25572 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25575 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25576 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25578 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25585 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25590 setTitle: function(o)
25595 initEvents: function() {
25598 this.el.on('click', this.onClick, this);
25602 onClick : function(e)
25604 Roo.log('img onclick');
25605 this.fireEvent('click', this, e);
25617 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25620 * @class Roo.bootstrap.dash.NumberBox
25621 * @extends Roo.bootstrap.Component
25622 * Bootstrap NumberBox class
25623 * @cfg {String} headline Box headline
25624 * @cfg {String} content Box content
25625 * @cfg {String} icon Box icon
25626 * @cfg {String} footer Footer text
25627 * @cfg {String} fhref Footer href
25630 * Create a new NumberBox
25631 * @param {Object} config The config object
25635 Roo.bootstrap.dash.NumberBox = function(config){
25636 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25640 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25649 getAutoCreate : function(){
25653 cls : 'small-box ',
25661 cls : 'roo-headline',
25662 html : this.headline
25666 cls : 'roo-content',
25667 html : this.content
25681 cls : 'ion ' + this.icon
25690 cls : 'small-box-footer',
25691 href : this.fhref || '#',
25695 cfg.cn.push(footer);
25702 onRender : function(ct,position){
25703 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25710 setHeadline: function (value)
25712 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25715 setFooter: function (value, href)
25717 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25720 this.el.select('a.small-box-footer',true).first().attr('href', href);
25725 setContent: function (value)
25727 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25730 initEvents: function()
25744 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25747 * @class Roo.bootstrap.dash.TabBox
25748 * @extends Roo.bootstrap.Component
25749 * Bootstrap TabBox class
25750 * @cfg {String} title Title of the TabBox
25751 * @cfg {String} icon Icon of the TabBox
25752 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25753 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25756 * Create a new TabBox
25757 * @param {Object} config The config object
25761 Roo.bootstrap.dash.TabBox = function(config){
25762 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25767 * When a pane is added
25768 * @param {Roo.bootstrap.dash.TabPane} pane
25772 * @event activatepane
25773 * When a pane is activated
25774 * @param {Roo.bootstrap.dash.TabPane} pane
25776 "activatepane" : true
25784 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25789 tabScrollable : false,
25791 getChildContainer : function()
25793 return this.el.select('.tab-content', true).first();
25796 getAutoCreate : function(){
25800 cls: 'pull-left header',
25808 cls: 'fa ' + this.icon
25814 cls: 'nav nav-tabs pull-right',
25820 if(this.tabScrollable){
25827 cls: 'nav nav-tabs pull-right',
25838 cls: 'nav-tabs-custom',
25843 cls: 'tab-content no-padding',
25851 initEvents : function()
25853 //Roo.log('add add pane handler');
25854 this.on('addpane', this.onAddPane, this);
25857 * Updates the box title
25858 * @param {String} html to set the title to.
25860 setTitle : function(value)
25862 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25864 onAddPane : function(pane)
25866 this.panes.push(pane);
25867 //Roo.log('addpane');
25869 // tabs are rendere left to right..
25870 if(!this.showtabs){
25874 var ctr = this.el.select('.nav-tabs', true).first();
25877 var existing = ctr.select('.nav-tab',true);
25878 var qty = existing.getCount();;
25881 var tab = ctr.createChild({
25883 cls : 'nav-tab' + (qty ? '' : ' active'),
25891 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25894 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25896 pane.el.addClass('active');
25901 onTabClick : function(ev,un,ob,pane)
25903 //Roo.log('tab - prev default');
25904 ev.preventDefault();
25907 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25908 pane.tab.addClass('active');
25909 //Roo.log(pane.title);
25910 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25911 // technically we should have a deactivate event.. but maybe add later.
25912 // and it should not de-activate the selected tab...
25913 this.fireEvent('activatepane', pane);
25914 pane.el.addClass('active');
25915 pane.fireEvent('activate');
25920 getActivePane : function()
25923 Roo.each(this.panes, function(p) {
25924 if(p.el.hasClass('active')){
25945 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25947 * @class Roo.bootstrap.TabPane
25948 * @extends Roo.bootstrap.Component
25949 * Bootstrap TabPane class
25950 * @cfg {Boolean} active (false | true) Default false
25951 * @cfg {String} title title of panel
25955 * Create a new TabPane
25956 * @param {Object} config The config object
25959 Roo.bootstrap.dash.TabPane = function(config){
25960 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25966 * When a pane is activated
25967 * @param {Roo.bootstrap.dash.TabPane} pane
25974 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25979 // the tabBox that this is attached to.
25982 getAutoCreate : function()
25990 cfg.cls += ' active';
25995 initEvents : function()
25997 //Roo.log('trigger add pane handler');
25998 this.parent().fireEvent('addpane', this)
26002 * Updates the tab title
26003 * @param {String} html to set the title to.
26005 setTitle: function(str)
26011 this.tab.select('a', true).first().dom.innerHTML = str;
26028 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26031 * @class Roo.bootstrap.menu.Menu
26032 * @extends Roo.bootstrap.Component
26033 * Bootstrap Menu class - container for Menu
26034 * @cfg {String} html Text of the menu
26035 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26036 * @cfg {String} icon Font awesome icon
26037 * @cfg {String} pos Menu align to (top | bottom) default bottom
26041 * Create a new Menu
26042 * @param {Object} config The config object
26046 Roo.bootstrap.menu.Menu = function(config){
26047 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26051 * @event beforeshow
26052 * Fires before this menu is displayed
26053 * @param {Roo.bootstrap.menu.Menu} this
26057 * @event beforehide
26058 * Fires before this menu is hidden
26059 * @param {Roo.bootstrap.menu.Menu} this
26064 * Fires after this menu is displayed
26065 * @param {Roo.bootstrap.menu.Menu} this
26070 * Fires after this menu is hidden
26071 * @param {Roo.bootstrap.menu.Menu} this
26076 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26077 * @param {Roo.bootstrap.menu.Menu} this
26078 * @param {Roo.EventObject} e
26085 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26089 weight : 'default',
26094 getChildContainer : function() {
26095 if(this.isSubMenu){
26099 return this.el.select('ul.dropdown-menu', true).first();
26102 getAutoCreate : function()
26107 cls : 'roo-menu-text',
26115 cls : 'fa ' + this.icon
26126 cls : 'dropdown-button btn btn-' + this.weight,
26131 cls : 'dropdown-toggle btn btn-' + this.weight,
26141 cls : 'dropdown-menu'
26147 if(this.pos == 'top'){
26148 cfg.cls += ' dropup';
26151 if(this.isSubMenu){
26154 cls : 'dropdown-menu'
26161 onRender : function(ct, position)
26163 this.isSubMenu = ct.hasClass('dropdown-submenu');
26165 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26168 initEvents : function()
26170 if(this.isSubMenu){
26174 this.hidden = true;
26176 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26177 this.triggerEl.on('click', this.onTriggerPress, this);
26179 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26180 this.buttonEl.on('click', this.onClick, this);
26186 if(this.isSubMenu){
26190 return this.el.select('ul.dropdown-menu', true).first();
26193 onClick : function(e)
26195 this.fireEvent("click", this, e);
26198 onTriggerPress : function(e)
26200 if (this.isVisible()) {
26207 isVisible : function(){
26208 return !this.hidden;
26213 this.fireEvent("beforeshow", this);
26215 this.hidden = false;
26216 this.el.addClass('open');
26218 Roo.get(document).on("mouseup", this.onMouseUp, this);
26220 this.fireEvent("show", this);
26227 this.fireEvent("beforehide", this);
26229 this.hidden = true;
26230 this.el.removeClass('open');
26232 Roo.get(document).un("mouseup", this.onMouseUp);
26234 this.fireEvent("hide", this);
26237 onMouseUp : function()
26251 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26254 * @class Roo.bootstrap.menu.Item
26255 * @extends Roo.bootstrap.Component
26256 * Bootstrap MenuItem class
26257 * @cfg {Boolean} submenu (true | false) default false
26258 * @cfg {String} html text of the item
26259 * @cfg {String} href the link
26260 * @cfg {Boolean} disable (true | false) default false
26261 * @cfg {Boolean} preventDefault (true | false) default true
26262 * @cfg {String} icon Font awesome icon
26263 * @cfg {String} pos Submenu align to (left | right) default right
26267 * Create a new Item
26268 * @param {Object} config The config object
26272 Roo.bootstrap.menu.Item = function(config){
26273 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26277 * Fires when the mouse is hovering over this menu
26278 * @param {Roo.bootstrap.menu.Item} this
26279 * @param {Roo.EventObject} e
26284 * Fires when the mouse exits this menu
26285 * @param {Roo.bootstrap.menu.Item} this
26286 * @param {Roo.EventObject} e
26292 * The raw click event for the entire grid.
26293 * @param {Roo.EventObject} e
26299 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26304 preventDefault: true,
26309 getAutoCreate : function()
26314 cls : 'roo-menu-item-text',
26322 cls : 'fa ' + this.icon
26331 href : this.href || '#',
26338 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26342 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26344 if(this.pos == 'left'){
26345 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26352 initEvents : function()
26354 this.el.on('mouseover', this.onMouseOver, this);
26355 this.el.on('mouseout', this.onMouseOut, this);
26357 this.el.select('a', true).first().on('click', this.onClick, this);
26361 onClick : function(e)
26363 if(this.preventDefault){
26364 e.preventDefault();
26367 this.fireEvent("click", this, e);
26370 onMouseOver : function(e)
26372 if(this.submenu && this.pos == 'left'){
26373 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26376 this.fireEvent("mouseover", this, e);
26379 onMouseOut : function(e)
26381 this.fireEvent("mouseout", this, e);
26393 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26396 * @class Roo.bootstrap.menu.Separator
26397 * @extends Roo.bootstrap.Component
26398 * Bootstrap Separator class
26401 * Create a new Separator
26402 * @param {Object} config The config object
26406 Roo.bootstrap.menu.Separator = function(config){
26407 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26410 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26412 getAutoCreate : function(){
26433 * @class Roo.bootstrap.Tooltip
26434 * Bootstrap Tooltip class
26435 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26436 * to determine which dom element triggers the tooltip.
26438 * It needs to add support for additional attributes like tooltip-position
26441 * Create a new Toolti
26442 * @param {Object} config The config object
26445 Roo.bootstrap.Tooltip = function(config){
26446 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26448 this.alignment = Roo.bootstrap.Tooltip.alignment;
26450 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26451 this.alignment = config.alignment;
26456 Roo.apply(Roo.bootstrap.Tooltip, {
26458 * @function init initialize tooltip monitoring.
26462 currentTip : false,
26463 currentRegion : false,
26469 Roo.get(document).on('mouseover', this.enter ,this);
26470 Roo.get(document).on('mouseout', this.leave, this);
26473 this.currentTip = new Roo.bootstrap.Tooltip();
26476 enter : function(ev)
26478 var dom = ev.getTarget();
26480 //Roo.log(['enter',dom]);
26481 var el = Roo.fly(dom);
26482 if (this.currentEl) {
26484 //Roo.log(this.currentEl);
26485 //Roo.log(this.currentEl.contains(dom));
26486 if (this.currentEl == el) {
26489 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26495 if (this.currentTip.el) {
26496 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26500 if(!el || el.dom == document){
26506 // you can not look for children, as if el is the body.. then everythign is the child..
26507 if (!el.attr('tooltip')) { //
26508 if (!el.select("[tooltip]").elements.length) {
26511 // is the mouse over this child...?
26512 bindEl = el.select("[tooltip]").first();
26513 var xy = ev.getXY();
26514 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26515 //Roo.log("not in region.");
26518 //Roo.log("child element over..");
26521 this.currentEl = bindEl;
26522 this.currentTip.bind(bindEl);
26523 this.currentRegion = Roo.lib.Region.getRegion(dom);
26524 this.currentTip.enter();
26527 leave : function(ev)
26529 var dom = ev.getTarget();
26530 //Roo.log(['leave',dom]);
26531 if (!this.currentEl) {
26536 if (dom != this.currentEl.dom) {
26539 var xy = ev.getXY();
26540 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26543 // only activate leave if mouse cursor is outside... bounding box..
26548 if (this.currentTip) {
26549 this.currentTip.leave();
26551 //Roo.log('clear currentEl');
26552 this.currentEl = false;
26557 'left' : ['r-l', [-2,0], 'right'],
26558 'right' : ['l-r', [2,0], 'left'],
26559 'bottom' : ['t-b', [0,2], 'top'],
26560 'top' : [ 'b-t', [0,-2], 'bottom']
26566 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26571 delay : null, // can be { show : 300 , hide: 500}
26575 hoverState : null, //???
26577 placement : 'bottom',
26581 getAutoCreate : function(){
26588 cls : 'tooltip-arrow'
26591 cls : 'tooltip-inner'
26598 bind : function(el)
26604 enter : function () {
26606 if (this.timeout != null) {
26607 clearTimeout(this.timeout);
26610 this.hoverState = 'in';
26611 //Roo.log("enter - show");
26612 if (!this.delay || !this.delay.show) {
26617 this.timeout = setTimeout(function () {
26618 if (_t.hoverState == 'in') {
26621 }, this.delay.show);
26625 clearTimeout(this.timeout);
26627 this.hoverState = 'out';
26628 if (!this.delay || !this.delay.hide) {
26634 this.timeout = setTimeout(function () {
26635 //Roo.log("leave - timeout");
26637 if (_t.hoverState == 'out') {
26639 Roo.bootstrap.Tooltip.currentEl = false;
26644 show : function (msg)
26647 this.render(document.body);
26650 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26652 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26654 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26656 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26658 var placement = typeof this.placement == 'function' ?
26659 this.placement.call(this, this.el, on_el) :
26662 var autoToken = /\s?auto?\s?/i;
26663 var autoPlace = autoToken.test(placement);
26665 placement = placement.replace(autoToken, '') || 'top';
26669 //this.el.setXY([0,0]);
26671 //this.el.dom.style.display='block';
26673 //this.el.appendTo(on_el);
26675 var p = this.getPosition();
26676 var box = this.el.getBox();
26682 var align = this.alignment[placement];
26684 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26686 if(placement == 'top' || placement == 'bottom'){
26688 placement = 'right';
26691 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26692 placement = 'left';
26695 var scroll = Roo.select('body', true).first().getScroll();
26697 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26701 align = this.alignment[placement];
26704 this.el.alignTo(this.bindEl, align[0],align[1]);
26705 //var arrow = this.el.select('.arrow',true).first();
26706 //arrow.set(align[2],
26708 this.el.addClass(placement);
26710 this.el.addClass('in fade');
26712 this.hoverState = null;
26714 if (this.el.hasClass('fade')) {
26725 //this.el.setXY([0,0]);
26726 this.el.removeClass('in');
26742 * @class Roo.bootstrap.LocationPicker
26743 * @extends Roo.bootstrap.Component
26744 * Bootstrap LocationPicker class
26745 * @cfg {Number} latitude Position when init default 0
26746 * @cfg {Number} longitude Position when init default 0
26747 * @cfg {Number} zoom default 15
26748 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26749 * @cfg {Boolean} mapTypeControl default false
26750 * @cfg {Boolean} disableDoubleClickZoom default false
26751 * @cfg {Boolean} scrollwheel default true
26752 * @cfg {Boolean} streetViewControl default false
26753 * @cfg {Number} radius default 0
26754 * @cfg {String} locationName
26755 * @cfg {Boolean} draggable default true
26756 * @cfg {Boolean} enableAutocomplete default false
26757 * @cfg {Boolean} enableReverseGeocode default true
26758 * @cfg {String} markerTitle
26761 * Create a new LocationPicker
26762 * @param {Object} config The config object
26766 Roo.bootstrap.LocationPicker = function(config){
26768 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26773 * Fires when the picker initialized.
26774 * @param {Roo.bootstrap.LocationPicker} this
26775 * @param {Google Location} location
26779 * @event positionchanged
26780 * Fires when the picker position changed.
26781 * @param {Roo.bootstrap.LocationPicker} this
26782 * @param {Google Location} location
26784 positionchanged : true,
26787 * Fires when the map resize.
26788 * @param {Roo.bootstrap.LocationPicker} this
26793 * Fires when the map show.
26794 * @param {Roo.bootstrap.LocationPicker} this
26799 * Fires when the map hide.
26800 * @param {Roo.bootstrap.LocationPicker} this
26805 * Fires when click the map.
26806 * @param {Roo.bootstrap.LocationPicker} this
26807 * @param {Map event} e
26811 * @event mapRightClick
26812 * Fires when right click the map.
26813 * @param {Roo.bootstrap.LocationPicker} this
26814 * @param {Map event} e
26816 mapRightClick : true,
26818 * @event markerClick
26819 * Fires when click the marker.
26820 * @param {Roo.bootstrap.LocationPicker} this
26821 * @param {Map event} e
26823 markerClick : true,
26825 * @event markerRightClick
26826 * Fires when right click the marker.
26827 * @param {Roo.bootstrap.LocationPicker} this
26828 * @param {Map event} e
26830 markerRightClick : true,
26832 * @event OverlayViewDraw
26833 * Fires when OverlayView Draw
26834 * @param {Roo.bootstrap.LocationPicker} this
26836 OverlayViewDraw : true,
26838 * @event OverlayViewOnAdd
26839 * Fires when OverlayView Draw
26840 * @param {Roo.bootstrap.LocationPicker} this
26842 OverlayViewOnAdd : true,
26844 * @event OverlayViewOnRemove
26845 * Fires when OverlayView Draw
26846 * @param {Roo.bootstrap.LocationPicker} this
26848 OverlayViewOnRemove : true,
26850 * @event OverlayViewShow
26851 * Fires when OverlayView Draw
26852 * @param {Roo.bootstrap.LocationPicker} this
26853 * @param {Pixel} cpx
26855 OverlayViewShow : true,
26857 * @event OverlayViewHide
26858 * Fires when OverlayView Draw
26859 * @param {Roo.bootstrap.LocationPicker} this
26861 OverlayViewHide : true,
26863 * @event loadexception
26864 * Fires when load google lib failed.
26865 * @param {Roo.bootstrap.LocationPicker} this
26867 loadexception : true
26872 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26874 gMapContext: false,
26880 mapTypeControl: false,
26881 disableDoubleClickZoom: false,
26883 streetViewControl: false,
26887 enableAutocomplete: false,
26888 enableReverseGeocode: true,
26891 getAutoCreate: function()
26896 cls: 'roo-location-picker'
26902 initEvents: function(ct, position)
26904 if(!this.el.getWidth() || this.isApplied()){
26908 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26913 initial: function()
26915 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26916 this.fireEvent('loadexception', this);
26920 if(!this.mapTypeId){
26921 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26924 this.gMapContext = this.GMapContext();
26926 this.initOverlayView();
26928 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26932 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26933 _this.setPosition(_this.gMapContext.marker.position);
26936 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26937 _this.fireEvent('mapClick', this, event);
26941 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26942 _this.fireEvent('mapRightClick', this, event);
26946 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26947 _this.fireEvent('markerClick', this, event);
26951 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26952 _this.fireEvent('markerRightClick', this, event);
26956 this.setPosition(this.gMapContext.location);
26958 this.fireEvent('initial', this, this.gMapContext.location);
26961 initOverlayView: function()
26965 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26969 _this.fireEvent('OverlayViewDraw', _this);
26974 _this.fireEvent('OverlayViewOnAdd', _this);
26977 onRemove: function()
26979 _this.fireEvent('OverlayViewOnRemove', _this);
26982 show: function(cpx)
26984 _this.fireEvent('OverlayViewShow', _this, cpx);
26989 _this.fireEvent('OverlayViewHide', _this);
26995 fromLatLngToContainerPixel: function(event)
26997 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
27000 isApplied: function()
27002 return this.getGmapContext() == false ? false : true;
27005 getGmapContext: function()
27007 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
27010 GMapContext: function()
27012 var position = new google.maps.LatLng(this.latitude, this.longitude);
27014 var _map = new google.maps.Map(this.el.dom, {
27017 mapTypeId: this.mapTypeId,
27018 mapTypeControl: this.mapTypeControl,
27019 disableDoubleClickZoom: this.disableDoubleClickZoom,
27020 scrollwheel: this.scrollwheel,
27021 streetViewControl: this.streetViewControl,
27022 locationName: this.locationName,
27023 draggable: this.draggable,
27024 enableAutocomplete: this.enableAutocomplete,
27025 enableReverseGeocode: this.enableReverseGeocode
27028 var _marker = new google.maps.Marker({
27029 position: position,
27031 title: this.markerTitle,
27032 draggable: this.draggable
27039 location: position,
27040 radius: this.radius,
27041 locationName: this.locationName,
27042 addressComponents: {
27043 formatted_address: null,
27044 addressLine1: null,
27045 addressLine2: null,
27047 streetNumber: null,
27051 stateOrProvince: null
27054 domContainer: this.el.dom,
27055 geodecoder: new google.maps.Geocoder()
27059 drawCircle: function(center, radius, options)
27061 if (this.gMapContext.circle != null) {
27062 this.gMapContext.circle.setMap(null);
27066 options = Roo.apply({}, options, {
27067 strokeColor: "#0000FF",
27068 strokeOpacity: .35,
27070 fillColor: "#0000FF",
27074 options.map = this.gMapContext.map;
27075 options.radius = radius;
27076 options.center = center;
27077 this.gMapContext.circle = new google.maps.Circle(options);
27078 return this.gMapContext.circle;
27084 setPosition: function(location)
27086 this.gMapContext.location = location;
27087 this.gMapContext.marker.setPosition(location);
27088 this.gMapContext.map.panTo(location);
27089 this.drawCircle(location, this.gMapContext.radius, {});
27093 if (this.gMapContext.settings.enableReverseGeocode) {
27094 this.gMapContext.geodecoder.geocode({
27095 latLng: this.gMapContext.location
27096 }, function(results, status) {
27098 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27099 _this.gMapContext.locationName = results[0].formatted_address;
27100 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27102 _this.fireEvent('positionchanged', this, location);
27109 this.fireEvent('positionchanged', this, location);
27114 google.maps.event.trigger(this.gMapContext.map, "resize");
27116 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27118 this.fireEvent('resize', this);
27121 setPositionByLatLng: function(latitude, longitude)
27123 this.setPosition(new google.maps.LatLng(latitude, longitude));
27126 getCurrentPosition: function()
27129 latitude: this.gMapContext.location.lat(),
27130 longitude: this.gMapContext.location.lng()
27134 getAddressName: function()
27136 return this.gMapContext.locationName;
27139 getAddressComponents: function()
27141 return this.gMapContext.addressComponents;
27144 address_component_from_google_geocode: function(address_components)
27148 for (var i = 0; i < address_components.length; i++) {
27149 var component = address_components[i];
27150 if (component.types.indexOf("postal_code") >= 0) {
27151 result.postalCode = component.short_name;
27152 } else if (component.types.indexOf("street_number") >= 0) {
27153 result.streetNumber = component.short_name;
27154 } else if (component.types.indexOf("route") >= 0) {
27155 result.streetName = component.short_name;
27156 } else if (component.types.indexOf("neighborhood") >= 0) {
27157 result.city = component.short_name;
27158 } else if (component.types.indexOf("locality") >= 0) {
27159 result.city = component.short_name;
27160 } else if (component.types.indexOf("sublocality") >= 0) {
27161 result.district = component.short_name;
27162 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27163 result.stateOrProvince = component.short_name;
27164 } else if (component.types.indexOf("country") >= 0) {
27165 result.country = component.short_name;
27169 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27170 result.addressLine2 = "";
27174 setZoomLevel: function(zoom)
27176 this.gMapContext.map.setZoom(zoom);
27189 this.fireEvent('show', this);
27200 this.fireEvent('hide', this);
27205 Roo.apply(Roo.bootstrap.LocationPicker, {
27207 OverlayView : function(map, options)
27209 options = options || {};
27223 * @class Roo.bootstrap.Alert
27224 * @extends Roo.bootstrap.Component
27225 * Bootstrap Alert class
27226 * @cfg {String} title The title of alert
27227 * @cfg {String} html The content of alert
27228 * @cfg {String} weight ( success | info | warning | danger )
27229 * @cfg {String} faicon font-awesomeicon
27232 * Create a new alert
27233 * @param {Object} config The config object
27237 Roo.bootstrap.Alert = function(config){
27238 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27242 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27249 getAutoCreate : function()
27258 cls : 'roo-alert-icon'
27263 cls : 'roo-alert-title',
27268 cls : 'roo-alert-text',
27275 cfg.cn[0].cls += ' fa ' + this.faicon;
27279 cfg.cls += ' alert-' + this.weight;
27285 initEvents: function()
27287 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27290 setTitle : function(str)
27292 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27295 setText : function(str)
27297 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27300 setWeight : function(weight)
27303 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27306 this.weight = weight;
27308 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27311 setIcon : function(icon)
27314 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27317 this.faicon = icon;
27319 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27340 * @class Roo.bootstrap.UploadCropbox
27341 * @extends Roo.bootstrap.Component
27342 * Bootstrap UploadCropbox class
27343 * @cfg {String} emptyText show when image has been loaded
27344 * @cfg {String} rotateNotify show when image too small to rotate
27345 * @cfg {Number} errorTimeout default 3000
27346 * @cfg {Number} minWidth default 300
27347 * @cfg {Number} minHeight default 300
27348 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27349 * @cfg {Boolean} isDocument (true|false) default false
27350 * @cfg {String} url action url
27351 * @cfg {String} paramName default 'imageUpload'
27352 * @cfg {String} method default POST
27353 * @cfg {Boolean} loadMask (true|false) default true
27354 * @cfg {Boolean} loadingText default 'Loading...'
27357 * Create a new UploadCropbox
27358 * @param {Object} config The config object
27361 Roo.bootstrap.UploadCropbox = function(config){
27362 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27366 * @event beforeselectfile
27367 * Fire before select file
27368 * @param {Roo.bootstrap.UploadCropbox} this
27370 "beforeselectfile" : true,
27373 * Fire after initEvent
27374 * @param {Roo.bootstrap.UploadCropbox} this
27379 * Fire after initEvent
27380 * @param {Roo.bootstrap.UploadCropbox} this
27381 * @param {String} data
27386 * Fire when preparing the file data
27387 * @param {Roo.bootstrap.UploadCropbox} this
27388 * @param {Object} file
27393 * Fire when get exception
27394 * @param {Roo.bootstrap.UploadCropbox} this
27395 * @param {XMLHttpRequest} xhr
27397 "exception" : true,
27399 * @event beforeloadcanvas
27400 * Fire before load the canvas
27401 * @param {Roo.bootstrap.UploadCropbox} this
27402 * @param {String} src
27404 "beforeloadcanvas" : true,
27407 * Fire when trash image
27408 * @param {Roo.bootstrap.UploadCropbox} this
27413 * Fire when download the image
27414 * @param {Roo.bootstrap.UploadCropbox} this
27418 * @event footerbuttonclick
27419 * Fire when footerbuttonclick
27420 * @param {Roo.bootstrap.UploadCropbox} this
27421 * @param {String} type
27423 "footerbuttonclick" : true,
27427 * @param {Roo.bootstrap.UploadCropbox} this
27432 * Fire when rotate the image
27433 * @param {Roo.bootstrap.UploadCropbox} this
27434 * @param {String} pos
27439 * Fire when inspect the file
27440 * @param {Roo.bootstrap.UploadCropbox} this
27441 * @param {Object} file
27446 * Fire when xhr upload the file
27447 * @param {Roo.bootstrap.UploadCropbox} this
27448 * @param {Object} data
27453 * Fire when arrange the file data
27454 * @param {Roo.bootstrap.UploadCropbox} this
27455 * @param {Object} formData
27460 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27463 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27465 emptyText : 'Click to upload image',
27466 rotateNotify : 'Image is too small to rotate',
27467 errorTimeout : 3000,
27481 cropType : 'image/jpeg',
27483 canvasLoaded : false,
27484 isDocument : false,
27486 paramName : 'imageUpload',
27488 loadingText : 'Loading...',
27491 getAutoCreate : function()
27495 cls : 'roo-upload-cropbox',
27499 cls : 'roo-upload-cropbox-selector',
27504 cls : 'roo-upload-cropbox-body',
27505 style : 'cursor:pointer',
27509 cls : 'roo-upload-cropbox-preview'
27513 cls : 'roo-upload-cropbox-thumb'
27517 cls : 'roo-upload-cropbox-empty-notify',
27518 html : this.emptyText
27522 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27523 html : this.rotateNotify
27529 cls : 'roo-upload-cropbox-footer',
27532 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27542 onRender : function(ct, position)
27544 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27546 if (this.buttons.length) {
27548 Roo.each(this.buttons, function(bb) {
27550 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27552 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27558 this.maskEl = this.el;
27562 initEvents : function()
27564 this.urlAPI = (window.createObjectURL && window) ||
27565 (window.URL && URL.revokeObjectURL && URL) ||
27566 (window.webkitURL && webkitURL);
27568 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27569 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27571 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27572 this.selectorEl.hide();
27574 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27575 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27577 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27578 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27579 this.thumbEl.hide();
27581 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27582 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27584 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27585 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27586 this.errorEl.hide();
27588 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27589 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27590 this.footerEl.hide();
27592 this.setThumbBoxSize();
27598 this.fireEvent('initial', this);
27605 window.addEventListener("resize", function() { _this.resize(); } );
27607 this.bodyEl.on('click', this.beforeSelectFile, this);
27610 this.bodyEl.on('touchstart', this.onTouchStart, this);
27611 this.bodyEl.on('touchmove', this.onTouchMove, this);
27612 this.bodyEl.on('touchend', this.onTouchEnd, this);
27616 this.bodyEl.on('mousedown', this.onMouseDown, this);
27617 this.bodyEl.on('mousemove', this.onMouseMove, this);
27618 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27619 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27620 Roo.get(document).on('mouseup', this.onMouseUp, this);
27623 this.selectorEl.on('change', this.onFileSelected, this);
27629 this.baseScale = 1;
27631 this.baseRotate = 1;
27632 this.dragable = false;
27633 this.pinching = false;
27636 this.cropData = false;
27637 this.notifyEl.dom.innerHTML = this.emptyText;
27639 this.selectorEl.dom.value = '';
27643 resize : function()
27645 if(this.fireEvent('resize', this) != false){
27646 this.setThumbBoxPosition();
27647 this.setCanvasPosition();
27651 onFooterButtonClick : function(e, el, o, type)
27654 case 'rotate-left' :
27655 this.onRotateLeft(e);
27657 case 'rotate-right' :
27658 this.onRotateRight(e);
27661 this.beforeSelectFile(e);
27676 this.fireEvent('footerbuttonclick', this, type);
27679 beforeSelectFile : function(e)
27681 e.preventDefault();
27683 if(this.fireEvent('beforeselectfile', this) != false){
27684 this.selectorEl.dom.click();
27688 onFileSelected : function(e)
27690 e.preventDefault();
27692 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27696 var file = this.selectorEl.dom.files[0];
27698 if(this.fireEvent('inspect', this, file) != false){
27699 this.prepare(file);
27704 trash : function(e)
27706 this.fireEvent('trash', this);
27709 download : function(e)
27711 this.fireEvent('download', this);
27714 loadCanvas : function(src)
27716 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27720 this.imageEl = document.createElement('img');
27724 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27726 this.imageEl.src = src;
27730 onLoadCanvas : function()
27732 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27733 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27735 this.bodyEl.un('click', this.beforeSelectFile, this);
27737 this.notifyEl.hide();
27738 this.thumbEl.show();
27739 this.footerEl.show();
27741 this.baseRotateLevel();
27743 if(this.isDocument){
27744 this.setThumbBoxSize();
27747 this.setThumbBoxPosition();
27749 this.baseScaleLevel();
27755 this.canvasLoaded = true;
27758 this.maskEl.unmask();
27763 setCanvasPosition : function()
27765 if(!this.canvasEl){
27769 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27770 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27772 this.previewEl.setLeft(pw);
27773 this.previewEl.setTop(ph);
27777 onMouseDown : function(e)
27781 this.dragable = true;
27782 this.pinching = false;
27784 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27785 this.dragable = false;
27789 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27790 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27794 onMouseMove : function(e)
27798 if(!this.canvasLoaded){
27802 if (!this.dragable){
27806 var minX = Math.ceil(this.thumbEl.getLeft(true));
27807 var minY = Math.ceil(this.thumbEl.getTop(true));
27809 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27810 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27812 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27813 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27815 x = x - this.mouseX;
27816 y = y - this.mouseY;
27818 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27819 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27821 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27822 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27824 this.previewEl.setLeft(bgX);
27825 this.previewEl.setTop(bgY);
27827 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27828 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27831 onMouseUp : function(e)
27835 this.dragable = false;
27838 onMouseWheel : function(e)
27842 this.startScale = this.scale;
27844 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27846 if(!this.zoomable()){
27847 this.scale = this.startScale;
27856 zoomable : function()
27858 var minScale = this.thumbEl.getWidth() / this.minWidth;
27860 if(this.minWidth < this.minHeight){
27861 minScale = this.thumbEl.getHeight() / this.minHeight;
27864 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27865 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27869 (this.rotate == 0 || this.rotate == 180) &&
27871 width > this.imageEl.OriginWidth ||
27872 height > this.imageEl.OriginHeight ||
27873 (width < this.minWidth && height < this.minHeight)
27881 (this.rotate == 90 || this.rotate == 270) &&
27883 width > this.imageEl.OriginWidth ||
27884 height > this.imageEl.OriginHeight ||
27885 (width < this.minHeight && height < this.minWidth)
27892 !this.isDocument &&
27893 (this.rotate == 0 || this.rotate == 180) &&
27895 width < this.minWidth ||
27896 width > this.imageEl.OriginWidth ||
27897 height < this.minHeight ||
27898 height > this.imageEl.OriginHeight
27905 !this.isDocument &&
27906 (this.rotate == 90 || this.rotate == 270) &&
27908 width < this.minHeight ||
27909 width > this.imageEl.OriginWidth ||
27910 height < this.minWidth ||
27911 height > this.imageEl.OriginHeight
27921 onRotateLeft : function(e)
27923 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27925 var minScale = this.thumbEl.getWidth() / this.minWidth;
27927 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27928 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27930 this.startScale = this.scale;
27932 while (this.getScaleLevel() < minScale){
27934 this.scale = this.scale + 1;
27936 if(!this.zoomable()){
27941 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27942 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27947 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27954 this.scale = this.startScale;
27956 this.onRotateFail();
27961 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27963 if(this.isDocument){
27964 this.setThumbBoxSize();
27965 this.setThumbBoxPosition();
27966 this.setCanvasPosition();
27971 this.fireEvent('rotate', this, 'left');
27975 onRotateRight : function(e)
27977 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27979 var minScale = this.thumbEl.getWidth() / this.minWidth;
27981 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27982 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27984 this.startScale = this.scale;
27986 while (this.getScaleLevel() < minScale){
27988 this.scale = this.scale + 1;
27990 if(!this.zoomable()){
27995 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27996 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
28001 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28008 this.scale = this.startScale;
28010 this.onRotateFail();
28015 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28017 if(this.isDocument){
28018 this.setThumbBoxSize();
28019 this.setThumbBoxPosition();
28020 this.setCanvasPosition();
28025 this.fireEvent('rotate', this, 'right');
28028 onRotateFail : function()
28030 this.errorEl.show(true);
28034 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28039 this.previewEl.dom.innerHTML = '';
28041 var canvasEl = document.createElement("canvas");
28043 var contextEl = canvasEl.getContext("2d");
28045 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28046 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28047 var center = this.imageEl.OriginWidth / 2;
28049 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28050 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28051 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28052 center = this.imageEl.OriginHeight / 2;
28055 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28057 contextEl.translate(center, center);
28058 contextEl.rotate(this.rotate * Math.PI / 180);
28060 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28062 this.canvasEl = document.createElement("canvas");
28064 this.contextEl = this.canvasEl.getContext("2d");
28066 switch (this.rotate) {
28069 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28070 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28072 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28077 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28078 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28080 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28081 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);
28085 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28090 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28091 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28093 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28094 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);
28098 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);
28103 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28104 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28106 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28107 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28111 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);
28118 this.previewEl.appendChild(this.canvasEl);
28120 this.setCanvasPosition();
28125 if(!this.canvasLoaded){
28129 var imageCanvas = document.createElement("canvas");
28131 var imageContext = imageCanvas.getContext("2d");
28133 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28134 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28136 var center = imageCanvas.width / 2;
28138 imageContext.translate(center, center);
28140 imageContext.rotate(this.rotate * Math.PI / 180);
28142 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28144 var canvas = document.createElement("canvas");
28146 var context = canvas.getContext("2d");
28148 canvas.width = this.minWidth;
28149 canvas.height = this.minHeight;
28151 switch (this.rotate) {
28154 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28155 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28157 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28158 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28160 var targetWidth = this.minWidth - 2 * x;
28161 var targetHeight = this.minHeight - 2 * y;
28165 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28166 scale = targetWidth / width;
28169 if(x > 0 && y == 0){
28170 scale = targetHeight / height;
28173 if(x > 0 && y > 0){
28174 scale = targetWidth / width;
28176 if(width < height){
28177 scale = targetHeight / height;
28181 context.scale(scale, scale);
28183 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28184 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28186 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28187 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28189 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28194 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28195 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28197 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28198 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28200 var targetWidth = this.minWidth - 2 * x;
28201 var targetHeight = this.minHeight - 2 * y;
28205 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28206 scale = targetWidth / width;
28209 if(x > 0 && y == 0){
28210 scale = targetHeight / height;
28213 if(x > 0 && y > 0){
28214 scale = targetWidth / width;
28216 if(width < height){
28217 scale = targetHeight / height;
28221 context.scale(scale, scale);
28223 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28224 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28226 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28227 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28229 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28231 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28236 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28237 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28239 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28240 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28242 var targetWidth = this.minWidth - 2 * x;
28243 var targetHeight = this.minHeight - 2 * y;
28247 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28248 scale = targetWidth / width;
28251 if(x > 0 && y == 0){
28252 scale = targetHeight / height;
28255 if(x > 0 && y > 0){
28256 scale = targetWidth / width;
28258 if(width < height){
28259 scale = targetHeight / height;
28263 context.scale(scale, scale);
28265 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28266 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28268 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28269 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28271 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28272 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28274 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28279 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28280 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28282 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28283 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28285 var targetWidth = this.minWidth - 2 * x;
28286 var targetHeight = this.minHeight - 2 * y;
28290 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28291 scale = targetWidth / width;
28294 if(x > 0 && y == 0){
28295 scale = targetHeight / height;
28298 if(x > 0 && y > 0){
28299 scale = targetWidth / width;
28301 if(width < height){
28302 scale = targetHeight / height;
28306 context.scale(scale, scale);
28308 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28309 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28311 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28312 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28314 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28316 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28323 this.cropData = canvas.toDataURL(this.cropType);
28325 if(this.fireEvent('crop', this, this.cropData) !== false){
28326 this.process(this.file, this.cropData);
28333 setThumbBoxSize : function()
28337 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28338 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28339 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28341 this.minWidth = width;
28342 this.minHeight = height;
28344 if(this.rotate == 90 || this.rotate == 270){
28345 this.minWidth = height;
28346 this.minHeight = width;
28351 width = Math.ceil(this.minWidth * height / this.minHeight);
28353 if(this.minWidth > this.minHeight){
28355 height = Math.ceil(this.minHeight * width / this.minWidth);
28358 this.thumbEl.setStyle({
28359 width : width + 'px',
28360 height : height + 'px'
28367 setThumbBoxPosition : function()
28369 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28370 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28372 this.thumbEl.setLeft(x);
28373 this.thumbEl.setTop(y);
28377 baseRotateLevel : function()
28379 this.baseRotate = 1;
28382 typeof(this.exif) != 'undefined' &&
28383 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28384 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28386 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28389 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28393 baseScaleLevel : function()
28397 if(this.isDocument){
28399 if(this.baseRotate == 6 || this.baseRotate == 8){
28401 height = this.thumbEl.getHeight();
28402 this.baseScale = height / this.imageEl.OriginWidth;
28404 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28405 width = this.thumbEl.getWidth();
28406 this.baseScale = width / this.imageEl.OriginHeight;
28412 height = this.thumbEl.getHeight();
28413 this.baseScale = height / this.imageEl.OriginHeight;
28415 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28416 width = this.thumbEl.getWidth();
28417 this.baseScale = width / this.imageEl.OriginWidth;
28423 if(this.baseRotate == 6 || this.baseRotate == 8){
28425 width = this.thumbEl.getHeight();
28426 this.baseScale = width / this.imageEl.OriginHeight;
28428 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28429 height = this.thumbEl.getWidth();
28430 this.baseScale = height / this.imageEl.OriginHeight;
28433 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28434 height = this.thumbEl.getWidth();
28435 this.baseScale = height / this.imageEl.OriginHeight;
28437 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28438 width = this.thumbEl.getHeight();
28439 this.baseScale = width / this.imageEl.OriginWidth;
28446 width = this.thumbEl.getWidth();
28447 this.baseScale = width / this.imageEl.OriginWidth;
28449 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28450 height = this.thumbEl.getHeight();
28451 this.baseScale = height / this.imageEl.OriginHeight;
28454 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28456 height = this.thumbEl.getHeight();
28457 this.baseScale = height / this.imageEl.OriginHeight;
28459 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28460 width = this.thumbEl.getWidth();
28461 this.baseScale = width / this.imageEl.OriginWidth;
28469 getScaleLevel : function()
28471 return this.baseScale * Math.pow(1.1, this.scale);
28474 onTouchStart : function(e)
28476 if(!this.canvasLoaded){
28477 this.beforeSelectFile(e);
28481 var touches = e.browserEvent.touches;
28487 if(touches.length == 1){
28488 this.onMouseDown(e);
28492 if(touches.length != 2){
28498 for(var i = 0, finger; finger = touches[i]; i++){
28499 coords.push(finger.pageX, finger.pageY);
28502 var x = Math.pow(coords[0] - coords[2], 2);
28503 var y = Math.pow(coords[1] - coords[3], 2);
28505 this.startDistance = Math.sqrt(x + y);
28507 this.startScale = this.scale;
28509 this.pinching = true;
28510 this.dragable = false;
28514 onTouchMove : function(e)
28516 if(!this.pinching && !this.dragable){
28520 var touches = e.browserEvent.touches;
28527 this.onMouseMove(e);
28533 for(var i = 0, finger; finger = touches[i]; i++){
28534 coords.push(finger.pageX, finger.pageY);
28537 var x = Math.pow(coords[0] - coords[2], 2);
28538 var y = Math.pow(coords[1] - coords[3], 2);
28540 this.endDistance = Math.sqrt(x + y);
28542 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28544 if(!this.zoomable()){
28545 this.scale = this.startScale;
28553 onTouchEnd : function(e)
28555 this.pinching = false;
28556 this.dragable = false;
28560 process : function(file, crop)
28563 this.maskEl.mask(this.loadingText);
28566 this.xhr = new XMLHttpRequest();
28568 file.xhr = this.xhr;
28570 this.xhr.open(this.method, this.url, true);
28573 "Accept": "application/json",
28574 "Cache-Control": "no-cache",
28575 "X-Requested-With": "XMLHttpRequest"
28578 for (var headerName in headers) {
28579 var headerValue = headers[headerName];
28581 this.xhr.setRequestHeader(headerName, headerValue);
28587 this.xhr.onload = function()
28589 _this.xhrOnLoad(_this.xhr);
28592 this.xhr.onerror = function()
28594 _this.xhrOnError(_this.xhr);
28597 var formData = new FormData();
28599 formData.append('returnHTML', 'NO');
28602 formData.append('crop', crop);
28605 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28606 formData.append(this.paramName, file, file.name);
28609 if(typeof(file.filename) != 'undefined'){
28610 formData.append('filename', file.filename);
28613 if(typeof(file.mimetype) != 'undefined'){
28614 formData.append('mimetype', file.mimetype);
28617 if(this.fireEvent('arrange', this, formData) != false){
28618 this.xhr.send(formData);
28622 xhrOnLoad : function(xhr)
28625 this.maskEl.unmask();
28628 if (xhr.readyState !== 4) {
28629 this.fireEvent('exception', this, xhr);
28633 var response = Roo.decode(xhr.responseText);
28635 if(!response.success){
28636 this.fireEvent('exception', this, xhr);
28640 var response = Roo.decode(xhr.responseText);
28642 this.fireEvent('upload', this, response);
28646 xhrOnError : function()
28649 this.maskEl.unmask();
28652 Roo.log('xhr on error');
28654 var response = Roo.decode(xhr.responseText);
28660 prepare : function(file)
28663 this.maskEl.mask(this.loadingText);
28669 if(typeof(file) === 'string'){
28670 this.loadCanvas(file);
28674 if(!file || !this.urlAPI){
28679 this.cropType = file.type;
28683 if(this.fireEvent('prepare', this, this.file) != false){
28685 var reader = new FileReader();
28687 reader.onload = function (e) {
28688 if (e.target.error) {
28689 Roo.log(e.target.error);
28693 var buffer = e.target.result,
28694 dataView = new DataView(buffer),
28696 maxOffset = dataView.byteLength - 4,
28700 if (dataView.getUint16(0) === 0xffd8) {
28701 while (offset < maxOffset) {
28702 markerBytes = dataView.getUint16(offset);
28704 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28705 markerLength = dataView.getUint16(offset + 2) + 2;
28706 if (offset + markerLength > dataView.byteLength) {
28707 Roo.log('Invalid meta data: Invalid segment size.');
28711 if(markerBytes == 0xffe1){
28712 _this.parseExifData(
28719 offset += markerLength;
28729 var url = _this.urlAPI.createObjectURL(_this.file);
28731 _this.loadCanvas(url);
28736 reader.readAsArrayBuffer(this.file);
28742 parseExifData : function(dataView, offset, length)
28744 var tiffOffset = offset + 10,
28748 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28749 // No Exif data, might be XMP data instead
28753 // Check for the ASCII code for "Exif" (0x45786966):
28754 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28755 // No Exif data, might be XMP data instead
28758 if (tiffOffset + 8 > dataView.byteLength) {
28759 Roo.log('Invalid Exif data: Invalid segment size.');
28762 // Check for the two null bytes:
28763 if (dataView.getUint16(offset + 8) !== 0x0000) {
28764 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28767 // Check the byte alignment:
28768 switch (dataView.getUint16(tiffOffset)) {
28770 littleEndian = true;
28773 littleEndian = false;
28776 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28779 // Check for the TIFF tag marker (0x002A):
28780 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28781 Roo.log('Invalid Exif data: Missing TIFF marker.');
28784 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28785 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28787 this.parseExifTags(
28790 tiffOffset + dirOffset,
28795 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28800 if (dirOffset + 6 > dataView.byteLength) {
28801 Roo.log('Invalid Exif data: Invalid directory offset.');
28804 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28805 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28806 if (dirEndOffset + 4 > dataView.byteLength) {
28807 Roo.log('Invalid Exif data: Invalid directory size.');
28810 for (i = 0; i < tagsNumber; i += 1) {
28814 dirOffset + 2 + 12 * i, // tag offset
28818 // Return the offset to the next directory:
28819 return dataView.getUint32(dirEndOffset, littleEndian);
28822 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28824 var tag = dataView.getUint16(offset, littleEndian);
28826 this.exif[tag] = this.getExifValue(
28830 dataView.getUint16(offset + 2, littleEndian), // tag type
28831 dataView.getUint32(offset + 4, littleEndian), // tag length
28836 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28838 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28847 Roo.log('Invalid Exif data: Invalid tag type.');
28851 tagSize = tagType.size * length;
28852 // Determine if the value is contained in the dataOffset bytes,
28853 // or if the value at the dataOffset is a pointer to the actual data:
28854 dataOffset = tagSize > 4 ?
28855 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28856 if (dataOffset + tagSize > dataView.byteLength) {
28857 Roo.log('Invalid Exif data: Invalid data offset.');
28860 if (length === 1) {
28861 return tagType.getValue(dataView, dataOffset, littleEndian);
28864 for (i = 0; i < length; i += 1) {
28865 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28868 if (tagType.ascii) {
28870 // Concatenate the chars:
28871 for (i = 0; i < values.length; i += 1) {
28873 // Ignore the terminating NULL byte(s):
28874 if (c === '\u0000') {
28886 Roo.apply(Roo.bootstrap.UploadCropbox, {
28888 'Orientation': 0x0112
28892 1: 0, //'top-left',
28894 3: 180, //'bottom-right',
28895 // 4: 'bottom-left',
28897 6: 90, //'right-top',
28898 // 7: 'right-bottom',
28899 8: 270 //'left-bottom'
28903 // byte, 8-bit unsigned int:
28905 getValue: function (dataView, dataOffset) {
28906 return dataView.getUint8(dataOffset);
28910 // ascii, 8-bit byte:
28912 getValue: function (dataView, dataOffset) {
28913 return String.fromCharCode(dataView.getUint8(dataOffset));
28918 // short, 16 bit int:
28920 getValue: function (dataView, dataOffset, littleEndian) {
28921 return dataView.getUint16(dataOffset, littleEndian);
28925 // long, 32 bit int:
28927 getValue: function (dataView, dataOffset, littleEndian) {
28928 return dataView.getUint32(dataOffset, littleEndian);
28932 // rational = two long values, first is numerator, second is denominator:
28934 getValue: function (dataView, dataOffset, littleEndian) {
28935 return dataView.getUint32(dataOffset, littleEndian) /
28936 dataView.getUint32(dataOffset + 4, littleEndian);
28940 // slong, 32 bit signed int:
28942 getValue: function (dataView, dataOffset, littleEndian) {
28943 return dataView.getInt32(dataOffset, littleEndian);
28947 // srational, two slongs, first is numerator, second is denominator:
28949 getValue: function (dataView, dataOffset, littleEndian) {
28950 return dataView.getInt32(dataOffset, littleEndian) /
28951 dataView.getInt32(dataOffset + 4, littleEndian);
28961 cls : 'btn-group roo-upload-cropbox-rotate-left',
28962 action : 'rotate-left',
28966 cls : 'btn btn-default',
28967 html : '<i class="fa fa-undo"></i>'
28973 cls : 'btn-group roo-upload-cropbox-picture',
28974 action : 'picture',
28978 cls : 'btn btn-default',
28979 html : '<i class="fa fa-picture-o"></i>'
28985 cls : 'btn-group roo-upload-cropbox-rotate-right',
28986 action : 'rotate-right',
28990 cls : 'btn btn-default',
28991 html : '<i class="fa fa-repeat"></i>'
28999 cls : 'btn-group roo-upload-cropbox-rotate-left',
29000 action : 'rotate-left',
29004 cls : 'btn btn-default',
29005 html : '<i class="fa fa-undo"></i>'
29011 cls : 'btn-group roo-upload-cropbox-download',
29012 action : 'download',
29016 cls : 'btn btn-default',
29017 html : '<i class="fa fa-download"></i>'
29023 cls : 'btn-group roo-upload-cropbox-crop',
29028 cls : 'btn btn-default',
29029 html : '<i class="fa fa-crop"></i>'
29035 cls : 'btn-group roo-upload-cropbox-trash',
29040 cls : 'btn btn-default',
29041 html : '<i class="fa fa-trash"></i>'
29047 cls : 'btn-group roo-upload-cropbox-rotate-right',
29048 action : 'rotate-right',
29052 cls : 'btn btn-default',
29053 html : '<i class="fa fa-repeat"></i>'
29061 cls : 'btn-group roo-upload-cropbox-rotate-left',
29062 action : 'rotate-left',
29066 cls : 'btn btn-default',
29067 html : '<i class="fa fa-undo"></i>'
29073 cls : 'btn-group roo-upload-cropbox-rotate-right',
29074 action : 'rotate-right',
29078 cls : 'btn btn-default',
29079 html : '<i class="fa fa-repeat"></i>'
29092 * @class Roo.bootstrap.DocumentManager
29093 * @extends Roo.bootstrap.Component
29094 * Bootstrap DocumentManager class
29095 * @cfg {String} paramName default 'imageUpload'
29096 * @cfg {String} toolTipName default 'filename'
29097 * @cfg {String} method default POST
29098 * @cfg {String} url action url
29099 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29100 * @cfg {Boolean} multiple multiple upload default true
29101 * @cfg {Number} thumbSize default 300
29102 * @cfg {String} fieldLabel
29103 * @cfg {Number} labelWidth default 4
29104 * @cfg {String} labelAlign (left|top) default left
29105 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29106 * @cfg {Number} labellg set the width of label (1-12)
29107 * @cfg {Number} labelmd set the width of label (1-12)
29108 * @cfg {Number} labelsm set the width of label (1-12)
29109 * @cfg {Number} labelxs set the width of label (1-12)
29112 * Create a new DocumentManager
29113 * @param {Object} config The config object
29116 Roo.bootstrap.DocumentManager = function(config){
29117 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29120 this.delegates = [];
29125 * Fire when initial the DocumentManager
29126 * @param {Roo.bootstrap.DocumentManager} this
29131 * inspect selected file
29132 * @param {Roo.bootstrap.DocumentManager} this
29133 * @param {File} file
29138 * Fire when xhr load exception
29139 * @param {Roo.bootstrap.DocumentManager} this
29140 * @param {XMLHttpRequest} xhr
29142 "exception" : true,
29144 * @event afterupload
29145 * Fire when xhr load exception
29146 * @param {Roo.bootstrap.DocumentManager} this
29147 * @param {XMLHttpRequest} xhr
29149 "afterupload" : true,
29152 * prepare the form data
29153 * @param {Roo.bootstrap.DocumentManager} this
29154 * @param {Object} formData
29159 * Fire when remove the file
29160 * @param {Roo.bootstrap.DocumentManager} this
29161 * @param {Object} file
29166 * Fire after refresh the file
29167 * @param {Roo.bootstrap.DocumentManager} this
29172 * Fire after click the image
29173 * @param {Roo.bootstrap.DocumentManager} this
29174 * @param {Object} file
29179 * Fire when upload a image and editable set to true
29180 * @param {Roo.bootstrap.DocumentManager} this
29181 * @param {Object} file
29185 * @event beforeselectfile
29186 * Fire before select file
29187 * @param {Roo.bootstrap.DocumentManager} this
29189 "beforeselectfile" : true,
29192 * Fire before process file
29193 * @param {Roo.bootstrap.DocumentManager} this
29194 * @param {Object} file
29198 * @event previewrendered
29199 * Fire when preview rendered
29200 * @param {Roo.bootstrap.DocumentManager} this
29201 * @param {Object} file
29203 "previewrendered" : true,
29206 "previewResize" : true
29211 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29220 paramName : 'imageUpload',
29221 toolTipName : 'filename',
29224 labelAlign : 'left',
29234 getAutoCreate : function()
29236 var managerWidget = {
29238 cls : 'roo-document-manager',
29242 cls : 'roo-document-manager-selector',
29247 cls : 'roo-document-manager-uploader',
29251 cls : 'roo-document-manager-upload-btn',
29252 html : '<i class="fa fa-plus"></i>'
29263 cls : 'column col-md-12',
29268 if(this.fieldLabel.length){
29273 cls : 'column col-md-12',
29274 html : this.fieldLabel
29278 cls : 'column col-md-12',
29283 if(this.labelAlign == 'left'){
29288 html : this.fieldLabel
29297 if(this.labelWidth > 12){
29298 content[0].style = "width: " + this.labelWidth + 'px';
29301 if(this.labelWidth < 13 && this.labelmd == 0){
29302 this.labelmd = this.labelWidth;
29305 if(this.labellg > 0){
29306 content[0].cls += ' col-lg-' + this.labellg;
29307 content[1].cls += ' col-lg-' + (12 - this.labellg);
29310 if(this.labelmd > 0){
29311 content[0].cls += ' col-md-' + this.labelmd;
29312 content[1].cls += ' col-md-' + (12 - this.labelmd);
29315 if(this.labelsm > 0){
29316 content[0].cls += ' col-sm-' + this.labelsm;
29317 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29320 if(this.labelxs > 0){
29321 content[0].cls += ' col-xs-' + this.labelxs;
29322 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29330 cls : 'row clearfix',
29338 initEvents : function()
29340 this.managerEl = this.el.select('.roo-document-manager', true).first();
29341 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29343 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29344 this.selectorEl.hide();
29347 this.selectorEl.attr('multiple', 'multiple');
29350 this.selectorEl.on('change', this.onFileSelected, this);
29352 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29353 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29355 this.uploader.on('click', this.onUploaderClick, this);
29357 this.renderProgressDialog();
29361 window.addEventListener("resize", function() { _this.refresh(); } );
29363 this.fireEvent('initial', this);
29366 renderProgressDialog : function()
29370 this.progressDialog = new Roo.bootstrap.Modal({
29371 cls : 'roo-document-manager-progress-dialog',
29372 allow_close : false,
29383 btnclick : function() {
29384 _this.uploadCancel();
29390 this.progressDialog.render(Roo.get(document.body));
29392 this.progress = new Roo.bootstrap.Progress({
29393 cls : 'roo-document-manager-progress',
29398 this.progress.render(this.progressDialog.getChildContainer());
29400 this.progressBar = new Roo.bootstrap.ProgressBar({
29401 cls : 'roo-document-manager-progress-bar',
29404 aria_valuemax : 12,
29408 this.progressBar.render(this.progress.getChildContainer());
29411 onUploaderClick : function(e)
29413 e.preventDefault();
29415 if(this.fireEvent('beforeselectfile', this) != false){
29416 this.selectorEl.dom.click();
29421 onFileSelected : function(e)
29423 e.preventDefault();
29425 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29429 Roo.each(this.selectorEl.dom.files, function(file){
29430 if(this.fireEvent('inspect', this, file) != false){
29431 this.files.push(file);
29441 this.selectorEl.dom.value = '';
29443 if(!this.files || !this.files.length){
29447 if(this.boxes > 0 && this.files.length > this.boxes){
29448 this.files = this.files.slice(0, this.boxes);
29451 this.uploader.show();
29453 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29454 this.uploader.hide();
29463 Roo.each(this.files, function(file){
29465 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29466 var f = this.renderPreview(file);
29471 if(file.type.indexOf('image') != -1){
29472 this.delegates.push(
29474 _this.process(file);
29475 }).createDelegate(this)
29483 _this.process(file);
29484 }).createDelegate(this)
29489 this.files = files;
29491 this.delegates = this.delegates.concat(docs);
29493 if(!this.delegates.length){
29498 this.progressBar.aria_valuemax = this.delegates.length;
29505 arrange : function()
29507 if(!this.delegates.length){
29508 this.progressDialog.hide();
29513 var delegate = this.delegates.shift();
29515 this.progressDialog.show();
29517 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29519 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29524 refresh : function()
29526 this.uploader.show();
29528 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29529 this.uploader.hide();
29532 Roo.isTouch ? this.closable(false) : this.closable(true);
29534 this.fireEvent('refresh', this);
29537 onRemove : function(e, el, o)
29539 e.preventDefault();
29541 this.fireEvent('remove', this, o);
29545 remove : function(o)
29549 Roo.each(this.files, function(file){
29550 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29559 this.files = files;
29566 Roo.each(this.files, function(file){
29571 file.target.remove();
29580 onClick : function(e, el, o)
29582 e.preventDefault();
29584 this.fireEvent('click', this, o);
29588 closable : function(closable)
29590 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29592 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29604 xhrOnLoad : function(xhr)
29606 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29610 if (xhr.readyState !== 4) {
29612 this.fireEvent('exception', this, xhr);
29616 var response = Roo.decode(xhr.responseText);
29618 if(!response.success){
29620 this.fireEvent('exception', this, xhr);
29624 var file = this.renderPreview(response.data);
29626 this.files.push(file);
29630 this.fireEvent('afterupload', this, xhr);
29634 xhrOnError : function(xhr)
29636 Roo.log('xhr on error');
29638 var response = Roo.decode(xhr.responseText);
29645 process : function(file)
29647 if(this.fireEvent('process', this, file) !== false){
29648 if(this.editable && file.type.indexOf('image') != -1){
29649 this.fireEvent('edit', this, file);
29653 this.uploadStart(file, false);
29660 uploadStart : function(file, crop)
29662 this.xhr = new XMLHttpRequest();
29664 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29669 file.xhr = this.xhr;
29671 this.managerEl.createChild({
29673 cls : 'roo-document-manager-loading',
29677 tooltip : file.name,
29678 cls : 'roo-document-manager-thumb',
29679 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29685 this.xhr.open(this.method, this.url, true);
29688 "Accept": "application/json",
29689 "Cache-Control": "no-cache",
29690 "X-Requested-With": "XMLHttpRequest"
29693 for (var headerName in headers) {
29694 var headerValue = headers[headerName];
29696 this.xhr.setRequestHeader(headerName, headerValue);
29702 this.xhr.onload = function()
29704 _this.xhrOnLoad(_this.xhr);
29707 this.xhr.onerror = function()
29709 _this.xhrOnError(_this.xhr);
29712 var formData = new FormData();
29714 formData.append('returnHTML', 'NO');
29717 formData.append('crop', crop);
29720 formData.append(this.paramName, file, file.name);
29727 if(this.fireEvent('prepare', this, formData, options) != false){
29729 if(options.manually){
29733 this.xhr.send(formData);
29737 this.uploadCancel();
29740 uploadCancel : function()
29746 this.delegates = [];
29748 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29755 renderPreview : function(file)
29757 if(typeof(file.target) != 'undefined' && file.target){
29761 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29763 var previewEl = this.managerEl.createChild({
29765 cls : 'roo-document-manager-preview',
29769 tooltip : file[this.toolTipName],
29770 cls : 'roo-document-manager-thumb',
29771 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29776 html : '<i class="fa fa-times-circle"></i>'
29781 var close = previewEl.select('button.close', true).first();
29783 close.on('click', this.onRemove, this, file);
29785 file.target = previewEl;
29787 var image = previewEl.select('img', true).first();
29791 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29793 image.on('click', this.onClick, this, file);
29795 this.fireEvent('previewrendered', this, file);
29801 onPreviewLoad : function(file, image)
29803 if(typeof(file.target) == 'undefined' || !file.target){
29807 var width = image.dom.naturalWidth || image.dom.width;
29808 var height = image.dom.naturalHeight || image.dom.height;
29810 if(!this.previewResize) {
29814 if(width > height){
29815 file.target.addClass('wide');
29819 file.target.addClass('tall');
29824 uploadFromSource : function(file, crop)
29826 this.xhr = new XMLHttpRequest();
29828 this.managerEl.createChild({
29830 cls : 'roo-document-manager-loading',
29834 tooltip : file.name,
29835 cls : 'roo-document-manager-thumb',
29836 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29842 this.xhr.open(this.method, this.url, true);
29845 "Accept": "application/json",
29846 "Cache-Control": "no-cache",
29847 "X-Requested-With": "XMLHttpRequest"
29850 for (var headerName in headers) {
29851 var headerValue = headers[headerName];
29853 this.xhr.setRequestHeader(headerName, headerValue);
29859 this.xhr.onload = function()
29861 _this.xhrOnLoad(_this.xhr);
29864 this.xhr.onerror = function()
29866 _this.xhrOnError(_this.xhr);
29869 var formData = new FormData();
29871 formData.append('returnHTML', 'NO');
29873 formData.append('crop', crop);
29875 if(typeof(file.filename) != 'undefined'){
29876 formData.append('filename', file.filename);
29879 if(typeof(file.mimetype) != 'undefined'){
29880 formData.append('mimetype', file.mimetype);
29885 if(this.fireEvent('prepare', this, formData) != false){
29886 this.xhr.send(formData);
29896 * @class Roo.bootstrap.DocumentViewer
29897 * @extends Roo.bootstrap.Component
29898 * Bootstrap DocumentViewer class
29899 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29900 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29903 * Create a new DocumentViewer
29904 * @param {Object} config The config object
29907 Roo.bootstrap.DocumentViewer = function(config){
29908 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29913 * Fire after initEvent
29914 * @param {Roo.bootstrap.DocumentViewer} this
29920 * @param {Roo.bootstrap.DocumentViewer} this
29925 * Fire after download button
29926 * @param {Roo.bootstrap.DocumentViewer} this
29931 * Fire after trash button
29932 * @param {Roo.bootstrap.DocumentViewer} this
29939 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29941 showDownload : true,
29945 getAutoCreate : function()
29949 cls : 'roo-document-viewer',
29953 cls : 'roo-document-viewer-body',
29957 cls : 'roo-document-viewer-thumb',
29961 cls : 'roo-document-viewer-image'
29969 cls : 'roo-document-viewer-footer',
29972 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29976 cls : 'btn-group roo-document-viewer-download',
29980 cls : 'btn btn-default',
29981 html : '<i class="fa fa-download"></i>'
29987 cls : 'btn-group roo-document-viewer-trash',
29991 cls : 'btn btn-default',
29992 html : '<i class="fa fa-trash"></i>'
30005 initEvents : function()
30007 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
30008 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
30010 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
30011 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
30013 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
30014 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
30016 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
30017 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
30019 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
30020 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
30022 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
30023 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
30025 this.bodyEl.on('click', this.onClick, this);
30026 this.downloadBtn.on('click', this.onDownload, this);
30027 this.trashBtn.on('click', this.onTrash, this);
30029 this.downloadBtn.hide();
30030 this.trashBtn.hide();
30032 if(this.showDownload){
30033 this.downloadBtn.show();
30036 if(this.showTrash){
30037 this.trashBtn.show();
30040 if(!this.showDownload && !this.showTrash) {
30041 this.footerEl.hide();
30046 initial : function()
30048 this.fireEvent('initial', this);
30052 onClick : function(e)
30054 e.preventDefault();
30056 this.fireEvent('click', this);
30059 onDownload : function(e)
30061 e.preventDefault();
30063 this.fireEvent('download', this);
30066 onTrash : function(e)
30068 e.preventDefault();
30070 this.fireEvent('trash', this);
30082 * @class Roo.bootstrap.NavProgressBar
30083 * @extends Roo.bootstrap.Component
30084 * Bootstrap NavProgressBar class
30087 * Create a new nav progress bar
30088 * @param {Object} config The config object
30091 Roo.bootstrap.NavProgressBar = function(config){
30092 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30094 this.bullets = this.bullets || [];
30096 // Roo.bootstrap.NavProgressBar.register(this);
30100 * Fires when the active item changes
30101 * @param {Roo.bootstrap.NavProgressBar} this
30102 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30103 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30110 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30115 getAutoCreate : function()
30117 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30121 cls : 'roo-navigation-bar-group',
30125 cls : 'roo-navigation-top-bar'
30129 cls : 'roo-navigation-bullets-bar',
30133 cls : 'roo-navigation-bar'
30140 cls : 'roo-navigation-bottom-bar'
30150 initEvents: function()
30155 onRender : function(ct, position)
30157 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30159 if(this.bullets.length){
30160 Roo.each(this.bullets, function(b){
30169 addItem : function(cfg)
30171 var item = new Roo.bootstrap.NavProgressItem(cfg);
30173 item.parentId = this.id;
30174 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30177 var top = new Roo.bootstrap.Element({
30179 cls : 'roo-navigation-bar-text'
30182 var bottom = new Roo.bootstrap.Element({
30184 cls : 'roo-navigation-bar-text'
30187 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30188 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30190 var topText = new Roo.bootstrap.Element({
30192 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30195 var bottomText = new Roo.bootstrap.Element({
30197 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30200 topText.onRender(top.el, null);
30201 bottomText.onRender(bottom.el, null);
30204 item.bottomEl = bottom;
30207 this.barItems.push(item);
30212 getActive : function()
30214 var active = false;
30216 Roo.each(this.barItems, function(v){
30218 if (!v.isActive()) {
30230 setActiveItem : function(item)
30234 Roo.each(this.barItems, function(v){
30235 if (v.rid == item.rid) {
30239 if (v.isActive()) {
30240 v.setActive(false);
30245 item.setActive(true);
30247 this.fireEvent('changed', this, item, prev);
30250 getBarItem: function(rid)
30254 Roo.each(this.barItems, function(e) {
30255 if (e.rid != rid) {
30266 indexOfItem : function(item)
30270 Roo.each(this.barItems, function(v, i){
30272 if (v.rid != item.rid) {
30283 setActiveNext : function()
30285 var i = this.indexOfItem(this.getActive());
30287 if (i > this.barItems.length) {
30291 this.setActiveItem(this.barItems[i+1]);
30294 setActivePrev : function()
30296 var i = this.indexOfItem(this.getActive());
30302 this.setActiveItem(this.barItems[i-1]);
30305 format : function()
30307 if(!this.barItems.length){
30311 var width = 100 / this.barItems.length;
30313 Roo.each(this.barItems, function(i){
30314 i.el.setStyle('width', width + '%');
30315 i.topEl.el.setStyle('width', width + '%');
30316 i.bottomEl.el.setStyle('width', width + '%');
30325 * Nav Progress Item
30330 * @class Roo.bootstrap.NavProgressItem
30331 * @extends Roo.bootstrap.Component
30332 * Bootstrap NavProgressItem class
30333 * @cfg {String} rid the reference id
30334 * @cfg {Boolean} active (true|false) Is item active default false
30335 * @cfg {Boolean} disabled (true|false) Is item active default false
30336 * @cfg {String} html
30337 * @cfg {String} position (top|bottom) text position default bottom
30338 * @cfg {String} icon show icon instead of number
30341 * Create a new NavProgressItem
30342 * @param {Object} config The config object
30344 Roo.bootstrap.NavProgressItem = function(config){
30345 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30350 * The raw click event for the entire grid.
30351 * @param {Roo.bootstrap.NavProgressItem} this
30352 * @param {Roo.EventObject} e
30359 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30365 position : 'bottom',
30368 getAutoCreate : function()
30370 var iconCls = 'roo-navigation-bar-item-icon';
30372 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30376 cls: 'roo-navigation-bar-item',
30386 cfg.cls += ' active';
30389 cfg.cls += ' disabled';
30395 disable : function()
30397 this.setDisabled(true);
30400 enable : function()
30402 this.setDisabled(false);
30405 initEvents: function()
30407 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30409 this.iconEl.on('click', this.onClick, this);
30412 onClick : function(e)
30414 e.preventDefault();
30420 if(this.fireEvent('click', this, e) === false){
30424 this.parent().setActiveItem(this);
30427 isActive: function ()
30429 return this.active;
30432 setActive : function(state)
30434 if(this.active == state){
30438 this.active = state;
30441 this.el.addClass('active');
30445 this.el.removeClass('active');
30450 setDisabled : function(state)
30452 if(this.disabled == state){
30456 this.disabled = state;
30459 this.el.addClass('disabled');
30463 this.el.removeClass('disabled');
30466 tooltipEl : function()
30468 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30481 * @class Roo.bootstrap.FieldLabel
30482 * @extends Roo.bootstrap.Component
30483 * Bootstrap FieldLabel class
30484 * @cfg {String} html contents of the element
30485 * @cfg {String} tag tag of the element default label
30486 * @cfg {String} cls class of the element
30487 * @cfg {String} target label target
30488 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30489 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30490 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30491 * @cfg {String} iconTooltip default "This field is required"
30492 * @cfg {String} indicatorpos (left|right) default left
30495 * Create a new FieldLabel
30496 * @param {Object} config The config object
30499 Roo.bootstrap.FieldLabel = function(config){
30500 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30505 * Fires after the field has been marked as invalid.
30506 * @param {Roo.form.FieldLabel} this
30507 * @param {String} msg The validation message
30512 * Fires after the field has been validated with no errors.
30513 * @param {Roo.form.FieldLabel} this
30519 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30526 invalidClass : 'has-warning',
30527 validClass : 'has-success',
30528 iconTooltip : 'This field is required',
30529 indicatorpos : 'left',
30531 getAutoCreate : function(){
30534 if (!this.allowBlank) {
30540 cls : 'roo-bootstrap-field-label ' + this.cls,
30545 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30546 tooltip : this.iconTooltip
30555 if(this.indicatorpos == 'right'){
30558 cls : 'roo-bootstrap-field-label ' + this.cls,
30567 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30568 tooltip : this.iconTooltip
30577 initEvents: function()
30579 Roo.bootstrap.Element.superclass.initEvents.call(this);
30581 this.indicator = this.indicatorEl();
30583 if(this.indicator){
30584 this.indicator.removeClass('visible');
30585 this.indicator.addClass('invisible');
30588 Roo.bootstrap.FieldLabel.register(this);
30591 indicatorEl : function()
30593 var indicator = this.el.select('i.roo-required-indicator',true).first();
30604 * Mark this field as valid
30606 markValid : function()
30608 if(this.indicator){
30609 this.indicator.removeClass('visible');
30610 this.indicator.addClass('invisible');
30612 if (Roo.bootstrap.version == 3) {
30613 this.el.removeClass(this.invalidClass);
30614 this.el.addClass(this.validClass);
30616 this.el.removeClass('is-invalid');
30617 this.el.addClass('is-valid');
30621 this.fireEvent('valid', this);
30625 * Mark this field as invalid
30626 * @param {String} msg The validation message
30628 markInvalid : function(msg)
30630 if(this.indicator){
30631 this.indicator.removeClass('invisible');
30632 this.indicator.addClass('visible');
30634 if (Roo.bootstrap.version == 3) {
30635 this.el.removeClass(this.validClass);
30636 this.el.addClass(this.invalidClass);
30638 this.el.removeClass('is-valid');
30639 this.el.addClass('is-invalid');
30643 this.fireEvent('invalid', this, msg);
30649 Roo.apply(Roo.bootstrap.FieldLabel, {
30654 * register a FieldLabel Group
30655 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30657 register : function(label)
30659 if(this.groups.hasOwnProperty(label.target)){
30663 this.groups[label.target] = label;
30667 * fetch a FieldLabel Group based on the target
30668 * @param {string} target
30669 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30671 get: function(target) {
30672 if (typeof(this.groups[target]) == 'undefined') {
30676 return this.groups[target] ;
30685 * page DateSplitField.
30691 * @class Roo.bootstrap.DateSplitField
30692 * @extends Roo.bootstrap.Component
30693 * Bootstrap DateSplitField class
30694 * @cfg {string} fieldLabel - the label associated
30695 * @cfg {Number} labelWidth set the width of label (0-12)
30696 * @cfg {String} labelAlign (top|left)
30697 * @cfg {Boolean} dayAllowBlank (true|false) default false
30698 * @cfg {Boolean} monthAllowBlank (true|false) default false
30699 * @cfg {Boolean} yearAllowBlank (true|false) default false
30700 * @cfg {string} dayPlaceholder
30701 * @cfg {string} monthPlaceholder
30702 * @cfg {string} yearPlaceholder
30703 * @cfg {string} dayFormat default 'd'
30704 * @cfg {string} monthFormat default 'm'
30705 * @cfg {string} yearFormat default 'Y'
30706 * @cfg {Number} labellg set the width of label (1-12)
30707 * @cfg {Number} labelmd set the width of label (1-12)
30708 * @cfg {Number} labelsm set the width of label (1-12)
30709 * @cfg {Number} labelxs set the width of label (1-12)
30713 * Create a new DateSplitField
30714 * @param {Object} config The config object
30717 Roo.bootstrap.DateSplitField = function(config){
30718 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30724 * getting the data of years
30725 * @param {Roo.bootstrap.DateSplitField} this
30726 * @param {Object} years
30731 * getting the data of days
30732 * @param {Roo.bootstrap.DateSplitField} this
30733 * @param {Object} days
30738 * Fires after the field has been marked as invalid.
30739 * @param {Roo.form.Field} this
30740 * @param {String} msg The validation message
30745 * Fires after the field has been validated with no errors.
30746 * @param {Roo.form.Field} this
30752 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30755 labelAlign : 'top',
30757 dayAllowBlank : false,
30758 monthAllowBlank : false,
30759 yearAllowBlank : false,
30760 dayPlaceholder : '',
30761 monthPlaceholder : '',
30762 yearPlaceholder : '',
30766 isFormField : true,
30772 getAutoCreate : function()
30776 cls : 'row roo-date-split-field-group',
30781 cls : 'form-hidden-field roo-date-split-field-group-value',
30787 var labelCls = 'col-md-12';
30788 var contentCls = 'col-md-4';
30790 if(this.fieldLabel){
30794 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30798 html : this.fieldLabel
30803 if(this.labelAlign == 'left'){
30805 if(this.labelWidth > 12){
30806 label.style = "width: " + this.labelWidth + 'px';
30809 if(this.labelWidth < 13 && this.labelmd == 0){
30810 this.labelmd = this.labelWidth;
30813 if(this.labellg > 0){
30814 labelCls = ' col-lg-' + this.labellg;
30815 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30818 if(this.labelmd > 0){
30819 labelCls = ' col-md-' + this.labelmd;
30820 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30823 if(this.labelsm > 0){
30824 labelCls = ' col-sm-' + this.labelsm;
30825 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30828 if(this.labelxs > 0){
30829 labelCls = ' col-xs-' + this.labelxs;
30830 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30834 label.cls += ' ' + labelCls;
30836 cfg.cn.push(label);
30839 Roo.each(['day', 'month', 'year'], function(t){
30842 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30849 inputEl: function ()
30851 return this.el.select('.roo-date-split-field-group-value', true).first();
30854 onRender : function(ct, position)
30858 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30860 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30862 this.dayField = new Roo.bootstrap.ComboBox({
30863 allowBlank : this.dayAllowBlank,
30864 alwaysQuery : true,
30865 displayField : 'value',
30868 forceSelection : true,
30870 placeholder : this.dayPlaceholder,
30871 selectOnFocus : true,
30872 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30873 triggerAction : 'all',
30875 valueField : 'value',
30876 store : new Roo.data.SimpleStore({
30877 data : (function() {
30879 _this.fireEvent('days', _this, days);
30882 fields : [ 'value' ]
30885 select : function (_self, record, index)
30887 _this.setValue(_this.getValue());
30892 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30894 this.monthField = new Roo.bootstrap.MonthField({
30895 after : '<i class=\"fa fa-calendar\"></i>',
30896 allowBlank : this.monthAllowBlank,
30897 placeholder : this.monthPlaceholder,
30900 render : function (_self)
30902 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30903 e.preventDefault();
30907 select : function (_self, oldvalue, newvalue)
30909 _this.setValue(_this.getValue());
30914 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30916 this.yearField = new Roo.bootstrap.ComboBox({
30917 allowBlank : this.yearAllowBlank,
30918 alwaysQuery : true,
30919 displayField : 'value',
30922 forceSelection : true,
30924 placeholder : this.yearPlaceholder,
30925 selectOnFocus : true,
30926 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30927 triggerAction : 'all',
30929 valueField : 'value',
30930 store : new Roo.data.SimpleStore({
30931 data : (function() {
30933 _this.fireEvent('years', _this, years);
30936 fields : [ 'value' ]
30939 select : function (_self, record, index)
30941 _this.setValue(_this.getValue());
30946 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30949 setValue : function(v, format)
30951 this.inputEl.dom.value = v;
30953 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30955 var d = Date.parseDate(v, f);
30962 this.setDay(d.format(this.dayFormat));
30963 this.setMonth(d.format(this.monthFormat));
30964 this.setYear(d.format(this.yearFormat));
30971 setDay : function(v)
30973 this.dayField.setValue(v);
30974 this.inputEl.dom.value = this.getValue();
30979 setMonth : function(v)
30981 this.monthField.setValue(v, true);
30982 this.inputEl.dom.value = this.getValue();
30987 setYear : function(v)
30989 this.yearField.setValue(v);
30990 this.inputEl.dom.value = this.getValue();
30995 getDay : function()
30997 return this.dayField.getValue();
31000 getMonth : function()
31002 return this.monthField.getValue();
31005 getYear : function()
31007 return this.yearField.getValue();
31010 getValue : function()
31012 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
31014 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
31024 this.inputEl.dom.value = '';
31029 validate : function()
31031 var d = this.dayField.validate();
31032 var m = this.monthField.validate();
31033 var y = this.yearField.validate();
31038 (!this.dayAllowBlank && !d) ||
31039 (!this.monthAllowBlank && !m) ||
31040 (!this.yearAllowBlank && !y)
31045 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31054 this.markInvalid();
31059 markValid : function()
31062 var label = this.el.select('label', true).first();
31063 var icon = this.el.select('i.fa-star', true).first();
31069 this.fireEvent('valid', this);
31073 * Mark this field as invalid
31074 * @param {String} msg The validation message
31076 markInvalid : function(msg)
31079 var label = this.el.select('label', true).first();
31080 var icon = this.el.select('i.fa-star', true).first();
31082 if(label && !icon){
31083 this.el.select('.roo-date-split-field-label', true).createChild({
31085 cls : 'text-danger fa fa-lg fa-star',
31086 tooltip : 'This field is required',
31087 style : 'margin-right:5px;'
31091 this.fireEvent('invalid', this, msg);
31094 clearInvalid : function()
31096 var label = this.el.select('label', true).first();
31097 var icon = this.el.select('i.fa-star', true).first();
31103 this.fireEvent('valid', this);
31106 getName: function()
31116 * http://masonry.desandro.com
31118 * The idea is to render all the bricks based on vertical width...
31120 * The original code extends 'outlayer' - we might need to use that....
31126 * @class Roo.bootstrap.LayoutMasonry
31127 * @extends Roo.bootstrap.Component
31128 * Bootstrap Layout Masonry class
31131 * Create a new Element
31132 * @param {Object} config The config object
31135 Roo.bootstrap.LayoutMasonry = function(config){
31137 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31141 Roo.bootstrap.LayoutMasonry.register(this);
31147 * Fire after layout the items
31148 * @param {Roo.bootstrap.LayoutMasonry} this
31149 * @param {Roo.EventObject} e
31156 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31159 * @cfg {Boolean} isLayoutInstant = no animation?
31161 isLayoutInstant : false, // needed?
31164 * @cfg {Number} boxWidth width of the columns
31169 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31174 * @cfg {Number} padWidth padding below box..
31179 * @cfg {Number} gutter gutter width..
31184 * @cfg {Number} maxCols maximum number of columns
31190 * @cfg {Boolean} isAutoInitial defalut true
31192 isAutoInitial : true,
31197 * @cfg {Boolean} isHorizontal defalut false
31199 isHorizontal : false,
31201 currentSize : null,
31207 bricks: null, //CompositeElement
31211 _isLayoutInited : false,
31213 // isAlternative : false, // only use for vertical layout...
31216 * @cfg {Number} alternativePadWidth padding below box..
31218 alternativePadWidth : 50,
31220 selectedBrick : [],
31222 getAutoCreate : function(){
31224 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31228 cls: 'blog-masonary-wrapper ' + this.cls,
31230 cls : 'mas-boxes masonary'
31237 getChildContainer: function( )
31239 if (this.boxesEl) {
31240 return this.boxesEl;
31243 this.boxesEl = this.el.select('.mas-boxes').first();
31245 return this.boxesEl;
31249 initEvents : function()
31253 if(this.isAutoInitial){
31254 Roo.log('hook children rendered');
31255 this.on('childrenrendered', function() {
31256 Roo.log('children rendered');
31262 initial : function()
31264 this.selectedBrick = [];
31266 this.currentSize = this.el.getBox(true);
31268 Roo.EventManager.onWindowResize(this.resize, this);
31270 if(!this.isAutoInitial){
31278 //this.layout.defer(500,this);
31282 resize : function()
31284 var cs = this.el.getBox(true);
31287 this.currentSize.width == cs.width &&
31288 this.currentSize.x == cs.x &&
31289 this.currentSize.height == cs.height &&
31290 this.currentSize.y == cs.y
31292 Roo.log("no change in with or X or Y");
31296 this.currentSize = cs;
31302 layout : function()
31304 this._resetLayout();
31306 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31308 this.layoutItems( isInstant );
31310 this._isLayoutInited = true;
31312 this.fireEvent('layout', this);
31316 _resetLayout : function()
31318 if(this.isHorizontal){
31319 this.horizontalMeasureColumns();
31323 this.verticalMeasureColumns();
31327 verticalMeasureColumns : function()
31329 this.getContainerWidth();
31331 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31332 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31336 var boxWidth = this.boxWidth + this.padWidth;
31338 if(this.containerWidth < this.boxWidth){
31339 boxWidth = this.containerWidth
31342 var containerWidth = this.containerWidth;
31344 var cols = Math.floor(containerWidth / boxWidth);
31346 this.cols = Math.max( cols, 1 );
31348 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31350 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31352 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31354 this.colWidth = boxWidth + avail - this.padWidth;
31356 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31357 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31360 horizontalMeasureColumns : function()
31362 this.getContainerWidth();
31364 var boxWidth = this.boxWidth;
31366 if(this.containerWidth < boxWidth){
31367 boxWidth = this.containerWidth;
31370 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31372 this.el.setHeight(boxWidth);
31376 getContainerWidth : function()
31378 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31381 layoutItems : function( isInstant )
31383 Roo.log(this.bricks);
31385 var items = Roo.apply([], this.bricks);
31387 if(this.isHorizontal){
31388 this._horizontalLayoutItems( items , isInstant );
31392 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31393 // this._verticalAlternativeLayoutItems( items , isInstant );
31397 this._verticalLayoutItems( items , isInstant );
31401 _verticalLayoutItems : function ( items , isInstant)
31403 if ( !items || !items.length ) {
31408 ['xs', 'xs', 'xs', 'tall'],
31409 ['xs', 'xs', 'tall'],
31410 ['xs', 'xs', 'sm'],
31411 ['xs', 'xs', 'xs'],
31417 ['sm', 'xs', 'xs'],
31421 ['tall', 'xs', 'xs', 'xs'],
31422 ['tall', 'xs', 'xs'],
31434 Roo.each(items, function(item, k){
31436 switch (item.size) {
31437 // these layouts take up a full box,
31448 boxes.push([item]);
31471 var filterPattern = function(box, length)
31479 var pattern = box.slice(0, length);
31483 Roo.each(pattern, function(i){
31484 format.push(i.size);
31487 Roo.each(standard, function(s){
31489 if(String(s) != String(format)){
31498 if(!match && length == 1){
31503 filterPattern(box, length - 1);
31507 queue.push(pattern);
31509 box = box.slice(length, box.length);
31511 filterPattern(box, 4);
31517 Roo.each(boxes, function(box, k){
31523 if(box.length == 1){
31528 filterPattern(box, 4);
31532 this._processVerticalLayoutQueue( queue, isInstant );
31536 // _verticalAlternativeLayoutItems : function( items , isInstant )
31538 // if ( !items || !items.length ) {
31542 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31546 _horizontalLayoutItems : function ( items , isInstant)
31548 if ( !items || !items.length || items.length < 3) {
31554 var eItems = items.slice(0, 3);
31556 items = items.slice(3, items.length);
31559 ['xs', 'xs', 'xs', 'wide'],
31560 ['xs', 'xs', 'wide'],
31561 ['xs', 'xs', 'sm'],
31562 ['xs', 'xs', 'xs'],
31568 ['sm', 'xs', 'xs'],
31572 ['wide', 'xs', 'xs', 'xs'],
31573 ['wide', 'xs', 'xs'],
31586 Roo.each(items, function(item, k){
31588 switch (item.size) {
31599 boxes.push([item]);
31623 var filterPattern = function(box, length)
31631 var pattern = box.slice(0, length);
31635 Roo.each(pattern, function(i){
31636 format.push(i.size);
31639 Roo.each(standard, function(s){
31641 if(String(s) != String(format)){
31650 if(!match && length == 1){
31655 filterPattern(box, length - 1);
31659 queue.push(pattern);
31661 box = box.slice(length, box.length);
31663 filterPattern(box, 4);
31669 Roo.each(boxes, function(box, k){
31675 if(box.length == 1){
31680 filterPattern(box, 4);
31687 var pos = this.el.getBox(true);
31691 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31693 var hit_end = false;
31695 Roo.each(queue, function(box){
31699 Roo.each(box, function(b){
31701 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31711 Roo.each(box, function(b){
31713 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31716 mx = Math.max(mx, b.x);
31720 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31724 Roo.each(box, function(b){
31726 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31740 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31743 /** Sets position of item in DOM
31744 * @param {Element} item
31745 * @param {Number} x - horizontal position
31746 * @param {Number} y - vertical position
31747 * @param {Boolean} isInstant - disables transitions
31749 _processVerticalLayoutQueue : function( queue, isInstant )
31751 var pos = this.el.getBox(true);
31756 for (var i = 0; i < this.cols; i++){
31760 Roo.each(queue, function(box, k){
31762 var col = k % this.cols;
31764 Roo.each(box, function(b,kk){
31766 b.el.position('absolute');
31768 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31769 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31771 if(b.size == 'md-left' || b.size == 'md-right'){
31772 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31773 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31776 b.el.setWidth(width);
31777 b.el.setHeight(height);
31779 b.el.select('iframe',true).setSize(width,height);
31783 for (var i = 0; i < this.cols; i++){
31785 if(maxY[i] < maxY[col]){
31790 col = Math.min(col, i);
31794 x = pos.x + col * (this.colWidth + this.padWidth);
31798 var positions = [];
31800 switch (box.length){
31802 positions = this.getVerticalOneBoxColPositions(x, y, box);
31805 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31808 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31811 positions = this.getVerticalFourBoxColPositions(x, y, box);
31817 Roo.each(box, function(b,kk){
31819 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31821 var sz = b.el.getSize();
31823 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31831 for (var i = 0; i < this.cols; i++){
31832 mY = Math.max(mY, maxY[i]);
31835 this.el.setHeight(mY - pos.y);
31839 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31841 // var pos = this.el.getBox(true);
31844 // var maxX = pos.right;
31846 // var maxHeight = 0;
31848 // Roo.each(items, function(item, k){
31852 // item.el.position('absolute');
31854 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31856 // item.el.setWidth(width);
31858 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31860 // item.el.setHeight(height);
31863 // item.el.setXY([x, y], isInstant ? false : true);
31865 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31868 // y = y + height + this.alternativePadWidth;
31870 // maxHeight = maxHeight + height + this.alternativePadWidth;
31874 // this.el.setHeight(maxHeight);
31878 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31880 var pos = this.el.getBox(true);
31885 var maxX = pos.right;
31887 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31889 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31891 Roo.each(queue, function(box, k){
31893 Roo.each(box, function(b, kk){
31895 b.el.position('absolute');
31897 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31898 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31900 if(b.size == 'md-left' || b.size == 'md-right'){
31901 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31902 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31905 b.el.setWidth(width);
31906 b.el.setHeight(height);
31914 var positions = [];
31916 switch (box.length){
31918 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31921 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31924 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31927 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31933 Roo.each(box, function(b,kk){
31935 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31937 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31945 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31947 Roo.each(eItems, function(b,k){
31949 b.size = (k == 0) ? 'sm' : 'xs';
31950 b.x = (k == 0) ? 2 : 1;
31951 b.y = (k == 0) ? 2 : 1;
31953 b.el.position('absolute');
31955 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31957 b.el.setWidth(width);
31959 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31961 b.el.setHeight(height);
31965 var positions = [];
31968 x : maxX - this.unitWidth * 2 - this.gutter,
31973 x : maxX - this.unitWidth,
31974 y : minY + (this.unitWidth + this.gutter) * 2
31978 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31982 Roo.each(eItems, function(b,k){
31984 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31990 getVerticalOneBoxColPositions : function(x, y, box)
31994 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31996 if(box[0].size == 'md-left'){
32000 if(box[0].size == 'md-right'){
32005 x : x + (this.unitWidth + this.gutter) * rand,
32012 getVerticalTwoBoxColPositions : function(x, y, box)
32016 if(box[0].size == 'xs'){
32020 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
32024 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32038 x : x + (this.unitWidth + this.gutter) * 2,
32039 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32046 getVerticalThreeBoxColPositions : function(x, y, box)
32050 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32058 x : x + (this.unitWidth + this.gutter) * 1,
32063 x : x + (this.unitWidth + this.gutter) * 2,
32071 if(box[0].size == 'xs' && box[1].size == 'xs'){
32080 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32084 x : x + (this.unitWidth + this.gutter) * 1,
32098 x : x + (this.unitWidth + this.gutter) * 2,
32103 x : x + (this.unitWidth + this.gutter) * 2,
32104 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32111 getVerticalFourBoxColPositions : function(x, y, box)
32115 if(box[0].size == 'xs'){
32124 y : y + (this.unitHeight + this.gutter) * 1
32129 y : y + (this.unitHeight + this.gutter) * 2
32133 x : x + (this.unitWidth + this.gutter) * 1,
32147 x : x + (this.unitWidth + this.gutter) * 2,
32152 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32153 y : y + (this.unitHeight + this.gutter) * 1
32157 x : x + (this.unitWidth + this.gutter) * 2,
32158 y : y + (this.unitWidth + this.gutter) * 2
32165 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32169 if(box[0].size == 'md-left'){
32171 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32178 if(box[0].size == 'md-right'){
32180 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32181 y : minY + (this.unitWidth + this.gutter) * 1
32187 var rand = Math.floor(Math.random() * (4 - box[0].y));
32190 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32191 y : minY + (this.unitWidth + this.gutter) * rand
32198 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32202 if(box[0].size == 'xs'){
32205 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32210 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32211 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32219 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32224 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32225 y : minY + (this.unitWidth + this.gutter) * 2
32232 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32236 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32239 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32244 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32245 y : minY + (this.unitWidth + this.gutter) * 1
32249 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32250 y : minY + (this.unitWidth + this.gutter) * 2
32257 if(box[0].size == 'xs' && box[1].size == 'xs'){
32260 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32265 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32270 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32271 y : minY + (this.unitWidth + this.gutter) * 1
32279 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32284 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32285 y : minY + (this.unitWidth + this.gutter) * 2
32289 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32290 y : minY + (this.unitWidth + this.gutter) * 2
32297 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32301 if(box[0].size == 'xs'){
32304 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32309 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32314 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),
32319 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32320 y : minY + (this.unitWidth + this.gutter) * 1
32328 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32333 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32334 y : minY + (this.unitWidth + this.gutter) * 2
32338 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32339 y : minY + (this.unitWidth + this.gutter) * 2
32343 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),
32344 y : minY + (this.unitWidth + this.gutter) * 2
32352 * remove a Masonry Brick
32353 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32355 removeBrick : function(brick_id)
32361 for (var i = 0; i<this.bricks.length; i++) {
32362 if (this.bricks[i].id == brick_id) {
32363 this.bricks.splice(i,1);
32364 this.el.dom.removeChild(Roo.get(brick_id).dom);
32371 * adds a Masonry Brick
32372 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32374 addBrick : function(cfg)
32376 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32377 //this.register(cn);
32378 cn.parentId = this.id;
32379 cn.render(this.el);
32384 * register a Masonry Brick
32385 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32388 register : function(brick)
32390 this.bricks.push(brick);
32391 brick.masonryId = this.id;
32395 * clear all the Masonry Brick
32397 clearAll : function()
32400 //this.getChildContainer().dom.innerHTML = "";
32401 this.el.dom.innerHTML = '';
32404 getSelected : function()
32406 if (!this.selectedBrick) {
32410 return this.selectedBrick;
32414 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32418 * register a Masonry Layout
32419 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32422 register : function(layout)
32424 this.groups[layout.id] = layout;
32427 * fetch a Masonry Layout based on the masonry layout ID
32428 * @param {string} the masonry layout to add
32429 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32432 get: function(layout_id) {
32433 if (typeof(this.groups[layout_id]) == 'undefined') {
32436 return this.groups[layout_id] ;
32448 * http://masonry.desandro.com
32450 * The idea is to render all the bricks based on vertical width...
32452 * The original code extends 'outlayer' - we might need to use that....
32458 * @class Roo.bootstrap.LayoutMasonryAuto
32459 * @extends Roo.bootstrap.Component
32460 * Bootstrap Layout Masonry class
32463 * Create a new Element
32464 * @param {Object} config The config object
32467 Roo.bootstrap.LayoutMasonryAuto = function(config){
32468 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32471 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32474 * @cfg {Boolean} isFitWidth - resize the width..
32476 isFitWidth : false, // options..
32478 * @cfg {Boolean} isOriginLeft = left align?
32480 isOriginLeft : true,
32482 * @cfg {Boolean} isOriginTop = top align?
32484 isOriginTop : false,
32486 * @cfg {Boolean} isLayoutInstant = no animation?
32488 isLayoutInstant : false, // needed?
32490 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32492 isResizingContainer : true,
32494 * @cfg {Number} columnWidth width of the columns
32500 * @cfg {Number} maxCols maximum number of columns
32505 * @cfg {Number} padHeight padding below box..
32511 * @cfg {Boolean} isAutoInitial defalut true
32514 isAutoInitial : true,
32520 initialColumnWidth : 0,
32521 currentSize : null,
32523 colYs : null, // array.
32530 bricks: null, //CompositeElement
32531 cols : 0, // array?
32532 // element : null, // wrapped now this.el
32533 _isLayoutInited : null,
32536 getAutoCreate : function(){
32540 cls: 'blog-masonary-wrapper ' + this.cls,
32542 cls : 'mas-boxes masonary'
32549 getChildContainer: function( )
32551 if (this.boxesEl) {
32552 return this.boxesEl;
32555 this.boxesEl = this.el.select('.mas-boxes').first();
32557 return this.boxesEl;
32561 initEvents : function()
32565 if(this.isAutoInitial){
32566 Roo.log('hook children rendered');
32567 this.on('childrenrendered', function() {
32568 Roo.log('children rendered');
32575 initial : function()
32577 this.reloadItems();
32579 this.currentSize = this.el.getBox(true);
32581 /// was window resize... - let's see if this works..
32582 Roo.EventManager.onWindowResize(this.resize, this);
32584 if(!this.isAutoInitial){
32589 this.layout.defer(500,this);
32592 reloadItems: function()
32594 this.bricks = this.el.select('.masonry-brick', true);
32596 this.bricks.each(function(b) {
32597 //Roo.log(b.getSize());
32598 if (!b.attr('originalwidth')) {
32599 b.attr('originalwidth', b.getSize().width);
32604 Roo.log(this.bricks.elements.length);
32607 resize : function()
32610 var cs = this.el.getBox(true);
32612 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32613 Roo.log("no change in with or X");
32616 this.currentSize = cs;
32620 layout : function()
32623 this._resetLayout();
32624 //this._manageStamps();
32626 // don't animate first layout
32627 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32628 this.layoutItems( isInstant );
32630 // flag for initalized
32631 this._isLayoutInited = true;
32634 layoutItems : function( isInstant )
32636 //var items = this._getItemsForLayout( this.items );
32637 // original code supports filtering layout items.. we just ignore it..
32639 this._layoutItems( this.bricks , isInstant );
32641 this._postLayout();
32643 _layoutItems : function ( items , isInstant)
32645 //this.fireEvent( 'layout', this, items );
32648 if ( !items || !items.elements.length ) {
32649 // no items, emit event with empty array
32654 items.each(function(item) {
32655 Roo.log("layout item");
32657 // get x/y object from method
32658 var position = this._getItemLayoutPosition( item );
32660 position.item = item;
32661 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32662 queue.push( position );
32665 this._processLayoutQueue( queue );
32667 /** Sets position of item in DOM
32668 * @param {Element} item
32669 * @param {Number} x - horizontal position
32670 * @param {Number} y - vertical position
32671 * @param {Boolean} isInstant - disables transitions
32673 _processLayoutQueue : function( queue )
32675 for ( var i=0, len = queue.length; i < len; i++ ) {
32676 var obj = queue[i];
32677 obj.item.position('absolute');
32678 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32684 * Any logic you want to do after each layout,
32685 * i.e. size the container
32687 _postLayout : function()
32689 this.resizeContainer();
32692 resizeContainer : function()
32694 if ( !this.isResizingContainer ) {
32697 var size = this._getContainerSize();
32699 this.el.setSize(size.width,size.height);
32700 this.boxesEl.setSize(size.width,size.height);
32706 _resetLayout : function()
32708 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32709 this.colWidth = this.el.getWidth();
32710 //this.gutter = this.el.getWidth();
32712 this.measureColumns();
32718 this.colYs.push( 0 );
32724 measureColumns : function()
32726 this.getContainerWidth();
32727 // if columnWidth is 0, default to outerWidth of first item
32728 if ( !this.columnWidth ) {
32729 var firstItem = this.bricks.first();
32730 Roo.log(firstItem);
32731 this.columnWidth = this.containerWidth;
32732 if (firstItem && firstItem.attr('originalwidth') ) {
32733 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32735 // columnWidth fall back to item of first element
32736 Roo.log("set column width?");
32737 this.initialColumnWidth = this.columnWidth ;
32739 // if first elem has no width, default to size of container
32744 if (this.initialColumnWidth) {
32745 this.columnWidth = this.initialColumnWidth;
32750 // column width is fixed at the top - however if container width get's smaller we should
32753 // this bit calcs how man columns..
32755 var columnWidth = this.columnWidth += this.gutter;
32757 // calculate columns
32758 var containerWidth = this.containerWidth + this.gutter;
32760 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32761 // fix rounding errors, typically with gutters
32762 var excess = columnWidth - containerWidth % columnWidth;
32765 // if overshoot is less than a pixel, round up, otherwise floor it
32766 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32767 cols = Math[ mathMethod ]( cols );
32768 this.cols = Math.max( cols, 1 );
32769 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32771 // padding positioning..
32772 var totalColWidth = this.cols * this.columnWidth;
32773 var padavail = this.containerWidth - totalColWidth;
32774 // so for 2 columns - we need 3 'pads'
32776 var padNeeded = (1+this.cols) * this.padWidth;
32778 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32780 this.columnWidth += padExtra
32781 //this.padWidth = Math.floor(padavail / ( this.cols));
32783 // adjust colum width so that padding is fixed??
32785 // we have 3 columns ... total = width * 3
32786 // we have X left over... that should be used by
32788 //if (this.expandC) {
32796 getContainerWidth : function()
32798 /* // container is parent if fit width
32799 var container = this.isFitWidth ? this.element.parentNode : this.element;
32800 // check that this.size and size are there
32801 // IE8 triggers resize on body size change, so they might not be
32803 var size = getSize( container ); //FIXME
32804 this.containerWidth = size && size.innerWidth; //FIXME
32807 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32811 _getItemLayoutPosition : function( item ) // what is item?
32813 // we resize the item to our columnWidth..
32815 item.setWidth(this.columnWidth);
32816 item.autoBoxAdjust = false;
32818 var sz = item.getSize();
32820 // how many columns does this brick span
32821 var remainder = this.containerWidth % this.columnWidth;
32823 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32824 // round if off by 1 pixel, otherwise use ceil
32825 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32826 colSpan = Math.min( colSpan, this.cols );
32828 // normally this should be '1' as we dont' currently allow multi width columns..
32830 var colGroup = this._getColGroup( colSpan );
32831 // get the minimum Y value from the columns
32832 var minimumY = Math.min.apply( Math, colGroup );
32833 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32835 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32837 // position the brick
32839 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32840 y: this.currentSize.y + minimumY + this.padHeight
32844 // apply setHeight to necessary columns
32845 var setHeight = minimumY + sz.height + this.padHeight;
32846 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32848 var setSpan = this.cols + 1 - colGroup.length;
32849 for ( var i = 0; i < setSpan; i++ ) {
32850 this.colYs[ shortColIndex + i ] = setHeight ;
32857 * @param {Number} colSpan - number of columns the element spans
32858 * @returns {Array} colGroup
32860 _getColGroup : function( colSpan )
32862 if ( colSpan < 2 ) {
32863 // if brick spans only one column, use all the column Ys
32868 // how many different places could this brick fit horizontally
32869 var groupCount = this.cols + 1 - colSpan;
32870 // for each group potential horizontal position
32871 for ( var i = 0; i < groupCount; i++ ) {
32872 // make an array of colY values for that one group
32873 var groupColYs = this.colYs.slice( i, i + colSpan );
32874 // and get the max value of the array
32875 colGroup[i] = Math.max.apply( Math, groupColYs );
32880 _manageStamp : function( stamp )
32882 var stampSize = stamp.getSize();
32883 var offset = stamp.getBox();
32884 // get the columns that this stamp affects
32885 var firstX = this.isOriginLeft ? offset.x : offset.right;
32886 var lastX = firstX + stampSize.width;
32887 var firstCol = Math.floor( firstX / this.columnWidth );
32888 firstCol = Math.max( 0, firstCol );
32890 var lastCol = Math.floor( lastX / this.columnWidth );
32891 // lastCol should not go over if multiple of columnWidth #425
32892 lastCol -= lastX % this.columnWidth ? 0 : 1;
32893 lastCol = Math.min( this.cols - 1, lastCol );
32895 // set colYs to bottom of the stamp
32896 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32899 for ( var i = firstCol; i <= lastCol; i++ ) {
32900 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32905 _getContainerSize : function()
32907 this.maxY = Math.max.apply( Math, this.colYs );
32912 if ( this.isFitWidth ) {
32913 size.width = this._getContainerFitWidth();
32919 _getContainerFitWidth : function()
32921 var unusedCols = 0;
32922 // count unused columns
32925 if ( this.colYs[i] !== 0 ) {
32930 // fit container to columns that have been used
32931 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32934 needsResizeLayout : function()
32936 var previousWidth = this.containerWidth;
32937 this.getContainerWidth();
32938 return previousWidth !== this.containerWidth;
32953 * @class Roo.bootstrap.MasonryBrick
32954 * @extends Roo.bootstrap.Component
32955 * Bootstrap MasonryBrick class
32958 * Create a new MasonryBrick
32959 * @param {Object} config The config object
32962 Roo.bootstrap.MasonryBrick = function(config){
32964 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32966 Roo.bootstrap.MasonryBrick.register(this);
32972 * When a MasonryBrick is clcik
32973 * @param {Roo.bootstrap.MasonryBrick} this
32974 * @param {Roo.EventObject} e
32980 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32983 * @cfg {String} title
32987 * @cfg {String} html
32991 * @cfg {String} bgimage
32995 * @cfg {String} videourl
32999 * @cfg {String} cls
33003 * @cfg {String} href
33007 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
33012 * @cfg {String} placetitle (center|bottom)
33017 * @cfg {Boolean} isFitContainer defalut true
33019 isFitContainer : true,
33022 * @cfg {Boolean} preventDefault defalut false
33024 preventDefault : false,
33027 * @cfg {Boolean} inverse defalut false
33029 maskInverse : false,
33031 getAutoCreate : function()
33033 if(!this.isFitContainer){
33034 return this.getSplitAutoCreate();
33037 var cls = 'masonry-brick masonry-brick-full';
33039 if(this.href.length){
33040 cls += ' masonry-brick-link';
33043 if(this.bgimage.length){
33044 cls += ' masonry-brick-image';
33047 if(this.maskInverse){
33048 cls += ' mask-inverse';
33051 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33052 cls += ' enable-mask';
33056 cls += ' masonry-' + this.size + '-brick';
33059 if(this.placetitle.length){
33061 switch (this.placetitle) {
33063 cls += ' masonry-center-title';
33066 cls += ' masonry-bottom-title';
33073 if(!this.html.length && !this.bgimage.length){
33074 cls += ' masonry-center-title';
33077 if(!this.html.length && this.bgimage.length){
33078 cls += ' masonry-bottom-title';
33083 cls += ' ' + this.cls;
33087 tag: (this.href.length) ? 'a' : 'div',
33092 cls: 'masonry-brick-mask'
33096 cls: 'masonry-brick-paragraph',
33102 if(this.href.length){
33103 cfg.href = this.href;
33106 var cn = cfg.cn[1].cn;
33108 if(this.title.length){
33111 cls: 'masonry-brick-title',
33116 if(this.html.length){
33119 cls: 'masonry-brick-text',
33124 if (!this.title.length && !this.html.length) {
33125 cfg.cn[1].cls += ' hide';
33128 if(this.bgimage.length){
33131 cls: 'masonry-brick-image-view',
33136 if(this.videourl.length){
33137 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33138 // youtube support only?
33141 cls: 'masonry-brick-image-view',
33144 allowfullscreen : true
33152 getSplitAutoCreate : function()
33154 var cls = 'masonry-brick masonry-brick-split';
33156 if(this.href.length){
33157 cls += ' masonry-brick-link';
33160 if(this.bgimage.length){
33161 cls += ' masonry-brick-image';
33165 cls += ' masonry-' + this.size + '-brick';
33168 switch (this.placetitle) {
33170 cls += ' masonry-center-title';
33173 cls += ' masonry-bottom-title';
33176 if(!this.bgimage.length){
33177 cls += ' masonry-center-title';
33180 if(this.bgimage.length){
33181 cls += ' masonry-bottom-title';
33187 cls += ' ' + this.cls;
33191 tag: (this.href.length) ? 'a' : 'div',
33196 cls: 'masonry-brick-split-head',
33200 cls: 'masonry-brick-paragraph',
33207 cls: 'masonry-brick-split-body',
33213 if(this.href.length){
33214 cfg.href = this.href;
33217 if(this.title.length){
33218 cfg.cn[0].cn[0].cn.push({
33220 cls: 'masonry-brick-title',
33225 if(this.html.length){
33226 cfg.cn[1].cn.push({
33228 cls: 'masonry-brick-text',
33233 if(this.bgimage.length){
33234 cfg.cn[0].cn.push({
33236 cls: 'masonry-brick-image-view',
33241 if(this.videourl.length){
33242 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33243 // youtube support only?
33244 cfg.cn[0].cn.cn.push({
33246 cls: 'masonry-brick-image-view',
33249 allowfullscreen : true
33256 initEvents: function()
33258 switch (this.size) {
33291 this.el.on('touchstart', this.onTouchStart, this);
33292 this.el.on('touchmove', this.onTouchMove, this);
33293 this.el.on('touchend', this.onTouchEnd, this);
33294 this.el.on('contextmenu', this.onContextMenu, this);
33296 this.el.on('mouseenter' ,this.enter, this);
33297 this.el.on('mouseleave', this.leave, this);
33298 this.el.on('click', this.onClick, this);
33301 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33302 this.parent().bricks.push(this);
33307 onClick: function(e, el)
33309 var time = this.endTimer - this.startTimer;
33310 // Roo.log(e.preventDefault());
33313 e.preventDefault();
33318 if(!this.preventDefault){
33322 e.preventDefault();
33324 if (this.activeClass != '') {
33325 this.selectBrick();
33328 this.fireEvent('click', this, e);
33331 enter: function(e, el)
33333 e.preventDefault();
33335 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33339 if(this.bgimage.length && this.html.length){
33340 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33344 leave: function(e, el)
33346 e.preventDefault();
33348 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33352 if(this.bgimage.length && this.html.length){
33353 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33357 onTouchStart: function(e, el)
33359 // e.preventDefault();
33361 this.touchmoved = false;
33363 if(!this.isFitContainer){
33367 if(!this.bgimage.length || !this.html.length){
33371 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33373 this.timer = new Date().getTime();
33377 onTouchMove: function(e, el)
33379 this.touchmoved = true;
33382 onContextMenu : function(e,el)
33384 e.preventDefault();
33385 e.stopPropagation();
33389 onTouchEnd: function(e, el)
33391 // e.preventDefault();
33393 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33400 if(!this.bgimage.length || !this.html.length){
33402 if(this.href.length){
33403 window.location.href = this.href;
33409 if(!this.isFitContainer){
33413 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33415 window.location.href = this.href;
33418 //selection on single brick only
33419 selectBrick : function() {
33421 if (!this.parentId) {
33425 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33426 var index = m.selectedBrick.indexOf(this.id);
33429 m.selectedBrick.splice(index,1);
33430 this.el.removeClass(this.activeClass);
33434 for(var i = 0; i < m.selectedBrick.length; i++) {
33435 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33436 b.el.removeClass(b.activeClass);
33439 m.selectedBrick = [];
33441 m.selectedBrick.push(this.id);
33442 this.el.addClass(this.activeClass);
33446 isSelected : function(){
33447 return this.el.hasClass(this.activeClass);
33452 Roo.apply(Roo.bootstrap.MasonryBrick, {
33455 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33457 * register a Masonry Brick
33458 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33461 register : function(brick)
33463 //this.groups[brick.id] = brick;
33464 this.groups.add(brick.id, brick);
33467 * fetch a masonry brick based on the masonry brick ID
33468 * @param {string} the masonry brick to add
33469 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33472 get: function(brick_id)
33474 // if (typeof(this.groups[brick_id]) == 'undefined') {
33477 // return this.groups[brick_id] ;
33479 if(this.groups.key(brick_id)) {
33480 return this.groups.key(brick_id);
33498 * @class Roo.bootstrap.Brick
33499 * @extends Roo.bootstrap.Component
33500 * Bootstrap Brick class
33503 * Create a new Brick
33504 * @param {Object} config The config object
33507 Roo.bootstrap.Brick = function(config){
33508 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33514 * When a Brick is click
33515 * @param {Roo.bootstrap.Brick} this
33516 * @param {Roo.EventObject} e
33522 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33525 * @cfg {String} title
33529 * @cfg {String} html
33533 * @cfg {String} bgimage
33537 * @cfg {String} cls
33541 * @cfg {String} href
33545 * @cfg {String} video
33549 * @cfg {Boolean} square
33553 getAutoCreate : function()
33555 var cls = 'roo-brick';
33557 if(this.href.length){
33558 cls += ' roo-brick-link';
33561 if(this.bgimage.length){
33562 cls += ' roo-brick-image';
33565 if(!this.html.length && !this.bgimage.length){
33566 cls += ' roo-brick-center-title';
33569 if(!this.html.length && this.bgimage.length){
33570 cls += ' roo-brick-bottom-title';
33574 cls += ' ' + this.cls;
33578 tag: (this.href.length) ? 'a' : 'div',
33583 cls: 'roo-brick-paragraph',
33589 if(this.href.length){
33590 cfg.href = this.href;
33593 var cn = cfg.cn[0].cn;
33595 if(this.title.length){
33598 cls: 'roo-brick-title',
33603 if(this.html.length){
33606 cls: 'roo-brick-text',
33613 if(this.bgimage.length){
33616 cls: 'roo-brick-image-view',
33624 initEvents: function()
33626 if(this.title.length || this.html.length){
33627 this.el.on('mouseenter' ,this.enter, this);
33628 this.el.on('mouseleave', this.leave, this);
33631 Roo.EventManager.onWindowResize(this.resize, this);
33633 if(this.bgimage.length){
33634 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33635 this.imageEl.on('load', this.onImageLoad, this);
33642 onImageLoad : function()
33647 resize : function()
33649 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33651 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33653 if(this.bgimage.length){
33654 var image = this.el.select('.roo-brick-image-view', true).first();
33656 image.setWidth(paragraph.getWidth());
33659 image.setHeight(paragraph.getWidth());
33662 this.el.setHeight(image.getHeight());
33663 paragraph.setHeight(image.getHeight());
33669 enter: function(e, el)
33671 e.preventDefault();
33673 if(this.bgimage.length){
33674 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33675 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33679 leave: function(e, el)
33681 e.preventDefault();
33683 if(this.bgimage.length){
33684 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33685 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33700 * @class Roo.bootstrap.NumberField
33701 * @extends Roo.bootstrap.Input
33702 * Bootstrap NumberField class
33708 * Create a new NumberField
33709 * @param {Object} config The config object
33712 Roo.bootstrap.NumberField = function(config){
33713 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33716 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33719 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33721 allowDecimals : true,
33723 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33725 decimalSeparator : ".",
33727 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33729 decimalPrecision : 2,
33731 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33733 allowNegative : true,
33736 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33740 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33742 minValue : Number.NEGATIVE_INFINITY,
33744 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33746 maxValue : Number.MAX_VALUE,
33748 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33750 minText : "The minimum value for this field is {0}",
33752 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33754 maxText : "The maximum value for this field is {0}",
33756 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33757 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33759 nanText : "{0} is not a valid number",
33761 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33763 thousandsDelimiter : false,
33765 * @cfg {String} valueAlign alignment of value
33767 valueAlign : "left",
33769 getAutoCreate : function()
33771 var hiddenInput = {
33775 cls: 'hidden-number-input'
33779 hiddenInput.name = this.name;
33784 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33786 this.name = hiddenInput.name;
33788 if(cfg.cn.length > 0) {
33789 cfg.cn.push(hiddenInput);
33796 initEvents : function()
33798 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33800 var allowed = "0123456789";
33802 if(this.allowDecimals){
33803 allowed += this.decimalSeparator;
33806 if(this.allowNegative){
33810 if(this.thousandsDelimiter) {
33814 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33816 var keyPress = function(e){
33818 var k = e.getKey();
33820 var c = e.getCharCode();
33823 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33824 allowed.indexOf(String.fromCharCode(c)) === -1
33830 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33834 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33839 this.el.on("keypress", keyPress, this);
33842 validateValue : function(value)
33845 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33849 var num = this.parseValue(value);
33852 this.markInvalid(String.format(this.nanText, value));
33856 if(num < this.minValue){
33857 this.markInvalid(String.format(this.minText, this.minValue));
33861 if(num > this.maxValue){
33862 this.markInvalid(String.format(this.maxText, this.maxValue));
33869 getValue : function()
33871 var v = this.hiddenEl().getValue();
33873 return this.fixPrecision(this.parseValue(v));
33876 parseValue : function(value)
33878 if(this.thousandsDelimiter) {
33880 r = new RegExp(",", "g");
33881 value = value.replace(r, "");
33884 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33885 return isNaN(value) ? '' : value;
33888 fixPrecision : function(value)
33890 if(this.thousandsDelimiter) {
33892 r = new RegExp(",", "g");
33893 value = value.replace(r, "");
33896 var nan = isNaN(value);
33898 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33899 return nan ? '' : value;
33901 return parseFloat(value).toFixed(this.decimalPrecision);
33904 setValue : function(v)
33906 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33912 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33914 this.inputEl().dom.value = (v == '') ? '' :
33915 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33917 if(!this.allowZero && v === '0') {
33918 this.hiddenEl().dom.value = '';
33919 this.inputEl().dom.value = '';
33926 decimalPrecisionFcn : function(v)
33928 return Math.floor(v);
33931 beforeBlur : function()
33933 var v = this.parseValue(this.getRawValue());
33935 if(v || v === 0 || v === ''){
33940 hiddenEl : function()
33942 return this.el.select('input.hidden-number-input',true).first();
33954 * @class Roo.bootstrap.DocumentSlider
33955 * @extends Roo.bootstrap.Component
33956 * Bootstrap DocumentSlider class
33959 * Create a new DocumentViewer
33960 * @param {Object} config The config object
33963 Roo.bootstrap.DocumentSlider = function(config){
33964 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33971 * Fire after initEvent
33972 * @param {Roo.bootstrap.DocumentSlider} this
33977 * Fire after update
33978 * @param {Roo.bootstrap.DocumentSlider} this
33984 * @param {Roo.bootstrap.DocumentSlider} this
33990 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33996 getAutoCreate : function()
34000 cls : 'roo-document-slider',
34004 cls : 'roo-document-slider-header',
34008 cls : 'roo-document-slider-header-title'
34014 cls : 'roo-document-slider-body',
34018 cls : 'roo-document-slider-prev',
34022 cls : 'fa fa-chevron-left'
34028 cls : 'roo-document-slider-thumb',
34032 cls : 'roo-document-slider-image'
34038 cls : 'roo-document-slider-next',
34042 cls : 'fa fa-chevron-right'
34054 initEvents : function()
34056 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34057 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34059 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34060 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34062 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34063 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34065 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34066 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34068 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34069 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34071 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34072 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34074 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34075 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34077 this.thumbEl.on('click', this.onClick, this);
34079 this.prevIndicator.on('click', this.prev, this);
34081 this.nextIndicator.on('click', this.next, this);
34085 initial : function()
34087 if(this.files.length){
34088 this.indicator = 1;
34092 this.fireEvent('initial', this);
34095 update : function()
34097 this.imageEl.attr('src', this.files[this.indicator - 1]);
34099 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34101 this.prevIndicator.show();
34103 if(this.indicator == 1){
34104 this.prevIndicator.hide();
34107 this.nextIndicator.show();
34109 if(this.indicator == this.files.length){
34110 this.nextIndicator.hide();
34113 this.thumbEl.scrollTo('top');
34115 this.fireEvent('update', this);
34118 onClick : function(e)
34120 e.preventDefault();
34122 this.fireEvent('click', this);
34127 e.preventDefault();
34129 this.indicator = Math.max(1, this.indicator - 1);
34136 e.preventDefault();
34138 this.indicator = Math.min(this.files.length, this.indicator + 1);
34152 * @class Roo.bootstrap.RadioSet
34153 * @extends Roo.bootstrap.Input
34154 * Bootstrap RadioSet class
34155 * @cfg {String} indicatorpos (left|right) default left
34156 * @cfg {Boolean} inline (true|false) inline the element (default true)
34157 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34159 * Create a new RadioSet
34160 * @param {Object} config The config object
34163 Roo.bootstrap.RadioSet = function(config){
34165 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34169 Roo.bootstrap.RadioSet.register(this);
34174 * Fires when the element is checked or unchecked.
34175 * @param {Roo.bootstrap.RadioSet} this This radio
34176 * @param {Roo.bootstrap.Radio} item The checked item
34181 * Fires when the element is click.
34182 * @param {Roo.bootstrap.RadioSet} this This radio set
34183 * @param {Roo.bootstrap.Radio} item The checked item
34184 * @param {Roo.EventObject} e The event object
34191 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34199 indicatorpos : 'left',
34201 getAutoCreate : function()
34205 cls : 'roo-radio-set-label',
34209 html : this.fieldLabel
34213 if (Roo.bootstrap.version == 3) {
34216 if(this.indicatorpos == 'left'){
34219 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34220 tooltip : 'This field is required'
34225 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34226 tooltip : 'This field is required'
34232 cls : 'roo-radio-set-items'
34235 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34237 if (align === 'left' && this.fieldLabel.length) {
34240 cls : "roo-radio-set-right",
34246 if(this.labelWidth > 12){
34247 label.style = "width: " + this.labelWidth + 'px';
34250 if(this.labelWidth < 13 && this.labelmd == 0){
34251 this.labelmd = this.labelWidth;
34254 if(this.labellg > 0){
34255 label.cls += ' col-lg-' + this.labellg;
34256 items.cls += ' col-lg-' + (12 - this.labellg);
34259 if(this.labelmd > 0){
34260 label.cls += ' col-md-' + this.labelmd;
34261 items.cls += ' col-md-' + (12 - this.labelmd);
34264 if(this.labelsm > 0){
34265 label.cls += ' col-sm-' + this.labelsm;
34266 items.cls += ' col-sm-' + (12 - this.labelsm);
34269 if(this.labelxs > 0){
34270 label.cls += ' col-xs-' + this.labelxs;
34271 items.cls += ' col-xs-' + (12 - this.labelxs);
34277 cls : 'roo-radio-set',
34281 cls : 'roo-radio-set-input',
34284 value : this.value ? this.value : ''
34291 if(this.weight.length){
34292 cfg.cls += ' roo-radio-' + this.weight;
34296 cfg.cls += ' roo-radio-set-inline';
34300 ['xs','sm','md','lg'].map(function(size){
34301 if (settings[size]) {
34302 cfg.cls += ' col-' + size + '-' + settings[size];
34310 initEvents : function()
34312 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34313 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34315 if(!this.fieldLabel.length){
34316 this.labelEl.hide();
34319 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34320 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34322 this.indicator = this.indicatorEl();
34324 if(this.indicator){
34325 this.indicator.addClass('invisible');
34328 this.originalValue = this.getValue();
34332 inputEl: function ()
34334 return this.el.select('.roo-radio-set-input', true).first();
34337 getChildContainer : function()
34339 return this.itemsEl;
34342 register : function(item)
34344 this.radioes.push(item);
34348 validate : function()
34350 if(this.getVisibilityEl().hasClass('hidden')){
34356 Roo.each(this.radioes, function(i){
34365 if(this.allowBlank) {
34369 if(this.disabled || valid){
34374 this.markInvalid();
34379 markValid : function()
34381 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34382 this.indicatorEl().removeClass('visible');
34383 this.indicatorEl().addClass('invisible');
34387 if (Roo.bootstrap.version == 3) {
34388 this.el.removeClass([this.invalidClass, this.validClass]);
34389 this.el.addClass(this.validClass);
34391 this.el.removeClass(['is-invalid','is-valid']);
34392 this.el.addClass(['is-valid']);
34394 this.fireEvent('valid', this);
34397 markInvalid : function(msg)
34399 if(this.allowBlank || this.disabled){
34403 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34404 this.indicatorEl().removeClass('invisible');
34405 this.indicatorEl().addClass('visible');
34407 if (Roo.bootstrap.version == 3) {
34408 this.el.removeClass([this.invalidClass, this.validClass]);
34409 this.el.addClass(this.invalidClass);
34411 this.el.removeClass(['is-invalid','is-valid']);
34412 this.el.addClass(['is-invalid']);
34415 this.fireEvent('invalid', this, msg);
34419 setValue : function(v, suppressEvent)
34421 if(this.value === v){
34428 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34431 Roo.each(this.radioes, function(i){
34433 i.el.removeClass('checked');
34436 Roo.each(this.radioes, function(i){
34438 if(i.value === v || i.value.toString() === v.toString()){
34440 i.el.addClass('checked');
34442 if(suppressEvent !== true){
34443 this.fireEvent('check', this, i);
34454 clearInvalid : function(){
34456 if(!this.el || this.preventMark){
34460 this.el.removeClass([this.invalidClass]);
34462 this.fireEvent('valid', this);
34467 Roo.apply(Roo.bootstrap.RadioSet, {
34471 register : function(set)
34473 this.groups[set.name] = set;
34476 get: function(name)
34478 if (typeof(this.groups[name]) == 'undefined') {
34482 return this.groups[name] ;
34488 * Ext JS Library 1.1.1
34489 * Copyright(c) 2006-2007, Ext JS, LLC.
34491 * Originally Released Under LGPL - original licence link has changed is not relivant.
34494 * <script type="text/javascript">
34499 * @class Roo.bootstrap.SplitBar
34500 * @extends Roo.util.Observable
34501 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34505 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34506 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34507 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34508 split.minSize = 100;
34509 split.maxSize = 600;
34510 split.animate = true;
34511 split.on('moved', splitterMoved);
34514 * Create a new SplitBar
34515 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34516 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34517 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34518 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34519 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34520 position of the SplitBar).
34522 Roo.bootstrap.SplitBar = function(cfg){
34527 // dragElement : elm
34528 // resizingElement: el,
34530 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34531 // placement : Roo.bootstrap.SplitBar.LEFT ,
34532 // existingProxy ???
34535 this.el = Roo.get(cfg.dragElement, true);
34536 this.el.dom.unselectable = "on";
34538 this.resizingEl = Roo.get(cfg.resizingElement, true);
34542 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34543 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34546 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34549 * The minimum size of the resizing element. (Defaults to 0)
34555 * The maximum size of the resizing element. (Defaults to 2000)
34558 this.maxSize = 2000;
34561 * Whether to animate the transition to the new size
34564 this.animate = false;
34567 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34570 this.useShim = false;
34575 if(!cfg.existingProxy){
34577 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34579 this.proxy = Roo.get(cfg.existingProxy).dom;
34582 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34585 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34588 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34591 this.dragSpecs = {};
34594 * @private The adapter to use to positon and resize elements
34596 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34597 this.adapter.init(this);
34599 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34601 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34602 this.el.addClass("roo-splitbar-h");
34605 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34606 this.el.addClass("roo-splitbar-v");
34612 * Fires when the splitter is moved (alias for {@link #event-moved})
34613 * @param {Roo.bootstrap.SplitBar} this
34614 * @param {Number} newSize the new width or height
34619 * Fires when the splitter is moved
34620 * @param {Roo.bootstrap.SplitBar} this
34621 * @param {Number} newSize the new width or height
34625 * @event beforeresize
34626 * Fires before the splitter is dragged
34627 * @param {Roo.bootstrap.SplitBar} this
34629 "beforeresize" : true,
34631 "beforeapply" : true
34634 Roo.util.Observable.call(this);
34637 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34638 onStartProxyDrag : function(x, y){
34639 this.fireEvent("beforeresize", this);
34641 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34643 o.enableDisplayMode("block");
34644 // all splitbars share the same overlay
34645 Roo.bootstrap.SplitBar.prototype.overlay = o;
34647 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34648 this.overlay.show();
34649 Roo.get(this.proxy).setDisplayed("block");
34650 var size = this.adapter.getElementSize(this);
34651 this.activeMinSize = this.getMinimumSize();;
34652 this.activeMaxSize = this.getMaximumSize();;
34653 var c1 = size - this.activeMinSize;
34654 var c2 = Math.max(this.activeMaxSize - size, 0);
34655 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34656 this.dd.resetConstraints();
34657 this.dd.setXConstraint(
34658 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34659 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34661 this.dd.setYConstraint(0, 0);
34663 this.dd.resetConstraints();
34664 this.dd.setXConstraint(0, 0);
34665 this.dd.setYConstraint(
34666 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34667 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34670 this.dragSpecs.startSize = size;
34671 this.dragSpecs.startPoint = [x, y];
34672 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34676 * @private Called after the drag operation by the DDProxy
34678 onEndProxyDrag : function(e){
34679 Roo.get(this.proxy).setDisplayed(false);
34680 var endPoint = Roo.lib.Event.getXY(e);
34682 this.overlay.hide();
34685 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34686 newSize = this.dragSpecs.startSize +
34687 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34688 endPoint[0] - this.dragSpecs.startPoint[0] :
34689 this.dragSpecs.startPoint[0] - endPoint[0]
34692 newSize = this.dragSpecs.startSize +
34693 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34694 endPoint[1] - this.dragSpecs.startPoint[1] :
34695 this.dragSpecs.startPoint[1] - endPoint[1]
34698 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34699 if(newSize != this.dragSpecs.startSize){
34700 if(this.fireEvent('beforeapply', this, newSize) !== false){
34701 this.adapter.setElementSize(this, newSize);
34702 this.fireEvent("moved", this, newSize);
34703 this.fireEvent("resize", this, newSize);
34709 * Get the adapter this SplitBar uses
34710 * @return The adapter object
34712 getAdapter : function(){
34713 return this.adapter;
34717 * Set the adapter this SplitBar uses
34718 * @param {Object} adapter A SplitBar adapter object
34720 setAdapter : function(adapter){
34721 this.adapter = adapter;
34722 this.adapter.init(this);
34726 * Gets the minimum size for the resizing element
34727 * @return {Number} The minimum size
34729 getMinimumSize : function(){
34730 return this.minSize;
34734 * Sets the minimum size for the resizing element
34735 * @param {Number} minSize The minimum size
34737 setMinimumSize : function(minSize){
34738 this.minSize = minSize;
34742 * Gets the maximum size for the resizing element
34743 * @return {Number} The maximum size
34745 getMaximumSize : function(){
34746 return this.maxSize;
34750 * Sets the maximum size for the resizing element
34751 * @param {Number} maxSize The maximum size
34753 setMaximumSize : function(maxSize){
34754 this.maxSize = maxSize;
34758 * Sets the initialize size for the resizing element
34759 * @param {Number} size The initial size
34761 setCurrentSize : function(size){
34762 var oldAnimate = this.animate;
34763 this.animate = false;
34764 this.adapter.setElementSize(this, size);
34765 this.animate = oldAnimate;
34769 * Destroy this splitbar.
34770 * @param {Boolean} removeEl True to remove the element
34772 destroy : function(removeEl){
34774 this.shim.remove();
34777 this.proxy.parentNode.removeChild(this.proxy);
34785 * @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.
34787 Roo.bootstrap.SplitBar.createProxy = function(dir){
34788 var proxy = new Roo.Element(document.createElement("div"));
34789 proxy.unselectable();
34790 var cls = 'roo-splitbar-proxy';
34791 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34792 document.body.appendChild(proxy.dom);
34797 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34798 * Default Adapter. It assumes the splitter and resizing element are not positioned
34799 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34801 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34804 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34805 // do nothing for now
34806 init : function(s){
34810 * Called before drag operations to get the current size of the resizing element.
34811 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34813 getElementSize : function(s){
34814 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34815 return s.resizingEl.getWidth();
34817 return s.resizingEl.getHeight();
34822 * Called after drag operations to set the size of the resizing element.
34823 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34824 * @param {Number} newSize The new size to set
34825 * @param {Function} onComplete A function to be invoked when resizing is complete
34827 setElementSize : function(s, newSize, onComplete){
34828 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34830 s.resizingEl.setWidth(newSize);
34832 onComplete(s, newSize);
34835 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34840 s.resizingEl.setHeight(newSize);
34842 onComplete(s, newSize);
34845 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34852 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34853 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34854 * Adapter that moves the splitter element to align with the resized sizing element.
34855 * Used with an absolute positioned SplitBar.
34856 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34857 * document.body, make sure you assign an id to the body element.
34859 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34860 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34861 this.container = Roo.get(container);
34864 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34865 init : function(s){
34866 this.basic.init(s);
34869 getElementSize : function(s){
34870 return this.basic.getElementSize(s);
34873 setElementSize : function(s, newSize, onComplete){
34874 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34877 moveSplitter : function(s){
34878 var yes = Roo.bootstrap.SplitBar;
34879 switch(s.placement){
34881 s.el.setX(s.resizingEl.getRight());
34884 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34887 s.el.setY(s.resizingEl.getBottom());
34890 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34897 * Orientation constant - Create a vertical SplitBar
34901 Roo.bootstrap.SplitBar.VERTICAL = 1;
34904 * Orientation constant - Create a horizontal SplitBar
34908 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34911 * Placement constant - The resizing element is to the left of the splitter element
34915 Roo.bootstrap.SplitBar.LEFT = 1;
34918 * Placement constant - The resizing element is to the right of the splitter element
34922 Roo.bootstrap.SplitBar.RIGHT = 2;
34925 * Placement constant - The resizing element is positioned above the splitter element
34929 Roo.bootstrap.SplitBar.TOP = 3;
34932 * Placement constant - The resizing element is positioned under splitter element
34936 Roo.bootstrap.SplitBar.BOTTOM = 4;
34937 Roo.namespace("Roo.bootstrap.layout");/*
34939 * Ext JS Library 1.1.1
34940 * Copyright(c) 2006-2007, Ext JS, LLC.
34942 * Originally Released Under LGPL - original licence link has changed is not relivant.
34945 * <script type="text/javascript">
34949 * @class Roo.bootstrap.layout.Manager
34950 * @extends Roo.bootstrap.Component
34951 * Base class for layout managers.
34953 Roo.bootstrap.layout.Manager = function(config)
34955 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34961 /** false to disable window resize monitoring @type Boolean */
34962 this.monitorWindowResize = true;
34967 * Fires when a layout is performed.
34968 * @param {Roo.LayoutManager} this
34972 * @event regionresized
34973 * Fires when the user resizes a region.
34974 * @param {Roo.LayoutRegion} region The resized region
34975 * @param {Number} newSize The new size (width for east/west, height for north/south)
34977 "regionresized" : true,
34979 * @event regioncollapsed
34980 * Fires when a region is collapsed.
34981 * @param {Roo.LayoutRegion} region The collapsed region
34983 "regioncollapsed" : true,
34985 * @event regionexpanded
34986 * Fires when a region is expanded.
34987 * @param {Roo.LayoutRegion} region The expanded region
34989 "regionexpanded" : true
34991 this.updating = false;
34994 this.el = Roo.get(config.el);
35000 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
35005 monitorWindowResize : true,
35011 onRender : function(ct, position)
35014 this.el = Roo.get(ct);
35017 //this.fireEvent('render',this);
35021 initEvents: function()
35025 // ie scrollbar fix
35026 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
35027 document.body.scroll = "no";
35028 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
35029 this.el.position('relative');
35031 this.id = this.el.id;
35032 this.el.addClass("roo-layout-container");
35033 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35034 if(this.el.dom != document.body ) {
35035 this.el.on('resize', this.layout,this);
35036 this.el.on('show', this.layout,this);
35042 * Returns true if this layout is currently being updated
35043 * @return {Boolean}
35045 isUpdating : function(){
35046 return this.updating;
35050 * Suspend the LayoutManager from doing auto-layouts while
35051 * making multiple add or remove calls
35053 beginUpdate : function(){
35054 this.updating = true;
35058 * Restore auto-layouts and optionally disable the manager from performing a layout
35059 * @param {Boolean} noLayout true to disable a layout update
35061 endUpdate : function(noLayout){
35062 this.updating = false;
35068 layout: function(){
35072 onRegionResized : function(region, newSize){
35073 this.fireEvent("regionresized", region, newSize);
35077 onRegionCollapsed : function(region){
35078 this.fireEvent("regioncollapsed", region);
35081 onRegionExpanded : function(region){
35082 this.fireEvent("regionexpanded", region);
35086 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35087 * performs box-model adjustments.
35088 * @return {Object} The size as an object {width: (the width), height: (the height)}
35090 getViewSize : function()
35093 if(this.el.dom != document.body){
35094 size = this.el.getSize();
35096 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35098 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35099 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35104 * Returns the Element this layout is bound to.
35105 * @return {Roo.Element}
35107 getEl : function(){
35112 * Returns the specified region.
35113 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35114 * @return {Roo.LayoutRegion}
35116 getRegion : function(target){
35117 return this.regions[target.toLowerCase()];
35120 onWindowResize : function(){
35121 if(this.monitorWindowResize){
35128 * Ext JS Library 1.1.1
35129 * Copyright(c) 2006-2007, Ext JS, LLC.
35131 * Originally Released Under LGPL - original licence link has changed is not relivant.
35134 * <script type="text/javascript">
35137 * @class Roo.bootstrap.layout.Border
35138 * @extends Roo.bootstrap.layout.Manager
35139 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35140 * please see: examples/bootstrap/nested.html<br><br>
35142 <b>The container the layout is rendered into can be either the body element or any other element.
35143 If it is not the body element, the container needs to either be an absolute positioned element,
35144 or you will need to add "position:relative" to the css of the container. You will also need to specify
35145 the container size if it is not the body element.</b>
35148 * Create a new Border
35149 * @param {Object} config Configuration options
35151 Roo.bootstrap.layout.Border = function(config){
35152 config = config || {};
35153 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35157 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35158 if(config[region]){
35159 config[region].region = region;
35160 this.addRegion(config[region]);
35166 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35168 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35170 parent : false, // this might point to a 'nest' or a ???
35173 * Creates and adds a new region if it doesn't already exist.
35174 * @param {String} target The target region key (north, south, east, west or center).
35175 * @param {Object} config The regions config object
35176 * @return {BorderLayoutRegion} The new region
35178 addRegion : function(config)
35180 if(!this.regions[config.region]){
35181 var r = this.factory(config);
35182 this.bindRegion(r);
35184 return this.regions[config.region];
35188 bindRegion : function(r){
35189 this.regions[r.config.region] = r;
35191 r.on("visibilitychange", this.layout, this);
35192 r.on("paneladded", this.layout, this);
35193 r.on("panelremoved", this.layout, this);
35194 r.on("invalidated", this.layout, this);
35195 r.on("resized", this.onRegionResized, this);
35196 r.on("collapsed", this.onRegionCollapsed, this);
35197 r.on("expanded", this.onRegionExpanded, this);
35201 * Performs a layout update.
35203 layout : function()
35205 if(this.updating) {
35209 // render all the rebions if they have not been done alreayd?
35210 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35211 if(this.regions[region] && !this.regions[region].bodyEl){
35212 this.regions[region].onRender(this.el)
35216 var size = this.getViewSize();
35217 var w = size.width;
35218 var h = size.height;
35223 //var x = 0, y = 0;
35225 var rs = this.regions;
35226 var north = rs["north"];
35227 var south = rs["south"];
35228 var west = rs["west"];
35229 var east = rs["east"];
35230 var center = rs["center"];
35231 //if(this.hideOnLayout){ // not supported anymore
35232 //c.el.setStyle("display", "none");
35234 if(north && north.isVisible()){
35235 var b = north.getBox();
35236 var m = north.getMargins();
35237 b.width = w - (m.left+m.right);
35240 centerY = b.height + b.y + m.bottom;
35241 centerH -= centerY;
35242 north.updateBox(this.safeBox(b));
35244 if(south && south.isVisible()){
35245 var b = south.getBox();
35246 var m = south.getMargins();
35247 b.width = w - (m.left+m.right);
35249 var totalHeight = (b.height + m.top + m.bottom);
35250 b.y = h - totalHeight + m.top;
35251 centerH -= totalHeight;
35252 south.updateBox(this.safeBox(b));
35254 if(west && west.isVisible()){
35255 var b = west.getBox();
35256 var m = west.getMargins();
35257 b.height = centerH - (m.top+m.bottom);
35259 b.y = centerY + m.top;
35260 var totalWidth = (b.width + m.left + m.right);
35261 centerX += totalWidth;
35262 centerW -= totalWidth;
35263 west.updateBox(this.safeBox(b));
35265 if(east && east.isVisible()){
35266 var b = east.getBox();
35267 var m = east.getMargins();
35268 b.height = centerH - (m.top+m.bottom);
35269 var totalWidth = (b.width + m.left + m.right);
35270 b.x = w - totalWidth + m.left;
35271 b.y = centerY + m.top;
35272 centerW -= totalWidth;
35273 east.updateBox(this.safeBox(b));
35276 var m = center.getMargins();
35278 x: centerX + m.left,
35279 y: centerY + m.top,
35280 width: centerW - (m.left+m.right),
35281 height: centerH - (m.top+m.bottom)
35283 //if(this.hideOnLayout){
35284 //center.el.setStyle("display", "block");
35286 center.updateBox(this.safeBox(centerBox));
35289 this.fireEvent("layout", this);
35293 safeBox : function(box){
35294 box.width = Math.max(0, box.width);
35295 box.height = Math.max(0, box.height);
35300 * Adds a ContentPanel (or subclass) to this layout.
35301 * @param {String} target The target region key (north, south, east, west or center).
35302 * @param {Roo.ContentPanel} panel The panel to add
35303 * @return {Roo.ContentPanel} The added panel
35305 add : function(target, panel){
35307 target = target.toLowerCase();
35308 return this.regions[target].add(panel);
35312 * Remove a ContentPanel (or subclass) to this layout.
35313 * @param {String} target The target region key (north, south, east, west or center).
35314 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35315 * @return {Roo.ContentPanel} The removed panel
35317 remove : function(target, panel){
35318 target = target.toLowerCase();
35319 return this.regions[target].remove(panel);
35323 * Searches all regions for a panel with the specified id
35324 * @param {String} panelId
35325 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35327 findPanel : function(panelId){
35328 var rs = this.regions;
35329 for(var target in rs){
35330 if(typeof rs[target] != "function"){
35331 var p = rs[target].getPanel(panelId);
35341 * Searches all regions for a panel with the specified id and activates (shows) it.
35342 * @param {String/ContentPanel} panelId The panels id or the panel itself
35343 * @return {Roo.ContentPanel} The shown panel or null
35345 showPanel : function(panelId) {
35346 var rs = this.regions;
35347 for(var target in rs){
35348 var r = rs[target];
35349 if(typeof r != "function"){
35350 if(r.hasPanel(panelId)){
35351 return r.showPanel(panelId);
35359 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35360 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35363 restoreState : function(provider){
35365 provider = Roo.state.Manager;
35367 var sm = new Roo.LayoutStateManager();
35368 sm.init(this, provider);
35374 * Adds a xtype elements to the layout.
35378 xtype : 'ContentPanel',
35385 xtype : 'NestedLayoutPanel',
35391 items : [ ... list of content panels or nested layout panels.. ]
35395 * @param {Object} cfg Xtype definition of item to add.
35397 addxtype : function(cfg)
35399 // basically accepts a pannel...
35400 // can accept a layout region..!?!?
35401 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35404 // theory? children can only be panels??
35406 //if (!cfg.xtype.match(/Panel$/)) {
35411 if (typeof(cfg.region) == 'undefined') {
35412 Roo.log("Failed to add Panel, region was not set");
35416 var region = cfg.region;
35422 xitems = cfg.items;
35427 if ( region == 'center') {
35428 Roo.log("Center: " + cfg.title);
35434 case 'Content': // ContentPanel (el, cfg)
35435 case 'Scroll': // ContentPanel (el, cfg)
35437 cfg.autoCreate = cfg.autoCreate || true;
35438 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35440 // var el = this.el.createChild();
35441 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35444 this.add(region, ret);
35448 case 'TreePanel': // our new panel!
35449 cfg.el = this.el.createChild();
35450 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35451 this.add(region, ret);
35456 // create a new Layout (which is a Border Layout...
35458 var clayout = cfg.layout;
35459 clayout.el = this.el.createChild();
35460 clayout.items = clayout.items || [];
35464 // replace this exitems with the clayout ones..
35465 xitems = clayout.items;
35467 // force background off if it's in center...
35468 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35469 cfg.background = false;
35471 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35474 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35475 //console.log('adding nested layout panel ' + cfg.toSource());
35476 this.add(region, ret);
35477 nb = {}; /// find first...
35482 // needs grid and region
35484 //var el = this.getRegion(region).el.createChild();
35486 *var el = this.el.createChild();
35487 // create the grid first...
35488 cfg.grid.container = el;
35489 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35492 if (region == 'center' && this.active ) {
35493 cfg.background = false;
35496 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35498 this.add(region, ret);
35500 if (cfg.background) {
35501 // render grid on panel activation (if panel background)
35502 ret.on('activate', function(gp) {
35503 if (!gp.grid.rendered) {
35504 // gp.grid.render(el);
35508 // cfg.grid.render(el);
35514 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35515 // it was the old xcomponent building that caused this before.
35516 // espeically if border is the top element in the tree.
35526 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35528 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35529 this.add(region, ret);
35533 throw "Can not add '" + cfg.xtype + "' to Border";
35539 this.beginUpdate();
35543 Roo.each(xitems, function(i) {
35544 region = nb && i.region ? i.region : false;
35546 var add = ret.addxtype(i);
35549 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35550 if (!i.background) {
35551 abn[region] = nb[region] ;
35558 // make the last non-background panel active..
35559 //if (nb) { Roo.log(abn); }
35562 for(var r in abn) {
35563 region = this.getRegion(r);
35565 // tried using nb[r], but it does not work..
35567 region.showPanel(abn[r]);
35578 factory : function(cfg)
35581 var validRegions = Roo.bootstrap.layout.Border.regions;
35583 var target = cfg.region;
35586 var r = Roo.bootstrap.layout;
35590 return new r.North(cfg);
35592 return new r.South(cfg);
35594 return new r.East(cfg);
35596 return new r.West(cfg);
35598 return new r.Center(cfg);
35600 throw 'Layout region "'+target+'" not supported.';
35607 * Ext JS Library 1.1.1
35608 * Copyright(c) 2006-2007, Ext JS, LLC.
35610 * Originally Released Under LGPL - original licence link has changed is not relivant.
35613 * <script type="text/javascript">
35617 * @class Roo.bootstrap.layout.Basic
35618 * @extends Roo.util.Observable
35619 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35620 * and does not have a titlebar, tabs or any other features. All it does is size and position
35621 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35622 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35623 * @cfg {string} region the region that it inhabits..
35624 * @cfg {bool} skipConfig skip config?
35628 Roo.bootstrap.layout.Basic = function(config){
35630 this.mgr = config.mgr;
35632 this.position = config.region;
35634 var skipConfig = config.skipConfig;
35638 * @scope Roo.BasicLayoutRegion
35642 * @event beforeremove
35643 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35644 * @param {Roo.LayoutRegion} this
35645 * @param {Roo.ContentPanel} panel The panel
35646 * @param {Object} e The cancel event object
35648 "beforeremove" : true,
35650 * @event invalidated
35651 * Fires when the layout for this region is changed.
35652 * @param {Roo.LayoutRegion} this
35654 "invalidated" : true,
35656 * @event visibilitychange
35657 * Fires when this region is shown or hidden
35658 * @param {Roo.LayoutRegion} this
35659 * @param {Boolean} visibility true or false
35661 "visibilitychange" : true,
35663 * @event paneladded
35664 * Fires when a panel is added.
35665 * @param {Roo.LayoutRegion} this
35666 * @param {Roo.ContentPanel} panel The panel
35668 "paneladded" : true,
35670 * @event panelremoved
35671 * Fires when a panel is removed.
35672 * @param {Roo.LayoutRegion} this
35673 * @param {Roo.ContentPanel} panel The panel
35675 "panelremoved" : true,
35677 * @event beforecollapse
35678 * Fires when this region before collapse.
35679 * @param {Roo.LayoutRegion} this
35681 "beforecollapse" : true,
35684 * Fires when this region is collapsed.
35685 * @param {Roo.LayoutRegion} this
35687 "collapsed" : true,
35690 * Fires when this region is expanded.
35691 * @param {Roo.LayoutRegion} this
35696 * Fires when this region is slid into view.
35697 * @param {Roo.LayoutRegion} this
35699 "slideshow" : true,
35702 * Fires when this region slides out of view.
35703 * @param {Roo.LayoutRegion} this
35705 "slidehide" : true,
35707 * @event panelactivated
35708 * Fires when a panel is activated.
35709 * @param {Roo.LayoutRegion} this
35710 * @param {Roo.ContentPanel} panel The activated panel
35712 "panelactivated" : true,
35715 * Fires when the user resizes this region.
35716 * @param {Roo.LayoutRegion} this
35717 * @param {Number} newSize The new size (width for east/west, height for north/south)
35721 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35722 this.panels = new Roo.util.MixedCollection();
35723 this.panels.getKey = this.getPanelId.createDelegate(this);
35725 this.activePanel = null;
35726 // ensure listeners are added...
35728 if (config.listeners || config.events) {
35729 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35730 listeners : config.listeners || {},
35731 events : config.events || {}
35735 if(skipConfig !== true){
35736 this.applyConfig(config);
35740 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35742 getPanelId : function(p){
35746 applyConfig : function(config){
35747 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35748 this.config = config;
35753 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35754 * the width, for horizontal (north, south) the height.
35755 * @param {Number} newSize The new width or height
35757 resizeTo : function(newSize){
35758 var el = this.el ? this.el :
35759 (this.activePanel ? this.activePanel.getEl() : null);
35761 switch(this.position){
35764 el.setWidth(newSize);
35765 this.fireEvent("resized", this, newSize);
35769 el.setHeight(newSize);
35770 this.fireEvent("resized", this, newSize);
35776 getBox : function(){
35777 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35780 getMargins : function(){
35781 return this.margins;
35784 updateBox : function(box){
35786 var el = this.activePanel.getEl();
35787 el.dom.style.left = box.x + "px";
35788 el.dom.style.top = box.y + "px";
35789 this.activePanel.setSize(box.width, box.height);
35793 * Returns the container element for this region.
35794 * @return {Roo.Element}
35796 getEl : function(){
35797 return this.activePanel;
35801 * Returns true if this region is currently visible.
35802 * @return {Boolean}
35804 isVisible : function(){
35805 return this.activePanel ? true : false;
35808 setActivePanel : function(panel){
35809 panel = this.getPanel(panel);
35810 if(this.activePanel && this.activePanel != panel){
35811 this.activePanel.setActiveState(false);
35812 this.activePanel.getEl().setLeftTop(-10000,-10000);
35814 this.activePanel = panel;
35815 panel.setActiveState(true);
35817 panel.setSize(this.box.width, this.box.height);
35819 this.fireEvent("panelactivated", this, panel);
35820 this.fireEvent("invalidated");
35824 * Show the specified panel.
35825 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35826 * @return {Roo.ContentPanel} The shown panel or null
35828 showPanel : function(panel){
35829 panel = this.getPanel(panel);
35831 this.setActivePanel(panel);
35837 * Get the active panel for this region.
35838 * @return {Roo.ContentPanel} The active panel or null
35840 getActivePanel : function(){
35841 return this.activePanel;
35845 * Add the passed ContentPanel(s)
35846 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35847 * @return {Roo.ContentPanel} The panel added (if only one was added)
35849 add : function(panel){
35850 if(arguments.length > 1){
35851 for(var i = 0, len = arguments.length; i < len; i++) {
35852 this.add(arguments[i]);
35856 if(this.hasPanel(panel)){
35857 this.showPanel(panel);
35860 var el = panel.getEl();
35861 if(el.dom.parentNode != this.mgr.el.dom){
35862 this.mgr.el.dom.appendChild(el.dom);
35864 if(panel.setRegion){
35865 panel.setRegion(this);
35867 this.panels.add(panel);
35868 el.setStyle("position", "absolute");
35869 if(!panel.background){
35870 this.setActivePanel(panel);
35871 if(this.config.initialSize && this.panels.getCount()==1){
35872 this.resizeTo(this.config.initialSize);
35875 this.fireEvent("paneladded", this, panel);
35880 * Returns true if the panel is in this region.
35881 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35882 * @return {Boolean}
35884 hasPanel : function(panel){
35885 if(typeof panel == "object"){ // must be panel obj
35886 panel = panel.getId();
35888 return this.getPanel(panel) ? true : false;
35892 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35893 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35894 * @param {Boolean} preservePanel Overrides the config preservePanel option
35895 * @return {Roo.ContentPanel} The panel that was removed
35897 remove : function(panel, preservePanel){
35898 panel = this.getPanel(panel);
35903 this.fireEvent("beforeremove", this, panel, e);
35904 if(e.cancel === true){
35907 var panelId = panel.getId();
35908 this.panels.removeKey(panelId);
35913 * Returns the panel specified or null if it's not in this region.
35914 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35915 * @return {Roo.ContentPanel}
35917 getPanel : function(id){
35918 if(typeof id == "object"){ // must be panel obj
35921 return this.panels.get(id);
35925 * Returns this regions position (north/south/east/west/center).
35928 getPosition: function(){
35929 return this.position;
35933 * Ext JS Library 1.1.1
35934 * Copyright(c) 2006-2007, Ext JS, LLC.
35936 * Originally Released Under LGPL - original licence link has changed is not relivant.
35939 * <script type="text/javascript">
35943 * @class Roo.bootstrap.layout.Region
35944 * @extends Roo.bootstrap.layout.Basic
35945 * This class represents a region in a layout manager.
35947 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35948 * @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})
35949 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35950 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35951 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35952 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35953 * @cfg {String} title The title for the region (overrides panel titles)
35954 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35955 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35956 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35957 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35958 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35959 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35960 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35961 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35962 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35963 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35965 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35966 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35967 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35968 * @cfg {Number} width For East/West panels
35969 * @cfg {Number} height For North/South panels
35970 * @cfg {Boolean} split To show the splitter
35971 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35973 * @cfg {string} cls Extra CSS classes to add to region
35975 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35976 * @cfg {string} region the region that it inhabits..
35979 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35980 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35982 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35983 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35984 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35986 Roo.bootstrap.layout.Region = function(config)
35988 this.applyConfig(config);
35990 var mgr = config.mgr;
35991 var pos = config.region;
35992 config.skipConfig = true;
35993 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35996 this.onRender(mgr.el);
35999 this.visible = true;
36000 this.collapsed = false;
36001 this.unrendered_panels = [];
36004 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
36006 position: '', // set by wrapper (eg. north/south etc..)
36007 unrendered_panels : null, // unrendered panels.
36009 tabPosition : false,
36011 mgr: false, // points to 'Border'
36014 createBody : function(){
36015 /** This region's body element
36016 * @type Roo.Element */
36017 this.bodyEl = this.el.createChild({
36019 cls: "roo-layout-panel-body tab-content" // bootstrap added...
36023 onRender: function(ctr, pos)
36025 var dh = Roo.DomHelper;
36026 /** This region's container element
36027 * @type Roo.Element */
36028 this.el = dh.append(ctr.dom, {
36030 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
36032 /** This region's title element
36033 * @type Roo.Element */
36035 this.titleEl = dh.append(this.el.dom, {
36037 unselectable: "on",
36038 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36040 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36041 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36045 this.titleEl.enableDisplayMode();
36046 /** This region's title text element
36047 * @type HTMLElement */
36048 this.titleTextEl = this.titleEl.dom.firstChild;
36049 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36051 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36052 this.closeBtn.enableDisplayMode();
36053 this.closeBtn.on("click", this.closeClicked, this);
36054 this.closeBtn.hide();
36056 this.createBody(this.config);
36057 if(this.config.hideWhenEmpty){
36059 this.on("paneladded", this.validateVisibility, this);
36060 this.on("panelremoved", this.validateVisibility, this);
36062 if(this.autoScroll){
36063 this.bodyEl.setStyle("overflow", "auto");
36065 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36067 //if(c.titlebar !== false){
36068 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36069 this.titleEl.hide();
36071 this.titleEl.show();
36072 if(this.config.title){
36073 this.titleTextEl.innerHTML = this.config.title;
36077 if(this.config.collapsed){
36078 this.collapse(true);
36080 if(this.config.hidden){
36084 if (this.unrendered_panels && this.unrendered_panels.length) {
36085 for (var i =0;i< this.unrendered_panels.length; i++) {
36086 this.add(this.unrendered_panels[i]);
36088 this.unrendered_panels = null;
36094 applyConfig : function(c)
36097 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36098 var dh = Roo.DomHelper;
36099 if(c.titlebar !== false){
36100 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36101 this.collapseBtn.on("click", this.collapse, this);
36102 this.collapseBtn.enableDisplayMode();
36104 if(c.showPin === true || this.showPin){
36105 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36106 this.stickBtn.enableDisplayMode();
36107 this.stickBtn.on("click", this.expand, this);
36108 this.stickBtn.hide();
36113 /** This region's collapsed element
36114 * @type Roo.Element */
36117 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36118 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36121 if(c.floatable !== false){
36122 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36123 this.collapsedEl.on("click", this.collapseClick, this);
36126 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36127 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36128 id: "message", unselectable: "on", style:{"float":"left"}});
36129 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36131 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36132 this.expandBtn.on("click", this.expand, this);
36136 if(this.collapseBtn){
36137 this.collapseBtn.setVisible(c.collapsible == true);
36140 this.cmargins = c.cmargins || this.cmargins ||
36141 (this.position == "west" || this.position == "east" ?
36142 {top: 0, left: 2, right:2, bottom: 0} :
36143 {top: 2, left: 0, right:0, bottom: 2});
36145 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36148 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36150 this.autoScroll = c.autoScroll || false;
36155 this.duration = c.duration || .30;
36156 this.slideDuration = c.slideDuration || .45;
36161 * Returns true if this region is currently visible.
36162 * @return {Boolean}
36164 isVisible : function(){
36165 return this.visible;
36169 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36170 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36172 //setCollapsedTitle : function(title){
36173 // title = title || " ";
36174 // if(this.collapsedTitleTextEl){
36175 // this.collapsedTitleTextEl.innerHTML = title;
36179 getBox : function(){
36181 // if(!this.collapsed){
36182 b = this.el.getBox(false, true);
36184 // b = this.collapsedEl.getBox(false, true);
36189 getMargins : function(){
36190 return this.margins;
36191 //return this.collapsed ? this.cmargins : this.margins;
36194 highlight : function(){
36195 this.el.addClass("x-layout-panel-dragover");
36198 unhighlight : function(){
36199 this.el.removeClass("x-layout-panel-dragover");
36202 updateBox : function(box)
36204 if (!this.bodyEl) {
36205 return; // not rendered yet..
36209 if(!this.collapsed){
36210 this.el.dom.style.left = box.x + "px";
36211 this.el.dom.style.top = box.y + "px";
36212 this.updateBody(box.width, box.height);
36214 this.collapsedEl.dom.style.left = box.x + "px";
36215 this.collapsedEl.dom.style.top = box.y + "px";
36216 this.collapsedEl.setSize(box.width, box.height);
36219 this.tabs.autoSizeTabs();
36223 updateBody : function(w, h)
36226 this.el.setWidth(w);
36227 w -= this.el.getBorderWidth("rl");
36228 if(this.config.adjustments){
36229 w += this.config.adjustments[0];
36232 if(h !== null && h > 0){
36233 this.el.setHeight(h);
36234 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36235 h -= this.el.getBorderWidth("tb");
36236 if(this.config.adjustments){
36237 h += this.config.adjustments[1];
36239 this.bodyEl.setHeight(h);
36241 h = this.tabs.syncHeight(h);
36244 if(this.panelSize){
36245 w = w !== null ? w : this.panelSize.width;
36246 h = h !== null ? h : this.panelSize.height;
36248 if(this.activePanel){
36249 var el = this.activePanel.getEl();
36250 w = w !== null ? w : el.getWidth();
36251 h = h !== null ? h : el.getHeight();
36252 this.panelSize = {width: w, height: h};
36253 this.activePanel.setSize(w, h);
36255 if(Roo.isIE && this.tabs){
36256 this.tabs.el.repaint();
36261 * Returns the container element for this region.
36262 * @return {Roo.Element}
36264 getEl : function(){
36269 * Hides this region.
36272 //if(!this.collapsed){
36273 this.el.dom.style.left = "-2000px";
36276 // this.collapsedEl.dom.style.left = "-2000px";
36277 // this.collapsedEl.hide();
36279 this.visible = false;
36280 this.fireEvent("visibilitychange", this, false);
36284 * Shows this region if it was previously hidden.
36287 //if(!this.collapsed){
36290 // this.collapsedEl.show();
36292 this.visible = true;
36293 this.fireEvent("visibilitychange", this, true);
36296 closeClicked : function(){
36297 if(this.activePanel){
36298 this.remove(this.activePanel);
36302 collapseClick : function(e){
36304 e.stopPropagation();
36307 e.stopPropagation();
36313 * Collapses this region.
36314 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36317 collapse : function(skipAnim, skipCheck = false){
36318 if(this.collapsed) {
36322 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36324 this.collapsed = true;
36326 this.split.el.hide();
36328 if(this.config.animate && skipAnim !== true){
36329 this.fireEvent("invalidated", this);
36330 this.animateCollapse();
36332 this.el.setLocation(-20000,-20000);
36334 this.collapsedEl.show();
36335 this.fireEvent("collapsed", this);
36336 this.fireEvent("invalidated", this);
36342 animateCollapse : function(){
36347 * Expands this region if it was previously collapsed.
36348 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36349 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36352 expand : function(e, skipAnim){
36354 e.stopPropagation();
36356 if(!this.collapsed || this.el.hasActiveFx()) {
36360 this.afterSlideIn();
36363 this.collapsed = false;
36364 if(this.config.animate && skipAnim !== true){
36365 this.animateExpand();
36369 this.split.el.show();
36371 this.collapsedEl.setLocation(-2000,-2000);
36372 this.collapsedEl.hide();
36373 this.fireEvent("invalidated", this);
36374 this.fireEvent("expanded", this);
36378 animateExpand : function(){
36382 initTabs : function()
36384 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36386 var ts = new Roo.bootstrap.panel.Tabs({
36387 el: this.bodyEl.dom,
36389 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36390 disableTooltips: this.config.disableTabTips,
36391 toolbar : this.config.toolbar
36394 if(this.config.hideTabs){
36395 ts.stripWrap.setDisplayed(false);
36398 ts.resizeTabs = this.config.resizeTabs === true;
36399 ts.minTabWidth = this.config.minTabWidth || 40;
36400 ts.maxTabWidth = this.config.maxTabWidth || 250;
36401 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36402 ts.monitorResize = false;
36403 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36404 ts.bodyEl.addClass('roo-layout-tabs-body');
36405 this.panels.each(this.initPanelAsTab, this);
36408 initPanelAsTab : function(panel){
36409 var ti = this.tabs.addTab(
36413 this.config.closeOnTab && panel.isClosable(),
36416 if(panel.tabTip !== undefined){
36417 ti.setTooltip(panel.tabTip);
36419 ti.on("activate", function(){
36420 this.setActivePanel(panel);
36423 if(this.config.closeOnTab){
36424 ti.on("beforeclose", function(t, e){
36426 this.remove(panel);
36430 panel.tabItem = ti;
36435 updatePanelTitle : function(panel, title)
36437 if(this.activePanel == panel){
36438 this.updateTitle(title);
36441 var ti = this.tabs.getTab(panel.getEl().id);
36443 if(panel.tabTip !== undefined){
36444 ti.setTooltip(panel.tabTip);
36449 updateTitle : function(title){
36450 if(this.titleTextEl && !this.config.title){
36451 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36455 setActivePanel : function(panel)
36457 panel = this.getPanel(panel);
36458 if(this.activePanel && this.activePanel != panel){
36459 if(this.activePanel.setActiveState(false) === false){
36463 this.activePanel = panel;
36464 panel.setActiveState(true);
36465 if(this.panelSize){
36466 panel.setSize(this.panelSize.width, this.panelSize.height);
36469 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36471 this.updateTitle(panel.getTitle());
36473 this.fireEvent("invalidated", this);
36475 this.fireEvent("panelactivated", this, panel);
36479 * Shows the specified panel.
36480 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36481 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36483 showPanel : function(panel)
36485 panel = this.getPanel(panel);
36488 var tab = this.tabs.getTab(panel.getEl().id);
36489 if(tab.isHidden()){
36490 this.tabs.unhideTab(tab.id);
36494 this.setActivePanel(panel);
36501 * Get the active panel for this region.
36502 * @return {Roo.ContentPanel} The active panel or null
36504 getActivePanel : function(){
36505 return this.activePanel;
36508 validateVisibility : function(){
36509 if(this.panels.getCount() < 1){
36510 this.updateTitle(" ");
36511 this.closeBtn.hide();
36514 if(!this.isVisible()){
36521 * Adds the passed ContentPanel(s) to this region.
36522 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36523 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36525 add : function(panel)
36527 if(arguments.length > 1){
36528 for(var i = 0, len = arguments.length; i < len; i++) {
36529 this.add(arguments[i]);
36534 // if we have not been rendered yet, then we can not really do much of this..
36535 if (!this.bodyEl) {
36536 this.unrendered_panels.push(panel);
36543 if(this.hasPanel(panel)){
36544 this.showPanel(panel);
36547 panel.setRegion(this);
36548 this.panels.add(panel);
36549 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36550 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36551 // and hide them... ???
36552 this.bodyEl.dom.appendChild(panel.getEl().dom);
36553 if(panel.background !== true){
36554 this.setActivePanel(panel);
36556 this.fireEvent("paneladded", this, panel);
36563 this.initPanelAsTab(panel);
36567 if(panel.background !== true){
36568 this.tabs.activate(panel.getEl().id);
36570 this.fireEvent("paneladded", this, panel);
36575 * Hides the tab for the specified panel.
36576 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36578 hidePanel : function(panel){
36579 if(this.tabs && (panel = this.getPanel(panel))){
36580 this.tabs.hideTab(panel.getEl().id);
36585 * Unhides the tab for a previously hidden panel.
36586 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36588 unhidePanel : function(panel){
36589 if(this.tabs && (panel = this.getPanel(panel))){
36590 this.tabs.unhideTab(panel.getEl().id);
36594 clearPanels : function(){
36595 while(this.panels.getCount() > 0){
36596 this.remove(this.panels.first());
36601 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36602 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36603 * @param {Boolean} preservePanel Overrides the config preservePanel option
36604 * @return {Roo.ContentPanel} The panel that was removed
36606 remove : function(panel, preservePanel)
36608 panel = this.getPanel(panel);
36613 this.fireEvent("beforeremove", this, panel, e);
36614 if(e.cancel === true){
36617 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36618 var panelId = panel.getId();
36619 this.panels.removeKey(panelId);
36621 document.body.appendChild(panel.getEl().dom);
36624 this.tabs.removeTab(panel.getEl().id);
36625 }else if (!preservePanel){
36626 this.bodyEl.dom.removeChild(panel.getEl().dom);
36628 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36629 var p = this.panels.first();
36630 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36631 tempEl.appendChild(p.getEl().dom);
36632 this.bodyEl.update("");
36633 this.bodyEl.dom.appendChild(p.getEl().dom);
36635 this.updateTitle(p.getTitle());
36637 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36638 this.setActivePanel(p);
36640 panel.setRegion(null);
36641 if(this.activePanel == panel){
36642 this.activePanel = null;
36644 if(this.config.autoDestroy !== false && preservePanel !== true){
36645 try{panel.destroy();}catch(e){}
36647 this.fireEvent("panelremoved", this, panel);
36652 * Returns the TabPanel component used by this region
36653 * @return {Roo.TabPanel}
36655 getTabs : function(){
36659 createTool : function(parentEl, className){
36660 var btn = Roo.DomHelper.append(parentEl, {
36662 cls: "x-layout-tools-button",
36665 cls: "roo-layout-tools-button-inner " + className,
36669 btn.addClassOnOver("roo-layout-tools-button-over");
36674 * Ext JS Library 1.1.1
36675 * Copyright(c) 2006-2007, Ext JS, LLC.
36677 * Originally Released Under LGPL - original licence link has changed is not relivant.
36680 * <script type="text/javascript">
36686 * @class Roo.SplitLayoutRegion
36687 * @extends Roo.LayoutRegion
36688 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36690 Roo.bootstrap.layout.Split = function(config){
36691 this.cursor = config.cursor;
36692 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36695 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36697 splitTip : "Drag to resize.",
36698 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36699 useSplitTips : false,
36701 applyConfig : function(config){
36702 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36705 onRender : function(ctr,pos) {
36707 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36708 if(!this.config.split){
36713 var splitEl = Roo.DomHelper.append(ctr.dom, {
36715 id: this.el.id + "-split",
36716 cls: "roo-layout-split roo-layout-split-"+this.position,
36719 /** The SplitBar for this region
36720 * @type Roo.SplitBar */
36721 // does not exist yet...
36722 Roo.log([this.position, this.orientation]);
36724 this.split = new Roo.bootstrap.SplitBar({
36725 dragElement : splitEl,
36726 resizingElement: this.el,
36727 orientation : this.orientation
36730 this.split.on("moved", this.onSplitMove, this);
36731 this.split.useShim = this.config.useShim === true;
36732 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36733 if(this.useSplitTips){
36734 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36736 //if(config.collapsible){
36737 // this.split.el.on("dblclick", this.collapse, this);
36740 if(typeof this.config.minSize != "undefined"){
36741 this.split.minSize = this.config.minSize;
36743 if(typeof this.config.maxSize != "undefined"){
36744 this.split.maxSize = this.config.maxSize;
36746 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36747 this.hideSplitter();
36752 getHMaxSize : function(){
36753 var cmax = this.config.maxSize || 10000;
36754 var center = this.mgr.getRegion("center");
36755 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36758 getVMaxSize : function(){
36759 var cmax = this.config.maxSize || 10000;
36760 var center = this.mgr.getRegion("center");
36761 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36764 onSplitMove : function(split, newSize){
36765 this.fireEvent("resized", this, newSize);
36769 * Returns the {@link Roo.SplitBar} for this region.
36770 * @return {Roo.SplitBar}
36772 getSplitBar : function(){
36777 this.hideSplitter();
36778 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36781 hideSplitter : function(){
36783 this.split.el.setLocation(-2000,-2000);
36784 this.split.el.hide();
36790 this.split.el.show();
36792 Roo.bootstrap.layout.Split.superclass.show.call(this);
36795 beforeSlide: function(){
36796 if(Roo.isGecko){// firefox overflow auto bug workaround
36797 this.bodyEl.clip();
36799 this.tabs.bodyEl.clip();
36801 if(this.activePanel){
36802 this.activePanel.getEl().clip();
36804 if(this.activePanel.beforeSlide){
36805 this.activePanel.beforeSlide();
36811 afterSlide : function(){
36812 if(Roo.isGecko){// firefox overflow auto bug workaround
36813 this.bodyEl.unclip();
36815 this.tabs.bodyEl.unclip();
36817 if(this.activePanel){
36818 this.activePanel.getEl().unclip();
36819 if(this.activePanel.afterSlide){
36820 this.activePanel.afterSlide();
36826 initAutoHide : function(){
36827 if(this.autoHide !== false){
36828 if(!this.autoHideHd){
36829 var st = new Roo.util.DelayedTask(this.slideIn, this);
36830 this.autoHideHd = {
36831 "mouseout": function(e){
36832 if(!e.within(this.el, true)){
36836 "mouseover" : function(e){
36842 this.el.on(this.autoHideHd);
36846 clearAutoHide : function(){
36847 if(this.autoHide !== false){
36848 this.el.un("mouseout", this.autoHideHd.mouseout);
36849 this.el.un("mouseover", this.autoHideHd.mouseover);
36853 clearMonitor : function(){
36854 Roo.get(document).un("click", this.slideInIf, this);
36857 // these names are backwards but not changed for compat
36858 slideOut : function(){
36859 if(this.isSlid || this.el.hasActiveFx()){
36862 this.isSlid = true;
36863 if(this.collapseBtn){
36864 this.collapseBtn.hide();
36866 this.closeBtnState = this.closeBtn.getStyle('display');
36867 this.closeBtn.hide();
36869 this.stickBtn.show();
36872 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36873 this.beforeSlide();
36874 this.el.setStyle("z-index", 10001);
36875 this.el.slideIn(this.getSlideAnchor(), {
36876 callback: function(){
36878 this.initAutoHide();
36879 Roo.get(document).on("click", this.slideInIf, this);
36880 this.fireEvent("slideshow", this);
36887 afterSlideIn : function(){
36888 this.clearAutoHide();
36889 this.isSlid = false;
36890 this.clearMonitor();
36891 this.el.setStyle("z-index", "");
36892 if(this.collapseBtn){
36893 this.collapseBtn.show();
36895 this.closeBtn.setStyle('display', this.closeBtnState);
36897 this.stickBtn.hide();
36899 this.fireEvent("slidehide", this);
36902 slideIn : function(cb){
36903 if(!this.isSlid || this.el.hasActiveFx()){
36907 this.isSlid = false;
36908 this.beforeSlide();
36909 this.el.slideOut(this.getSlideAnchor(), {
36910 callback: function(){
36911 this.el.setLeftTop(-10000, -10000);
36913 this.afterSlideIn();
36921 slideInIf : function(e){
36922 if(!e.within(this.el)){
36927 animateCollapse : function(){
36928 this.beforeSlide();
36929 this.el.setStyle("z-index", 20000);
36930 var anchor = this.getSlideAnchor();
36931 this.el.slideOut(anchor, {
36932 callback : function(){
36933 this.el.setStyle("z-index", "");
36934 this.collapsedEl.slideIn(anchor, {duration:.3});
36936 this.el.setLocation(-10000,-10000);
36938 this.fireEvent("collapsed", this);
36945 animateExpand : function(){
36946 this.beforeSlide();
36947 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36948 this.el.setStyle("z-index", 20000);
36949 this.collapsedEl.hide({
36952 this.el.slideIn(this.getSlideAnchor(), {
36953 callback : function(){
36954 this.el.setStyle("z-index", "");
36957 this.split.el.show();
36959 this.fireEvent("invalidated", this);
36960 this.fireEvent("expanded", this);
36988 getAnchor : function(){
36989 return this.anchors[this.position];
36992 getCollapseAnchor : function(){
36993 return this.canchors[this.position];
36996 getSlideAnchor : function(){
36997 return this.sanchors[this.position];
37000 getAlignAdj : function(){
37001 var cm = this.cmargins;
37002 switch(this.position){
37018 getExpandAdj : function(){
37019 var c = this.collapsedEl, cm = this.cmargins;
37020 switch(this.position){
37022 return [-(cm.right+c.getWidth()+cm.left), 0];
37025 return [cm.right+c.getWidth()+cm.left, 0];
37028 return [0, -(cm.top+cm.bottom+c.getHeight())];
37031 return [0, cm.top+cm.bottom+c.getHeight()];
37037 * Ext JS Library 1.1.1
37038 * Copyright(c) 2006-2007, Ext JS, LLC.
37040 * Originally Released Under LGPL - original licence link has changed is not relivant.
37043 * <script type="text/javascript">
37046 * These classes are private internal classes
37048 Roo.bootstrap.layout.Center = function(config){
37049 config.region = "center";
37050 Roo.bootstrap.layout.Region.call(this, config);
37051 this.visible = true;
37052 this.minWidth = config.minWidth || 20;
37053 this.minHeight = config.minHeight || 20;
37056 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37058 // center panel can't be hidden
37062 // center panel can't be hidden
37065 getMinWidth: function(){
37066 return this.minWidth;
37069 getMinHeight: function(){
37070 return this.minHeight;
37084 Roo.bootstrap.layout.North = function(config)
37086 config.region = 'north';
37087 config.cursor = 'n-resize';
37089 Roo.bootstrap.layout.Split.call(this, config);
37093 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37094 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37095 this.split.el.addClass("roo-layout-split-v");
37097 var size = config.initialSize || config.height;
37098 if(typeof size != "undefined"){
37099 this.el.setHeight(size);
37102 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37104 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37108 getBox : function(){
37109 if(this.collapsed){
37110 return this.collapsedEl.getBox();
37112 var box = this.el.getBox();
37114 box.height += this.split.el.getHeight();
37119 updateBox : function(box){
37120 if(this.split && !this.collapsed){
37121 box.height -= this.split.el.getHeight();
37122 this.split.el.setLeft(box.x);
37123 this.split.el.setTop(box.y+box.height);
37124 this.split.el.setWidth(box.width);
37126 if(this.collapsed){
37127 this.updateBody(box.width, null);
37129 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37137 Roo.bootstrap.layout.South = function(config){
37138 config.region = 'south';
37139 config.cursor = 's-resize';
37140 Roo.bootstrap.layout.Split.call(this, config);
37142 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37143 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37144 this.split.el.addClass("roo-layout-split-v");
37146 var size = config.initialSize || config.height;
37147 if(typeof size != "undefined"){
37148 this.el.setHeight(size);
37152 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37153 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37154 getBox : function(){
37155 if(this.collapsed){
37156 return this.collapsedEl.getBox();
37158 var box = this.el.getBox();
37160 var sh = this.split.el.getHeight();
37167 updateBox : function(box){
37168 if(this.split && !this.collapsed){
37169 var sh = this.split.el.getHeight();
37172 this.split.el.setLeft(box.x);
37173 this.split.el.setTop(box.y-sh);
37174 this.split.el.setWidth(box.width);
37176 if(this.collapsed){
37177 this.updateBody(box.width, null);
37179 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37183 Roo.bootstrap.layout.East = function(config){
37184 config.region = "east";
37185 config.cursor = "e-resize";
37186 Roo.bootstrap.layout.Split.call(this, config);
37188 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37189 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37190 this.split.el.addClass("roo-layout-split-h");
37192 var size = config.initialSize || config.width;
37193 if(typeof size != "undefined"){
37194 this.el.setWidth(size);
37197 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37198 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37199 getBox : function(){
37200 if(this.collapsed){
37201 return this.collapsedEl.getBox();
37203 var box = this.el.getBox();
37205 var sw = this.split.el.getWidth();
37212 updateBox : function(box){
37213 if(this.split && !this.collapsed){
37214 var sw = this.split.el.getWidth();
37216 this.split.el.setLeft(box.x);
37217 this.split.el.setTop(box.y);
37218 this.split.el.setHeight(box.height);
37221 if(this.collapsed){
37222 this.updateBody(null, box.height);
37224 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37228 Roo.bootstrap.layout.West = function(config){
37229 config.region = "west";
37230 config.cursor = "w-resize";
37232 Roo.bootstrap.layout.Split.call(this, config);
37234 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37235 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37236 this.split.el.addClass("roo-layout-split-h");
37240 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37241 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37243 onRender: function(ctr, pos)
37245 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37246 var size = this.config.initialSize || this.config.width;
37247 if(typeof size != "undefined"){
37248 this.el.setWidth(size);
37252 getBox : function(){
37253 if(this.collapsed){
37254 return this.collapsedEl.getBox();
37256 var box = this.el.getBox();
37258 box.width += this.split.el.getWidth();
37263 updateBox : function(box){
37264 if(this.split && !this.collapsed){
37265 var sw = this.split.el.getWidth();
37267 this.split.el.setLeft(box.x+box.width);
37268 this.split.el.setTop(box.y);
37269 this.split.el.setHeight(box.height);
37271 if(this.collapsed){
37272 this.updateBody(null, box.height);
37274 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37276 });Roo.namespace("Roo.bootstrap.panel");/*
37278 * Ext JS Library 1.1.1
37279 * Copyright(c) 2006-2007, Ext JS, LLC.
37281 * Originally Released Under LGPL - original licence link has changed is not relivant.
37284 * <script type="text/javascript">
37287 * @class Roo.ContentPanel
37288 * @extends Roo.util.Observable
37289 * A basic ContentPanel element.
37290 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37291 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37292 * @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
37293 * @cfg {Boolean} closable True if the panel can be closed/removed
37294 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37295 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37296 * @cfg {Toolbar} toolbar A toolbar for this panel
37297 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37298 * @cfg {String} title The title for this panel
37299 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37300 * @cfg {String} url Calls {@link #setUrl} with this value
37301 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37302 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37303 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37304 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37305 * @cfg {Boolean} badges render the badges
37308 * Create a new ContentPanel.
37309 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37310 * @param {String/Object} config A string to set only the title or a config object
37311 * @param {String} content (optional) Set the HTML content for this panel
37312 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37314 Roo.bootstrap.panel.Content = function( config){
37316 this.tpl = config.tpl || false;
37318 var el = config.el;
37319 var content = config.content;
37321 if(config.autoCreate){ // xtype is available if this is called from factory
37324 this.el = Roo.get(el);
37325 if(!this.el && config && config.autoCreate){
37326 if(typeof config.autoCreate == "object"){
37327 if(!config.autoCreate.id){
37328 config.autoCreate.id = config.id||el;
37330 this.el = Roo.DomHelper.append(document.body,
37331 config.autoCreate, true);
37333 var elcfg = { tag: "div",
37334 cls: "roo-layout-inactive-content",
37338 elcfg.html = config.html;
37342 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37345 this.closable = false;
37346 this.loaded = false;
37347 this.active = false;
37350 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37352 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37354 this.wrapEl = this.el; //this.el.wrap();
37356 if (config.toolbar.items) {
37357 ti = config.toolbar.items ;
37358 delete config.toolbar.items ;
37362 this.toolbar.render(this.wrapEl, 'before');
37363 for(var i =0;i < ti.length;i++) {
37364 // Roo.log(['add child', items[i]]);
37365 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37367 this.toolbar.items = nitems;
37368 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37369 delete config.toolbar;
37373 // xtype created footer. - not sure if will work as we normally have to render first..
37374 if (this.footer && !this.footer.el && this.footer.xtype) {
37375 if (!this.wrapEl) {
37376 this.wrapEl = this.el.wrap();
37379 this.footer.container = this.wrapEl.createChild();
37381 this.footer = Roo.factory(this.footer, Roo);
37386 if(typeof config == "string"){
37387 this.title = config;
37389 Roo.apply(this, config);
37393 this.resizeEl = Roo.get(this.resizeEl, true);
37395 this.resizeEl = this.el;
37397 // handle view.xtype
37405 * Fires when this panel is activated.
37406 * @param {Roo.ContentPanel} this
37410 * @event deactivate
37411 * Fires when this panel is activated.
37412 * @param {Roo.ContentPanel} this
37414 "deactivate" : true,
37418 * Fires when this panel is resized if fitToFrame is true.
37419 * @param {Roo.ContentPanel} this
37420 * @param {Number} width The width after any component adjustments
37421 * @param {Number} height The height after any component adjustments
37427 * Fires when this tab is created
37428 * @param {Roo.ContentPanel} this
37439 if(this.autoScroll){
37440 this.resizeEl.setStyle("overflow", "auto");
37442 // fix randome scrolling
37443 //this.el.on('scroll', function() {
37444 // Roo.log('fix random scolling');
37445 // this.scrollTo('top',0);
37448 content = content || this.content;
37450 this.setContent(content);
37452 if(config && config.url){
37453 this.setUrl(this.url, this.params, this.loadOnce);
37458 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37460 if (this.view && typeof(this.view.xtype) != 'undefined') {
37461 this.view.el = this.el.appendChild(document.createElement("div"));
37462 this.view = Roo.factory(this.view);
37463 this.view.render && this.view.render(false, '');
37467 this.fireEvent('render', this);
37470 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37474 setRegion : function(region){
37475 this.region = region;
37476 this.setActiveClass(region && !this.background);
37480 setActiveClass: function(state)
37483 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37484 this.el.setStyle('position','relative');
37486 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37487 this.el.setStyle('position', 'absolute');
37492 * Returns the toolbar for this Panel if one was configured.
37493 * @return {Roo.Toolbar}
37495 getToolbar : function(){
37496 return this.toolbar;
37499 setActiveState : function(active)
37501 this.active = active;
37502 this.setActiveClass(active);
37504 if(this.fireEvent("deactivate", this) === false){
37509 this.fireEvent("activate", this);
37513 * Updates this panel's element
37514 * @param {String} content The new content
37515 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37517 setContent : function(content, loadScripts){
37518 this.el.update(content, loadScripts);
37521 ignoreResize : function(w, h){
37522 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37525 this.lastSize = {width: w, height: h};
37530 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37531 * @return {Roo.UpdateManager} The UpdateManager
37533 getUpdateManager : function(){
37534 return this.el.getUpdateManager();
37537 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37538 * @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:
37541 url: "your-url.php",
37542 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37543 callback: yourFunction,
37544 scope: yourObject, //(optional scope)
37547 text: "Loading...",
37552 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37553 * 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.
37554 * @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}
37555 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37556 * @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.
37557 * @return {Roo.ContentPanel} this
37560 var um = this.el.getUpdateManager();
37561 um.update.apply(um, arguments);
37567 * 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.
37568 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37569 * @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)
37570 * @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)
37571 * @return {Roo.UpdateManager} The UpdateManager
37573 setUrl : function(url, params, loadOnce){
37574 if(this.refreshDelegate){
37575 this.removeListener("activate", this.refreshDelegate);
37577 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37578 this.on("activate", this.refreshDelegate);
37579 return this.el.getUpdateManager();
37582 _handleRefresh : function(url, params, loadOnce){
37583 if(!loadOnce || !this.loaded){
37584 var updater = this.el.getUpdateManager();
37585 updater.update(url, params, this._setLoaded.createDelegate(this));
37589 _setLoaded : function(){
37590 this.loaded = true;
37594 * Returns this panel's id
37597 getId : function(){
37602 * Returns this panel's element - used by regiosn to add.
37603 * @return {Roo.Element}
37605 getEl : function(){
37606 return this.wrapEl || this.el;
37611 adjustForComponents : function(width, height)
37613 //Roo.log('adjustForComponents ');
37614 if(this.resizeEl != this.el){
37615 width -= this.el.getFrameWidth('lr');
37616 height -= this.el.getFrameWidth('tb');
37619 var te = this.toolbar.getEl();
37620 te.setWidth(width);
37621 height -= te.getHeight();
37624 var te = this.footer.getEl();
37625 te.setWidth(width);
37626 height -= te.getHeight();
37630 if(this.adjustments){
37631 width += this.adjustments[0];
37632 height += this.adjustments[1];
37634 return {"width": width, "height": height};
37637 setSize : function(width, height){
37638 if(this.fitToFrame && !this.ignoreResize(width, height)){
37639 if(this.fitContainer && this.resizeEl != this.el){
37640 this.el.setSize(width, height);
37642 var size = this.adjustForComponents(width, height);
37643 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37644 this.fireEvent('resize', this, size.width, size.height);
37649 * Returns this panel's title
37652 getTitle : function(){
37654 if (typeof(this.title) != 'object') {
37659 for (var k in this.title) {
37660 if (!this.title.hasOwnProperty(k)) {
37664 if (k.indexOf('-') >= 0) {
37665 var s = k.split('-');
37666 for (var i = 0; i<s.length; i++) {
37667 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37670 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37677 * Set this panel's title
37678 * @param {String} title
37680 setTitle : function(title){
37681 this.title = title;
37683 this.region.updatePanelTitle(this, title);
37688 * Returns true is this panel was configured to be closable
37689 * @return {Boolean}
37691 isClosable : function(){
37692 return this.closable;
37695 beforeSlide : function(){
37697 this.resizeEl.clip();
37700 afterSlide : function(){
37702 this.resizeEl.unclip();
37706 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37707 * Will fail silently if the {@link #setUrl} method has not been called.
37708 * This does not activate the panel, just updates its content.
37710 refresh : function(){
37711 if(this.refreshDelegate){
37712 this.loaded = false;
37713 this.refreshDelegate();
37718 * Destroys this panel
37720 destroy : function(){
37721 this.el.removeAllListeners();
37722 var tempEl = document.createElement("span");
37723 tempEl.appendChild(this.el.dom);
37724 tempEl.innerHTML = "";
37730 * form - if the content panel contains a form - this is a reference to it.
37731 * @type {Roo.form.Form}
37735 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37736 * This contains a reference to it.
37742 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37752 * @param {Object} cfg Xtype definition of item to add.
37756 getChildContainer: function () {
37757 return this.getEl();
37762 var ret = new Roo.factory(cfg);
37767 if (cfg.xtype.match(/^Form$/)) {
37770 //if (this.footer) {
37771 // el = this.footer.container.insertSibling(false, 'before');
37773 el = this.el.createChild();
37776 this.form = new Roo.form.Form(cfg);
37779 if ( this.form.allItems.length) {
37780 this.form.render(el.dom);
37784 // should only have one of theses..
37785 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37786 // views.. should not be just added - used named prop 'view''
37788 cfg.el = this.el.appendChild(document.createElement("div"));
37791 var ret = new Roo.factory(cfg);
37793 ret.render && ret.render(false, ''); // render blank..
37803 * @class Roo.bootstrap.panel.Grid
37804 * @extends Roo.bootstrap.panel.Content
37806 * Create a new GridPanel.
37807 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37808 * @param {Object} config A the config object
37814 Roo.bootstrap.panel.Grid = function(config)
37818 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37819 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37821 config.el = this.wrapper;
37822 //this.el = this.wrapper;
37824 if (config.container) {
37825 // ctor'ed from a Border/panel.grid
37828 this.wrapper.setStyle("overflow", "hidden");
37829 this.wrapper.addClass('roo-grid-container');
37834 if(config.toolbar){
37835 var tool_el = this.wrapper.createChild();
37836 this.toolbar = Roo.factory(config.toolbar);
37838 if (config.toolbar.items) {
37839 ti = config.toolbar.items ;
37840 delete config.toolbar.items ;
37844 this.toolbar.render(tool_el);
37845 for(var i =0;i < ti.length;i++) {
37846 // Roo.log(['add child', items[i]]);
37847 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37849 this.toolbar.items = nitems;
37851 delete config.toolbar;
37854 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37855 config.grid.scrollBody = true;;
37856 config.grid.monitorWindowResize = false; // turn off autosizing
37857 config.grid.autoHeight = false;
37858 config.grid.autoWidth = false;
37860 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37862 if (config.background) {
37863 // render grid on panel activation (if panel background)
37864 this.on('activate', function(gp) {
37865 if (!gp.grid.rendered) {
37866 gp.grid.render(this.wrapper);
37867 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37872 this.grid.render(this.wrapper);
37873 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37876 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37877 // ??? needed ??? config.el = this.wrapper;
37882 // xtype created footer. - not sure if will work as we normally have to render first..
37883 if (this.footer && !this.footer.el && this.footer.xtype) {
37885 var ctr = this.grid.getView().getFooterPanel(true);
37886 this.footer.dataSource = this.grid.dataSource;
37887 this.footer = Roo.factory(this.footer, Roo);
37888 this.footer.render(ctr);
37898 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37899 getId : function(){
37900 return this.grid.id;
37904 * Returns the grid for this panel
37905 * @return {Roo.bootstrap.Table}
37907 getGrid : function(){
37911 setSize : function(width, height){
37912 if(!this.ignoreResize(width, height)){
37913 var grid = this.grid;
37914 var size = this.adjustForComponents(width, height);
37915 var gridel = grid.getGridEl();
37916 gridel.setSize(size.width, size.height);
37918 var thd = grid.getGridEl().select('thead',true).first();
37919 var tbd = grid.getGridEl().select('tbody', true).first();
37921 tbd.setSize(width, height - thd.getHeight());
37930 beforeSlide : function(){
37931 this.grid.getView().scroller.clip();
37934 afterSlide : function(){
37935 this.grid.getView().scroller.unclip();
37938 destroy : function(){
37939 this.grid.destroy();
37941 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37946 * @class Roo.bootstrap.panel.Nest
37947 * @extends Roo.bootstrap.panel.Content
37949 * Create a new Panel, that can contain a layout.Border.
37952 * @param {Roo.BorderLayout} layout The layout for this panel
37953 * @param {String/Object} config A string to set only the title or a config object
37955 Roo.bootstrap.panel.Nest = function(config)
37957 // construct with only one argument..
37958 /* FIXME - implement nicer consturctors
37959 if (layout.layout) {
37961 layout = config.layout;
37962 delete config.layout;
37964 if (layout.xtype && !layout.getEl) {
37965 // then layout needs constructing..
37966 layout = Roo.factory(layout, Roo);
37970 config.el = config.layout.getEl();
37972 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37974 config.layout.monitorWindowResize = false; // turn off autosizing
37975 this.layout = config.layout;
37976 this.layout.getEl().addClass("roo-layout-nested-layout");
37977 this.layout.parent = this;
37984 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37986 setSize : function(width, height){
37987 if(!this.ignoreResize(width, height)){
37988 var size = this.adjustForComponents(width, height);
37989 var el = this.layout.getEl();
37990 if (size.height < 1) {
37991 el.setWidth(size.width);
37993 el.setSize(size.width, size.height);
37995 var touch = el.dom.offsetWidth;
37996 this.layout.layout();
37997 // ie requires a double layout on the first pass
37998 if(Roo.isIE && !this.initialized){
37999 this.initialized = true;
38000 this.layout.layout();
38005 // activate all subpanels if not currently active..
38007 setActiveState : function(active){
38008 this.active = active;
38009 this.setActiveClass(active);
38012 this.fireEvent("deactivate", this);
38016 this.fireEvent("activate", this);
38017 // not sure if this should happen before or after..
38018 if (!this.layout) {
38019 return; // should not happen..
38022 for (var r in this.layout.regions) {
38023 reg = this.layout.getRegion(r);
38024 if (reg.getActivePanel()) {
38025 //reg.showPanel(reg.getActivePanel()); // force it to activate..
38026 reg.setActivePanel(reg.getActivePanel());
38029 if (!reg.panels.length) {
38032 reg.showPanel(reg.getPanel(0));
38041 * Returns the nested BorderLayout for this panel
38042 * @return {Roo.BorderLayout}
38044 getLayout : function(){
38045 return this.layout;
38049 * Adds a xtype elements to the layout of the nested panel
38053 xtype : 'ContentPanel',
38060 xtype : 'NestedLayoutPanel',
38066 items : [ ... list of content panels or nested layout panels.. ]
38070 * @param {Object} cfg Xtype definition of item to add.
38072 addxtype : function(cfg) {
38073 return this.layout.addxtype(cfg);
38078 * Ext JS Library 1.1.1
38079 * Copyright(c) 2006-2007, Ext JS, LLC.
38081 * Originally Released Under LGPL - original licence link has changed is not relivant.
38084 * <script type="text/javascript">
38087 * @class Roo.TabPanel
38088 * @extends Roo.util.Observable
38089 * A lightweight tab container.
38093 // basic tabs 1, built from existing content
38094 var tabs = new Roo.TabPanel("tabs1");
38095 tabs.addTab("script", "View Script");
38096 tabs.addTab("markup", "View Markup");
38097 tabs.activate("script");
38099 // more advanced tabs, built from javascript
38100 var jtabs = new Roo.TabPanel("jtabs");
38101 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38103 // set up the UpdateManager
38104 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38105 var updater = tab2.getUpdateManager();
38106 updater.setDefaultUrl("ajax1.htm");
38107 tab2.on('activate', updater.refresh, updater, true);
38109 // Use setUrl for Ajax loading
38110 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38111 tab3.setUrl("ajax2.htm", null, true);
38114 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38117 jtabs.activate("jtabs-1");
38120 * Create a new TabPanel.
38121 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38122 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38124 Roo.bootstrap.panel.Tabs = function(config){
38126 * The container element for this TabPanel.
38127 * @type Roo.Element
38129 this.el = Roo.get(config.el);
38132 if(typeof config == "boolean"){
38133 this.tabPosition = config ? "bottom" : "top";
38135 Roo.apply(this, config);
38139 if(this.tabPosition == "bottom"){
38140 // if tabs are at the bottom = create the body first.
38141 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38142 this.el.addClass("roo-tabs-bottom");
38144 // next create the tabs holders
38146 if (this.tabPosition == "west"){
38148 var reg = this.region; // fake it..
38150 if (!reg.mgr.parent) {
38153 reg = reg.mgr.parent.region;
38155 Roo.log("got nest?");
38157 if (reg.mgr.getRegion('west')) {
38158 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38159 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38160 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38161 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38162 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38170 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38171 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38172 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38173 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38178 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38181 // finally - if tabs are at the top, then create the body last..
38182 if(this.tabPosition != "bottom"){
38183 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38184 * @type Roo.Element
38186 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38187 this.el.addClass("roo-tabs-top");
38191 this.bodyEl.setStyle("position", "relative");
38193 this.active = null;
38194 this.activateDelegate = this.activate.createDelegate(this);
38199 * Fires when the active tab changes
38200 * @param {Roo.TabPanel} this
38201 * @param {Roo.TabPanelItem} activePanel The new active tab
38205 * @event beforetabchange
38206 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38207 * @param {Roo.TabPanel} this
38208 * @param {Object} e Set cancel to true on this object to cancel the tab change
38209 * @param {Roo.TabPanelItem} tab The tab being changed to
38211 "beforetabchange" : true
38214 Roo.EventManager.onWindowResize(this.onResize, this);
38215 this.cpad = this.el.getPadding("lr");
38216 this.hiddenCount = 0;
38219 // toolbar on the tabbar support...
38220 if (this.toolbar) {
38221 alert("no toolbar support yet");
38222 this.toolbar = false;
38224 var tcfg = this.toolbar;
38225 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38226 this.toolbar = new Roo.Toolbar(tcfg);
38227 if (Roo.isSafari) {
38228 var tbl = tcfg.container.child('table', true);
38229 tbl.setAttribute('width', '100%');
38237 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38240 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38242 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38244 tabPosition : "top",
38246 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38248 currentTabWidth : 0,
38250 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38254 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38258 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38260 preferredTabWidth : 175,
38262 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38264 resizeTabs : false,
38266 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38268 monitorResize : true,
38270 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38272 toolbar : false, // set by caller..
38274 region : false, /// set by caller
38276 disableTooltips : true, // not used yet...
38279 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38280 * @param {String} id The id of the div to use <b>or create</b>
38281 * @param {String} text The text for the tab
38282 * @param {String} content (optional) Content to put in the TabPanelItem body
38283 * @param {Boolean} closable (optional) True to create a close icon on the tab
38284 * @return {Roo.TabPanelItem} The created TabPanelItem
38286 addTab : function(id, text, content, closable, tpl)
38288 var item = new Roo.bootstrap.panel.TabItem({
38292 closable : closable,
38295 this.addTabItem(item);
38297 item.setContent(content);
38303 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38304 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38305 * @return {Roo.TabPanelItem}
38307 getTab : function(id){
38308 return this.items[id];
38312 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38313 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38315 hideTab : function(id){
38316 var t = this.items[id];
38319 this.hiddenCount++;
38320 this.autoSizeTabs();
38325 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38326 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38328 unhideTab : function(id){
38329 var t = this.items[id];
38331 t.setHidden(false);
38332 this.hiddenCount--;
38333 this.autoSizeTabs();
38338 * Adds an existing {@link Roo.TabPanelItem}.
38339 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38341 addTabItem : function(item)
38343 this.items[item.id] = item;
38344 this.items.push(item);
38345 this.autoSizeTabs();
38346 // if(this.resizeTabs){
38347 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38348 // this.autoSizeTabs();
38350 // item.autoSize();
38355 * Removes a {@link Roo.TabPanelItem}.
38356 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38358 removeTab : function(id){
38359 var items = this.items;
38360 var tab = items[id];
38361 if(!tab) { return; }
38362 var index = items.indexOf(tab);
38363 if(this.active == tab && items.length > 1){
38364 var newTab = this.getNextAvailable(index);
38369 this.stripEl.dom.removeChild(tab.pnode.dom);
38370 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38371 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38373 items.splice(index, 1);
38374 delete this.items[tab.id];
38375 tab.fireEvent("close", tab);
38376 tab.purgeListeners();
38377 this.autoSizeTabs();
38380 getNextAvailable : function(start){
38381 var items = this.items;
38383 // look for a next tab that will slide over to
38384 // replace the one being removed
38385 while(index < items.length){
38386 var item = items[++index];
38387 if(item && !item.isHidden()){
38391 // if one isn't found select the previous tab (on the left)
38394 var item = items[--index];
38395 if(item && !item.isHidden()){
38403 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38404 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38406 disableTab : function(id){
38407 var tab = this.items[id];
38408 if(tab && this.active != tab){
38414 * Enables a {@link Roo.TabPanelItem} that is disabled.
38415 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38417 enableTab : function(id){
38418 var tab = this.items[id];
38423 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38424 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38425 * @return {Roo.TabPanelItem} The TabPanelItem.
38427 activate : function(id)
38429 //Roo.log('activite:' + id);
38431 var tab = this.items[id];
38435 if(tab == this.active || tab.disabled){
38439 this.fireEvent("beforetabchange", this, e, tab);
38440 if(e.cancel !== true && !tab.disabled){
38442 this.active.hide();
38444 this.active = this.items[id];
38445 this.active.show();
38446 this.fireEvent("tabchange", this, this.active);
38452 * Gets the active {@link Roo.TabPanelItem}.
38453 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38455 getActiveTab : function(){
38456 return this.active;
38460 * Updates the tab body element to fit the height of the container element
38461 * for overflow scrolling
38462 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38464 syncHeight : function(targetHeight){
38465 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38466 var bm = this.bodyEl.getMargins();
38467 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38468 this.bodyEl.setHeight(newHeight);
38472 onResize : function(){
38473 if(this.monitorResize){
38474 this.autoSizeTabs();
38479 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38481 beginUpdate : function(){
38482 this.updating = true;
38486 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38488 endUpdate : function(){
38489 this.updating = false;
38490 this.autoSizeTabs();
38494 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38496 autoSizeTabs : function()
38498 var count = this.items.length;
38499 var vcount = count - this.hiddenCount;
38502 this.stripEl.hide();
38504 this.stripEl.show();
38507 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38512 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38513 var availWidth = Math.floor(w / vcount);
38514 var b = this.stripBody;
38515 if(b.getWidth() > w){
38516 var tabs = this.items;
38517 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38518 if(availWidth < this.minTabWidth){
38519 /*if(!this.sleft){ // incomplete scrolling code
38520 this.createScrollButtons();
38523 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38526 if(this.currentTabWidth < this.preferredTabWidth){
38527 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38533 * Returns the number of tabs in this TabPanel.
38536 getCount : function(){
38537 return this.items.length;
38541 * Resizes all the tabs to the passed width
38542 * @param {Number} The new width
38544 setTabWidth : function(width){
38545 this.currentTabWidth = width;
38546 for(var i = 0, len = this.items.length; i < len; i++) {
38547 if(!this.items[i].isHidden()) {
38548 this.items[i].setWidth(width);
38554 * Destroys this TabPanel
38555 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38557 destroy : function(removeEl){
38558 Roo.EventManager.removeResizeListener(this.onResize, this);
38559 for(var i = 0, len = this.items.length; i < len; i++){
38560 this.items[i].purgeListeners();
38562 if(removeEl === true){
38563 this.el.update("");
38568 createStrip : function(container)
38570 var strip = document.createElement("nav");
38571 strip.className = Roo.bootstrap.version == 4 ?
38572 "navbar-light bg-light" :
38573 "navbar navbar-default"; //"x-tabs-wrap";
38574 container.appendChild(strip);
38578 createStripList : function(strip)
38580 // div wrapper for retard IE
38581 // returns the "tr" element.
38582 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38583 //'<div class="x-tabs-strip-wrap">'+
38584 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38585 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38586 return strip.firstChild; //.firstChild.firstChild.firstChild;
38588 createBody : function(container)
38590 var body = document.createElement("div");
38591 Roo.id(body, "tab-body");
38592 //Roo.fly(body).addClass("x-tabs-body");
38593 Roo.fly(body).addClass("tab-content");
38594 container.appendChild(body);
38597 createItemBody :function(bodyEl, id){
38598 var body = Roo.getDom(id);
38600 body = document.createElement("div");
38603 //Roo.fly(body).addClass("x-tabs-item-body");
38604 Roo.fly(body).addClass("tab-pane");
38605 bodyEl.insertBefore(body, bodyEl.firstChild);
38609 createStripElements : function(stripEl, text, closable, tpl)
38611 var td = document.createElement("li"); // was td..
38612 td.className = 'nav-item';
38614 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38617 stripEl.appendChild(td);
38619 td.className = "x-tabs-closable";
38620 if(!this.closeTpl){
38621 this.closeTpl = new Roo.Template(
38622 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38623 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38624 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38627 var el = this.closeTpl.overwrite(td, {"text": text});
38628 var close = el.getElementsByTagName("div")[0];
38629 var inner = el.getElementsByTagName("em")[0];
38630 return {"el": el, "close": close, "inner": inner};
38633 // not sure what this is..
38634 // if(!this.tabTpl){
38635 //this.tabTpl = new Roo.Template(
38636 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38637 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38639 // this.tabTpl = new Roo.Template(
38640 // '<a href="#">' +
38641 // '<span unselectable="on"' +
38642 // (this.disableTooltips ? '' : ' title="{text}"') +
38643 // ' >{text}</span></a>'
38649 var template = tpl || this.tabTpl || false;
38652 template = new Roo.Template(
38653 Roo.bootstrap.version == 4 ?
38655 '<a class="nav-link" href="#" unselectable="on"' +
38656 (this.disableTooltips ? '' : ' title="{text}"') +
38659 '<a class="nav-link" href="#">' +
38660 '<span unselectable="on"' +
38661 (this.disableTooltips ? '' : ' title="{text}"') +
38662 ' >{text}</span></a>'
38667 switch (typeof(template)) {
38671 template = new Roo.Template(template);
38677 var el = template.overwrite(td, {"text": text});
38679 var inner = el.getElementsByTagName("span")[0];
38681 return {"el": el, "inner": inner};
38689 * @class Roo.TabPanelItem
38690 * @extends Roo.util.Observable
38691 * Represents an individual item (tab plus body) in a TabPanel.
38692 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38693 * @param {String} id The id of this TabPanelItem
38694 * @param {String} text The text for the tab of this TabPanelItem
38695 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38697 Roo.bootstrap.panel.TabItem = function(config){
38699 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38700 * @type Roo.TabPanel
38702 this.tabPanel = config.panel;
38704 * The id for this TabPanelItem
38707 this.id = config.id;
38709 this.disabled = false;
38711 this.text = config.text;
38713 this.loaded = false;
38714 this.closable = config.closable;
38717 * The body element for this TabPanelItem.
38718 * @type Roo.Element
38720 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38721 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38722 this.bodyEl.setStyle("display", "block");
38723 this.bodyEl.setStyle("zoom", "1");
38724 //this.hideAction();
38726 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38728 this.el = Roo.get(els.el);
38729 this.inner = Roo.get(els.inner, true);
38730 this.textEl = Roo.bootstrap.version == 4 ?
38731 this.el : Roo.get(this.el.dom.firstChild, true);
38733 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38734 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38737 // this.el.on("mousedown", this.onTabMouseDown, this);
38738 this.el.on("click", this.onTabClick, this);
38740 if(config.closable){
38741 var c = Roo.get(els.close, true);
38742 c.dom.title = this.closeText;
38743 c.addClassOnOver("close-over");
38744 c.on("click", this.closeClick, this);
38750 * Fires when this tab becomes the active tab.
38751 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38752 * @param {Roo.TabPanelItem} this
38756 * @event beforeclose
38757 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38758 * @param {Roo.TabPanelItem} this
38759 * @param {Object} e Set cancel to true on this object to cancel the close.
38761 "beforeclose": true,
38764 * Fires when this tab is closed.
38765 * @param {Roo.TabPanelItem} this
38769 * @event deactivate
38770 * Fires when this tab is no longer the active tab.
38771 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38772 * @param {Roo.TabPanelItem} this
38774 "deactivate" : true
38776 this.hidden = false;
38778 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38781 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38783 purgeListeners : function(){
38784 Roo.util.Observable.prototype.purgeListeners.call(this);
38785 this.el.removeAllListeners();
38788 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38791 this.status_node.addClass("active");
38794 this.tabPanel.stripWrap.repaint();
38796 this.fireEvent("activate", this.tabPanel, this);
38800 * Returns true if this tab is the active tab.
38801 * @return {Boolean}
38803 isActive : function(){
38804 return this.tabPanel.getActiveTab() == this;
38808 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38811 this.status_node.removeClass("active");
38813 this.fireEvent("deactivate", this.tabPanel, this);
38816 hideAction : function(){
38817 this.bodyEl.hide();
38818 this.bodyEl.setStyle("position", "absolute");
38819 this.bodyEl.setLeft("-20000px");
38820 this.bodyEl.setTop("-20000px");
38823 showAction : function(){
38824 this.bodyEl.setStyle("position", "relative");
38825 this.bodyEl.setTop("");
38826 this.bodyEl.setLeft("");
38827 this.bodyEl.show();
38831 * Set the tooltip for the tab.
38832 * @param {String} tooltip The tab's tooltip
38834 setTooltip : function(text){
38835 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38836 this.textEl.dom.qtip = text;
38837 this.textEl.dom.removeAttribute('title');
38839 this.textEl.dom.title = text;
38843 onTabClick : function(e){
38844 e.preventDefault();
38845 this.tabPanel.activate(this.id);
38848 onTabMouseDown : function(e){
38849 e.preventDefault();
38850 this.tabPanel.activate(this.id);
38853 getWidth : function(){
38854 return this.inner.getWidth();
38857 setWidth : function(width){
38858 var iwidth = width - this.linode.getPadding("lr");
38859 this.inner.setWidth(iwidth);
38860 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38861 this.linode.setWidth(width);
38865 * Show or hide the tab
38866 * @param {Boolean} hidden True to hide or false to show.
38868 setHidden : function(hidden){
38869 this.hidden = hidden;
38870 this.linode.setStyle("display", hidden ? "none" : "");
38874 * Returns true if this tab is "hidden"
38875 * @return {Boolean}
38877 isHidden : function(){
38878 return this.hidden;
38882 * Returns the text for this tab
38885 getText : function(){
38889 autoSize : function(){
38890 //this.el.beginMeasure();
38891 this.textEl.setWidth(1);
38893 * #2804 [new] Tabs in Roojs
38894 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38896 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38897 //this.el.endMeasure();
38901 * Sets the text for the tab (Note: this also sets the tooltip text)
38902 * @param {String} text The tab's text and tooltip
38904 setText : function(text){
38906 this.textEl.update(text);
38907 this.setTooltip(text);
38908 //if(!this.tabPanel.resizeTabs){
38909 // this.autoSize();
38913 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38915 activate : function(){
38916 this.tabPanel.activate(this.id);
38920 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38922 disable : function(){
38923 if(this.tabPanel.active != this){
38924 this.disabled = true;
38925 this.status_node.addClass("disabled");
38930 * Enables this TabPanelItem if it was previously disabled.
38932 enable : function(){
38933 this.disabled = false;
38934 this.status_node.removeClass("disabled");
38938 * Sets the content for this TabPanelItem.
38939 * @param {String} content The content
38940 * @param {Boolean} loadScripts true to look for and load scripts
38942 setContent : function(content, loadScripts){
38943 this.bodyEl.update(content, loadScripts);
38947 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38948 * @return {Roo.UpdateManager} The UpdateManager
38950 getUpdateManager : function(){
38951 return this.bodyEl.getUpdateManager();
38955 * Set a URL to be used to load the content for this TabPanelItem.
38956 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38957 * @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)
38958 * @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)
38959 * @return {Roo.UpdateManager} The UpdateManager
38961 setUrl : function(url, params, loadOnce){
38962 if(this.refreshDelegate){
38963 this.un('activate', this.refreshDelegate);
38965 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38966 this.on("activate", this.refreshDelegate);
38967 return this.bodyEl.getUpdateManager();
38971 _handleRefresh : function(url, params, loadOnce){
38972 if(!loadOnce || !this.loaded){
38973 var updater = this.bodyEl.getUpdateManager();
38974 updater.update(url, params, this._setLoaded.createDelegate(this));
38979 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38980 * Will fail silently if the setUrl method has not been called.
38981 * This does not activate the panel, just updates its content.
38983 refresh : function(){
38984 if(this.refreshDelegate){
38985 this.loaded = false;
38986 this.refreshDelegate();
38991 _setLoaded : function(){
38992 this.loaded = true;
38996 closeClick : function(e){
38999 this.fireEvent("beforeclose", this, o);
39000 if(o.cancel !== true){
39001 this.tabPanel.removeTab(this.id);
39005 * The text displayed in the tooltip for the close icon.
39008 closeText : "Close this tab"
39011 * This script refer to:
39012 * Title: International Telephone Input
39013 * Author: Jack O'Connor
39014 * Code version: v12.1.12
39015 * Availability: https://github.com/jackocnr/intl-tel-input.git
39018 Roo.bootstrap.PhoneInputData = function() {
39021 "Afghanistan (افغانستان)",
39026 "Albania (Shqipëri)",
39031 "Algeria (الجزائر)",
39056 "Antigua and Barbuda",
39066 "Armenia (Հայաստան)",
39082 "Austria (Österreich)",
39087 "Azerbaijan (Azərbaycan)",
39097 "Bahrain (البحرين)",
39102 "Bangladesh (বাংলাদেশ)",
39112 "Belarus (Беларусь)",
39117 "Belgium (België)",
39147 "Bosnia and Herzegovina (Босна и Херцеговина)",
39162 "British Indian Ocean Territory",
39167 "British Virgin Islands",
39177 "Bulgaria (България)",
39187 "Burundi (Uburundi)",
39192 "Cambodia (កម្ពុជា)",
39197 "Cameroon (Cameroun)",
39206 ["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"]
39209 "Cape Verde (Kabu Verdi)",
39214 "Caribbean Netherlands",
39225 "Central African Republic (République centrafricaine)",
39245 "Christmas Island",
39251 "Cocos (Keeling) Islands",
39262 "Comoros (جزر القمر)",
39267 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39272 "Congo (Republic) (Congo-Brazzaville)",
39292 "Croatia (Hrvatska)",
39313 "Czech Republic (Česká republika)",
39318 "Denmark (Danmark)",
39333 "Dominican Republic (República Dominicana)",
39337 ["809", "829", "849"]
39355 "Equatorial Guinea (Guinea Ecuatorial)",
39375 "Falkland Islands (Islas Malvinas)",
39380 "Faroe Islands (Føroyar)",
39401 "French Guiana (Guyane française)",
39406 "French Polynesia (Polynésie française)",
39421 "Georgia (საქართველო)",
39426 "Germany (Deutschland)",
39446 "Greenland (Kalaallit Nunaat)",
39483 "Guinea-Bissau (Guiné Bissau)",
39508 "Hungary (Magyarország)",
39513 "Iceland (Ísland)",
39533 "Iraq (العراق)",
39549 "Israel (ישראל)",
39576 "Jordan (الأردن)",
39581 "Kazakhstan (Казахстан)",
39602 "Kuwait (الكويت)",
39607 "Kyrgyzstan (Кыргызстан)",
39617 "Latvia (Latvija)",
39622 "Lebanon (لبنان)",
39637 "Libya (ليبيا)",
39647 "Lithuania (Lietuva)",
39662 "Macedonia (FYROM) (Македонија)",
39667 "Madagascar (Madagasikara)",
39697 "Marshall Islands",
39707 "Mauritania (موريتانيا)",
39712 "Mauritius (Moris)",
39733 "Moldova (Republica Moldova)",
39743 "Mongolia (Монгол)",
39748 "Montenegro (Crna Gora)",
39758 "Morocco (المغرب)",
39764 "Mozambique (Moçambique)",
39769 "Myanmar (Burma) (မြန်မာ)",
39774 "Namibia (Namibië)",
39789 "Netherlands (Nederland)",
39794 "New Caledonia (Nouvelle-Calédonie)",
39829 "North Korea (조선 민주주의 인민 공화국)",
39834 "Northern Mariana Islands",
39850 "Pakistan (پاکستان)",
39860 "Palestine (فلسطين)",
39870 "Papua New Guinea",
39912 "Réunion (La Réunion)",
39918 "Romania (România)",
39934 "Saint Barthélemy",
39945 "Saint Kitts and Nevis",
39955 "Saint Martin (Saint-Martin (partie française))",
39961 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39966 "Saint Vincent and the Grenadines",
39981 "São Tomé and Príncipe (São Tomé e Príncipe)",
39986 "Saudi Arabia (المملكة العربية السعودية)",
39991 "Senegal (Sénégal)",
40021 "Slovakia (Slovensko)",
40026 "Slovenia (Slovenija)",
40036 "Somalia (Soomaaliya)",
40046 "South Korea (대한민국)",
40051 "South Sudan (جنوب السودان)",
40061 "Sri Lanka (ශ්රී ලංකාව)",
40066 "Sudan (السودان)",
40076 "Svalbard and Jan Mayen",
40087 "Sweden (Sverige)",
40092 "Switzerland (Schweiz)",
40097 "Syria (سوريا)",
40142 "Trinidad and Tobago",
40147 "Tunisia (تونس)",
40152 "Turkey (Türkiye)",
40162 "Turks and Caicos Islands",
40172 "U.S. Virgin Islands",
40182 "Ukraine (Україна)",
40187 "United Arab Emirates (الإمارات العربية المتحدة)",
40209 "Uzbekistan (Oʻzbekiston)",
40219 "Vatican City (Città del Vaticano)",
40230 "Vietnam (Việt Nam)",
40235 "Wallis and Futuna (Wallis-et-Futuna)",
40240 "Western Sahara (الصحراء الغربية)",
40246 "Yemen (اليمن)",
40270 * This script refer to:
40271 * Title: International Telephone Input
40272 * Author: Jack O'Connor
40273 * Code version: v12.1.12
40274 * Availability: https://github.com/jackocnr/intl-tel-input.git
40278 * @class Roo.bootstrap.PhoneInput
40279 * @extends Roo.bootstrap.TriggerField
40280 * An input with International dial-code selection
40282 * @cfg {String} defaultDialCode default '+852'
40283 * @cfg {Array} preferedCountries default []
40286 * Create a new PhoneInput.
40287 * @param {Object} config Configuration options
40290 Roo.bootstrap.PhoneInput = function(config) {
40291 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40294 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40296 listWidth: undefined,
40298 selectedClass: 'active',
40300 invalidClass : "has-warning",
40302 validClass: 'has-success',
40304 allowed: '0123456789',
40309 * @cfg {String} defaultDialCode The default dial code when initializing the input
40311 defaultDialCode: '+852',
40314 * @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
40316 preferedCountries: false,
40318 getAutoCreate : function()
40320 var data = Roo.bootstrap.PhoneInputData();
40321 var align = this.labelAlign || this.parentLabelAlign();
40324 this.allCountries = [];
40325 this.dialCodeMapping = [];
40327 for (var i = 0; i < data.length; i++) {
40329 this.allCountries[i] = {
40333 priority: c[3] || 0,
40334 areaCodes: c[4] || null
40336 this.dialCodeMapping[c[2]] = {
40339 priority: c[3] || 0,
40340 areaCodes: c[4] || null
40352 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40353 maxlength: this.max_length,
40354 cls : 'form-control tel-input',
40355 autocomplete: 'new-password'
40358 var hiddenInput = {
40361 cls: 'hidden-tel-input'
40365 hiddenInput.name = this.name;
40368 if (this.disabled) {
40369 input.disabled = true;
40372 var flag_container = {
40389 cls: this.hasFeedback ? 'has-feedback' : '',
40395 cls: 'dial-code-holder',
40402 cls: 'roo-select2-container input-group',
40409 if (this.fieldLabel.length) {
40412 tooltip: 'This field is required'
40418 cls: 'control-label',
40424 html: this.fieldLabel
40427 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40433 if(this.indicatorpos == 'right') {
40434 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40441 if(align == 'left') {
40449 if(this.labelWidth > 12){
40450 label.style = "width: " + this.labelWidth + 'px';
40452 if(this.labelWidth < 13 && this.labelmd == 0){
40453 this.labelmd = this.labelWidth;
40455 if(this.labellg > 0){
40456 label.cls += ' col-lg-' + this.labellg;
40457 input.cls += ' col-lg-' + (12 - this.labellg);
40459 if(this.labelmd > 0){
40460 label.cls += ' col-md-' + this.labelmd;
40461 container.cls += ' col-md-' + (12 - this.labelmd);
40463 if(this.labelsm > 0){
40464 label.cls += ' col-sm-' + this.labelsm;
40465 container.cls += ' col-sm-' + (12 - this.labelsm);
40467 if(this.labelxs > 0){
40468 label.cls += ' col-xs-' + this.labelxs;
40469 container.cls += ' col-xs-' + (12 - this.labelxs);
40479 var settings = this;
40481 ['xs','sm','md','lg'].map(function(size){
40482 if (settings[size]) {
40483 cfg.cls += ' col-' + size + '-' + settings[size];
40487 this.store = new Roo.data.Store({
40488 proxy : new Roo.data.MemoryProxy({}),
40489 reader : new Roo.data.JsonReader({
40500 'name' : 'dialCode',
40504 'name' : 'priority',
40508 'name' : 'areaCodes',
40515 if(!this.preferedCountries) {
40516 this.preferedCountries = [
40523 var p = this.preferedCountries.reverse();
40526 for (var i = 0; i < p.length; i++) {
40527 for (var j = 0; j < this.allCountries.length; j++) {
40528 if(this.allCountries[j].iso2 == p[i]) {
40529 var t = this.allCountries[j];
40530 this.allCountries.splice(j,1);
40531 this.allCountries.unshift(t);
40537 this.store.proxy.data = {
40539 data: this.allCountries
40545 initEvents : function()
40548 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40550 this.indicator = this.indicatorEl();
40551 this.flag = this.flagEl();
40552 this.dialCodeHolder = this.dialCodeHolderEl();
40554 this.trigger = this.el.select('div.flag-box',true).first();
40555 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40560 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40561 _this.list.setWidth(lw);
40564 this.list.on('mouseover', this.onViewOver, this);
40565 this.list.on('mousemove', this.onViewMove, this);
40566 this.inputEl().on("keyup", this.onKeyUp, this);
40567 this.inputEl().on("keypress", this.onKeyPress, this);
40569 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40571 this.view = new Roo.View(this.list, this.tpl, {
40572 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40575 this.view.on('click', this.onViewClick, this);
40576 this.setValue(this.defaultDialCode);
40579 onTriggerClick : function(e)
40581 Roo.log('trigger click');
40586 if(this.isExpanded()){
40588 this.hasFocus = false;
40590 this.store.load({});
40591 this.hasFocus = true;
40596 isExpanded : function()
40598 return this.list.isVisible();
40601 collapse : function()
40603 if(!this.isExpanded()){
40607 Roo.get(document).un('mousedown', this.collapseIf, this);
40608 Roo.get(document).un('mousewheel', this.collapseIf, this);
40609 this.fireEvent('collapse', this);
40613 expand : function()
40617 if(this.isExpanded() || !this.hasFocus){
40621 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40622 this.list.setWidth(lw);
40625 this.restrictHeight();
40627 Roo.get(document).on('mousedown', this.collapseIf, this);
40628 Roo.get(document).on('mousewheel', this.collapseIf, this);
40630 this.fireEvent('expand', this);
40633 restrictHeight : function()
40635 this.list.alignTo(this.inputEl(), this.listAlign);
40636 this.list.alignTo(this.inputEl(), this.listAlign);
40639 onViewOver : function(e, t)
40641 if(this.inKeyMode){
40644 var item = this.view.findItemFromChild(t);
40647 var index = this.view.indexOf(item);
40648 this.select(index, false);
40653 onViewClick : function(view, doFocus, el, e)
40655 var index = this.view.getSelectedIndexes()[0];
40657 var r = this.store.getAt(index);
40660 this.onSelect(r, index);
40662 if(doFocus !== false && !this.blockFocus){
40663 this.inputEl().focus();
40667 onViewMove : function(e, t)
40669 this.inKeyMode = false;
40672 select : function(index, scrollIntoView)
40674 this.selectedIndex = index;
40675 this.view.select(index);
40676 if(scrollIntoView !== false){
40677 var el = this.view.getNode(index);
40679 this.list.scrollChildIntoView(el, false);
40684 createList : function()
40686 this.list = Roo.get(document.body).createChild({
40688 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40689 style: 'display:none'
40692 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40695 collapseIf : function(e)
40697 var in_combo = e.within(this.el);
40698 var in_list = e.within(this.list);
40699 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40701 if (in_combo || in_list || is_list) {
40707 onSelect : function(record, index)
40709 if(this.fireEvent('beforeselect', this, record, index) !== false){
40711 this.setFlagClass(record.data.iso2);
40712 this.setDialCode(record.data.dialCode);
40713 this.hasFocus = false;
40715 this.fireEvent('select', this, record, index);
40719 flagEl : function()
40721 var flag = this.el.select('div.flag',true).first();
40728 dialCodeHolderEl : function()
40730 var d = this.el.select('input.dial-code-holder',true).first();
40737 setDialCode : function(v)
40739 this.dialCodeHolder.dom.value = '+'+v;
40742 setFlagClass : function(n)
40744 this.flag.dom.className = 'flag '+n;
40747 getValue : function()
40749 var v = this.inputEl().getValue();
40750 if(this.dialCodeHolder) {
40751 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40756 setValue : function(v)
40758 var d = this.getDialCode(v);
40760 //invalid dial code
40761 if(v.length == 0 || !d || d.length == 0) {
40763 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40764 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40770 this.setFlagClass(this.dialCodeMapping[d].iso2);
40771 this.setDialCode(d);
40772 this.inputEl().dom.value = v.replace('+'+d,'');
40773 this.hiddenEl().dom.value = this.getValue();
40778 getDialCode : function(v)
40782 if (v.length == 0) {
40783 return this.dialCodeHolder.dom.value;
40787 if (v.charAt(0) != "+") {
40790 var numericChars = "";
40791 for (var i = 1; i < v.length; i++) {
40792 var c = v.charAt(i);
40795 if (this.dialCodeMapping[numericChars]) {
40796 dialCode = v.substr(1, i);
40798 if (numericChars.length == 4) {
40808 this.setValue(this.defaultDialCode);
40812 hiddenEl : function()
40814 return this.el.select('input.hidden-tel-input',true).first();
40817 // after setting val
40818 onKeyUp : function(e){
40819 this.setValue(this.getValue());
40822 onKeyPress : function(e){
40823 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40830 * @class Roo.bootstrap.MoneyField
40831 * @extends Roo.bootstrap.ComboBox
40832 * Bootstrap MoneyField class
40835 * Create a new MoneyField.
40836 * @param {Object} config Configuration options
40839 Roo.bootstrap.MoneyField = function(config) {
40841 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40845 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40848 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40850 allowDecimals : true,
40852 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40854 decimalSeparator : ".",
40856 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40858 decimalPrecision : 0,
40860 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40862 allowNegative : true,
40864 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40868 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40870 minValue : Number.NEGATIVE_INFINITY,
40872 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40874 maxValue : Number.MAX_VALUE,
40876 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40878 minText : "The minimum value for this field is {0}",
40880 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40882 maxText : "The maximum value for this field is {0}",
40884 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40885 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40887 nanText : "{0} is not a valid number",
40889 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40893 * @cfg {String} defaults currency of the MoneyField
40894 * value should be in lkey
40896 defaultCurrency : false,
40898 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40900 thousandsDelimiter : false,
40902 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40913 getAutoCreate : function()
40915 var align = this.labelAlign || this.parentLabelAlign();
40927 cls : 'form-control roo-money-amount-input',
40928 autocomplete: 'new-password'
40931 var hiddenInput = {
40935 cls: 'hidden-number-input'
40938 if(this.max_length) {
40939 input.maxlength = this.max_length;
40943 hiddenInput.name = this.name;
40946 if (this.disabled) {
40947 input.disabled = true;
40950 var clg = 12 - this.inputlg;
40951 var cmd = 12 - this.inputmd;
40952 var csm = 12 - this.inputsm;
40953 var cxs = 12 - this.inputxs;
40957 cls : 'row roo-money-field',
40961 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40965 cls: 'roo-select2-container input-group',
40969 cls : 'form-control roo-money-currency-input',
40970 autocomplete: 'new-password',
40972 name : this.currencyName
40976 cls : 'input-group-addon',
40990 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40994 cls: this.hasFeedback ? 'has-feedback' : '',
41005 if (this.fieldLabel.length) {
41008 tooltip: 'This field is required'
41014 cls: 'control-label',
41020 html: this.fieldLabel
41023 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
41029 if(this.indicatorpos == 'right') {
41030 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41037 if(align == 'left') {
41045 if(this.labelWidth > 12){
41046 label.style = "width: " + this.labelWidth + 'px';
41048 if(this.labelWidth < 13 && this.labelmd == 0){
41049 this.labelmd = this.labelWidth;
41051 if(this.labellg > 0){
41052 label.cls += ' col-lg-' + this.labellg;
41053 input.cls += ' col-lg-' + (12 - this.labellg);
41055 if(this.labelmd > 0){
41056 label.cls += ' col-md-' + this.labelmd;
41057 container.cls += ' col-md-' + (12 - this.labelmd);
41059 if(this.labelsm > 0){
41060 label.cls += ' col-sm-' + this.labelsm;
41061 container.cls += ' col-sm-' + (12 - this.labelsm);
41063 if(this.labelxs > 0){
41064 label.cls += ' col-xs-' + this.labelxs;
41065 container.cls += ' col-xs-' + (12 - this.labelxs);
41076 var settings = this;
41078 ['xs','sm','md','lg'].map(function(size){
41079 if (settings[size]) {
41080 cfg.cls += ' col-' + size + '-' + settings[size];
41087 initEvents : function()
41089 this.indicator = this.indicatorEl();
41091 this.initCurrencyEvent();
41093 this.initNumberEvent();
41096 initCurrencyEvent : function()
41099 throw "can not find store for combo";
41102 this.store = Roo.factory(this.store, Roo.data);
41103 this.store.parent = this;
41107 this.triggerEl = this.el.select('.input-group-addon', true).first();
41109 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41114 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41115 _this.list.setWidth(lw);
41118 this.list.on('mouseover', this.onViewOver, this);
41119 this.list.on('mousemove', this.onViewMove, this);
41120 this.list.on('scroll', this.onViewScroll, this);
41123 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41126 this.view = new Roo.View(this.list, this.tpl, {
41127 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41130 this.view.on('click', this.onViewClick, this);
41132 this.store.on('beforeload', this.onBeforeLoad, this);
41133 this.store.on('load', this.onLoad, this);
41134 this.store.on('loadexception', this.onLoadException, this);
41136 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41137 "up" : function(e){
41138 this.inKeyMode = true;
41142 "down" : function(e){
41143 if(!this.isExpanded()){
41144 this.onTriggerClick();
41146 this.inKeyMode = true;
41151 "enter" : function(e){
41154 if(this.fireEvent("specialkey", this, e)){
41155 this.onViewClick(false);
41161 "esc" : function(e){
41165 "tab" : function(e){
41168 if(this.fireEvent("specialkey", this, e)){
41169 this.onViewClick(false);
41177 doRelay : function(foo, bar, hname){
41178 if(hname == 'down' || this.scope.isExpanded()){
41179 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41187 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41191 initNumberEvent : function(e)
41193 this.inputEl().on("keydown" , this.fireKey, this);
41194 this.inputEl().on("focus", this.onFocus, this);
41195 this.inputEl().on("blur", this.onBlur, this);
41197 this.inputEl().relayEvent('keyup', this);
41199 if(this.indicator){
41200 this.indicator.addClass('invisible');
41203 this.originalValue = this.getValue();
41205 if(this.validationEvent == 'keyup'){
41206 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41207 this.inputEl().on('keyup', this.filterValidation, this);
41209 else if(this.validationEvent !== false){
41210 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41213 if(this.selectOnFocus){
41214 this.on("focus", this.preFocus, this);
41217 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41218 this.inputEl().on("keypress", this.filterKeys, this);
41220 this.inputEl().relayEvent('keypress', this);
41223 var allowed = "0123456789";
41225 if(this.allowDecimals){
41226 allowed += this.decimalSeparator;
41229 if(this.allowNegative){
41233 if(this.thousandsDelimiter) {
41237 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41239 var keyPress = function(e){
41241 var k = e.getKey();
41243 var c = e.getCharCode();
41246 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41247 allowed.indexOf(String.fromCharCode(c)) === -1
41253 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41257 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41262 this.inputEl().on("keypress", keyPress, this);
41266 onTriggerClick : function(e)
41273 this.loadNext = false;
41275 if(this.isExpanded()){
41280 this.hasFocus = true;
41282 if(this.triggerAction == 'all') {
41283 this.doQuery(this.allQuery, true);
41287 this.doQuery(this.getRawValue());
41290 getCurrency : function()
41292 var v = this.currencyEl().getValue();
41297 restrictHeight : function()
41299 this.list.alignTo(this.currencyEl(), this.listAlign);
41300 this.list.alignTo(this.currencyEl(), this.listAlign);
41303 onViewClick : function(view, doFocus, el, e)
41305 var index = this.view.getSelectedIndexes()[0];
41307 var r = this.store.getAt(index);
41310 this.onSelect(r, index);
41314 onSelect : function(record, index){
41316 if(this.fireEvent('beforeselect', this, record, index) !== false){
41318 this.setFromCurrencyData(index > -1 ? record.data : false);
41322 this.fireEvent('select', this, record, index);
41326 setFromCurrencyData : function(o)
41330 this.lastCurrency = o;
41332 if (this.currencyField) {
41333 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41335 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41338 this.lastSelectionText = currency;
41340 //setting default currency
41341 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41342 this.setCurrency(this.defaultCurrency);
41346 this.setCurrency(currency);
41349 setFromData : function(o)
41353 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41355 this.setFromCurrencyData(c);
41360 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41362 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41365 this.setValue(value);
41369 setCurrency : function(v)
41371 this.currencyValue = v;
41374 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41379 setValue : function(v)
41381 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41387 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41389 this.inputEl().dom.value = (v == '') ? '' :
41390 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41392 if(!this.allowZero && v === '0') {
41393 this.hiddenEl().dom.value = '';
41394 this.inputEl().dom.value = '';
41401 getRawValue : function()
41403 var v = this.inputEl().getValue();
41408 getValue : function()
41410 return this.fixPrecision(this.parseValue(this.getRawValue()));
41413 parseValue : function(value)
41415 if(this.thousandsDelimiter) {
41417 r = new RegExp(",", "g");
41418 value = value.replace(r, "");
41421 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41422 return isNaN(value) ? '' : value;
41426 fixPrecision : function(value)
41428 if(this.thousandsDelimiter) {
41430 r = new RegExp(",", "g");
41431 value = value.replace(r, "");
41434 var nan = isNaN(value);
41436 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41437 return nan ? '' : value;
41439 return parseFloat(value).toFixed(this.decimalPrecision);
41442 decimalPrecisionFcn : function(v)
41444 return Math.floor(v);
41447 validateValue : function(value)
41449 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41453 var num = this.parseValue(value);
41456 this.markInvalid(String.format(this.nanText, value));
41460 if(num < this.minValue){
41461 this.markInvalid(String.format(this.minText, this.minValue));
41465 if(num > this.maxValue){
41466 this.markInvalid(String.format(this.maxText, this.maxValue));
41473 validate : function()
41475 if(this.disabled || this.allowBlank){
41480 var currency = this.getCurrency();
41482 if(this.validateValue(this.getRawValue()) && currency.length){
41487 this.markInvalid();
41491 getName: function()
41496 beforeBlur : function()
41502 var v = this.parseValue(this.getRawValue());
41509 onBlur : function()
41513 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41514 //this.el.removeClass(this.focusClass);
41517 this.hasFocus = false;
41519 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41523 var v = this.getValue();
41525 if(String(v) !== String(this.startValue)){
41526 this.fireEvent('change', this, v, this.startValue);
41529 this.fireEvent("blur", this);
41532 inputEl : function()
41534 return this.el.select('.roo-money-amount-input', true).first();
41537 currencyEl : function()
41539 return this.el.select('.roo-money-currency-input', true).first();
41542 hiddenEl : function()
41544 return this.el.select('input.hidden-number-input',true).first();
41548 * This script refer to:
41549 * Title: Signature Pad
41551 * Availability: https://github.com/szimek/signature_pad
41555 * @class Roo.bootstrap.BezierSignature
41556 * @extends Roo.bootstrap.Component
41557 * Bootstrap BezierSignature class
41560 * Create a new BezierSignature
41561 * @param {Object} config The config object
41564 Roo.bootstrap.BezierSignature = function(config){
41565 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41571 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, {
41577 mouse_btn_down: true,
41580 * @cfg(int) canvas height
41582 canvas_height: '200px',
41585 * @cfg(float or function) Radius of a single dot.
41590 * @cfg(float) Minimum width of a line. Defaults to 0.5.
41595 * @cfg(float) Maximum width of a line. Defaults to 2.5.
41600 * @cfg(integer) Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41605 * @cfg(integer) Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41610 * @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.
41612 bg_color: 'rgba(0, 0, 0, 0)',
41615 * @cfg(string) Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41617 dot_color: 'black',
41620 * @cfg(float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41622 velocity_filter_weight: 0.7,
41625 * @cfg(function) Callback when stroke begin.
41630 * @cfg(function) Callback when stroke end.
41634 getAutoCreate : function()
41636 var cls = 'roo-signature column';
41639 cls += ' ' + this.cls;
41649 for(var i = 0; i < col_sizes.length; i++) {
41650 if(this[col_sizes[i]]) {
41651 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41661 cls: 'roo-signature-body',
41665 cls: 'roo-signature-body-canvas',
41666 height: this.canvas_height,
41667 width: this.canvas_width
41674 style: 'display: none'
41682 initEvents: function()
41684 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41686 var canvas = this.canvasEl();
41688 // mouse && touch event swapping...
41689 canvas.dom.style.touchAction = 'none';
41690 canvas.dom.style.msTouchAction = 'none';
41692 this.mouse_btn_down = false;
41693 canvas.on('mousedown', this._handleMouseDown, this);
41694 canvas.on('mousemove', this._handleMouseMove, this);
41695 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41697 if (window.PointerEvent) {
41698 canvas.on('pointerdown', this._handleMouseDown, this);
41699 canvas.on('pointermove', this._handleMouseMove, this);
41700 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41703 if ('ontouchstart' in window) {
41704 canvas.on('touchstart', this._handleTouchStart, this);
41705 canvas.on('touchmove', this._handleTouchMove, this);
41706 canvas.on('touchend', this._handleTouchEnd, this);
41709 Roo.EventManager.onWindowResize(this.resize, this, true);
41711 // file input event
41712 this.fileEl().on('change', this.uploadImage, this);
41719 resize: function(){
41721 var canvas = this.canvasEl().dom;
41722 var ctx = this.canvasElCtx();
41723 var img_data = false;
41725 if(canvas.width > 0) {
41726 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41728 // setting canvas width will clean img data
41731 var style = window.getComputedStyle ?
41732 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41734 var padding_left = parseInt(style.paddingLeft) || 0;
41735 var padding_right = parseInt(style.paddingRight) || 0;
41737 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41740 ctx.putImageData(img_data, 0, 0);
41744 _handleMouseDown: function(e)
41746 if (e.browserEvent.which === 1) {
41747 this.mouse_btn_down = true;
41748 this.strokeBegin(e);
41752 _handleMouseMove: function (e)
41754 if (this.mouse_btn_down) {
41755 this.strokeMoveUpdate(e);
41759 _handleMouseUp: function (e)
41761 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41762 this.mouse_btn_down = false;
41767 _handleTouchStart: function (e) {
41769 e.preventDefault();
41770 if (e.browserEvent.targetTouches.length === 1) {
41771 // var touch = e.browserEvent.changedTouches[0];
41772 // this.strokeBegin(touch);
41774 this.strokeBegin(e); // assume e catching the correct xy...
41778 _handleTouchMove: function (e) {
41779 e.preventDefault();
41780 // var touch = event.targetTouches[0];
41781 // _this._strokeMoveUpdate(touch);
41782 this.strokeMoveUpdate(e);
41785 _handleTouchEnd: function (e) {
41786 var wasCanvasTouched = e.target === this.canvasEl().dom;
41787 if (wasCanvasTouched) {
41788 e.preventDefault();
41789 // var touch = event.changedTouches[0];
41790 // _this._strokeEnd(touch);
41795 reset: function () {
41796 this._lastPoints = [];
41797 this._lastVelocity = 0;
41798 this._lastWidth = (this.min_width + this.max_width) / 2;
41799 this.canvasElCtx().fillStyle = this.dot_color;
41802 strokeMoveUpdate: function(e)
41804 this.strokeUpdate(e);
41806 if (this.throttle) {
41807 this.throttle(this.strokeUpdate, this.throttle);
41810 this.strokeUpdate(e);
41814 strokeBegin: function(e)
41816 var newPointGroup = {
41817 color: this.dot_color,
41821 if (typeof this.onBegin === 'function') {
41825 this.curve_data.push(newPointGroup);
41827 this.strokeUpdate(e);
41830 strokeUpdate: function(e)
41832 var rect = this.canvasEl().dom.getBoundingClientRect();
41833 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41834 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41835 var lastPoints = lastPointGroup.points;
41836 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41837 var isLastPointTooClose = lastPoint
41838 ? point.distanceTo(lastPoint) <= this.min_distance
41840 var color = lastPointGroup.color;
41841 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41842 var curve = this.addPoint(point);
41844 this.drawDot({color: color, point: point});
41847 this.drawCurve({color: color, curve: curve});
41857 strokeEnd: function(e)
41859 this.strokeUpdate(e);
41860 if (typeof this.onEnd === 'function') {
41865 addPoint: function (point) {
41866 var _lastPoints = this._lastPoints;
41867 _lastPoints.push(point);
41868 if (_lastPoints.length > 2) {
41869 if (_lastPoints.length === 3) {
41870 _lastPoints.unshift(_lastPoints[0]);
41872 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41873 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41874 _lastPoints.shift();
41880 calculateCurveWidths: function (startPoint, endPoint) {
41881 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41882 (1 - this.velocity_filter_weight) * this._lastVelocity;
41884 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41887 start: this._lastWidth
41890 this._lastVelocity = velocity;
41891 this._lastWidth = newWidth;
41895 drawDot: function (_a) {
41896 var color = _a.color, point = _a.point;
41897 var ctx = this.canvasElCtx();
41898 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41900 this.drawCurveSegment(point.x, point.y, width);
41902 ctx.fillStyle = color;
41906 drawCurve: function (_a) {
41907 var color = _a.color, curve = _a.curve;
41908 var ctx = this.canvasElCtx();
41909 var widthDelta = curve.endWidth - curve.startWidth;
41910 var drawSteps = Math.floor(curve.length()) * 2;
41912 ctx.fillStyle = color;
41913 for (var i = 0; i < drawSteps; i += 1) {
41914 var t = i / drawSteps;
41920 var x = uuu * curve.startPoint.x;
41921 x += 3 * uu * t * curve.control1.x;
41922 x += 3 * u * tt * curve.control2.x;
41923 x += ttt * curve.endPoint.x;
41924 var y = uuu * curve.startPoint.y;
41925 y += 3 * uu * t * curve.control1.y;
41926 y += 3 * u * tt * curve.control2.y;
41927 y += ttt * curve.endPoint.y;
41928 var width = curve.startWidth + ttt * widthDelta;
41929 this.drawCurveSegment(x, y, width);
41935 drawCurveSegment: function (x, y, width) {
41936 var ctx = this.canvasElCtx();
41938 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41939 this.is_empty = false;
41944 var ctx = this.canvasElCtx();
41945 var canvas = this.canvasEl().dom;
41946 ctx.fillStyle = this.bg_color;
41947 ctx.clearRect(0, 0, canvas.width, canvas.height);
41948 ctx.fillRect(0, 0, canvas.width, canvas.height);
41949 this.curve_data = [];
41951 this.is_empty = true;
41956 return this.el.select('input',true).first();
41959 canvasEl: function()
41961 return this.el.select('canvas',true).first();
41964 canvasElCtx: function()
41966 return this.el.select('canvas',true).first().dom.getContext('2d');
41969 getImage: function(type)
41971 if(this.is_empty) {
41976 return this.canvasEl().dom.toDataURL('image/'+type, 1);
41979 drawFromImage: function(img_src)
41981 var img = new Image();
41983 img.onload = function(){
41984 this.canvasElCtx().drawImage(img, 0, 0);
41989 this.is_empty = false;
41992 selectImage: function()
41994 this.fileEl().dom.click();
41997 uploadImage: function(e)
41999 var reader = new FileReader();
42001 reader.onload = function(e){
42002 var img = new Image();
42003 img.onload = function(){
42005 this.canvasElCtx().drawImage(img, 0, 0);
42007 img.src = e.target.result;
42010 reader.readAsDataURL(e.target.files[0]);
42013 // Bezier Point Constructor
42014 Point: (function () {
42015 function Point(x, y, time) {
42018 this.time = time || Date.now();
42020 Point.prototype.distanceTo = function (start) {
42021 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
42023 Point.prototype.equals = function (other) {
42024 return this.x === other.x && this.y === other.y && this.time === other.time;
42026 Point.prototype.velocityFrom = function (start) {
42027 return this.time !== start.time
42028 ? this.distanceTo(start) / (this.time - start.time)
42035 // Bezier Constructor
42036 Bezier: (function () {
42037 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
42038 this.startPoint = startPoint;
42039 this.control2 = control2;
42040 this.control1 = control1;
42041 this.endPoint = endPoint;
42042 this.startWidth = startWidth;
42043 this.endWidth = endWidth;
42045 Bezier.fromPoints = function (points, widths, scope) {
42046 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42047 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42048 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42050 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42051 var dx1 = s1.x - s2.x;
42052 var dy1 = s1.y - s2.y;
42053 var dx2 = s2.x - s3.x;
42054 var dy2 = s2.y - s3.y;
42055 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42056 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42057 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42058 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42059 var dxm = m1.x - m2.x;
42060 var dym = m1.y - m2.y;
42061 var k = l2 / (l1 + l2);
42062 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42063 var tx = s2.x - cm.x;
42064 var ty = s2.y - cm.y;
42066 c1: new scope.Point(m1.x + tx, m1.y + ty),
42067 c2: new scope.Point(m2.x + tx, m2.y + ty)
42070 Bezier.prototype.length = function () {
42075 for (var i = 0; i <= steps; i += 1) {
42077 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42078 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42080 var xdiff = cx - px;
42081 var ydiff = cy - py;
42082 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42089 Bezier.prototype.point = function (t, start, c1, c2, end) {
42090 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42091 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42092 + (3.0 * c2 * (1.0 - t) * t * t)
42093 + (end * t * t * t);
42098 throttle: function(fn, wait) {
42099 if (wait === void 0) { wait = 250; }
42101 var timeout = null;
42105 var later = function () {
42106 previous = Date.now();
42108 result = fn.apply(storedContext, storedArgs);
42110 storedContext = null;
42114 return function wrapper() {
42116 for (var _i = 0; _i < arguments.length; _i++) {
42117 args[_i] = arguments[_i];
42119 var now = Date.now();
42120 var remaining = wait - (now - previous);
42121 storedContext = this;
42123 if (remaining <= 0 || remaining > wait) {
42125 clearTimeout(timeout);
42129 result = fn.apply(storedContext, storedArgs);
42131 storedContext = null;
42135 else if (!timeout) {
42136 timeout = window.setTimeout(later, remaining);