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');
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass('hidden');
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 fs
593 * @cfg {String} badge text for badge
594 * @cfg {String} theme (default|glow)
595 * @cfg {Boolean} inverse dark themed version
596 * @cfg {Boolean} toggle is it a slidy toggle button
597 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
598 * @cfg {String} ontext text for on slidy toggle state
599 * @cfg {String} offtext text for off slidy toggle state
600 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
601 * @cfg {Boolean} removeClass remove the standard class..
602 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
605 * Create a new button
606 * @param {Object} config The config object
610 Roo.bootstrap.Button = function(config){
611 Roo.bootstrap.Button.superclass.constructor.call(this, config);
612 this.weightClass = ["btn-default btn-outline-secondary",
624 * When a butotn is pressed
625 * @param {Roo.bootstrap.Button} btn
626 * @param {Roo.EventObject} e
631 * After the button has been toggles
632 * @param {Roo.bootstrap.Button} btn
633 * @param {Roo.EventObject} e
634 * @param {boolean} pressed (also available as button.pressed)
640 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
661 preventDefault: true,
669 getAutoCreate : function(){
677 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
678 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
683 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
685 if (this.toggle == true) {
688 cls: 'slider-frame roo-button',
693 'data-off-text':'OFF',
694 cls: 'slider-button',
700 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
701 cfg.cls += ' '+this.weight;
710 cfg["aria-hidden"] = true;
712 cfg.html = "×";
718 if (this.theme==='default') {
719 cfg.cls = 'btn roo-button';
721 //if (this.parentType != 'Navbar') {
722 this.weight = this.weight.length ? this.weight : 'default';
724 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
726 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
727 var weight = this.weight == 'default' ? 'secondary' : this.weight;
728 cfg.cls += ' btn-' + outline + weight;
729 if (this.weight == 'default') {
731 cfg.cls += ' btn-' + this.weight;
734 } else if (this.theme==='glow') {
737 cfg.cls = 'btn-glow roo-button';
739 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
741 cfg.cls += ' ' + this.weight;
747 this.cls += ' inverse';
751 if (this.active || this.pressed === true) {
752 cfg.cls += ' active';
756 cfg.disabled = 'disabled';
760 Roo.log('changing to ul' );
762 this.glyphicon = 'caret';
763 if (Roo.bootstrap.version == 4) {
764 this.fa = 'caret-down';
769 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
771 //gsRoo.log(this.parentType);
772 if (this.parentType === 'Navbar' && !this.parent().bar) {
773 Roo.log('changing to li?');
782 href : this.href || '#'
785 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
786 cfg.cls += ' dropdown';
793 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
795 if (this.glyphicon) {
796 cfg.html = ' ' + cfg.html;
801 cls: 'glyphicon glyphicon-' + this.glyphicon
806 cfg.html = ' ' + cfg.html;
811 cls: 'fa fas fa-' + this.fa
821 // cfg.cls='btn roo-button';
825 var value = cfg.html;
830 cls: 'glyphicon glyphicon-' + this.glyphicon,
837 cls: 'fa fas fa-' + this.fa,
842 var bw = this.badge_weight.length ? this.badge_weight :
843 (this.weight.length ? this.weight : 'secondary');
844 bw = bw == 'default' ? 'secondary' : bw;
850 cls: 'badge badge-' + bw,
859 cfg.cls += ' dropdown';
860 cfg.html = typeof(cfg.html) != 'undefined' ?
861 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
864 if (cfg.tag !== 'a' && this.href !== '') {
865 throw "Tag must be a to set href.";
866 } else if (this.href.length > 0) {
867 cfg.href = this.href;
870 if(this.removeClass){
875 cfg.target = this.target;
880 initEvents: function() {
881 // Roo.log('init events?');
882 // Roo.log(this.el.dom);
885 if (typeof (this.menu) != 'undefined') {
886 this.menu.parentType = this.xtype;
887 this.menu.triggerEl = this.el;
888 this.addxtype(Roo.apply({}, this.menu));
892 if (this.el.hasClass('roo-button')) {
893 this.el.on('click', this.onClick, this);
895 this.el.select('.roo-button').on('click', this.onClick, this);
898 if(this.removeClass){
899 this.el.on('click', this.onClick, this);
902 this.el.enableDisplayMode();
905 onClick : function(e)
911 Roo.log('button on click ');
912 if(this.preventDefault){
916 if (this.pressed === true || this.pressed === false) {
917 this.toggleActive(e);
921 this.fireEvent('click', this, e);
925 * Enables this button
929 this.disabled = false;
930 this.el.removeClass('disabled');
934 * Disable this button
938 this.disabled = true;
939 this.el.addClass('disabled');
942 * sets the active state on/off,
943 * @param {Boolean} state (optional) Force a particular state
945 setActive : function(v) {
947 this.el[v ? 'addClass' : 'removeClass']('active');
951 * toggles the current active state
953 toggleActive : function(e)
955 this.setActive(!this.pressed);
956 this.fireEvent('toggle', this, e, !this.pressed);
959 * get the current active state
960 * @return {boolean} true if it's active
962 isActive : function()
964 return this.el.hasClass('active');
967 * set the text of the first selected button
969 setText : function(str)
971 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
974 * get the text of the first selected button
978 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
981 setWeight : function(str)
983 this.el.removeClass(this.weightClass);
985 var outline = this.outline ? 'outline-' : '';
986 if (str == 'default') {
987 this.el.addClass('btn-default btn-outline-secondary');
990 this.el.addClass('btn-' + outline + str);
1004 * @class Roo.bootstrap.Column
1005 * @extends Roo.bootstrap.Component
1006 * Bootstrap Column class
1007 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1008 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1009 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1010 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1011 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1012 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1013 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1014 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1017 * @cfg {Boolean} hidden (true|false) hide the element
1018 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1019 * @cfg {String} fa (ban|check|...) font awesome icon
1020 * @cfg {Number} fasize (1|2|....) font awsome size
1022 * @cfg {String} icon (info-sign|check|...) glyphicon name
1024 * @cfg {String} html content of column.
1027 * Create a new Column
1028 * @param {Object} config The config object
1031 Roo.bootstrap.Column = function(config){
1032 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1035 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1053 getAutoCreate : function(){
1054 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1062 ['xs','sm','md','lg'].map(function(size){
1063 //Roo.log( size + ':' + settings[size]);
1065 if (settings[size+'off'] !== false) {
1066 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1069 if (settings[size] === false) {
1073 if (!settings[size]) { // 0 = hidden
1074 cfg.cls += ' hidden-' + size;
1077 cfg.cls += ' col-' + size + '-' + settings[size];
1082 cfg.cls += ' hidden';
1085 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1086 cfg.cls +=' alert alert-' + this.alert;
1090 if (this.html.length) {
1091 cfg.html = this.html;
1095 if (this.fasize > 1) {
1096 fasize = ' fa-' + this.fasize + 'x';
1098 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1103 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1122 * @class Roo.bootstrap.Container
1123 * @extends Roo.bootstrap.Component
1124 * Bootstrap Container class
1125 * @cfg {Boolean} jumbotron is it a jumbotron element
1126 * @cfg {String} html content of element
1127 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1128 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1129 * @cfg {String} header content of header (for panel)
1130 * @cfg {String} footer content of footer (for panel)
1131 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1132 * @cfg {String} tag (header|aside|section) type of HTML tag.
1133 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1134 * @cfg {String} fa font awesome icon
1135 * @cfg {String} icon (info-sign|check|...) glyphicon name
1136 * @cfg {Boolean} hidden (true|false) hide the element
1137 * @cfg {Boolean} expandable (true|false) default false
1138 * @cfg {Boolean} expanded (true|false) default true
1139 * @cfg {String} rheader contet on the right of header
1140 * @cfg {Boolean} clickable (true|false) default false
1144 * Create a new Container
1145 * @param {Object} config The config object
1148 Roo.bootstrap.Container = function(config){
1149 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1155 * After the panel has been expand
1157 * @param {Roo.bootstrap.Container} this
1162 * After the panel has been collapsed
1164 * @param {Roo.bootstrap.Container} this
1169 * When a element is chick
1170 * @param {Roo.bootstrap.Container} this
1171 * @param {Roo.EventObject} e
1177 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1195 getChildContainer : function() {
1201 if (this.panel.length) {
1202 return this.el.select('.panel-body',true).first();
1209 getAutoCreate : function(){
1212 tag : this.tag || 'div',
1216 if (this.jumbotron) {
1217 cfg.cls = 'jumbotron';
1222 // - this is applied by the parent..
1224 // cfg.cls = this.cls + '';
1227 if (this.sticky.length) {
1229 var bd = Roo.get(document.body);
1230 if (!bd.hasClass('bootstrap-sticky')) {
1231 bd.addClass('bootstrap-sticky');
1232 Roo.select('html',true).setStyle('height', '100%');
1235 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1239 if (this.well.length) {
1240 switch (this.well) {
1243 cfg.cls +=' well well-' +this.well;
1252 cfg.cls += ' hidden';
1256 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1257 cfg.cls +=' alert alert-' + this.alert;
1262 if (this.panel.length) {
1263 cfg.cls += ' panel panel-' + this.panel;
1265 if (this.header.length) {
1269 if(this.expandable){
1271 cfg.cls = cfg.cls + ' expandable';
1275 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1283 cls : 'panel-title',
1284 html : (this.expandable ? ' ' : '') + this.header
1288 cls: 'panel-header-right',
1294 cls : 'panel-heading',
1295 style : this.expandable ? 'cursor: pointer' : '',
1303 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1308 if (this.footer.length) {
1310 cls : 'panel-footer',
1319 body.html = this.html || cfg.html;
1320 // prefix with the icons..
1322 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1325 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1330 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1331 cfg.cls = 'container';
1337 initEvents: function()
1339 if(this.expandable){
1340 var headerEl = this.headerEl();
1343 headerEl.on('click', this.onToggleClick, this);
1348 this.el.on('click', this.onClick, this);
1353 onToggleClick : function()
1355 var headerEl = this.headerEl();
1371 if(this.fireEvent('expand', this)) {
1373 this.expanded = true;
1375 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1377 this.el.select('.panel-body',true).first().removeClass('hide');
1379 var toggleEl = this.toggleEl();
1385 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1390 collapse : function()
1392 if(this.fireEvent('collapse', this)) {
1394 this.expanded = false;
1396 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1397 this.el.select('.panel-body',true).first().addClass('hide');
1399 var toggleEl = this.toggleEl();
1405 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1409 toggleEl : function()
1411 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1415 return this.el.select('.panel-heading .fa',true).first();
1418 headerEl : function()
1420 if(!this.el || !this.panel.length || !this.header.length){
1424 return this.el.select('.panel-heading',true).first()
1429 if(!this.el || !this.panel.length){
1433 return this.el.select('.panel-body',true).first()
1436 titleEl : function()
1438 if(!this.el || !this.panel.length || !this.header.length){
1442 return this.el.select('.panel-title',true).first();
1445 setTitle : function(v)
1447 var titleEl = this.titleEl();
1453 titleEl.dom.innerHTML = v;
1456 getTitle : function()
1459 var titleEl = this.titleEl();
1465 return titleEl.dom.innerHTML;
1468 setRightTitle : function(v)
1470 var t = this.el.select('.panel-header-right',true).first();
1476 t.dom.innerHTML = v;
1479 onClick : function(e)
1483 this.fireEvent('click', this, e);
1496 * @class Roo.bootstrap.Img
1497 * @extends Roo.bootstrap.Component
1498 * Bootstrap Img class
1499 * @cfg {Boolean} imgResponsive false | true
1500 * @cfg {String} border rounded | circle | thumbnail
1501 * @cfg {String} src image source
1502 * @cfg {String} alt image alternative text
1503 * @cfg {String} href a tag href
1504 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1505 * @cfg {String} xsUrl xs image source
1506 * @cfg {String} smUrl sm image source
1507 * @cfg {String} mdUrl md image source
1508 * @cfg {String} lgUrl lg image source
1511 * Create a new Input
1512 * @param {Object} config The config object
1515 Roo.bootstrap.Img = function(config){
1516 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1522 * The img click event for the img.
1523 * @param {Roo.EventObject} e
1529 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1531 imgResponsive: true,
1541 getAutoCreate : function()
1543 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1544 return this.createSingleImg();
1549 cls: 'roo-image-responsive-group',
1554 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1556 if(!_this[size + 'Url']){
1562 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1563 html: _this.html || cfg.html,
1564 src: _this[size + 'Url']
1567 img.cls += ' roo-image-responsive-' + size;
1569 var s = ['xs', 'sm', 'md', 'lg'];
1571 s.splice(s.indexOf(size), 1);
1573 Roo.each(s, function(ss){
1574 img.cls += ' hidden-' + ss;
1577 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1578 cfg.cls += ' img-' + _this.border;
1582 cfg.alt = _this.alt;
1595 a.target = _this.target;
1599 cfg.cn.push((_this.href) ? a : img);
1606 createSingleImg : function()
1610 cls: (this.imgResponsive) ? 'img-responsive' : '',
1612 src : 'about:blank' // just incase src get's set to undefined?!?
1615 cfg.html = this.html || cfg.html;
1617 cfg.src = this.src || cfg.src;
1619 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1620 cfg.cls += ' img-' + this.border;
1637 a.target = this.target;
1642 return (this.href) ? a : cfg;
1645 initEvents: function()
1648 this.el.on('click', this.onClick, this);
1653 onClick : function(e)
1655 Roo.log('img onclick');
1656 this.fireEvent('click', this, e);
1659 * Sets the url of the image - used to update it
1660 * @param {String} url the url of the image
1663 setSrc : function(url)
1667 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1668 this.el.dom.src = url;
1672 this.el.select('img', true).first().dom.src = url;
1688 * @class Roo.bootstrap.Link
1689 * @extends Roo.bootstrap.Component
1690 * Bootstrap Link Class
1691 * @cfg {String} alt image alternative text
1692 * @cfg {String} href a tag href
1693 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1694 * @cfg {String} html the content of the link.
1695 * @cfg {String} anchor name for the anchor link
1696 * @cfg {String} fa - favicon
1698 * @cfg {Boolean} preventDefault (true | false) default false
1702 * Create a new Input
1703 * @param {Object} config The config object
1706 Roo.bootstrap.Link = function(config){
1707 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1713 * The img click event for the img.
1714 * @param {Roo.EventObject} e
1720 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1724 preventDefault: false,
1730 getAutoCreate : function()
1732 var html = this.html || '';
1734 if (this.fa !== false) {
1735 html = '<i class="fa fa-' + this.fa + '"></i>';
1740 // anchor's do not require html/href...
1741 if (this.anchor === false) {
1743 cfg.href = this.href || '#';
1745 cfg.name = this.anchor;
1746 if (this.html !== false || this.fa !== false) {
1749 if (this.href !== false) {
1750 cfg.href = this.href;
1754 if(this.alt !== false){
1759 if(this.target !== false) {
1760 cfg.target = this.target;
1766 initEvents: function() {
1768 if(!this.href || this.preventDefault){
1769 this.el.on('click', this.onClick, this);
1773 onClick : function(e)
1775 if(this.preventDefault){
1778 //Roo.log('img onclick');
1779 this.fireEvent('click', this, e);
1792 * @class Roo.bootstrap.Header
1793 * @extends Roo.bootstrap.Component
1794 * Bootstrap Header class
1795 * @cfg {String} html content of header
1796 * @cfg {Number} level (1|2|3|4|5|6) default 1
1799 * Create a new Header
1800 * @param {Object} config The config object
1804 Roo.bootstrap.Header = function(config){
1805 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1808 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1816 getAutoCreate : function(){
1821 tag: 'h' + (1 *this.level),
1822 html: this.html || ''
1834 * Ext JS Library 1.1.1
1835 * Copyright(c) 2006-2007, Ext JS, LLC.
1837 * Originally Released Under LGPL - original licence link has changed is not relivant.
1840 * <script type="text/javascript">
1844 * @class Roo.bootstrap.MenuMgr
1845 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1848 Roo.bootstrap.MenuMgr = function(){
1849 var menus, active, groups = {}, attached = false, lastShow = new Date();
1851 // private - called when first menu is created
1854 active = new Roo.util.MixedCollection();
1855 Roo.get(document).addKeyListener(27, function(){
1856 if(active.length > 0){
1864 if(active && active.length > 0){
1865 var c = active.clone();
1875 if(active.length < 1){
1876 Roo.get(document).un("mouseup", onMouseDown);
1884 var last = active.last();
1885 lastShow = new Date();
1888 Roo.get(document).on("mouseup", onMouseDown);
1893 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1894 m.parentMenu.activeChild = m;
1895 }else if(last && last.isVisible()){
1896 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1901 function onBeforeHide(m){
1903 m.activeChild.hide();
1905 if(m.autoHideTimer){
1906 clearTimeout(m.autoHideTimer);
1907 delete m.autoHideTimer;
1912 function onBeforeShow(m){
1913 var pm = m.parentMenu;
1914 if(!pm && !m.allowOtherMenus){
1916 }else if(pm && pm.activeChild && active != m){
1917 pm.activeChild.hide();
1921 // private this should really trigger on mouseup..
1922 function onMouseDown(e){
1923 Roo.log("on Mouse Up");
1925 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1926 Roo.log("MenuManager hideAll");
1935 function onBeforeCheck(mi, state){
1937 var g = groups[mi.group];
1938 for(var i = 0, l = g.length; i < l; i++){
1940 g[i].setChecked(false);
1949 * Hides all menus that are currently visible
1951 hideAll : function(){
1956 register : function(menu){
1960 menus[menu.id] = menu;
1961 menu.on("beforehide", onBeforeHide);
1962 menu.on("hide", onHide);
1963 menu.on("beforeshow", onBeforeShow);
1964 menu.on("show", onShow);
1966 if(g && menu.events["checkchange"]){
1970 groups[g].push(menu);
1971 menu.on("checkchange", onCheck);
1976 * Returns a {@link Roo.menu.Menu} object
1977 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1978 * be used to generate and return a new Menu instance.
1980 get : function(menu){
1981 if(typeof menu == "string"){ // menu id
1983 }else if(menu.events){ // menu instance
1986 /*else if(typeof menu.length == 'number'){ // array of menu items?
1987 return new Roo.bootstrap.Menu({items:menu});
1988 }else{ // otherwise, must be a config
1989 return new Roo.bootstrap.Menu(menu);
1996 unregister : function(menu){
1997 delete menus[menu.id];
1998 menu.un("beforehide", onBeforeHide);
1999 menu.un("hide", onHide);
2000 menu.un("beforeshow", onBeforeShow);
2001 menu.un("show", onShow);
2003 if(g && menu.events["checkchange"]){
2004 groups[g].remove(menu);
2005 menu.un("checkchange", onCheck);
2010 registerCheckable : function(menuItem){
2011 var g = menuItem.group;
2016 groups[g].push(menuItem);
2017 menuItem.on("beforecheckchange", onBeforeCheck);
2022 unregisterCheckable : function(menuItem){
2023 var g = menuItem.group;
2025 groups[g].remove(menuItem);
2026 menuItem.un("beforecheckchange", onBeforeCheck);
2038 * @class Roo.bootstrap.Menu
2039 * @extends Roo.bootstrap.Component
2040 * Bootstrap Menu class - container for MenuItems
2041 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2042 * @cfg {bool} hidden if the menu should be hidden when rendered.
2043 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2044 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2048 * @param {Object} config The config object
2052 Roo.bootstrap.Menu = function(config){
2053 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2054 if (this.registerMenu && this.type != 'treeview') {
2055 Roo.bootstrap.MenuMgr.register(this);
2062 * Fires before this menu is displayed
2063 * @param {Roo.menu.Menu} this
2068 * Fires before this menu is hidden
2069 * @param {Roo.menu.Menu} this
2074 * Fires after this menu is displayed
2075 * @param {Roo.menu.Menu} this
2080 * Fires after this menu is hidden
2081 * @param {Roo.menu.Menu} this
2086 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2087 * @param {Roo.menu.Menu} this
2088 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2089 * @param {Roo.EventObject} e
2094 * Fires when the mouse is hovering over this menu
2095 * @param {Roo.menu.Menu} this
2096 * @param {Roo.EventObject} e
2097 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2102 * Fires when the mouse exits this menu
2103 * @param {Roo.menu.Menu} this
2104 * @param {Roo.EventObject} e
2105 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2110 * Fires when a menu item contained in this menu is clicked
2111 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2112 * @param {Roo.EventObject} e
2116 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2119 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2123 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2126 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2128 registerMenu : true,
2130 menuItems :false, // stores the menu items..
2140 getChildContainer : function() {
2144 getAutoCreate : function(){
2146 //if (['right'].indexOf(this.align)!==-1) {
2147 // cfg.cn[1].cls += ' pull-right'
2153 cls : 'dropdown-menu' ,
2154 style : 'z-index:1000'
2158 if (this.type === 'submenu') {
2159 cfg.cls = 'submenu active';
2161 if (this.type === 'treeview') {
2162 cfg.cls = 'treeview-menu';
2167 initEvents : function() {
2169 // Roo.log("ADD event");
2170 // Roo.log(this.triggerEl.dom);
2172 this.triggerEl.on('click', this.onTriggerClick, this);
2174 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2177 if (this.triggerEl.hasClass('nav-item')) {
2178 // dropdown toggle on the 'a' in BS4?
2179 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2181 this.triggerEl.addClass('dropdown-toggle');
2184 this.el.on('touchstart' , this.onTouch, this);
2186 this.el.on('click' , this.onClick, this);
2188 this.el.on("mouseover", this.onMouseOver, this);
2189 this.el.on("mouseout", this.onMouseOut, this);
2193 findTargetItem : function(e)
2195 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2199 //Roo.log(t); Roo.log(t.id);
2201 //Roo.log(this.menuitems);
2202 return this.menuitems.get(t.id);
2204 //return this.items.get(t.menuItemId);
2210 onTouch : function(e)
2212 Roo.log("menu.onTouch");
2213 //e.stopEvent(); this make the user popdown broken
2217 onClick : function(e)
2219 Roo.log("menu.onClick");
2221 var t = this.findTargetItem(e);
2222 if(!t || t.isContainer){
2227 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2228 if(t == this.activeItem && t.shouldDeactivate(e)){
2229 this.activeItem.deactivate();
2230 delete this.activeItem;
2234 this.setActiveItem(t, true);
2242 Roo.log('pass click event');
2246 this.fireEvent("click", this, t, e);
2250 if(!t.href.length || t.href == '#'){
2251 (function() { _this.hide(); }).defer(100);
2256 onMouseOver : function(e){
2257 var t = this.findTargetItem(e);
2260 // if(t.canActivate && !t.disabled){
2261 // this.setActiveItem(t, true);
2265 this.fireEvent("mouseover", this, e, t);
2267 isVisible : function(){
2268 return !this.hidden;
2270 onMouseOut : function(e){
2271 var t = this.findTargetItem(e);
2274 // if(t == this.activeItem && t.shouldDeactivate(e)){
2275 // this.activeItem.deactivate();
2276 // delete this.activeItem;
2279 this.fireEvent("mouseout", this, e, t);
2284 * Displays this menu relative to another element
2285 * @param {String/HTMLElement/Roo.Element} element The element to align to
2286 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2287 * the element (defaults to this.defaultAlign)
2288 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2290 show : function(el, pos, parentMenu){
2291 this.parentMenu = parentMenu;
2295 this.fireEvent("beforeshow", this);
2296 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2299 * Displays this menu at a specific xy position
2300 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2301 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2303 showAt : function(xy, parentMenu, /* private: */_e){
2304 this.parentMenu = parentMenu;
2309 this.fireEvent("beforeshow", this);
2310 //xy = this.el.adjustForConstraints(xy);
2314 this.hideMenuItems();
2315 this.hidden = false;
2316 this.triggerEl.addClass('open');
2317 this.el.addClass('show');
2319 // reassign x when hitting right
2320 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2321 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2324 // reassign y when hitting bottom
2325 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2326 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2329 // but the list may align on trigger left or trigger top... should it be a properity?
2331 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2336 this.fireEvent("show", this);
2342 this.doFocus.defer(50, this);
2346 doFocus : function(){
2348 this.focusEl.focus();
2353 * Hides this menu and optionally all parent menus
2354 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2356 hide : function(deep)
2359 this.hideMenuItems();
2360 if(this.el && this.isVisible()){
2361 this.fireEvent("beforehide", this);
2362 if(this.activeItem){
2363 this.activeItem.deactivate();
2364 this.activeItem = null;
2366 this.triggerEl.removeClass('open');;
2367 this.el.removeClass('show');
2369 this.fireEvent("hide", this);
2371 if(deep === true && this.parentMenu){
2372 this.parentMenu.hide(true);
2376 onTriggerClick : function(e)
2378 Roo.log('trigger click');
2380 var target = e.getTarget();
2382 Roo.log(target.nodeName.toLowerCase());
2384 if(target.nodeName.toLowerCase() === 'i'){
2390 onTriggerPress : function(e)
2392 Roo.log('trigger press');
2393 //Roo.log(e.getTarget());
2394 // Roo.log(this.triggerEl.dom);
2396 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2397 var pel = Roo.get(e.getTarget());
2398 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2399 Roo.log('is treeview or dropdown?');
2403 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2407 if (this.isVisible()) {
2412 this.show(this.triggerEl, false, false);
2415 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2422 hideMenuItems : function()
2424 Roo.log("hide Menu Items");
2428 //$(backdrop).remove()
2429 this.el.select('.open',true).each(function(aa) {
2431 aa.removeClass('open');
2432 //var parent = getParent($(this))
2433 //var relatedTarget = { relatedTarget: this }
2435 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2436 //if (e.isDefaultPrevented()) return
2437 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2440 addxtypeChild : function (tree, cntr) {
2441 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2443 this.menuitems.add(comp);
2455 this.getEl().dom.innerHTML = '';
2456 this.menuitems.clear();
2470 * @class Roo.bootstrap.MenuItem
2471 * @extends Roo.bootstrap.Component
2472 * Bootstrap MenuItem class
2473 * @cfg {String} html the menu label
2474 * @cfg {String} href the link
2475 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2476 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2477 * @cfg {Boolean} active used on sidebars to highlight active itesm
2478 * @cfg {String} fa favicon to show on left of menu item.
2479 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2483 * Create a new MenuItem
2484 * @param {Object} config The config object
2488 Roo.bootstrap.MenuItem = function(config){
2489 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2494 * The raw click event for the entire grid.
2495 * @param {Roo.bootstrap.MenuItem} this
2496 * @param {Roo.EventObject} e
2502 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2506 preventDefault: false,
2507 isContainer : false,
2511 getAutoCreate : function(){
2513 if(this.isContainer){
2516 cls: 'dropdown-menu-item '
2526 cls : 'dropdown-item',
2531 if (this.fa !== false) {
2534 cls : 'fa fa-' + this.fa
2543 cls: 'dropdown-menu-item',
2546 if (this.parent().type == 'treeview') {
2547 cfg.cls = 'treeview-menu';
2550 cfg.cls += ' active';
2555 anc.href = this.href || cfg.cn[0].href ;
2556 ctag.html = this.html || cfg.cn[0].html ;
2560 initEvents: function()
2562 if (this.parent().type == 'treeview') {
2563 this.el.select('a').on('click', this.onClick, this);
2567 this.menu.parentType = this.xtype;
2568 this.menu.triggerEl = this.el;
2569 this.menu = this.addxtype(Roo.apply({}, this.menu));
2573 onClick : function(e)
2575 Roo.log('item on click ');
2577 if(this.preventDefault){
2580 //this.parent().hideMenuItems();
2582 this.fireEvent('click', this, e);
2601 * @class Roo.bootstrap.MenuSeparator
2602 * @extends Roo.bootstrap.Component
2603 * Bootstrap MenuSeparator class
2606 * Create a new MenuItem
2607 * @param {Object} config The config object
2611 Roo.bootstrap.MenuSeparator = function(config){
2612 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2615 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2617 getAutoCreate : function(){
2636 * @class Roo.bootstrap.Modal
2637 * @extends Roo.bootstrap.Component
2638 * Bootstrap Modal class
2639 * @cfg {String} title Title of dialog
2640 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2641 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2642 * @cfg {Boolean} specificTitle default false
2643 * @cfg {Array} buttons Array of buttons or standard button set..
2644 * @cfg {String} buttonPosition (left|right|center) default right
2645 * @cfg {Boolean} animate default true
2646 * @cfg {Boolean} allow_close default true
2647 * @cfg {Boolean} fitwindow default false
2648 * @cfg {String} size (sm|lg) default empty
2649 * @cfg {Number} max_width set the max width of modal
2653 * Create a new Modal Dialog
2654 * @param {Object} config The config object
2657 Roo.bootstrap.Modal = function(config){
2658 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2663 * The raw btnclick event for the button
2664 * @param {Roo.EventObject} e
2669 * Fire when dialog resize
2670 * @param {Roo.bootstrap.Modal} this
2671 * @param {Roo.EventObject} e
2675 this.buttons = this.buttons || [];
2678 this.tmpl = Roo.factory(this.tmpl);
2683 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2685 title : 'test dialog',
2695 specificTitle: false,
2697 buttonPosition: 'right',
2720 onRender : function(ct, position)
2722 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2725 var cfg = Roo.apply({}, this.getAutoCreate());
2728 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2730 //if (!cfg.name.length) {
2734 cfg.cls += ' ' + this.cls;
2737 cfg.style = this.style;
2739 this.el = Roo.get(document.body).createChild(cfg, position);
2741 //var type = this.el.dom.type;
2744 if(this.tabIndex !== undefined){
2745 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2748 this.dialogEl = this.el.select('.modal-dialog',true).first();
2749 this.bodyEl = this.el.select('.modal-body',true).first();
2750 this.closeEl = this.el.select('.modal-header .close', true).first();
2751 this.headerEl = this.el.select('.modal-header',true).first();
2752 this.titleEl = this.el.select('.modal-title',true).first();
2753 this.footerEl = this.el.select('.modal-footer',true).first();
2755 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2757 //this.el.addClass("x-dlg-modal");
2759 if (this.buttons.length) {
2760 Roo.each(this.buttons, function(bb) {
2761 var b = Roo.apply({}, bb);
2762 b.xns = b.xns || Roo.bootstrap;
2763 b.xtype = b.xtype || 'Button';
2764 if (typeof(b.listeners) == 'undefined') {
2765 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2768 var btn = Roo.factory(b);
2770 btn.render(this.el.select('.modal-footer div').first());
2774 // render the children.
2777 if(typeof(this.items) != 'undefined'){
2778 var items = this.items;
2781 for(var i =0;i < items.length;i++) {
2782 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2786 this.items = nitems;
2788 // where are these used - they used to be body/close/footer
2792 //this.el.addClass([this.fieldClass, this.cls]);
2796 getAutoCreate : function()
2800 html : this.html || ''
2805 cls : 'modal-title',
2809 if(this.specificTitle){
2815 if (this.allow_close && Roo.bootstrap.version == 3) {
2825 if (this.allow_close && Roo.bootstrap.version == 4) {
2835 if(this.size.length){
2836 size = 'modal-' + this.size;
2843 cls: "modal-dialog " + size,
2846 cls : "modal-content",
2849 cls : 'modal-header',
2854 cls : 'modal-footer',
2858 cls: 'btn-' + this.buttonPosition
2875 modal.cls += ' fade';
2881 getChildContainer : function() {
2886 getButtonContainer : function() {
2887 return this.el.select('.modal-footer div',true).first();
2890 initEvents : function()
2892 if (this.allow_close) {
2893 this.closeEl.on('click', this.hide, this);
2895 Roo.EventManager.onWindowResize(this.resize, this, true);
2902 this.maskEl.setSize(
2903 Roo.lib.Dom.getViewWidth(true),
2904 Roo.lib.Dom.getViewHeight(true)
2907 if (this.fitwindow) {
2909 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2910 this.height || Roo.lib.Dom.getViewportHeight(true) - 60
2915 if(this.max_width !== 0) {
2917 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2920 this.setSize(w, this.height);
2924 if(this.max_height) {
2925 this.setSize(w,Math.min(
2927 Roo.lib.Dom.getViewportHeight(true) - 60
2933 if(!this.fit_content) {
2934 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2938 this.setSize(w, Math.min(
2940 this.headerEl.getHeight() +
2941 this.footerEl.getHeight() +
2942 this.getChildHeight(this.bodyEl.dom.childNodes),
2943 Roo.lib.Dom.getViewportHeight(true) - 60)
2949 setSize : function(w,h)
2960 if (!this.rendered) {
2964 //this.el.setStyle('display', 'block');
2965 this.el.removeClass('hideing');
2966 this.el.dom.style.display='block';
2968 Roo.get(document.body).addClass('modal-open');
2970 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2973 this.el.addClass('show');
2974 this.el.addClass('in');
2977 this.el.addClass('show');
2978 this.el.addClass('in');
2981 // not sure how we can show data in here..
2983 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2986 Roo.get(document.body).addClass("x-body-masked");
2988 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2989 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2990 this.maskEl.dom.style.display = 'block';
2991 this.maskEl.addClass('show');
2996 this.fireEvent('show', this);
2998 // set zindex here - otherwise it appears to be ignored...
2999 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3002 this.items.forEach( function(e) {
3003 e.layout ? e.layout() : false;
3011 if(this.fireEvent("beforehide", this) !== false){
3013 this.maskEl.removeClass('show');
3015 this.maskEl.dom.style.display = '';
3016 Roo.get(document.body).removeClass("x-body-masked");
3017 this.el.removeClass('in');
3018 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3020 if(this.animate){ // why
3021 this.el.addClass('hideing');
3022 this.el.removeClass('show');
3024 if (!this.el.hasClass('hideing')) {
3025 return; // it's been shown again...
3028 this.el.dom.style.display='';
3030 Roo.get(document.body).removeClass('modal-open');
3031 this.el.removeClass('hideing');
3035 this.el.removeClass('show');
3036 this.el.dom.style.display='';
3037 Roo.get(document.body).removeClass('modal-open');
3040 this.fireEvent('hide', this);
3043 isVisible : function()
3046 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3050 addButton : function(str, cb)
3054 var b = Roo.apply({}, { html : str } );
3055 b.xns = b.xns || Roo.bootstrap;
3056 b.xtype = b.xtype || 'Button';
3057 if (typeof(b.listeners) == 'undefined') {
3058 b.listeners = { click : cb.createDelegate(this) };
3061 var btn = Roo.factory(b);
3063 btn.render(this.el.select('.modal-footer div').first());
3069 setDefaultButton : function(btn)
3071 //this.el.select('.modal-footer').()
3075 resizeTo: function(w,h)
3079 this.dialogEl.setWidth(w);
3080 if (this.diff === false) {
3081 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
3084 this.bodyEl.setHeight(h - this.diff);
3086 this.fireEvent('resize', this);
3089 setContentSize : function(w, h)
3093 onButtonClick: function(btn,e)
3096 this.fireEvent('btnclick', btn.name, e);
3099 * Set the title of the Dialog
3100 * @param {String} str new Title
3102 setTitle: function(str) {
3103 this.titleEl.dom.innerHTML = str;
3106 * Set the body of the Dialog
3107 * @param {String} str new Title
3109 setBody: function(str) {
3110 this.bodyEl.dom.innerHTML = str;
3113 * Set the body of the Dialog using the template
3114 * @param {Obj} data - apply this data to the template and replace the body contents.
3116 applyBody: function(obj)
3119 Roo.log("Error - using apply Body without a template");
3122 this.tmpl.overwrite(this.bodyEl, obj);
3125 getChildHeight : function(child_nodes)
3129 child_nodes.length == 0
3134 var child_height = 0;
3136 for(var i = 0; i < child_nodes.length; i++) {
3139 * for modal with tabs...
3140 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3142 var layout_childs = child_nodes[i].childNodes;
3144 for(var j = 0; j < layout_childs.length; j++) {
3146 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3148 var layout_body_childs = layout_childs[j].childNodes;
3150 for(var k = 0; k < layout_body_childs.length; k++) {
3152 if(layout_body_childs[k].classList.contains('navbar')) {
3153 child_height += layout_body_childs[k].offsetHeight;
3157 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3159 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3161 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3163 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3164 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3179 child_height += child_nodes[i].offsetHeight;
3180 // Roo.log(child_nodes[i].offsetHeight);
3183 return child_height;
3189 Roo.apply(Roo.bootstrap.Modal, {
3191 * Button config that displays a single OK button
3200 * Button config that displays Yes and No buttons
3216 * Button config that displays OK and Cancel buttons
3231 * Button config that displays Yes, No and Cancel buttons
3255 * messagebox - can be used as a replace
3259 * @class Roo.MessageBox
3260 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3264 Roo.Msg.alert('Status', 'Changes saved successfully.');
3266 // Prompt for user data:
3267 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3269 // process text value...
3273 // Show a dialog using config options:
3275 title:'Save Changes?',
3276 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3277 buttons: Roo.Msg.YESNOCANCEL,
3284 Roo.bootstrap.MessageBox = function(){
3285 var dlg, opt, mask, waitTimer;
3286 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3287 var buttons, activeTextEl, bwidth;
3291 var handleButton = function(button){
3293 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3297 var handleHide = function(){
3299 dlg.el.removeClass(opt.cls);
3302 // Roo.TaskMgr.stop(waitTimer);
3303 // waitTimer = null;
3308 var updateButtons = function(b){
3311 buttons["ok"].hide();
3312 buttons["cancel"].hide();
3313 buttons["yes"].hide();
3314 buttons["no"].hide();
3315 //dlg.footer.dom.style.display = 'none';
3318 dlg.footerEl.dom.style.display = '';
3319 for(var k in buttons){
3320 if(typeof buttons[k] != "function"){
3323 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3324 width += buttons[k].el.getWidth()+15;
3334 var handleEsc = function(d, k, e){
3335 if(opt && opt.closable !== false){
3345 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3346 * @return {Roo.BasicDialog} The BasicDialog element
3348 getDialog : function(){
3350 dlg = new Roo.bootstrap.Modal( {
3353 //constraintoviewport:false,
3355 //collapsible : false,
3360 //buttonAlign:"center",
3361 closeClick : function(){
3362 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3365 handleButton("cancel");
3370 dlg.on("hide", handleHide);
3372 //dlg.addKeyListener(27, handleEsc);
3374 this.buttons = buttons;
3375 var bt = this.buttonText;
3376 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3377 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3378 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3379 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3381 bodyEl = dlg.bodyEl.createChild({
3383 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3384 '<textarea class="roo-mb-textarea"></textarea>' +
3385 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3387 msgEl = bodyEl.dom.firstChild;
3388 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3389 textboxEl.enableDisplayMode();
3390 textboxEl.addKeyListener([10,13], function(){
3391 if(dlg.isVisible() && opt && opt.buttons){
3394 }else if(opt.buttons.yes){
3395 handleButton("yes");
3399 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3400 textareaEl.enableDisplayMode();
3401 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3402 progressEl.enableDisplayMode();
3404 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3405 var pf = progressEl.dom.firstChild;
3407 pp = Roo.get(pf.firstChild);
3408 pp.setHeight(pf.offsetHeight);
3416 * Updates the message box body text
3417 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3418 * the XHTML-compliant non-breaking space character '&#160;')
3419 * @return {Roo.MessageBox} This message box
3421 updateText : function(text)
3423 if(!dlg.isVisible() && !opt.width){
3424 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3425 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3427 msgEl.innerHTML = text || ' ';
3429 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3430 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3432 Math.min(opt.width || cw , this.maxWidth),
3433 Math.max(opt.minWidth || this.minWidth, bwidth)
3436 activeTextEl.setWidth(w);
3438 if(dlg.isVisible()){
3439 dlg.fixedcenter = false;
3441 // to big, make it scroll. = But as usual stupid IE does not support
3444 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3445 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3446 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3448 bodyEl.dom.style.height = '';
3449 bodyEl.dom.style.overflowY = '';
3452 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3454 bodyEl.dom.style.overflowX = '';
3457 dlg.setContentSize(w, bodyEl.getHeight());
3458 if(dlg.isVisible()){
3459 dlg.fixedcenter = true;
3465 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3466 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3467 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3468 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3469 * @return {Roo.MessageBox} This message box
3471 updateProgress : function(value, text){
3473 this.updateText(text);
3476 if (pp) { // weird bug on my firefox - for some reason this is not defined
3477 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3478 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3484 * Returns true if the message box is currently displayed
3485 * @return {Boolean} True if the message box is visible, else false
3487 isVisible : function(){
3488 return dlg && dlg.isVisible();
3492 * Hides the message box if it is displayed
3495 if(this.isVisible()){
3501 * Displays a new message box, or reinitializes an existing message box, based on the config options
3502 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3503 * The following config object properties are supported:
3505 Property Type Description
3506 ---------- --------------- ------------------------------------------------------------------------------------
3507 animEl String/Element An id or Element from which the message box should animate as it opens and
3508 closes (defaults to undefined)
3509 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3510 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3511 closable Boolean False to hide the top-right close button (defaults to true). Note that
3512 progress and wait dialogs will ignore this property and always hide the
3513 close button as they can only be closed programmatically.
3514 cls String A custom CSS class to apply to the message box element
3515 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3516 displayed (defaults to 75)
3517 fn Function A callback function to execute after closing the dialog. The arguments to the
3518 function will be btn (the name of the button that was clicked, if applicable,
3519 e.g. "ok"), and text (the value of the active text field, if applicable).
3520 Progress and wait dialogs will ignore this option since they do not respond to
3521 user actions and can only be closed programmatically, so any required function
3522 should be called by the same code after it closes the dialog.
3523 icon String A CSS class that provides a background image to be used as an icon for
3524 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3525 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3526 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3527 modal Boolean False to allow user interaction with the page while the message box is
3528 displayed (defaults to true)
3529 msg String A string that will replace the existing message box body text (defaults
3530 to the XHTML-compliant non-breaking space character ' ')
3531 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3532 progress Boolean True to display a progress bar (defaults to false)
3533 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3534 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3535 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3536 title String The title text
3537 value String The string value to set into the active textbox element if displayed
3538 wait Boolean True to display a progress bar (defaults to false)
3539 width Number The width of the dialog in pixels
3546 msg: 'Please enter your address:',
3548 buttons: Roo.MessageBox.OKCANCEL,
3551 animEl: 'addAddressBtn'
3554 * @param {Object} config Configuration options
3555 * @return {Roo.MessageBox} This message box
3557 show : function(options)
3560 // this causes nightmares if you show one dialog after another
3561 // especially on callbacks..
3563 if(this.isVisible()){
3566 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3567 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3568 Roo.log("New Dialog Message:" + options.msg )
3569 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3570 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3573 var d = this.getDialog();
3575 d.setTitle(opt.title || " ");
3576 d.closeEl.setDisplayed(opt.closable !== false);
3577 activeTextEl = textboxEl;
3578 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3583 textareaEl.setHeight(typeof opt.multiline == "number" ?
3584 opt.multiline : this.defaultTextHeight);
3585 activeTextEl = textareaEl;
3594 progressEl.setDisplayed(opt.progress === true);
3595 this.updateProgress(0);
3596 activeTextEl.dom.value = opt.value || "";
3598 dlg.setDefaultButton(activeTextEl);
3600 var bs = opt.buttons;
3604 }else if(bs && bs.yes){
3605 db = buttons["yes"];
3607 dlg.setDefaultButton(db);
3609 bwidth = updateButtons(opt.buttons);
3610 this.updateText(opt.msg);
3612 d.el.addClass(opt.cls);
3614 d.proxyDrag = opt.proxyDrag === true;
3615 d.modal = opt.modal !== false;
3616 d.mask = opt.modal !== false ? mask : false;
3618 // force it to the end of the z-index stack so it gets a cursor in FF
3619 document.body.appendChild(dlg.el.dom);
3620 d.animateTarget = null;
3621 d.show(options.animEl);
3627 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3628 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3629 * and closing the message box when the process is complete.
3630 * @param {String} title The title bar text
3631 * @param {String} msg The message box body text
3632 * @return {Roo.MessageBox} This message box
3634 progress : function(title, msg){
3641 minWidth: this.minProgressWidth,
3648 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3649 * If a callback function is passed it will be called after the user clicks the button, and the
3650 * id of the button that was clicked will be passed as the only parameter to the callback
3651 * (could also be the top-right close button).
3652 * @param {String} title The title bar text
3653 * @param {String} msg The message box body text
3654 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3655 * @param {Object} scope (optional) The scope of the callback function
3656 * @return {Roo.MessageBox} This message box
3658 alert : function(title, msg, fn, scope)
3673 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3674 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3675 * You are responsible for closing the message box when the process is complete.
3676 * @param {String} msg The message box body text
3677 * @param {String} title (optional) The title bar text
3678 * @return {Roo.MessageBox} This message box
3680 wait : function(msg, title){
3691 waitTimer = Roo.TaskMgr.start({
3693 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3701 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3702 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3703 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3704 * @param {String} title The title bar text
3705 * @param {String} msg The message box body text
3706 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3707 * @param {Object} scope (optional) The scope of the callback function
3708 * @return {Roo.MessageBox} This message box
3710 confirm : function(title, msg, fn, scope){
3714 buttons: this.YESNO,
3723 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3724 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3725 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3726 * (could also be the top-right close button) and the text that was entered will be passed as the two
3727 * parameters to the callback.
3728 * @param {String} title The title bar text
3729 * @param {String} msg The message box body text
3730 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3731 * @param {Object} scope (optional) The scope of the callback function
3732 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3733 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3734 * @return {Roo.MessageBox} This message box
3736 prompt : function(title, msg, fn, scope, multiline){
3740 buttons: this.OKCANCEL,
3745 multiline: multiline,
3752 * Button config that displays a single OK button
3757 * Button config that displays Yes and No buttons
3760 YESNO : {yes:true, no:true},
3762 * Button config that displays OK and Cancel buttons
3765 OKCANCEL : {ok:true, cancel:true},
3767 * Button config that displays Yes, No and Cancel buttons
3770 YESNOCANCEL : {yes:true, no:true, cancel:true},
3773 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3776 defaultTextHeight : 75,
3778 * The maximum width in pixels of the message box (defaults to 600)
3783 * The minimum width in pixels of the message box (defaults to 100)
3788 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3789 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3792 minProgressWidth : 250,
3794 * An object containing the default button text strings that can be overriden for localized language support.
3795 * Supported properties are: ok, cancel, yes and no.
3796 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3809 * Shorthand for {@link Roo.MessageBox}
3811 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3812 Roo.Msg = Roo.Msg || Roo.MessageBox;
3821 * @class Roo.bootstrap.Navbar
3822 * @extends Roo.bootstrap.Component
3823 * Bootstrap Navbar class
3826 * Create a new Navbar
3827 * @param {Object} config The config object
3831 Roo.bootstrap.Navbar = function(config){
3832 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3836 * @event beforetoggle
3837 * Fire before toggle the menu
3838 * @param {Roo.EventObject} e
3840 "beforetoggle" : true
3844 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3853 getAutoCreate : function(){
3856 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3860 initEvents :function ()
3862 //Roo.log(this.el.select('.navbar-toggle',true));
3863 this.el.select('.navbar-toggle',true).on('click', function() {
3864 if(this.fireEvent('beforetoggle', this) !== false){
3865 var ce = this.el.select('.navbar-collapse',true).first();
3866 ce.toggleClass('in'); // old...
3867 if (ce.hasClass('collapse')) {
3869 ce.removeClass('collapse');
3870 ce.addClass('show');
3871 var h = ce.getHeight();
3873 ce.removeClass('show');
3874 // at this point we should be able to see it..
3875 ce.addClass('collapsing');
3877 ce.setHeight(0); // resize it ...
3878 ce.on('transitionend', function() {
3879 Roo.log('done transition');
3880 ce.removeClass('collapsing');
3881 ce.addClass('show');
3882 ce.removeClass('collapse');
3884 ce.dom.style.height = '';
3885 }, this, { single: true} );
3889 ce.setHeight(ce.getHeight());
3890 ce.removeClass('show');
3891 ce.addClass('collapsing');
3893 ce.on('transitionend', function() {
3894 ce.dom.style.height = '';
3895 ce.removeClass('collapsing');
3896 ce.addClass('collapse');
3897 }, this, { single: true} );
3909 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3911 var size = this.el.getSize();
3912 this.maskEl.setSize(size.width, size.height);
3913 this.maskEl.enableDisplayMode("block");
3922 getChildContainer : function()
3924 if (this.el.select('.collapse').getCount()) {
3925 return this.el.select('.collapse',true).first();
3958 * @class Roo.bootstrap.NavSimplebar
3959 * @extends Roo.bootstrap.Navbar
3960 * Bootstrap Sidebar class
3962 * @cfg {Boolean} inverse is inverted color
3964 * @cfg {String} type (nav | pills | tabs)
3965 * @cfg {Boolean} arrangement stacked | justified
3966 * @cfg {String} align (left | right) alignment
3968 * @cfg {Boolean} main (true|false) main nav bar? default false
3969 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3971 * @cfg {String} tag (header|footer|nav|div) default is nav
3973 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
3977 * Create a new Sidebar
3978 * @param {Object} config The config object
3982 Roo.bootstrap.NavSimplebar = function(config){
3983 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3986 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4002 getAutoCreate : function(){
4006 tag : this.tag || 'div',
4007 cls : 'navbar navbar-expand-lg'
4009 if (['light','white'].indexOf(this.weight) > -1) {
4010 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4012 cfg.cls += ' bg-' + this.weight;
4024 this.type = this.type || 'nav';
4025 if (['tabs','pills'].indexOf(this.type)!==-1) {
4026 cfg.cn[0].cls += ' nav-' + this.type
4030 if (this.type!=='nav') {
4031 Roo.log('nav type must be nav/tabs/pills')
4033 cfg.cn[0].cls += ' navbar-nav'
4039 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
4040 cfg.cn[0].cls += ' nav-' + this.arrangement;
4044 if (this.align === 'right') {
4045 cfg.cn[0].cls += ' navbar-right';
4049 cfg.cls += ' navbar-inverse';
4073 * navbar-expand-md fixed-top
4077 * @class Roo.bootstrap.NavHeaderbar
4078 * @extends Roo.bootstrap.NavSimplebar
4079 * Bootstrap Sidebar class
4081 * @cfg {String} brand what is brand
4082 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4083 * @cfg {String} brand_href href of the brand
4084 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4085 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4086 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4087 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4090 * Create a new Sidebar
4091 * @param {Object} config The config object
4095 Roo.bootstrap.NavHeaderbar = function(config){
4096 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4100 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4107 desktopCenter : false,
4110 getAutoCreate : function(){
4113 tag: this.nav || 'nav',
4114 cls: 'navbar navbar-expand-md',
4120 if (this.desktopCenter) {
4121 cn.push({cls : 'container', cn : []});
4129 cls: 'navbar-toggle navbar-toggler',
4130 'data-toggle': 'collapse',
4135 html: 'Toggle navigation'
4139 cls: 'icon-bar navbar-toggler-icon'
4152 cn.push( Roo.bootstrap.version == 4 ? btn : {
4154 cls: 'navbar-header',
4163 cls: 'collapse navbar-collapse',
4167 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4169 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4170 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4172 // tag can override this..
4174 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4177 if (this.brand !== '') {
4178 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4179 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4181 href: this.brand_href ? this.brand_href : '#',
4182 cls: 'navbar-brand',
4190 cfg.cls += ' main-nav';
4198 getHeaderChildContainer : function()
4200 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4201 return this.el.select('.navbar-header',true).first();
4204 return this.getChildContainer();
4208 initEvents : function()
4210 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4212 if (this.autohide) {
4217 Roo.get(document).on('scroll',function(e) {
4218 var ns = Roo.get(document).getScroll().top;
4219 var os = prevScroll;
4223 ft.removeClass('slideDown');
4224 ft.addClass('slideUp');
4227 ft.removeClass('slideUp');
4228 ft.addClass('slideDown');
4249 * @class Roo.bootstrap.NavSidebar
4250 * @extends Roo.bootstrap.Navbar
4251 * Bootstrap Sidebar class
4254 * Create a new Sidebar
4255 * @param {Object} config The config object
4259 Roo.bootstrap.NavSidebar = function(config){
4260 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4263 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4265 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4267 getAutoCreate : function(){
4272 cls: 'sidebar sidebar-nav'
4294 * @class Roo.bootstrap.NavGroup
4295 * @extends Roo.bootstrap.Component
4296 * Bootstrap NavGroup class
4297 * @cfg {String} align (left|right)
4298 * @cfg {Boolean} inverse
4299 * @cfg {String} type (nav|pills|tab) default nav
4300 * @cfg {String} navId - reference Id for navbar.
4304 * Create a new nav group
4305 * @param {Object} config The config object
4308 Roo.bootstrap.NavGroup = function(config){
4309 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4312 Roo.bootstrap.NavGroup.register(this);
4316 * Fires when the active item changes
4317 * @param {Roo.bootstrap.NavGroup} this
4318 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4319 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4326 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4337 getAutoCreate : function()
4339 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4346 if (['tabs','pills'].indexOf(this.type)!==-1) {
4347 cfg.cls += ' nav-' + this.type
4349 if (this.type!=='nav') {
4350 Roo.log('nav type must be nav/tabs/pills')
4352 cfg.cls += ' navbar-nav'
4355 if (this.parent() && this.parent().sidebar) {
4358 cls: 'dashboard-menu sidebar-menu'
4364 if (this.form === true) {
4370 if (this.align === 'right') {
4371 cfg.cls += ' navbar-right ml-md-auto';
4373 cfg.cls += ' navbar-left';
4377 if (this.align === 'right') {
4378 cfg.cls += ' navbar-right ml-md-auto';
4380 cfg.cls += ' mr-auto';
4384 cfg.cls += ' navbar-inverse';
4392 * sets the active Navigation item
4393 * @param {Roo.bootstrap.NavItem} the new current navitem
4395 setActiveItem : function(item)
4398 Roo.each(this.navItems, function(v){
4403 v.setActive(false, true);
4410 item.setActive(true, true);
4411 this.fireEvent('changed', this, item, prev);
4416 * gets the active Navigation item
4417 * @return {Roo.bootstrap.NavItem} the current navitem
4419 getActive : function()
4423 Roo.each(this.navItems, function(v){
4434 indexOfNav : function()
4438 Roo.each(this.navItems, function(v,i){
4449 * adds a Navigation item
4450 * @param {Roo.bootstrap.NavItem} the navitem to add
4452 addItem : function(cfg)
4454 var cn = new Roo.bootstrap.NavItem(cfg);
4456 cn.parentId = this.id;
4457 cn.onRender(this.el, null);
4461 * register a Navigation item
4462 * @param {Roo.bootstrap.NavItem} the navitem to add
4464 register : function(item)
4466 this.navItems.push( item);
4467 item.navId = this.navId;
4472 * clear all the Navigation item
4475 clearAll : function()
4478 this.el.dom.innerHTML = '';
4481 getNavItem: function(tabId)
4484 Roo.each(this.navItems, function(e) {
4485 if (e.tabId == tabId) {
4495 setActiveNext : function()
4497 var i = this.indexOfNav(this.getActive());
4498 if (i > this.navItems.length) {
4501 this.setActiveItem(this.navItems[i+1]);
4503 setActivePrev : function()
4505 var i = this.indexOfNav(this.getActive());
4509 this.setActiveItem(this.navItems[i-1]);
4511 clearWasActive : function(except) {
4512 Roo.each(this.navItems, function(e) {
4513 if (e.tabId != except.tabId && e.was_active) {
4514 e.was_active = false;
4521 getWasActive : function ()
4524 Roo.each(this.navItems, function(e) {
4539 Roo.apply(Roo.bootstrap.NavGroup, {
4543 * register a Navigation Group
4544 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4546 register : function(navgrp)
4548 this.groups[navgrp.navId] = navgrp;
4552 * fetch a Navigation Group based on the navigation ID
4553 * @param {string} the navgroup to add
4554 * @returns {Roo.bootstrap.NavGroup} the navgroup
4556 get: function(navId) {
4557 if (typeof(this.groups[navId]) == 'undefined') {
4559 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4561 return this.groups[navId] ;
4576 * @class Roo.bootstrap.NavItem
4577 * @extends Roo.bootstrap.Component
4578 * Bootstrap Navbar.NavItem class
4579 * @cfg {String} href link to
4580 * @cfg {String} html content of button
4581 * @cfg {String} badge text inside badge
4582 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4583 * @cfg {String} glyphicon DEPRICATED - use fa
4584 * @cfg {String} icon DEPRICATED - use fa
4585 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4586 * @cfg {Boolean} active Is item active
4587 * @cfg {Boolean} disabled Is item disabled
4589 * @cfg {Boolean} preventDefault (true | false) default false
4590 * @cfg {String} tabId the tab that this item activates.
4591 * @cfg {String} tagtype (a|span) render as a href or span?
4592 * @cfg {Boolean} animateRef (true|false) link to element default false
4595 * Create a new Navbar Item
4596 * @param {Object} config The config object
4598 Roo.bootstrap.NavItem = function(config){
4599 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4604 * The raw click event for the entire grid.
4605 * @param {Roo.EventObject} e
4610 * Fires when the active item active state changes
4611 * @param {Roo.bootstrap.NavItem} this
4612 * @param {boolean} state the new state
4618 * Fires when scroll to element
4619 * @param {Roo.bootstrap.NavItem} this
4620 * @param {Object} options
4621 * @param {Roo.EventObject} e
4629 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4638 preventDefault : false,
4645 getAutoCreate : function(){
4654 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4656 if (this.disabled) {
4657 cfg.cls += ' disabled';
4660 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4664 href : this.href || "#",
4665 html: this.html || ''
4668 if (this.tagtype == 'a') {
4669 cfg.cn[0].cls = 'nav-link';
4672 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4675 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>'
4677 if(this.glyphicon) {
4678 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4683 cfg.cn[0].html += " <span class='caret'></span>";
4687 if (this.badge !== '') {
4689 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4697 initEvents: function()
4699 if (typeof (this.menu) != 'undefined') {
4700 this.menu.parentType = this.xtype;
4701 this.menu.triggerEl = this.el;
4702 this.menu = this.addxtype(Roo.apply({}, this.menu));
4705 this.el.select('a',true).on('click', this.onClick, this);
4707 if(this.tagtype == 'span'){
4708 this.el.select('span',true).on('click', this.onClick, this);
4711 // at this point parent should be available..
4712 this.parent().register(this);
4715 onClick : function(e)
4717 if (e.getTarget('.dropdown-menu-item')) {
4718 // did you click on a menu itemm.... - then don't trigger onclick..
4723 this.preventDefault ||
4726 Roo.log("NavItem - prevent Default?");
4730 if (this.disabled) {
4734 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4735 if (tg && tg.transition) {
4736 Roo.log("waiting for the transitionend");
4742 //Roo.log("fire event clicked");
4743 if(this.fireEvent('click', this, e) === false){
4747 if(this.tagtype == 'span'){
4751 //Roo.log(this.href);
4752 var ael = this.el.select('a',true).first();
4755 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4756 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4757 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4758 return; // ignore... - it's a 'hash' to another page.
4760 Roo.log("NavItem - prevent Default?");
4762 this.scrollToElement(e);
4766 var p = this.parent();
4768 if (['tabs','pills'].indexOf(p.type)!==-1) {
4769 if (typeof(p.setActiveItem) !== 'undefined') {
4770 p.setActiveItem(this);
4774 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4775 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4776 // remove the collapsed menu expand...
4777 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4781 isActive: function () {
4784 setActive : function(state, fire, is_was_active)
4786 if (this.active && !state && this.navId) {
4787 this.was_active = true;
4788 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4790 nv.clearWasActive(this);
4794 this.active = state;
4797 this.el.removeClass('active');
4798 } else if (!this.el.hasClass('active')) {
4799 this.el.addClass('active');
4802 this.fireEvent('changed', this, state);
4805 // show a panel if it's registered and related..
4807 if (!this.navId || !this.tabId || !state || is_was_active) {
4811 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4815 var pan = tg.getPanelByName(this.tabId);
4819 // if we can not flip to new panel - go back to old nav highlight..
4820 if (false == tg.showPanel(pan)) {
4821 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4823 var onav = nv.getWasActive();
4825 onav.setActive(true, false, true);
4834 // this should not be here...
4835 setDisabled : function(state)
4837 this.disabled = state;
4839 this.el.removeClass('disabled');
4840 } else if (!this.el.hasClass('disabled')) {
4841 this.el.addClass('disabled');
4847 * Fetch the element to display the tooltip on.
4848 * @return {Roo.Element} defaults to this.el
4850 tooltipEl : function()
4852 return this.el.select('' + this.tagtype + '', true).first();
4855 scrollToElement : function(e)
4857 var c = document.body;
4860 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4862 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4863 c = document.documentElement;
4866 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4872 var o = target.calcOffsetsTo(c);
4879 this.fireEvent('scrollto', this, options, e);
4881 Roo.get(c).scrollTo('top', options.value, true);
4894 * <span> icon </span>
4895 * <span> text </span>
4896 * <span>badge </span>
4900 * @class Roo.bootstrap.NavSidebarItem
4901 * @extends Roo.bootstrap.NavItem
4902 * Bootstrap Navbar.NavSidebarItem class
4903 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4904 * {Boolean} open is the menu open
4905 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4906 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4907 * {String} buttonSize (sm|md|lg)the extra classes for the button
4908 * {Boolean} showArrow show arrow next to the text (default true)
4910 * Create a new Navbar Button
4911 * @param {Object} config The config object
4913 Roo.bootstrap.NavSidebarItem = function(config){
4914 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4919 * The raw click event for the entire grid.
4920 * @param {Roo.EventObject} e
4925 * Fires when the active item active state changes
4926 * @param {Roo.bootstrap.NavSidebarItem} this
4927 * @param {boolean} state the new state
4935 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4937 badgeWeight : 'default',
4943 buttonWeight : 'default',
4949 getAutoCreate : function(){
4954 href : this.href || '#',
4960 if(this.buttonView){
4963 href : this.href || '#',
4964 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4977 cfg.cls += ' active';
4980 if (this.disabled) {
4981 cfg.cls += ' disabled';
4984 cfg.cls += ' open x-open';
4987 if (this.glyphicon || this.icon) {
4988 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4989 a.cn.push({ tag : 'i', cls : c }) ;
4992 if(!this.buttonView){
4995 html : this.html || ''
5002 if (this.badge !== '') {
5003 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5009 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5012 a.cls += ' dropdown-toggle treeview' ;
5018 initEvents : function()
5020 if (typeof (this.menu) != 'undefined') {
5021 this.menu.parentType = this.xtype;
5022 this.menu.triggerEl = this.el;
5023 this.menu = this.addxtype(Roo.apply({}, this.menu));
5026 this.el.on('click', this.onClick, this);
5028 if(this.badge !== ''){
5029 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5034 onClick : function(e)
5041 if(this.preventDefault){
5045 this.fireEvent('click', this);
5048 disable : function()
5050 this.setDisabled(true);
5055 this.setDisabled(false);
5058 setDisabled : function(state)
5060 if(this.disabled == state){
5064 this.disabled = state;
5067 this.el.addClass('disabled');
5071 this.el.removeClass('disabled');
5076 setActive : function(state)
5078 if(this.active == state){
5082 this.active = state;
5085 this.el.addClass('active');
5089 this.el.removeClass('active');
5094 isActive: function ()
5099 setBadge : function(str)
5105 this.badgeEl.dom.innerHTML = str;
5122 * @class Roo.bootstrap.Row
5123 * @extends Roo.bootstrap.Component
5124 * Bootstrap Row class (contains columns...)
5128 * @param {Object} config The config object
5131 Roo.bootstrap.Row = function(config){
5132 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5135 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5137 getAutoCreate : function(){
5156 * @class Roo.bootstrap.Element
5157 * @extends Roo.bootstrap.Component
5158 * Bootstrap Element class
5159 * @cfg {String} html contents of the element
5160 * @cfg {String} tag tag of the element
5161 * @cfg {String} cls class of the element
5162 * @cfg {Boolean} preventDefault (true|false) default false
5163 * @cfg {Boolean} clickable (true|false) default false
5166 * Create a new Element
5167 * @param {Object} config The config object
5170 Roo.bootstrap.Element = function(config){
5171 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5177 * When a element is chick
5178 * @param {Roo.bootstrap.Element} this
5179 * @param {Roo.EventObject} e
5185 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5190 preventDefault: false,
5193 getAutoCreate : function(){
5197 // cls: this.cls, double assign in parent class Component.js :: onRender
5204 initEvents: function()
5206 Roo.bootstrap.Element.superclass.initEvents.call(this);
5209 this.el.on('click', this.onClick, this);
5214 onClick : function(e)
5216 if(this.preventDefault){
5220 this.fireEvent('click', this, e);
5223 getValue : function()
5225 return this.el.dom.innerHTML;
5228 setValue : function(value)
5230 this.el.dom.innerHTML = value;
5245 * @class Roo.bootstrap.Pagination
5246 * @extends Roo.bootstrap.Component
5247 * Bootstrap Pagination class
5248 * @cfg {String} size xs | sm | md | lg
5249 * @cfg {Boolean} inverse false | true
5252 * Create a new Pagination
5253 * @param {Object} config The config object
5256 Roo.bootstrap.Pagination = function(config){
5257 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5260 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5266 getAutoCreate : function(){
5272 cfg.cls += ' inverse';
5278 cfg.cls += " " + this.cls;
5296 * @class Roo.bootstrap.PaginationItem
5297 * @extends Roo.bootstrap.Component
5298 * Bootstrap PaginationItem class
5299 * @cfg {String} html text
5300 * @cfg {String} href the link
5301 * @cfg {Boolean} preventDefault (true | false) default true
5302 * @cfg {Boolean} active (true | false) default false
5303 * @cfg {Boolean} disabled default false
5307 * Create a new PaginationItem
5308 * @param {Object} config The config object
5312 Roo.bootstrap.PaginationItem = function(config){
5313 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5318 * The raw click event for the entire grid.
5319 * @param {Roo.EventObject} e
5325 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5329 preventDefault: true,
5334 getAutoCreate : function(){
5340 href : this.href ? this.href : '#',
5341 html : this.html ? this.html : ''
5351 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5355 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5361 initEvents: function() {
5363 this.el.on('click', this.onClick, this);
5366 onClick : function(e)
5368 Roo.log('PaginationItem on click ');
5369 if(this.preventDefault){
5377 this.fireEvent('click', this, e);
5393 * @class Roo.bootstrap.Slider
5394 * @extends Roo.bootstrap.Component
5395 * Bootstrap Slider class
5398 * Create a new Slider
5399 * @param {Object} config The config object
5402 Roo.bootstrap.Slider = function(config){
5403 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5406 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5408 getAutoCreate : function(){
5412 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5416 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5428 * Ext JS Library 1.1.1
5429 * Copyright(c) 2006-2007, Ext JS, LLC.
5431 * Originally Released Under LGPL - original licence link has changed is not relivant.
5434 * <script type="text/javascript">
5439 * @class Roo.grid.ColumnModel
5440 * @extends Roo.util.Observable
5441 * This is the default implementation of a ColumnModel used by the Grid. It defines
5442 * the columns in the grid.
5445 var colModel = new Roo.grid.ColumnModel([
5446 {header: "Ticker", width: 60, sortable: true, locked: true},
5447 {header: "Company Name", width: 150, sortable: true},
5448 {header: "Market Cap.", width: 100, sortable: true},
5449 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5450 {header: "Employees", width: 100, sortable: true, resizable: false}
5455 * The config options listed for this class are options which may appear in each
5456 * individual column definition.
5457 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5459 * @param {Object} config An Array of column config objects. See this class's
5460 * config objects for details.
5462 Roo.grid.ColumnModel = function(config){
5464 * The config passed into the constructor
5466 this.config = config;
5469 // if no id, create one
5470 // if the column does not have a dataIndex mapping,
5471 // map it to the order it is in the config
5472 for(var i = 0, len = config.length; i < len; i++){
5474 if(typeof c.dataIndex == "undefined"){
5477 if(typeof c.renderer == "string"){
5478 c.renderer = Roo.util.Format[c.renderer];
5480 if(typeof c.id == "undefined"){
5483 if(c.editor && c.editor.xtype){
5484 c.editor = Roo.factory(c.editor, Roo.grid);
5486 if(c.editor && c.editor.isFormField){
5487 c.editor = new Roo.grid.GridEditor(c.editor);
5489 this.lookup[c.id] = c;
5493 * The width of columns which have no width specified (defaults to 100)
5496 this.defaultWidth = 100;
5499 * Default sortable of columns which have no sortable specified (defaults to false)
5502 this.defaultSortable = false;
5506 * @event widthchange
5507 * Fires when the width of a column changes.
5508 * @param {ColumnModel} this
5509 * @param {Number} columnIndex The column index
5510 * @param {Number} newWidth The new width
5512 "widthchange": true,
5514 * @event headerchange
5515 * Fires when the text of a header changes.
5516 * @param {ColumnModel} this
5517 * @param {Number} columnIndex The column index
5518 * @param {Number} newText The new header text
5520 "headerchange": true,
5522 * @event hiddenchange
5523 * Fires when a column is hidden or "unhidden".
5524 * @param {ColumnModel} this
5525 * @param {Number} columnIndex The column index
5526 * @param {Boolean} hidden true if hidden, false otherwise
5528 "hiddenchange": true,
5530 * @event columnmoved
5531 * Fires when a column is moved.
5532 * @param {ColumnModel} this
5533 * @param {Number} oldIndex
5534 * @param {Number} newIndex
5536 "columnmoved" : true,
5538 * @event columlockchange
5539 * Fires when a column's locked state is changed
5540 * @param {ColumnModel} this
5541 * @param {Number} colIndex
5542 * @param {Boolean} locked true if locked
5544 "columnlockchange" : true
5546 Roo.grid.ColumnModel.superclass.constructor.call(this);
5548 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5550 * @cfg {String} header The header text to display in the Grid view.
5553 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5554 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5555 * specified, the column's index is used as an index into the Record's data Array.
5558 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5559 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5562 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5563 * Defaults to the value of the {@link #defaultSortable} property.
5564 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5567 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5570 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5573 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5576 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5579 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5580 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5581 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5582 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5585 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5588 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5591 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5594 * @cfg {String} cursor (Optional)
5597 * @cfg {String} tooltip (Optional)
5600 * @cfg {Number} xs (Optional)
5603 * @cfg {Number} sm (Optional)
5606 * @cfg {Number} md (Optional)
5609 * @cfg {Number} lg (Optional)
5612 * Returns the id of the column at the specified index.
5613 * @param {Number} index The column index
5614 * @return {String} the id
5616 getColumnId : function(index){
5617 return this.config[index].id;
5621 * Returns the column for a specified id.
5622 * @param {String} id The column id
5623 * @return {Object} the column
5625 getColumnById : function(id){
5626 return this.lookup[id];
5631 * Returns the column for a specified dataIndex.
5632 * @param {String} dataIndex The column dataIndex
5633 * @return {Object|Boolean} the column or false if not found
5635 getColumnByDataIndex: function(dataIndex){
5636 var index = this.findColumnIndex(dataIndex);
5637 return index > -1 ? this.config[index] : false;
5641 * Returns the index for a specified column id.
5642 * @param {String} id The column id
5643 * @return {Number} the index, or -1 if not found
5645 getIndexById : function(id){
5646 for(var i = 0, len = this.config.length; i < len; i++){
5647 if(this.config[i].id == id){
5655 * Returns the index for a specified column dataIndex.
5656 * @param {String} dataIndex The column dataIndex
5657 * @return {Number} the index, or -1 if not found
5660 findColumnIndex : function(dataIndex){
5661 for(var i = 0, len = this.config.length; i < len; i++){
5662 if(this.config[i].dataIndex == dataIndex){
5670 moveColumn : function(oldIndex, newIndex){
5671 var c = this.config[oldIndex];
5672 this.config.splice(oldIndex, 1);
5673 this.config.splice(newIndex, 0, c);
5674 this.dataMap = null;
5675 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5678 isLocked : function(colIndex){
5679 return this.config[colIndex].locked === true;
5682 setLocked : function(colIndex, value, suppressEvent){
5683 if(this.isLocked(colIndex) == value){
5686 this.config[colIndex].locked = value;
5688 this.fireEvent("columnlockchange", this, colIndex, value);
5692 getTotalLockedWidth : function(){
5694 for(var i = 0; i < this.config.length; i++){
5695 if(this.isLocked(i) && !this.isHidden(i)){
5696 this.totalWidth += this.getColumnWidth(i);
5702 getLockedCount : function(){
5703 for(var i = 0, len = this.config.length; i < len; i++){
5704 if(!this.isLocked(i)){
5709 return this.config.length;
5713 * Returns the number of columns.
5716 getColumnCount : function(visibleOnly){
5717 if(visibleOnly === true){
5719 for(var i = 0, len = this.config.length; i < len; i++){
5720 if(!this.isHidden(i)){
5726 return this.config.length;
5730 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5731 * @param {Function} fn
5732 * @param {Object} scope (optional)
5733 * @return {Array} result
5735 getColumnsBy : function(fn, scope){
5737 for(var i = 0, len = this.config.length; i < len; i++){
5738 var c = this.config[i];
5739 if(fn.call(scope||this, c, i) === true){
5747 * Returns true if the specified column is sortable.
5748 * @param {Number} col The column index
5751 isSortable : function(col){
5752 if(typeof this.config[col].sortable == "undefined"){
5753 return this.defaultSortable;
5755 return this.config[col].sortable;
5759 * Returns the rendering (formatting) function defined for the column.
5760 * @param {Number} col The column index.
5761 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5763 getRenderer : function(col){
5764 if(!this.config[col].renderer){
5765 return Roo.grid.ColumnModel.defaultRenderer;
5767 return this.config[col].renderer;
5771 * Sets the rendering (formatting) function for a column.
5772 * @param {Number} col The column index
5773 * @param {Function} fn The function to use to process the cell's raw data
5774 * to return HTML markup for the grid view. The render function is called with
5775 * the following parameters:<ul>
5776 * <li>Data value.</li>
5777 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5778 * <li>css A CSS style string to apply to the table cell.</li>
5779 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5780 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5781 * <li>Row index</li>
5782 * <li>Column index</li>
5783 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5785 setRenderer : function(col, fn){
5786 this.config[col].renderer = fn;
5790 * Returns the width for the specified column.
5791 * @param {Number} col The column index
5794 getColumnWidth : function(col){
5795 return this.config[col].width * 1 || this.defaultWidth;
5799 * Sets the width for a column.
5800 * @param {Number} col The column index
5801 * @param {Number} width The new width
5803 setColumnWidth : function(col, width, suppressEvent){
5804 this.config[col].width = width;
5805 this.totalWidth = null;
5807 this.fireEvent("widthchange", this, col, width);
5812 * Returns the total width of all columns.
5813 * @param {Boolean} includeHidden True to include hidden column widths
5816 getTotalWidth : function(includeHidden){
5817 if(!this.totalWidth){
5818 this.totalWidth = 0;
5819 for(var i = 0, len = this.config.length; i < len; i++){
5820 if(includeHidden || !this.isHidden(i)){
5821 this.totalWidth += this.getColumnWidth(i);
5825 return this.totalWidth;
5829 * Returns the header for the specified column.
5830 * @param {Number} col The column index
5833 getColumnHeader : function(col){
5834 return this.config[col].header;
5838 * Sets the header for a column.
5839 * @param {Number} col The column index
5840 * @param {String} header The new header
5842 setColumnHeader : function(col, header){
5843 this.config[col].header = header;
5844 this.fireEvent("headerchange", this, col, header);
5848 * Returns the tooltip for the specified column.
5849 * @param {Number} col The column index
5852 getColumnTooltip : function(col){
5853 return this.config[col].tooltip;
5856 * Sets the tooltip for a column.
5857 * @param {Number} col The column index
5858 * @param {String} tooltip The new tooltip
5860 setColumnTooltip : function(col, tooltip){
5861 this.config[col].tooltip = tooltip;
5865 * Returns the dataIndex for the specified column.
5866 * @param {Number} col The column index
5869 getDataIndex : function(col){
5870 return this.config[col].dataIndex;
5874 * Sets the dataIndex for a column.
5875 * @param {Number} col The column index
5876 * @param {Number} dataIndex The new dataIndex
5878 setDataIndex : function(col, dataIndex){
5879 this.config[col].dataIndex = dataIndex;
5885 * Returns true if the cell is editable.
5886 * @param {Number} colIndex The column index
5887 * @param {Number} rowIndex The row index - this is nto actually used..?
5890 isCellEditable : function(colIndex, rowIndex){
5891 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5895 * Returns the editor defined for the cell/column.
5896 * return false or null to disable editing.
5897 * @param {Number} colIndex The column index
5898 * @param {Number} rowIndex The row index
5901 getCellEditor : function(colIndex, rowIndex){
5902 return this.config[colIndex].editor;
5906 * Sets if a column is editable.
5907 * @param {Number} col The column index
5908 * @param {Boolean} editable True if the column is editable
5910 setEditable : function(col, editable){
5911 this.config[col].editable = editable;
5916 * Returns true if the column is hidden.
5917 * @param {Number} colIndex The column index
5920 isHidden : function(colIndex){
5921 return this.config[colIndex].hidden;
5926 * Returns true if the column width cannot be changed
5928 isFixed : function(colIndex){
5929 return this.config[colIndex].fixed;
5933 * Returns true if the column can be resized
5936 isResizable : function(colIndex){
5937 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5940 * Sets if a column is hidden.
5941 * @param {Number} colIndex The column index
5942 * @param {Boolean} hidden True if the column is hidden
5944 setHidden : function(colIndex, hidden){
5945 this.config[colIndex].hidden = hidden;
5946 this.totalWidth = null;
5947 this.fireEvent("hiddenchange", this, colIndex, hidden);
5951 * Sets the editor for a column.
5952 * @param {Number} col The column index
5953 * @param {Object} editor The editor object
5955 setEditor : function(col, editor){
5956 this.config[col].editor = editor;
5960 Roo.grid.ColumnModel.defaultRenderer = function(value)
5962 if(typeof value == "object") {
5965 if(typeof value == "string" && value.length < 1){
5969 return String.format("{0}", value);
5972 // Alias for backwards compatibility
5973 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5976 * Ext JS Library 1.1.1
5977 * Copyright(c) 2006-2007, Ext JS, LLC.
5979 * Originally Released Under LGPL - original licence link has changed is not relivant.
5982 * <script type="text/javascript">
5986 * @class Roo.LoadMask
5987 * A simple utility class for generically masking elements while loading data. If the element being masked has
5988 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5989 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5990 * element's UpdateManager load indicator and will be destroyed after the initial load.
5992 * Create a new LoadMask
5993 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5994 * @param {Object} config The config object
5996 Roo.LoadMask = function(el, config){
5997 this.el = Roo.get(el);
5998 Roo.apply(this, config);
6000 this.store.on('beforeload', this.onBeforeLoad, this);
6001 this.store.on('load', this.onLoad, this);
6002 this.store.on('loadexception', this.onLoadException, this);
6003 this.removeMask = false;
6005 var um = this.el.getUpdateManager();
6006 um.showLoadIndicator = false; // disable the default indicator
6007 um.on('beforeupdate', this.onBeforeLoad, this);
6008 um.on('update', this.onLoad, this);
6009 um.on('failure', this.onLoad, this);
6010 this.removeMask = true;
6014 Roo.LoadMask.prototype = {
6016 * @cfg {Boolean} removeMask
6017 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6018 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6022 * The text to display in a centered loading message box (defaults to 'Loading...')
6026 * @cfg {String} msgCls
6027 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6029 msgCls : 'x-mask-loading',
6032 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6038 * Disables the mask to prevent it from being displayed
6040 disable : function(){
6041 this.disabled = true;
6045 * Enables the mask so that it can be displayed
6047 enable : function(){
6048 this.disabled = false;
6051 onLoadException : function()
6055 if (typeof(arguments[3]) != 'undefined') {
6056 Roo.MessageBox.alert("Error loading",arguments[3]);
6060 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6061 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6068 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6073 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6077 onBeforeLoad : function(){
6079 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6084 destroy : function(){
6086 this.store.un('beforeload', this.onBeforeLoad, this);
6087 this.store.un('load', this.onLoad, this);
6088 this.store.un('loadexception', this.onLoadException, this);
6090 var um = this.el.getUpdateManager();
6091 um.un('beforeupdate', this.onBeforeLoad, this);
6092 um.un('update', this.onLoad, this);
6093 um.un('failure', this.onLoad, this);
6104 * @class Roo.bootstrap.Table
6105 * @extends Roo.bootstrap.Component
6106 * Bootstrap Table class
6107 * @cfg {String} cls table class
6108 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6109 * @cfg {String} bgcolor Specifies the background color for a table
6110 * @cfg {Number} border Specifies whether the table cells should have borders or not
6111 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6112 * @cfg {Number} cellspacing Specifies the space between cells
6113 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6114 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6115 * @cfg {String} sortable Specifies that the table should be sortable
6116 * @cfg {String} summary Specifies a summary of the content of a table
6117 * @cfg {Number} width Specifies the width of a table
6118 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6120 * @cfg {boolean} striped Should the rows be alternative striped
6121 * @cfg {boolean} bordered Add borders to the table
6122 * @cfg {boolean} hover Add hover highlighting
6123 * @cfg {boolean} condensed Format condensed
6124 * @cfg {boolean} responsive Format condensed
6125 * @cfg {Boolean} loadMask (true|false) default false
6126 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6127 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6128 * @cfg {Boolean} rowSelection (true|false) default false
6129 * @cfg {Boolean} cellSelection (true|false) default false
6130 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6131 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6132 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6133 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6137 * Create a new Table
6138 * @param {Object} config The config object
6141 Roo.bootstrap.Table = function(config){
6142 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6147 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6148 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6149 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6150 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6152 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6154 this.sm.grid = this;
6155 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6156 this.sm = this.selModel;
6157 this.sm.xmodule = this.xmodule || false;
6160 if (this.cm && typeof(this.cm.config) == 'undefined') {
6161 this.colModel = new Roo.grid.ColumnModel(this.cm);
6162 this.cm = this.colModel;
6163 this.cm.xmodule = this.xmodule || false;
6166 this.store= Roo.factory(this.store, Roo.data);
6167 this.ds = this.store;
6168 this.ds.xmodule = this.xmodule || false;
6171 if (this.footer && this.store) {
6172 this.footer.dataSource = this.ds;
6173 this.footer = Roo.factory(this.footer);
6180 * Fires when a cell is clicked
6181 * @param {Roo.bootstrap.Table} this
6182 * @param {Roo.Element} el
6183 * @param {Number} rowIndex
6184 * @param {Number} columnIndex
6185 * @param {Roo.EventObject} e
6189 * @event celldblclick
6190 * Fires when a cell is double clicked
6191 * @param {Roo.bootstrap.Table} this
6192 * @param {Roo.Element} el
6193 * @param {Number} rowIndex
6194 * @param {Number} columnIndex
6195 * @param {Roo.EventObject} e
6197 "celldblclick" : true,
6200 * Fires when a row is clicked
6201 * @param {Roo.bootstrap.Table} this
6202 * @param {Roo.Element} el
6203 * @param {Number} rowIndex
6204 * @param {Roo.EventObject} e
6208 * @event rowdblclick
6209 * Fires when a row is double clicked
6210 * @param {Roo.bootstrap.Table} this
6211 * @param {Roo.Element} el
6212 * @param {Number} rowIndex
6213 * @param {Roo.EventObject} e
6215 "rowdblclick" : true,
6218 * Fires when a mouseover occur
6219 * @param {Roo.bootstrap.Table} this
6220 * @param {Roo.Element} el
6221 * @param {Number} rowIndex
6222 * @param {Number} columnIndex
6223 * @param {Roo.EventObject} e
6228 * Fires when a mouseout occur
6229 * @param {Roo.bootstrap.Table} this
6230 * @param {Roo.Element} el
6231 * @param {Number} rowIndex
6232 * @param {Number} columnIndex
6233 * @param {Roo.EventObject} e
6238 * Fires when a row is rendered, so you can change add a style to it.
6239 * @param {Roo.bootstrap.Table} this
6240 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6244 * @event rowsrendered
6245 * Fires when all the rows have been rendered
6246 * @param {Roo.bootstrap.Table} this
6248 'rowsrendered' : true,
6250 * @event contextmenu
6251 * The raw contextmenu event for the entire grid.
6252 * @param {Roo.EventObject} e
6254 "contextmenu" : true,
6256 * @event rowcontextmenu
6257 * Fires when a row is right clicked
6258 * @param {Roo.bootstrap.Table} this
6259 * @param {Number} rowIndex
6260 * @param {Roo.EventObject} e
6262 "rowcontextmenu" : true,
6264 * @event cellcontextmenu
6265 * Fires when a cell is right clicked
6266 * @param {Roo.bootstrap.Table} this
6267 * @param {Number} rowIndex
6268 * @param {Number} cellIndex
6269 * @param {Roo.EventObject} e
6271 "cellcontextmenu" : true,
6273 * @event headercontextmenu
6274 * Fires when a header is right clicked
6275 * @param {Roo.bootstrap.Table} this
6276 * @param {Number} columnIndex
6277 * @param {Roo.EventObject} e
6279 "headercontextmenu" : true
6283 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6309 rowSelection : false,
6310 cellSelection : false,
6313 // Roo.Element - the tbody
6315 // Roo.Element - thead element
6318 container: false, // used by gridpanel...
6324 auto_hide_footer : false,
6326 getAutoCreate : function()
6328 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6335 if (this.scrollBody) {
6336 cfg.cls += ' table-body-fixed';
6339 cfg.cls += ' table-striped';
6343 cfg.cls += ' table-hover';
6345 if (this.bordered) {
6346 cfg.cls += ' table-bordered';
6348 if (this.condensed) {
6349 cfg.cls += ' table-condensed';
6351 if (this.responsive) {
6352 cfg.cls += ' table-responsive';
6356 cfg.cls+= ' ' +this.cls;
6359 // this lot should be simplifed...
6372 ].forEach(function(k) {
6380 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6383 if(this.store || this.cm){
6384 if(this.headerShow){
6385 cfg.cn.push(this.renderHeader());
6388 cfg.cn.push(this.renderBody());
6390 if(this.footerShow){
6391 cfg.cn.push(this.renderFooter());
6393 // where does this come from?
6394 //cfg.cls+= ' TableGrid';
6397 return { cn : [ cfg ] };
6400 initEvents : function()
6402 if(!this.store || !this.cm){
6405 if (this.selModel) {
6406 this.selModel.initEvents();
6410 //Roo.log('initEvents with ds!!!!');
6412 this.mainBody = this.el.select('tbody', true).first();
6413 this.mainHead = this.el.select('thead', true).first();
6414 this.mainFoot = this.el.select('tfoot', true).first();
6420 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6421 e.on('click', _this.sort, _this);
6424 this.mainBody.on("click", this.onClick, this);
6425 this.mainBody.on("dblclick", this.onDblClick, this);
6427 // why is this done????? = it breaks dialogs??
6428 //this.parent().el.setStyle('position', 'relative');
6432 this.footer.parentId = this.id;
6433 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6436 this.el.select('tfoot tr td').first().addClass('hide');
6441 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6444 this.store.on('load', this.onLoad, this);
6445 this.store.on('beforeload', this.onBeforeLoad, this);
6446 this.store.on('update', this.onUpdate, this);
6447 this.store.on('add', this.onAdd, this);
6448 this.store.on("clear", this.clear, this);
6450 this.el.on("contextmenu", this.onContextMenu, this);
6452 this.mainBody.on('scroll', this.onBodyScroll, this);
6454 this.cm.on("headerchange", this.onHeaderChange, this);
6456 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6460 onContextMenu : function(e, t)
6462 this.processEvent("contextmenu", e);
6465 processEvent : function(name, e)
6467 if (name != 'touchstart' ) {
6468 this.fireEvent(name, e);
6471 var t = e.getTarget();
6473 var cell = Roo.get(t);
6479 if(cell.findParent('tfoot', false, true)){
6483 if(cell.findParent('thead', false, true)){
6485 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6486 cell = Roo.get(t).findParent('th', false, true);
6488 Roo.log("failed to find th in thead?");
6489 Roo.log(e.getTarget());
6494 var cellIndex = cell.dom.cellIndex;
6496 var ename = name == 'touchstart' ? 'click' : name;
6497 this.fireEvent("header" + ename, this, cellIndex, e);
6502 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6503 cell = Roo.get(t).findParent('td', false, true);
6505 Roo.log("failed to find th in tbody?");
6506 Roo.log(e.getTarget());
6511 var row = cell.findParent('tr', false, true);
6512 var cellIndex = cell.dom.cellIndex;
6513 var rowIndex = row.dom.rowIndex - 1;
6517 this.fireEvent("row" + name, this, rowIndex, e);
6521 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6527 onMouseover : function(e, el)
6529 var cell = Roo.get(el);
6535 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6536 cell = cell.findParent('td', false, true);
6539 var row = cell.findParent('tr', false, true);
6540 var cellIndex = cell.dom.cellIndex;
6541 var rowIndex = row.dom.rowIndex - 1; // start from 0
6543 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6547 onMouseout : function(e, el)
6549 var cell = Roo.get(el);
6555 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6556 cell = cell.findParent('td', false, true);
6559 var row = cell.findParent('tr', false, true);
6560 var cellIndex = cell.dom.cellIndex;
6561 var rowIndex = row.dom.rowIndex - 1; // start from 0
6563 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6567 onClick : function(e, el)
6569 var cell = Roo.get(el);
6571 if(!cell || (!this.cellSelection && !this.rowSelection)){
6575 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6576 cell = cell.findParent('td', false, true);
6579 if(!cell || typeof(cell) == 'undefined'){
6583 var row = cell.findParent('tr', false, true);
6585 if(!row || typeof(row) == 'undefined'){
6589 var cellIndex = cell.dom.cellIndex;
6590 var rowIndex = this.getRowIndex(row);
6592 // why??? - should these not be based on SelectionModel?
6593 if(this.cellSelection){
6594 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6597 if(this.rowSelection){
6598 this.fireEvent('rowclick', this, row, rowIndex, e);
6604 onDblClick : function(e,el)
6606 var cell = Roo.get(el);
6608 if(!cell || (!this.cellSelection && !this.rowSelection)){
6612 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6613 cell = cell.findParent('td', false, true);
6616 if(!cell || typeof(cell) == 'undefined'){
6620 var row = cell.findParent('tr', false, true);
6622 if(!row || typeof(row) == 'undefined'){
6626 var cellIndex = cell.dom.cellIndex;
6627 var rowIndex = this.getRowIndex(row);
6629 if(this.cellSelection){
6630 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6633 if(this.rowSelection){
6634 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6638 sort : function(e,el)
6640 var col = Roo.get(el);
6642 if(!col.hasClass('sortable')){
6646 var sort = col.attr('sort');
6649 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6653 this.store.sortInfo = {field : sort, direction : dir};
6656 Roo.log("calling footer first");
6657 this.footer.onClick('first');
6660 this.store.load({ params : { start : 0 } });
6664 renderHeader : function()
6672 this.totalWidth = 0;
6674 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6676 var config = cm.config[i];
6680 cls : 'x-hcol-' + i,
6682 html: cm.getColumnHeader(i)
6687 if(typeof(config.sortable) != 'undefined' && config.sortable){
6689 c.html = '<i class="glyphicon"></i>' + c.html;
6692 if(typeof(config.lgHeader) != 'undefined'){
6693 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6696 if(typeof(config.mdHeader) != 'undefined'){
6697 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6700 if(typeof(config.smHeader) != 'undefined'){
6701 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6704 if(typeof(config.xsHeader) != 'undefined'){
6705 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6712 if(typeof(config.tooltip) != 'undefined'){
6713 c.tooltip = config.tooltip;
6716 if(typeof(config.colspan) != 'undefined'){
6717 c.colspan = config.colspan;
6720 if(typeof(config.hidden) != 'undefined' && config.hidden){
6721 c.style += ' display:none;';
6724 if(typeof(config.dataIndex) != 'undefined'){
6725 c.sort = config.dataIndex;
6730 if(typeof(config.align) != 'undefined' && config.align.length){
6731 c.style += ' text-align:' + config.align + ';';
6734 if(typeof(config.width) != 'undefined'){
6735 c.style += ' width:' + config.width + 'px;';
6736 this.totalWidth += config.width;
6738 this.totalWidth += 100; // assume minimum of 100 per column?
6741 if(typeof(config.cls) != 'undefined'){
6742 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6745 ['xs','sm','md','lg'].map(function(size){
6747 if(typeof(config[size]) == 'undefined'){
6751 if (!config[size]) { // 0 = hidden
6752 c.cls += ' hidden-' + size;
6756 c.cls += ' col-' + size + '-' + config[size];
6766 renderBody : function()
6776 colspan : this.cm.getColumnCount()
6786 renderFooter : function()
6796 colspan : this.cm.getColumnCount()
6810 // Roo.log('ds onload');
6815 var ds = this.store;
6817 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6818 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6819 if (_this.store.sortInfo) {
6821 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6822 e.select('i', true).addClass(['glyphicon-arrow-up']);
6825 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6826 e.select('i', true).addClass(['glyphicon-arrow-down']);
6831 var tbody = this.mainBody;
6833 if(ds.getCount() > 0){
6834 ds.data.each(function(d,rowIndex){
6835 var row = this.renderRow(cm, ds, rowIndex);
6837 tbody.createChild(row);
6841 if(row.cellObjects.length){
6842 Roo.each(row.cellObjects, function(r){
6843 _this.renderCellObject(r);
6850 var tfoot = this.el.select('tfoot', true).first();
6852 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6854 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6856 var total = this.ds.getTotalCount();
6858 if(this.footer.pageSize < total){
6859 this.mainFoot.show();
6863 Roo.each(this.el.select('tbody td', true).elements, function(e){
6864 e.on('mouseover', _this.onMouseover, _this);
6867 Roo.each(this.el.select('tbody td', true).elements, function(e){
6868 e.on('mouseout', _this.onMouseout, _this);
6870 this.fireEvent('rowsrendered', this);
6876 onUpdate : function(ds,record)
6878 this.refreshRow(record);
6882 onRemove : function(ds, record, index, isUpdate){
6883 if(isUpdate !== true){
6884 this.fireEvent("beforerowremoved", this, index, record);
6886 var bt = this.mainBody.dom;
6888 var rows = this.el.select('tbody > tr', true).elements;
6890 if(typeof(rows[index]) != 'undefined'){
6891 bt.removeChild(rows[index].dom);
6894 // if(bt.rows[index]){
6895 // bt.removeChild(bt.rows[index]);
6898 if(isUpdate !== true){
6899 //this.stripeRows(index);
6900 //this.syncRowHeights(index, index);
6902 this.fireEvent("rowremoved", this, index, record);
6906 onAdd : function(ds, records, rowIndex)
6908 //Roo.log('on Add called');
6909 // - note this does not handle multiple adding very well..
6910 var bt = this.mainBody.dom;
6911 for (var i =0 ; i < records.length;i++) {
6912 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6913 //Roo.log(records[i]);
6914 //Roo.log(this.store.getAt(rowIndex+i));
6915 this.insertRow(this.store, rowIndex + i, false);
6922 refreshRow : function(record){
6923 var ds = this.store, index;
6924 if(typeof record == 'number'){
6926 record = ds.getAt(index);
6928 index = ds.indexOf(record);
6930 this.insertRow(ds, index, true);
6932 this.onRemove(ds, record, index+1, true);
6934 //this.syncRowHeights(index, index);
6936 this.fireEvent("rowupdated", this, index, record);
6939 insertRow : function(dm, rowIndex, isUpdate){
6942 this.fireEvent("beforerowsinserted", this, rowIndex);
6944 //var s = this.getScrollState();
6945 var row = this.renderRow(this.cm, this.store, rowIndex);
6946 // insert before rowIndex..
6947 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6951 if(row.cellObjects.length){
6952 Roo.each(row.cellObjects, function(r){
6953 _this.renderCellObject(r);
6958 this.fireEvent("rowsinserted", this, rowIndex);
6959 //this.syncRowHeights(firstRow, lastRow);
6960 //this.stripeRows(firstRow);
6967 getRowDom : function(rowIndex)
6969 var rows = this.el.select('tbody > tr', true).elements;
6971 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6974 // returns the object tree for a tr..
6977 renderRow : function(cm, ds, rowIndex)
6979 var d = ds.getAt(rowIndex);
6983 cls : 'x-row-' + rowIndex,
6987 var cellObjects = [];
6989 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6990 var config = cm.config[i];
6992 var renderer = cm.getRenderer(i);
6996 if(typeof(renderer) !== 'undefined'){
6997 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6999 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7000 // and are rendered into the cells after the row is rendered - using the id for the element.
7002 if(typeof(value) === 'object'){
7012 rowIndex : rowIndex,
7017 this.fireEvent('rowclass', this, rowcfg);
7021 cls : rowcfg.rowClass + ' x-col-' + i,
7023 html: (typeof(value) === 'object') ? '' : value
7030 if(typeof(config.colspan) != 'undefined'){
7031 td.colspan = config.colspan;
7034 if(typeof(config.hidden) != 'undefined' && config.hidden){
7035 td.style += ' display:none;';
7038 if(typeof(config.align) != 'undefined' && config.align.length){
7039 td.style += ' text-align:' + config.align + ';';
7041 if(typeof(config.valign) != 'undefined' && config.valign.length){
7042 td.style += ' vertical-align:' + config.valign + ';';
7045 if(typeof(config.width) != 'undefined'){
7046 td.style += ' width:' + config.width + 'px;';
7049 if(typeof(config.cursor) != 'undefined'){
7050 td.style += ' cursor:' + config.cursor + ';';
7053 if(typeof(config.cls) != 'undefined'){
7054 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7057 ['xs','sm','md','lg'].map(function(size){
7059 if(typeof(config[size]) == 'undefined'){
7063 if (!config[size]) { // 0 = hidden
7064 td.cls += ' hidden-' + size;
7068 td.cls += ' col-' + size + '-' + config[size];
7076 row.cellObjects = cellObjects;
7084 onBeforeLoad : function()
7093 this.el.select('tbody', true).first().dom.innerHTML = '';
7096 * Show or hide a row.
7097 * @param {Number} rowIndex to show or hide
7098 * @param {Boolean} state hide
7100 setRowVisibility : function(rowIndex, state)
7102 var bt = this.mainBody.dom;
7104 var rows = this.el.select('tbody > tr', true).elements;
7106 if(typeof(rows[rowIndex]) == 'undefined'){
7109 rows[rowIndex].dom.style.display = state ? '' : 'none';
7113 getSelectionModel : function(){
7115 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7117 return this.selModel;
7120 * Render the Roo.bootstrap object from renderder
7122 renderCellObject : function(r)
7126 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7128 var t = r.cfg.render(r.container);
7131 Roo.each(r.cfg.cn, function(c){
7133 container: t.getChildContainer(),
7136 _this.renderCellObject(child);
7141 getRowIndex : function(row)
7145 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7156 * Returns the grid's underlying element = used by panel.Grid
7157 * @return {Element} The element
7159 getGridEl : function(){
7163 * Forces a resize - used by panel.Grid
7164 * @return {Element} The element
7166 autoSize : function()
7168 //var ctr = Roo.get(this.container.dom.parentElement);
7169 var ctr = Roo.get(this.el.dom);
7171 var thd = this.getGridEl().select('thead',true).first();
7172 var tbd = this.getGridEl().select('tbody', true).first();
7173 var tfd = this.getGridEl().select('tfoot', true).first();
7175 var cw = ctr.getWidth();
7179 tbd.setSize(ctr.getWidth(),
7180 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7182 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7185 cw = Math.max(cw, this.totalWidth);
7186 this.getGridEl().select('tr',true).setWidth(cw);
7187 // resize 'expandable coloumn?
7189 return; // we doe not have a view in this design..
7192 onBodyScroll: function()
7194 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7196 this.mainHead.setStyle({
7197 'position' : 'relative',
7198 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7204 var scrollHeight = this.mainBody.dom.scrollHeight;
7206 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7208 var height = this.mainBody.getHeight();
7210 if(scrollHeight - height == scrollTop) {
7212 var total = this.ds.getTotalCount();
7214 if(this.footer.cursor + this.footer.pageSize < total){
7216 this.footer.ds.load({
7218 start : this.footer.cursor + this.footer.pageSize,
7219 limit : this.footer.pageSize
7229 onHeaderChange : function()
7231 var header = this.renderHeader();
7232 var table = this.el.select('table', true).first();
7234 this.mainHead.remove();
7235 this.mainHead = table.createChild(header, this.mainBody, false);
7238 onHiddenChange : function(colModel, colIndex, hidden)
7240 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7241 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7243 this.CSS.updateRule(thSelector, "display", "");
7244 this.CSS.updateRule(tdSelector, "display", "");
7247 this.CSS.updateRule(thSelector, "display", "none");
7248 this.CSS.updateRule(tdSelector, "display", "none");
7251 this.onHeaderChange();
7255 setColumnWidth: function(col_index, width)
7257 // width = "md-2 xs-2..."
7258 if(!this.colModel.config[col_index]) {
7262 var w = width.split(" ");
7264 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7266 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7269 for(var j = 0; j < w.length; j++) {
7275 var size_cls = w[j].split("-");
7277 if(!Number.isInteger(size_cls[1] * 1)) {
7281 if(!this.colModel.config[col_index][size_cls[0]]) {
7285 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7289 h_row[0].classList.replace(
7290 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7291 "col-"+size_cls[0]+"-"+size_cls[1]
7294 for(var i = 0; i < rows.length; i++) {
7296 var size_cls = w[j].split("-");
7298 if(!Number.isInteger(size_cls[1] * 1)) {
7302 if(!this.colModel.config[col_index][size_cls[0]]) {
7306 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7310 rows[i].classList.replace(
7311 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7312 "col-"+size_cls[0]+"-"+size_cls[1]
7316 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7331 * @class Roo.bootstrap.TableCell
7332 * @extends Roo.bootstrap.Component
7333 * Bootstrap TableCell class
7334 * @cfg {String} html cell contain text
7335 * @cfg {String} cls cell class
7336 * @cfg {String} tag cell tag (td|th) default td
7337 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7338 * @cfg {String} align Aligns the content in a cell
7339 * @cfg {String} axis Categorizes cells
7340 * @cfg {String} bgcolor Specifies the background color of a cell
7341 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7342 * @cfg {Number} colspan Specifies the number of columns a cell should span
7343 * @cfg {String} headers Specifies one or more header cells a cell is related to
7344 * @cfg {Number} height Sets the height of a cell
7345 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7346 * @cfg {Number} rowspan Sets the number of rows a cell should span
7347 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7348 * @cfg {String} valign Vertical aligns the content in a cell
7349 * @cfg {Number} width Specifies the width of a cell
7352 * Create a new TableCell
7353 * @param {Object} config The config object
7356 Roo.bootstrap.TableCell = function(config){
7357 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7360 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7380 getAutoCreate : function(){
7381 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7401 cfg.align=this.align
7407 cfg.bgcolor=this.bgcolor
7410 cfg.charoff=this.charoff
7413 cfg.colspan=this.colspan
7416 cfg.headers=this.headers
7419 cfg.height=this.height
7422 cfg.nowrap=this.nowrap
7425 cfg.rowspan=this.rowspan
7428 cfg.scope=this.scope
7431 cfg.valign=this.valign
7434 cfg.width=this.width
7453 * @class Roo.bootstrap.TableRow
7454 * @extends Roo.bootstrap.Component
7455 * Bootstrap TableRow class
7456 * @cfg {String} cls row class
7457 * @cfg {String} align Aligns the content in a table row
7458 * @cfg {String} bgcolor Specifies a background color for a table row
7459 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7460 * @cfg {String} valign Vertical aligns the content in a table row
7463 * Create a new TableRow
7464 * @param {Object} config The config object
7467 Roo.bootstrap.TableRow = function(config){
7468 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7471 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7479 getAutoCreate : function(){
7480 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7490 cfg.align = this.align;
7493 cfg.bgcolor = this.bgcolor;
7496 cfg.charoff = this.charoff;
7499 cfg.valign = this.valign;
7517 * @class Roo.bootstrap.TableBody
7518 * @extends Roo.bootstrap.Component
7519 * Bootstrap TableBody class
7520 * @cfg {String} cls element class
7521 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7522 * @cfg {String} align Aligns the content inside the element
7523 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7524 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7527 * Create a new TableBody
7528 * @param {Object} config The config object
7531 Roo.bootstrap.TableBody = function(config){
7532 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7535 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7543 getAutoCreate : function(){
7544 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7558 cfg.align = this.align;
7561 cfg.charoff = this.charoff;
7564 cfg.valign = this.valign;
7571 // initEvents : function()
7578 // this.store = Roo.factory(this.store, Roo.data);
7579 // this.store.on('load', this.onLoad, this);
7581 // this.store.load();
7585 // onLoad: function ()
7587 // this.fireEvent('load', this);
7597 * Ext JS Library 1.1.1
7598 * Copyright(c) 2006-2007, Ext JS, LLC.
7600 * Originally Released Under LGPL - original licence link has changed is not relivant.
7603 * <script type="text/javascript">
7606 // as we use this in bootstrap.
7607 Roo.namespace('Roo.form');
7609 * @class Roo.form.Action
7610 * Internal Class used to handle form actions
7612 * @param {Roo.form.BasicForm} el The form element or its id
7613 * @param {Object} config Configuration options
7618 // define the action interface
7619 Roo.form.Action = function(form, options){
7621 this.options = options || {};
7624 * Client Validation Failed
7627 Roo.form.Action.CLIENT_INVALID = 'client';
7629 * Server Validation Failed
7632 Roo.form.Action.SERVER_INVALID = 'server';
7634 * Connect to Server Failed
7637 Roo.form.Action.CONNECT_FAILURE = 'connect';
7639 * Reading Data from Server Failed
7642 Roo.form.Action.LOAD_FAILURE = 'load';
7644 Roo.form.Action.prototype = {
7646 failureType : undefined,
7647 response : undefined,
7651 run : function(options){
7656 success : function(response){
7661 handleResponse : function(response){
7665 // default connection failure
7666 failure : function(response){
7668 this.response = response;
7669 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7670 this.form.afterAction(this, false);
7673 processResponse : function(response){
7674 this.response = response;
7675 if(!response.responseText){
7678 this.result = this.handleResponse(response);
7682 // utility functions used internally
7683 getUrl : function(appendParams){
7684 var url = this.options.url || this.form.url || this.form.el.dom.action;
7686 var p = this.getParams();
7688 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7694 getMethod : function(){
7695 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7698 getParams : function(){
7699 var bp = this.form.baseParams;
7700 var p = this.options.params;
7702 if(typeof p == "object"){
7703 p = Roo.urlEncode(Roo.applyIf(p, bp));
7704 }else if(typeof p == 'string' && bp){
7705 p += '&' + Roo.urlEncode(bp);
7708 p = Roo.urlEncode(bp);
7713 createCallback : function(){
7715 success: this.success,
7716 failure: this.failure,
7718 timeout: (this.form.timeout*1000),
7719 upload: this.form.fileUpload ? this.success : undefined
7724 Roo.form.Action.Submit = function(form, options){
7725 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7728 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7731 haveProgress : false,
7732 uploadComplete : false,
7734 // uploadProgress indicator.
7735 uploadProgress : function()
7737 if (!this.form.progressUrl) {
7741 if (!this.haveProgress) {
7742 Roo.MessageBox.progress("Uploading", "Uploading");
7744 if (this.uploadComplete) {
7745 Roo.MessageBox.hide();
7749 this.haveProgress = true;
7751 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7753 var c = new Roo.data.Connection();
7755 url : this.form.progressUrl,
7760 success : function(req){
7761 //console.log(data);
7765 rdata = Roo.decode(req.responseText)
7767 Roo.log("Invalid data from server..");
7771 if (!rdata || !rdata.success) {
7773 Roo.MessageBox.alert(Roo.encode(rdata));
7776 var data = rdata.data;
7778 if (this.uploadComplete) {
7779 Roo.MessageBox.hide();
7784 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7785 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7788 this.uploadProgress.defer(2000,this);
7791 failure: function(data) {
7792 Roo.log('progress url failed ');
7803 // run get Values on the form, so it syncs any secondary forms.
7804 this.form.getValues();
7806 var o = this.options;
7807 var method = this.getMethod();
7808 var isPost = method == 'POST';
7809 if(o.clientValidation === false || this.form.isValid()){
7811 if (this.form.progressUrl) {
7812 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7813 (new Date() * 1) + '' + Math.random());
7818 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7819 form:this.form.el.dom,
7820 url:this.getUrl(!isPost),
7822 params:isPost ? this.getParams() : null,
7823 isUpload: this.form.fileUpload
7826 this.uploadProgress();
7828 }else if (o.clientValidation !== false){ // client validation failed
7829 this.failureType = Roo.form.Action.CLIENT_INVALID;
7830 this.form.afterAction(this, false);
7834 success : function(response)
7836 this.uploadComplete= true;
7837 if (this.haveProgress) {
7838 Roo.MessageBox.hide();
7842 var result = this.processResponse(response);
7843 if(result === true || result.success){
7844 this.form.afterAction(this, true);
7848 this.form.markInvalid(result.errors);
7849 this.failureType = Roo.form.Action.SERVER_INVALID;
7851 this.form.afterAction(this, false);
7853 failure : function(response)
7855 this.uploadComplete= true;
7856 if (this.haveProgress) {
7857 Roo.MessageBox.hide();
7860 this.response = response;
7861 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7862 this.form.afterAction(this, false);
7865 handleResponse : function(response){
7866 if(this.form.errorReader){
7867 var rs = this.form.errorReader.read(response);
7870 for(var i = 0, len = rs.records.length; i < len; i++) {
7871 var r = rs.records[i];
7875 if(errors.length < 1){
7879 success : rs.success,
7885 ret = Roo.decode(response.responseText);
7889 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7899 Roo.form.Action.Load = function(form, options){
7900 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7901 this.reader = this.form.reader;
7904 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7909 Roo.Ajax.request(Roo.apply(
7910 this.createCallback(), {
7911 method:this.getMethod(),
7912 url:this.getUrl(false),
7913 params:this.getParams()
7917 success : function(response){
7919 var result = this.processResponse(response);
7920 if(result === true || !result.success || !result.data){
7921 this.failureType = Roo.form.Action.LOAD_FAILURE;
7922 this.form.afterAction(this, false);
7925 this.form.clearInvalid();
7926 this.form.setValues(result.data);
7927 this.form.afterAction(this, true);
7930 handleResponse : function(response){
7931 if(this.form.reader){
7932 var rs = this.form.reader.read(response);
7933 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7935 success : rs.success,
7939 return Roo.decode(response.responseText);
7943 Roo.form.Action.ACTION_TYPES = {
7944 'load' : Roo.form.Action.Load,
7945 'submit' : Roo.form.Action.Submit
7954 * @class Roo.bootstrap.Form
7955 * @extends Roo.bootstrap.Component
7956 * Bootstrap Form class
7957 * @cfg {String} method GET | POST (default POST)
7958 * @cfg {String} labelAlign top | left (default top)
7959 * @cfg {String} align left | right - for navbars
7960 * @cfg {Boolean} loadMask load mask when submit (default true)
7965 * @param {Object} config The config object
7969 Roo.bootstrap.Form = function(config){
7971 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7973 Roo.bootstrap.Form.popover.apply();
7977 * @event clientvalidation
7978 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7979 * @param {Form} this
7980 * @param {Boolean} valid true if the form has passed client-side validation
7982 clientvalidation: true,
7984 * @event beforeaction
7985 * Fires before any action is performed. Return false to cancel the action.
7986 * @param {Form} this
7987 * @param {Action} action The action to be performed
7991 * @event actionfailed
7992 * Fires when an action fails.
7993 * @param {Form} this
7994 * @param {Action} action The action that failed
7996 actionfailed : true,
7998 * @event actioncomplete
7999 * Fires when an action is completed.
8000 * @param {Form} this
8001 * @param {Action} action The action that completed
8003 actioncomplete : true
8007 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8010 * @cfg {String} method
8011 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8016 * The URL to use for form actions if one isn't supplied in the action options.
8019 * @cfg {Boolean} fileUpload
8020 * Set to true if this form is a file upload.
8024 * @cfg {Object} baseParams
8025 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8029 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8033 * @cfg {Sting} align (left|right) for navbar forms
8038 activeAction : null,
8041 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8042 * element by passing it or its id or mask the form itself by passing in true.
8045 waitMsgTarget : false,
8050 * @cfg {Boolean} errorMask (true|false) default false
8055 * @cfg {Number} maskOffset Default 100
8060 * @cfg {Boolean} maskBody
8064 getAutoCreate : function(){
8068 method : this.method || 'POST',
8069 id : this.id || Roo.id(),
8072 if (this.parent().xtype.match(/^Nav/)) {
8073 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8077 if (this.labelAlign == 'left' ) {
8078 cfg.cls += ' form-horizontal';
8084 initEvents : function()
8086 this.el.on('submit', this.onSubmit, this);
8087 // this was added as random key presses on the form where triggering form submit.
8088 this.el.on('keypress', function(e) {
8089 if (e.getCharCode() != 13) {
8092 // we might need to allow it for textareas.. and some other items.
8093 // check e.getTarget().
8095 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8099 Roo.log("keypress blocked");
8107 onSubmit : function(e){
8112 * Returns true if client-side validation on the form is successful.
8115 isValid : function(){
8116 var items = this.getItems();
8120 items.each(function(f){
8126 Roo.log('invalid field: ' + f.name);
8130 if(!target && f.el.isVisible(true)){
8136 if(this.errorMask && !valid){
8137 Roo.bootstrap.Form.popover.mask(this, target);
8144 * Returns true if any fields in this form have changed since their original load.
8147 isDirty : function(){
8149 var items = this.getItems();
8150 items.each(function(f){
8160 * Performs a predefined action (submit or load) or custom actions you define on this form.
8161 * @param {String} actionName The name of the action type
8162 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8163 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8164 * accept other config options):
8166 Property Type Description
8167 ---------------- --------------- ----------------------------------------------------------------------------------
8168 url String The url for the action (defaults to the form's url)
8169 method String The form method to use (defaults to the form's method, or POST if not defined)
8170 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8171 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8172 validate the form on the client (defaults to false)
8174 * @return {BasicForm} this
8176 doAction : function(action, options){
8177 if(typeof action == 'string'){
8178 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8180 if(this.fireEvent('beforeaction', this, action) !== false){
8181 this.beforeAction(action);
8182 action.run.defer(100, action);
8188 beforeAction : function(action){
8189 var o = action.options;
8194 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8196 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8199 // not really supported yet.. ??
8201 //if(this.waitMsgTarget === true){
8202 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8203 //}else if(this.waitMsgTarget){
8204 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8205 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8207 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8213 afterAction : function(action, success){
8214 this.activeAction = null;
8215 var o = action.options;
8220 Roo.get(document.body).unmask();
8226 //if(this.waitMsgTarget === true){
8227 // this.el.unmask();
8228 //}else if(this.waitMsgTarget){
8229 // this.waitMsgTarget.unmask();
8231 // Roo.MessageBox.updateProgress(1);
8232 // Roo.MessageBox.hide();
8239 Roo.callback(o.success, o.scope, [this, action]);
8240 this.fireEvent('actioncomplete', this, action);
8244 // failure condition..
8245 // we have a scenario where updates need confirming.
8246 // eg. if a locking scenario exists..
8247 // we look for { errors : { needs_confirm : true }} in the response.
8249 (typeof(action.result) != 'undefined') &&
8250 (typeof(action.result.errors) != 'undefined') &&
8251 (typeof(action.result.errors.needs_confirm) != 'undefined')
8254 Roo.log("not supported yet");
8257 Roo.MessageBox.confirm(
8258 "Change requires confirmation",
8259 action.result.errorMsg,
8264 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8274 Roo.callback(o.failure, o.scope, [this, action]);
8275 // show an error message if no failed handler is set..
8276 if (!this.hasListener('actionfailed')) {
8277 Roo.log("need to add dialog support");
8279 Roo.MessageBox.alert("Error",
8280 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8281 action.result.errorMsg :
8282 "Saving Failed, please check your entries or try again"
8287 this.fireEvent('actionfailed', this, action);
8292 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8293 * @param {String} id The value to search for
8296 findField : function(id){
8297 var items = this.getItems();
8298 var field = items.get(id);
8300 items.each(function(f){
8301 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8308 return field || null;
8311 * Mark fields in this form invalid in bulk.
8312 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8313 * @return {BasicForm} this
8315 markInvalid : function(errors){
8316 if(errors instanceof Array){
8317 for(var i = 0, len = errors.length; i < len; i++){
8318 var fieldError = errors[i];
8319 var f = this.findField(fieldError.id);
8321 f.markInvalid(fieldError.msg);
8327 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8328 field.markInvalid(errors[id]);
8332 //Roo.each(this.childForms || [], function (f) {
8333 // f.markInvalid(errors);
8340 * Set values for fields in this form in bulk.
8341 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8342 * @return {BasicForm} this
8344 setValues : function(values){
8345 if(values instanceof Array){ // array of objects
8346 for(var i = 0, len = values.length; i < len; i++){
8348 var f = this.findField(v.id);
8350 f.setValue(v.value);
8351 if(this.trackResetOnLoad){
8352 f.originalValue = f.getValue();
8356 }else{ // object hash
8359 if(typeof values[id] != 'function' && (field = this.findField(id))){
8361 if (field.setFromData &&
8363 field.displayField &&
8364 // combos' with local stores can
8365 // be queried via setValue()
8366 // to set their value..
8367 (field.store && !field.store.isLocal)
8371 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8372 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8373 field.setFromData(sd);
8375 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8377 field.setFromData(values);
8380 field.setValue(values[id]);
8384 if(this.trackResetOnLoad){
8385 field.originalValue = field.getValue();
8391 //Roo.each(this.childForms || [], function (f) {
8392 // f.setValues(values);
8399 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8400 * they are returned as an array.
8401 * @param {Boolean} asString
8404 getValues : function(asString){
8405 //if (this.childForms) {
8406 // copy values from the child forms
8407 // Roo.each(this.childForms, function (f) {
8408 // this.setValues(f.getValues());
8414 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8415 if(asString === true){
8418 return Roo.urlDecode(fs);
8422 * Returns the fields in this form as an object with key/value pairs.
8423 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8426 getFieldValues : function(with_hidden)
8428 var items = this.getItems();
8430 items.each(function(f){
8436 var v = f.getValue();
8438 if (f.inputType =='radio') {
8439 if (typeof(ret[f.getName()]) == 'undefined') {
8440 ret[f.getName()] = ''; // empty..
8443 if (!f.el.dom.checked) {
8451 if(f.xtype == 'MoneyField'){
8452 ret[f.currencyName] = f.getCurrency();
8455 // not sure if this supported any more..
8456 if ((typeof(v) == 'object') && f.getRawValue) {
8457 v = f.getRawValue() ; // dates..
8459 // combo boxes where name != hiddenName...
8460 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8461 ret[f.name] = f.getRawValue();
8463 ret[f.getName()] = v;
8470 * Clears all invalid messages in this form.
8471 * @return {BasicForm} this
8473 clearInvalid : function(){
8474 var items = this.getItems();
8476 items.each(function(f){
8485 * @return {BasicForm} this
8488 var items = this.getItems();
8489 items.each(function(f){
8493 Roo.each(this.childForms || [], function (f) {
8501 getItems : function()
8503 var r=new Roo.util.MixedCollection(false, function(o){
8504 return o.id || (o.id = Roo.id());
8506 var iter = function(el) {
8513 Roo.each(el.items,function(e) {
8522 hideFields : function(items)
8524 Roo.each(items, function(i){
8526 var f = this.findField(i);
8537 showFields : function(items)
8539 Roo.each(items, function(i){
8541 var f = this.findField(i);
8554 Roo.apply(Roo.bootstrap.Form, {
8581 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8582 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8583 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8584 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8587 this.maskEl.top.enableDisplayMode("block");
8588 this.maskEl.left.enableDisplayMode("block");
8589 this.maskEl.bottom.enableDisplayMode("block");
8590 this.maskEl.right.enableDisplayMode("block");
8592 this.toolTip = new Roo.bootstrap.Tooltip({
8593 cls : 'roo-form-error-popover',
8595 'left' : ['r-l', [-2,0], 'right'],
8596 'right' : ['l-r', [2,0], 'left'],
8597 'bottom' : ['tl-bl', [0,2], 'top'],
8598 'top' : [ 'bl-tl', [0,-2], 'bottom']
8602 this.toolTip.render(Roo.get(document.body));
8604 this.toolTip.el.enableDisplayMode("block");
8606 Roo.get(document.body).on('click', function(){
8610 Roo.get(document.body).on('touchstart', function(){
8614 this.isApplied = true
8617 mask : function(form, target)
8621 this.target = target;
8623 if(!this.form.errorMask || !target.el){
8627 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8629 Roo.log(scrollable);
8631 var ot = this.target.el.calcOffsetsTo(scrollable);
8633 var scrollTo = ot[1] - this.form.maskOffset;
8635 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8637 scrollable.scrollTo('top', scrollTo);
8639 var box = this.target.el.getBox();
8641 var zIndex = Roo.bootstrap.Modal.zIndex++;
8644 this.maskEl.top.setStyle('position', 'absolute');
8645 this.maskEl.top.setStyle('z-index', zIndex);
8646 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8647 this.maskEl.top.setLeft(0);
8648 this.maskEl.top.setTop(0);
8649 this.maskEl.top.show();
8651 this.maskEl.left.setStyle('position', 'absolute');
8652 this.maskEl.left.setStyle('z-index', zIndex);
8653 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8654 this.maskEl.left.setLeft(0);
8655 this.maskEl.left.setTop(box.y - this.padding);
8656 this.maskEl.left.show();
8658 this.maskEl.bottom.setStyle('position', 'absolute');
8659 this.maskEl.bottom.setStyle('z-index', zIndex);
8660 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8661 this.maskEl.bottom.setLeft(0);
8662 this.maskEl.bottom.setTop(box.bottom + this.padding);
8663 this.maskEl.bottom.show();
8665 this.maskEl.right.setStyle('position', 'absolute');
8666 this.maskEl.right.setStyle('z-index', zIndex);
8667 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8668 this.maskEl.right.setLeft(box.right + this.padding);
8669 this.maskEl.right.setTop(box.y - this.padding);
8670 this.maskEl.right.show();
8672 this.toolTip.bindEl = this.target.el;
8674 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8676 var tip = this.target.blankText;
8678 if(this.target.getValue() !== '' ) {
8680 if (this.target.invalidText.length) {
8681 tip = this.target.invalidText;
8682 } else if (this.target.regexText.length){
8683 tip = this.target.regexText;
8687 this.toolTip.show(tip);
8689 this.intervalID = window.setInterval(function() {
8690 Roo.bootstrap.Form.popover.unmask();
8693 window.onwheel = function(){ return false;};
8695 (function(){ this.isMasked = true; }).defer(500, this);
8701 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8705 this.maskEl.top.setStyle('position', 'absolute');
8706 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8707 this.maskEl.top.hide();
8709 this.maskEl.left.setStyle('position', 'absolute');
8710 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8711 this.maskEl.left.hide();
8713 this.maskEl.bottom.setStyle('position', 'absolute');
8714 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8715 this.maskEl.bottom.hide();
8717 this.maskEl.right.setStyle('position', 'absolute');
8718 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8719 this.maskEl.right.hide();
8721 this.toolTip.hide();
8723 this.toolTip.el.hide();
8725 window.onwheel = function(){ return true;};
8727 if(this.intervalID){
8728 window.clearInterval(this.intervalID);
8729 this.intervalID = false;
8732 this.isMasked = false;
8742 * Ext JS Library 1.1.1
8743 * Copyright(c) 2006-2007, Ext JS, LLC.
8745 * Originally Released Under LGPL - original licence link has changed is not relivant.
8748 * <script type="text/javascript">
8751 * @class Roo.form.VTypes
8752 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8755 Roo.form.VTypes = function(){
8756 // closure these in so they are only created once.
8757 var alpha = /^[a-zA-Z_]+$/;
8758 var alphanum = /^[a-zA-Z0-9_]+$/;
8759 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8760 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8762 // All these messages and functions are configurable
8765 * The function used to validate email addresses
8766 * @param {String} value The email address
8768 'email' : function(v){
8769 return email.test(v);
8772 * The error text to display when the email validation function returns false
8775 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8777 * The keystroke filter mask to be applied on email input
8780 'emailMask' : /[a-z0-9_\.\-@]/i,
8783 * The function used to validate URLs
8784 * @param {String} value The URL
8786 'url' : function(v){
8790 * The error text to display when the url validation function returns false
8793 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8796 * The function used to validate alpha values
8797 * @param {String} value The value
8799 'alpha' : function(v){
8800 return alpha.test(v);
8803 * The error text to display when the alpha validation function returns false
8806 'alphaText' : 'This field should only contain letters and _',
8808 * The keystroke filter mask to be applied on alpha input
8811 'alphaMask' : /[a-z_]/i,
8814 * The function used to validate alphanumeric values
8815 * @param {String} value The value
8817 'alphanum' : function(v){
8818 return alphanum.test(v);
8821 * The error text to display when the alphanumeric validation function returns false
8824 'alphanumText' : 'This field should only contain letters, numbers and _',
8826 * The keystroke filter mask to be applied on alphanumeric input
8829 'alphanumMask' : /[a-z0-9_]/i
8839 * @class Roo.bootstrap.Input
8840 * @extends Roo.bootstrap.Component
8841 * Bootstrap Input class
8842 * @cfg {Boolean} disabled is it disabled
8843 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8844 * @cfg {String} name name of the input
8845 * @cfg {string} fieldLabel - the label associated
8846 * @cfg {string} placeholder - placeholder to put in text.
8847 * @cfg {string} before - input group add on before
8848 * @cfg {string} after - input group add on after
8849 * @cfg {string} size - (lg|sm) or leave empty..
8850 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8851 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8852 * @cfg {Number} md colspan out of 12 for computer-sized screens
8853 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8854 * @cfg {string} value default value of the input
8855 * @cfg {Number} labelWidth set the width of label
8856 * @cfg {Number} labellg set the width of label (1-12)
8857 * @cfg {Number} labelmd set the width of label (1-12)
8858 * @cfg {Number} labelsm set the width of label (1-12)
8859 * @cfg {Number} labelxs set the width of label (1-12)
8860 * @cfg {String} labelAlign (top|left)
8861 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8862 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8863 * @cfg {String} indicatorpos (left|right) default left
8864 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8865 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8867 * @cfg {String} align (left|center|right) Default left
8868 * @cfg {Boolean} forceFeedback (true|false) Default false
8871 * Create a new Input
8872 * @param {Object} config The config object
8875 Roo.bootstrap.Input = function(config){
8877 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8882 * Fires when this field receives input focus.
8883 * @param {Roo.form.Field} this
8888 * Fires when this field loses input focus.
8889 * @param {Roo.form.Field} this
8894 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8895 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8896 * @param {Roo.form.Field} this
8897 * @param {Roo.EventObject} e The event object
8902 * Fires just before the field blurs if the field value has changed.
8903 * @param {Roo.form.Field} this
8904 * @param {Mixed} newValue The new value
8905 * @param {Mixed} oldValue The original value
8910 * Fires after the field has been marked as invalid.
8911 * @param {Roo.form.Field} this
8912 * @param {String} msg The validation message
8917 * Fires after the field has been validated with no errors.
8918 * @param {Roo.form.Field} this
8923 * Fires after the key up
8924 * @param {Roo.form.Field} this
8925 * @param {Roo.EventObject} e The event Object
8931 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8933 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8934 automatic validation (defaults to "keyup").
8936 validationEvent : "keyup",
8938 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8940 validateOnBlur : true,
8942 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8944 validationDelay : 250,
8946 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8948 focusClass : "x-form-focus", // not needed???
8952 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8954 invalidClass : "has-warning",
8957 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8959 validClass : "has-success",
8962 * @cfg {Boolean} hasFeedback (true|false) default true
8967 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8969 invalidFeedbackClass : "glyphicon-warning-sign",
8972 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8974 validFeedbackClass : "glyphicon-ok",
8977 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8979 selectOnFocus : false,
8982 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8986 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8991 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8993 disableKeyFilter : false,
8996 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9000 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9004 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9006 blankText : "Please complete this mandatory field",
9009 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9013 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9015 maxLength : Number.MAX_VALUE,
9017 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9019 minLengthText : "The minimum length for this field is {0}",
9021 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9023 maxLengthText : "The maximum length for this field is {0}",
9027 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9028 * If available, this function will be called only after the basic validators all return true, and will be passed the
9029 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9033 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9034 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9035 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9039 * @cfg {String} regexText -- Depricated - use Invalid Text
9044 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9050 autocomplete: false,
9069 formatedValue : false,
9070 forceFeedback : false,
9072 indicatorpos : 'left',
9082 parentLabelAlign : function()
9085 while (parent.parent()) {
9086 parent = parent.parent();
9087 if (typeof(parent.labelAlign) !='undefined') {
9088 return parent.labelAlign;
9095 getAutoCreate : function()
9097 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9103 if(this.inputType != 'hidden'){
9104 cfg.cls = 'form-group' //input-group
9110 type : this.inputType,
9112 cls : 'form-control',
9113 placeholder : this.placeholder || '',
9114 autocomplete : this.autocomplete || 'new-password'
9117 if(this.capture.length){
9118 input.capture = this.capture;
9121 if(this.accept.length){
9122 input.accept = this.accept + "/*";
9126 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9129 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9130 input.maxLength = this.maxLength;
9133 if (this.disabled) {
9134 input.disabled=true;
9137 if (this.readOnly) {
9138 input.readonly=true;
9142 input.name = this.name;
9146 input.cls += ' input-' + this.size;
9150 ['xs','sm','md','lg'].map(function(size){
9151 if (settings[size]) {
9152 cfg.cls += ' col-' + size + '-' + settings[size];
9156 var inputblock = input;
9160 cls: 'glyphicon form-control-feedback'
9163 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9166 cls : 'has-feedback',
9174 if (this.before || this.after) {
9177 cls : 'input-group',
9181 if (this.before && typeof(this.before) == 'string') {
9183 inputblock.cn.push({
9185 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9189 if (this.before && typeof(this.before) == 'object') {
9190 this.before = Roo.factory(this.before);
9192 inputblock.cn.push({
9194 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9195 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9199 inputblock.cn.push(input);
9201 if (this.after && typeof(this.after) == 'string') {
9202 inputblock.cn.push({
9204 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9208 if (this.after && typeof(this.after) == 'object') {
9209 this.after = Roo.factory(this.after);
9211 inputblock.cn.push({
9213 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9214 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9218 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9219 inputblock.cls += ' has-feedback';
9220 inputblock.cn.push(feedback);
9225 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9226 tooltip : 'This field is required'
9228 if (Roo.bootstrap.version == 4) {
9231 style : 'display-none'
9234 if (align ==='left' && this.fieldLabel.length) {
9236 cfg.cls += ' roo-form-group-label-left row';
9243 cls : 'control-label col-form-label',
9244 html : this.fieldLabel
9255 var labelCfg = cfg.cn[1];
9256 var contentCfg = cfg.cn[2];
9258 if(this.indicatorpos == 'right'){
9263 cls : 'control-label col-form-label',
9267 html : this.fieldLabel
9281 labelCfg = cfg.cn[0];
9282 contentCfg = cfg.cn[1];
9286 if(this.labelWidth > 12){
9287 labelCfg.style = "width: " + this.labelWidth + 'px';
9290 if(this.labelWidth < 13 && this.labelmd == 0){
9291 this.labelmd = this.labelWidth;
9294 if(this.labellg > 0){
9295 labelCfg.cls += ' col-lg-' + this.labellg;
9296 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9299 if(this.labelmd > 0){
9300 labelCfg.cls += ' col-md-' + this.labelmd;
9301 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9304 if(this.labelsm > 0){
9305 labelCfg.cls += ' col-sm-' + this.labelsm;
9306 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9309 if(this.labelxs > 0){
9310 labelCfg.cls += ' col-xs-' + this.labelxs;
9311 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9315 } else if ( this.fieldLabel.length) {
9320 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9321 tooltip : 'This field is required'
9325 //cls : 'input-group-addon',
9326 html : this.fieldLabel
9334 if(this.indicatorpos == 'right'){
9339 //cls : 'input-group-addon',
9340 html : this.fieldLabel
9345 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9346 tooltip : 'This field is required'
9366 if (this.parentType === 'Navbar' && this.parent().bar) {
9367 cfg.cls += ' navbar-form';
9370 if (this.parentType === 'NavGroup') {
9371 cfg.cls += ' navbar-form';
9379 * return the real input element.
9381 inputEl: function ()
9383 return this.el.select('input.form-control',true).first();
9386 tooltipEl : function()
9388 return this.inputEl();
9391 indicatorEl : function()
9393 if (Roo.bootstrap.version == 4) {
9394 return false; // not enabled in v4 yet.
9397 var indicator = this.el.select('i.roo-required-indicator',true).first();
9407 setDisabled : function(v)
9409 var i = this.inputEl().dom;
9411 i.removeAttribute('disabled');
9415 i.setAttribute('disabled','true');
9417 initEvents : function()
9420 this.inputEl().on("keydown" , this.fireKey, this);
9421 this.inputEl().on("focus", this.onFocus, this);
9422 this.inputEl().on("blur", this.onBlur, this);
9424 this.inputEl().relayEvent('keyup', this);
9426 this.indicator = this.indicatorEl();
9429 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9432 // reference to original value for reset
9433 this.originalValue = this.getValue();
9434 //Roo.form.TextField.superclass.initEvents.call(this);
9435 if(this.validationEvent == 'keyup'){
9436 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9437 this.inputEl().on('keyup', this.filterValidation, this);
9439 else if(this.validationEvent !== false){
9440 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9443 if(this.selectOnFocus){
9444 this.on("focus", this.preFocus, this);
9447 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9448 this.inputEl().on("keypress", this.filterKeys, this);
9450 this.inputEl().relayEvent('keypress', this);
9453 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9454 this.el.on("click", this.autoSize, this);
9457 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9458 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9461 if (typeof(this.before) == 'object') {
9462 this.before.render(this.el.select('.roo-input-before',true).first());
9464 if (typeof(this.after) == 'object') {
9465 this.after.render(this.el.select('.roo-input-after',true).first());
9468 this.inputEl().on('change', this.onChange, this);
9471 filterValidation : function(e){
9472 if(!e.isNavKeyPress()){
9473 this.validationTask.delay(this.validationDelay);
9477 * Validates the field value
9478 * @return {Boolean} True if the value is valid, else false
9480 validate : function(){
9481 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9482 if(this.disabled || this.validateValue(this.getRawValue())){
9493 * Validates a value according to the field's validation rules and marks the field as invalid
9494 * if the validation fails
9495 * @param {Mixed} value The value to validate
9496 * @return {Boolean} True if the value is valid, else false
9498 validateValue : function(value)
9500 if(this.getVisibilityEl().hasClass('hidden')){
9504 if(value.length < 1) { // if it's blank
9505 if(this.allowBlank){
9511 if(value.length < this.minLength){
9514 if(value.length > this.maxLength){
9518 var vt = Roo.form.VTypes;
9519 if(!vt[this.vtype](value, this)){
9523 if(typeof this.validator == "function"){
9524 var msg = this.validator(value);
9528 if (typeof(msg) == 'string') {
9529 this.invalidText = msg;
9533 if(this.regex && !this.regex.test(value)){
9541 fireKey : function(e){
9542 //Roo.log('field ' + e.getKey());
9543 if(e.isNavKeyPress()){
9544 this.fireEvent("specialkey", this, e);
9547 focus : function (selectText){
9549 this.inputEl().focus();
9550 if(selectText === true){
9551 this.inputEl().dom.select();
9557 onFocus : function(){
9558 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9559 // this.el.addClass(this.focusClass);
9562 this.hasFocus = true;
9563 this.startValue = this.getValue();
9564 this.fireEvent("focus", this);
9568 beforeBlur : Roo.emptyFn,
9572 onBlur : function(){
9574 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9575 //this.el.removeClass(this.focusClass);
9577 this.hasFocus = false;
9578 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9581 var v = this.getValue();
9582 if(String(v) !== String(this.startValue)){
9583 this.fireEvent('change', this, v, this.startValue);
9585 this.fireEvent("blur", this);
9588 onChange : function(e)
9590 var v = this.getValue();
9591 if(String(v) !== String(this.startValue)){
9592 this.fireEvent('change', this, v, this.startValue);
9598 * Resets the current field value to the originally loaded value and clears any validation messages
9601 this.setValue(this.originalValue);
9605 * Returns the name of the field
9606 * @return {Mixed} name The name field
9608 getName: function(){
9612 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9613 * @return {Mixed} value The field value
9615 getValue : function(){
9617 var v = this.inputEl().getValue();
9622 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9623 * @return {Mixed} value The field value
9625 getRawValue : function(){
9626 var v = this.inputEl().getValue();
9632 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9633 * @param {Mixed} value The value to set
9635 setRawValue : function(v){
9636 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9639 selectText : function(start, end){
9640 var v = this.getRawValue();
9642 start = start === undefined ? 0 : start;
9643 end = end === undefined ? v.length : end;
9644 var d = this.inputEl().dom;
9645 if(d.setSelectionRange){
9646 d.setSelectionRange(start, end);
9647 }else if(d.createTextRange){
9648 var range = d.createTextRange();
9649 range.moveStart("character", start);
9650 range.moveEnd("character", v.length-end);
9657 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9658 * @param {Mixed} value The value to set
9660 setValue : function(v){
9663 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9669 processValue : function(value){
9670 if(this.stripCharsRe){
9671 var newValue = value.replace(this.stripCharsRe, '');
9672 if(newValue !== value){
9673 this.setRawValue(newValue);
9680 preFocus : function(){
9682 if(this.selectOnFocus){
9683 this.inputEl().dom.select();
9686 filterKeys : function(e){
9688 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9691 var c = e.getCharCode(), cc = String.fromCharCode(c);
9692 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9695 if(!this.maskRe.test(cc)){
9700 * Clear any invalid styles/messages for this field
9702 clearInvalid : function(){
9704 if(!this.el || this.preventMark){ // not rendered
9709 this.el.removeClass(this.invalidClass);
9711 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9713 var feedback = this.el.select('.form-control-feedback', true).first();
9716 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9722 this.indicator.removeClass('visible');
9723 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9726 this.fireEvent('valid', this);
9730 * Mark this field as valid
9732 markValid : function()
9734 if(!this.el || this.preventMark){ // not rendered...
9738 this.el.removeClass([this.invalidClass, this.validClass]);
9740 var feedback = this.el.select('.form-control-feedback', true).first();
9743 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9747 this.indicator.removeClass('visible');
9748 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9755 if(this.allowBlank && !this.getRawValue().length){
9759 this.el.addClass(this.validClass);
9761 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9763 var feedback = this.el.select('.form-control-feedback', true).first();
9766 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9767 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9772 this.fireEvent('valid', this);
9776 * Mark this field as invalid
9777 * @param {String} msg The validation message
9779 markInvalid : function(msg)
9781 if(!this.el || this.preventMark){ // not rendered
9785 this.el.removeClass([this.invalidClass, this.validClass]);
9787 var feedback = this.el.select('.form-control-feedback', true).first();
9790 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9797 if(this.allowBlank && !this.getRawValue().length){
9802 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9803 this.indicator.addClass('visible');
9806 this.el.addClass(this.invalidClass);
9808 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9810 var feedback = this.el.select('.form-control-feedback', true).first();
9813 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9815 if(this.getValue().length || this.forceFeedback){
9816 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9823 this.fireEvent('invalid', this, msg);
9826 SafariOnKeyDown : function(event)
9828 // this is a workaround for a password hang bug on chrome/ webkit.
9829 if (this.inputEl().dom.type != 'password') {
9833 var isSelectAll = false;
9835 if(this.inputEl().dom.selectionEnd > 0){
9836 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9838 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9839 event.preventDefault();
9844 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9846 event.preventDefault();
9847 // this is very hacky as keydown always get's upper case.
9849 var cc = String.fromCharCode(event.getCharCode());
9850 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9854 adjustWidth : function(tag, w){
9855 tag = tag.toLowerCase();
9856 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9857 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9861 if(tag == 'textarea'){
9864 }else if(Roo.isOpera){
9868 if(tag == 'textarea'){
9876 setFieldLabel : function(v)
9882 if(this.indicatorEl()){
9883 var ar = this.el.select('label > span',true);
9885 if (ar.elements.length) {
9886 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9887 this.fieldLabel = v;
9891 var br = this.el.select('label',true);
9893 if(br.elements.length) {
9894 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9895 this.fieldLabel = v;
9899 Roo.log('Cannot Found any of label > span || label in input');
9903 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9904 this.fieldLabel = v;
9919 * @class Roo.bootstrap.TextArea
9920 * @extends Roo.bootstrap.Input
9921 * Bootstrap TextArea class
9922 * @cfg {Number} cols Specifies the visible width of a text area
9923 * @cfg {Number} rows Specifies the visible number of lines in a text area
9924 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9925 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9926 * @cfg {string} html text
9929 * Create a new TextArea
9930 * @param {Object} config The config object
9933 Roo.bootstrap.TextArea = function(config){
9934 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9938 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9948 getAutoCreate : function(){
9950 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9956 if(this.inputType != 'hidden'){
9957 cfg.cls = 'form-group' //input-group
9965 value : this.value || '',
9966 html: this.html || '',
9967 cls : 'form-control',
9968 placeholder : this.placeholder || ''
9972 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9973 input.maxLength = this.maxLength;
9977 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9981 input.cols = this.cols;
9984 if (this.readOnly) {
9985 input.readonly = true;
9989 input.name = this.name;
9993 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9997 ['xs','sm','md','lg'].map(function(size){
9998 if (settings[size]) {
9999 cfg.cls += ' col-' + size + '-' + settings[size];
10003 var inputblock = input;
10005 if(this.hasFeedback && !this.allowBlank){
10009 cls: 'glyphicon form-control-feedback'
10013 cls : 'has-feedback',
10022 if (this.before || this.after) {
10025 cls : 'input-group',
10029 inputblock.cn.push({
10031 cls : 'input-group-addon',
10036 inputblock.cn.push(input);
10038 if(this.hasFeedback && !this.allowBlank){
10039 inputblock.cls += ' has-feedback';
10040 inputblock.cn.push(feedback);
10044 inputblock.cn.push({
10046 cls : 'input-group-addon',
10053 if (align ==='left' && this.fieldLabel.length) {
10058 cls : 'control-label',
10059 html : this.fieldLabel
10070 if(this.labelWidth > 12){
10071 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10074 if(this.labelWidth < 13 && this.labelmd == 0){
10075 this.labelmd = this.labelWidth;
10078 if(this.labellg > 0){
10079 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10080 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10083 if(this.labelmd > 0){
10084 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10085 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10088 if(this.labelsm > 0){
10089 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10090 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10093 if(this.labelxs > 0){
10094 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10095 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10098 } else if ( this.fieldLabel.length) {
10103 //cls : 'input-group-addon',
10104 html : this.fieldLabel
10122 if (this.disabled) {
10123 input.disabled=true;
10130 * return the real textarea element.
10132 inputEl: function ()
10134 return this.el.select('textarea.form-control',true).first();
10138 * Clear any invalid styles/messages for this field
10140 clearInvalid : function()
10143 if(!this.el || this.preventMark){ // not rendered
10147 var label = this.el.select('label', true).first();
10148 var icon = this.el.select('i.fa-star', true).first();
10154 this.el.removeClass(this.invalidClass);
10156 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10158 var feedback = this.el.select('.form-control-feedback', true).first();
10161 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10166 this.fireEvent('valid', this);
10170 * Mark this field as valid
10172 markValid : function()
10174 if(!this.el || this.preventMark){ // not rendered
10178 this.el.removeClass([this.invalidClass, this.validClass]);
10180 var feedback = this.el.select('.form-control-feedback', true).first();
10183 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10186 if(this.disabled || this.allowBlank){
10190 var label = this.el.select('label', true).first();
10191 var icon = this.el.select('i.fa-star', true).first();
10197 this.el.addClass(this.validClass);
10199 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10201 var feedback = this.el.select('.form-control-feedback', true).first();
10204 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10205 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10210 this.fireEvent('valid', this);
10214 * Mark this field as invalid
10215 * @param {String} msg The validation message
10217 markInvalid : function(msg)
10219 if(!this.el || this.preventMark){ // not rendered
10223 this.el.removeClass([this.invalidClass, this.validClass]);
10225 var feedback = this.el.select('.form-control-feedback', true).first();
10228 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10231 if(this.disabled || this.allowBlank){
10235 var label = this.el.select('label', true).first();
10236 var icon = this.el.select('i.fa-star', true).first();
10238 if(!this.getValue().length && label && !icon){
10239 this.el.createChild({
10241 cls : 'text-danger fa fa-lg fa-star',
10242 tooltip : 'This field is required',
10243 style : 'margin-right:5px;'
10247 this.el.addClass(this.invalidClass);
10249 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10251 var feedback = this.el.select('.form-control-feedback', true).first();
10254 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10256 if(this.getValue().length || this.forceFeedback){
10257 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10264 this.fireEvent('invalid', this, msg);
10272 * trigger field - base class for combo..
10277 * @class Roo.bootstrap.TriggerField
10278 * @extends Roo.bootstrap.Input
10279 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10280 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10281 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10282 * for which you can provide a custom implementation. For example:
10284 var trigger = new Roo.bootstrap.TriggerField();
10285 trigger.onTriggerClick = myTriggerFn;
10286 trigger.applyTo('my-field');
10289 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10290 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10291 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10292 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10293 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10296 * Create a new TriggerField.
10297 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10298 * to the base TextField)
10300 Roo.bootstrap.TriggerField = function(config){
10301 this.mimicing = false;
10302 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10305 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10307 * @cfg {String} triggerClass A CSS class to apply to the trigger
10310 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10315 * @cfg {Boolean} removable (true|false) special filter default false
10319 /** @cfg {Boolean} grow @hide */
10320 /** @cfg {Number} growMin @hide */
10321 /** @cfg {Number} growMax @hide */
10327 autoSize: Roo.emptyFn,
10331 deferHeight : true,
10334 actionMode : 'wrap',
10339 getAutoCreate : function(){
10341 var align = this.labelAlign || this.parentLabelAlign();
10346 cls: 'form-group' //input-group
10353 type : this.inputType,
10354 cls : 'form-control',
10355 autocomplete: 'new-password',
10356 placeholder : this.placeholder || ''
10360 input.name = this.name;
10363 input.cls += ' input-' + this.size;
10366 if (this.disabled) {
10367 input.disabled=true;
10370 var inputblock = input;
10372 if(this.hasFeedback && !this.allowBlank){
10376 cls: 'glyphicon form-control-feedback'
10379 if(this.removable && !this.editable && !this.tickable){
10381 cls : 'has-feedback',
10387 cls : 'roo-combo-removable-btn close'
10394 cls : 'has-feedback',
10403 if(this.removable && !this.editable && !this.tickable){
10405 cls : 'roo-removable',
10411 cls : 'roo-combo-removable-btn close'
10418 if (this.before || this.after) {
10421 cls : 'input-group',
10425 inputblock.cn.push({
10427 cls : 'input-group-addon input-group-prepend input-group-text',
10432 inputblock.cn.push(input);
10434 if(this.hasFeedback && !this.allowBlank){
10435 inputblock.cls += ' has-feedback';
10436 inputblock.cn.push(feedback);
10440 inputblock.cn.push({
10442 cls : 'input-group-addon input-group-append input-group-text',
10451 var ibwrap = inputblock;
10456 cls: 'roo-select2-choices',
10460 cls: 'roo-select2-search-field',
10472 cls: 'roo-select2-container input-group',
10477 cls: 'form-hidden-field'
10483 if(!this.multiple && this.showToggleBtn){
10489 if (this.caret != false) {
10492 cls: 'fa fa-' + this.caret
10499 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10504 cls: 'combobox-clear',
10518 combobox.cls += ' roo-select2-container-multi';
10522 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10523 tooltip : 'This field is required'
10525 if (Roo.bootstrap.version == 4) {
10528 style : 'display:none'
10533 if (align ==='left' && this.fieldLabel.length) {
10535 cfg.cls += ' roo-form-group-label-left row';
10542 cls : 'control-label',
10543 html : this.fieldLabel
10555 var labelCfg = cfg.cn[1];
10556 var contentCfg = cfg.cn[2];
10558 if(this.indicatorpos == 'right'){
10563 cls : 'control-label',
10567 html : this.fieldLabel
10581 labelCfg = cfg.cn[0];
10582 contentCfg = cfg.cn[1];
10585 if(this.labelWidth > 12){
10586 labelCfg.style = "width: " + this.labelWidth + 'px';
10589 if(this.labelWidth < 13 && this.labelmd == 0){
10590 this.labelmd = this.labelWidth;
10593 if(this.labellg > 0){
10594 labelCfg.cls += ' col-lg-' + this.labellg;
10595 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10598 if(this.labelmd > 0){
10599 labelCfg.cls += ' col-md-' + this.labelmd;
10600 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10603 if(this.labelsm > 0){
10604 labelCfg.cls += ' col-sm-' + this.labelsm;
10605 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10608 if(this.labelxs > 0){
10609 labelCfg.cls += ' col-xs-' + this.labelxs;
10610 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10613 } else if ( this.fieldLabel.length) {
10614 // Roo.log(" label");
10619 //cls : 'input-group-addon',
10620 html : this.fieldLabel
10628 if(this.indicatorpos == 'right'){
10636 html : this.fieldLabel
10650 // Roo.log(" no label && no align");
10657 ['xs','sm','md','lg'].map(function(size){
10658 if (settings[size]) {
10659 cfg.cls += ' col-' + size + '-' + settings[size];
10670 onResize : function(w, h){
10671 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10672 // if(typeof w == 'number'){
10673 // var x = w - this.trigger.getWidth();
10674 // this.inputEl().setWidth(this.adjustWidth('input', x));
10675 // this.trigger.setStyle('left', x+'px');
10680 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10683 getResizeEl : function(){
10684 return this.inputEl();
10688 getPositionEl : function(){
10689 return this.inputEl();
10693 alignErrorIcon : function(){
10694 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10698 initEvents : function(){
10702 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10703 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10704 if(!this.multiple && this.showToggleBtn){
10705 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10706 if(this.hideTrigger){
10707 this.trigger.setDisplayed(false);
10709 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10713 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10716 if(this.removable && !this.editable && !this.tickable){
10717 var close = this.closeTriggerEl();
10720 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10721 close.on('click', this.removeBtnClick, this, close);
10725 //this.trigger.addClassOnOver('x-form-trigger-over');
10726 //this.trigger.addClassOnClick('x-form-trigger-click');
10729 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10733 closeTriggerEl : function()
10735 var close = this.el.select('.roo-combo-removable-btn', true).first();
10736 return close ? close : false;
10739 removeBtnClick : function(e, h, el)
10741 e.preventDefault();
10743 if(this.fireEvent("remove", this) !== false){
10745 this.fireEvent("afterremove", this)
10749 createList : function()
10751 this.list = Roo.get(document.body).createChild({
10752 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10753 cls: 'typeahead typeahead-long dropdown-menu',
10754 style: 'display:none'
10757 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10762 initTrigger : function(){
10767 onDestroy : function(){
10769 this.trigger.removeAllListeners();
10770 // this.trigger.remove();
10773 // this.wrap.remove();
10775 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10779 onFocus : function(){
10780 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10782 if(!this.mimicing){
10783 this.wrap.addClass('x-trigger-wrap-focus');
10784 this.mimicing = true;
10785 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10786 if(this.monitorTab){
10787 this.el.on("keydown", this.checkTab, this);
10794 checkTab : function(e){
10795 if(e.getKey() == e.TAB){
10796 this.triggerBlur();
10801 onBlur : function(){
10806 mimicBlur : function(e, t){
10808 if(!this.wrap.contains(t) && this.validateBlur()){
10809 this.triggerBlur();
10815 triggerBlur : function(){
10816 this.mimicing = false;
10817 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10818 if(this.monitorTab){
10819 this.el.un("keydown", this.checkTab, this);
10821 //this.wrap.removeClass('x-trigger-wrap-focus');
10822 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10826 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10827 validateBlur : function(e, t){
10832 onDisable : function(){
10833 this.inputEl().dom.disabled = true;
10834 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10836 // this.wrap.addClass('x-item-disabled');
10841 onEnable : function(){
10842 this.inputEl().dom.disabled = false;
10843 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10845 // this.el.removeClass('x-item-disabled');
10850 onShow : function(){
10851 var ae = this.getActionEl();
10854 ae.dom.style.display = '';
10855 ae.dom.style.visibility = 'visible';
10861 onHide : function(){
10862 var ae = this.getActionEl();
10863 ae.dom.style.display = 'none';
10867 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10868 * by an implementing function.
10870 * @param {EventObject} e
10872 onTriggerClick : Roo.emptyFn
10876 * Ext JS Library 1.1.1
10877 * Copyright(c) 2006-2007, Ext JS, LLC.
10879 * Originally Released Under LGPL - original licence link has changed is not relivant.
10882 * <script type="text/javascript">
10887 * @class Roo.data.SortTypes
10889 * Defines the default sorting (casting?) comparison functions used when sorting data.
10891 Roo.data.SortTypes = {
10893 * Default sort that does nothing
10894 * @param {Mixed} s The value being converted
10895 * @return {Mixed} The comparison value
10897 none : function(s){
10902 * The regular expression used to strip tags
10906 stripTagsRE : /<\/?[^>]+>/gi,
10909 * Strips all HTML tags to sort on text only
10910 * @param {Mixed} s The value being converted
10911 * @return {String} The comparison value
10913 asText : function(s){
10914 return String(s).replace(this.stripTagsRE, "");
10918 * Strips all HTML tags to sort on text only - Case insensitive
10919 * @param {Mixed} s The value being converted
10920 * @return {String} The comparison value
10922 asUCText : function(s){
10923 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10927 * Case insensitive string
10928 * @param {Mixed} s The value being converted
10929 * @return {String} The comparison value
10931 asUCString : function(s) {
10932 return String(s).toUpperCase();
10937 * @param {Mixed} s The value being converted
10938 * @return {Number} The comparison value
10940 asDate : function(s) {
10944 if(s instanceof Date){
10945 return s.getTime();
10947 return Date.parse(String(s));
10952 * @param {Mixed} s The value being converted
10953 * @return {Float} The comparison value
10955 asFloat : function(s) {
10956 var val = parseFloat(String(s).replace(/,/g, ""));
10965 * @param {Mixed} s The value being converted
10966 * @return {Number} The comparison value
10968 asInt : function(s) {
10969 var val = parseInt(String(s).replace(/,/g, ""));
10977 * Ext JS Library 1.1.1
10978 * Copyright(c) 2006-2007, Ext JS, LLC.
10980 * Originally Released Under LGPL - original licence link has changed is not relivant.
10983 * <script type="text/javascript">
10987 * @class Roo.data.Record
10988 * Instances of this class encapsulate both record <em>definition</em> information, and record
10989 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10990 * to access Records cached in an {@link Roo.data.Store} object.<br>
10992 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10993 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10996 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10998 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10999 * {@link #create}. The parameters are the same.
11000 * @param {Array} data An associative Array of data values keyed by the field name.
11001 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11002 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11003 * not specified an integer id is generated.
11005 Roo.data.Record = function(data, id){
11006 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11011 * Generate a constructor for a specific record layout.
11012 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11013 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11014 * Each field definition object may contain the following properties: <ul>
11015 * <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,
11016 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11017 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11018 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11019 * is being used, then this is a string containing the javascript expression to reference the data relative to
11020 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11021 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11022 * this may be omitted.</p></li>
11023 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11024 * <ul><li>auto (Default, implies no conversion)</li>
11029 * <li>date</li></ul></p></li>
11030 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11031 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11032 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11033 * by the Reader into an object that will be stored in the Record. It is passed the
11034 * following parameters:<ul>
11035 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11037 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11039 * <br>usage:<br><pre><code>
11040 var TopicRecord = Roo.data.Record.create(
11041 {name: 'title', mapping: 'topic_title'},
11042 {name: 'author', mapping: 'username'},
11043 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11044 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11045 {name: 'lastPoster', mapping: 'user2'},
11046 {name: 'excerpt', mapping: 'post_text'}
11049 var myNewRecord = new TopicRecord({
11050 title: 'Do my job please',
11053 lastPost: new Date(),
11054 lastPoster: 'Animal',
11055 excerpt: 'No way dude!'
11057 myStore.add(myNewRecord);
11062 Roo.data.Record.create = function(o){
11063 var f = function(){
11064 f.superclass.constructor.apply(this, arguments);
11066 Roo.extend(f, Roo.data.Record);
11067 var p = f.prototype;
11068 p.fields = new Roo.util.MixedCollection(false, function(field){
11071 for(var i = 0, len = o.length; i < len; i++){
11072 p.fields.add(new Roo.data.Field(o[i]));
11074 f.getField = function(name){
11075 return p.fields.get(name);
11080 Roo.data.Record.AUTO_ID = 1000;
11081 Roo.data.Record.EDIT = 'edit';
11082 Roo.data.Record.REJECT = 'reject';
11083 Roo.data.Record.COMMIT = 'commit';
11085 Roo.data.Record.prototype = {
11087 * Readonly flag - true if this record has been modified.
11096 join : function(store){
11097 this.store = store;
11101 * Set the named field to the specified value.
11102 * @param {String} name The name of the field to set.
11103 * @param {Object} value The value to set the field to.
11105 set : function(name, value){
11106 if(this.data[name] == value){
11110 if(!this.modified){
11111 this.modified = {};
11113 if(typeof this.modified[name] == 'undefined'){
11114 this.modified[name] = this.data[name];
11116 this.data[name] = value;
11117 if(!this.editing && this.store){
11118 this.store.afterEdit(this);
11123 * Get the value of the named field.
11124 * @param {String} name The name of the field to get the value of.
11125 * @return {Object} The value of the field.
11127 get : function(name){
11128 return this.data[name];
11132 beginEdit : function(){
11133 this.editing = true;
11134 this.modified = {};
11138 cancelEdit : function(){
11139 this.editing = false;
11140 delete this.modified;
11144 endEdit : function(){
11145 this.editing = false;
11146 if(this.dirty && this.store){
11147 this.store.afterEdit(this);
11152 * Usually called by the {@link Roo.data.Store} which owns the Record.
11153 * Rejects all changes made to the Record since either creation, or the last commit operation.
11154 * Modified fields are reverted to their original values.
11156 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11157 * of reject operations.
11159 reject : function(){
11160 var m = this.modified;
11162 if(typeof m[n] != "function"){
11163 this.data[n] = m[n];
11166 this.dirty = false;
11167 delete this.modified;
11168 this.editing = false;
11170 this.store.afterReject(this);
11175 * Usually called by the {@link Roo.data.Store} which owns the Record.
11176 * Commits all changes made to the Record since either creation, or the last commit operation.
11178 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11179 * of commit operations.
11181 commit : function(){
11182 this.dirty = false;
11183 delete this.modified;
11184 this.editing = false;
11186 this.store.afterCommit(this);
11191 hasError : function(){
11192 return this.error != null;
11196 clearError : function(){
11201 * Creates a copy of this record.
11202 * @param {String} id (optional) A new record id if you don't want to use this record's id
11205 copy : function(newId) {
11206 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11210 * Ext JS Library 1.1.1
11211 * Copyright(c) 2006-2007, Ext JS, LLC.
11213 * Originally Released Under LGPL - original licence link has changed is not relivant.
11216 * <script type="text/javascript">
11222 * @class Roo.data.Store
11223 * @extends Roo.util.Observable
11224 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11225 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11227 * 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
11228 * has no knowledge of the format of the data returned by the Proxy.<br>
11230 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11231 * instances from the data object. These records are cached and made available through accessor functions.
11233 * Creates a new Store.
11234 * @param {Object} config A config object containing the objects needed for the Store to access data,
11235 * and read the data into Records.
11237 Roo.data.Store = function(config){
11238 this.data = new Roo.util.MixedCollection(false);
11239 this.data.getKey = function(o){
11242 this.baseParams = {};
11244 this.paramNames = {
11249 "multisort" : "_multisort"
11252 if(config && config.data){
11253 this.inlineData = config.data;
11254 delete config.data;
11257 Roo.apply(this, config);
11259 if(this.reader){ // reader passed
11260 this.reader = Roo.factory(this.reader, Roo.data);
11261 this.reader.xmodule = this.xmodule || false;
11262 if(!this.recordType){
11263 this.recordType = this.reader.recordType;
11265 if(this.reader.onMetaChange){
11266 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11270 if(this.recordType){
11271 this.fields = this.recordType.prototype.fields;
11273 this.modified = [];
11277 * @event datachanged
11278 * Fires when the data cache has changed, and a widget which is using this Store
11279 * as a Record cache should refresh its view.
11280 * @param {Store} this
11282 datachanged : true,
11284 * @event metachange
11285 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11286 * @param {Store} this
11287 * @param {Object} meta The JSON metadata
11292 * Fires when Records have been added to the Store
11293 * @param {Store} this
11294 * @param {Roo.data.Record[]} records The array of Records added
11295 * @param {Number} index The index at which the record(s) were added
11300 * Fires when a Record has been removed from the Store
11301 * @param {Store} this
11302 * @param {Roo.data.Record} record The Record that was removed
11303 * @param {Number} index The index at which the record was removed
11308 * Fires when a Record has been updated
11309 * @param {Store} this
11310 * @param {Roo.data.Record} record The Record that was updated
11311 * @param {String} operation The update operation being performed. Value may be one of:
11313 Roo.data.Record.EDIT
11314 Roo.data.Record.REJECT
11315 Roo.data.Record.COMMIT
11321 * Fires when the data cache has been cleared.
11322 * @param {Store} this
11326 * @event beforeload
11327 * Fires before a request is made for a new data object. If the beforeload handler returns false
11328 * the load action will be canceled.
11329 * @param {Store} this
11330 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11334 * @event beforeloadadd
11335 * Fires after a new set of Records has been loaded.
11336 * @param {Store} this
11337 * @param {Roo.data.Record[]} records The Records that were loaded
11338 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11340 beforeloadadd : true,
11343 * Fires after a new set of Records has been loaded, before they are added to the store.
11344 * @param {Store} this
11345 * @param {Roo.data.Record[]} records The Records that were loaded
11346 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11347 * @params {Object} return from reader
11351 * @event loadexception
11352 * Fires if an exception occurs in the Proxy during loading.
11353 * Called with the signature of the Proxy's "loadexception" event.
11354 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11357 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11358 * @param {Object} load options
11359 * @param {Object} jsonData from your request (normally this contains the Exception)
11361 loadexception : true
11365 this.proxy = Roo.factory(this.proxy, Roo.data);
11366 this.proxy.xmodule = this.xmodule || false;
11367 this.relayEvents(this.proxy, ["loadexception"]);
11369 this.sortToggle = {};
11370 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11372 Roo.data.Store.superclass.constructor.call(this);
11374 if(this.inlineData){
11375 this.loadData(this.inlineData);
11376 delete this.inlineData;
11380 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11382 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11383 * without a remote query - used by combo/forms at present.
11387 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11390 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11393 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11394 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11397 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11398 * on any HTTP request
11401 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11404 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11408 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11409 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11411 remoteSort : false,
11414 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11415 * loaded or when a record is removed. (defaults to false).
11417 pruneModifiedRecords : false,
11420 lastOptions : null,
11423 * Add Records to the Store and fires the add event.
11424 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11426 add : function(records){
11427 records = [].concat(records);
11428 for(var i = 0, len = records.length; i < len; i++){
11429 records[i].join(this);
11431 var index = this.data.length;
11432 this.data.addAll(records);
11433 this.fireEvent("add", this, records, index);
11437 * Remove a Record from the Store and fires the remove event.
11438 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11440 remove : function(record){
11441 var index = this.data.indexOf(record);
11442 this.data.removeAt(index);
11444 if(this.pruneModifiedRecords){
11445 this.modified.remove(record);
11447 this.fireEvent("remove", this, record, index);
11451 * Remove all Records from the Store and fires the clear event.
11453 removeAll : function(){
11455 if(this.pruneModifiedRecords){
11456 this.modified = [];
11458 this.fireEvent("clear", this);
11462 * Inserts Records to the Store at the given index and fires the add event.
11463 * @param {Number} index The start index at which to insert the passed Records.
11464 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11466 insert : function(index, records){
11467 records = [].concat(records);
11468 for(var i = 0, len = records.length; i < len; i++){
11469 this.data.insert(index, records[i]);
11470 records[i].join(this);
11472 this.fireEvent("add", this, records, index);
11476 * Get the index within the cache of the passed Record.
11477 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11478 * @return {Number} The index of the passed Record. Returns -1 if not found.
11480 indexOf : function(record){
11481 return this.data.indexOf(record);
11485 * Get the index within the cache of the Record with the passed id.
11486 * @param {String} id The id of the Record to find.
11487 * @return {Number} The index of the Record. Returns -1 if not found.
11489 indexOfId : function(id){
11490 return this.data.indexOfKey(id);
11494 * Get the Record with the specified id.
11495 * @param {String} id The id of the Record to find.
11496 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11498 getById : function(id){
11499 return this.data.key(id);
11503 * Get the Record at the specified index.
11504 * @param {Number} index The index of the Record to find.
11505 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11507 getAt : function(index){
11508 return this.data.itemAt(index);
11512 * Returns a range of Records between specified indices.
11513 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11514 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11515 * @return {Roo.data.Record[]} An array of Records
11517 getRange : function(start, end){
11518 return this.data.getRange(start, end);
11522 storeOptions : function(o){
11523 o = Roo.apply({}, o);
11526 this.lastOptions = o;
11530 * Loads the Record cache from the configured Proxy using the configured Reader.
11532 * If using remote paging, then the first load call must specify the <em>start</em>
11533 * and <em>limit</em> properties in the options.params property to establish the initial
11534 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11536 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11537 * and this call will return before the new data has been loaded. Perform any post-processing
11538 * in a callback function, or in a "load" event handler.</strong>
11540 * @param {Object} options An object containing properties which control loading options:<ul>
11541 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11542 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11543 * passed the following arguments:<ul>
11544 * <li>r : Roo.data.Record[]</li>
11545 * <li>options: Options object from the load call</li>
11546 * <li>success: Boolean success indicator</li></ul></li>
11547 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11548 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11551 load : function(options){
11552 options = options || {};
11553 if(this.fireEvent("beforeload", this, options) !== false){
11554 this.storeOptions(options);
11555 var p = Roo.apply(options.params || {}, this.baseParams);
11556 // if meta was not loaded from remote source.. try requesting it.
11557 if (!this.reader.metaFromRemote) {
11558 p._requestMeta = 1;
11560 if(this.sortInfo && this.remoteSort){
11561 var pn = this.paramNames;
11562 p[pn["sort"]] = this.sortInfo.field;
11563 p[pn["dir"]] = this.sortInfo.direction;
11565 if (this.multiSort) {
11566 var pn = this.paramNames;
11567 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11570 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11575 * Reloads the Record cache from the configured Proxy using the configured Reader and
11576 * the options from the last load operation performed.
11577 * @param {Object} options (optional) An object containing properties which may override the options
11578 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11579 * the most recently used options are reused).
11581 reload : function(options){
11582 this.load(Roo.applyIf(options||{}, this.lastOptions));
11586 // Called as a callback by the Reader during a load operation.
11587 loadRecords : function(o, options, success){
11588 if(!o || success === false){
11589 if(success !== false){
11590 this.fireEvent("load", this, [], options, o);
11592 if(options.callback){
11593 options.callback.call(options.scope || this, [], options, false);
11597 // if data returned failure - throw an exception.
11598 if (o.success === false) {
11599 // show a message if no listener is registered.
11600 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11601 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11603 // loadmask wil be hooked into this..
11604 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11607 var r = o.records, t = o.totalRecords || r.length;
11609 this.fireEvent("beforeloadadd", this, r, options, o);
11611 if(!options || options.add !== true){
11612 if(this.pruneModifiedRecords){
11613 this.modified = [];
11615 for(var i = 0, len = r.length; i < len; i++){
11619 this.data = this.snapshot;
11620 delete this.snapshot;
11623 this.data.addAll(r);
11624 this.totalLength = t;
11626 this.fireEvent("datachanged", this);
11628 this.totalLength = Math.max(t, this.data.length+r.length);
11632 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11634 var e = new Roo.data.Record({});
11636 e.set(this.parent.displayField, this.parent.emptyTitle);
11637 e.set(this.parent.valueField, '');
11642 this.fireEvent("load", this, r, options, o);
11643 if(options.callback){
11644 options.callback.call(options.scope || this, r, options, true);
11650 * Loads data from a passed data block. A Reader which understands the format of the data
11651 * must have been configured in the constructor.
11652 * @param {Object} data The data block from which to read the Records. The format of the data expected
11653 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11654 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11656 loadData : function(o, append){
11657 var r = this.reader.readRecords(o);
11658 this.loadRecords(r, {add: append}, true);
11662 * Gets the number of cached records.
11664 * <em>If using paging, this may not be the total size of the dataset. If the data object
11665 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11666 * the data set size</em>
11668 getCount : function(){
11669 return this.data.length || 0;
11673 * Gets the total number of records in the dataset as returned by the server.
11675 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11676 * the dataset size</em>
11678 getTotalCount : function(){
11679 return this.totalLength || 0;
11683 * Returns the sort state of the Store as an object with two properties:
11685 field {String} The name of the field by which the Records are sorted
11686 direction {String} The sort order, "ASC" or "DESC"
11689 getSortState : function(){
11690 return this.sortInfo;
11694 applySort : function(){
11695 if(this.sortInfo && !this.remoteSort){
11696 var s = this.sortInfo, f = s.field;
11697 var st = this.fields.get(f).sortType;
11698 var fn = function(r1, r2){
11699 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11700 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11702 this.data.sort(s.direction, fn);
11703 if(this.snapshot && this.snapshot != this.data){
11704 this.snapshot.sort(s.direction, fn);
11710 * Sets the default sort column and order to be used by the next load operation.
11711 * @param {String} fieldName The name of the field to sort by.
11712 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11714 setDefaultSort : function(field, dir){
11715 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11719 * Sort the Records.
11720 * If remote sorting is used, the sort is performed on the server, and the cache is
11721 * reloaded. If local sorting is used, the cache is sorted internally.
11722 * @param {String} fieldName The name of the field to sort by.
11723 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11725 sort : function(fieldName, dir){
11726 var f = this.fields.get(fieldName);
11728 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11730 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11731 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11736 this.sortToggle[f.name] = dir;
11737 this.sortInfo = {field: f.name, direction: dir};
11738 if(!this.remoteSort){
11740 this.fireEvent("datachanged", this);
11742 this.load(this.lastOptions);
11747 * Calls the specified function for each of the Records in the cache.
11748 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11749 * Returning <em>false</em> aborts and exits the iteration.
11750 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11752 each : function(fn, scope){
11753 this.data.each(fn, scope);
11757 * Gets all records modified since the last commit. Modified records are persisted across load operations
11758 * (e.g., during paging).
11759 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11761 getModifiedRecords : function(){
11762 return this.modified;
11766 createFilterFn : function(property, value, anyMatch){
11767 if(!value.exec){ // not a regex
11768 value = String(value);
11769 if(value.length == 0){
11772 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11774 return function(r){
11775 return value.test(r.data[property]);
11780 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11781 * @param {String} property A field on your records
11782 * @param {Number} start The record index to start at (defaults to 0)
11783 * @param {Number} end The last record index to include (defaults to length - 1)
11784 * @return {Number} The sum
11786 sum : function(property, start, end){
11787 var rs = this.data.items, v = 0;
11788 start = start || 0;
11789 end = (end || end === 0) ? end : rs.length-1;
11791 for(var i = start; i <= end; i++){
11792 v += (rs[i].data[property] || 0);
11798 * Filter the records by a specified property.
11799 * @param {String} field A field on your records
11800 * @param {String/RegExp} value Either a string that the field
11801 * should start with or a RegExp to test against the field
11802 * @param {Boolean} anyMatch True to match any part not just the beginning
11804 filter : function(property, value, anyMatch){
11805 var fn = this.createFilterFn(property, value, anyMatch);
11806 return fn ? this.filterBy(fn) : this.clearFilter();
11810 * Filter by a function. The specified function will be called with each
11811 * record in this data source. If the function returns true the record is included,
11812 * otherwise it is filtered.
11813 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11814 * @param {Object} scope (optional) The scope of the function (defaults to this)
11816 filterBy : function(fn, scope){
11817 this.snapshot = this.snapshot || this.data;
11818 this.data = this.queryBy(fn, scope||this);
11819 this.fireEvent("datachanged", this);
11823 * Query the records by a specified property.
11824 * @param {String} field A field on your records
11825 * @param {String/RegExp} value Either a string that the field
11826 * should start with or a RegExp to test against the field
11827 * @param {Boolean} anyMatch True to match any part not just the beginning
11828 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11830 query : function(property, value, anyMatch){
11831 var fn = this.createFilterFn(property, value, anyMatch);
11832 return fn ? this.queryBy(fn) : this.data.clone();
11836 * Query by a function. The specified function will be called with each
11837 * record in this data source. If the function returns true the record is included
11839 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11840 * @param {Object} scope (optional) The scope of the function (defaults to this)
11841 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11843 queryBy : function(fn, scope){
11844 var data = this.snapshot || this.data;
11845 return data.filterBy(fn, scope||this);
11849 * Collects unique values for a particular dataIndex from this store.
11850 * @param {String} dataIndex The property to collect
11851 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11852 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11853 * @return {Array} An array of the unique values
11855 collect : function(dataIndex, allowNull, bypassFilter){
11856 var d = (bypassFilter === true && this.snapshot) ?
11857 this.snapshot.items : this.data.items;
11858 var v, sv, r = [], l = {};
11859 for(var i = 0, len = d.length; i < len; i++){
11860 v = d[i].data[dataIndex];
11862 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11871 * Revert to a view of the Record cache with no filtering applied.
11872 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11874 clearFilter : function(suppressEvent){
11875 if(this.snapshot && this.snapshot != this.data){
11876 this.data = this.snapshot;
11877 delete this.snapshot;
11878 if(suppressEvent !== true){
11879 this.fireEvent("datachanged", this);
11885 afterEdit : function(record){
11886 if(this.modified.indexOf(record) == -1){
11887 this.modified.push(record);
11889 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11893 afterReject : function(record){
11894 this.modified.remove(record);
11895 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11899 afterCommit : function(record){
11900 this.modified.remove(record);
11901 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11905 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11906 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11908 commitChanges : function(){
11909 var m = this.modified.slice(0);
11910 this.modified = [];
11911 for(var i = 0, len = m.length; i < len; i++){
11917 * Cancel outstanding changes on all changed records.
11919 rejectChanges : function(){
11920 var m = this.modified.slice(0);
11921 this.modified = [];
11922 for(var i = 0, len = m.length; i < len; i++){
11927 onMetaChange : function(meta, rtype, o){
11928 this.recordType = rtype;
11929 this.fields = rtype.prototype.fields;
11930 delete this.snapshot;
11931 this.sortInfo = meta.sortInfo || this.sortInfo;
11932 this.modified = [];
11933 this.fireEvent('metachange', this, this.reader.meta);
11936 moveIndex : function(data, type)
11938 var index = this.indexOf(data);
11940 var newIndex = index + type;
11944 this.insert(newIndex, data);
11949 * Ext JS Library 1.1.1
11950 * Copyright(c) 2006-2007, Ext JS, LLC.
11952 * Originally Released Under LGPL - original licence link has changed is not relivant.
11955 * <script type="text/javascript">
11959 * @class Roo.data.SimpleStore
11960 * @extends Roo.data.Store
11961 * Small helper class to make creating Stores from Array data easier.
11962 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11963 * @cfg {Array} fields An array of field definition objects, or field name strings.
11964 * @cfg {Array} data The multi-dimensional array of data
11966 * @param {Object} config
11968 Roo.data.SimpleStore = function(config){
11969 Roo.data.SimpleStore.superclass.constructor.call(this, {
11971 reader: new Roo.data.ArrayReader({
11974 Roo.data.Record.create(config.fields)
11976 proxy : new Roo.data.MemoryProxy(config.data)
11980 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11982 * Ext JS Library 1.1.1
11983 * Copyright(c) 2006-2007, Ext JS, LLC.
11985 * Originally Released Under LGPL - original licence link has changed is not relivant.
11988 * <script type="text/javascript">
11993 * @extends Roo.data.Store
11994 * @class Roo.data.JsonStore
11995 * Small helper class to make creating Stores for JSON data easier. <br/>
11997 var store = new Roo.data.JsonStore({
11998 url: 'get-images.php',
12000 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12003 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12004 * JsonReader and HttpProxy (unless inline data is provided).</b>
12005 * @cfg {Array} fields An array of field definition objects, or field name strings.
12007 * @param {Object} config
12009 Roo.data.JsonStore = function(c){
12010 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12011 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12012 reader: new Roo.data.JsonReader(c, c.fields)
12015 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12017 * Ext JS Library 1.1.1
12018 * Copyright(c) 2006-2007, Ext JS, LLC.
12020 * Originally Released Under LGPL - original licence link has changed is not relivant.
12023 * <script type="text/javascript">
12027 Roo.data.Field = function(config){
12028 if(typeof config == "string"){
12029 config = {name: config};
12031 Roo.apply(this, config);
12034 this.type = "auto";
12037 var st = Roo.data.SortTypes;
12038 // named sortTypes are supported, here we look them up
12039 if(typeof this.sortType == "string"){
12040 this.sortType = st[this.sortType];
12043 // set default sortType for strings and dates
12044 if(!this.sortType){
12047 this.sortType = st.asUCString;
12050 this.sortType = st.asDate;
12053 this.sortType = st.none;
12058 var stripRe = /[\$,%]/g;
12060 // prebuilt conversion function for this field, instead of
12061 // switching every time we're reading a value
12063 var cv, dateFormat = this.dateFormat;
12068 cv = function(v){ return v; };
12071 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12075 return v !== undefined && v !== null && v !== '' ?
12076 parseInt(String(v).replace(stripRe, ""), 10) : '';
12081 return v !== undefined && v !== null && v !== '' ?
12082 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12087 cv = function(v){ return v === true || v === "true" || v == 1; };
12094 if(v instanceof Date){
12098 if(dateFormat == "timestamp"){
12099 return new Date(v*1000);
12101 return Date.parseDate(v, dateFormat);
12103 var parsed = Date.parse(v);
12104 return parsed ? new Date(parsed) : null;
12113 Roo.data.Field.prototype = {
12121 * Ext JS Library 1.1.1
12122 * Copyright(c) 2006-2007, Ext JS, LLC.
12124 * Originally Released Under LGPL - original licence link has changed is not relivant.
12127 * <script type="text/javascript">
12130 // Base class for reading structured data from a data source. This class is intended to be
12131 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12134 * @class Roo.data.DataReader
12135 * Base class for reading structured data from a data source. This class is intended to be
12136 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12139 Roo.data.DataReader = function(meta, recordType){
12143 this.recordType = recordType instanceof Array ?
12144 Roo.data.Record.create(recordType) : recordType;
12147 Roo.data.DataReader.prototype = {
12149 * Create an empty record
12150 * @param {Object} data (optional) - overlay some values
12151 * @return {Roo.data.Record} record created.
12153 newRow : function(d) {
12155 this.recordType.prototype.fields.each(function(c) {
12157 case 'int' : da[c.name] = 0; break;
12158 case 'date' : da[c.name] = new Date(); break;
12159 case 'float' : da[c.name] = 0.0; break;
12160 case 'boolean' : da[c.name] = false; break;
12161 default : da[c.name] = ""; break;
12165 return new this.recordType(Roo.apply(da, d));
12170 * Ext JS Library 1.1.1
12171 * Copyright(c) 2006-2007, Ext JS, LLC.
12173 * Originally Released Under LGPL - original licence link has changed is not relivant.
12176 * <script type="text/javascript">
12180 * @class Roo.data.DataProxy
12181 * @extends Roo.data.Observable
12182 * This class is an abstract base class for implementations which provide retrieval of
12183 * unformatted data objects.<br>
12185 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12186 * (of the appropriate type which knows how to parse the data object) to provide a block of
12187 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12189 * Custom implementations must implement the load method as described in
12190 * {@link Roo.data.HttpProxy#load}.
12192 Roo.data.DataProxy = function(){
12195 * @event beforeload
12196 * Fires before a network request is made to retrieve a data object.
12197 * @param {Object} This DataProxy object.
12198 * @param {Object} params The params parameter to the load function.
12203 * Fires before the load method's callback is called.
12204 * @param {Object} This DataProxy object.
12205 * @param {Object} o The data object.
12206 * @param {Object} arg The callback argument object passed to the load function.
12210 * @event loadexception
12211 * Fires if an Exception occurs during data retrieval.
12212 * @param {Object} This DataProxy object.
12213 * @param {Object} o The data object.
12214 * @param {Object} arg The callback argument object passed to the load function.
12215 * @param {Object} e The Exception.
12217 loadexception : true
12219 Roo.data.DataProxy.superclass.constructor.call(this);
12222 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12225 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12229 * Ext JS Library 1.1.1
12230 * Copyright(c) 2006-2007, Ext JS, LLC.
12232 * Originally Released Under LGPL - original licence link has changed is not relivant.
12235 * <script type="text/javascript">
12238 * @class Roo.data.MemoryProxy
12239 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12240 * to the Reader when its load method is called.
12242 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12244 Roo.data.MemoryProxy = function(data){
12248 Roo.data.MemoryProxy.superclass.constructor.call(this);
12252 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12255 * Load data from the requested source (in this case an in-memory
12256 * data object passed to the constructor), read the data object into
12257 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12258 * process that block using the passed callback.
12259 * @param {Object} params This parameter is not used by the MemoryProxy class.
12260 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12261 * object into a block of Roo.data.Records.
12262 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12263 * The function must be passed <ul>
12264 * <li>The Record block object</li>
12265 * <li>The "arg" argument from the load function</li>
12266 * <li>A boolean success indicator</li>
12268 * @param {Object} scope The scope in which to call the callback
12269 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12271 load : function(params, reader, callback, scope, arg){
12272 params = params || {};
12275 result = reader.readRecords(this.data);
12277 this.fireEvent("loadexception", this, arg, null, e);
12278 callback.call(scope, null, arg, false);
12281 callback.call(scope, result, arg, true);
12285 update : function(params, records){
12290 * Ext JS Library 1.1.1
12291 * Copyright(c) 2006-2007, Ext JS, LLC.
12293 * Originally Released Under LGPL - original licence link has changed is not relivant.
12296 * <script type="text/javascript">
12299 * @class Roo.data.HttpProxy
12300 * @extends Roo.data.DataProxy
12301 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12302 * configured to reference a certain URL.<br><br>
12304 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12305 * from which the running page was served.<br><br>
12307 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12309 * Be aware that to enable the browser to parse an XML document, the server must set
12310 * the Content-Type header in the HTTP response to "text/xml".
12312 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12313 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12314 * will be used to make the request.
12316 Roo.data.HttpProxy = function(conn){
12317 Roo.data.HttpProxy.superclass.constructor.call(this);
12318 // is conn a conn config or a real conn?
12320 this.useAjax = !conn || !conn.events;
12324 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12325 // thse are take from connection...
12328 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12331 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12332 * extra parameters to each request made by this object. (defaults to undefined)
12335 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12336 * to each request made by this object. (defaults to undefined)
12339 * @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)
12342 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12345 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12351 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12355 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12356 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12357 * a finer-grained basis than the DataProxy events.
12359 getConnection : function(){
12360 return this.useAjax ? Roo.Ajax : this.conn;
12364 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12365 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12366 * process that block using the passed callback.
12367 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12368 * for the request to the remote server.
12369 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12370 * object into a block of Roo.data.Records.
12371 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12372 * The function must be passed <ul>
12373 * <li>The Record block object</li>
12374 * <li>The "arg" argument from the load function</li>
12375 * <li>A boolean success indicator</li>
12377 * @param {Object} scope The scope in which to call the callback
12378 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12380 load : function(params, reader, callback, scope, arg){
12381 if(this.fireEvent("beforeload", this, params) !== false){
12383 params : params || {},
12385 callback : callback,
12390 callback : this.loadResponse,
12394 Roo.applyIf(o, this.conn);
12395 if(this.activeRequest){
12396 Roo.Ajax.abort(this.activeRequest);
12398 this.activeRequest = Roo.Ajax.request(o);
12400 this.conn.request(o);
12403 callback.call(scope||this, null, arg, false);
12408 loadResponse : function(o, success, response){
12409 delete this.activeRequest;
12411 this.fireEvent("loadexception", this, o, response);
12412 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12417 result = o.reader.read(response);
12419 this.fireEvent("loadexception", this, o, response, e);
12420 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12424 this.fireEvent("load", this, o, o.request.arg);
12425 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12429 update : function(dataSet){
12434 updateResponse : function(dataSet){
12439 * Ext JS Library 1.1.1
12440 * Copyright(c) 2006-2007, Ext JS, LLC.
12442 * Originally Released Under LGPL - original licence link has changed is not relivant.
12445 * <script type="text/javascript">
12449 * @class Roo.data.ScriptTagProxy
12450 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12451 * other than the originating domain of the running page.<br><br>
12453 * <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
12454 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12456 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12457 * source code that is used as the source inside a <script> tag.<br><br>
12459 * In order for the browser to process the returned data, the server must wrap the data object
12460 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12461 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12462 * depending on whether the callback name was passed:
12465 boolean scriptTag = false;
12466 String cb = request.getParameter("callback");
12469 response.setContentType("text/javascript");
12471 response.setContentType("application/x-json");
12473 Writer out = response.getWriter();
12475 out.write(cb + "(");
12477 out.print(dataBlock.toJsonString());
12484 * @param {Object} config A configuration object.
12486 Roo.data.ScriptTagProxy = function(config){
12487 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12488 Roo.apply(this, config);
12489 this.head = document.getElementsByTagName("head")[0];
12492 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12494 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12496 * @cfg {String} url The URL from which to request the data object.
12499 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12503 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12504 * the server the name of the callback function set up by the load call to process the returned data object.
12505 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12506 * javascript output which calls this named function passing the data object as its only parameter.
12508 callbackParam : "callback",
12510 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12511 * name to the request.
12516 * Load data from the configured URL, read the data object into
12517 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12518 * process that block using the passed callback.
12519 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12520 * for the request to the remote server.
12521 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12522 * object into a block of Roo.data.Records.
12523 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12524 * The function must be passed <ul>
12525 * <li>The Record block object</li>
12526 * <li>The "arg" argument from the load function</li>
12527 * <li>A boolean success indicator</li>
12529 * @param {Object} scope The scope in which to call the callback
12530 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12532 load : function(params, reader, callback, scope, arg){
12533 if(this.fireEvent("beforeload", this, params) !== false){
12535 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12537 var url = this.url;
12538 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12540 url += "&_dc=" + (new Date().getTime());
12542 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12545 cb : "stcCallback"+transId,
12546 scriptId : "stcScript"+transId,
12550 callback : callback,
12556 window[trans.cb] = function(o){
12557 conn.handleResponse(o, trans);
12560 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12562 if(this.autoAbort !== false){
12566 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12568 var script = document.createElement("script");
12569 script.setAttribute("src", url);
12570 script.setAttribute("type", "text/javascript");
12571 script.setAttribute("id", trans.scriptId);
12572 this.head.appendChild(script);
12574 this.trans = trans;
12576 callback.call(scope||this, null, arg, false);
12581 isLoading : function(){
12582 return this.trans ? true : false;
12586 * Abort the current server request.
12588 abort : function(){
12589 if(this.isLoading()){
12590 this.destroyTrans(this.trans);
12595 destroyTrans : function(trans, isLoaded){
12596 this.head.removeChild(document.getElementById(trans.scriptId));
12597 clearTimeout(trans.timeoutId);
12599 window[trans.cb] = undefined;
12601 delete window[trans.cb];
12604 // if hasn't been loaded, wait for load to remove it to prevent script error
12605 window[trans.cb] = function(){
12606 window[trans.cb] = undefined;
12608 delete window[trans.cb];
12615 handleResponse : function(o, trans){
12616 this.trans = false;
12617 this.destroyTrans(trans, true);
12620 result = trans.reader.readRecords(o);
12622 this.fireEvent("loadexception", this, o, trans.arg, e);
12623 trans.callback.call(trans.scope||window, null, trans.arg, false);
12626 this.fireEvent("load", this, o, trans.arg);
12627 trans.callback.call(trans.scope||window, result, trans.arg, true);
12631 handleFailure : function(trans){
12632 this.trans = false;
12633 this.destroyTrans(trans, false);
12634 this.fireEvent("loadexception", this, null, trans.arg);
12635 trans.callback.call(trans.scope||window, null, trans.arg, false);
12639 * Ext JS Library 1.1.1
12640 * Copyright(c) 2006-2007, Ext JS, LLC.
12642 * Originally Released Under LGPL - original licence link has changed is not relivant.
12645 * <script type="text/javascript">
12649 * @class Roo.data.JsonReader
12650 * @extends Roo.data.DataReader
12651 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12652 * based on mappings in a provided Roo.data.Record constructor.
12654 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12655 * in the reply previously.
12660 var RecordDef = Roo.data.Record.create([
12661 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12662 {name: 'occupation'} // This field will use "occupation" as the mapping.
12664 var myReader = new Roo.data.JsonReader({
12665 totalProperty: "results", // The property which contains the total dataset size (optional)
12666 root: "rows", // The property which contains an Array of row objects
12667 id: "id" // The property within each row object that provides an ID for the record (optional)
12671 * This would consume a JSON file like this:
12673 { 'results': 2, 'rows': [
12674 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12675 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12678 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12679 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12680 * paged from the remote server.
12681 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12682 * @cfg {String} root name of the property which contains the Array of row objects.
12683 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12684 * @cfg {Array} fields Array of field definition objects
12686 * Create a new JsonReader
12687 * @param {Object} meta Metadata configuration options
12688 * @param {Object} recordType Either an Array of field definition objects,
12689 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12691 Roo.data.JsonReader = function(meta, recordType){
12694 // set some defaults:
12695 Roo.applyIf(meta, {
12696 totalProperty: 'total',
12697 successProperty : 'success',
12702 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12704 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12707 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12708 * Used by Store query builder to append _requestMeta to params.
12711 metaFromRemote : false,
12713 * This method is only used by a DataProxy which has retrieved data from a remote server.
12714 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12715 * @return {Object} data A data block which is used by an Roo.data.Store object as
12716 * a cache of Roo.data.Records.
12718 read : function(response){
12719 var json = response.responseText;
12721 var o = /* eval:var:o */ eval("("+json+")");
12723 throw {message: "JsonReader.read: Json object not found"};
12729 this.metaFromRemote = true;
12730 this.meta = o.metaData;
12731 this.recordType = Roo.data.Record.create(o.metaData.fields);
12732 this.onMetaChange(this.meta, this.recordType, o);
12734 return this.readRecords(o);
12737 // private function a store will implement
12738 onMetaChange : function(meta, recordType, o){
12745 simpleAccess: function(obj, subsc) {
12752 getJsonAccessor: function(){
12754 return function(expr) {
12756 return(re.test(expr))
12757 ? new Function("obj", "return obj." + expr)
12762 return Roo.emptyFn;
12767 * Create a data block containing Roo.data.Records from an XML document.
12768 * @param {Object} o An object which contains an Array of row objects in the property specified
12769 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12770 * which contains the total size of the dataset.
12771 * @return {Object} data A data block which is used by an Roo.data.Store object as
12772 * a cache of Roo.data.Records.
12774 readRecords : function(o){
12776 * After any data loads, the raw JSON data is available for further custom processing.
12780 var s = this.meta, Record = this.recordType,
12781 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12783 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12785 if(s.totalProperty) {
12786 this.getTotal = this.getJsonAccessor(s.totalProperty);
12788 if(s.successProperty) {
12789 this.getSuccess = this.getJsonAccessor(s.successProperty);
12791 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12793 var g = this.getJsonAccessor(s.id);
12794 this.getId = function(rec) {
12796 return (r === undefined || r === "") ? null : r;
12799 this.getId = function(){return null;};
12802 for(var jj = 0; jj < fl; jj++){
12804 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12805 this.ef[jj] = this.getJsonAccessor(map);
12809 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12810 if(s.totalProperty){
12811 var vt = parseInt(this.getTotal(o), 10);
12816 if(s.successProperty){
12817 var vs = this.getSuccess(o);
12818 if(vs === false || vs === 'false'){
12823 for(var i = 0; i < c; i++){
12826 var id = this.getId(n);
12827 for(var j = 0; j < fl; j++){
12829 var v = this.ef[j](n);
12831 Roo.log('missing convert for ' + f.name);
12835 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12837 var record = new Record(values, id);
12839 records[i] = record;
12845 totalRecords : totalRecords
12850 * Ext JS Library 1.1.1
12851 * Copyright(c) 2006-2007, Ext JS, LLC.
12853 * Originally Released Under LGPL - original licence link has changed is not relivant.
12856 * <script type="text/javascript">
12860 * @class Roo.data.ArrayReader
12861 * @extends Roo.data.DataReader
12862 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12863 * Each element of that Array represents a row of data fields. The
12864 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12865 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12869 var RecordDef = Roo.data.Record.create([
12870 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12871 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12873 var myReader = new Roo.data.ArrayReader({
12874 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12878 * This would consume an Array like this:
12880 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12882 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12884 * Create a new JsonReader
12885 * @param {Object} meta Metadata configuration options.
12886 * @param {Object} recordType Either an Array of field definition objects
12887 * as specified to {@link Roo.data.Record#create},
12888 * or an {@link Roo.data.Record} object
12889 * created using {@link Roo.data.Record#create}.
12891 Roo.data.ArrayReader = function(meta, recordType){
12892 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12895 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12897 * Create a data block containing Roo.data.Records from an XML document.
12898 * @param {Object} o An Array of row objects which represents the dataset.
12899 * @return {Object} data A data block which is used by an Roo.data.Store object as
12900 * a cache of Roo.data.Records.
12902 readRecords : function(o){
12903 var sid = this.meta ? this.meta.id : null;
12904 var recordType = this.recordType, fields = recordType.prototype.fields;
12907 for(var i = 0; i < root.length; i++){
12910 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12911 for(var j = 0, jlen = fields.length; j < jlen; j++){
12912 var f = fields.items[j];
12913 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12914 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12916 values[f.name] = v;
12918 var record = new recordType(values, id);
12920 records[records.length] = record;
12924 totalRecords : records.length
12933 * @class Roo.bootstrap.ComboBox
12934 * @extends Roo.bootstrap.TriggerField
12935 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12936 * @cfg {Boolean} append (true|false) default false
12937 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12938 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12939 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12940 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12941 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12942 * @cfg {Boolean} animate default true
12943 * @cfg {Boolean} emptyResultText only for touch device
12944 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12945 * @cfg {String} emptyTitle default ''
12947 * Create a new ComboBox.
12948 * @param {Object} config Configuration options
12950 Roo.bootstrap.ComboBox = function(config){
12951 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12955 * Fires when the dropdown list is expanded
12956 * @param {Roo.bootstrap.ComboBox} combo This combo box
12961 * Fires when the dropdown list is collapsed
12962 * @param {Roo.bootstrap.ComboBox} combo This combo box
12966 * @event beforeselect
12967 * Fires before a list item is selected. Return false to cancel the selection.
12968 * @param {Roo.bootstrap.ComboBox} combo This combo box
12969 * @param {Roo.data.Record} record The data record returned from the underlying store
12970 * @param {Number} index The index of the selected item in the dropdown list
12972 'beforeselect' : true,
12975 * Fires when a list item is selected
12976 * @param {Roo.bootstrap.ComboBox} combo This combo box
12977 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12978 * @param {Number} index The index of the selected item in the dropdown list
12982 * @event beforequery
12983 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12984 * The event object passed has these properties:
12985 * @param {Roo.bootstrap.ComboBox} combo This combo box
12986 * @param {String} query The query
12987 * @param {Boolean} forceAll true to force "all" query
12988 * @param {Boolean} cancel true to cancel the query
12989 * @param {Object} e The query event object
12991 'beforequery': true,
12994 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12995 * @param {Roo.bootstrap.ComboBox} combo This combo box
13000 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13001 * @param {Roo.bootstrap.ComboBox} combo This combo box
13002 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13007 * Fires when the remove value from the combobox array
13008 * @param {Roo.bootstrap.ComboBox} combo This combo box
13012 * @event afterremove
13013 * Fires when the remove value from the combobox array
13014 * @param {Roo.bootstrap.ComboBox} combo This combo box
13016 'afterremove' : true,
13018 * @event specialfilter
13019 * Fires when specialfilter
13020 * @param {Roo.bootstrap.ComboBox} combo This combo box
13022 'specialfilter' : true,
13025 * Fires when tick the element
13026 * @param {Roo.bootstrap.ComboBox} combo This combo box
13030 * @event touchviewdisplay
13031 * Fires when touch view require special display (default is using displayField)
13032 * @param {Roo.bootstrap.ComboBox} combo This combo box
13033 * @param {Object} cfg set html .
13035 'touchviewdisplay' : true
13040 this.tickItems = [];
13042 this.selectedIndex = -1;
13043 if(this.mode == 'local'){
13044 if(config.queryDelay === undefined){
13045 this.queryDelay = 10;
13047 if(config.minChars === undefined){
13053 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13056 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13057 * rendering into an Roo.Editor, defaults to false)
13060 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13061 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13064 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13067 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13068 * the dropdown list (defaults to undefined, with no header element)
13072 * @cfg {String/Roo.Template} tpl The template to use to render the output
13076 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13078 listWidth: undefined,
13080 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13081 * mode = 'remote' or 'text' if mode = 'local')
13083 displayField: undefined,
13086 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13087 * mode = 'remote' or 'value' if mode = 'local').
13088 * Note: use of a valueField requires the user make a selection
13089 * in order for a value to be mapped.
13091 valueField: undefined,
13093 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13098 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13099 * field's data value (defaults to the underlying DOM element's name)
13101 hiddenName: undefined,
13103 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13107 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13109 selectedClass: 'active',
13112 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13116 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13117 * anchor positions (defaults to 'tl-bl')
13119 listAlign: 'tl-bl?',
13121 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13125 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13126 * query specified by the allQuery config option (defaults to 'query')
13128 triggerAction: 'query',
13130 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13131 * (defaults to 4, does not apply if editable = false)
13135 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13136 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13140 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13141 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13145 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13146 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13150 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13151 * when editable = true (defaults to false)
13153 selectOnFocus:false,
13155 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13157 queryParam: 'query',
13159 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13160 * when mode = 'remote' (defaults to 'Loading...')
13162 loadingText: 'Loading...',
13164 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13168 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13172 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13173 * traditional select (defaults to true)
13177 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13181 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13185 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13186 * listWidth has a higher value)
13190 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13191 * allow the user to set arbitrary text into the field (defaults to false)
13193 forceSelection:false,
13195 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13196 * if typeAhead = true (defaults to 250)
13198 typeAheadDelay : 250,
13200 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13201 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13203 valueNotFoundText : undefined,
13205 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13207 blockFocus : false,
13210 * @cfg {Boolean} disableClear Disable showing of clear button.
13212 disableClear : false,
13214 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13216 alwaysQuery : false,
13219 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13224 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
13226 invalidClass : "has-warning",
13229 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
13231 validClass : "has-success",
13234 * @cfg {Boolean} specialFilter (true|false) special filter default false
13236 specialFilter : false,
13239 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13241 mobileTouchView : true,
13244 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13246 useNativeIOS : false,
13249 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13251 mobile_restrict_height : false,
13253 ios_options : false,
13265 btnPosition : 'right',
13266 triggerList : true,
13267 showToggleBtn : true,
13269 emptyResultText: 'Empty',
13270 triggerText : 'Select',
13273 // element that contains real text value.. (when hidden is used..)
13275 getAutoCreate : function()
13280 * Render classic select for iso
13283 if(Roo.isIOS && this.useNativeIOS){
13284 cfg = this.getAutoCreateNativeIOS();
13292 if(Roo.isTouch && this.mobileTouchView){
13293 cfg = this.getAutoCreateTouchView();
13300 if(!this.tickable){
13301 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13306 * ComboBox with tickable selections
13309 var align = this.labelAlign || this.parentLabelAlign();
13312 cls : 'form-group roo-combobox-tickable' //input-group
13315 var btn_text_select = '';
13316 var btn_text_done = '';
13317 var btn_text_cancel = '';
13319 if (this.btn_text_show) {
13320 btn_text_select = 'Select';
13321 btn_text_done = 'Done';
13322 btn_text_cancel = 'Cancel';
13327 cls : 'tickable-buttons',
13332 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13333 //html : this.triggerText
13334 html: btn_text_select
13340 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13342 html: btn_text_done
13348 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13350 html: btn_text_cancel
13356 buttons.cn.unshift({
13358 cls: 'roo-select2-search-field-input'
13364 Roo.each(buttons.cn, function(c){
13366 c.cls += ' btn-' + _this.size;
13369 if (_this.disabled) {
13376 style : 'display: contents',
13381 cls: 'form-hidden-field'
13385 cls: 'roo-select2-choices',
13389 cls: 'roo-select2-search-field',
13400 cls: 'roo-select2-container input-group roo-select2-container-multi',
13406 // cls: 'typeahead typeahead-long dropdown-menu',
13407 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13412 if(this.hasFeedback && !this.allowBlank){
13416 cls: 'glyphicon form-control-feedback'
13419 combobox.cn.push(feedback);
13424 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13425 tooltip : 'This field is required'
13427 if (Roo.bootstrap.version == 4) {
13430 style : 'display:none'
13433 if (align ==='left' && this.fieldLabel.length) {
13435 cfg.cls += ' roo-form-group-label-left row';
13442 cls : 'control-label col-form-label',
13443 html : this.fieldLabel
13455 var labelCfg = cfg.cn[1];
13456 var contentCfg = cfg.cn[2];
13459 if(this.indicatorpos == 'right'){
13465 cls : 'control-label col-form-label',
13469 html : this.fieldLabel
13485 labelCfg = cfg.cn[0];
13486 contentCfg = cfg.cn[1];
13490 if(this.labelWidth > 12){
13491 labelCfg.style = "width: " + this.labelWidth + 'px';
13494 if(this.labelWidth < 13 && this.labelmd == 0){
13495 this.labelmd = this.labelWidth;
13498 if(this.labellg > 0){
13499 labelCfg.cls += ' col-lg-' + this.labellg;
13500 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13503 if(this.labelmd > 0){
13504 labelCfg.cls += ' col-md-' + this.labelmd;
13505 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13508 if(this.labelsm > 0){
13509 labelCfg.cls += ' col-sm-' + this.labelsm;
13510 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13513 if(this.labelxs > 0){
13514 labelCfg.cls += ' col-xs-' + this.labelxs;
13515 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13519 } else if ( this.fieldLabel.length) {
13520 // Roo.log(" label");
13525 //cls : 'input-group-addon',
13526 html : this.fieldLabel
13531 if(this.indicatorpos == 'right'){
13535 //cls : 'input-group-addon',
13536 html : this.fieldLabel
13546 // Roo.log(" no label && no align");
13553 ['xs','sm','md','lg'].map(function(size){
13554 if (settings[size]) {
13555 cfg.cls += ' col-' + size + '-' + settings[size];
13563 _initEventsCalled : false,
13566 initEvents: function()
13568 if (this._initEventsCalled) { // as we call render... prevent looping...
13571 this._initEventsCalled = true;
13574 throw "can not find store for combo";
13577 this.indicator = this.indicatorEl();
13579 this.store = Roo.factory(this.store, Roo.data);
13580 this.store.parent = this;
13582 // if we are building from html. then this element is so complex, that we can not really
13583 // use the rendered HTML.
13584 // so we have to trash and replace the previous code.
13585 if (Roo.XComponent.build_from_html) {
13586 // remove this element....
13587 var e = this.el.dom, k=0;
13588 while (e ) { e = e.previousSibling; ++k;}
13593 this.rendered = false;
13595 this.render(this.parent().getChildContainer(true), k);
13598 if(Roo.isIOS && this.useNativeIOS){
13599 this.initIOSView();
13607 if(Roo.isTouch && this.mobileTouchView){
13608 this.initTouchView();
13613 this.initTickableEvents();
13617 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13619 if(this.hiddenName){
13621 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13623 this.hiddenField.dom.value =
13624 this.hiddenValue !== undefined ? this.hiddenValue :
13625 this.value !== undefined ? this.value : '';
13627 // prevent input submission
13628 this.el.dom.removeAttribute('name');
13629 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13634 // this.el.dom.setAttribute('autocomplete', 'off');
13637 var cls = 'x-combo-list';
13639 //this.list = new Roo.Layer({
13640 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13646 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13647 _this.list.setWidth(lw);
13650 this.list.on('mouseover', this.onViewOver, this);
13651 this.list.on('mousemove', this.onViewMove, this);
13652 this.list.on('scroll', this.onViewScroll, this);
13655 this.list.swallowEvent('mousewheel');
13656 this.assetHeight = 0;
13659 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13660 this.assetHeight += this.header.getHeight();
13663 this.innerList = this.list.createChild({cls:cls+'-inner'});
13664 this.innerList.on('mouseover', this.onViewOver, this);
13665 this.innerList.on('mousemove', this.onViewMove, this);
13666 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13668 if(this.allowBlank && !this.pageSize && !this.disableClear){
13669 this.footer = this.list.createChild({cls:cls+'-ft'});
13670 this.pageTb = new Roo.Toolbar(this.footer);
13674 this.footer = this.list.createChild({cls:cls+'-ft'});
13675 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13676 {pageSize: this.pageSize});
13680 if (this.pageTb && this.allowBlank && !this.disableClear) {
13682 this.pageTb.add(new Roo.Toolbar.Fill(), {
13683 cls: 'x-btn-icon x-btn-clear',
13685 handler: function()
13688 _this.clearValue();
13689 _this.onSelect(false, -1);
13694 this.assetHeight += this.footer.getHeight();
13699 this.tpl = Roo.bootstrap.version == 4 ?
13700 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13701 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13704 this.view = new Roo.View(this.list, this.tpl, {
13705 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13707 //this.view.wrapEl.setDisplayed(false);
13708 this.view.on('click', this.onViewClick, this);
13711 this.store.on('beforeload', this.onBeforeLoad, this);
13712 this.store.on('load', this.onLoad, this);
13713 this.store.on('loadexception', this.onLoadException, this);
13715 if(this.resizable){
13716 this.resizer = new Roo.Resizable(this.list, {
13717 pinned:true, handles:'se'
13719 this.resizer.on('resize', function(r, w, h){
13720 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13721 this.listWidth = w;
13722 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13723 this.restrictHeight();
13725 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13728 if(!this.editable){
13729 this.editable = true;
13730 this.setEditable(false);
13735 if (typeof(this.events.add.listeners) != 'undefined') {
13737 this.addicon = this.wrap.createChild(
13738 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13740 this.addicon.on('click', function(e) {
13741 this.fireEvent('add', this);
13744 if (typeof(this.events.edit.listeners) != 'undefined') {
13746 this.editicon = this.wrap.createChild(
13747 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13748 if (this.addicon) {
13749 this.editicon.setStyle('margin-left', '40px');
13751 this.editicon.on('click', function(e) {
13753 // we fire even if inothing is selected..
13754 this.fireEvent('edit', this, this.lastData );
13760 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13761 "up" : function(e){
13762 this.inKeyMode = true;
13766 "down" : function(e){
13767 if(!this.isExpanded()){
13768 this.onTriggerClick();
13770 this.inKeyMode = true;
13775 "enter" : function(e){
13776 // this.onViewClick();
13780 if(this.fireEvent("specialkey", this, e)){
13781 this.onViewClick(false);
13787 "esc" : function(e){
13791 "tab" : function(e){
13794 if(this.fireEvent("specialkey", this, e)){
13795 this.onViewClick(false);
13803 doRelay : function(foo, bar, hname){
13804 if(hname == 'down' || this.scope.isExpanded()){
13805 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13814 this.queryDelay = Math.max(this.queryDelay || 10,
13815 this.mode == 'local' ? 10 : 250);
13818 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13820 if(this.typeAhead){
13821 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13823 if(this.editable !== false){
13824 this.inputEl().on("keyup", this.onKeyUp, this);
13826 if(this.forceSelection){
13827 this.inputEl().on('blur', this.doForce, this);
13831 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13832 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13836 initTickableEvents: function()
13840 if(this.hiddenName){
13842 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13844 this.hiddenField.dom.value =
13845 this.hiddenValue !== undefined ? this.hiddenValue :
13846 this.value !== undefined ? this.value : '';
13848 // prevent input submission
13849 this.el.dom.removeAttribute('name');
13850 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13855 // this.list = this.el.select('ul.dropdown-menu',true).first();
13857 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13858 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13859 if(this.triggerList){
13860 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13863 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13864 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13866 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13867 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13869 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13870 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13872 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13873 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13874 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13877 this.cancelBtn.hide();
13882 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13883 _this.list.setWidth(lw);
13886 this.list.on('mouseover', this.onViewOver, this);
13887 this.list.on('mousemove', this.onViewMove, this);
13889 this.list.on('scroll', this.onViewScroll, this);
13892 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
13893 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13896 this.view = new Roo.View(this.list, this.tpl, {
13901 selectedClass: this.selectedClass
13904 //this.view.wrapEl.setDisplayed(false);
13905 this.view.on('click', this.onViewClick, this);
13909 this.store.on('beforeload', this.onBeforeLoad, this);
13910 this.store.on('load', this.onLoad, this);
13911 this.store.on('loadexception', this.onLoadException, this);
13914 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13915 "up" : function(e){
13916 this.inKeyMode = true;
13920 "down" : function(e){
13921 this.inKeyMode = true;
13925 "enter" : function(e){
13926 if(this.fireEvent("specialkey", this, e)){
13927 this.onViewClick(false);
13933 "esc" : function(e){
13934 this.onTickableFooterButtonClick(e, false, false);
13937 "tab" : function(e){
13938 this.fireEvent("specialkey", this, e);
13940 this.onTickableFooterButtonClick(e, false, false);
13947 doRelay : function(e, fn, key){
13948 if(this.scope.isExpanded()){
13949 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13958 this.queryDelay = Math.max(this.queryDelay || 10,
13959 this.mode == 'local' ? 10 : 250);
13962 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13964 if(this.typeAhead){
13965 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13968 if(this.editable !== false){
13969 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13972 this.indicator = this.indicatorEl();
13974 if(this.indicator){
13975 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13976 this.indicator.hide();
13981 onDestroy : function(){
13983 this.view.setStore(null);
13984 this.view.el.removeAllListeners();
13985 this.view.el.remove();
13986 this.view.purgeListeners();
13989 this.list.dom.innerHTML = '';
13993 this.store.un('beforeload', this.onBeforeLoad, this);
13994 this.store.un('load', this.onLoad, this);
13995 this.store.un('loadexception', this.onLoadException, this);
13997 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14001 fireKey : function(e){
14002 if(e.isNavKeyPress() && !this.list.isVisible()){
14003 this.fireEvent("specialkey", this, e);
14008 onResize: function(w, h){
14009 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14011 // if(typeof w != 'number'){
14012 // // we do not handle it!?!?
14015 // var tw = this.trigger.getWidth();
14016 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14017 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14019 // this.inputEl().setWidth( this.adjustWidth('input', x));
14021 // //this.trigger.setStyle('left', x+'px');
14023 // if(this.list && this.listWidth === undefined){
14024 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14025 // this.list.setWidth(lw);
14026 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14034 * Allow or prevent the user from directly editing the field text. If false is passed,
14035 * the user will only be able to select from the items defined in the dropdown list. This method
14036 * is the runtime equivalent of setting the 'editable' config option at config time.
14037 * @param {Boolean} value True to allow the user to directly edit the field text
14039 setEditable : function(value){
14040 if(value == this.editable){
14043 this.editable = value;
14045 this.inputEl().dom.setAttribute('readOnly', true);
14046 this.inputEl().on('mousedown', this.onTriggerClick, this);
14047 this.inputEl().addClass('x-combo-noedit');
14049 this.inputEl().dom.setAttribute('readOnly', false);
14050 this.inputEl().un('mousedown', this.onTriggerClick, this);
14051 this.inputEl().removeClass('x-combo-noedit');
14057 onBeforeLoad : function(combo,opts){
14058 if(!this.hasFocus){
14062 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14064 this.restrictHeight();
14065 this.selectedIndex = -1;
14069 onLoad : function(){
14071 this.hasQuery = false;
14073 if(!this.hasFocus){
14077 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14078 this.loading.hide();
14081 if(this.store.getCount() > 0){
14084 this.restrictHeight();
14085 if(this.lastQuery == this.allQuery){
14086 if(this.editable && !this.tickable){
14087 this.inputEl().dom.select();
14091 !this.selectByValue(this.value, true) &&
14094 !this.store.lastOptions ||
14095 typeof(this.store.lastOptions.add) == 'undefined' ||
14096 this.store.lastOptions.add != true
14099 this.select(0, true);
14102 if(this.autoFocus){
14105 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14106 this.taTask.delay(this.typeAheadDelay);
14110 this.onEmptyResults();
14116 onLoadException : function()
14118 this.hasQuery = false;
14120 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14121 this.loading.hide();
14124 if(this.tickable && this.editable){
14129 // only causes errors at present
14130 //Roo.log(this.store.reader.jsonData);
14131 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14133 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14139 onTypeAhead : function(){
14140 if(this.store.getCount() > 0){
14141 var r = this.store.getAt(0);
14142 var newValue = r.data[this.displayField];
14143 var len = newValue.length;
14144 var selStart = this.getRawValue().length;
14146 if(selStart != len){
14147 this.setRawValue(newValue);
14148 this.selectText(selStart, newValue.length);
14154 onSelect : function(record, index){
14156 if(this.fireEvent('beforeselect', this, record, index) !== false){
14158 this.setFromData(index > -1 ? record.data : false);
14161 this.fireEvent('select', this, record, index);
14166 * Returns the currently selected field value or empty string if no value is set.
14167 * @return {String} value The selected value
14169 getValue : function()
14171 if(Roo.isIOS && this.useNativeIOS){
14172 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14176 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14179 if(this.valueField){
14180 return typeof this.value != 'undefined' ? this.value : '';
14182 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14186 getRawValue : function()
14188 if(Roo.isIOS && this.useNativeIOS){
14189 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14192 var v = this.inputEl().getValue();
14198 * Clears any text/value currently set in the field
14200 clearValue : function(){
14202 if(this.hiddenField){
14203 this.hiddenField.dom.value = '';
14206 this.setRawValue('');
14207 this.lastSelectionText = '';
14208 this.lastData = false;
14210 var close = this.closeTriggerEl();
14221 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14222 * will be displayed in the field. If the value does not match the data value of an existing item,
14223 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14224 * Otherwise the field will be blank (although the value will still be set).
14225 * @param {String} value The value to match
14227 setValue : function(v)
14229 if(Roo.isIOS && this.useNativeIOS){
14230 this.setIOSValue(v);
14240 if(this.valueField){
14241 var r = this.findRecord(this.valueField, v);
14243 text = r.data[this.displayField];
14244 }else if(this.valueNotFoundText !== undefined){
14245 text = this.valueNotFoundText;
14248 this.lastSelectionText = text;
14249 if(this.hiddenField){
14250 this.hiddenField.dom.value = v;
14252 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14255 var close = this.closeTriggerEl();
14258 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14264 * @property {Object} the last set data for the element
14269 * Sets the value of the field based on a object which is related to the record format for the store.
14270 * @param {Object} value the value to set as. or false on reset?
14272 setFromData : function(o){
14279 var dv = ''; // display value
14280 var vv = ''; // value value..
14282 if (this.displayField) {
14283 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14285 // this is an error condition!!!
14286 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14289 if(this.valueField){
14290 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14293 var close = this.closeTriggerEl();
14296 if(dv.length || vv * 1 > 0){
14298 this.blockFocus=true;
14304 if(this.hiddenField){
14305 this.hiddenField.dom.value = vv;
14307 this.lastSelectionText = dv;
14308 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14312 // no hidden field.. - we store the value in 'value', but still display
14313 // display field!!!!
14314 this.lastSelectionText = dv;
14315 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14322 reset : function(){
14323 // overridden so that last data is reset..
14330 this.setValue(this.originalValue);
14331 //this.clearInvalid();
14332 this.lastData = false;
14334 this.view.clearSelections();
14340 findRecord : function(prop, value){
14342 if(this.store.getCount() > 0){
14343 this.store.each(function(r){
14344 if(r.data[prop] == value){
14354 getName: function()
14356 // returns hidden if it's set..
14357 if (!this.rendered) {return ''};
14358 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14362 onViewMove : function(e, t){
14363 this.inKeyMode = false;
14367 onViewOver : function(e, t){
14368 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14371 var item = this.view.findItemFromChild(t);
14374 var index = this.view.indexOf(item);
14375 this.select(index, false);
14380 onViewClick : function(view, doFocus, el, e)
14382 var index = this.view.getSelectedIndexes()[0];
14384 var r = this.store.getAt(index);
14388 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14395 Roo.each(this.tickItems, function(v,k){
14397 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14399 _this.tickItems.splice(k, 1);
14401 if(typeof(e) == 'undefined' && view == false){
14402 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14414 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14415 this.tickItems.push(r.data);
14418 if(typeof(e) == 'undefined' && view == false){
14419 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14426 this.onSelect(r, index);
14428 if(doFocus !== false && !this.blockFocus){
14429 this.inputEl().focus();
14434 restrictHeight : function(){
14435 //this.innerList.dom.style.height = '';
14436 //var inner = this.innerList.dom;
14437 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14438 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14439 //this.list.beginUpdate();
14440 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14441 this.list.alignTo(this.inputEl(), this.listAlign);
14442 this.list.alignTo(this.inputEl(), this.listAlign);
14443 //this.list.endUpdate();
14447 onEmptyResults : function(){
14449 if(this.tickable && this.editable){
14450 this.hasFocus = false;
14451 this.restrictHeight();
14459 * Returns true if the dropdown list is expanded, else false.
14461 isExpanded : function(){
14462 return this.list.isVisible();
14466 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14467 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14468 * @param {String} value The data value of the item to select
14469 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14470 * selected item if it is not currently in view (defaults to true)
14471 * @return {Boolean} True if the value matched an item in the list, else false
14473 selectByValue : function(v, scrollIntoView){
14474 if(v !== undefined && v !== null){
14475 var r = this.findRecord(this.valueField || this.displayField, v);
14477 this.select(this.store.indexOf(r), scrollIntoView);
14485 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14486 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14487 * @param {Number} index The zero-based index of the list item to select
14488 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14489 * selected item if it is not currently in view (defaults to true)
14491 select : function(index, scrollIntoView){
14492 this.selectedIndex = index;
14493 this.view.select(index);
14494 if(scrollIntoView !== false){
14495 var el = this.view.getNode(index);
14497 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14500 this.list.scrollChildIntoView(el, false);
14506 selectNext : function(){
14507 var ct = this.store.getCount();
14509 if(this.selectedIndex == -1){
14511 }else if(this.selectedIndex < ct-1){
14512 this.select(this.selectedIndex+1);
14518 selectPrev : function(){
14519 var ct = this.store.getCount();
14521 if(this.selectedIndex == -1){
14523 }else if(this.selectedIndex != 0){
14524 this.select(this.selectedIndex-1);
14530 onKeyUp : function(e){
14531 if(this.editable !== false && !e.isSpecialKey()){
14532 this.lastKey = e.getKey();
14533 this.dqTask.delay(this.queryDelay);
14538 validateBlur : function(){
14539 return !this.list || !this.list.isVisible();
14543 initQuery : function(){
14545 var v = this.getRawValue();
14547 if(this.tickable && this.editable){
14548 v = this.tickableInputEl().getValue();
14555 doForce : function(){
14556 if(this.inputEl().dom.value.length > 0){
14557 this.inputEl().dom.value =
14558 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14564 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14565 * query allowing the query action to be canceled if needed.
14566 * @param {String} query The SQL query to execute
14567 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14568 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14569 * saved in the current store (defaults to false)
14571 doQuery : function(q, forceAll){
14573 if(q === undefined || q === null){
14578 forceAll: forceAll,
14582 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14587 forceAll = qe.forceAll;
14588 if(forceAll === true || (q.length >= this.minChars)){
14590 this.hasQuery = true;
14592 if(this.lastQuery != q || this.alwaysQuery){
14593 this.lastQuery = q;
14594 if(this.mode == 'local'){
14595 this.selectedIndex = -1;
14597 this.store.clearFilter();
14600 if(this.specialFilter){
14601 this.fireEvent('specialfilter', this);
14606 this.store.filter(this.displayField, q);
14609 this.store.fireEvent("datachanged", this.store);
14616 this.store.baseParams[this.queryParam] = q;
14618 var options = {params : this.getParams(q)};
14621 options.add = true;
14622 options.params.start = this.page * this.pageSize;
14625 this.store.load(options);
14628 * this code will make the page width larger, at the beginning, the list not align correctly,
14629 * we should expand the list on onLoad
14630 * so command out it
14635 this.selectedIndex = -1;
14640 this.loadNext = false;
14644 getParams : function(q){
14646 //p[this.queryParam] = q;
14650 p.limit = this.pageSize;
14656 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14658 collapse : function(){
14659 if(!this.isExpanded()){
14665 this.hasFocus = false;
14669 this.cancelBtn.hide();
14670 this.trigger.show();
14673 this.tickableInputEl().dom.value = '';
14674 this.tickableInputEl().blur();
14679 Roo.get(document).un('mousedown', this.collapseIf, this);
14680 Roo.get(document).un('mousewheel', this.collapseIf, this);
14681 if (!this.editable) {
14682 Roo.get(document).un('keydown', this.listKeyPress, this);
14684 this.fireEvent('collapse', this);
14690 collapseIf : function(e){
14691 var in_combo = e.within(this.el);
14692 var in_list = e.within(this.list);
14693 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14695 if (in_combo || in_list || is_list) {
14696 //e.stopPropagation();
14701 this.onTickableFooterButtonClick(e, false, false);
14709 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14711 expand : function(){
14713 if(this.isExpanded() || !this.hasFocus){
14717 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14718 this.list.setWidth(lw);
14724 this.restrictHeight();
14728 this.tickItems = Roo.apply([], this.item);
14731 this.cancelBtn.show();
14732 this.trigger.hide();
14735 this.tickableInputEl().focus();
14740 Roo.get(document).on('mousedown', this.collapseIf, this);
14741 Roo.get(document).on('mousewheel', this.collapseIf, this);
14742 if (!this.editable) {
14743 Roo.get(document).on('keydown', this.listKeyPress, this);
14746 this.fireEvent('expand', this);
14750 // Implements the default empty TriggerField.onTriggerClick function
14751 onTriggerClick : function(e)
14753 Roo.log('trigger click');
14755 if(this.disabled || !this.triggerList){
14760 this.loadNext = false;
14762 if(this.isExpanded()){
14764 if (!this.blockFocus) {
14765 this.inputEl().focus();
14769 this.hasFocus = true;
14770 if(this.triggerAction == 'all') {
14771 this.doQuery(this.allQuery, true);
14773 this.doQuery(this.getRawValue());
14775 if (!this.blockFocus) {
14776 this.inputEl().focus();
14781 onTickableTriggerClick : function(e)
14788 this.loadNext = false;
14789 this.hasFocus = true;
14791 if(this.triggerAction == 'all') {
14792 this.doQuery(this.allQuery, true);
14794 this.doQuery(this.getRawValue());
14798 onSearchFieldClick : function(e)
14800 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14801 this.onTickableFooterButtonClick(e, false, false);
14805 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14810 this.loadNext = false;
14811 this.hasFocus = true;
14813 if(this.triggerAction == 'all') {
14814 this.doQuery(this.allQuery, true);
14816 this.doQuery(this.getRawValue());
14820 listKeyPress : function(e)
14822 //Roo.log('listkeypress');
14823 // scroll to first matching element based on key pres..
14824 if (e.isSpecialKey()) {
14827 var k = String.fromCharCode(e.getKey()).toUpperCase();
14830 var csel = this.view.getSelectedNodes();
14831 var cselitem = false;
14833 var ix = this.view.indexOf(csel[0]);
14834 cselitem = this.store.getAt(ix);
14835 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14841 this.store.each(function(v) {
14843 // start at existing selection.
14844 if (cselitem.id == v.id) {
14850 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14851 match = this.store.indexOf(v);
14857 if (match === false) {
14858 return true; // no more action?
14861 this.view.select(match);
14862 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14863 sn.scrollIntoView(sn.dom.parentNode, false);
14866 onViewScroll : function(e, t){
14868 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){
14872 this.hasQuery = true;
14874 this.loading = this.list.select('.loading', true).first();
14876 if(this.loading === null){
14877 this.list.createChild({
14879 cls: 'loading roo-select2-more-results roo-select2-active',
14880 html: 'Loading more results...'
14883 this.loading = this.list.select('.loading', true).first();
14885 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14887 this.loading.hide();
14890 this.loading.show();
14895 this.loadNext = true;
14897 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14902 addItem : function(o)
14904 var dv = ''; // display value
14906 if (this.displayField) {
14907 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14909 // this is an error condition!!!
14910 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14917 var choice = this.choices.createChild({
14919 cls: 'roo-select2-search-choice',
14928 cls: 'roo-select2-search-choice-close fa fa-times',
14933 }, this.searchField);
14935 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14937 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14945 this.inputEl().dom.value = '';
14950 onRemoveItem : function(e, _self, o)
14952 e.preventDefault();
14954 this.lastItem = Roo.apply([], this.item);
14956 var index = this.item.indexOf(o.data) * 1;
14959 Roo.log('not this item?!');
14963 this.item.splice(index, 1);
14968 this.fireEvent('remove', this, e);
14974 syncValue : function()
14976 if(!this.item.length){
14983 Roo.each(this.item, function(i){
14984 if(_this.valueField){
14985 value.push(i[_this.valueField]);
14992 this.value = value.join(',');
14994 if(this.hiddenField){
14995 this.hiddenField.dom.value = this.value;
14998 this.store.fireEvent("datachanged", this.store);
15003 clearItem : function()
15005 if(!this.multiple){
15011 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15019 if(this.tickable && !Roo.isTouch){
15020 this.view.refresh();
15024 inputEl: function ()
15026 if(Roo.isIOS && this.useNativeIOS){
15027 return this.el.select('select.roo-ios-select', true).first();
15030 if(Roo.isTouch && this.mobileTouchView){
15031 return this.el.select('input.form-control',true).first();
15035 return this.searchField;
15038 return this.el.select('input.form-control',true).first();
15041 onTickableFooterButtonClick : function(e, btn, el)
15043 e.preventDefault();
15045 this.lastItem = Roo.apply([], this.item);
15047 if(btn && btn.name == 'cancel'){
15048 this.tickItems = Roo.apply([], this.item);
15057 Roo.each(this.tickItems, function(o){
15065 validate : function()
15067 if(this.getVisibilityEl().hasClass('hidden')){
15071 var v = this.getRawValue();
15074 v = this.getValue();
15077 if(this.disabled || this.allowBlank || v.length){
15082 this.markInvalid();
15086 tickableInputEl : function()
15088 if(!this.tickable || !this.editable){
15089 return this.inputEl();
15092 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15096 getAutoCreateTouchView : function()
15101 cls: 'form-group' //input-group
15107 type : this.inputType,
15108 cls : 'form-control x-combo-noedit',
15109 autocomplete: 'new-password',
15110 placeholder : this.placeholder || '',
15115 input.name = this.name;
15119 input.cls += ' input-' + this.size;
15122 if (this.disabled) {
15123 input.disabled = true;
15134 inputblock.cls += ' input-group';
15136 inputblock.cn.unshift({
15138 cls : 'input-group-addon input-group-prepend input-group-text',
15143 if(this.removable && !this.multiple){
15144 inputblock.cls += ' roo-removable';
15146 inputblock.cn.push({
15149 cls : 'roo-combo-removable-btn close'
15153 if(this.hasFeedback && !this.allowBlank){
15155 inputblock.cls += ' has-feedback';
15157 inputblock.cn.push({
15159 cls: 'glyphicon form-control-feedback'
15166 inputblock.cls += (this.before) ? '' : ' input-group';
15168 inputblock.cn.push({
15170 cls : 'input-group-addon input-group-append input-group-text',
15176 var ibwrap = inputblock;
15181 cls: 'roo-select2-choices',
15185 cls: 'roo-select2-search-field',
15198 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15203 cls: 'form-hidden-field'
15209 if(!this.multiple && this.showToggleBtn){
15216 if (this.caret != false) {
15219 cls: 'fa fa-' + this.caret
15226 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15231 cls: 'combobox-clear',
15245 combobox.cls += ' roo-select2-container-multi';
15248 var align = this.labelAlign || this.parentLabelAlign();
15250 if (align ==='left' && this.fieldLabel.length) {
15255 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15256 tooltip : 'This field is required'
15260 cls : 'control-label col-form-label',
15261 html : this.fieldLabel
15272 var labelCfg = cfg.cn[1];
15273 var contentCfg = cfg.cn[2];
15276 if(this.indicatorpos == 'right'){
15281 cls : 'control-label col-form-label',
15285 html : this.fieldLabel
15289 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15290 tooltip : 'This field is required'
15303 labelCfg = cfg.cn[0];
15304 contentCfg = cfg.cn[1];
15309 if(this.labelWidth > 12){
15310 labelCfg.style = "width: " + this.labelWidth + 'px';
15313 if(this.labelWidth < 13 && this.labelmd == 0){
15314 this.labelmd = this.labelWidth;
15317 if(this.labellg > 0){
15318 labelCfg.cls += ' col-lg-' + this.labellg;
15319 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15322 if(this.labelmd > 0){
15323 labelCfg.cls += ' col-md-' + this.labelmd;
15324 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15327 if(this.labelsm > 0){
15328 labelCfg.cls += ' col-sm-' + this.labelsm;
15329 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15332 if(this.labelxs > 0){
15333 labelCfg.cls += ' col-xs-' + this.labelxs;
15334 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15338 } else if ( this.fieldLabel.length) {
15342 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15343 tooltip : 'This field is required'
15347 cls : 'control-label',
15348 html : this.fieldLabel
15359 if(this.indicatorpos == 'right'){
15363 cls : 'control-label',
15364 html : this.fieldLabel,
15368 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15369 tooltip : 'This field is required'
15386 var settings = this;
15388 ['xs','sm','md','lg'].map(function(size){
15389 if (settings[size]) {
15390 cfg.cls += ' col-' + size + '-' + settings[size];
15397 initTouchView : function()
15399 this.renderTouchView();
15401 this.touchViewEl.on('scroll', function(){
15402 this.el.dom.scrollTop = 0;
15405 this.originalValue = this.getValue();
15407 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15409 this.inputEl().on("click", this.showTouchView, this);
15410 if (this.triggerEl) {
15411 this.triggerEl.on("click", this.showTouchView, this);
15415 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15416 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15418 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15420 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15421 this.store.on('load', this.onTouchViewLoad, this);
15422 this.store.on('loadexception', this.onTouchViewLoadException, this);
15424 if(this.hiddenName){
15426 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15428 this.hiddenField.dom.value =
15429 this.hiddenValue !== undefined ? this.hiddenValue :
15430 this.value !== undefined ? this.value : '';
15432 this.el.dom.removeAttribute('name');
15433 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15437 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15438 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15441 if(this.removable && !this.multiple){
15442 var close = this.closeTriggerEl();
15444 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15445 close.on('click', this.removeBtnClick, this, close);
15449 * fix the bug in Safari iOS8
15451 this.inputEl().on("focus", function(e){
15452 document.activeElement.blur();
15455 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15462 renderTouchView : function()
15464 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15465 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15467 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15468 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15470 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15471 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15472 this.touchViewBodyEl.setStyle('overflow', 'auto');
15474 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15475 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15477 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15478 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15482 showTouchView : function()
15488 this.touchViewHeaderEl.hide();
15490 if(this.modalTitle.length){
15491 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15492 this.touchViewHeaderEl.show();
15495 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15496 this.touchViewEl.show();
15498 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15500 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15501 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15503 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15505 if(this.modalTitle.length){
15506 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15509 this.touchViewBodyEl.setHeight(bodyHeight);
15513 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15515 this.touchViewEl.addClass('in');
15518 if(this._touchViewMask){
15519 Roo.get(document.body).addClass("x-body-masked");
15520 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15521 this._touchViewMask.setStyle('z-index', 10000);
15522 this._touchViewMask.addClass('show');
15525 this.doTouchViewQuery();
15529 hideTouchView : function()
15531 this.touchViewEl.removeClass('in');
15535 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15537 this.touchViewEl.setStyle('display', 'none');
15540 if(this._touchViewMask){
15541 this._touchViewMask.removeClass('show');
15542 Roo.get(document.body).removeClass("x-body-masked");
15546 setTouchViewValue : function()
15553 Roo.each(this.tickItems, function(o){
15558 this.hideTouchView();
15561 doTouchViewQuery : function()
15570 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15574 if(!this.alwaysQuery || this.mode == 'local'){
15575 this.onTouchViewLoad();
15582 onTouchViewBeforeLoad : function(combo,opts)
15588 onTouchViewLoad : function()
15590 if(this.store.getCount() < 1){
15591 this.onTouchViewEmptyResults();
15595 this.clearTouchView();
15597 var rawValue = this.getRawValue();
15599 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15601 this.tickItems = [];
15603 this.store.data.each(function(d, rowIndex){
15604 var row = this.touchViewListGroup.createChild(template);
15606 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15607 row.addClass(d.data.cls);
15610 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15613 html : d.data[this.displayField]
15616 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15617 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15620 row.removeClass('selected');
15621 if(!this.multiple && this.valueField &&
15622 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15625 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15626 row.addClass('selected');
15629 if(this.multiple && this.valueField &&
15630 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15634 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15635 this.tickItems.push(d.data);
15638 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15642 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15644 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15646 if(this.modalTitle.length){
15647 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15650 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15652 if(this.mobile_restrict_height && listHeight < bodyHeight){
15653 this.touchViewBodyEl.setHeight(listHeight);
15658 if(firstChecked && listHeight > bodyHeight){
15659 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15664 onTouchViewLoadException : function()
15666 this.hideTouchView();
15669 onTouchViewEmptyResults : function()
15671 this.clearTouchView();
15673 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15675 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15679 clearTouchView : function()
15681 this.touchViewListGroup.dom.innerHTML = '';
15684 onTouchViewClick : function(e, el, o)
15686 e.preventDefault();
15689 var rowIndex = o.rowIndex;
15691 var r = this.store.getAt(rowIndex);
15693 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15695 if(!this.multiple){
15696 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15697 c.dom.removeAttribute('checked');
15700 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15702 this.setFromData(r.data);
15704 var close = this.closeTriggerEl();
15710 this.hideTouchView();
15712 this.fireEvent('select', this, r, rowIndex);
15717 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15718 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15719 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15723 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15724 this.addItem(r.data);
15725 this.tickItems.push(r.data);
15729 getAutoCreateNativeIOS : function()
15732 cls: 'form-group' //input-group,
15737 cls : 'roo-ios-select'
15741 combobox.name = this.name;
15744 if (this.disabled) {
15745 combobox.disabled = true;
15748 var settings = this;
15750 ['xs','sm','md','lg'].map(function(size){
15751 if (settings[size]) {
15752 cfg.cls += ' col-' + size + '-' + settings[size];
15762 initIOSView : function()
15764 this.store.on('load', this.onIOSViewLoad, this);
15769 onIOSViewLoad : function()
15771 if(this.store.getCount() < 1){
15775 this.clearIOSView();
15777 if(this.allowBlank) {
15779 var default_text = '-- SELECT --';
15781 if(this.placeholder.length){
15782 default_text = this.placeholder;
15785 if(this.emptyTitle.length){
15786 default_text += ' - ' + this.emptyTitle + ' -';
15789 var opt = this.inputEl().createChild({
15792 html : default_text
15796 o[this.valueField] = 0;
15797 o[this.displayField] = default_text;
15799 this.ios_options.push({
15806 this.store.data.each(function(d, rowIndex){
15810 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15811 html = d.data[this.displayField];
15816 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15817 value = d.data[this.valueField];
15826 if(this.value == d.data[this.valueField]){
15827 option['selected'] = true;
15830 var opt = this.inputEl().createChild(option);
15832 this.ios_options.push({
15839 this.inputEl().on('change', function(){
15840 this.fireEvent('select', this);
15845 clearIOSView: function()
15847 this.inputEl().dom.innerHTML = '';
15849 this.ios_options = [];
15852 setIOSValue: function(v)
15856 if(!this.ios_options){
15860 Roo.each(this.ios_options, function(opts){
15862 opts.el.dom.removeAttribute('selected');
15864 if(opts.data[this.valueField] != v){
15868 opts.el.dom.setAttribute('selected', true);
15874 * @cfg {Boolean} grow
15878 * @cfg {Number} growMin
15882 * @cfg {Number} growMax
15891 Roo.apply(Roo.bootstrap.ComboBox, {
15895 cls: 'modal-header',
15917 cls: 'list-group-item',
15921 cls: 'roo-combobox-list-group-item-value'
15925 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15939 listItemCheckbox : {
15941 cls: 'list-group-item',
15945 cls: 'roo-combobox-list-group-item-value'
15949 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15965 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15970 cls: 'modal-footer',
15978 cls: 'col-xs-6 text-left',
15981 cls: 'btn btn-danger roo-touch-view-cancel',
15987 cls: 'col-xs-6 text-right',
15990 cls: 'btn btn-success roo-touch-view-ok',
16001 Roo.apply(Roo.bootstrap.ComboBox, {
16003 touchViewTemplate : {
16005 cls: 'modal fade roo-combobox-touch-view',
16009 cls: 'modal-dialog',
16010 style : 'position:fixed', // we have to fix position....
16014 cls: 'modal-content',
16016 Roo.bootstrap.ComboBox.header,
16017 Roo.bootstrap.ComboBox.body,
16018 Roo.bootstrap.ComboBox.footer
16027 * Ext JS Library 1.1.1
16028 * Copyright(c) 2006-2007, Ext JS, LLC.
16030 * Originally Released Under LGPL - original licence link has changed is not relivant.
16033 * <script type="text/javascript">
16038 * @extends Roo.util.Observable
16039 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16040 * This class also supports single and multi selection modes. <br>
16041 * Create a data model bound view:
16043 var store = new Roo.data.Store(...);
16045 var view = new Roo.View({
16047 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16049 singleSelect: true,
16050 selectedClass: "ydataview-selected",
16054 // listen for node click?
16055 view.on("click", function(vw, index, node, e){
16056 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16060 dataModel.load("foobar.xml");
16062 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16064 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16065 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16067 * Note: old style constructor is still suported (container, template, config)
16070 * Create a new View
16071 * @param {Object} config The config object
16074 Roo.View = function(config, depreciated_tpl, depreciated_config){
16076 this.parent = false;
16078 if (typeof(depreciated_tpl) == 'undefined') {
16079 // new way.. - universal constructor.
16080 Roo.apply(this, config);
16081 this.el = Roo.get(this.el);
16084 this.el = Roo.get(config);
16085 this.tpl = depreciated_tpl;
16086 Roo.apply(this, depreciated_config);
16088 this.wrapEl = this.el.wrap().wrap();
16089 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16092 if(typeof(this.tpl) == "string"){
16093 this.tpl = new Roo.Template(this.tpl);
16095 // support xtype ctors..
16096 this.tpl = new Roo.factory(this.tpl, Roo);
16100 this.tpl.compile();
16105 * @event beforeclick
16106 * Fires before a click is processed. Returns false to cancel the default action.
16107 * @param {Roo.View} this
16108 * @param {Number} index The index of the target node
16109 * @param {HTMLElement} node The target node
16110 * @param {Roo.EventObject} e The raw event object
16112 "beforeclick" : true,
16115 * Fires when a template node is clicked.
16116 * @param {Roo.View} this
16117 * @param {Number} index The index of the target node
16118 * @param {HTMLElement} node The target node
16119 * @param {Roo.EventObject} e The raw event object
16124 * Fires when a template node is double clicked.
16125 * @param {Roo.View} this
16126 * @param {Number} index The index of the target node
16127 * @param {HTMLElement} node The target node
16128 * @param {Roo.EventObject} e The raw event object
16132 * @event contextmenu
16133 * Fires when a template node is right clicked.
16134 * @param {Roo.View} this
16135 * @param {Number} index The index of the target node
16136 * @param {HTMLElement} node The target node
16137 * @param {Roo.EventObject} e The raw event object
16139 "contextmenu" : true,
16141 * @event selectionchange
16142 * Fires when the selected nodes change.
16143 * @param {Roo.View} this
16144 * @param {Array} selections Array of the selected nodes
16146 "selectionchange" : true,
16149 * @event beforeselect
16150 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16151 * @param {Roo.View} this
16152 * @param {HTMLElement} node The node to be selected
16153 * @param {Array} selections Array of currently selected nodes
16155 "beforeselect" : true,
16157 * @event preparedata
16158 * Fires on every row to render, to allow you to change the data.
16159 * @param {Roo.View} this
16160 * @param {Object} data to be rendered (change this)
16162 "preparedata" : true
16170 "click": this.onClick,
16171 "dblclick": this.onDblClick,
16172 "contextmenu": this.onContextMenu,
16176 this.selections = [];
16178 this.cmp = new Roo.CompositeElementLite([]);
16180 this.store = Roo.factory(this.store, Roo.data);
16181 this.setStore(this.store, true);
16184 if ( this.footer && this.footer.xtype) {
16186 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16188 this.footer.dataSource = this.store;
16189 this.footer.container = fctr;
16190 this.footer = Roo.factory(this.footer, Roo);
16191 fctr.insertFirst(this.el);
16193 // this is a bit insane - as the paging toolbar seems to detach the el..
16194 // dom.parentNode.parentNode.parentNode
16195 // they get detached?
16199 Roo.View.superclass.constructor.call(this);
16204 Roo.extend(Roo.View, Roo.util.Observable, {
16207 * @cfg {Roo.data.Store} store Data store to load data from.
16212 * @cfg {String|Roo.Element} el The container element.
16217 * @cfg {String|Roo.Template} tpl The template used by this View
16221 * @cfg {String} dataName the named area of the template to use as the data area
16222 * Works with domtemplates roo-name="name"
16226 * @cfg {String} selectedClass The css class to add to selected nodes
16228 selectedClass : "x-view-selected",
16230 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16235 * @cfg {String} text to display on mask (default Loading)
16239 * @cfg {Boolean} multiSelect Allow multiple selection
16241 multiSelect : false,
16243 * @cfg {Boolean} singleSelect Allow single selection
16245 singleSelect: false,
16248 * @cfg {Boolean} toggleSelect - selecting
16250 toggleSelect : false,
16253 * @cfg {Boolean} tickable - selecting
16258 * Returns the element this view is bound to.
16259 * @return {Roo.Element}
16261 getEl : function(){
16262 return this.wrapEl;
16268 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16270 refresh : function(){
16271 //Roo.log('refresh');
16274 // if we are using something like 'domtemplate', then
16275 // the what gets used is:
16276 // t.applySubtemplate(NAME, data, wrapping data..)
16277 // the outer template then get' applied with
16278 // the store 'extra data'
16279 // and the body get's added to the
16280 // roo-name="data" node?
16281 // <span class='roo-tpl-{name}'></span> ?????
16285 this.clearSelections();
16286 this.el.update("");
16288 var records = this.store.getRange();
16289 if(records.length < 1) {
16291 // is this valid?? = should it render a template??
16293 this.el.update(this.emptyText);
16297 if (this.dataName) {
16298 this.el.update(t.apply(this.store.meta)); //????
16299 el = this.el.child('.roo-tpl-' + this.dataName);
16302 for(var i = 0, len = records.length; i < len; i++){
16303 var data = this.prepareData(records[i].data, i, records[i]);
16304 this.fireEvent("preparedata", this, data, i, records[i]);
16306 var d = Roo.apply({}, data);
16309 Roo.apply(d, {'roo-id' : Roo.id()});
16313 Roo.each(this.parent.item, function(item){
16314 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16317 Roo.apply(d, {'roo-data-checked' : 'checked'});
16321 html[html.length] = Roo.util.Format.trim(
16323 t.applySubtemplate(this.dataName, d, this.store.meta) :
16330 el.update(html.join(""));
16331 this.nodes = el.dom.childNodes;
16332 this.updateIndexes(0);
16337 * Function to override to reformat the data that is sent to
16338 * the template for each node.
16339 * DEPRICATED - use the preparedata event handler.
16340 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16341 * a JSON object for an UpdateManager bound view).
16343 prepareData : function(data, index, record)
16345 this.fireEvent("preparedata", this, data, index, record);
16349 onUpdate : function(ds, record){
16350 // Roo.log('on update');
16351 this.clearSelections();
16352 var index = this.store.indexOf(record);
16353 var n = this.nodes[index];
16354 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16355 n.parentNode.removeChild(n);
16356 this.updateIndexes(index, index);
16362 onAdd : function(ds, records, index)
16364 //Roo.log(['on Add', ds, records, index] );
16365 this.clearSelections();
16366 if(this.nodes.length == 0){
16370 var n = this.nodes[index];
16371 for(var i = 0, len = records.length; i < len; i++){
16372 var d = this.prepareData(records[i].data, i, records[i]);
16374 this.tpl.insertBefore(n, d);
16377 this.tpl.append(this.el, d);
16380 this.updateIndexes(index);
16383 onRemove : function(ds, record, index){
16384 // Roo.log('onRemove');
16385 this.clearSelections();
16386 var el = this.dataName ?
16387 this.el.child('.roo-tpl-' + this.dataName) :
16390 el.dom.removeChild(this.nodes[index]);
16391 this.updateIndexes(index);
16395 * Refresh an individual node.
16396 * @param {Number} index
16398 refreshNode : function(index){
16399 this.onUpdate(this.store, this.store.getAt(index));
16402 updateIndexes : function(startIndex, endIndex){
16403 var ns = this.nodes;
16404 startIndex = startIndex || 0;
16405 endIndex = endIndex || ns.length - 1;
16406 for(var i = startIndex; i <= endIndex; i++){
16407 ns[i].nodeIndex = i;
16412 * Changes the data store this view uses and refresh the view.
16413 * @param {Store} store
16415 setStore : function(store, initial){
16416 if(!initial && this.store){
16417 this.store.un("datachanged", this.refresh);
16418 this.store.un("add", this.onAdd);
16419 this.store.un("remove", this.onRemove);
16420 this.store.un("update", this.onUpdate);
16421 this.store.un("clear", this.refresh);
16422 this.store.un("beforeload", this.onBeforeLoad);
16423 this.store.un("load", this.onLoad);
16424 this.store.un("loadexception", this.onLoad);
16428 store.on("datachanged", this.refresh, this);
16429 store.on("add", this.onAdd, this);
16430 store.on("remove", this.onRemove, this);
16431 store.on("update", this.onUpdate, this);
16432 store.on("clear", this.refresh, this);
16433 store.on("beforeload", this.onBeforeLoad, this);
16434 store.on("load", this.onLoad, this);
16435 store.on("loadexception", this.onLoad, this);
16443 * onbeforeLoad - masks the loading area.
16446 onBeforeLoad : function(store,opts)
16448 //Roo.log('onBeforeLoad');
16450 this.el.update("");
16452 this.el.mask(this.mask ? this.mask : "Loading" );
16454 onLoad : function ()
16461 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16462 * @param {HTMLElement} node
16463 * @return {HTMLElement} The template node
16465 findItemFromChild : function(node){
16466 var el = this.dataName ?
16467 this.el.child('.roo-tpl-' + this.dataName,true) :
16470 if(!node || node.parentNode == el){
16473 var p = node.parentNode;
16474 while(p && p != el){
16475 if(p.parentNode == el){
16484 onClick : function(e){
16485 var item = this.findItemFromChild(e.getTarget());
16487 var index = this.indexOf(item);
16488 if(this.onItemClick(item, index, e) !== false){
16489 this.fireEvent("click", this, index, item, e);
16492 this.clearSelections();
16497 onContextMenu : function(e){
16498 var item = this.findItemFromChild(e.getTarget());
16500 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16505 onDblClick : function(e){
16506 var item = this.findItemFromChild(e.getTarget());
16508 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16512 onItemClick : function(item, index, e)
16514 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16517 if (this.toggleSelect) {
16518 var m = this.isSelected(item) ? 'unselect' : 'select';
16521 _t[m](item, true, false);
16524 if(this.multiSelect || this.singleSelect){
16525 if(this.multiSelect && e.shiftKey && this.lastSelection){
16526 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16528 this.select(item, this.multiSelect && e.ctrlKey);
16529 this.lastSelection = item;
16532 if(!this.tickable){
16533 e.preventDefault();
16541 * Get the number of selected nodes.
16544 getSelectionCount : function(){
16545 return this.selections.length;
16549 * Get the currently selected nodes.
16550 * @return {Array} An array of HTMLElements
16552 getSelectedNodes : function(){
16553 return this.selections;
16557 * Get the indexes of the selected nodes.
16560 getSelectedIndexes : function(){
16561 var indexes = [], s = this.selections;
16562 for(var i = 0, len = s.length; i < len; i++){
16563 indexes.push(s[i].nodeIndex);
16569 * Clear all selections
16570 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16572 clearSelections : function(suppressEvent){
16573 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16574 this.cmp.elements = this.selections;
16575 this.cmp.removeClass(this.selectedClass);
16576 this.selections = [];
16577 if(!suppressEvent){
16578 this.fireEvent("selectionchange", this, this.selections);
16584 * Returns true if the passed node is selected
16585 * @param {HTMLElement/Number} node The node or node index
16586 * @return {Boolean}
16588 isSelected : function(node){
16589 var s = this.selections;
16593 node = this.getNode(node);
16594 return s.indexOf(node) !== -1;
16599 * @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
16600 * @param {Boolean} keepExisting (optional) true to keep existing selections
16601 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16603 select : function(nodeInfo, keepExisting, suppressEvent){
16604 if(nodeInfo instanceof Array){
16606 this.clearSelections(true);
16608 for(var i = 0, len = nodeInfo.length; i < len; i++){
16609 this.select(nodeInfo[i], true, true);
16613 var node = this.getNode(nodeInfo);
16614 if(!node || this.isSelected(node)){
16615 return; // already selected.
16618 this.clearSelections(true);
16621 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16622 Roo.fly(node).addClass(this.selectedClass);
16623 this.selections.push(node);
16624 if(!suppressEvent){
16625 this.fireEvent("selectionchange", this, this.selections);
16633 * @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
16634 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16635 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16637 unselect : function(nodeInfo, keepExisting, suppressEvent)
16639 if(nodeInfo instanceof Array){
16640 Roo.each(this.selections, function(s) {
16641 this.unselect(s, nodeInfo);
16645 var node = this.getNode(nodeInfo);
16646 if(!node || !this.isSelected(node)){
16647 //Roo.log("not selected");
16648 return; // not selected.
16652 Roo.each(this.selections, function(s) {
16654 Roo.fly(node).removeClass(this.selectedClass);
16661 this.selections= ns;
16662 this.fireEvent("selectionchange", this, this.selections);
16666 * Gets a template node.
16667 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16668 * @return {HTMLElement} The node or null if it wasn't found
16670 getNode : function(nodeInfo){
16671 if(typeof nodeInfo == "string"){
16672 return document.getElementById(nodeInfo);
16673 }else if(typeof nodeInfo == "number"){
16674 return this.nodes[nodeInfo];
16680 * Gets a range template nodes.
16681 * @param {Number} startIndex
16682 * @param {Number} endIndex
16683 * @return {Array} An array of nodes
16685 getNodes : function(start, end){
16686 var ns = this.nodes;
16687 start = start || 0;
16688 end = typeof end == "undefined" ? ns.length - 1 : end;
16691 for(var i = start; i <= end; i++){
16695 for(var i = start; i >= end; i--){
16703 * Finds the index of the passed node
16704 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16705 * @return {Number} The index of the node or -1
16707 indexOf : function(node){
16708 node = this.getNode(node);
16709 if(typeof node.nodeIndex == "number"){
16710 return node.nodeIndex;
16712 var ns = this.nodes;
16713 for(var i = 0, len = ns.length; i < len; i++){
16724 * based on jquery fullcalendar
16728 Roo.bootstrap = Roo.bootstrap || {};
16730 * @class Roo.bootstrap.Calendar
16731 * @extends Roo.bootstrap.Component
16732 * Bootstrap Calendar class
16733 * @cfg {Boolean} loadMask (true|false) default false
16734 * @cfg {Object} header generate the user specific header of the calendar, default false
16737 * Create a new Container
16738 * @param {Object} config The config object
16743 Roo.bootstrap.Calendar = function(config){
16744 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16748 * Fires when a date is selected
16749 * @param {DatePicker} this
16750 * @param {Date} date The selected date
16754 * @event monthchange
16755 * Fires when the displayed month changes
16756 * @param {DatePicker} this
16757 * @param {Date} date The selected month
16759 'monthchange': true,
16761 * @event evententer
16762 * Fires when mouse over an event
16763 * @param {Calendar} this
16764 * @param {event} Event
16766 'evententer': true,
16768 * @event eventleave
16769 * Fires when the mouse leaves an
16770 * @param {Calendar} this
16773 'eventleave': true,
16775 * @event eventclick
16776 * Fires when the mouse click an
16777 * @param {Calendar} this
16786 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16789 * @cfg {Number} startDay
16790 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16798 getAutoCreate : function(){
16801 var fc_button = function(name, corner, style, content ) {
16802 return Roo.apply({},{
16804 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16806 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16809 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16820 style : 'width:100%',
16827 cls : 'fc-header-left',
16829 fc_button('prev', 'left', 'arrow', '‹' ),
16830 fc_button('next', 'right', 'arrow', '›' ),
16831 { tag: 'span', cls: 'fc-header-space' },
16832 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16840 cls : 'fc-header-center',
16844 cls: 'fc-header-title',
16847 html : 'month / year'
16855 cls : 'fc-header-right',
16857 /* fc_button('month', 'left', '', 'month' ),
16858 fc_button('week', '', '', 'week' ),
16859 fc_button('day', 'right', '', 'day' )
16871 header = this.header;
16874 var cal_heads = function() {
16876 // fixme - handle this.
16878 for (var i =0; i < Date.dayNames.length; i++) {
16879 var d = Date.dayNames[i];
16882 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16883 html : d.substring(0,3)
16887 ret[0].cls += ' fc-first';
16888 ret[6].cls += ' fc-last';
16891 var cal_cell = function(n) {
16894 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16899 cls: 'fc-day-number',
16903 cls: 'fc-day-content',
16907 style: 'position: relative;' // height: 17px;
16919 var cal_rows = function() {
16922 for (var r = 0; r < 6; r++) {
16929 for (var i =0; i < Date.dayNames.length; i++) {
16930 var d = Date.dayNames[i];
16931 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16934 row.cn[0].cls+=' fc-first';
16935 row.cn[0].cn[0].style = 'min-height:90px';
16936 row.cn[6].cls+=' fc-last';
16940 ret[0].cls += ' fc-first';
16941 ret[4].cls += ' fc-prev-last';
16942 ret[5].cls += ' fc-last';
16949 cls: 'fc-border-separate',
16950 style : 'width:100%',
16958 cls : 'fc-first fc-last',
16976 cls : 'fc-content',
16977 style : "position: relative;",
16980 cls : 'fc-view fc-view-month fc-grid',
16981 style : 'position: relative',
16982 unselectable : 'on',
16985 cls : 'fc-event-container',
16986 style : 'position:absolute;z-index:8;top:0;left:0;'
17004 initEvents : function()
17007 throw "can not find store for calendar";
17013 style: "text-align:center",
17017 style: "background-color:white;width:50%;margin:250 auto",
17021 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17032 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17034 var size = this.el.select('.fc-content', true).first().getSize();
17035 this.maskEl.setSize(size.width, size.height);
17036 this.maskEl.enableDisplayMode("block");
17037 if(!this.loadMask){
17038 this.maskEl.hide();
17041 this.store = Roo.factory(this.store, Roo.data);
17042 this.store.on('load', this.onLoad, this);
17043 this.store.on('beforeload', this.onBeforeLoad, this);
17047 this.cells = this.el.select('.fc-day',true);
17048 //Roo.log(this.cells);
17049 this.textNodes = this.el.query('.fc-day-number');
17050 this.cells.addClassOnOver('fc-state-hover');
17052 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17053 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17054 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17055 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17057 this.on('monthchange', this.onMonthChange, this);
17059 this.update(new Date().clearTime());
17062 resize : function() {
17063 var sz = this.el.getSize();
17065 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17066 this.el.select('.fc-day-content div',true).setHeight(34);
17071 showPrevMonth : function(e){
17072 this.update(this.activeDate.add("mo", -1));
17074 showToday : function(e){
17075 this.update(new Date().clearTime());
17078 showNextMonth : function(e){
17079 this.update(this.activeDate.add("mo", 1));
17083 showPrevYear : function(){
17084 this.update(this.activeDate.add("y", -1));
17088 showNextYear : function(){
17089 this.update(this.activeDate.add("y", 1));
17094 update : function(date)
17096 var vd = this.activeDate;
17097 this.activeDate = date;
17098 // if(vd && this.el){
17099 // var t = date.getTime();
17100 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17101 // Roo.log('using add remove');
17103 // this.fireEvent('monthchange', this, date);
17105 // this.cells.removeClass("fc-state-highlight");
17106 // this.cells.each(function(c){
17107 // if(c.dateValue == t){
17108 // c.addClass("fc-state-highlight");
17109 // setTimeout(function(){
17110 // try{c.dom.firstChild.focus();}catch(e){}
17120 var days = date.getDaysInMonth();
17122 var firstOfMonth = date.getFirstDateOfMonth();
17123 var startingPos = firstOfMonth.getDay()-this.startDay;
17125 if(startingPos < this.startDay){
17129 var pm = date.add(Date.MONTH, -1);
17130 var prevStart = pm.getDaysInMonth()-startingPos;
17132 this.cells = this.el.select('.fc-day',true);
17133 this.textNodes = this.el.query('.fc-day-number');
17134 this.cells.addClassOnOver('fc-state-hover');
17136 var cells = this.cells.elements;
17137 var textEls = this.textNodes;
17139 Roo.each(cells, function(cell){
17140 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17143 days += startingPos;
17145 // convert everything to numbers so it's fast
17146 var day = 86400000;
17147 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17150 //Roo.log(prevStart);
17152 var today = new Date().clearTime().getTime();
17153 var sel = date.clearTime().getTime();
17154 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17155 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17156 var ddMatch = this.disabledDatesRE;
17157 var ddText = this.disabledDatesText;
17158 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17159 var ddaysText = this.disabledDaysText;
17160 var format = this.format;
17162 var setCellClass = function(cal, cell){
17166 //Roo.log('set Cell Class');
17168 var t = d.getTime();
17172 cell.dateValue = t;
17174 cell.className += " fc-today";
17175 cell.className += " fc-state-highlight";
17176 cell.title = cal.todayText;
17179 // disable highlight in other month..
17180 //cell.className += " fc-state-highlight";
17185 cell.className = " fc-state-disabled";
17186 cell.title = cal.minText;
17190 cell.className = " fc-state-disabled";
17191 cell.title = cal.maxText;
17195 if(ddays.indexOf(d.getDay()) != -1){
17196 cell.title = ddaysText;
17197 cell.className = " fc-state-disabled";
17200 if(ddMatch && format){
17201 var fvalue = d.dateFormat(format);
17202 if(ddMatch.test(fvalue)){
17203 cell.title = ddText.replace("%0", fvalue);
17204 cell.className = " fc-state-disabled";
17208 if (!cell.initialClassName) {
17209 cell.initialClassName = cell.dom.className;
17212 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17217 for(; i < startingPos; i++) {
17218 textEls[i].innerHTML = (++prevStart);
17219 d.setDate(d.getDate()+1);
17221 cells[i].className = "fc-past fc-other-month";
17222 setCellClass(this, cells[i]);
17227 for(; i < days; i++){
17228 intDay = i - startingPos + 1;
17229 textEls[i].innerHTML = (intDay);
17230 d.setDate(d.getDate()+1);
17232 cells[i].className = ''; // "x-date-active";
17233 setCellClass(this, cells[i]);
17237 for(; i < 42; i++) {
17238 textEls[i].innerHTML = (++extraDays);
17239 d.setDate(d.getDate()+1);
17241 cells[i].className = "fc-future fc-other-month";
17242 setCellClass(this, cells[i]);
17245 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17247 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17249 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17250 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17252 if(totalRows != 6){
17253 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17254 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17257 this.fireEvent('monthchange', this, date);
17261 if(!this.internalRender){
17262 var main = this.el.dom.firstChild;
17263 var w = main.offsetWidth;
17264 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17265 Roo.fly(main).setWidth(w);
17266 this.internalRender = true;
17267 // opera does not respect the auto grow header center column
17268 // then, after it gets a width opera refuses to recalculate
17269 // without a second pass
17270 if(Roo.isOpera && !this.secondPass){
17271 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17272 this.secondPass = true;
17273 this.update.defer(10, this, [date]);
17280 findCell : function(dt) {
17281 dt = dt.clearTime().getTime();
17283 this.cells.each(function(c){
17284 //Roo.log("check " +c.dateValue + '?=' + dt);
17285 if(c.dateValue == dt){
17295 findCells : function(ev) {
17296 var s = ev.start.clone().clearTime().getTime();
17298 var e= ev.end.clone().clearTime().getTime();
17301 this.cells.each(function(c){
17302 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17304 if(c.dateValue > e){
17307 if(c.dateValue < s){
17316 // findBestRow: function(cells)
17320 // for (var i =0 ; i < cells.length;i++) {
17321 // ret = Math.max(cells[i].rows || 0,ret);
17328 addItem : function(ev)
17330 // look for vertical location slot in
17331 var cells = this.findCells(ev);
17333 // ev.row = this.findBestRow(cells);
17335 // work out the location.
17339 for(var i =0; i < cells.length; i++) {
17341 cells[i].row = cells[0].row;
17344 cells[i].row = cells[i].row + 1;
17354 if (crow.start.getY() == cells[i].getY()) {
17356 crow.end = cells[i];
17373 cells[0].events.push(ev);
17375 this.calevents.push(ev);
17378 clearEvents: function() {
17380 if(!this.calevents){
17384 Roo.each(this.cells.elements, function(c){
17390 Roo.each(this.calevents, function(e) {
17391 Roo.each(e.els, function(el) {
17392 el.un('mouseenter' ,this.onEventEnter, this);
17393 el.un('mouseleave' ,this.onEventLeave, this);
17398 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17404 renderEvents: function()
17408 this.cells.each(function(c) {
17417 if(c.row != c.events.length){
17418 r = 4 - (4 - (c.row - c.events.length));
17421 c.events = ev.slice(0, r);
17422 c.more = ev.slice(r);
17424 if(c.more.length && c.more.length == 1){
17425 c.events.push(c.more.pop());
17428 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17432 this.cells.each(function(c) {
17434 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17437 for (var e = 0; e < c.events.length; e++){
17438 var ev = c.events[e];
17439 var rows = ev.rows;
17441 for(var i = 0; i < rows.length; i++) {
17443 // how many rows should it span..
17446 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17447 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17449 unselectable : "on",
17452 cls: 'fc-event-inner',
17456 // cls: 'fc-event-time',
17457 // html : cells.length > 1 ? '' : ev.time
17461 cls: 'fc-event-title',
17462 html : String.format('{0}', ev.title)
17469 cls: 'ui-resizable-handle ui-resizable-e',
17470 html : '  '
17477 cfg.cls += ' fc-event-start';
17479 if ((i+1) == rows.length) {
17480 cfg.cls += ' fc-event-end';
17483 var ctr = _this.el.select('.fc-event-container',true).first();
17484 var cg = ctr.createChild(cfg);
17486 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17487 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17489 var r = (c.more.length) ? 1 : 0;
17490 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17491 cg.setWidth(ebox.right - sbox.x -2);
17493 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17494 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17495 cg.on('click', _this.onEventClick, _this, ev);
17506 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17507 style : 'position: absolute',
17508 unselectable : "on",
17511 cls: 'fc-event-inner',
17515 cls: 'fc-event-title',
17523 cls: 'ui-resizable-handle ui-resizable-e',
17524 html : '  '
17530 var ctr = _this.el.select('.fc-event-container',true).first();
17531 var cg = ctr.createChild(cfg);
17533 var sbox = c.select('.fc-day-content',true).first().getBox();
17534 var ebox = c.select('.fc-day-content',true).first().getBox();
17536 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17537 cg.setWidth(ebox.right - sbox.x -2);
17539 cg.on('click', _this.onMoreEventClick, _this, c.more);
17549 onEventEnter: function (e, el,event,d) {
17550 this.fireEvent('evententer', this, el, event);
17553 onEventLeave: function (e, el,event,d) {
17554 this.fireEvent('eventleave', this, el, event);
17557 onEventClick: function (e, el,event,d) {
17558 this.fireEvent('eventclick', this, el, event);
17561 onMonthChange: function () {
17565 onMoreEventClick: function(e, el, more)
17569 this.calpopover.placement = 'right';
17570 this.calpopover.setTitle('More');
17572 this.calpopover.setContent('');
17574 var ctr = this.calpopover.el.select('.popover-content', true).first();
17576 Roo.each(more, function(m){
17578 cls : 'fc-event-hori fc-event-draggable',
17581 var cg = ctr.createChild(cfg);
17583 cg.on('click', _this.onEventClick, _this, m);
17586 this.calpopover.show(el);
17591 onLoad: function ()
17593 this.calevents = [];
17596 if(this.store.getCount() > 0){
17597 this.store.data.each(function(d){
17600 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17601 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17602 time : d.data.start_time,
17603 title : d.data.title,
17604 description : d.data.description,
17605 venue : d.data.venue
17610 this.renderEvents();
17612 if(this.calevents.length && this.loadMask){
17613 this.maskEl.hide();
17617 onBeforeLoad: function()
17619 this.clearEvents();
17621 this.maskEl.show();
17635 * @class Roo.bootstrap.Popover
17636 * @extends Roo.bootstrap.Component
17637 * Bootstrap Popover class
17638 * @cfg {String} html contents of the popover (or false to use children..)
17639 * @cfg {String} title of popover (or false to hide)
17640 * @cfg {String} placement how it is placed
17641 * @cfg {String} trigger click || hover (or false to trigger manually)
17642 * @cfg {String} over what (parent or false to trigger manually.)
17643 * @cfg {Number} delay - delay before showing
17646 * Create a new Popover
17647 * @param {Object} config The config object
17650 Roo.bootstrap.Popover = function(config){
17651 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17657 * After the popover show
17659 * @param {Roo.bootstrap.Popover} this
17664 * After the popover hide
17666 * @param {Roo.bootstrap.Popover} this
17672 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17674 title: 'Fill in a title',
17677 placement : 'right',
17678 trigger : 'hover', // hover
17684 can_build_overlaid : false,
17686 getChildContainer : function()
17688 return this.el.select('.popover-content',true).first();
17691 getAutoCreate : function(){
17694 cls : 'popover roo-dynamic',
17695 style: 'display:block',
17701 cls : 'popover-inner',
17705 cls: 'popover-title popover-header',
17709 cls : 'popover-content popover-body',
17720 setTitle: function(str)
17723 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17725 setContent: function(str)
17728 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17730 // as it get's added to the bottom of the page.
17731 onRender : function(ct, position)
17733 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17735 var cfg = Roo.apply({}, this.getAutoCreate());
17739 cfg.cls += ' ' + this.cls;
17742 cfg.style = this.style;
17744 //Roo.log("adding to ");
17745 this.el = Roo.get(document.body).createChild(cfg, position);
17746 // Roo.log(this.el);
17751 initEvents : function()
17753 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17754 this.el.enableDisplayMode('block');
17756 if (this.over === false) {
17759 if (this.triggers === false) {
17762 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17763 var triggers = this.trigger ? this.trigger.split(' ') : [];
17764 Roo.each(triggers, function(trigger) {
17766 if (trigger == 'click') {
17767 on_el.on('click', this.toggle, this);
17768 } else if (trigger != 'manual') {
17769 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17770 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17772 on_el.on(eventIn ,this.enter, this);
17773 on_el.on(eventOut, this.leave, this);
17784 toggle : function () {
17785 this.hoverState == 'in' ? this.leave() : this.enter();
17788 enter : function () {
17790 clearTimeout(this.timeout);
17792 this.hoverState = 'in';
17794 if (!this.delay || !this.delay.show) {
17799 this.timeout = setTimeout(function () {
17800 if (_t.hoverState == 'in') {
17803 }, this.delay.show)
17806 leave : function() {
17807 clearTimeout(this.timeout);
17809 this.hoverState = 'out';
17811 if (!this.delay || !this.delay.hide) {
17816 this.timeout = setTimeout(function () {
17817 if (_t.hoverState == 'out') {
17820 }, this.delay.hide)
17823 show : function (on_el)
17826 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17830 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17831 if (this.html !== false) {
17832 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17834 this.el.removeClass([
17835 'fade','top','bottom', 'left', 'right','in',
17836 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17838 if (!this.title.length) {
17839 this.el.select('.popover-title',true).hide();
17842 var placement = typeof this.placement == 'function' ?
17843 this.placement.call(this, this.el, on_el) :
17846 var autoToken = /\s?auto?\s?/i;
17847 var autoPlace = autoToken.test(placement);
17849 placement = placement.replace(autoToken, '') || 'top';
17853 //this.el.setXY([0,0]);
17855 this.el.dom.style.display='block';
17856 this.el.addClass(placement);
17858 //this.el.appendTo(on_el);
17860 var p = this.getPosition();
17861 var box = this.el.getBox();
17866 var align = Roo.bootstrap.Popover.alignment[placement];
17869 this.el.alignTo(on_el, align[0],align[1]);
17870 //var arrow = this.el.select('.arrow',true).first();
17871 //arrow.set(align[2],
17873 this.el.addClass('in');
17876 if (this.el.hasClass('fade')) {
17880 this.hoverState = 'in';
17882 this.fireEvent('show', this);
17887 this.el.setXY([0,0]);
17888 this.el.removeClass('in');
17890 this.hoverState = null;
17892 this.fireEvent('hide', this);
17897 Roo.bootstrap.Popover.alignment = {
17898 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
17899 'right' : ['l-r', [10,0], 'left bs-popover-left'],
17900 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
17901 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
17912 * @class Roo.bootstrap.Progress
17913 * @extends Roo.bootstrap.Component
17914 * Bootstrap Progress class
17915 * @cfg {Boolean} striped striped of the progress bar
17916 * @cfg {Boolean} active animated of the progress bar
17920 * Create a new Progress
17921 * @param {Object} config The config object
17924 Roo.bootstrap.Progress = function(config){
17925 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17928 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17933 getAutoCreate : function(){
17941 cfg.cls += ' progress-striped';
17945 cfg.cls += ' active';
17964 * @class Roo.bootstrap.ProgressBar
17965 * @extends Roo.bootstrap.Component
17966 * Bootstrap ProgressBar class
17967 * @cfg {Number} aria_valuenow aria-value now
17968 * @cfg {Number} aria_valuemin aria-value min
17969 * @cfg {Number} aria_valuemax aria-value max
17970 * @cfg {String} label label for the progress bar
17971 * @cfg {String} panel (success | info | warning | danger )
17972 * @cfg {String} role role of the progress bar
17973 * @cfg {String} sr_only text
17977 * Create a new ProgressBar
17978 * @param {Object} config The config object
17981 Roo.bootstrap.ProgressBar = function(config){
17982 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17985 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17989 aria_valuemax : 100,
17995 getAutoCreate : function()
18000 cls: 'progress-bar',
18001 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18013 cfg.role = this.role;
18016 if(this.aria_valuenow){
18017 cfg['aria-valuenow'] = this.aria_valuenow;
18020 if(this.aria_valuemin){
18021 cfg['aria-valuemin'] = this.aria_valuemin;
18024 if(this.aria_valuemax){
18025 cfg['aria-valuemax'] = this.aria_valuemax;
18028 if(this.label && !this.sr_only){
18029 cfg.html = this.label;
18033 cfg.cls += ' progress-bar-' + this.panel;
18039 update : function(aria_valuenow)
18041 this.aria_valuenow = aria_valuenow;
18043 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18058 * @class Roo.bootstrap.TabGroup
18059 * @extends Roo.bootstrap.Column
18060 * Bootstrap Column class
18061 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18062 * @cfg {Boolean} carousel true to make the group behave like a carousel
18063 * @cfg {Boolean} bullets show bullets for the panels
18064 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18065 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18066 * @cfg {Boolean} showarrow (true|false) show arrow default true
18069 * Create a new TabGroup
18070 * @param {Object} config The config object
18073 Roo.bootstrap.TabGroup = function(config){
18074 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18076 this.navId = Roo.id();
18079 Roo.bootstrap.TabGroup.register(this);
18083 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18086 transition : false,
18091 slideOnTouch : false,
18094 getAutoCreate : function()
18096 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18098 cfg.cls += ' tab-content';
18100 if (this.carousel) {
18101 cfg.cls += ' carousel slide';
18104 cls : 'carousel-inner',
18108 if(this.bullets && !Roo.isTouch){
18111 cls : 'carousel-bullets',
18115 if(this.bullets_cls){
18116 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18123 cfg.cn[0].cn.push(bullets);
18126 if(this.showarrow){
18127 cfg.cn[0].cn.push({
18129 class : 'carousel-arrow',
18133 class : 'carousel-prev',
18137 class : 'fa fa-chevron-left'
18143 class : 'carousel-next',
18147 class : 'fa fa-chevron-right'
18160 initEvents: function()
18162 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18163 // this.el.on("touchstart", this.onTouchStart, this);
18166 if(this.autoslide){
18169 this.slideFn = window.setInterval(function() {
18170 _this.showPanelNext();
18174 if(this.showarrow){
18175 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18176 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18182 // onTouchStart : function(e, el, o)
18184 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18188 // this.showPanelNext();
18192 getChildContainer : function()
18194 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18198 * register a Navigation item
18199 * @param {Roo.bootstrap.NavItem} the navitem to add
18201 register : function(item)
18203 this.tabs.push( item);
18204 item.navId = this.navId; // not really needed..
18209 getActivePanel : function()
18212 Roo.each(this.tabs, function(t) {
18222 getPanelByName : function(n)
18225 Roo.each(this.tabs, function(t) {
18226 if (t.tabId == n) {
18234 indexOfPanel : function(p)
18237 Roo.each(this.tabs, function(t,i) {
18238 if (t.tabId == p.tabId) {
18247 * show a specific panel
18248 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18249 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18251 showPanel : function (pan)
18253 if(this.transition || typeof(pan) == 'undefined'){
18254 Roo.log("waiting for the transitionend");
18258 if (typeof(pan) == 'number') {
18259 pan = this.tabs[pan];
18262 if (typeof(pan) == 'string') {
18263 pan = this.getPanelByName(pan);
18266 var cur = this.getActivePanel();
18269 Roo.log('pan or acitve pan is undefined');
18273 if (pan.tabId == this.getActivePanel().tabId) {
18277 if (false === cur.fireEvent('beforedeactivate')) {
18281 if(this.bullets > 0 && !Roo.isTouch){
18282 this.setActiveBullet(this.indexOfPanel(pan));
18285 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18287 this.transition = true;
18288 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18289 var lr = dir == 'next' ? 'left' : 'right';
18290 pan.el.addClass(dir); // or prev
18291 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18292 cur.el.addClass(lr); // or right
18293 pan.el.addClass(lr);
18296 cur.el.on('transitionend', function() {
18297 Roo.log("trans end?");
18299 pan.el.removeClass([lr,dir]);
18300 pan.setActive(true);
18302 cur.el.removeClass([lr]);
18303 cur.setActive(false);
18305 _this.transition = false;
18307 }, this, { single: true } );
18312 cur.setActive(false);
18313 pan.setActive(true);
18318 showPanelNext : function()
18320 var i = this.indexOfPanel(this.getActivePanel());
18322 if (i >= this.tabs.length - 1 && !this.autoslide) {
18326 if (i >= this.tabs.length - 1 && this.autoslide) {
18330 this.showPanel(this.tabs[i+1]);
18333 showPanelPrev : function()
18335 var i = this.indexOfPanel(this.getActivePanel());
18337 if (i < 1 && !this.autoslide) {
18341 if (i < 1 && this.autoslide) {
18342 i = this.tabs.length;
18345 this.showPanel(this.tabs[i-1]);
18349 addBullet: function()
18351 if(!this.bullets || Roo.isTouch){
18354 var ctr = this.el.select('.carousel-bullets',true).first();
18355 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18356 var bullet = ctr.createChild({
18357 cls : 'bullet bullet-' + i
18358 },ctr.dom.lastChild);
18363 bullet.on('click', (function(e, el, o, ii, t){
18365 e.preventDefault();
18367 this.showPanel(ii);
18369 if(this.autoslide && this.slideFn){
18370 clearInterval(this.slideFn);
18371 this.slideFn = window.setInterval(function() {
18372 _this.showPanelNext();
18376 }).createDelegate(this, [i, bullet], true));
18381 setActiveBullet : function(i)
18387 Roo.each(this.el.select('.bullet', true).elements, function(el){
18388 el.removeClass('selected');
18391 var bullet = this.el.select('.bullet-' + i, true).first();
18397 bullet.addClass('selected');
18408 Roo.apply(Roo.bootstrap.TabGroup, {
18412 * register a Navigation Group
18413 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18415 register : function(navgrp)
18417 this.groups[navgrp.navId] = navgrp;
18421 * fetch a Navigation Group based on the navigation ID
18422 * if one does not exist , it will get created.
18423 * @param {string} the navgroup to add
18424 * @returns {Roo.bootstrap.NavGroup} the navgroup
18426 get: function(navId) {
18427 if (typeof(this.groups[navId]) == 'undefined') {
18428 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18430 return this.groups[navId] ;
18445 * @class Roo.bootstrap.TabPanel
18446 * @extends Roo.bootstrap.Component
18447 * Bootstrap TabPanel class
18448 * @cfg {Boolean} active panel active
18449 * @cfg {String} html panel content
18450 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18451 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18452 * @cfg {String} href click to link..
18456 * Create a new TabPanel
18457 * @param {Object} config The config object
18460 Roo.bootstrap.TabPanel = function(config){
18461 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18465 * Fires when the active status changes
18466 * @param {Roo.bootstrap.TabPanel} this
18467 * @param {Boolean} state the new state
18472 * @event beforedeactivate
18473 * Fires before a tab is de-activated - can be used to do validation on a form.
18474 * @param {Roo.bootstrap.TabPanel} this
18475 * @return {Boolean} false if there is an error
18478 'beforedeactivate': true
18481 this.tabId = this.tabId || Roo.id();
18485 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18493 getAutoCreate : function(){
18496 // item is needed for carousel - not sure if it has any effect otherwise
18497 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18498 html: this.html || ''
18502 cfg.cls += ' active';
18506 cfg.tabId = this.tabId;
18513 initEvents: function()
18515 var p = this.parent();
18517 this.navId = this.navId || p.navId;
18519 if (typeof(this.navId) != 'undefined') {
18520 // not really needed.. but just in case.. parent should be a NavGroup.
18521 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18525 var i = tg.tabs.length - 1;
18527 if(this.active && tg.bullets > 0 && i < tg.bullets){
18528 tg.setActiveBullet(i);
18532 this.el.on('click', this.onClick, this);
18535 this.el.on("touchstart", this.onTouchStart, this);
18536 this.el.on("touchmove", this.onTouchMove, this);
18537 this.el.on("touchend", this.onTouchEnd, this);
18542 onRender : function(ct, position)
18544 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18547 setActive : function(state)
18549 Roo.log("panel - set active " + this.tabId + "=" + state);
18551 this.active = state;
18553 this.el.removeClass('active');
18555 } else if (!this.el.hasClass('active')) {
18556 this.el.addClass('active');
18559 this.fireEvent('changed', this, state);
18562 onClick : function(e)
18564 e.preventDefault();
18566 if(!this.href.length){
18570 window.location.href = this.href;
18579 onTouchStart : function(e)
18581 this.swiping = false;
18583 this.startX = e.browserEvent.touches[0].clientX;
18584 this.startY = e.browserEvent.touches[0].clientY;
18587 onTouchMove : function(e)
18589 this.swiping = true;
18591 this.endX = e.browserEvent.touches[0].clientX;
18592 this.endY = e.browserEvent.touches[0].clientY;
18595 onTouchEnd : function(e)
18602 var tabGroup = this.parent();
18604 if(this.endX > this.startX){ // swiping right
18605 tabGroup.showPanelPrev();
18609 if(this.startX > this.endX){ // swiping left
18610 tabGroup.showPanelNext();
18629 * @class Roo.bootstrap.DateField
18630 * @extends Roo.bootstrap.Input
18631 * Bootstrap DateField class
18632 * @cfg {Number} weekStart default 0
18633 * @cfg {String} viewMode default empty, (months|years)
18634 * @cfg {String} minViewMode default empty, (months|years)
18635 * @cfg {Number} startDate default -Infinity
18636 * @cfg {Number} endDate default Infinity
18637 * @cfg {Boolean} todayHighlight default false
18638 * @cfg {Boolean} todayBtn default false
18639 * @cfg {Boolean} calendarWeeks default false
18640 * @cfg {Object} daysOfWeekDisabled default empty
18641 * @cfg {Boolean} singleMode default false (true | false)
18643 * @cfg {Boolean} keyboardNavigation default true
18644 * @cfg {String} language default en
18647 * Create a new DateField
18648 * @param {Object} config The config object
18651 Roo.bootstrap.DateField = function(config){
18652 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18656 * Fires when this field show.
18657 * @param {Roo.bootstrap.DateField} this
18658 * @param {Mixed} date The date value
18663 * Fires when this field hide.
18664 * @param {Roo.bootstrap.DateField} this
18665 * @param {Mixed} date The date value
18670 * Fires when select a date.
18671 * @param {Roo.bootstrap.DateField} this
18672 * @param {Mixed} date The date value
18676 * @event beforeselect
18677 * Fires when before select a date.
18678 * @param {Roo.bootstrap.DateField} this
18679 * @param {Mixed} date The date value
18681 beforeselect : true
18685 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18688 * @cfg {String} format
18689 * The default date format string which can be overriden for localization support. The format must be
18690 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18694 * @cfg {String} altFormats
18695 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18696 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18698 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18706 todayHighlight : false,
18712 keyboardNavigation: true,
18714 calendarWeeks: false,
18716 startDate: -Infinity,
18720 daysOfWeekDisabled: [],
18724 singleMode : false,
18726 UTCDate: function()
18728 return new Date(Date.UTC.apply(Date, arguments));
18731 UTCToday: function()
18733 var today = new Date();
18734 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18737 getDate: function() {
18738 var d = this.getUTCDate();
18739 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18742 getUTCDate: function() {
18746 setDate: function(d) {
18747 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18750 setUTCDate: function(d) {
18752 this.setValue(this.formatDate(this.date));
18755 onRender: function(ct, position)
18758 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18760 this.language = this.language || 'en';
18761 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18762 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18764 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18765 this.format = this.format || 'm/d/y';
18766 this.isInline = false;
18767 this.isInput = true;
18768 this.component = this.el.select('.add-on', true).first() || false;
18769 this.component = (this.component && this.component.length === 0) ? false : this.component;
18770 this.hasInput = this.component && this.inputEl().length;
18772 if (typeof(this.minViewMode === 'string')) {
18773 switch (this.minViewMode) {
18775 this.minViewMode = 1;
18778 this.minViewMode = 2;
18781 this.minViewMode = 0;
18786 if (typeof(this.viewMode === 'string')) {
18787 switch (this.viewMode) {
18800 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18802 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18804 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18806 this.picker().on('mousedown', this.onMousedown, this);
18807 this.picker().on('click', this.onClick, this);
18809 this.picker().addClass('datepicker-dropdown');
18811 this.startViewMode = this.viewMode;
18813 if(this.singleMode){
18814 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18815 v.setVisibilityMode(Roo.Element.DISPLAY);
18819 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18820 v.setStyle('width', '189px');
18824 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18825 if(!this.calendarWeeks){
18830 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18831 v.attr('colspan', function(i, val){
18832 return parseInt(val) + 1;
18837 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18839 this.setStartDate(this.startDate);
18840 this.setEndDate(this.endDate);
18842 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18849 if(this.isInline) {
18854 picker : function()
18856 return this.pickerEl;
18857 // return this.el.select('.datepicker', true).first();
18860 fillDow: function()
18862 var dowCnt = this.weekStart;
18871 if(this.calendarWeeks){
18879 while (dowCnt < this.weekStart + 7) {
18883 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18887 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18890 fillMonths: function()
18893 var months = this.picker().select('>.datepicker-months td', true).first();
18895 months.dom.innerHTML = '';
18901 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18904 months.createChild(month);
18911 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;
18913 if (this.date < this.startDate) {
18914 this.viewDate = new Date(this.startDate);
18915 } else if (this.date > this.endDate) {
18916 this.viewDate = new Date(this.endDate);
18918 this.viewDate = new Date(this.date);
18926 var d = new Date(this.viewDate),
18927 year = d.getUTCFullYear(),
18928 month = d.getUTCMonth(),
18929 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18930 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18931 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18932 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18933 currentDate = this.date && this.date.valueOf(),
18934 today = this.UTCToday();
18936 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18938 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18940 // this.picker.select('>tfoot th.today').
18941 // .text(dates[this.language].today)
18942 // .toggle(this.todayBtn !== false);
18944 this.updateNavArrows();
18947 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18949 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18951 prevMonth.setUTCDate(day);
18953 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18955 var nextMonth = new Date(prevMonth);
18957 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18959 nextMonth = nextMonth.valueOf();
18961 var fillMonths = false;
18963 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18965 while(prevMonth.valueOf() <= nextMonth) {
18968 if (prevMonth.getUTCDay() === this.weekStart) {
18970 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18978 if(this.calendarWeeks){
18979 // ISO 8601: First week contains first thursday.
18980 // ISO also states week starts on Monday, but we can be more abstract here.
18982 // Start of current week: based on weekstart/current date
18983 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18984 // Thursday of this week
18985 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18986 // First Thursday of year, year from thursday
18987 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18988 // Calendar week: ms between thursdays, div ms per day, div 7 days
18989 calWeek = (th - yth) / 864e5 / 7 + 1;
18991 fillMonths.cn.push({
18999 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19001 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19004 if (this.todayHighlight &&
19005 prevMonth.getUTCFullYear() == today.getFullYear() &&
19006 prevMonth.getUTCMonth() == today.getMonth() &&
19007 prevMonth.getUTCDate() == today.getDate()) {
19008 clsName += ' today';
19011 if (currentDate && prevMonth.valueOf() === currentDate) {
19012 clsName += ' active';
19015 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19016 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19017 clsName += ' disabled';
19020 fillMonths.cn.push({
19022 cls: 'day ' + clsName,
19023 html: prevMonth.getDate()
19026 prevMonth.setDate(prevMonth.getDate()+1);
19029 var currentYear = this.date && this.date.getUTCFullYear();
19030 var currentMonth = this.date && this.date.getUTCMonth();
19032 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19034 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19035 v.removeClass('active');
19037 if(currentYear === year && k === currentMonth){
19038 v.addClass('active');
19041 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19042 v.addClass('disabled');
19048 year = parseInt(year/10, 10) * 10;
19050 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19052 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19055 for (var i = -1; i < 11; i++) {
19056 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19058 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19066 showMode: function(dir)
19069 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19072 Roo.each(this.picker().select('>div',true).elements, function(v){
19073 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19076 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19081 if(this.isInline) {
19085 this.picker().removeClass(['bottom', 'top']);
19087 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19089 * place to the top of element!
19093 this.picker().addClass('top');
19094 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19099 this.picker().addClass('bottom');
19101 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19104 parseDate : function(value)
19106 if(!value || value instanceof Date){
19109 var v = Date.parseDate(value, this.format);
19110 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19111 v = Date.parseDate(value, 'Y-m-d');
19113 if(!v && this.altFormats){
19114 if(!this.altFormatsArray){
19115 this.altFormatsArray = this.altFormats.split("|");
19117 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19118 v = Date.parseDate(value, this.altFormatsArray[i]);
19124 formatDate : function(date, fmt)
19126 return (!date || !(date instanceof Date)) ?
19127 date : date.dateFormat(fmt || this.format);
19130 onFocus : function()
19132 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19136 onBlur : function()
19138 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19140 var d = this.inputEl().getValue();
19147 showPopup : function()
19149 this.picker().show();
19153 this.fireEvent('showpopup', this, this.date);
19156 hidePopup : function()
19158 if(this.isInline) {
19161 this.picker().hide();
19162 this.viewMode = this.startViewMode;
19165 this.fireEvent('hidepopup', this, this.date);
19169 onMousedown: function(e)
19171 e.stopPropagation();
19172 e.preventDefault();
19177 Roo.bootstrap.DateField.superclass.keyup.call(this);
19181 setValue: function(v)
19183 if(this.fireEvent('beforeselect', this, v) !== false){
19184 var d = new Date(this.parseDate(v) ).clearTime();
19186 if(isNaN(d.getTime())){
19187 this.date = this.viewDate = '';
19188 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19192 v = this.formatDate(d);
19194 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19196 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19200 this.fireEvent('select', this, this.date);
19204 getValue: function()
19206 return this.formatDate(this.date);
19209 fireKey: function(e)
19211 if (!this.picker().isVisible()){
19212 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19218 var dateChanged = false,
19220 newDate, newViewDate;
19225 e.preventDefault();
19229 if (!this.keyboardNavigation) {
19232 dir = e.keyCode == 37 ? -1 : 1;
19235 newDate = this.moveYear(this.date, dir);
19236 newViewDate = this.moveYear(this.viewDate, dir);
19237 } else if (e.shiftKey){
19238 newDate = this.moveMonth(this.date, dir);
19239 newViewDate = this.moveMonth(this.viewDate, dir);
19241 newDate = new Date(this.date);
19242 newDate.setUTCDate(this.date.getUTCDate() + dir);
19243 newViewDate = new Date(this.viewDate);
19244 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19246 if (this.dateWithinRange(newDate)){
19247 this.date = newDate;
19248 this.viewDate = newViewDate;
19249 this.setValue(this.formatDate(this.date));
19251 e.preventDefault();
19252 dateChanged = true;
19257 if (!this.keyboardNavigation) {
19260 dir = e.keyCode == 38 ? -1 : 1;
19262 newDate = this.moveYear(this.date, dir);
19263 newViewDate = this.moveYear(this.viewDate, dir);
19264 } else if (e.shiftKey){
19265 newDate = this.moveMonth(this.date, dir);
19266 newViewDate = this.moveMonth(this.viewDate, dir);
19268 newDate = new Date(this.date);
19269 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19270 newViewDate = new Date(this.viewDate);
19271 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19273 if (this.dateWithinRange(newDate)){
19274 this.date = newDate;
19275 this.viewDate = newViewDate;
19276 this.setValue(this.formatDate(this.date));
19278 e.preventDefault();
19279 dateChanged = true;
19283 this.setValue(this.formatDate(this.date));
19285 e.preventDefault();
19288 this.setValue(this.formatDate(this.date));
19302 onClick: function(e)
19304 e.stopPropagation();
19305 e.preventDefault();
19307 var target = e.getTarget();
19309 if(target.nodeName.toLowerCase() === 'i'){
19310 target = Roo.get(target).dom.parentNode;
19313 var nodeName = target.nodeName;
19314 var className = target.className;
19315 var html = target.innerHTML;
19316 //Roo.log(nodeName);
19318 switch(nodeName.toLowerCase()) {
19320 switch(className) {
19326 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19327 switch(this.viewMode){
19329 this.viewDate = this.moveMonth(this.viewDate, dir);
19333 this.viewDate = this.moveYear(this.viewDate, dir);
19339 var date = new Date();
19340 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19342 this.setValue(this.formatDate(this.date));
19349 if (className.indexOf('disabled') < 0) {
19350 this.viewDate.setUTCDate(1);
19351 if (className.indexOf('month') > -1) {
19352 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19354 var year = parseInt(html, 10) || 0;
19355 this.viewDate.setUTCFullYear(year);
19359 if(this.singleMode){
19360 this.setValue(this.formatDate(this.viewDate));
19371 //Roo.log(className);
19372 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19373 var day = parseInt(html, 10) || 1;
19374 var year = this.viewDate.getUTCFullYear(),
19375 month = this.viewDate.getUTCMonth();
19377 if (className.indexOf('old') > -1) {
19384 } else if (className.indexOf('new') > -1) {
19392 //Roo.log([year,month,day]);
19393 this.date = this.UTCDate(year, month, day,0,0,0,0);
19394 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19396 //Roo.log(this.formatDate(this.date));
19397 this.setValue(this.formatDate(this.date));
19404 setStartDate: function(startDate)
19406 this.startDate = startDate || -Infinity;
19407 if (this.startDate !== -Infinity) {
19408 this.startDate = this.parseDate(this.startDate);
19411 this.updateNavArrows();
19414 setEndDate: function(endDate)
19416 this.endDate = endDate || Infinity;
19417 if (this.endDate !== Infinity) {
19418 this.endDate = this.parseDate(this.endDate);
19421 this.updateNavArrows();
19424 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19426 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19427 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19428 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19430 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19431 return parseInt(d, 10);
19434 this.updateNavArrows();
19437 updateNavArrows: function()
19439 if(this.singleMode){
19443 var d = new Date(this.viewDate),
19444 year = d.getUTCFullYear(),
19445 month = d.getUTCMonth();
19447 Roo.each(this.picker().select('.prev', true).elements, function(v){
19449 switch (this.viewMode) {
19452 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19458 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19465 Roo.each(this.picker().select('.next', true).elements, function(v){
19467 switch (this.viewMode) {
19470 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19476 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19484 moveMonth: function(date, dir)
19489 var new_date = new Date(date.valueOf()),
19490 day = new_date.getUTCDate(),
19491 month = new_date.getUTCMonth(),
19492 mag = Math.abs(dir),
19494 dir = dir > 0 ? 1 : -1;
19497 // If going back one month, make sure month is not current month
19498 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19500 return new_date.getUTCMonth() == month;
19502 // If going forward one month, make sure month is as expected
19503 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19505 return new_date.getUTCMonth() != new_month;
19507 new_month = month + dir;
19508 new_date.setUTCMonth(new_month);
19509 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19510 if (new_month < 0 || new_month > 11) {
19511 new_month = (new_month + 12) % 12;
19514 // For magnitudes >1, move one month at a time...
19515 for (var i=0; i<mag; i++) {
19516 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19517 new_date = this.moveMonth(new_date, dir);
19519 // ...then reset the day, keeping it in the new month
19520 new_month = new_date.getUTCMonth();
19521 new_date.setUTCDate(day);
19523 return new_month != new_date.getUTCMonth();
19526 // Common date-resetting loop -- if date is beyond end of month, make it
19529 new_date.setUTCDate(--day);
19530 new_date.setUTCMonth(new_month);
19535 moveYear: function(date, dir)
19537 return this.moveMonth(date, dir*12);
19540 dateWithinRange: function(date)
19542 return date >= this.startDate && date <= this.endDate;
19548 this.picker().remove();
19551 validateValue : function(value)
19553 if(this.getVisibilityEl().hasClass('hidden')){
19557 if(value.length < 1) {
19558 if(this.allowBlank){
19564 if(value.length < this.minLength){
19567 if(value.length > this.maxLength){
19571 var vt = Roo.form.VTypes;
19572 if(!vt[this.vtype](value, this)){
19576 if(typeof this.validator == "function"){
19577 var msg = this.validator(value);
19583 if(this.regex && !this.regex.test(value)){
19587 if(typeof(this.parseDate(value)) == 'undefined'){
19591 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19595 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19605 this.date = this.viewDate = '';
19607 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19612 Roo.apply(Roo.bootstrap.DateField, {
19623 html: '<i class="fa fa-arrow-left"/>'
19633 html: '<i class="fa fa-arrow-right"/>'
19675 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19676 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19677 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19678 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19679 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19692 navFnc: 'FullYear',
19697 navFnc: 'FullYear',
19702 Roo.apply(Roo.bootstrap.DateField, {
19706 cls: 'datepicker dropdown-menu roo-dynamic',
19710 cls: 'datepicker-days',
19714 cls: 'table-condensed',
19716 Roo.bootstrap.DateField.head,
19720 Roo.bootstrap.DateField.footer
19727 cls: 'datepicker-months',
19731 cls: 'table-condensed',
19733 Roo.bootstrap.DateField.head,
19734 Roo.bootstrap.DateField.content,
19735 Roo.bootstrap.DateField.footer
19742 cls: 'datepicker-years',
19746 cls: 'table-condensed',
19748 Roo.bootstrap.DateField.head,
19749 Roo.bootstrap.DateField.content,
19750 Roo.bootstrap.DateField.footer
19769 * @class Roo.bootstrap.TimeField
19770 * @extends Roo.bootstrap.Input
19771 * Bootstrap DateField class
19775 * Create a new TimeField
19776 * @param {Object} config The config object
19779 Roo.bootstrap.TimeField = function(config){
19780 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19784 * Fires when this field show.
19785 * @param {Roo.bootstrap.DateField} thisthis
19786 * @param {Mixed} date The date value
19791 * Fires when this field hide.
19792 * @param {Roo.bootstrap.DateField} this
19793 * @param {Mixed} date The date value
19798 * Fires when select a date.
19799 * @param {Roo.bootstrap.DateField} this
19800 * @param {Mixed} date The date value
19806 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19809 * @cfg {String} format
19810 * The default time format string which can be overriden for localization support. The format must be
19811 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19815 onRender: function(ct, position)
19818 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19820 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19822 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19824 this.pop = this.picker().select('>.datepicker-time',true).first();
19825 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19827 this.picker().on('mousedown', this.onMousedown, this);
19828 this.picker().on('click', this.onClick, this);
19830 this.picker().addClass('datepicker-dropdown');
19835 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19836 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19837 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19838 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19839 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19840 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19844 fireKey: function(e){
19845 if (!this.picker().isVisible()){
19846 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19852 e.preventDefault();
19860 this.onTogglePeriod();
19863 this.onIncrementMinutes();
19866 this.onDecrementMinutes();
19875 onClick: function(e) {
19876 e.stopPropagation();
19877 e.preventDefault();
19880 picker : function()
19882 return this.el.select('.datepicker', true).first();
19885 fillTime: function()
19887 var time = this.pop.select('tbody', true).first();
19889 time.dom.innerHTML = '';
19904 cls: 'hours-up glyphicon glyphicon-chevron-up'
19924 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19945 cls: 'timepicker-hour',
19960 cls: 'timepicker-minute',
19975 cls: 'btn btn-primary period',
19997 cls: 'hours-down glyphicon glyphicon-chevron-down'
20017 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20035 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20042 var hours = this.time.getHours();
20043 var minutes = this.time.getMinutes();
20056 hours = hours - 12;
20060 hours = '0' + hours;
20064 minutes = '0' + minutes;
20067 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20068 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20069 this.pop.select('button', true).first().dom.innerHTML = period;
20075 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20077 var cls = ['bottom'];
20079 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20086 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20091 this.picker().addClass(cls.join('-'));
20095 Roo.each(cls, function(c){
20097 _this.picker().setTop(_this.inputEl().getHeight());
20101 _this.picker().setTop(0 - _this.picker().getHeight());
20106 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20110 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20117 onFocus : function()
20119 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20123 onBlur : function()
20125 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20131 this.picker().show();
20136 this.fireEvent('show', this, this.date);
20141 this.picker().hide();
20144 this.fireEvent('hide', this, this.date);
20147 setTime : function()
20150 this.setValue(this.time.format(this.format));
20152 this.fireEvent('select', this, this.date);
20157 onMousedown: function(e){
20158 e.stopPropagation();
20159 e.preventDefault();
20162 onIncrementHours: function()
20164 Roo.log('onIncrementHours');
20165 this.time = this.time.add(Date.HOUR, 1);
20170 onDecrementHours: function()
20172 Roo.log('onDecrementHours');
20173 this.time = this.time.add(Date.HOUR, -1);
20177 onIncrementMinutes: function()
20179 Roo.log('onIncrementMinutes');
20180 this.time = this.time.add(Date.MINUTE, 1);
20184 onDecrementMinutes: function()
20186 Roo.log('onDecrementMinutes');
20187 this.time = this.time.add(Date.MINUTE, -1);
20191 onTogglePeriod: function()
20193 Roo.log('onTogglePeriod');
20194 this.time = this.time.add(Date.HOUR, 12);
20201 Roo.apply(Roo.bootstrap.TimeField, {
20231 cls: 'btn btn-info ok',
20243 Roo.apply(Roo.bootstrap.TimeField, {
20247 cls: 'datepicker dropdown-menu',
20251 cls: 'datepicker-time',
20255 cls: 'table-condensed',
20257 Roo.bootstrap.TimeField.content,
20258 Roo.bootstrap.TimeField.footer
20277 * @class Roo.bootstrap.MonthField
20278 * @extends Roo.bootstrap.Input
20279 * Bootstrap MonthField class
20281 * @cfg {String} language default en
20284 * Create a new MonthField
20285 * @param {Object} config The config object
20288 Roo.bootstrap.MonthField = function(config){
20289 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20294 * Fires when this field show.
20295 * @param {Roo.bootstrap.MonthField} this
20296 * @param {Mixed} date The date value
20301 * Fires when this field hide.
20302 * @param {Roo.bootstrap.MonthField} this
20303 * @param {Mixed} date The date value
20308 * Fires when select a date.
20309 * @param {Roo.bootstrap.MonthField} this
20310 * @param {String} oldvalue The old value
20311 * @param {String} newvalue The new value
20317 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20319 onRender: function(ct, position)
20322 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20324 this.language = this.language || 'en';
20325 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20326 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20328 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20329 this.isInline = false;
20330 this.isInput = true;
20331 this.component = this.el.select('.add-on', true).first() || false;
20332 this.component = (this.component && this.component.length === 0) ? false : this.component;
20333 this.hasInput = this.component && this.inputEL().length;
20335 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20337 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20339 this.picker().on('mousedown', this.onMousedown, this);
20340 this.picker().on('click', this.onClick, this);
20342 this.picker().addClass('datepicker-dropdown');
20344 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20345 v.setStyle('width', '189px');
20352 if(this.isInline) {
20358 setValue: function(v, suppressEvent)
20360 var o = this.getValue();
20362 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20366 if(suppressEvent !== true){
20367 this.fireEvent('select', this, o, v);
20372 getValue: function()
20377 onClick: function(e)
20379 e.stopPropagation();
20380 e.preventDefault();
20382 var target = e.getTarget();
20384 if(target.nodeName.toLowerCase() === 'i'){
20385 target = Roo.get(target).dom.parentNode;
20388 var nodeName = target.nodeName;
20389 var className = target.className;
20390 var html = target.innerHTML;
20392 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20396 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20398 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20404 picker : function()
20406 return this.pickerEl;
20409 fillMonths: function()
20412 var months = this.picker().select('>.datepicker-months td', true).first();
20414 months.dom.innerHTML = '';
20420 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20423 months.createChild(month);
20432 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20433 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20436 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20437 e.removeClass('active');
20439 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20440 e.addClass('active');
20447 if(this.isInline) {
20451 this.picker().removeClass(['bottom', 'top']);
20453 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20455 * place to the top of element!
20459 this.picker().addClass('top');
20460 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20465 this.picker().addClass('bottom');
20467 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20470 onFocus : function()
20472 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20476 onBlur : function()
20478 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20480 var d = this.inputEl().getValue();
20489 this.picker().show();
20490 this.picker().select('>.datepicker-months', true).first().show();
20494 this.fireEvent('show', this, this.date);
20499 if(this.isInline) {
20502 this.picker().hide();
20503 this.fireEvent('hide', this, this.date);
20507 onMousedown: function(e)
20509 e.stopPropagation();
20510 e.preventDefault();
20515 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20519 fireKey: function(e)
20521 if (!this.picker().isVisible()){
20522 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20533 e.preventDefault();
20537 dir = e.keyCode == 37 ? -1 : 1;
20539 this.vIndex = this.vIndex + dir;
20541 if(this.vIndex < 0){
20545 if(this.vIndex > 11){
20549 if(isNaN(this.vIndex)){
20553 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20559 dir = e.keyCode == 38 ? -1 : 1;
20561 this.vIndex = this.vIndex + dir * 4;
20563 if(this.vIndex < 0){
20567 if(this.vIndex > 11){
20571 if(isNaN(this.vIndex)){
20575 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20580 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20581 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20585 e.preventDefault();
20588 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20589 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20605 this.picker().remove();
20610 Roo.apply(Roo.bootstrap.MonthField, {
20629 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20630 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20635 Roo.apply(Roo.bootstrap.MonthField, {
20639 cls: 'datepicker dropdown-menu roo-dynamic',
20643 cls: 'datepicker-months',
20647 cls: 'table-condensed',
20649 Roo.bootstrap.DateField.content
20669 * @class Roo.bootstrap.CheckBox
20670 * @extends Roo.bootstrap.Input
20671 * Bootstrap CheckBox class
20673 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20674 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20675 * @cfg {String} boxLabel The text that appears beside the checkbox
20676 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20677 * @cfg {Boolean} checked initnal the element
20678 * @cfg {Boolean} inline inline the element (default false)
20679 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20680 * @cfg {String} tooltip label tooltip
20683 * Create a new CheckBox
20684 * @param {Object} config The config object
20687 Roo.bootstrap.CheckBox = function(config){
20688 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20693 * Fires when the element is checked or unchecked.
20694 * @param {Roo.bootstrap.CheckBox} this This input
20695 * @param {Boolean} checked The new checked value
20700 * Fires when the element is click.
20701 * @param {Roo.bootstrap.CheckBox} this This input
20708 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20710 inputType: 'checkbox',
20719 getAutoCreate : function()
20721 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20727 cfg.cls = 'form-group ' + this.inputType; //input-group
20730 cfg.cls += ' ' + this.inputType + '-inline';
20736 type : this.inputType,
20737 value : this.inputValue,
20738 cls : 'roo-' + this.inputType, //'form-box',
20739 placeholder : this.placeholder || ''
20743 if(this.inputType != 'radio'){
20747 cls : 'roo-hidden-value',
20748 value : this.checked ? this.inputValue : this.valueOff
20753 if (this.weight) { // Validity check?
20754 cfg.cls += " " + this.inputType + "-" + this.weight;
20757 if (this.disabled) {
20758 input.disabled=true;
20762 input.checked = this.checked;
20767 input.name = this.name;
20769 if(this.inputType != 'radio'){
20770 hidden.name = this.name;
20771 input.name = '_hidden_' + this.name;
20776 input.cls += ' input-' + this.size;
20781 ['xs','sm','md','lg'].map(function(size){
20782 if (settings[size]) {
20783 cfg.cls += ' col-' + size + '-' + settings[size];
20787 var inputblock = input;
20789 if (this.before || this.after) {
20792 cls : 'input-group',
20797 inputblock.cn.push({
20799 cls : 'input-group-addon',
20804 inputblock.cn.push(input);
20806 if(this.inputType != 'radio'){
20807 inputblock.cn.push(hidden);
20811 inputblock.cn.push({
20813 cls : 'input-group-addon',
20820 if (align ==='left' && this.fieldLabel.length) {
20821 // Roo.log("left and has label");
20826 cls : 'control-label',
20827 html : this.fieldLabel
20837 if(this.labelWidth > 12){
20838 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20841 if(this.labelWidth < 13 && this.labelmd == 0){
20842 this.labelmd = this.labelWidth;
20845 if(this.labellg > 0){
20846 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20847 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20850 if(this.labelmd > 0){
20851 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20852 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20855 if(this.labelsm > 0){
20856 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20857 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20860 if(this.labelxs > 0){
20861 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20862 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20865 } else if ( this.fieldLabel.length) {
20866 // Roo.log(" label");
20870 tag: this.boxLabel ? 'span' : 'label',
20872 cls: 'control-label box-input-label',
20873 //cls : 'input-group-addon',
20874 html : this.fieldLabel
20883 // Roo.log(" no label && no align");
20884 cfg.cn = [ inputblock ] ;
20890 var boxLabelCfg = {
20892 //'for': id, // box label is handled by onclick - so no for...
20894 html: this.boxLabel
20898 boxLabelCfg.tooltip = this.tooltip;
20901 cfg.cn.push(boxLabelCfg);
20904 if(this.inputType != 'radio'){
20905 cfg.cn.push(hidden);
20913 * return the real input element.
20915 inputEl: function ()
20917 return this.el.select('input.roo-' + this.inputType,true).first();
20919 hiddenEl: function ()
20921 return this.el.select('input.roo-hidden-value',true).first();
20924 labelEl: function()
20926 return this.el.select('label.control-label',true).first();
20928 /* depricated... */
20932 return this.labelEl();
20935 boxLabelEl: function()
20937 return this.el.select('label.box-label',true).first();
20940 initEvents : function()
20942 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20944 this.inputEl().on('click', this.onClick, this);
20946 if (this.boxLabel) {
20947 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20950 this.startValue = this.getValue();
20953 Roo.bootstrap.CheckBox.register(this);
20957 onClick : function(e)
20959 if(this.fireEvent('click', this, e) !== false){
20960 this.setChecked(!this.checked);
20965 setChecked : function(state,suppressEvent)
20967 this.startValue = this.getValue();
20969 if(this.inputType == 'radio'){
20971 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20972 e.dom.checked = false;
20975 this.inputEl().dom.checked = true;
20977 this.inputEl().dom.value = this.inputValue;
20979 if(suppressEvent !== true){
20980 this.fireEvent('check', this, true);
20988 this.checked = state;
20990 this.inputEl().dom.checked = state;
20993 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20995 if(suppressEvent !== true){
20996 this.fireEvent('check', this, state);
21002 getValue : function()
21004 if(this.inputType == 'radio'){
21005 return this.getGroupValue();
21008 return this.hiddenEl().dom.value;
21012 getGroupValue : function()
21014 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21018 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21021 setValue : function(v,suppressEvent)
21023 if(this.inputType == 'radio'){
21024 this.setGroupValue(v, suppressEvent);
21028 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21033 setGroupValue : function(v, suppressEvent)
21035 this.startValue = this.getValue();
21037 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21038 e.dom.checked = false;
21040 if(e.dom.value == v){
21041 e.dom.checked = true;
21045 if(suppressEvent !== true){
21046 this.fireEvent('check', this, true);
21054 validate : function()
21056 if(this.getVisibilityEl().hasClass('hidden')){
21062 (this.inputType == 'radio' && this.validateRadio()) ||
21063 (this.inputType == 'checkbox' && this.validateCheckbox())
21069 this.markInvalid();
21073 validateRadio : function()
21075 if(this.getVisibilityEl().hasClass('hidden')){
21079 if(this.allowBlank){
21085 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21086 if(!e.dom.checked){
21098 validateCheckbox : function()
21101 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21102 //return (this.getValue() == this.inputValue) ? true : false;
21105 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21113 for(var i in group){
21114 if(group[i].el.isVisible(true)){
21122 for(var i in group){
21127 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21134 * Mark this field as valid
21136 markValid : function()
21140 this.fireEvent('valid', this);
21142 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21145 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21152 if(this.inputType == 'radio'){
21153 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21154 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21155 e.findParent('.form-group', false, true).addClass(_this.validClass);
21162 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21163 this.el.findParent('.form-group', false, true).addClass(this.validClass);
21167 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21173 for(var i in group){
21174 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21175 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
21180 * Mark this field as invalid
21181 * @param {String} msg The validation message
21183 markInvalid : function(msg)
21185 if(this.allowBlank){
21191 this.fireEvent('invalid', this, msg);
21193 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21196 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21200 label.markInvalid();
21203 if(this.inputType == 'radio'){
21204 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21205 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21206 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
21213 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21214 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
21218 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21224 for(var i in group){
21225 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21226 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
21231 clearInvalid : function()
21233 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21235 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21237 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21239 if (label && label.iconEl) {
21240 label.iconEl.removeClass(label.validClass);
21241 label.iconEl.removeClass(label.invalidClass);
21245 disable : function()
21247 if(this.inputType != 'radio'){
21248 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21255 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21256 _this.getActionEl().addClass(this.disabledClass);
21257 e.dom.disabled = true;
21261 this.disabled = true;
21262 this.fireEvent("disable", this);
21266 enable : function()
21268 if(this.inputType != 'radio'){
21269 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21276 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21277 _this.getActionEl().removeClass(this.disabledClass);
21278 e.dom.disabled = false;
21282 this.disabled = false;
21283 this.fireEvent("enable", this);
21287 setBoxLabel : function(v)
21292 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21298 Roo.apply(Roo.bootstrap.CheckBox, {
21303 * register a CheckBox Group
21304 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21306 register : function(checkbox)
21308 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21309 this.groups[checkbox.groupId] = {};
21312 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21316 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21320 * fetch a CheckBox Group based on the group ID
21321 * @param {string} the group ID
21322 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21324 get: function(groupId) {
21325 if (typeof(this.groups[groupId]) == 'undefined') {
21329 return this.groups[groupId] ;
21342 * @class Roo.bootstrap.Radio
21343 * @extends Roo.bootstrap.Component
21344 * Bootstrap Radio class
21345 * @cfg {String} boxLabel - the label associated
21346 * @cfg {String} value - the value of radio
21349 * Create a new Radio
21350 * @param {Object} config The config object
21352 Roo.bootstrap.Radio = function(config){
21353 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21357 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21363 getAutoCreate : function()
21367 cls : 'form-group radio',
21372 html : this.boxLabel
21380 initEvents : function()
21382 this.parent().register(this);
21384 this.el.on('click', this.onClick, this);
21388 onClick : function(e)
21390 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21391 this.setChecked(true);
21395 setChecked : function(state, suppressEvent)
21397 this.parent().setValue(this.value, suppressEvent);
21401 setBoxLabel : function(v)
21406 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21421 * @class Roo.bootstrap.SecurePass
21422 * @extends Roo.bootstrap.Input
21423 * Bootstrap SecurePass class
21427 * Create a new SecurePass
21428 * @param {Object} config The config object
21431 Roo.bootstrap.SecurePass = function (config) {
21432 // these go here, so the translation tool can replace them..
21434 PwdEmpty: "Please type a password, and then retype it to confirm.",
21435 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21436 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21437 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21438 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21439 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21440 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21441 TooWeak: "Your password is Too Weak."
21443 this.meterLabel = "Password strength:";
21444 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21445 this.meterClass = [
21446 "roo-password-meter-tooweak",
21447 "roo-password-meter-weak",
21448 "roo-password-meter-medium",
21449 "roo-password-meter-strong",
21450 "roo-password-meter-grey"
21455 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21458 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21460 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21462 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21463 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21464 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21465 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21466 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21467 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21468 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21478 * @cfg {String/Object} Label for the strength meter (defaults to
21479 * 'Password strength:')
21484 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21485 * ['Weak', 'Medium', 'Strong'])
21488 pwdStrengths: false,
21501 initEvents: function ()
21503 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21505 if (this.el.is('input[type=password]') && Roo.isSafari) {
21506 this.el.on('keydown', this.SafariOnKeyDown, this);
21509 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21512 onRender: function (ct, position)
21514 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21515 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21516 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21518 this.trigger.createChild({
21523 cls: 'roo-password-meter-grey col-xs-12',
21526 //width: this.meterWidth + 'px'
21530 cls: 'roo-password-meter-text'
21536 if (this.hideTrigger) {
21537 this.trigger.setDisplayed(false);
21539 this.setSize(this.width || '', this.height || '');
21542 onDestroy: function ()
21544 if (this.trigger) {
21545 this.trigger.removeAllListeners();
21546 this.trigger.remove();
21549 this.wrap.remove();
21551 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21554 checkStrength: function ()
21556 var pwd = this.inputEl().getValue();
21557 if (pwd == this._lastPwd) {
21562 if (this.ClientSideStrongPassword(pwd)) {
21564 } else if (this.ClientSideMediumPassword(pwd)) {
21566 } else if (this.ClientSideWeakPassword(pwd)) {
21572 Roo.log('strength1: ' + strength);
21574 //var pm = this.trigger.child('div/div/div').dom;
21575 var pm = this.trigger.child('div/div');
21576 pm.removeClass(this.meterClass);
21577 pm.addClass(this.meterClass[strength]);
21580 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21582 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21584 this._lastPwd = pwd;
21588 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21590 this._lastPwd = '';
21592 var pm = this.trigger.child('div/div');
21593 pm.removeClass(this.meterClass);
21594 pm.addClass('roo-password-meter-grey');
21597 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21600 this.inputEl().dom.type='password';
21603 validateValue: function (value)
21606 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21609 if (value.length == 0) {
21610 if (this.allowBlank) {
21611 this.clearInvalid();
21615 this.markInvalid(this.errors.PwdEmpty);
21616 this.errorMsg = this.errors.PwdEmpty;
21624 if ('[\x21-\x7e]*'.match(value)) {
21625 this.markInvalid(this.errors.PwdBadChar);
21626 this.errorMsg = this.errors.PwdBadChar;
21629 if (value.length < 6) {
21630 this.markInvalid(this.errors.PwdShort);
21631 this.errorMsg = this.errors.PwdShort;
21634 if (value.length > 16) {
21635 this.markInvalid(this.errors.PwdLong);
21636 this.errorMsg = this.errors.PwdLong;
21640 if (this.ClientSideStrongPassword(value)) {
21642 } else if (this.ClientSideMediumPassword(value)) {
21644 } else if (this.ClientSideWeakPassword(value)) {
21651 if (strength < 2) {
21652 //this.markInvalid(this.errors.TooWeak);
21653 this.errorMsg = this.errors.TooWeak;
21658 console.log('strength2: ' + strength);
21660 //var pm = this.trigger.child('div/div/div').dom;
21662 var pm = this.trigger.child('div/div');
21663 pm.removeClass(this.meterClass);
21664 pm.addClass(this.meterClass[strength]);
21666 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21668 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21670 this.errorMsg = '';
21674 CharacterSetChecks: function (type)
21677 this.fResult = false;
21680 isctype: function (character, type)
21683 case this.kCapitalLetter:
21684 if (character >= 'A' && character <= 'Z') {
21689 case this.kSmallLetter:
21690 if (character >= 'a' && character <= 'z') {
21696 if (character >= '0' && character <= '9') {
21701 case this.kPunctuation:
21702 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21713 IsLongEnough: function (pwd, size)
21715 return !(pwd == null || isNaN(size) || pwd.length < size);
21718 SpansEnoughCharacterSets: function (word, nb)
21720 if (!this.IsLongEnough(word, nb))
21725 var characterSetChecks = new Array(
21726 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21727 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21730 for (var index = 0; index < word.length; ++index) {
21731 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21732 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21733 characterSetChecks[nCharSet].fResult = true;
21740 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21741 if (characterSetChecks[nCharSet].fResult) {
21746 if (nCharSets < nb) {
21752 ClientSideStrongPassword: function (pwd)
21754 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21757 ClientSideMediumPassword: function (pwd)
21759 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21762 ClientSideWeakPassword: function (pwd)
21764 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21767 })//<script type="text/javascript">
21770 * Based Ext JS Library 1.1.1
21771 * Copyright(c) 2006-2007, Ext JS, LLC.
21777 * @class Roo.HtmlEditorCore
21778 * @extends Roo.Component
21779 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21781 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21784 Roo.HtmlEditorCore = function(config){
21787 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21792 * @event initialize
21793 * Fires when the editor is fully initialized (including the iframe)
21794 * @param {Roo.HtmlEditorCore} this
21799 * Fires when the editor is first receives the focus. Any insertion must wait
21800 * until after this event.
21801 * @param {Roo.HtmlEditorCore} this
21805 * @event beforesync
21806 * Fires before the textarea is updated with content from the editor iframe. Return false
21807 * to cancel the sync.
21808 * @param {Roo.HtmlEditorCore} this
21809 * @param {String} html
21813 * @event beforepush
21814 * Fires before the iframe editor is updated with content from the textarea. Return false
21815 * to cancel the push.
21816 * @param {Roo.HtmlEditorCore} this
21817 * @param {String} html
21822 * Fires when the textarea is updated with content from the editor iframe.
21823 * @param {Roo.HtmlEditorCore} this
21824 * @param {String} html
21829 * Fires when the iframe editor is updated with content from the textarea.
21830 * @param {Roo.HtmlEditorCore} this
21831 * @param {String} html
21836 * @event editorevent
21837 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21838 * @param {Roo.HtmlEditorCore} this
21844 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21846 // defaults : white / black...
21847 this.applyBlacklists();
21854 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21858 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21864 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21869 * @cfg {Number} height (in pixels)
21873 * @cfg {Number} width (in pixels)
21878 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21881 stylesheets: false,
21886 // private properties
21887 validationEvent : false,
21889 initialized : false,
21891 sourceEditMode : false,
21892 onFocus : Roo.emptyFn,
21894 hideMode:'offsets',
21898 // blacklist + whitelisted elements..
21905 * Protected method that will not generally be called directly. It
21906 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21907 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21909 getDocMarkup : function(){
21913 // inherit styels from page...??
21914 if (this.stylesheets === false) {
21916 Roo.get(document.head).select('style').each(function(node) {
21917 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21920 Roo.get(document.head).select('link').each(function(node) {
21921 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21924 } else if (!this.stylesheets.length) {
21926 st = '<style type="text/css">' +
21927 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21930 st = '<style type="text/css">' +
21935 st += '<style type="text/css">' +
21936 'IMG { cursor: pointer } ' +
21939 var cls = 'roo-htmleditor-body';
21941 if(this.bodyCls.length){
21942 cls += ' ' + this.bodyCls;
21945 return '<html><head>' + st +
21946 //<style type="text/css">' +
21947 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21949 ' </head><body class="' + cls + '"></body></html>';
21953 onRender : function(ct, position)
21956 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21957 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21960 this.el.dom.style.border = '0 none';
21961 this.el.dom.setAttribute('tabIndex', -1);
21962 this.el.addClass('x-hidden hide');
21966 if(Roo.isIE){ // fix IE 1px bogus margin
21967 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21971 this.frameId = Roo.id();
21975 var iframe = this.owner.wrap.createChild({
21977 cls: 'form-control', // bootstrap..
21979 name: this.frameId,
21980 frameBorder : 'no',
21981 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21986 this.iframe = iframe.dom;
21988 this.assignDocWin();
21990 this.doc.designMode = 'on';
21993 this.doc.write(this.getDocMarkup());
21997 var task = { // must defer to wait for browser to be ready
21999 //console.log("run task?" + this.doc.readyState);
22000 this.assignDocWin();
22001 if(this.doc.body || this.doc.readyState == 'complete'){
22003 this.doc.designMode="on";
22007 Roo.TaskMgr.stop(task);
22008 this.initEditor.defer(10, this);
22015 Roo.TaskMgr.start(task);
22020 onResize : function(w, h)
22022 Roo.log('resize: ' +w + ',' + h );
22023 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22027 if(typeof w == 'number'){
22029 this.iframe.style.width = w + 'px';
22031 if(typeof h == 'number'){
22033 this.iframe.style.height = h + 'px';
22035 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22042 * Toggles the editor between standard and source edit mode.
22043 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22045 toggleSourceEdit : function(sourceEditMode){
22047 this.sourceEditMode = sourceEditMode === true;
22049 if(this.sourceEditMode){
22051 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22054 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22055 //this.iframe.className = '';
22058 //this.setSize(this.owner.wrap.getSize());
22059 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22066 * Protected method that will not generally be called directly. If you need/want
22067 * custom HTML cleanup, this is the method you should override.
22068 * @param {String} html The HTML to be cleaned
22069 * return {String} The cleaned HTML
22071 cleanHtml : function(html){
22072 html = String(html);
22073 if(html.length > 5){
22074 if(Roo.isSafari){ // strip safari nonsense
22075 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22078 if(html == ' '){
22085 * HTML Editor -> Textarea
22086 * Protected method that will not generally be called directly. Syncs the contents
22087 * of the editor iframe with the textarea.
22089 syncValue : function(){
22090 if(this.initialized){
22091 var bd = (this.doc.body || this.doc.documentElement);
22092 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22093 var html = bd.innerHTML;
22095 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22096 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22098 html = '<div style="'+m[0]+'">' + html + '</div>';
22101 html = this.cleanHtml(html);
22102 // fix up the special chars.. normaly like back quotes in word...
22103 // however we do not want to do this with chinese..
22104 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22105 var cc = b.charCodeAt();
22107 (cc >= 0x4E00 && cc < 0xA000 ) ||
22108 (cc >= 0x3400 && cc < 0x4E00 ) ||
22109 (cc >= 0xf900 && cc < 0xfb00 )
22115 if(this.owner.fireEvent('beforesync', this, html) !== false){
22116 this.el.dom.value = html;
22117 this.owner.fireEvent('sync', this, html);
22123 * Protected method that will not generally be called directly. Pushes the value of the textarea
22124 * into the iframe editor.
22126 pushValue : function(){
22127 if(this.initialized){
22128 var v = this.el.dom.value.trim();
22130 // if(v.length < 1){
22134 if(this.owner.fireEvent('beforepush', this, v) !== false){
22135 var d = (this.doc.body || this.doc.documentElement);
22137 this.cleanUpPaste();
22138 this.el.dom.value = d.innerHTML;
22139 this.owner.fireEvent('push', this, v);
22145 deferFocus : function(){
22146 this.focus.defer(10, this);
22150 focus : function(){
22151 if(this.win && !this.sourceEditMode){
22158 assignDocWin: function()
22160 var iframe = this.iframe;
22163 this.doc = iframe.contentWindow.document;
22164 this.win = iframe.contentWindow;
22166 // if (!Roo.get(this.frameId)) {
22169 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22170 // this.win = Roo.get(this.frameId).dom.contentWindow;
22172 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22176 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22177 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22182 initEditor : function(){
22183 //console.log("INIT EDITOR");
22184 this.assignDocWin();
22188 this.doc.designMode="on";
22190 this.doc.write(this.getDocMarkup());
22193 var dbody = (this.doc.body || this.doc.documentElement);
22194 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22195 // this copies styles from the containing element into thsi one..
22196 // not sure why we need all of this..
22197 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22199 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22200 //ss['background-attachment'] = 'fixed'; // w3c
22201 dbody.bgProperties = 'fixed'; // ie
22202 //Roo.DomHelper.applyStyles(dbody, ss);
22203 Roo.EventManager.on(this.doc, {
22204 //'mousedown': this.onEditorEvent,
22205 'mouseup': this.onEditorEvent,
22206 'dblclick': this.onEditorEvent,
22207 'click': this.onEditorEvent,
22208 'keyup': this.onEditorEvent,
22213 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22215 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22216 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22218 this.initialized = true;
22220 this.owner.fireEvent('initialize', this);
22225 onDestroy : function(){
22231 //for (var i =0; i < this.toolbars.length;i++) {
22232 // // fixme - ask toolbars for heights?
22233 // this.toolbars[i].onDestroy();
22236 //this.wrap.dom.innerHTML = '';
22237 //this.wrap.remove();
22242 onFirstFocus : function(){
22244 this.assignDocWin();
22247 this.activated = true;
22250 if(Roo.isGecko){ // prevent silly gecko errors
22252 var s = this.win.getSelection();
22253 if(!s.focusNode || s.focusNode.nodeType != 3){
22254 var r = s.getRangeAt(0);
22255 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22260 this.execCmd('useCSS', true);
22261 this.execCmd('styleWithCSS', false);
22264 this.owner.fireEvent('activate', this);
22268 adjustFont: function(btn){
22269 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22270 //if(Roo.isSafari){ // safari
22273 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22274 if(Roo.isSafari){ // safari
22275 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22276 v = (v < 10) ? 10 : v;
22277 v = (v > 48) ? 48 : v;
22278 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22283 v = Math.max(1, v+adjust);
22285 this.execCmd('FontSize', v );
22288 onEditorEvent : function(e)
22290 this.owner.fireEvent('editorevent', this, e);
22291 // this.updateToolbar();
22292 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22295 insertTag : function(tg)
22297 // could be a bit smarter... -> wrap the current selected tRoo..
22298 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22300 range = this.createRange(this.getSelection());
22301 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22302 wrappingNode.appendChild(range.extractContents());
22303 range.insertNode(wrappingNode);
22310 this.execCmd("formatblock", tg);
22314 insertText : function(txt)
22318 var range = this.createRange();
22319 range.deleteContents();
22320 //alert(Sender.getAttribute('label'));
22322 range.insertNode(this.doc.createTextNode(txt));
22328 * Executes a Midas editor command on the editor document and performs necessary focus and
22329 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22330 * @param {String} cmd The Midas command
22331 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22333 relayCmd : function(cmd, value){
22335 this.execCmd(cmd, value);
22336 this.owner.fireEvent('editorevent', this);
22337 //this.updateToolbar();
22338 this.owner.deferFocus();
22342 * Executes a Midas editor command directly on the editor document.
22343 * For visual commands, you should use {@link #relayCmd} instead.
22344 * <b>This should only be called after the editor is initialized.</b>
22345 * @param {String} cmd The Midas command
22346 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22348 execCmd : function(cmd, value){
22349 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22356 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22358 * @param {String} text | dom node..
22360 insertAtCursor : function(text)
22363 if(!this.activated){
22369 var r = this.doc.selection.createRange();
22380 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22384 // from jquery ui (MIT licenced)
22386 var win = this.win;
22388 if (win.getSelection && win.getSelection().getRangeAt) {
22389 range = win.getSelection().getRangeAt(0);
22390 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22391 range.insertNode(node);
22392 } else if (win.document.selection && win.document.selection.createRange) {
22393 // no firefox support
22394 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22395 win.document.selection.createRange().pasteHTML(txt);
22397 // no firefox support
22398 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22399 this.execCmd('InsertHTML', txt);
22408 mozKeyPress : function(e){
22410 var c = e.getCharCode(), cmd;
22413 c = String.fromCharCode(c).toLowerCase();
22427 this.cleanUpPaste.defer(100, this);
22435 e.preventDefault();
22443 fixKeys : function(){ // load time branching for fastest keydown performance
22445 return function(e){
22446 var k = e.getKey(), r;
22449 r = this.doc.selection.createRange();
22452 r.pasteHTML('    ');
22459 r = this.doc.selection.createRange();
22461 var target = r.parentElement();
22462 if(!target || target.tagName.toLowerCase() != 'li'){
22464 r.pasteHTML('<br />');
22470 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22471 this.cleanUpPaste.defer(100, this);
22477 }else if(Roo.isOpera){
22478 return function(e){
22479 var k = e.getKey();
22483 this.execCmd('InsertHTML','    ');
22486 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22487 this.cleanUpPaste.defer(100, this);
22492 }else if(Roo.isSafari){
22493 return function(e){
22494 var k = e.getKey();
22498 this.execCmd('InsertText','\t');
22502 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22503 this.cleanUpPaste.defer(100, this);
22511 getAllAncestors: function()
22513 var p = this.getSelectedNode();
22516 a.push(p); // push blank onto stack..
22517 p = this.getParentElement();
22521 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22525 a.push(this.doc.body);
22529 lastSelNode : false,
22532 getSelection : function()
22534 this.assignDocWin();
22535 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22538 getSelectedNode: function()
22540 // this may only work on Gecko!!!
22542 // should we cache this!!!!
22547 var range = this.createRange(this.getSelection()).cloneRange();
22550 var parent = range.parentElement();
22552 var testRange = range.duplicate();
22553 testRange.moveToElementText(parent);
22554 if (testRange.inRange(range)) {
22557 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22560 parent = parent.parentElement;
22565 // is ancestor a text element.
22566 var ac = range.commonAncestorContainer;
22567 if (ac.nodeType == 3) {
22568 ac = ac.parentNode;
22571 var ar = ac.childNodes;
22574 var other_nodes = [];
22575 var has_other_nodes = false;
22576 for (var i=0;i<ar.length;i++) {
22577 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22580 // fullly contained node.
22582 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22587 // probably selected..
22588 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22589 other_nodes.push(ar[i]);
22593 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22598 has_other_nodes = true;
22600 if (!nodes.length && other_nodes.length) {
22601 nodes= other_nodes;
22603 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22609 createRange: function(sel)
22611 // this has strange effects when using with
22612 // top toolbar - not sure if it's a great idea.
22613 //this.editor.contentWindow.focus();
22614 if (typeof sel != "undefined") {
22616 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22618 return this.doc.createRange();
22621 return this.doc.createRange();
22624 getParentElement: function()
22627 this.assignDocWin();
22628 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22630 var range = this.createRange(sel);
22633 var p = range.commonAncestorContainer;
22634 while (p.nodeType == 3) { // text node
22645 * Range intersection.. the hard stuff...
22649 * [ -- selected range --- ]
22653 * if end is before start or hits it. fail.
22654 * if start is after end or hits it fail.
22656 * if either hits (but other is outside. - then it's not
22662 // @see http://www.thismuchiknow.co.uk/?p=64.
22663 rangeIntersectsNode : function(range, node)
22665 var nodeRange = node.ownerDocument.createRange();
22667 nodeRange.selectNode(node);
22669 nodeRange.selectNodeContents(node);
22672 var rangeStartRange = range.cloneRange();
22673 rangeStartRange.collapse(true);
22675 var rangeEndRange = range.cloneRange();
22676 rangeEndRange.collapse(false);
22678 var nodeStartRange = nodeRange.cloneRange();
22679 nodeStartRange.collapse(true);
22681 var nodeEndRange = nodeRange.cloneRange();
22682 nodeEndRange.collapse(false);
22684 return rangeStartRange.compareBoundaryPoints(
22685 Range.START_TO_START, nodeEndRange) == -1 &&
22686 rangeEndRange.compareBoundaryPoints(
22687 Range.START_TO_START, nodeStartRange) == 1;
22691 rangeCompareNode : function(range, node)
22693 var nodeRange = node.ownerDocument.createRange();
22695 nodeRange.selectNode(node);
22697 nodeRange.selectNodeContents(node);
22701 range.collapse(true);
22703 nodeRange.collapse(true);
22705 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22706 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22708 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22710 var nodeIsBefore = ss == 1;
22711 var nodeIsAfter = ee == -1;
22713 if (nodeIsBefore && nodeIsAfter) {
22716 if (!nodeIsBefore && nodeIsAfter) {
22717 return 1; //right trailed.
22720 if (nodeIsBefore && !nodeIsAfter) {
22721 return 2; // left trailed.
22727 // private? - in a new class?
22728 cleanUpPaste : function()
22730 // cleans up the whole document..
22731 Roo.log('cleanuppaste');
22733 this.cleanUpChildren(this.doc.body);
22734 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22735 if (clean != this.doc.body.innerHTML) {
22736 this.doc.body.innerHTML = clean;
22741 cleanWordChars : function(input) {// change the chars to hex code
22742 var he = Roo.HtmlEditorCore;
22744 var output = input;
22745 Roo.each(he.swapCodes, function(sw) {
22746 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22748 output = output.replace(swapper, sw[1]);
22755 cleanUpChildren : function (n)
22757 if (!n.childNodes.length) {
22760 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22761 this.cleanUpChild(n.childNodes[i]);
22768 cleanUpChild : function (node)
22771 //console.log(node);
22772 if (node.nodeName == "#text") {
22773 // clean up silly Windows -- stuff?
22776 if (node.nodeName == "#comment") {
22777 node.parentNode.removeChild(node);
22778 // clean up silly Windows -- stuff?
22781 var lcname = node.tagName.toLowerCase();
22782 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22783 // whitelist of tags..
22785 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22787 node.parentNode.removeChild(node);
22792 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22794 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22795 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22797 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22798 // remove_keep_children = true;
22801 if (remove_keep_children) {
22802 this.cleanUpChildren(node);
22803 // inserts everything just before this node...
22804 while (node.childNodes.length) {
22805 var cn = node.childNodes[0];
22806 node.removeChild(cn);
22807 node.parentNode.insertBefore(cn, node);
22809 node.parentNode.removeChild(node);
22813 if (!node.attributes || !node.attributes.length) {
22814 this.cleanUpChildren(node);
22818 function cleanAttr(n,v)
22821 if (v.match(/^\./) || v.match(/^\//)) {
22824 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22827 if (v.match(/^#/)) {
22830 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22831 node.removeAttribute(n);
22835 var cwhite = this.cwhite;
22836 var cblack = this.cblack;
22838 function cleanStyle(n,v)
22840 if (v.match(/expression/)) { //XSS?? should we even bother..
22841 node.removeAttribute(n);
22845 var parts = v.split(/;/);
22848 Roo.each(parts, function(p) {
22849 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22853 var l = p.split(':').shift().replace(/\s+/g,'');
22854 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22856 if ( cwhite.length && cblack.indexOf(l) > -1) {
22857 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22858 //node.removeAttribute(n);
22862 // only allow 'c whitelisted system attributes'
22863 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22864 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22865 //node.removeAttribute(n);
22875 if (clean.length) {
22876 node.setAttribute(n, clean.join(';'));
22878 node.removeAttribute(n);
22884 for (var i = node.attributes.length-1; i > -1 ; i--) {
22885 var a = node.attributes[i];
22888 if (a.name.toLowerCase().substr(0,2)=='on') {
22889 node.removeAttribute(a.name);
22892 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22893 node.removeAttribute(a.name);
22896 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22897 cleanAttr(a.name,a.value); // fixme..
22900 if (a.name == 'style') {
22901 cleanStyle(a.name,a.value);
22904 /// clean up MS crap..
22905 // tecnically this should be a list of valid class'es..
22908 if (a.name == 'class') {
22909 if (a.value.match(/^Mso/)) {
22910 node.className = '';
22913 if (a.value.match(/^body$/)) {
22914 node.className = '';
22925 this.cleanUpChildren(node);
22931 * Clean up MS wordisms...
22933 cleanWord : function(node)
22938 this.cleanWord(this.doc.body);
22941 if (node.nodeName == "#text") {
22942 // clean up silly Windows -- stuff?
22945 if (node.nodeName == "#comment") {
22946 node.parentNode.removeChild(node);
22947 // clean up silly Windows -- stuff?
22951 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22952 node.parentNode.removeChild(node);
22956 // remove - but keep children..
22957 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22958 while (node.childNodes.length) {
22959 var cn = node.childNodes[0];
22960 node.removeChild(cn);
22961 node.parentNode.insertBefore(cn, node);
22963 node.parentNode.removeChild(node);
22964 this.iterateChildren(node, this.cleanWord);
22968 if (node.className.length) {
22970 var cn = node.className.split(/\W+/);
22972 Roo.each(cn, function(cls) {
22973 if (cls.match(/Mso[a-zA-Z]+/)) {
22978 node.className = cna.length ? cna.join(' ') : '';
22980 node.removeAttribute("class");
22984 if (node.hasAttribute("lang")) {
22985 node.removeAttribute("lang");
22988 if (node.hasAttribute("style")) {
22990 var styles = node.getAttribute("style").split(";");
22992 Roo.each(styles, function(s) {
22993 if (!s.match(/:/)) {
22996 var kv = s.split(":");
22997 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23000 // what ever is left... we allow.
23003 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23004 if (!nstyle.length) {
23005 node.removeAttribute('style');
23008 this.iterateChildren(node, this.cleanWord);
23014 * iterateChildren of a Node, calling fn each time, using this as the scole..
23015 * @param {DomNode} node node to iterate children of.
23016 * @param {Function} fn method of this class to call on each item.
23018 iterateChildren : function(node, fn)
23020 if (!node.childNodes.length) {
23023 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23024 fn.call(this, node.childNodes[i])
23030 * cleanTableWidths.
23032 * Quite often pasting from word etc.. results in tables with column and widths.
23033 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23036 cleanTableWidths : function(node)
23041 this.cleanTableWidths(this.doc.body);
23046 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23049 Roo.log(node.tagName);
23050 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23051 this.iterateChildren(node, this.cleanTableWidths);
23054 if (node.hasAttribute('width')) {
23055 node.removeAttribute('width');
23059 if (node.hasAttribute("style")) {
23062 var styles = node.getAttribute("style").split(";");
23064 Roo.each(styles, function(s) {
23065 if (!s.match(/:/)) {
23068 var kv = s.split(":");
23069 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23072 // what ever is left... we allow.
23075 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23076 if (!nstyle.length) {
23077 node.removeAttribute('style');
23081 this.iterateChildren(node, this.cleanTableWidths);
23089 domToHTML : function(currentElement, depth, nopadtext) {
23091 depth = depth || 0;
23092 nopadtext = nopadtext || false;
23094 if (!currentElement) {
23095 return this.domToHTML(this.doc.body);
23098 //Roo.log(currentElement);
23100 var allText = false;
23101 var nodeName = currentElement.nodeName;
23102 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23104 if (nodeName == '#text') {
23106 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23111 if (nodeName != 'BODY') {
23114 // Prints the node tagName, such as <A>, <IMG>, etc
23117 for(i = 0; i < currentElement.attributes.length;i++) {
23119 var aname = currentElement.attributes.item(i).name;
23120 if (!currentElement.attributes.item(i).value.length) {
23123 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23126 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23135 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23138 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23143 // Traverse the tree
23145 var currentElementChild = currentElement.childNodes.item(i);
23146 var allText = true;
23147 var innerHTML = '';
23149 while (currentElementChild) {
23150 // Formatting code (indent the tree so it looks nice on the screen)
23151 var nopad = nopadtext;
23152 if (lastnode == 'SPAN') {
23156 if (currentElementChild.nodeName == '#text') {
23157 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23158 toadd = nopadtext ? toadd : toadd.trim();
23159 if (!nopad && toadd.length > 80) {
23160 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23162 innerHTML += toadd;
23165 currentElementChild = currentElement.childNodes.item(i);
23171 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23173 // Recursively traverse the tree structure of the child node
23174 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23175 lastnode = currentElementChild.nodeName;
23177 currentElementChild=currentElement.childNodes.item(i);
23183 // The remaining code is mostly for formatting the tree
23184 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23189 ret+= "</"+tagName+">";
23195 applyBlacklists : function()
23197 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23198 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23202 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23203 if (b.indexOf(tag) > -1) {
23206 this.white.push(tag);
23210 Roo.each(w, function(tag) {
23211 if (b.indexOf(tag) > -1) {
23214 if (this.white.indexOf(tag) > -1) {
23217 this.white.push(tag);
23222 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23223 if (w.indexOf(tag) > -1) {
23226 this.black.push(tag);
23230 Roo.each(b, function(tag) {
23231 if (w.indexOf(tag) > -1) {
23234 if (this.black.indexOf(tag) > -1) {
23237 this.black.push(tag);
23242 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23243 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23247 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23248 if (b.indexOf(tag) > -1) {
23251 this.cwhite.push(tag);
23255 Roo.each(w, function(tag) {
23256 if (b.indexOf(tag) > -1) {
23259 if (this.cwhite.indexOf(tag) > -1) {
23262 this.cwhite.push(tag);
23267 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23268 if (w.indexOf(tag) > -1) {
23271 this.cblack.push(tag);
23275 Roo.each(b, function(tag) {
23276 if (w.indexOf(tag) > -1) {
23279 if (this.cblack.indexOf(tag) > -1) {
23282 this.cblack.push(tag);
23287 setStylesheets : function(stylesheets)
23289 if(typeof(stylesheets) == 'string'){
23290 Roo.get(this.iframe.contentDocument.head).createChild({
23292 rel : 'stylesheet',
23301 Roo.each(stylesheets, function(s) {
23306 Roo.get(_this.iframe.contentDocument.head).createChild({
23308 rel : 'stylesheet',
23317 removeStylesheets : function()
23321 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23326 setStyle : function(style)
23328 Roo.get(this.iframe.contentDocument.head).createChild({
23337 // hide stuff that is not compatible
23351 * @event specialkey
23355 * @cfg {String} fieldClass @hide
23358 * @cfg {String} focusClass @hide
23361 * @cfg {String} autoCreate @hide
23364 * @cfg {String} inputType @hide
23367 * @cfg {String} invalidClass @hide
23370 * @cfg {String} invalidText @hide
23373 * @cfg {String} msgFx @hide
23376 * @cfg {String} validateOnBlur @hide
23380 Roo.HtmlEditorCore.white = [
23381 'area', 'br', 'img', 'input', 'hr', 'wbr',
23383 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23384 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23385 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23386 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23387 'table', 'ul', 'xmp',
23389 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23392 'dir', 'menu', 'ol', 'ul', 'dl',
23398 Roo.HtmlEditorCore.black = [
23399 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23401 'base', 'basefont', 'bgsound', 'blink', 'body',
23402 'frame', 'frameset', 'head', 'html', 'ilayer',
23403 'iframe', 'layer', 'link', 'meta', 'object',
23404 'script', 'style' ,'title', 'xml' // clean later..
23406 Roo.HtmlEditorCore.clean = [
23407 'script', 'style', 'title', 'xml'
23409 Roo.HtmlEditorCore.remove = [
23414 Roo.HtmlEditorCore.ablack = [
23418 Roo.HtmlEditorCore.aclean = [
23419 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23423 Roo.HtmlEditorCore.pwhite= [
23424 'http', 'https', 'mailto'
23427 // white listed style attributes.
23428 Roo.HtmlEditorCore.cwhite= [
23429 // 'text-align', /// default is to allow most things..
23435 // black listed style attributes.
23436 Roo.HtmlEditorCore.cblack= [
23437 // 'font-size' -- this can be set by the project
23441 Roo.HtmlEditorCore.swapCodes =[
23460 * @class Roo.bootstrap.HtmlEditor
23461 * @extends Roo.bootstrap.TextArea
23462 * Bootstrap HtmlEditor class
23465 * Create a new HtmlEditor
23466 * @param {Object} config The config object
23469 Roo.bootstrap.HtmlEditor = function(config){
23470 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23471 if (!this.toolbars) {
23472 this.toolbars = [];
23475 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23478 * @event initialize
23479 * Fires when the editor is fully initialized (including the iframe)
23480 * @param {HtmlEditor} this
23485 * Fires when the editor is first receives the focus. Any insertion must wait
23486 * until after this event.
23487 * @param {HtmlEditor} this
23491 * @event beforesync
23492 * Fires before the textarea is updated with content from the editor iframe. Return false
23493 * to cancel the sync.
23494 * @param {HtmlEditor} this
23495 * @param {String} html
23499 * @event beforepush
23500 * Fires before the iframe editor is updated with content from the textarea. Return false
23501 * to cancel the push.
23502 * @param {HtmlEditor} this
23503 * @param {String} html
23508 * Fires when the textarea is updated with content from the editor iframe.
23509 * @param {HtmlEditor} this
23510 * @param {String} html
23515 * Fires when the iframe editor is updated with content from the textarea.
23516 * @param {HtmlEditor} this
23517 * @param {String} html
23521 * @event editmodechange
23522 * Fires when the editor switches edit modes
23523 * @param {HtmlEditor} this
23524 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23526 editmodechange: true,
23528 * @event editorevent
23529 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23530 * @param {HtmlEditor} this
23534 * @event firstfocus
23535 * Fires when on first focus - needed by toolbars..
23536 * @param {HtmlEditor} this
23541 * Auto save the htmlEditor value as a file into Events
23542 * @param {HtmlEditor} this
23546 * @event savedpreview
23547 * preview the saved version of htmlEditor
23548 * @param {HtmlEditor} this
23555 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23559 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23564 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23569 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23574 * @cfg {Number} height (in pixels)
23578 * @cfg {Number} width (in pixels)
23583 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23586 stylesheets: false,
23591 // private properties
23592 validationEvent : false,
23594 initialized : false,
23597 onFocus : Roo.emptyFn,
23599 hideMode:'offsets',
23601 tbContainer : false,
23605 toolbarContainer :function() {
23606 return this.wrap.select('.x-html-editor-tb',true).first();
23610 * Protected method that will not generally be called directly. It
23611 * is called when the editor creates its toolbar. Override this method if you need to
23612 * add custom toolbar buttons.
23613 * @param {HtmlEditor} editor
23615 createToolbar : function(){
23616 Roo.log('renewing');
23617 Roo.log("create toolbars");
23619 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23620 this.toolbars[0].render(this.toolbarContainer());
23624 // if (!editor.toolbars || !editor.toolbars.length) {
23625 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23628 // for (var i =0 ; i < editor.toolbars.length;i++) {
23629 // editor.toolbars[i] = Roo.factory(
23630 // typeof(editor.toolbars[i]) == 'string' ?
23631 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23632 // Roo.bootstrap.HtmlEditor);
23633 // editor.toolbars[i].init(editor);
23639 onRender : function(ct, position)
23641 // Roo.log("Call onRender: " + this.xtype);
23643 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23645 this.wrap = this.inputEl().wrap({
23646 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23649 this.editorcore.onRender(ct, position);
23651 if (this.resizable) {
23652 this.resizeEl = new Roo.Resizable(this.wrap, {
23656 minHeight : this.height,
23657 height: this.height,
23658 handles : this.resizable,
23661 resize : function(r, w, h) {
23662 _t.onResize(w,h); // -something
23668 this.createToolbar(this);
23671 if(!this.width && this.resizable){
23672 this.setSize(this.wrap.getSize());
23674 if (this.resizeEl) {
23675 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23676 // should trigger onReize..
23682 onResize : function(w, h)
23684 Roo.log('resize: ' +w + ',' + h );
23685 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23689 if(this.inputEl() ){
23690 if(typeof w == 'number'){
23691 var aw = w - this.wrap.getFrameWidth('lr');
23692 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23695 if(typeof h == 'number'){
23696 var tbh = -11; // fixme it needs to tool bar size!
23697 for (var i =0; i < this.toolbars.length;i++) {
23698 // fixme - ask toolbars for heights?
23699 tbh += this.toolbars[i].el.getHeight();
23700 //if (this.toolbars[i].footer) {
23701 // tbh += this.toolbars[i].footer.el.getHeight();
23709 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23710 ah -= 5; // knock a few pixes off for look..
23711 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23715 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23716 this.editorcore.onResize(ew,eh);
23721 * Toggles the editor between standard and source edit mode.
23722 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23724 toggleSourceEdit : function(sourceEditMode)
23726 this.editorcore.toggleSourceEdit(sourceEditMode);
23728 if(this.editorcore.sourceEditMode){
23729 Roo.log('editor - showing textarea');
23732 // Roo.log(this.syncValue());
23734 this.inputEl().removeClass(['hide', 'x-hidden']);
23735 this.inputEl().dom.removeAttribute('tabIndex');
23736 this.inputEl().focus();
23738 Roo.log('editor - hiding textarea');
23740 // Roo.log(this.pushValue());
23743 this.inputEl().addClass(['hide', 'x-hidden']);
23744 this.inputEl().dom.setAttribute('tabIndex', -1);
23745 //this.deferFocus();
23748 if(this.resizable){
23749 this.setSize(this.wrap.getSize());
23752 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23755 // private (for BoxComponent)
23756 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23758 // private (for BoxComponent)
23759 getResizeEl : function(){
23763 // private (for BoxComponent)
23764 getPositionEl : function(){
23769 initEvents : function(){
23770 this.originalValue = this.getValue();
23774 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23777 // markInvalid : Roo.emptyFn,
23779 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23782 // clearInvalid : Roo.emptyFn,
23784 setValue : function(v){
23785 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23786 this.editorcore.pushValue();
23791 deferFocus : function(){
23792 this.focus.defer(10, this);
23796 focus : function(){
23797 this.editorcore.focus();
23803 onDestroy : function(){
23809 for (var i =0; i < this.toolbars.length;i++) {
23810 // fixme - ask toolbars for heights?
23811 this.toolbars[i].onDestroy();
23814 this.wrap.dom.innerHTML = '';
23815 this.wrap.remove();
23820 onFirstFocus : function(){
23821 //Roo.log("onFirstFocus");
23822 this.editorcore.onFirstFocus();
23823 for (var i =0; i < this.toolbars.length;i++) {
23824 this.toolbars[i].onFirstFocus();
23830 syncValue : function()
23832 this.editorcore.syncValue();
23835 pushValue : function()
23837 this.editorcore.pushValue();
23841 // hide stuff that is not compatible
23855 * @event specialkey
23859 * @cfg {String} fieldClass @hide
23862 * @cfg {String} focusClass @hide
23865 * @cfg {String} autoCreate @hide
23868 * @cfg {String} inputType @hide
23871 * @cfg {String} invalidClass @hide
23874 * @cfg {String} invalidText @hide
23877 * @cfg {String} msgFx @hide
23880 * @cfg {String} validateOnBlur @hide
23889 Roo.namespace('Roo.bootstrap.htmleditor');
23891 * @class Roo.bootstrap.HtmlEditorToolbar1
23896 new Roo.bootstrap.HtmlEditor({
23899 new Roo.bootstrap.HtmlEditorToolbar1({
23900 disable : { fonts: 1 , format: 1, ..., ... , ...],
23906 * @cfg {Object} disable List of elements to disable..
23907 * @cfg {Array} btns List of additional buttons.
23911 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23914 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23917 Roo.apply(this, config);
23919 // default disabled, based on 'good practice'..
23920 this.disable = this.disable || {};
23921 Roo.applyIf(this.disable, {
23924 specialElements : true
23926 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23928 this.editor = config.editor;
23929 this.editorcore = config.editor.editorcore;
23931 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23933 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23934 // dont call parent... till later.
23936 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23941 editorcore : false,
23946 "h1","h2","h3","h4","h5","h6",
23948 "abbr", "acronym", "address", "cite", "samp", "var",
23952 onRender : function(ct, position)
23954 // Roo.log("Call onRender: " + this.xtype);
23956 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23958 this.el.dom.style.marginBottom = '0';
23960 var editorcore = this.editorcore;
23961 var editor= this.editor;
23964 var btn = function(id,cmd , toggle, handler, html){
23966 var event = toggle ? 'toggle' : 'click';
23971 xns: Roo.bootstrap,
23974 enableToggle:toggle !== false,
23976 pressed : toggle ? false : null,
23979 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23980 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23986 // var cb_box = function...
23991 xns: Roo.bootstrap,
23992 glyphicon : 'font',
23996 xns: Roo.bootstrap,
24000 Roo.each(this.formats, function(f) {
24001 style.menu.items.push({
24003 xns: Roo.bootstrap,
24004 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24009 editorcore.insertTag(this.tagname);
24016 children.push(style);
24018 btn('bold',false,true);
24019 btn('italic',false,true);
24020 btn('align-left', 'justifyleft',true);
24021 btn('align-center', 'justifycenter',true);
24022 btn('align-right' , 'justifyright',true);
24023 btn('link', false, false, function(btn) {
24024 //Roo.log("create link?");
24025 var url = prompt(this.createLinkText, this.defaultLinkValue);
24026 if(url && url != 'http:/'+'/'){
24027 this.editorcore.relayCmd('createlink', url);
24030 btn('list','insertunorderedlist',true);
24031 btn('pencil', false,true, function(btn){
24033 this.toggleSourceEdit(btn.pressed);
24036 if (this.editor.btns.length > 0) {
24037 for (var i = 0; i<this.editor.btns.length; i++) {
24038 children.push(this.editor.btns[i]);
24046 xns: Roo.bootstrap,
24051 xns: Roo.bootstrap,
24056 cog.menu.items.push({
24058 xns: Roo.bootstrap,
24059 html : Clean styles,
24064 editorcore.insertTag(this.tagname);
24073 this.xtype = 'NavSimplebar';
24075 for(var i=0;i< children.length;i++) {
24077 this.buttons.add(this.addxtypeChild(children[i]));
24081 editor.on('editorevent', this.updateToolbar, this);
24083 onBtnClick : function(id)
24085 this.editorcore.relayCmd(id);
24086 this.editorcore.focus();
24090 * Protected method that will not generally be called directly. It triggers
24091 * a toolbar update by reading the markup state of the current selection in the editor.
24093 updateToolbar: function(){
24095 if(!this.editorcore.activated){
24096 this.editor.onFirstFocus(); // is this neeed?
24100 var btns = this.buttons;
24101 var doc = this.editorcore.doc;
24102 btns.get('bold').setActive(doc.queryCommandState('bold'));
24103 btns.get('italic').setActive(doc.queryCommandState('italic'));
24104 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24106 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24107 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24108 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24110 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24111 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24114 var ans = this.editorcore.getAllAncestors();
24115 if (this.formatCombo) {
24118 var store = this.formatCombo.store;
24119 this.formatCombo.setValue("");
24120 for (var i =0; i < ans.length;i++) {
24121 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24123 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24131 // hides menus... - so this cant be on a menu...
24132 Roo.bootstrap.MenuMgr.hideAll();
24134 Roo.bootstrap.MenuMgr.hideAll();
24135 //this.editorsyncValue();
24137 onFirstFocus: function() {
24138 this.buttons.each(function(item){
24142 toggleSourceEdit : function(sourceEditMode){
24145 if(sourceEditMode){
24146 Roo.log("disabling buttons");
24147 this.buttons.each( function(item){
24148 if(item.cmd != 'pencil'){
24154 Roo.log("enabling buttons");
24155 if(this.editorcore.initialized){
24156 this.buttons.each( function(item){
24162 Roo.log("calling toggole on editor");
24163 // tell the editor that it's been pressed..
24164 this.editor.toggleSourceEdit(sourceEditMode);
24174 * @class Roo.bootstrap.Table.AbstractSelectionModel
24175 * @extends Roo.util.Observable
24176 * Abstract base class for grid SelectionModels. It provides the interface that should be
24177 * implemented by descendant classes. This class should not be directly instantiated.
24180 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24181 this.locked = false;
24182 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24186 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24187 /** @ignore Called by the grid automatically. Do not call directly. */
24188 init : function(grid){
24194 * Locks the selections.
24197 this.locked = true;
24201 * Unlocks the selections.
24203 unlock : function(){
24204 this.locked = false;
24208 * Returns true if the selections are locked.
24209 * @return {Boolean}
24211 isLocked : function(){
24212 return this.locked;
24216 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24217 * @class Roo.bootstrap.Table.RowSelectionModel
24218 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24219 * It supports multiple selections and keyboard selection/navigation.
24221 * @param {Object} config
24224 Roo.bootstrap.Table.RowSelectionModel = function(config){
24225 Roo.apply(this, config);
24226 this.selections = new Roo.util.MixedCollection(false, function(o){
24231 this.lastActive = false;
24235 * @event selectionchange
24236 * Fires when the selection changes
24237 * @param {SelectionModel} this
24239 "selectionchange" : true,
24241 * @event afterselectionchange
24242 * Fires after the selection changes (eg. by key press or clicking)
24243 * @param {SelectionModel} this
24245 "afterselectionchange" : true,
24247 * @event beforerowselect
24248 * Fires when a row is selected being selected, return false to cancel.
24249 * @param {SelectionModel} this
24250 * @param {Number} rowIndex The selected index
24251 * @param {Boolean} keepExisting False if other selections will be cleared
24253 "beforerowselect" : true,
24256 * Fires when a row is selected.
24257 * @param {SelectionModel} this
24258 * @param {Number} rowIndex The selected index
24259 * @param {Roo.data.Record} r The record
24261 "rowselect" : true,
24263 * @event rowdeselect
24264 * Fires when a row is deselected.
24265 * @param {SelectionModel} this
24266 * @param {Number} rowIndex The selected index
24268 "rowdeselect" : true
24270 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24271 this.locked = false;
24274 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24276 * @cfg {Boolean} singleSelect
24277 * True to allow selection of only one row at a time (defaults to false)
24279 singleSelect : false,
24282 initEvents : function()
24285 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24286 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24287 //}else{ // allow click to work like normal
24288 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24290 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24291 this.grid.on("rowclick", this.handleMouseDown, this);
24293 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24294 "up" : function(e){
24296 this.selectPrevious(e.shiftKey);
24297 }else if(this.last !== false && this.lastActive !== false){
24298 var last = this.last;
24299 this.selectRange(this.last, this.lastActive-1);
24300 this.grid.getView().focusRow(this.lastActive);
24301 if(last !== false){
24305 this.selectFirstRow();
24307 this.fireEvent("afterselectionchange", this);
24309 "down" : function(e){
24311 this.selectNext(e.shiftKey);
24312 }else if(this.last !== false && this.lastActive !== false){
24313 var last = this.last;
24314 this.selectRange(this.last, this.lastActive+1);
24315 this.grid.getView().focusRow(this.lastActive);
24316 if(last !== false){
24320 this.selectFirstRow();
24322 this.fireEvent("afterselectionchange", this);
24326 this.grid.store.on('load', function(){
24327 this.selections.clear();
24330 var view = this.grid.view;
24331 view.on("refresh", this.onRefresh, this);
24332 view.on("rowupdated", this.onRowUpdated, this);
24333 view.on("rowremoved", this.onRemove, this);
24338 onRefresh : function()
24340 var ds = this.grid.store, i, v = this.grid.view;
24341 var s = this.selections;
24342 s.each(function(r){
24343 if((i = ds.indexOfId(r.id)) != -1){
24352 onRemove : function(v, index, r){
24353 this.selections.remove(r);
24357 onRowUpdated : function(v, index, r){
24358 if(this.isSelected(r)){
24359 v.onRowSelect(index);
24365 * @param {Array} records The records to select
24366 * @param {Boolean} keepExisting (optional) True to keep existing selections
24368 selectRecords : function(records, keepExisting)
24371 this.clearSelections();
24373 var ds = this.grid.store;
24374 for(var i = 0, len = records.length; i < len; i++){
24375 this.selectRow(ds.indexOf(records[i]), true);
24380 * Gets the number of selected rows.
24383 getCount : function(){
24384 return this.selections.length;
24388 * Selects the first row in the grid.
24390 selectFirstRow : function(){
24395 * Select the last row.
24396 * @param {Boolean} keepExisting (optional) True to keep existing selections
24398 selectLastRow : function(keepExisting){
24399 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24400 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24404 * Selects the row immediately following the last selected row.
24405 * @param {Boolean} keepExisting (optional) True to keep existing selections
24407 selectNext : function(keepExisting)
24409 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24410 this.selectRow(this.last+1, keepExisting);
24411 this.grid.getView().focusRow(this.last);
24416 * Selects the row that precedes the last selected row.
24417 * @param {Boolean} keepExisting (optional) True to keep existing selections
24419 selectPrevious : function(keepExisting){
24421 this.selectRow(this.last-1, keepExisting);
24422 this.grid.getView().focusRow(this.last);
24427 * Returns the selected records
24428 * @return {Array} Array of selected records
24430 getSelections : function(){
24431 return [].concat(this.selections.items);
24435 * Returns the first selected record.
24438 getSelected : function(){
24439 return this.selections.itemAt(0);
24444 * Clears all selections.
24446 clearSelections : function(fast)
24452 var ds = this.grid.store;
24453 var s = this.selections;
24454 s.each(function(r){
24455 this.deselectRow(ds.indexOfId(r.id));
24459 this.selections.clear();
24466 * Selects all rows.
24468 selectAll : function(){
24472 this.selections.clear();
24473 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24474 this.selectRow(i, true);
24479 * Returns True if there is a selection.
24480 * @return {Boolean}
24482 hasSelection : function(){
24483 return this.selections.length > 0;
24487 * Returns True if the specified row is selected.
24488 * @param {Number/Record} record The record or index of the record to check
24489 * @return {Boolean}
24491 isSelected : function(index){
24492 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24493 return (r && this.selections.key(r.id) ? true : false);
24497 * Returns True if the specified record id is selected.
24498 * @param {String} id The id of record to check
24499 * @return {Boolean}
24501 isIdSelected : function(id){
24502 return (this.selections.key(id) ? true : false);
24507 handleMouseDBClick : function(e, t){
24511 handleMouseDown : function(e, t)
24513 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24514 if(this.isLocked() || rowIndex < 0 ){
24517 if(e.shiftKey && this.last !== false){
24518 var last = this.last;
24519 this.selectRange(last, rowIndex, e.ctrlKey);
24520 this.last = last; // reset the last
24524 var isSelected = this.isSelected(rowIndex);
24525 //Roo.log("select row:" + rowIndex);
24527 this.deselectRow(rowIndex);
24529 this.selectRow(rowIndex, true);
24533 if(e.button !== 0 && isSelected){
24534 alert('rowIndex 2: ' + rowIndex);
24535 view.focusRow(rowIndex);
24536 }else if(e.ctrlKey && isSelected){
24537 this.deselectRow(rowIndex);
24538 }else if(!isSelected){
24539 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24540 view.focusRow(rowIndex);
24544 this.fireEvent("afterselectionchange", this);
24547 handleDragableRowClick : function(grid, rowIndex, e)
24549 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24550 this.selectRow(rowIndex, false);
24551 grid.view.focusRow(rowIndex);
24552 this.fireEvent("afterselectionchange", this);
24557 * Selects multiple rows.
24558 * @param {Array} rows Array of the indexes of the row to select
24559 * @param {Boolean} keepExisting (optional) True to keep existing selections
24561 selectRows : function(rows, keepExisting){
24563 this.clearSelections();
24565 for(var i = 0, len = rows.length; i < len; i++){
24566 this.selectRow(rows[i], true);
24571 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24572 * @param {Number} startRow The index of the first row in the range
24573 * @param {Number} endRow The index of the last row in the range
24574 * @param {Boolean} keepExisting (optional) True to retain existing selections
24576 selectRange : function(startRow, endRow, keepExisting){
24581 this.clearSelections();
24583 if(startRow <= endRow){
24584 for(var i = startRow; i <= endRow; i++){
24585 this.selectRow(i, true);
24588 for(var i = startRow; i >= endRow; i--){
24589 this.selectRow(i, true);
24595 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24596 * @param {Number} startRow The index of the first row in the range
24597 * @param {Number} endRow The index of the last row in the range
24599 deselectRange : function(startRow, endRow, preventViewNotify){
24603 for(var i = startRow; i <= endRow; i++){
24604 this.deselectRow(i, preventViewNotify);
24610 * @param {Number} row The index of the row to select
24611 * @param {Boolean} keepExisting (optional) True to keep existing selections
24613 selectRow : function(index, keepExisting, preventViewNotify)
24615 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24618 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24619 if(!keepExisting || this.singleSelect){
24620 this.clearSelections();
24623 var r = this.grid.store.getAt(index);
24624 //console.log('selectRow - record id :' + r.id);
24626 this.selections.add(r);
24627 this.last = this.lastActive = index;
24628 if(!preventViewNotify){
24629 var proxy = new Roo.Element(
24630 this.grid.getRowDom(index)
24632 proxy.addClass('bg-info info');
24634 this.fireEvent("rowselect", this, index, r);
24635 this.fireEvent("selectionchange", this);
24641 * @param {Number} row The index of the row to deselect
24643 deselectRow : function(index, preventViewNotify)
24648 if(this.last == index){
24651 if(this.lastActive == index){
24652 this.lastActive = false;
24655 var r = this.grid.store.getAt(index);
24660 this.selections.remove(r);
24661 //.console.log('deselectRow - record id :' + r.id);
24662 if(!preventViewNotify){
24664 var proxy = new Roo.Element(
24665 this.grid.getRowDom(index)
24667 proxy.removeClass('bg-info info');
24669 this.fireEvent("rowdeselect", this, index);
24670 this.fireEvent("selectionchange", this);
24674 restoreLast : function(){
24676 this.last = this._last;
24681 acceptsNav : function(row, col, cm){
24682 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24686 onEditorKey : function(field, e){
24687 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24692 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24694 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24696 }else if(k == e.ENTER && !e.ctrlKey){
24700 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24702 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24704 }else if(k == e.ESC){
24708 g.startEditing(newCell[0], newCell[1]);
24714 * Ext JS Library 1.1.1
24715 * Copyright(c) 2006-2007, Ext JS, LLC.
24717 * Originally Released Under LGPL - original licence link has changed is not relivant.
24720 * <script type="text/javascript">
24724 * @class Roo.bootstrap.PagingToolbar
24725 * @extends Roo.bootstrap.NavSimplebar
24726 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24728 * Create a new PagingToolbar
24729 * @param {Object} config The config object
24730 * @param {Roo.data.Store} store
24732 Roo.bootstrap.PagingToolbar = function(config)
24734 // old args format still supported... - xtype is prefered..
24735 // created from xtype...
24737 this.ds = config.dataSource;
24739 if (config.store && !this.ds) {
24740 this.store= Roo.factory(config.store, Roo.data);
24741 this.ds = this.store;
24742 this.ds.xmodule = this.xmodule || false;
24745 this.toolbarItems = [];
24746 if (config.items) {
24747 this.toolbarItems = config.items;
24750 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24755 this.bind(this.ds);
24758 if (Roo.bootstrap.version == 4) {
24759 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24761 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24766 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24768 * @cfg {Roo.data.Store} dataSource
24769 * The underlying data store providing the paged data
24772 * @cfg {String/HTMLElement/Element} container
24773 * container The id or element that will contain the toolbar
24776 * @cfg {Boolean} displayInfo
24777 * True to display the displayMsg (defaults to false)
24780 * @cfg {Number} pageSize
24781 * The number of records to display per page (defaults to 20)
24785 * @cfg {String} displayMsg
24786 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24788 displayMsg : 'Displaying {0} - {1} of {2}',
24790 * @cfg {String} emptyMsg
24791 * The message to display when no records are found (defaults to "No data to display")
24793 emptyMsg : 'No data to display',
24795 * Customizable piece of the default paging text (defaults to "Page")
24798 beforePageText : "Page",
24800 * Customizable piece of the default paging text (defaults to "of %0")
24803 afterPageText : "of {0}",
24805 * Customizable piece of the default paging text (defaults to "First Page")
24808 firstText : "First Page",
24810 * Customizable piece of the default paging text (defaults to "Previous Page")
24813 prevText : "Previous Page",
24815 * Customizable piece of the default paging text (defaults to "Next Page")
24818 nextText : "Next Page",
24820 * Customizable piece of the default paging text (defaults to "Last Page")
24823 lastText : "Last Page",
24825 * Customizable piece of the default paging text (defaults to "Refresh")
24828 refreshText : "Refresh",
24832 onRender : function(ct, position)
24834 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24835 this.navgroup.parentId = this.id;
24836 this.navgroup.onRender(this.el, null);
24837 // add the buttons to the navgroup
24839 if(this.displayInfo){
24840 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24841 this.displayEl = this.el.select('.x-paging-info', true).first();
24842 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24843 // this.displayEl = navel.el.select('span',true).first();
24849 Roo.each(_this.buttons, function(e){ // this might need to use render????
24850 Roo.factory(e).render(_this.el);
24854 Roo.each(_this.toolbarItems, function(e) {
24855 _this.navgroup.addItem(e);
24859 this.first = this.navgroup.addItem({
24860 tooltip: this.firstText,
24861 cls: "prev btn-outline-secondary",
24862 html : ' <i class="fa fa-step-backward"></i>',
24864 preventDefault: true,
24865 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24868 this.prev = this.navgroup.addItem({
24869 tooltip: this.prevText,
24870 cls: "prev btn-outline-secondary",
24871 html : ' <i class="fa fa-backward"></i>',
24873 preventDefault: true,
24874 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24876 //this.addSeparator();
24879 var field = this.navgroup.addItem( {
24881 cls : 'x-paging-position btn-outline-secondary',
24883 html : this.beforePageText +
24884 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24885 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24888 this.field = field.el.select('input', true).first();
24889 this.field.on("keydown", this.onPagingKeydown, this);
24890 this.field.on("focus", function(){this.dom.select();});
24893 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24894 //this.field.setHeight(18);
24895 //this.addSeparator();
24896 this.next = this.navgroup.addItem({
24897 tooltip: this.nextText,
24898 cls: "next btn-outline-secondary",
24899 html : ' <i class="fa fa-forward"></i>',
24901 preventDefault: true,
24902 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24904 this.last = this.navgroup.addItem({
24905 tooltip: this.lastText,
24906 html : ' <i class="fa fa-step-forward"></i>',
24907 cls: "next btn-outline-secondary",
24909 preventDefault: true,
24910 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24912 //this.addSeparator();
24913 this.loading = this.navgroup.addItem({
24914 tooltip: this.refreshText,
24915 cls: "btn-outline-secondary",
24916 html : ' <i class="fa fa-refresh"></i>',
24917 preventDefault: true,
24918 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24924 updateInfo : function(){
24925 if(this.displayEl){
24926 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24927 var msg = count == 0 ?
24931 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24933 this.displayEl.update(msg);
24938 onLoad : function(ds, r, o)
24940 this.cursor = o.params.start ? o.params.start : 0;
24942 var d = this.getPageData(),
24947 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24948 this.field.dom.value = ap;
24949 this.first.setDisabled(ap == 1);
24950 this.prev.setDisabled(ap == 1);
24951 this.next.setDisabled(ap == ps);
24952 this.last.setDisabled(ap == ps);
24953 this.loading.enable();
24958 getPageData : function(){
24959 var total = this.ds.getTotalCount();
24962 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24963 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24968 onLoadError : function(){
24969 this.loading.enable();
24973 onPagingKeydown : function(e){
24974 var k = e.getKey();
24975 var d = this.getPageData();
24977 var v = this.field.dom.value, pageNum;
24978 if(!v || isNaN(pageNum = parseInt(v, 10))){
24979 this.field.dom.value = d.activePage;
24982 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24983 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24986 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))
24988 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24989 this.field.dom.value = pageNum;
24990 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24993 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24995 var v = this.field.dom.value, pageNum;
24996 var increment = (e.shiftKey) ? 10 : 1;
24997 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25000 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25001 this.field.dom.value = d.activePage;
25004 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25006 this.field.dom.value = parseInt(v, 10) + increment;
25007 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25008 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25015 beforeLoad : function(){
25017 this.loading.disable();
25022 onClick : function(which){
25031 ds.load({params:{start: 0, limit: this.pageSize}});
25034 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25037 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25040 var total = ds.getTotalCount();
25041 var extra = total % this.pageSize;
25042 var lastStart = extra ? (total - extra) : total-this.pageSize;
25043 ds.load({params:{start: lastStart, limit: this.pageSize}});
25046 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25052 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25053 * @param {Roo.data.Store} store The data store to unbind
25055 unbind : function(ds){
25056 ds.un("beforeload", this.beforeLoad, this);
25057 ds.un("load", this.onLoad, this);
25058 ds.un("loadexception", this.onLoadError, this);
25059 ds.un("remove", this.updateInfo, this);
25060 ds.un("add", this.updateInfo, this);
25061 this.ds = undefined;
25065 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25066 * @param {Roo.data.Store} store The data store to bind
25068 bind : function(ds){
25069 ds.on("beforeload", this.beforeLoad, this);
25070 ds.on("load", this.onLoad, this);
25071 ds.on("loadexception", this.onLoadError, this);
25072 ds.on("remove", this.updateInfo, this);
25073 ds.on("add", this.updateInfo, this);
25084 * @class Roo.bootstrap.MessageBar
25085 * @extends Roo.bootstrap.Component
25086 * Bootstrap MessageBar class
25087 * @cfg {String} html contents of the MessageBar
25088 * @cfg {String} weight (info | success | warning | danger) default info
25089 * @cfg {String} beforeClass insert the bar before the given class
25090 * @cfg {Boolean} closable (true | false) default false
25091 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25094 * Create a new Element
25095 * @param {Object} config The config object
25098 Roo.bootstrap.MessageBar = function(config){
25099 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25102 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25108 beforeClass: 'bootstrap-sticky-wrap',
25110 getAutoCreate : function(){
25114 cls: 'alert alert-dismissable alert-' + this.weight,
25119 html: this.html || ''
25125 cfg.cls += ' alert-messages-fixed';
25139 onRender : function(ct, position)
25141 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25144 var cfg = Roo.apply({}, this.getAutoCreate());
25148 cfg.cls += ' ' + this.cls;
25151 cfg.style = this.style;
25153 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25155 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25158 this.el.select('>button.close').on('click', this.hide, this);
25164 if (!this.rendered) {
25170 this.fireEvent('show', this);
25176 if (!this.rendered) {
25182 this.fireEvent('hide', this);
25185 update : function()
25187 // var e = this.el.dom.firstChild;
25189 // if(this.closable){
25190 // e = e.nextSibling;
25193 // e.data = this.html || '';
25195 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25211 * @class Roo.bootstrap.Graph
25212 * @extends Roo.bootstrap.Component
25213 * Bootstrap Graph class
25217 @cfg {String} graphtype bar | vbar | pie
25218 @cfg {number} g_x coodinator | centre x (pie)
25219 @cfg {number} g_y coodinator | centre y (pie)
25220 @cfg {number} g_r radius (pie)
25221 @cfg {number} g_height height of the chart (respected by all elements in the set)
25222 @cfg {number} g_width width of the chart (respected by all elements in the set)
25223 @cfg {Object} title The title of the chart
25226 -opts (object) options for the chart
25228 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25229 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25231 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.
25232 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25234 o stretch (boolean)
25236 -opts (object) options for the pie
25239 o startAngle (number)
25240 o endAngle (number)
25244 * Create a new Input
25245 * @param {Object} config The config object
25248 Roo.bootstrap.Graph = function(config){
25249 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25255 * The img click event for the img.
25256 * @param {Roo.EventObject} e
25262 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25273 //g_colors: this.colors,
25280 getAutoCreate : function(){
25291 onRender : function(ct,position){
25294 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25296 if (typeof(Raphael) == 'undefined') {
25297 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25301 this.raphael = Raphael(this.el.dom);
25303 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25304 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25305 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25306 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25308 r.text(160, 10, "Single Series Chart").attr(txtattr);
25309 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25310 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25311 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25313 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25314 r.barchart(330, 10, 300, 220, data1);
25315 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25316 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25319 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25320 // r.barchart(30, 30, 560, 250, xdata, {
25321 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25322 // axis : "0 0 1 1",
25323 // axisxlabels : xdata
25324 // //yvalues : cols,
25327 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25329 // this.load(null,xdata,{
25330 // axis : "0 0 1 1",
25331 // axisxlabels : xdata
25336 load : function(graphtype,xdata,opts)
25338 this.raphael.clear();
25340 graphtype = this.graphtype;
25345 var r = this.raphael,
25346 fin = function () {
25347 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25349 fout = function () {
25350 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25352 pfin = function() {
25353 this.sector.stop();
25354 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25357 this.label[0].stop();
25358 this.label[0].attr({ r: 7.5 });
25359 this.label[1].attr({ "font-weight": 800 });
25362 pfout = function() {
25363 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25366 this.label[0].animate({ r: 5 }, 500, "bounce");
25367 this.label[1].attr({ "font-weight": 400 });
25373 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25376 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25379 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25380 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25382 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25389 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25394 setTitle: function(o)
25399 initEvents: function() {
25402 this.el.on('click', this.onClick, this);
25406 onClick : function(e)
25408 Roo.log('img onclick');
25409 this.fireEvent('click', this, e);
25421 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25424 * @class Roo.bootstrap.dash.NumberBox
25425 * @extends Roo.bootstrap.Component
25426 * Bootstrap NumberBox class
25427 * @cfg {String} headline Box headline
25428 * @cfg {String} content Box content
25429 * @cfg {String} icon Box icon
25430 * @cfg {String} footer Footer text
25431 * @cfg {String} fhref Footer href
25434 * Create a new NumberBox
25435 * @param {Object} config The config object
25439 Roo.bootstrap.dash.NumberBox = function(config){
25440 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25444 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25453 getAutoCreate : function(){
25457 cls : 'small-box ',
25465 cls : 'roo-headline',
25466 html : this.headline
25470 cls : 'roo-content',
25471 html : this.content
25485 cls : 'ion ' + this.icon
25494 cls : 'small-box-footer',
25495 href : this.fhref || '#',
25499 cfg.cn.push(footer);
25506 onRender : function(ct,position){
25507 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25514 setHeadline: function (value)
25516 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25519 setFooter: function (value, href)
25521 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25524 this.el.select('a.small-box-footer',true).first().attr('href', href);
25529 setContent: function (value)
25531 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25534 initEvents: function()
25548 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25551 * @class Roo.bootstrap.dash.TabBox
25552 * @extends Roo.bootstrap.Component
25553 * Bootstrap TabBox class
25554 * @cfg {String} title Title of the TabBox
25555 * @cfg {String} icon Icon of the TabBox
25556 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25557 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25560 * Create a new TabBox
25561 * @param {Object} config The config object
25565 Roo.bootstrap.dash.TabBox = function(config){
25566 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25571 * When a pane is added
25572 * @param {Roo.bootstrap.dash.TabPane} pane
25576 * @event activatepane
25577 * When a pane is activated
25578 * @param {Roo.bootstrap.dash.TabPane} pane
25580 "activatepane" : true
25588 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25593 tabScrollable : false,
25595 getChildContainer : function()
25597 return this.el.select('.tab-content', true).first();
25600 getAutoCreate : function(){
25604 cls: 'pull-left header',
25612 cls: 'fa ' + this.icon
25618 cls: 'nav nav-tabs pull-right',
25624 if(this.tabScrollable){
25631 cls: 'nav nav-tabs pull-right',
25642 cls: 'nav-tabs-custom',
25647 cls: 'tab-content no-padding',
25655 initEvents : function()
25657 //Roo.log('add add pane handler');
25658 this.on('addpane', this.onAddPane, this);
25661 * Updates the box title
25662 * @param {String} html to set the title to.
25664 setTitle : function(value)
25666 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25668 onAddPane : function(pane)
25670 this.panes.push(pane);
25671 //Roo.log('addpane');
25673 // tabs are rendere left to right..
25674 if(!this.showtabs){
25678 var ctr = this.el.select('.nav-tabs', true).first();
25681 var existing = ctr.select('.nav-tab',true);
25682 var qty = existing.getCount();;
25685 var tab = ctr.createChild({
25687 cls : 'nav-tab' + (qty ? '' : ' active'),
25695 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25698 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25700 pane.el.addClass('active');
25705 onTabClick : function(ev,un,ob,pane)
25707 //Roo.log('tab - prev default');
25708 ev.preventDefault();
25711 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25712 pane.tab.addClass('active');
25713 //Roo.log(pane.title);
25714 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25715 // technically we should have a deactivate event.. but maybe add later.
25716 // and it should not de-activate the selected tab...
25717 this.fireEvent('activatepane', pane);
25718 pane.el.addClass('active');
25719 pane.fireEvent('activate');
25724 getActivePane : function()
25727 Roo.each(this.panes, function(p) {
25728 if(p.el.hasClass('active')){
25749 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25751 * @class Roo.bootstrap.TabPane
25752 * @extends Roo.bootstrap.Component
25753 * Bootstrap TabPane class
25754 * @cfg {Boolean} active (false | true) Default false
25755 * @cfg {String} title title of panel
25759 * Create a new TabPane
25760 * @param {Object} config The config object
25763 Roo.bootstrap.dash.TabPane = function(config){
25764 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25770 * When a pane is activated
25771 * @param {Roo.bootstrap.dash.TabPane} pane
25778 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25783 // the tabBox that this is attached to.
25786 getAutoCreate : function()
25794 cfg.cls += ' active';
25799 initEvents : function()
25801 //Roo.log('trigger add pane handler');
25802 this.parent().fireEvent('addpane', this)
25806 * Updates the tab title
25807 * @param {String} html to set the title to.
25809 setTitle: function(str)
25815 this.tab.select('a', true).first().dom.innerHTML = str;
25832 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25835 * @class Roo.bootstrap.menu.Menu
25836 * @extends Roo.bootstrap.Component
25837 * Bootstrap Menu class - container for Menu
25838 * @cfg {String} html Text of the menu
25839 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25840 * @cfg {String} icon Font awesome icon
25841 * @cfg {String} pos Menu align to (top | bottom) default bottom
25845 * Create a new Menu
25846 * @param {Object} config The config object
25850 Roo.bootstrap.menu.Menu = function(config){
25851 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25855 * @event beforeshow
25856 * Fires before this menu is displayed
25857 * @param {Roo.bootstrap.menu.Menu} this
25861 * @event beforehide
25862 * Fires before this menu is hidden
25863 * @param {Roo.bootstrap.menu.Menu} this
25868 * Fires after this menu is displayed
25869 * @param {Roo.bootstrap.menu.Menu} this
25874 * Fires after this menu is hidden
25875 * @param {Roo.bootstrap.menu.Menu} this
25880 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25881 * @param {Roo.bootstrap.menu.Menu} this
25882 * @param {Roo.EventObject} e
25889 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25893 weight : 'default',
25898 getChildContainer : function() {
25899 if(this.isSubMenu){
25903 return this.el.select('ul.dropdown-menu', true).first();
25906 getAutoCreate : function()
25911 cls : 'roo-menu-text',
25919 cls : 'fa ' + this.icon
25930 cls : 'dropdown-button btn btn-' + this.weight,
25935 cls : 'dropdown-toggle btn btn-' + this.weight,
25945 cls : 'dropdown-menu'
25951 if(this.pos == 'top'){
25952 cfg.cls += ' dropup';
25955 if(this.isSubMenu){
25958 cls : 'dropdown-menu'
25965 onRender : function(ct, position)
25967 this.isSubMenu = ct.hasClass('dropdown-submenu');
25969 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25972 initEvents : function()
25974 if(this.isSubMenu){
25978 this.hidden = true;
25980 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25981 this.triggerEl.on('click', this.onTriggerPress, this);
25983 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25984 this.buttonEl.on('click', this.onClick, this);
25990 if(this.isSubMenu){
25994 return this.el.select('ul.dropdown-menu', true).first();
25997 onClick : function(e)
25999 this.fireEvent("click", this, e);
26002 onTriggerPress : function(e)
26004 if (this.isVisible()) {
26011 isVisible : function(){
26012 return !this.hidden;
26017 this.fireEvent("beforeshow", this);
26019 this.hidden = false;
26020 this.el.addClass('open');
26022 Roo.get(document).on("mouseup", this.onMouseUp, this);
26024 this.fireEvent("show", this);
26031 this.fireEvent("beforehide", this);
26033 this.hidden = true;
26034 this.el.removeClass('open');
26036 Roo.get(document).un("mouseup", this.onMouseUp);
26038 this.fireEvent("hide", this);
26041 onMouseUp : function()
26055 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26058 * @class Roo.bootstrap.menu.Item
26059 * @extends Roo.bootstrap.Component
26060 * Bootstrap MenuItem class
26061 * @cfg {Boolean} submenu (true | false) default false
26062 * @cfg {String} html text of the item
26063 * @cfg {String} href the link
26064 * @cfg {Boolean} disable (true | false) default false
26065 * @cfg {Boolean} preventDefault (true | false) default true
26066 * @cfg {String} icon Font awesome icon
26067 * @cfg {String} pos Submenu align to (left | right) default right
26071 * Create a new Item
26072 * @param {Object} config The config object
26076 Roo.bootstrap.menu.Item = function(config){
26077 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26081 * Fires when the mouse is hovering over this menu
26082 * @param {Roo.bootstrap.menu.Item} this
26083 * @param {Roo.EventObject} e
26088 * Fires when the mouse exits this menu
26089 * @param {Roo.bootstrap.menu.Item} this
26090 * @param {Roo.EventObject} e
26096 * The raw click event for the entire grid.
26097 * @param {Roo.EventObject} e
26103 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26108 preventDefault: true,
26113 getAutoCreate : function()
26118 cls : 'roo-menu-item-text',
26126 cls : 'fa ' + this.icon
26135 href : this.href || '#',
26142 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26146 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26148 if(this.pos == 'left'){
26149 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26156 initEvents : function()
26158 this.el.on('mouseover', this.onMouseOver, this);
26159 this.el.on('mouseout', this.onMouseOut, this);
26161 this.el.select('a', true).first().on('click', this.onClick, this);
26165 onClick : function(e)
26167 if(this.preventDefault){
26168 e.preventDefault();
26171 this.fireEvent("click", this, e);
26174 onMouseOver : function(e)
26176 if(this.submenu && this.pos == 'left'){
26177 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26180 this.fireEvent("mouseover", this, e);
26183 onMouseOut : function(e)
26185 this.fireEvent("mouseout", this, e);
26197 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26200 * @class Roo.bootstrap.menu.Separator
26201 * @extends Roo.bootstrap.Component
26202 * Bootstrap Separator class
26205 * Create a new Separator
26206 * @param {Object} config The config object
26210 Roo.bootstrap.menu.Separator = function(config){
26211 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26214 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26216 getAutoCreate : function(){
26237 * @class Roo.bootstrap.Tooltip
26238 * Bootstrap Tooltip class
26239 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26240 * to determine which dom element triggers the tooltip.
26242 * It needs to add support for additional attributes like tooltip-position
26245 * Create a new Toolti
26246 * @param {Object} config The config object
26249 Roo.bootstrap.Tooltip = function(config){
26250 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26252 this.alignment = Roo.bootstrap.Tooltip.alignment;
26254 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26255 this.alignment = config.alignment;
26260 Roo.apply(Roo.bootstrap.Tooltip, {
26262 * @function init initialize tooltip monitoring.
26266 currentTip : false,
26267 currentRegion : false,
26273 Roo.get(document).on('mouseover', this.enter ,this);
26274 Roo.get(document).on('mouseout', this.leave, this);
26277 this.currentTip = new Roo.bootstrap.Tooltip();
26280 enter : function(ev)
26282 var dom = ev.getTarget();
26284 //Roo.log(['enter',dom]);
26285 var el = Roo.fly(dom);
26286 if (this.currentEl) {
26288 //Roo.log(this.currentEl);
26289 //Roo.log(this.currentEl.contains(dom));
26290 if (this.currentEl == el) {
26293 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26299 if (this.currentTip.el) {
26300 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26304 if(!el || el.dom == document){
26310 // you can not look for children, as if el is the body.. then everythign is the child..
26311 if (!el.attr('tooltip')) { //
26312 if (!el.select("[tooltip]").elements.length) {
26315 // is the mouse over this child...?
26316 bindEl = el.select("[tooltip]").first();
26317 var xy = ev.getXY();
26318 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26319 //Roo.log("not in region.");
26322 //Roo.log("child element over..");
26325 this.currentEl = bindEl;
26326 this.currentTip.bind(bindEl);
26327 this.currentRegion = Roo.lib.Region.getRegion(dom);
26328 this.currentTip.enter();
26331 leave : function(ev)
26333 var dom = ev.getTarget();
26334 //Roo.log(['leave',dom]);
26335 if (!this.currentEl) {
26340 if (dom != this.currentEl.dom) {
26343 var xy = ev.getXY();
26344 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26347 // only activate leave if mouse cursor is outside... bounding box..
26352 if (this.currentTip) {
26353 this.currentTip.leave();
26355 //Roo.log('clear currentEl');
26356 this.currentEl = false;
26361 'left' : ['r-l', [-2,0], 'right'],
26362 'right' : ['l-r', [2,0], 'left'],
26363 'bottom' : ['t-b', [0,2], 'top'],
26364 'top' : [ 'b-t', [0,-2], 'bottom']
26370 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26375 delay : null, // can be { show : 300 , hide: 500}
26379 hoverState : null, //???
26381 placement : 'bottom',
26385 getAutoCreate : function(){
26392 cls : 'tooltip-arrow'
26395 cls : 'tooltip-inner'
26402 bind : function(el)
26408 enter : function () {
26410 if (this.timeout != null) {
26411 clearTimeout(this.timeout);
26414 this.hoverState = 'in';
26415 //Roo.log("enter - show");
26416 if (!this.delay || !this.delay.show) {
26421 this.timeout = setTimeout(function () {
26422 if (_t.hoverState == 'in') {
26425 }, this.delay.show);
26429 clearTimeout(this.timeout);
26431 this.hoverState = 'out';
26432 if (!this.delay || !this.delay.hide) {
26438 this.timeout = setTimeout(function () {
26439 //Roo.log("leave - timeout");
26441 if (_t.hoverState == 'out') {
26443 Roo.bootstrap.Tooltip.currentEl = false;
26448 show : function (msg)
26451 this.render(document.body);
26454 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26456 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26458 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26460 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26462 var placement = typeof this.placement == 'function' ?
26463 this.placement.call(this, this.el, on_el) :
26466 var autoToken = /\s?auto?\s?/i;
26467 var autoPlace = autoToken.test(placement);
26469 placement = placement.replace(autoToken, '') || 'top';
26473 //this.el.setXY([0,0]);
26475 //this.el.dom.style.display='block';
26477 //this.el.appendTo(on_el);
26479 var p = this.getPosition();
26480 var box = this.el.getBox();
26486 var align = this.alignment[placement];
26488 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26490 if(placement == 'top' || placement == 'bottom'){
26492 placement = 'right';
26495 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26496 placement = 'left';
26499 var scroll = Roo.select('body', true).first().getScroll();
26501 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26505 align = this.alignment[placement];
26508 this.el.alignTo(this.bindEl, align[0],align[1]);
26509 //var arrow = this.el.select('.arrow',true).first();
26510 //arrow.set(align[2],
26512 this.el.addClass(placement);
26514 this.el.addClass('in fade');
26516 this.hoverState = null;
26518 if (this.el.hasClass('fade')) {
26529 //this.el.setXY([0,0]);
26530 this.el.removeClass('in');
26546 * @class Roo.bootstrap.LocationPicker
26547 * @extends Roo.bootstrap.Component
26548 * Bootstrap LocationPicker class
26549 * @cfg {Number} latitude Position when init default 0
26550 * @cfg {Number} longitude Position when init default 0
26551 * @cfg {Number} zoom default 15
26552 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26553 * @cfg {Boolean} mapTypeControl default false
26554 * @cfg {Boolean} disableDoubleClickZoom default false
26555 * @cfg {Boolean} scrollwheel default true
26556 * @cfg {Boolean} streetViewControl default false
26557 * @cfg {Number} radius default 0
26558 * @cfg {String} locationName
26559 * @cfg {Boolean} draggable default true
26560 * @cfg {Boolean} enableAutocomplete default false
26561 * @cfg {Boolean} enableReverseGeocode default true
26562 * @cfg {String} markerTitle
26565 * Create a new LocationPicker
26566 * @param {Object} config The config object
26570 Roo.bootstrap.LocationPicker = function(config){
26572 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26577 * Fires when the picker initialized.
26578 * @param {Roo.bootstrap.LocationPicker} this
26579 * @param {Google Location} location
26583 * @event positionchanged
26584 * Fires when the picker position changed.
26585 * @param {Roo.bootstrap.LocationPicker} this
26586 * @param {Google Location} location
26588 positionchanged : true,
26591 * Fires when the map resize.
26592 * @param {Roo.bootstrap.LocationPicker} this
26597 * Fires when the map show.
26598 * @param {Roo.bootstrap.LocationPicker} this
26603 * Fires when the map hide.
26604 * @param {Roo.bootstrap.LocationPicker} this
26609 * Fires when click the map.
26610 * @param {Roo.bootstrap.LocationPicker} this
26611 * @param {Map event} e
26615 * @event mapRightClick
26616 * Fires when right click the map.
26617 * @param {Roo.bootstrap.LocationPicker} this
26618 * @param {Map event} e
26620 mapRightClick : true,
26622 * @event markerClick
26623 * Fires when click the marker.
26624 * @param {Roo.bootstrap.LocationPicker} this
26625 * @param {Map event} e
26627 markerClick : true,
26629 * @event markerRightClick
26630 * Fires when right click the marker.
26631 * @param {Roo.bootstrap.LocationPicker} this
26632 * @param {Map event} e
26634 markerRightClick : true,
26636 * @event OverlayViewDraw
26637 * Fires when OverlayView Draw
26638 * @param {Roo.bootstrap.LocationPicker} this
26640 OverlayViewDraw : true,
26642 * @event OverlayViewOnAdd
26643 * Fires when OverlayView Draw
26644 * @param {Roo.bootstrap.LocationPicker} this
26646 OverlayViewOnAdd : true,
26648 * @event OverlayViewOnRemove
26649 * Fires when OverlayView Draw
26650 * @param {Roo.bootstrap.LocationPicker} this
26652 OverlayViewOnRemove : true,
26654 * @event OverlayViewShow
26655 * Fires when OverlayView Draw
26656 * @param {Roo.bootstrap.LocationPicker} this
26657 * @param {Pixel} cpx
26659 OverlayViewShow : true,
26661 * @event OverlayViewHide
26662 * Fires when OverlayView Draw
26663 * @param {Roo.bootstrap.LocationPicker} this
26665 OverlayViewHide : true,
26667 * @event loadexception
26668 * Fires when load google lib failed.
26669 * @param {Roo.bootstrap.LocationPicker} this
26671 loadexception : true
26676 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26678 gMapContext: false,
26684 mapTypeControl: false,
26685 disableDoubleClickZoom: false,
26687 streetViewControl: false,
26691 enableAutocomplete: false,
26692 enableReverseGeocode: true,
26695 getAutoCreate: function()
26700 cls: 'roo-location-picker'
26706 initEvents: function(ct, position)
26708 if(!this.el.getWidth() || this.isApplied()){
26712 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26717 initial: function()
26719 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26720 this.fireEvent('loadexception', this);
26724 if(!this.mapTypeId){
26725 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26728 this.gMapContext = this.GMapContext();
26730 this.initOverlayView();
26732 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26736 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26737 _this.setPosition(_this.gMapContext.marker.position);
26740 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26741 _this.fireEvent('mapClick', this, event);
26745 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26746 _this.fireEvent('mapRightClick', this, event);
26750 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26751 _this.fireEvent('markerClick', this, event);
26755 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26756 _this.fireEvent('markerRightClick', this, event);
26760 this.setPosition(this.gMapContext.location);
26762 this.fireEvent('initial', this, this.gMapContext.location);
26765 initOverlayView: function()
26769 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26773 _this.fireEvent('OverlayViewDraw', _this);
26778 _this.fireEvent('OverlayViewOnAdd', _this);
26781 onRemove: function()
26783 _this.fireEvent('OverlayViewOnRemove', _this);
26786 show: function(cpx)
26788 _this.fireEvent('OverlayViewShow', _this, cpx);
26793 _this.fireEvent('OverlayViewHide', _this);
26799 fromLatLngToContainerPixel: function(event)
26801 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26804 isApplied: function()
26806 return this.getGmapContext() == false ? false : true;
26809 getGmapContext: function()
26811 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26814 GMapContext: function()
26816 var position = new google.maps.LatLng(this.latitude, this.longitude);
26818 var _map = new google.maps.Map(this.el.dom, {
26821 mapTypeId: this.mapTypeId,
26822 mapTypeControl: this.mapTypeControl,
26823 disableDoubleClickZoom: this.disableDoubleClickZoom,
26824 scrollwheel: this.scrollwheel,
26825 streetViewControl: this.streetViewControl,
26826 locationName: this.locationName,
26827 draggable: this.draggable,
26828 enableAutocomplete: this.enableAutocomplete,
26829 enableReverseGeocode: this.enableReverseGeocode
26832 var _marker = new google.maps.Marker({
26833 position: position,
26835 title: this.markerTitle,
26836 draggable: this.draggable
26843 location: position,
26844 radius: this.radius,
26845 locationName: this.locationName,
26846 addressComponents: {
26847 formatted_address: null,
26848 addressLine1: null,
26849 addressLine2: null,
26851 streetNumber: null,
26855 stateOrProvince: null
26858 domContainer: this.el.dom,
26859 geodecoder: new google.maps.Geocoder()
26863 drawCircle: function(center, radius, options)
26865 if (this.gMapContext.circle != null) {
26866 this.gMapContext.circle.setMap(null);
26870 options = Roo.apply({}, options, {
26871 strokeColor: "#0000FF",
26872 strokeOpacity: .35,
26874 fillColor: "#0000FF",
26878 options.map = this.gMapContext.map;
26879 options.radius = radius;
26880 options.center = center;
26881 this.gMapContext.circle = new google.maps.Circle(options);
26882 return this.gMapContext.circle;
26888 setPosition: function(location)
26890 this.gMapContext.location = location;
26891 this.gMapContext.marker.setPosition(location);
26892 this.gMapContext.map.panTo(location);
26893 this.drawCircle(location, this.gMapContext.radius, {});
26897 if (this.gMapContext.settings.enableReverseGeocode) {
26898 this.gMapContext.geodecoder.geocode({
26899 latLng: this.gMapContext.location
26900 }, function(results, status) {
26902 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26903 _this.gMapContext.locationName = results[0].formatted_address;
26904 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26906 _this.fireEvent('positionchanged', this, location);
26913 this.fireEvent('positionchanged', this, location);
26918 google.maps.event.trigger(this.gMapContext.map, "resize");
26920 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26922 this.fireEvent('resize', this);
26925 setPositionByLatLng: function(latitude, longitude)
26927 this.setPosition(new google.maps.LatLng(latitude, longitude));
26930 getCurrentPosition: function()
26933 latitude: this.gMapContext.location.lat(),
26934 longitude: this.gMapContext.location.lng()
26938 getAddressName: function()
26940 return this.gMapContext.locationName;
26943 getAddressComponents: function()
26945 return this.gMapContext.addressComponents;
26948 address_component_from_google_geocode: function(address_components)
26952 for (var i = 0; i < address_components.length; i++) {
26953 var component = address_components[i];
26954 if (component.types.indexOf("postal_code") >= 0) {
26955 result.postalCode = component.short_name;
26956 } else if (component.types.indexOf("street_number") >= 0) {
26957 result.streetNumber = component.short_name;
26958 } else if (component.types.indexOf("route") >= 0) {
26959 result.streetName = component.short_name;
26960 } else if (component.types.indexOf("neighborhood") >= 0) {
26961 result.city = component.short_name;
26962 } else if (component.types.indexOf("locality") >= 0) {
26963 result.city = component.short_name;
26964 } else if (component.types.indexOf("sublocality") >= 0) {
26965 result.district = component.short_name;
26966 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26967 result.stateOrProvince = component.short_name;
26968 } else if (component.types.indexOf("country") >= 0) {
26969 result.country = component.short_name;
26973 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26974 result.addressLine2 = "";
26978 setZoomLevel: function(zoom)
26980 this.gMapContext.map.setZoom(zoom);
26993 this.fireEvent('show', this);
27004 this.fireEvent('hide', this);
27009 Roo.apply(Roo.bootstrap.LocationPicker, {
27011 OverlayView : function(map, options)
27013 options = options || {};
27027 * @class Roo.bootstrap.Alert
27028 * @extends Roo.bootstrap.Component
27029 * Bootstrap Alert class
27030 * @cfg {String} title The title of alert
27031 * @cfg {String} html The content of alert
27032 * @cfg {String} weight ( success | info | warning | danger )
27033 * @cfg {String} faicon font-awesomeicon
27036 * Create a new alert
27037 * @param {Object} config The config object
27041 Roo.bootstrap.Alert = function(config){
27042 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27046 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27053 getAutoCreate : function()
27062 cls : 'roo-alert-icon'
27067 cls : 'roo-alert-title',
27072 cls : 'roo-alert-text',
27079 cfg.cn[0].cls += ' fa ' + this.faicon;
27083 cfg.cls += ' alert-' + this.weight;
27089 initEvents: function()
27091 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27094 setTitle : function(str)
27096 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27099 setText : function(str)
27101 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27104 setWeight : function(weight)
27107 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27110 this.weight = weight;
27112 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27115 setIcon : function(icon)
27118 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27121 this.faicon = icon;
27123 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27144 * @class Roo.bootstrap.UploadCropbox
27145 * @extends Roo.bootstrap.Component
27146 * Bootstrap UploadCropbox class
27147 * @cfg {String} emptyText show when image has been loaded
27148 * @cfg {String} rotateNotify show when image too small to rotate
27149 * @cfg {Number} errorTimeout default 3000
27150 * @cfg {Number} minWidth default 300
27151 * @cfg {Number} minHeight default 300
27152 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27153 * @cfg {Boolean} isDocument (true|false) default false
27154 * @cfg {String} url action url
27155 * @cfg {String} paramName default 'imageUpload'
27156 * @cfg {String} method default POST
27157 * @cfg {Boolean} loadMask (true|false) default true
27158 * @cfg {Boolean} loadingText default 'Loading...'
27161 * Create a new UploadCropbox
27162 * @param {Object} config The config object
27165 Roo.bootstrap.UploadCropbox = function(config){
27166 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27170 * @event beforeselectfile
27171 * Fire before select file
27172 * @param {Roo.bootstrap.UploadCropbox} this
27174 "beforeselectfile" : true,
27177 * Fire after initEvent
27178 * @param {Roo.bootstrap.UploadCropbox} this
27183 * Fire after initEvent
27184 * @param {Roo.bootstrap.UploadCropbox} this
27185 * @param {String} data
27190 * Fire when preparing the file data
27191 * @param {Roo.bootstrap.UploadCropbox} this
27192 * @param {Object} file
27197 * Fire when get exception
27198 * @param {Roo.bootstrap.UploadCropbox} this
27199 * @param {XMLHttpRequest} xhr
27201 "exception" : true,
27203 * @event beforeloadcanvas
27204 * Fire before load the canvas
27205 * @param {Roo.bootstrap.UploadCropbox} this
27206 * @param {String} src
27208 "beforeloadcanvas" : true,
27211 * Fire when trash image
27212 * @param {Roo.bootstrap.UploadCropbox} this
27217 * Fire when download the image
27218 * @param {Roo.bootstrap.UploadCropbox} this
27222 * @event footerbuttonclick
27223 * Fire when footerbuttonclick
27224 * @param {Roo.bootstrap.UploadCropbox} this
27225 * @param {String} type
27227 "footerbuttonclick" : true,
27231 * @param {Roo.bootstrap.UploadCropbox} this
27236 * Fire when rotate the image
27237 * @param {Roo.bootstrap.UploadCropbox} this
27238 * @param {String} pos
27243 * Fire when inspect the file
27244 * @param {Roo.bootstrap.UploadCropbox} this
27245 * @param {Object} file
27250 * Fire when xhr upload the file
27251 * @param {Roo.bootstrap.UploadCropbox} this
27252 * @param {Object} data
27257 * Fire when arrange the file data
27258 * @param {Roo.bootstrap.UploadCropbox} this
27259 * @param {Object} formData
27264 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27267 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27269 emptyText : 'Click to upload image',
27270 rotateNotify : 'Image is too small to rotate',
27271 errorTimeout : 3000,
27285 cropType : 'image/jpeg',
27287 canvasLoaded : false,
27288 isDocument : false,
27290 paramName : 'imageUpload',
27292 loadingText : 'Loading...',
27295 getAutoCreate : function()
27299 cls : 'roo-upload-cropbox',
27303 cls : 'roo-upload-cropbox-selector',
27308 cls : 'roo-upload-cropbox-body',
27309 style : 'cursor:pointer',
27313 cls : 'roo-upload-cropbox-preview'
27317 cls : 'roo-upload-cropbox-thumb'
27321 cls : 'roo-upload-cropbox-empty-notify',
27322 html : this.emptyText
27326 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27327 html : this.rotateNotify
27333 cls : 'roo-upload-cropbox-footer',
27336 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27346 onRender : function(ct, position)
27348 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27350 if (this.buttons.length) {
27352 Roo.each(this.buttons, function(bb) {
27354 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27356 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27362 this.maskEl = this.el;
27366 initEvents : function()
27368 this.urlAPI = (window.createObjectURL && window) ||
27369 (window.URL && URL.revokeObjectURL && URL) ||
27370 (window.webkitURL && webkitURL);
27372 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27373 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27375 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27376 this.selectorEl.hide();
27378 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27379 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27381 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27382 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27383 this.thumbEl.hide();
27385 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27386 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27388 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27389 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27390 this.errorEl.hide();
27392 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27393 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27394 this.footerEl.hide();
27396 this.setThumbBoxSize();
27402 this.fireEvent('initial', this);
27409 window.addEventListener("resize", function() { _this.resize(); } );
27411 this.bodyEl.on('click', this.beforeSelectFile, this);
27414 this.bodyEl.on('touchstart', this.onTouchStart, this);
27415 this.bodyEl.on('touchmove', this.onTouchMove, this);
27416 this.bodyEl.on('touchend', this.onTouchEnd, this);
27420 this.bodyEl.on('mousedown', this.onMouseDown, this);
27421 this.bodyEl.on('mousemove', this.onMouseMove, this);
27422 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27423 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27424 Roo.get(document).on('mouseup', this.onMouseUp, this);
27427 this.selectorEl.on('change', this.onFileSelected, this);
27433 this.baseScale = 1;
27435 this.baseRotate = 1;
27436 this.dragable = false;
27437 this.pinching = false;
27440 this.cropData = false;
27441 this.notifyEl.dom.innerHTML = this.emptyText;
27443 this.selectorEl.dom.value = '';
27447 resize : function()
27449 if(this.fireEvent('resize', this) != false){
27450 this.setThumbBoxPosition();
27451 this.setCanvasPosition();
27455 onFooterButtonClick : function(e, el, o, type)
27458 case 'rotate-left' :
27459 this.onRotateLeft(e);
27461 case 'rotate-right' :
27462 this.onRotateRight(e);
27465 this.beforeSelectFile(e);
27480 this.fireEvent('footerbuttonclick', this, type);
27483 beforeSelectFile : function(e)
27485 e.preventDefault();
27487 if(this.fireEvent('beforeselectfile', this) != false){
27488 this.selectorEl.dom.click();
27492 onFileSelected : function(e)
27494 e.preventDefault();
27496 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27500 var file = this.selectorEl.dom.files[0];
27502 if(this.fireEvent('inspect', this, file) != false){
27503 this.prepare(file);
27508 trash : function(e)
27510 this.fireEvent('trash', this);
27513 download : function(e)
27515 this.fireEvent('download', this);
27518 loadCanvas : function(src)
27520 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27524 this.imageEl = document.createElement('img');
27528 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27530 this.imageEl.src = src;
27534 onLoadCanvas : function()
27536 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27537 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27539 this.bodyEl.un('click', this.beforeSelectFile, this);
27541 this.notifyEl.hide();
27542 this.thumbEl.show();
27543 this.footerEl.show();
27545 this.baseRotateLevel();
27547 if(this.isDocument){
27548 this.setThumbBoxSize();
27551 this.setThumbBoxPosition();
27553 this.baseScaleLevel();
27559 this.canvasLoaded = true;
27562 this.maskEl.unmask();
27567 setCanvasPosition : function()
27569 if(!this.canvasEl){
27573 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27574 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27576 this.previewEl.setLeft(pw);
27577 this.previewEl.setTop(ph);
27581 onMouseDown : function(e)
27585 this.dragable = true;
27586 this.pinching = false;
27588 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27589 this.dragable = false;
27593 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27594 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27598 onMouseMove : function(e)
27602 if(!this.canvasLoaded){
27606 if (!this.dragable){
27610 var minX = Math.ceil(this.thumbEl.getLeft(true));
27611 var minY = Math.ceil(this.thumbEl.getTop(true));
27613 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27614 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27616 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27617 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27619 x = x - this.mouseX;
27620 y = y - this.mouseY;
27622 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27623 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27625 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27626 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27628 this.previewEl.setLeft(bgX);
27629 this.previewEl.setTop(bgY);
27631 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27632 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27635 onMouseUp : function(e)
27639 this.dragable = false;
27642 onMouseWheel : function(e)
27646 this.startScale = this.scale;
27648 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27650 if(!this.zoomable()){
27651 this.scale = this.startScale;
27660 zoomable : function()
27662 var minScale = this.thumbEl.getWidth() / this.minWidth;
27664 if(this.minWidth < this.minHeight){
27665 minScale = this.thumbEl.getHeight() / this.minHeight;
27668 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27669 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27673 (this.rotate == 0 || this.rotate == 180) &&
27675 width > this.imageEl.OriginWidth ||
27676 height > this.imageEl.OriginHeight ||
27677 (width < this.minWidth && height < this.minHeight)
27685 (this.rotate == 90 || this.rotate == 270) &&
27687 width > this.imageEl.OriginWidth ||
27688 height > this.imageEl.OriginHeight ||
27689 (width < this.minHeight && height < this.minWidth)
27696 !this.isDocument &&
27697 (this.rotate == 0 || this.rotate == 180) &&
27699 width < this.minWidth ||
27700 width > this.imageEl.OriginWidth ||
27701 height < this.minHeight ||
27702 height > this.imageEl.OriginHeight
27709 !this.isDocument &&
27710 (this.rotate == 90 || this.rotate == 270) &&
27712 width < this.minHeight ||
27713 width > this.imageEl.OriginWidth ||
27714 height < this.minWidth ||
27715 height > this.imageEl.OriginHeight
27725 onRotateLeft : function(e)
27727 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27729 var minScale = this.thumbEl.getWidth() / this.minWidth;
27731 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27732 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27734 this.startScale = this.scale;
27736 while (this.getScaleLevel() < minScale){
27738 this.scale = this.scale + 1;
27740 if(!this.zoomable()){
27745 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27746 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27751 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27758 this.scale = this.startScale;
27760 this.onRotateFail();
27765 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27767 if(this.isDocument){
27768 this.setThumbBoxSize();
27769 this.setThumbBoxPosition();
27770 this.setCanvasPosition();
27775 this.fireEvent('rotate', this, 'left');
27779 onRotateRight : function(e)
27781 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27783 var minScale = this.thumbEl.getWidth() / this.minWidth;
27785 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27786 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27788 this.startScale = this.scale;
27790 while (this.getScaleLevel() < minScale){
27792 this.scale = this.scale + 1;
27794 if(!this.zoomable()){
27799 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27800 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27805 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27812 this.scale = this.startScale;
27814 this.onRotateFail();
27819 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27821 if(this.isDocument){
27822 this.setThumbBoxSize();
27823 this.setThumbBoxPosition();
27824 this.setCanvasPosition();
27829 this.fireEvent('rotate', this, 'right');
27832 onRotateFail : function()
27834 this.errorEl.show(true);
27838 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27843 this.previewEl.dom.innerHTML = '';
27845 var canvasEl = document.createElement("canvas");
27847 var contextEl = canvasEl.getContext("2d");
27849 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27850 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27851 var center = this.imageEl.OriginWidth / 2;
27853 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27854 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27855 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27856 center = this.imageEl.OriginHeight / 2;
27859 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27861 contextEl.translate(center, center);
27862 contextEl.rotate(this.rotate * Math.PI / 180);
27864 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27866 this.canvasEl = document.createElement("canvas");
27868 this.contextEl = this.canvasEl.getContext("2d");
27870 switch (this.rotate) {
27873 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27874 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27876 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27881 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27882 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27884 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27885 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);
27889 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27894 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27895 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27897 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27898 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);
27902 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);
27907 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27908 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27910 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27911 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27915 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);
27922 this.previewEl.appendChild(this.canvasEl);
27924 this.setCanvasPosition();
27929 if(!this.canvasLoaded){
27933 var imageCanvas = document.createElement("canvas");
27935 var imageContext = imageCanvas.getContext("2d");
27937 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27938 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27940 var center = imageCanvas.width / 2;
27942 imageContext.translate(center, center);
27944 imageContext.rotate(this.rotate * Math.PI / 180);
27946 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27948 var canvas = document.createElement("canvas");
27950 var context = canvas.getContext("2d");
27952 canvas.width = this.minWidth;
27953 canvas.height = this.minHeight;
27955 switch (this.rotate) {
27958 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27959 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27961 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27962 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27964 var targetWidth = this.minWidth - 2 * x;
27965 var targetHeight = this.minHeight - 2 * y;
27969 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27970 scale = targetWidth / width;
27973 if(x > 0 && y == 0){
27974 scale = targetHeight / height;
27977 if(x > 0 && y > 0){
27978 scale = targetWidth / width;
27980 if(width < height){
27981 scale = targetHeight / height;
27985 context.scale(scale, scale);
27987 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27988 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27990 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27991 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27993 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27998 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27999 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28001 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28002 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28004 var targetWidth = this.minWidth - 2 * x;
28005 var targetHeight = this.minHeight - 2 * y;
28009 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28010 scale = targetWidth / width;
28013 if(x > 0 && y == 0){
28014 scale = targetHeight / height;
28017 if(x > 0 && y > 0){
28018 scale = targetWidth / width;
28020 if(width < height){
28021 scale = targetHeight / height;
28025 context.scale(scale, scale);
28027 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28028 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28030 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28031 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28033 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28035 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28040 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28041 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28043 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28044 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28046 var targetWidth = this.minWidth - 2 * x;
28047 var targetHeight = this.minHeight - 2 * y;
28051 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28052 scale = targetWidth / width;
28055 if(x > 0 && y == 0){
28056 scale = targetHeight / height;
28059 if(x > 0 && y > 0){
28060 scale = targetWidth / width;
28062 if(width < height){
28063 scale = targetHeight / height;
28067 context.scale(scale, scale);
28069 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28070 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28072 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28073 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28075 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28076 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28078 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28083 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28084 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28086 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28087 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28089 var targetWidth = this.minWidth - 2 * x;
28090 var targetHeight = this.minHeight - 2 * y;
28094 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28095 scale = targetWidth / width;
28098 if(x > 0 && y == 0){
28099 scale = targetHeight / height;
28102 if(x > 0 && y > 0){
28103 scale = targetWidth / width;
28105 if(width < height){
28106 scale = targetHeight / height;
28110 context.scale(scale, scale);
28112 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28113 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28115 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28116 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28118 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28120 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28127 this.cropData = canvas.toDataURL(this.cropType);
28129 if(this.fireEvent('crop', this, this.cropData) !== false){
28130 this.process(this.file, this.cropData);
28137 setThumbBoxSize : function()
28141 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28142 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28143 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28145 this.minWidth = width;
28146 this.minHeight = height;
28148 if(this.rotate == 90 || this.rotate == 270){
28149 this.minWidth = height;
28150 this.minHeight = width;
28155 width = Math.ceil(this.minWidth * height / this.minHeight);
28157 if(this.minWidth > this.minHeight){
28159 height = Math.ceil(this.minHeight * width / this.minWidth);
28162 this.thumbEl.setStyle({
28163 width : width + 'px',
28164 height : height + 'px'
28171 setThumbBoxPosition : function()
28173 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28174 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28176 this.thumbEl.setLeft(x);
28177 this.thumbEl.setTop(y);
28181 baseRotateLevel : function()
28183 this.baseRotate = 1;
28186 typeof(this.exif) != 'undefined' &&
28187 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28188 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28190 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28193 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28197 baseScaleLevel : function()
28201 if(this.isDocument){
28203 if(this.baseRotate == 6 || this.baseRotate == 8){
28205 height = this.thumbEl.getHeight();
28206 this.baseScale = height / this.imageEl.OriginWidth;
28208 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28209 width = this.thumbEl.getWidth();
28210 this.baseScale = width / this.imageEl.OriginHeight;
28216 height = this.thumbEl.getHeight();
28217 this.baseScale = height / this.imageEl.OriginHeight;
28219 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28220 width = this.thumbEl.getWidth();
28221 this.baseScale = width / this.imageEl.OriginWidth;
28227 if(this.baseRotate == 6 || this.baseRotate == 8){
28229 width = this.thumbEl.getHeight();
28230 this.baseScale = width / this.imageEl.OriginHeight;
28232 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28233 height = this.thumbEl.getWidth();
28234 this.baseScale = height / this.imageEl.OriginHeight;
28237 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28238 height = this.thumbEl.getWidth();
28239 this.baseScale = height / this.imageEl.OriginHeight;
28241 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28242 width = this.thumbEl.getHeight();
28243 this.baseScale = width / this.imageEl.OriginWidth;
28250 width = this.thumbEl.getWidth();
28251 this.baseScale = width / this.imageEl.OriginWidth;
28253 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28254 height = this.thumbEl.getHeight();
28255 this.baseScale = height / this.imageEl.OriginHeight;
28258 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28260 height = this.thumbEl.getHeight();
28261 this.baseScale = height / this.imageEl.OriginHeight;
28263 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28264 width = this.thumbEl.getWidth();
28265 this.baseScale = width / this.imageEl.OriginWidth;
28273 getScaleLevel : function()
28275 return this.baseScale * Math.pow(1.1, this.scale);
28278 onTouchStart : function(e)
28280 if(!this.canvasLoaded){
28281 this.beforeSelectFile(e);
28285 var touches = e.browserEvent.touches;
28291 if(touches.length == 1){
28292 this.onMouseDown(e);
28296 if(touches.length != 2){
28302 for(var i = 0, finger; finger = touches[i]; i++){
28303 coords.push(finger.pageX, finger.pageY);
28306 var x = Math.pow(coords[0] - coords[2], 2);
28307 var y = Math.pow(coords[1] - coords[3], 2);
28309 this.startDistance = Math.sqrt(x + y);
28311 this.startScale = this.scale;
28313 this.pinching = true;
28314 this.dragable = false;
28318 onTouchMove : function(e)
28320 if(!this.pinching && !this.dragable){
28324 var touches = e.browserEvent.touches;
28331 this.onMouseMove(e);
28337 for(var i = 0, finger; finger = touches[i]; i++){
28338 coords.push(finger.pageX, finger.pageY);
28341 var x = Math.pow(coords[0] - coords[2], 2);
28342 var y = Math.pow(coords[1] - coords[3], 2);
28344 this.endDistance = Math.sqrt(x + y);
28346 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28348 if(!this.zoomable()){
28349 this.scale = this.startScale;
28357 onTouchEnd : function(e)
28359 this.pinching = false;
28360 this.dragable = false;
28364 process : function(file, crop)
28367 this.maskEl.mask(this.loadingText);
28370 this.xhr = new XMLHttpRequest();
28372 file.xhr = this.xhr;
28374 this.xhr.open(this.method, this.url, true);
28377 "Accept": "application/json",
28378 "Cache-Control": "no-cache",
28379 "X-Requested-With": "XMLHttpRequest"
28382 for (var headerName in headers) {
28383 var headerValue = headers[headerName];
28385 this.xhr.setRequestHeader(headerName, headerValue);
28391 this.xhr.onload = function()
28393 _this.xhrOnLoad(_this.xhr);
28396 this.xhr.onerror = function()
28398 _this.xhrOnError(_this.xhr);
28401 var formData = new FormData();
28403 formData.append('returnHTML', 'NO');
28406 formData.append('crop', crop);
28409 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28410 formData.append(this.paramName, file, file.name);
28413 if(typeof(file.filename) != 'undefined'){
28414 formData.append('filename', file.filename);
28417 if(typeof(file.mimetype) != 'undefined'){
28418 formData.append('mimetype', file.mimetype);
28421 if(this.fireEvent('arrange', this, formData) != false){
28422 this.xhr.send(formData);
28426 xhrOnLoad : function(xhr)
28429 this.maskEl.unmask();
28432 if (xhr.readyState !== 4) {
28433 this.fireEvent('exception', this, xhr);
28437 var response = Roo.decode(xhr.responseText);
28439 if(!response.success){
28440 this.fireEvent('exception', this, xhr);
28444 var response = Roo.decode(xhr.responseText);
28446 this.fireEvent('upload', this, response);
28450 xhrOnError : function()
28453 this.maskEl.unmask();
28456 Roo.log('xhr on error');
28458 var response = Roo.decode(xhr.responseText);
28464 prepare : function(file)
28467 this.maskEl.mask(this.loadingText);
28473 if(typeof(file) === 'string'){
28474 this.loadCanvas(file);
28478 if(!file || !this.urlAPI){
28483 this.cropType = file.type;
28487 if(this.fireEvent('prepare', this, this.file) != false){
28489 var reader = new FileReader();
28491 reader.onload = function (e) {
28492 if (e.target.error) {
28493 Roo.log(e.target.error);
28497 var buffer = e.target.result,
28498 dataView = new DataView(buffer),
28500 maxOffset = dataView.byteLength - 4,
28504 if (dataView.getUint16(0) === 0xffd8) {
28505 while (offset < maxOffset) {
28506 markerBytes = dataView.getUint16(offset);
28508 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28509 markerLength = dataView.getUint16(offset + 2) + 2;
28510 if (offset + markerLength > dataView.byteLength) {
28511 Roo.log('Invalid meta data: Invalid segment size.');
28515 if(markerBytes == 0xffe1){
28516 _this.parseExifData(
28523 offset += markerLength;
28533 var url = _this.urlAPI.createObjectURL(_this.file);
28535 _this.loadCanvas(url);
28540 reader.readAsArrayBuffer(this.file);
28546 parseExifData : function(dataView, offset, length)
28548 var tiffOffset = offset + 10,
28552 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28553 // No Exif data, might be XMP data instead
28557 // Check for the ASCII code for "Exif" (0x45786966):
28558 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28559 // No Exif data, might be XMP data instead
28562 if (tiffOffset + 8 > dataView.byteLength) {
28563 Roo.log('Invalid Exif data: Invalid segment size.');
28566 // Check for the two null bytes:
28567 if (dataView.getUint16(offset + 8) !== 0x0000) {
28568 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28571 // Check the byte alignment:
28572 switch (dataView.getUint16(tiffOffset)) {
28574 littleEndian = true;
28577 littleEndian = false;
28580 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28583 // Check for the TIFF tag marker (0x002A):
28584 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28585 Roo.log('Invalid Exif data: Missing TIFF marker.');
28588 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28589 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28591 this.parseExifTags(
28594 tiffOffset + dirOffset,
28599 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28604 if (dirOffset + 6 > dataView.byteLength) {
28605 Roo.log('Invalid Exif data: Invalid directory offset.');
28608 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28609 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28610 if (dirEndOffset + 4 > dataView.byteLength) {
28611 Roo.log('Invalid Exif data: Invalid directory size.');
28614 for (i = 0; i < tagsNumber; i += 1) {
28618 dirOffset + 2 + 12 * i, // tag offset
28622 // Return the offset to the next directory:
28623 return dataView.getUint32(dirEndOffset, littleEndian);
28626 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28628 var tag = dataView.getUint16(offset, littleEndian);
28630 this.exif[tag] = this.getExifValue(
28634 dataView.getUint16(offset + 2, littleEndian), // tag type
28635 dataView.getUint32(offset + 4, littleEndian), // tag length
28640 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28642 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28651 Roo.log('Invalid Exif data: Invalid tag type.');
28655 tagSize = tagType.size * length;
28656 // Determine if the value is contained in the dataOffset bytes,
28657 // or if the value at the dataOffset is a pointer to the actual data:
28658 dataOffset = tagSize > 4 ?
28659 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28660 if (dataOffset + tagSize > dataView.byteLength) {
28661 Roo.log('Invalid Exif data: Invalid data offset.');
28664 if (length === 1) {
28665 return tagType.getValue(dataView, dataOffset, littleEndian);
28668 for (i = 0; i < length; i += 1) {
28669 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28672 if (tagType.ascii) {
28674 // Concatenate the chars:
28675 for (i = 0; i < values.length; i += 1) {
28677 // Ignore the terminating NULL byte(s):
28678 if (c === '\u0000') {
28690 Roo.apply(Roo.bootstrap.UploadCropbox, {
28692 'Orientation': 0x0112
28696 1: 0, //'top-left',
28698 3: 180, //'bottom-right',
28699 // 4: 'bottom-left',
28701 6: 90, //'right-top',
28702 // 7: 'right-bottom',
28703 8: 270 //'left-bottom'
28707 // byte, 8-bit unsigned int:
28709 getValue: function (dataView, dataOffset) {
28710 return dataView.getUint8(dataOffset);
28714 // ascii, 8-bit byte:
28716 getValue: function (dataView, dataOffset) {
28717 return String.fromCharCode(dataView.getUint8(dataOffset));
28722 // short, 16 bit int:
28724 getValue: function (dataView, dataOffset, littleEndian) {
28725 return dataView.getUint16(dataOffset, littleEndian);
28729 // long, 32 bit int:
28731 getValue: function (dataView, dataOffset, littleEndian) {
28732 return dataView.getUint32(dataOffset, littleEndian);
28736 // rational = two long values, first is numerator, second is denominator:
28738 getValue: function (dataView, dataOffset, littleEndian) {
28739 return dataView.getUint32(dataOffset, littleEndian) /
28740 dataView.getUint32(dataOffset + 4, littleEndian);
28744 // slong, 32 bit signed int:
28746 getValue: function (dataView, dataOffset, littleEndian) {
28747 return dataView.getInt32(dataOffset, littleEndian);
28751 // srational, two slongs, first is numerator, second is denominator:
28753 getValue: function (dataView, dataOffset, littleEndian) {
28754 return dataView.getInt32(dataOffset, littleEndian) /
28755 dataView.getInt32(dataOffset + 4, littleEndian);
28765 cls : 'btn-group roo-upload-cropbox-rotate-left',
28766 action : 'rotate-left',
28770 cls : 'btn btn-default',
28771 html : '<i class="fa fa-undo"></i>'
28777 cls : 'btn-group roo-upload-cropbox-picture',
28778 action : 'picture',
28782 cls : 'btn btn-default',
28783 html : '<i class="fa fa-picture-o"></i>'
28789 cls : 'btn-group roo-upload-cropbox-rotate-right',
28790 action : 'rotate-right',
28794 cls : 'btn btn-default',
28795 html : '<i class="fa fa-repeat"></i>'
28803 cls : 'btn-group roo-upload-cropbox-rotate-left',
28804 action : 'rotate-left',
28808 cls : 'btn btn-default',
28809 html : '<i class="fa fa-undo"></i>'
28815 cls : 'btn-group roo-upload-cropbox-download',
28816 action : 'download',
28820 cls : 'btn btn-default',
28821 html : '<i class="fa fa-download"></i>'
28827 cls : 'btn-group roo-upload-cropbox-crop',
28832 cls : 'btn btn-default',
28833 html : '<i class="fa fa-crop"></i>'
28839 cls : 'btn-group roo-upload-cropbox-trash',
28844 cls : 'btn btn-default',
28845 html : '<i class="fa fa-trash"></i>'
28851 cls : 'btn-group roo-upload-cropbox-rotate-right',
28852 action : 'rotate-right',
28856 cls : 'btn btn-default',
28857 html : '<i class="fa fa-repeat"></i>'
28865 cls : 'btn-group roo-upload-cropbox-rotate-left',
28866 action : 'rotate-left',
28870 cls : 'btn btn-default',
28871 html : '<i class="fa fa-undo"></i>'
28877 cls : 'btn-group roo-upload-cropbox-rotate-right',
28878 action : 'rotate-right',
28882 cls : 'btn btn-default',
28883 html : '<i class="fa fa-repeat"></i>'
28896 * @class Roo.bootstrap.DocumentManager
28897 * @extends Roo.bootstrap.Component
28898 * Bootstrap DocumentManager class
28899 * @cfg {String} paramName default 'imageUpload'
28900 * @cfg {String} toolTipName default 'filename'
28901 * @cfg {String} method default POST
28902 * @cfg {String} url action url
28903 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28904 * @cfg {Boolean} multiple multiple upload default true
28905 * @cfg {Number} thumbSize default 300
28906 * @cfg {String} fieldLabel
28907 * @cfg {Number} labelWidth default 4
28908 * @cfg {String} labelAlign (left|top) default left
28909 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28910 * @cfg {Number} labellg set the width of label (1-12)
28911 * @cfg {Number} labelmd set the width of label (1-12)
28912 * @cfg {Number} labelsm set the width of label (1-12)
28913 * @cfg {Number} labelxs set the width of label (1-12)
28916 * Create a new DocumentManager
28917 * @param {Object} config The config object
28920 Roo.bootstrap.DocumentManager = function(config){
28921 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28924 this.delegates = [];
28929 * Fire when initial the DocumentManager
28930 * @param {Roo.bootstrap.DocumentManager} this
28935 * inspect selected file
28936 * @param {Roo.bootstrap.DocumentManager} this
28937 * @param {File} file
28942 * Fire when xhr load exception
28943 * @param {Roo.bootstrap.DocumentManager} this
28944 * @param {XMLHttpRequest} xhr
28946 "exception" : true,
28948 * @event afterupload
28949 * Fire when xhr load exception
28950 * @param {Roo.bootstrap.DocumentManager} this
28951 * @param {XMLHttpRequest} xhr
28953 "afterupload" : true,
28956 * prepare the form data
28957 * @param {Roo.bootstrap.DocumentManager} this
28958 * @param {Object} formData
28963 * Fire when remove the file
28964 * @param {Roo.bootstrap.DocumentManager} this
28965 * @param {Object} file
28970 * Fire after refresh the file
28971 * @param {Roo.bootstrap.DocumentManager} this
28976 * Fire after click the image
28977 * @param {Roo.bootstrap.DocumentManager} this
28978 * @param {Object} file
28983 * Fire when upload a image and editable set to true
28984 * @param {Roo.bootstrap.DocumentManager} this
28985 * @param {Object} file
28989 * @event beforeselectfile
28990 * Fire before select file
28991 * @param {Roo.bootstrap.DocumentManager} this
28993 "beforeselectfile" : true,
28996 * Fire before process file
28997 * @param {Roo.bootstrap.DocumentManager} this
28998 * @param {Object} file
29002 * @event previewrendered
29003 * Fire when preview rendered
29004 * @param {Roo.bootstrap.DocumentManager} this
29005 * @param {Object} file
29007 "previewrendered" : true,
29010 "previewResize" : true
29015 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29024 paramName : 'imageUpload',
29025 toolTipName : 'filename',
29028 labelAlign : 'left',
29038 getAutoCreate : function()
29040 var managerWidget = {
29042 cls : 'roo-document-manager',
29046 cls : 'roo-document-manager-selector',
29051 cls : 'roo-document-manager-uploader',
29055 cls : 'roo-document-manager-upload-btn',
29056 html : '<i class="fa fa-plus"></i>'
29067 cls : 'column col-md-12',
29072 if(this.fieldLabel.length){
29077 cls : 'column col-md-12',
29078 html : this.fieldLabel
29082 cls : 'column col-md-12',
29087 if(this.labelAlign == 'left'){
29092 html : this.fieldLabel
29101 if(this.labelWidth > 12){
29102 content[0].style = "width: " + this.labelWidth + 'px';
29105 if(this.labelWidth < 13 && this.labelmd == 0){
29106 this.labelmd = this.labelWidth;
29109 if(this.labellg > 0){
29110 content[0].cls += ' col-lg-' + this.labellg;
29111 content[1].cls += ' col-lg-' + (12 - this.labellg);
29114 if(this.labelmd > 0){
29115 content[0].cls += ' col-md-' + this.labelmd;
29116 content[1].cls += ' col-md-' + (12 - this.labelmd);
29119 if(this.labelsm > 0){
29120 content[0].cls += ' col-sm-' + this.labelsm;
29121 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29124 if(this.labelxs > 0){
29125 content[0].cls += ' col-xs-' + this.labelxs;
29126 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29134 cls : 'row clearfix',
29142 initEvents : function()
29144 this.managerEl = this.el.select('.roo-document-manager', true).first();
29145 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29147 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29148 this.selectorEl.hide();
29151 this.selectorEl.attr('multiple', 'multiple');
29154 this.selectorEl.on('change', this.onFileSelected, this);
29156 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29157 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29159 this.uploader.on('click', this.onUploaderClick, this);
29161 this.renderProgressDialog();
29165 window.addEventListener("resize", function() { _this.refresh(); } );
29167 this.fireEvent('initial', this);
29170 renderProgressDialog : function()
29174 this.progressDialog = new Roo.bootstrap.Modal({
29175 cls : 'roo-document-manager-progress-dialog',
29176 allow_close : false,
29186 btnclick : function() {
29187 _this.uploadCancel();
29193 this.progressDialog.render(Roo.get(document.body));
29195 this.progress = new Roo.bootstrap.Progress({
29196 cls : 'roo-document-manager-progress',
29201 this.progress.render(this.progressDialog.getChildContainer());
29203 this.progressBar = new Roo.bootstrap.ProgressBar({
29204 cls : 'roo-document-manager-progress-bar',
29207 aria_valuemax : 12,
29211 this.progressBar.render(this.progress.getChildContainer());
29214 onUploaderClick : function(e)
29216 e.preventDefault();
29218 if(this.fireEvent('beforeselectfile', this) != false){
29219 this.selectorEl.dom.click();
29224 onFileSelected : function(e)
29226 e.preventDefault();
29228 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29232 Roo.each(this.selectorEl.dom.files, function(file){
29233 if(this.fireEvent('inspect', this, file) != false){
29234 this.files.push(file);
29244 this.selectorEl.dom.value = '';
29246 if(!this.files || !this.files.length){
29250 if(this.boxes > 0 && this.files.length > this.boxes){
29251 this.files = this.files.slice(0, this.boxes);
29254 this.uploader.show();
29256 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29257 this.uploader.hide();
29266 Roo.each(this.files, function(file){
29268 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29269 var f = this.renderPreview(file);
29274 if(file.type.indexOf('image') != -1){
29275 this.delegates.push(
29277 _this.process(file);
29278 }).createDelegate(this)
29286 _this.process(file);
29287 }).createDelegate(this)
29292 this.files = files;
29294 this.delegates = this.delegates.concat(docs);
29296 if(!this.delegates.length){
29301 this.progressBar.aria_valuemax = this.delegates.length;
29308 arrange : function()
29310 if(!this.delegates.length){
29311 this.progressDialog.hide();
29316 var delegate = this.delegates.shift();
29318 this.progressDialog.show();
29320 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29322 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29327 refresh : function()
29329 this.uploader.show();
29331 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29332 this.uploader.hide();
29335 Roo.isTouch ? this.closable(false) : this.closable(true);
29337 this.fireEvent('refresh', this);
29340 onRemove : function(e, el, o)
29342 e.preventDefault();
29344 this.fireEvent('remove', this, o);
29348 remove : function(o)
29352 Roo.each(this.files, function(file){
29353 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29362 this.files = files;
29369 Roo.each(this.files, function(file){
29374 file.target.remove();
29383 onClick : function(e, el, o)
29385 e.preventDefault();
29387 this.fireEvent('click', this, o);
29391 closable : function(closable)
29393 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29395 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29407 xhrOnLoad : function(xhr)
29409 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29413 if (xhr.readyState !== 4) {
29415 this.fireEvent('exception', this, xhr);
29419 var response = Roo.decode(xhr.responseText);
29421 if(!response.success){
29423 this.fireEvent('exception', this, xhr);
29427 var file = this.renderPreview(response.data);
29429 this.files.push(file);
29433 this.fireEvent('afterupload', this, xhr);
29437 xhrOnError : function(xhr)
29439 Roo.log('xhr on error');
29441 var response = Roo.decode(xhr.responseText);
29448 process : function(file)
29450 if(this.fireEvent('process', this, file) !== false){
29451 if(this.editable && file.type.indexOf('image') != -1){
29452 this.fireEvent('edit', this, file);
29456 this.uploadStart(file, false);
29463 uploadStart : function(file, crop)
29465 this.xhr = new XMLHttpRequest();
29467 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29472 file.xhr = this.xhr;
29474 this.managerEl.createChild({
29476 cls : 'roo-document-manager-loading',
29480 tooltip : file.name,
29481 cls : 'roo-document-manager-thumb',
29482 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29488 this.xhr.open(this.method, this.url, true);
29491 "Accept": "application/json",
29492 "Cache-Control": "no-cache",
29493 "X-Requested-With": "XMLHttpRequest"
29496 for (var headerName in headers) {
29497 var headerValue = headers[headerName];
29499 this.xhr.setRequestHeader(headerName, headerValue);
29505 this.xhr.onload = function()
29507 _this.xhrOnLoad(_this.xhr);
29510 this.xhr.onerror = function()
29512 _this.xhrOnError(_this.xhr);
29515 var formData = new FormData();
29517 formData.append('returnHTML', 'NO');
29520 formData.append('crop', crop);
29523 formData.append(this.paramName, file, file.name);
29530 if(this.fireEvent('prepare', this, formData, options) != false){
29532 if(options.manually){
29536 this.xhr.send(formData);
29540 this.uploadCancel();
29543 uploadCancel : function()
29549 this.delegates = [];
29551 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29558 renderPreview : function(file)
29560 if(typeof(file.target) != 'undefined' && file.target){
29564 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29566 var previewEl = this.managerEl.createChild({
29568 cls : 'roo-document-manager-preview',
29572 tooltip : file[this.toolTipName],
29573 cls : 'roo-document-manager-thumb',
29574 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29579 html : '<i class="fa fa-times-circle"></i>'
29584 var close = previewEl.select('button.close', true).first();
29586 close.on('click', this.onRemove, this, file);
29588 file.target = previewEl;
29590 var image = previewEl.select('img', true).first();
29594 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29596 image.on('click', this.onClick, this, file);
29598 this.fireEvent('previewrendered', this, file);
29604 onPreviewLoad : function(file, image)
29606 if(typeof(file.target) == 'undefined' || !file.target){
29610 var width = image.dom.naturalWidth || image.dom.width;
29611 var height = image.dom.naturalHeight || image.dom.height;
29613 if(!this.previewResize) {
29617 if(width > height){
29618 file.target.addClass('wide');
29622 file.target.addClass('tall');
29627 uploadFromSource : function(file, crop)
29629 this.xhr = new XMLHttpRequest();
29631 this.managerEl.createChild({
29633 cls : 'roo-document-manager-loading',
29637 tooltip : file.name,
29638 cls : 'roo-document-manager-thumb',
29639 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29645 this.xhr.open(this.method, this.url, true);
29648 "Accept": "application/json",
29649 "Cache-Control": "no-cache",
29650 "X-Requested-With": "XMLHttpRequest"
29653 for (var headerName in headers) {
29654 var headerValue = headers[headerName];
29656 this.xhr.setRequestHeader(headerName, headerValue);
29662 this.xhr.onload = function()
29664 _this.xhrOnLoad(_this.xhr);
29667 this.xhr.onerror = function()
29669 _this.xhrOnError(_this.xhr);
29672 var formData = new FormData();
29674 formData.append('returnHTML', 'NO');
29676 formData.append('crop', crop);
29678 if(typeof(file.filename) != 'undefined'){
29679 formData.append('filename', file.filename);
29682 if(typeof(file.mimetype) != 'undefined'){
29683 formData.append('mimetype', file.mimetype);
29688 if(this.fireEvent('prepare', this, formData) != false){
29689 this.xhr.send(formData);
29699 * @class Roo.bootstrap.DocumentViewer
29700 * @extends Roo.bootstrap.Component
29701 * Bootstrap DocumentViewer class
29702 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29703 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29706 * Create a new DocumentViewer
29707 * @param {Object} config The config object
29710 Roo.bootstrap.DocumentViewer = function(config){
29711 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29716 * Fire after initEvent
29717 * @param {Roo.bootstrap.DocumentViewer} this
29723 * @param {Roo.bootstrap.DocumentViewer} this
29728 * Fire after download button
29729 * @param {Roo.bootstrap.DocumentViewer} this
29734 * Fire after trash button
29735 * @param {Roo.bootstrap.DocumentViewer} this
29742 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29744 showDownload : true,
29748 getAutoCreate : function()
29752 cls : 'roo-document-viewer',
29756 cls : 'roo-document-viewer-body',
29760 cls : 'roo-document-viewer-thumb',
29764 cls : 'roo-document-viewer-image'
29772 cls : 'roo-document-viewer-footer',
29775 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29779 cls : 'btn-group roo-document-viewer-download',
29783 cls : 'btn btn-default',
29784 html : '<i class="fa fa-download"></i>'
29790 cls : 'btn-group roo-document-viewer-trash',
29794 cls : 'btn btn-default',
29795 html : '<i class="fa fa-trash"></i>'
29808 initEvents : function()
29810 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29811 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29813 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29814 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29816 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29817 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29819 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29820 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29822 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29823 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29825 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29826 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29828 this.bodyEl.on('click', this.onClick, this);
29829 this.downloadBtn.on('click', this.onDownload, this);
29830 this.trashBtn.on('click', this.onTrash, this);
29832 this.downloadBtn.hide();
29833 this.trashBtn.hide();
29835 if(this.showDownload){
29836 this.downloadBtn.show();
29839 if(this.showTrash){
29840 this.trashBtn.show();
29843 if(!this.showDownload && !this.showTrash) {
29844 this.footerEl.hide();
29849 initial : function()
29851 this.fireEvent('initial', this);
29855 onClick : function(e)
29857 e.preventDefault();
29859 this.fireEvent('click', this);
29862 onDownload : function(e)
29864 e.preventDefault();
29866 this.fireEvent('download', this);
29869 onTrash : function(e)
29871 e.preventDefault();
29873 this.fireEvent('trash', this);
29885 * @class Roo.bootstrap.NavProgressBar
29886 * @extends Roo.bootstrap.Component
29887 * Bootstrap NavProgressBar class
29890 * Create a new nav progress bar
29891 * @param {Object} config The config object
29894 Roo.bootstrap.NavProgressBar = function(config){
29895 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29897 this.bullets = this.bullets || [];
29899 // Roo.bootstrap.NavProgressBar.register(this);
29903 * Fires when the active item changes
29904 * @param {Roo.bootstrap.NavProgressBar} this
29905 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29906 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29913 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29918 getAutoCreate : function()
29920 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29924 cls : 'roo-navigation-bar-group',
29928 cls : 'roo-navigation-top-bar'
29932 cls : 'roo-navigation-bullets-bar',
29936 cls : 'roo-navigation-bar'
29943 cls : 'roo-navigation-bottom-bar'
29953 initEvents: function()
29958 onRender : function(ct, position)
29960 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29962 if(this.bullets.length){
29963 Roo.each(this.bullets, function(b){
29972 addItem : function(cfg)
29974 var item = new Roo.bootstrap.NavProgressItem(cfg);
29976 item.parentId = this.id;
29977 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29980 var top = new Roo.bootstrap.Element({
29982 cls : 'roo-navigation-bar-text'
29985 var bottom = new Roo.bootstrap.Element({
29987 cls : 'roo-navigation-bar-text'
29990 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29991 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29993 var topText = new Roo.bootstrap.Element({
29995 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29998 var bottomText = new Roo.bootstrap.Element({
30000 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30003 topText.onRender(top.el, null);
30004 bottomText.onRender(bottom.el, null);
30007 item.bottomEl = bottom;
30010 this.barItems.push(item);
30015 getActive : function()
30017 var active = false;
30019 Roo.each(this.barItems, function(v){
30021 if (!v.isActive()) {
30033 setActiveItem : function(item)
30037 Roo.each(this.barItems, function(v){
30038 if (v.rid == item.rid) {
30042 if (v.isActive()) {
30043 v.setActive(false);
30048 item.setActive(true);
30050 this.fireEvent('changed', this, item, prev);
30053 getBarItem: function(rid)
30057 Roo.each(this.barItems, function(e) {
30058 if (e.rid != rid) {
30069 indexOfItem : function(item)
30073 Roo.each(this.barItems, function(v, i){
30075 if (v.rid != item.rid) {
30086 setActiveNext : function()
30088 var i = this.indexOfItem(this.getActive());
30090 if (i > this.barItems.length) {
30094 this.setActiveItem(this.barItems[i+1]);
30097 setActivePrev : function()
30099 var i = this.indexOfItem(this.getActive());
30105 this.setActiveItem(this.barItems[i-1]);
30108 format : function()
30110 if(!this.barItems.length){
30114 var width = 100 / this.barItems.length;
30116 Roo.each(this.barItems, function(i){
30117 i.el.setStyle('width', width + '%');
30118 i.topEl.el.setStyle('width', width + '%');
30119 i.bottomEl.el.setStyle('width', width + '%');
30128 * Nav Progress Item
30133 * @class Roo.bootstrap.NavProgressItem
30134 * @extends Roo.bootstrap.Component
30135 * Bootstrap NavProgressItem class
30136 * @cfg {String} rid the reference id
30137 * @cfg {Boolean} active (true|false) Is item active default false
30138 * @cfg {Boolean} disabled (true|false) Is item active default false
30139 * @cfg {String} html
30140 * @cfg {String} position (top|bottom) text position default bottom
30141 * @cfg {String} icon show icon instead of number
30144 * Create a new NavProgressItem
30145 * @param {Object} config The config object
30147 Roo.bootstrap.NavProgressItem = function(config){
30148 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30153 * The raw click event for the entire grid.
30154 * @param {Roo.bootstrap.NavProgressItem} this
30155 * @param {Roo.EventObject} e
30162 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30168 position : 'bottom',
30171 getAutoCreate : function()
30173 var iconCls = 'roo-navigation-bar-item-icon';
30175 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30179 cls: 'roo-navigation-bar-item',
30189 cfg.cls += ' active';
30192 cfg.cls += ' disabled';
30198 disable : function()
30200 this.setDisabled(true);
30203 enable : function()
30205 this.setDisabled(false);
30208 initEvents: function()
30210 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30212 this.iconEl.on('click', this.onClick, this);
30215 onClick : function(e)
30217 e.preventDefault();
30223 if(this.fireEvent('click', this, e) === false){
30227 this.parent().setActiveItem(this);
30230 isActive: function ()
30232 return this.active;
30235 setActive : function(state)
30237 if(this.active == state){
30241 this.active = state;
30244 this.el.addClass('active');
30248 this.el.removeClass('active');
30253 setDisabled : function(state)
30255 if(this.disabled == state){
30259 this.disabled = state;
30262 this.el.addClass('disabled');
30266 this.el.removeClass('disabled');
30269 tooltipEl : function()
30271 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30284 * @class Roo.bootstrap.FieldLabel
30285 * @extends Roo.bootstrap.Component
30286 * Bootstrap FieldLabel class
30287 * @cfg {String} html contents of the element
30288 * @cfg {String} tag tag of the element default label
30289 * @cfg {String} cls class of the element
30290 * @cfg {String} target label target
30291 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30292 * @cfg {String} invalidClass default "text-warning"
30293 * @cfg {String} validClass default "text-success"
30294 * @cfg {String} iconTooltip default "This field is required"
30295 * @cfg {String} indicatorpos (left|right) default left
30298 * Create a new FieldLabel
30299 * @param {Object} config The config object
30302 Roo.bootstrap.FieldLabel = function(config){
30303 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30308 * Fires after the field has been marked as invalid.
30309 * @param {Roo.form.FieldLabel} this
30310 * @param {String} msg The validation message
30315 * Fires after the field has been validated with no errors.
30316 * @param {Roo.form.FieldLabel} this
30322 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30329 invalidClass : 'has-warning',
30330 validClass : 'has-success',
30331 iconTooltip : 'This field is required',
30332 indicatorpos : 'left',
30334 getAutoCreate : function(){
30337 if (!this.allowBlank) {
30343 cls : 'roo-bootstrap-field-label ' + this.cls,
30348 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30349 tooltip : this.iconTooltip
30358 if(this.indicatorpos == 'right'){
30361 cls : 'roo-bootstrap-field-label ' + this.cls,
30370 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30371 tooltip : this.iconTooltip
30380 initEvents: function()
30382 Roo.bootstrap.Element.superclass.initEvents.call(this);
30384 this.indicator = this.indicatorEl();
30386 if(this.indicator){
30387 this.indicator.removeClass('visible');
30388 this.indicator.addClass('invisible');
30391 Roo.bootstrap.FieldLabel.register(this);
30394 indicatorEl : function()
30396 var indicator = this.el.select('i.roo-required-indicator',true).first();
30407 * Mark this field as valid
30409 markValid : function()
30411 if(this.indicator){
30412 this.indicator.removeClass('visible');
30413 this.indicator.addClass('invisible');
30416 this.el.removeClass(this.invalidClass);
30418 this.el.addClass(this.validClass);
30420 this.fireEvent('valid', this);
30424 * Mark this field as invalid
30425 * @param {String} msg The validation message
30427 markInvalid : function(msg)
30429 if(this.indicator){
30430 this.indicator.removeClass('invisible');
30431 this.indicator.addClass('visible');
30434 this.el.removeClass(this.validClass);
30436 this.el.addClass(this.invalidClass);
30438 this.fireEvent('invalid', this, msg);
30444 Roo.apply(Roo.bootstrap.FieldLabel, {
30449 * register a FieldLabel Group
30450 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30452 register : function(label)
30454 if(this.groups.hasOwnProperty(label.target)){
30458 this.groups[label.target] = label;
30462 * fetch a FieldLabel Group based on the target
30463 * @param {string} target
30464 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30466 get: function(target) {
30467 if (typeof(this.groups[target]) == 'undefined') {
30471 return this.groups[target] ;
30480 * page DateSplitField.
30486 * @class Roo.bootstrap.DateSplitField
30487 * @extends Roo.bootstrap.Component
30488 * Bootstrap DateSplitField class
30489 * @cfg {string} fieldLabel - the label associated
30490 * @cfg {Number} labelWidth set the width of label (0-12)
30491 * @cfg {String} labelAlign (top|left)
30492 * @cfg {Boolean} dayAllowBlank (true|false) default false
30493 * @cfg {Boolean} monthAllowBlank (true|false) default false
30494 * @cfg {Boolean} yearAllowBlank (true|false) default false
30495 * @cfg {string} dayPlaceholder
30496 * @cfg {string} monthPlaceholder
30497 * @cfg {string} yearPlaceholder
30498 * @cfg {string} dayFormat default 'd'
30499 * @cfg {string} monthFormat default 'm'
30500 * @cfg {string} yearFormat default 'Y'
30501 * @cfg {Number} labellg set the width of label (1-12)
30502 * @cfg {Number} labelmd set the width of label (1-12)
30503 * @cfg {Number} labelsm set the width of label (1-12)
30504 * @cfg {Number} labelxs set the width of label (1-12)
30508 * Create a new DateSplitField
30509 * @param {Object} config The config object
30512 Roo.bootstrap.DateSplitField = function(config){
30513 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30519 * getting the data of years
30520 * @param {Roo.bootstrap.DateSplitField} this
30521 * @param {Object} years
30526 * getting the data of days
30527 * @param {Roo.bootstrap.DateSplitField} this
30528 * @param {Object} days
30533 * Fires after the field has been marked as invalid.
30534 * @param {Roo.form.Field} this
30535 * @param {String} msg The validation message
30540 * Fires after the field has been validated with no errors.
30541 * @param {Roo.form.Field} this
30547 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30550 labelAlign : 'top',
30552 dayAllowBlank : false,
30553 monthAllowBlank : false,
30554 yearAllowBlank : false,
30555 dayPlaceholder : '',
30556 monthPlaceholder : '',
30557 yearPlaceholder : '',
30561 isFormField : true,
30567 getAutoCreate : function()
30571 cls : 'row roo-date-split-field-group',
30576 cls : 'form-hidden-field roo-date-split-field-group-value',
30582 var labelCls = 'col-md-12';
30583 var contentCls = 'col-md-4';
30585 if(this.fieldLabel){
30589 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30593 html : this.fieldLabel
30598 if(this.labelAlign == 'left'){
30600 if(this.labelWidth > 12){
30601 label.style = "width: " + this.labelWidth + 'px';
30604 if(this.labelWidth < 13 && this.labelmd == 0){
30605 this.labelmd = this.labelWidth;
30608 if(this.labellg > 0){
30609 labelCls = ' col-lg-' + this.labellg;
30610 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30613 if(this.labelmd > 0){
30614 labelCls = ' col-md-' + this.labelmd;
30615 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30618 if(this.labelsm > 0){
30619 labelCls = ' col-sm-' + this.labelsm;
30620 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30623 if(this.labelxs > 0){
30624 labelCls = ' col-xs-' + this.labelxs;
30625 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30629 label.cls += ' ' + labelCls;
30631 cfg.cn.push(label);
30634 Roo.each(['day', 'month', 'year'], function(t){
30637 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30644 inputEl: function ()
30646 return this.el.select('.roo-date-split-field-group-value', true).first();
30649 onRender : function(ct, position)
30653 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30655 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30657 this.dayField = new Roo.bootstrap.ComboBox({
30658 allowBlank : this.dayAllowBlank,
30659 alwaysQuery : true,
30660 displayField : 'value',
30663 forceSelection : true,
30665 placeholder : this.dayPlaceholder,
30666 selectOnFocus : true,
30667 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30668 triggerAction : 'all',
30670 valueField : 'value',
30671 store : new Roo.data.SimpleStore({
30672 data : (function() {
30674 _this.fireEvent('days', _this, days);
30677 fields : [ 'value' ]
30680 select : function (_self, record, index)
30682 _this.setValue(_this.getValue());
30687 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30689 this.monthField = new Roo.bootstrap.MonthField({
30690 after : '<i class=\"fa fa-calendar\"></i>',
30691 allowBlank : this.monthAllowBlank,
30692 placeholder : this.monthPlaceholder,
30695 render : function (_self)
30697 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30698 e.preventDefault();
30702 select : function (_self, oldvalue, newvalue)
30704 _this.setValue(_this.getValue());
30709 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30711 this.yearField = new Roo.bootstrap.ComboBox({
30712 allowBlank : this.yearAllowBlank,
30713 alwaysQuery : true,
30714 displayField : 'value',
30717 forceSelection : true,
30719 placeholder : this.yearPlaceholder,
30720 selectOnFocus : true,
30721 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30722 triggerAction : 'all',
30724 valueField : 'value',
30725 store : new Roo.data.SimpleStore({
30726 data : (function() {
30728 _this.fireEvent('years', _this, years);
30731 fields : [ 'value' ]
30734 select : function (_self, record, index)
30736 _this.setValue(_this.getValue());
30741 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30744 setValue : function(v, format)
30746 this.inputEl.dom.value = v;
30748 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30750 var d = Date.parseDate(v, f);
30757 this.setDay(d.format(this.dayFormat));
30758 this.setMonth(d.format(this.monthFormat));
30759 this.setYear(d.format(this.yearFormat));
30766 setDay : function(v)
30768 this.dayField.setValue(v);
30769 this.inputEl.dom.value = this.getValue();
30774 setMonth : function(v)
30776 this.monthField.setValue(v, true);
30777 this.inputEl.dom.value = this.getValue();
30782 setYear : function(v)
30784 this.yearField.setValue(v);
30785 this.inputEl.dom.value = this.getValue();
30790 getDay : function()
30792 return this.dayField.getValue();
30795 getMonth : function()
30797 return this.monthField.getValue();
30800 getYear : function()
30802 return this.yearField.getValue();
30805 getValue : function()
30807 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30809 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30819 this.inputEl.dom.value = '';
30824 validate : function()
30826 var d = this.dayField.validate();
30827 var m = this.monthField.validate();
30828 var y = this.yearField.validate();
30833 (!this.dayAllowBlank && !d) ||
30834 (!this.monthAllowBlank && !m) ||
30835 (!this.yearAllowBlank && !y)
30840 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30849 this.markInvalid();
30854 markValid : function()
30857 var label = this.el.select('label', true).first();
30858 var icon = this.el.select('i.fa-star', true).first();
30864 this.fireEvent('valid', this);
30868 * Mark this field as invalid
30869 * @param {String} msg The validation message
30871 markInvalid : function(msg)
30874 var label = this.el.select('label', true).first();
30875 var icon = this.el.select('i.fa-star', true).first();
30877 if(label && !icon){
30878 this.el.select('.roo-date-split-field-label', true).createChild({
30880 cls : 'text-danger fa fa-lg fa-star',
30881 tooltip : 'This field is required',
30882 style : 'margin-right:5px;'
30886 this.fireEvent('invalid', this, msg);
30889 clearInvalid : function()
30891 var label = this.el.select('label', true).first();
30892 var icon = this.el.select('i.fa-star', true).first();
30898 this.fireEvent('valid', this);
30901 getName: function()
30911 * http://masonry.desandro.com
30913 * The idea is to render all the bricks based on vertical width...
30915 * The original code extends 'outlayer' - we might need to use that....
30921 * @class Roo.bootstrap.LayoutMasonry
30922 * @extends Roo.bootstrap.Component
30923 * Bootstrap Layout Masonry class
30926 * Create a new Element
30927 * @param {Object} config The config object
30930 Roo.bootstrap.LayoutMasonry = function(config){
30932 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30936 Roo.bootstrap.LayoutMasonry.register(this);
30942 * Fire after layout the items
30943 * @param {Roo.bootstrap.LayoutMasonry} this
30944 * @param {Roo.EventObject} e
30951 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30954 * @cfg {Boolean} isLayoutInstant = no animation?
30956 isLayoutInstant : false, // needed?
30959 * @cfg {Number} boxWidth width of the columns
30964 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30969 * @cfg {Number} padWidth padding below box..
30974 * @cfg {Number} gutter gutter width..
30979 * @cfg {Number} maxCols maximum number of columns
30985 * @cfg {Boolean} isAutoInitial defalut true
30987 isAutoInitial : true,
30992 * @cfg {Boolean} isHorizontal defalut false
30994 isHorizontal : false,
30996 currentSize : null,
31002 bricks: null, //CompositeElement
31006 _isLayoutInited : false,
31008 // isAlternative : false, // only use for vertical layout...
31011 * @cfg {Number} alternativePadWidth padding below box..
31013 alternativePadWidth : 50,
31015 selectedBrick : [],
31017 getAutoCreate : function(){
31019 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31023 cls: 'blog-masonary-wrapper ' + this.cls,
31025 cls : 'mas-boxes masonary'
31032 getChildContainer: function( )
31034 if (this.boxesEl) {
31035 return this.boxesEl;
31038 this.boxesEl = this.el.select('.mas-boxes').first();
31040 return this.boxesEl;
31044 initEvents : function()
31048 if(this.isAutoInitial){
31049 Roo.log('hook children rendered');
31050 this.on('childrenrendered', function() {
31051 Roo.log('children rendered');
31057 initial : function()
31059 this.selectedBrick = [];
31061 this.currentSize = this.el.getBox(true);
31063 Roo.EventManager.onWindowResize(this.resize, this);
31065 if(!this.isAutoInitial){
31073 //this.layout.defer(500,this);
31077 resize : function()
31079 var cs = this.el.getBox(true);
31082 this.currentSize.width == cs.width &&
31083 this.currentSize.x == cs.x &&
31084 this.currentSize.height == cs.height &&
31085 this.currentSize.y == cs.y
31087 Roo.log("no change in with or X or Y");
31091 this.currentSize = cs;
31097 layout : function()
31099 this._resetLayout();
31101 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31103 this.layoutItems( isInstant );
31105 this._isLayoutInited = true;
31107 this.fireEvent('layout', this);
31111 _resetLayout : function()
31113 if(this.isHorizontal){
31114 this.horizontalMeasureColumns();
31118 this.verticalMeasureColumns();
31122 verticalMeasureColumns : function()
31124 this.getContainerWidth();
31126 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31127 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31131 var boxWidth = this.boxWidth + this.padWidth;
31133 if(this.containerWidth < this.boxWidth){
31134 boxWidth = this.containerWidth
31137 var containerWidth = this.containerWidth;
31139 var cols = Math.floor(containerWidth / boxWidth);
31141 this.cols = Math.max( cols, 1 );
31143 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31145 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31147 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31149 this.colWidth = boxWidth + avail - this.padWidth;
31151 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31152 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31155 horizontalMeasureColumns : function()
31157 this.getContainerWidth();
31159 var boxWidth = this.boxWidth;
31161 if(this.containerWidth < boxWidth){
31162 boxWidth = this.containerWidth;
31165 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31167 this.el.setHeight(boxWidth);
31171 getContainerWidth : function()
31173 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31176 layoutItems : function( isInstant )
31178 Roo.log(this.bricks);
31180 var items = Roo.apply([], this.bricks);
31182 if(this.isHorizontal){
31183 this._horizontalLayoutItems( items , isInstant );
31187 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31188 // this._verticalAlternativeLayoutItems( items , isInstant );
31192 this._verticalLayoutItems( items , isInstant );
31196 _verticalLayoutItems : function ( items , isInstant)
31198 if ( !items || !items.length ) {
31203 ['xs', 'xs', 'xs', 'tall'],
31204 ['xs', 'xs', 'tall'],
31205 ['xs', 'xs', 'sm'],
31206 ['xs', 'xs', 'xs'],
31212 ['sm', 'xs', 'xs'],
31216 ['tall', 'xs', 'xs', 'xs'],
31217 ['tall', 'xs', 'xs'],
31229 Roo.each(items, function(item, k){
31231 switch (item.size) {
31232 // these layouts take up a full box,
31243 boxes.push([item]);
31266 var filterPattern = function(box, length)
31274 var pattern = box.slice(0, length);
31278 Roo.each(pattern, function(i){
31279 format.push(i.size);
31282 Roo.each(standard, function(s){
31284 if(String(s) != String(format)){
31293 if(!match && length == 1){
31298 filterPattern(box, length - 1);
31302 queue.push(pattern);
31304 box = box.slice(length, box.length);
31306 filterPattern(box, 4);
31312 Roo.each(boxes, function(box, k){
31318 if(box.length == 1){
31323 filterPattern(box, 4);
31327 this._processVerticalLayoutQueue( queue, isInstant );
31331 // _verticalAlternativeLayoutItems : function( items , isInstant )
31333 // if ( !items || !items.length ) {
31337 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31341 _horizontalLayoutItems : function ( items , isInstant)
31343 if ( !items || !items.length || items.length < 3) {
31349 var eItems = items.slice(0, 3);
31351 items = items.slice(3, items.length);
31354 ['xs', 'xs', 'xs', 'wide'],
31355 ['xs', 'xs', 'wide'],
31356 ['xs', 'xs', 'sm'],
31357 ['xs', 'xs', 'xs'],
31363 ['sm', 'xs', 'xs'],
31367 ['wide', 'xs', 'xs', 'xs'],
31368 ['wide', 'xs', 'xs'],
31381 Roo.each(items, function(item, k){
31383 switch (item.size) {
31394 boxes.push([item]);
31418 var filterPattern = function(box, length)
31426 var pattern = box.slice(0, length);
31430 Roo.each(pattern, function(i){
31431 format.push(i.size);
31434 Roo.each(standard, function(s){
31436 if(String(s) != String(format)){
31445 if(!match && length == 1){
31450 filterPattern(box, length - 1);
31454 queue.push(pattern);
31456 box = box.slice(length, box.length);
31458 filterPattern(box, 4);
31464 Roo.each(boxes, function(box, k){
31470 if(box.length == 1){
31475 filterPattern(box, 4);
31482 var pos = this.el.getBox(true);
31486 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31488 var hit_end = false;
31490 Roo.each(queue, function(box){
31494 Roo.each(box, function(b){
31496 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31506 Roo.each(box, function(b){
31508 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31511 mx = Math.max(mx, b.x);
31515 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31519 Roo.each(box, function(b){
31521 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31535 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31538 /** Sets position of item in DOM
31539 * @param {Element} item
31540 * @param {Number} x - horizontal position
31541 * @param {Number} y - vertical position
31542 * @param {Boolean} isInstant - disables transitions
31544 _processVerticalLayoutQueue : function( queue, isInstant )
31546 var pos = this.el.getBox(true);
31551 for (var i = 0; i < this.cols; i++){
31555 Roo.each(queue, function(box, k){
31557 var col = k % this.cols;
31559 Roo.each(box, function(b,kk){
31561 b.el.position('absolute');
31563 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31564 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31566 if(b.size == 'md-left' || b.size == 'md-right'){
31567 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31568 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31571 b.el.setWidth(width);
31572 b.el.setHeight(height);
31574 b.el.select('iframe',true).setSize(width,height);
31578 for (var i = 0; i < this.cols; i++){
31580 if(maxY[i] < maxY[col]){
31585 col = Math.min(col, i);
31589 x = pos.x + col * (this.colWidth + this.padWidth);
31593 var positions = [];
31595 switch (box.length){
31597 positions = this.getVerticalOneBoxColPositions(x, y, box);
31600 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31603 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31606 positions = this.getVerticalFourBoxColPositions(x, y, box);
31612 Roo.each(box, function(b,kk){
31614 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31616 var sz = b.el.getSize();
31618 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31626 for (var i = 0; i < this.cols; i++){
31627 mY = Math.max(mY, maxY[i]);
31630 this.el.setHeight(mY - pos.y);
31634 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31636 // var pos = this.el.getBox(true);
31639 // var maxX = pos.right;
31641 // var maxHeight = 0;
31643 // Roo.each(items, function(item, k){
31647 // item.el.position('absolute');
31649 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31651 // item.el.setWidth(width);
31653 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31655 // item.el.setHeight(height);
31658 // item.el.setXY([x, y], isInstant ? false : true);
31660 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31663 // y = y + height + this.alternativePadWidth;
31665 // maxHeight = maxHeight + height + this.alternativePadWidth;
31669 // this.el.setHeight(maxHeight);
31673 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31675 var pos = this.el.getBox(true);
31680 var maxX = pos.right;
31682 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31684 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31686 Roo.each(queue, function(box, k){
31688 Roo.each(box, function(b, kk){
31690 b.el.position('absolute');
31692 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31693 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31695 if(b.size == 'md-left' || b.size == 'md-right'){
31696 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31697 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31700 b.el.setWidth(width);
31701 b.el.setHeight(height);
31709 var positions = [];
31711 switch (box.length){
31713 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31716 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31719 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31722 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31728 Roo.each(box, function(b,kk){
31730 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31732 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31740 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31742 Roo.each(eItems, function(b,k){
31744 b.size = (k == 0) ? 'sm' : 'xs';
31745 b.x = (k == 0) ? 2 : 1;
31746 b.y = (k == 0) ? 2 : 1;
31748 b.el.position('absolute');
31750 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31752 b.el.setWidth(width);
31754 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31756 b.el.setHeight(height);
31760 var positions = [];
31763 x : maxX - this.unitWidth * 2 - this.gutter,
31768 x : maxX - this.unitWidth,
31769 y : minY + (this.unitWidth + this.gutter) * 2
31773 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31777 Roo.each(eItems, function(b,k){
31779 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31785 getVerticalOneBoxColPositions : function(x, y, box)
31789 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31791 if(box[0].size == 'md-left'){
31795 if(box[0].size == 'md-right'){
31800 x : x + (this.unitWidth + this.gutter) * rand,
31807 getVerticalTwoBoxColPositions : function(x, y, box)
31811 if(box[0].size == 'xs'){
31815 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31819 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31833 x : x + (this.unitWidth + this.gutter) * 2,
31834 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31841 getVerticalThreeBoxColPositions : function(x, y, box)
31845 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31853 x : x + (this.unitWidth + this.gutter) * 1,
31858 x : x + (this.unitWidth + this.gutter) * 2,
31866 if(box[0].size == 'xs' && box[1].size == 'xs'){
31875 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31879 x : x + (this.unitWidth + this.gutter) * 1,
31893 x : x + (this.unitWidth + this.gutter) * 2,
31898 x : x + (this.unitWidth + this.gutter) * 2,
31899 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31906 getVerticalFourBoxColPositions : function(x, y, box)
31910 if(box[0].size == 'xs'){
31919 y : y + (this.unitHeight + this.gutter) * 1
31924 y : y + (this.unitHeight + this.gutter) * 2
31928 x : x + (this.unitWidth + this.gutter) * 1,
31942 x : x + (this.unitWidth + this.gutter) * 2,
31947 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31948 y : y + (this.unitHeight + this.gutter) * 1
31952 x : x + (this.unitWidth + this.gutter) * 2,
31953 y : y + (this.unitWidth + this.gutter) * 2
31960 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31964 if(box[0].size == 'md-left'){
31966 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31973 if(box[0].size == 'md-right'){
31975 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31976 y : minY + (this.unitWidth + this.gutter) * 1
31982 var rand = Math.floor(Math.random() * (4 - box[0].y));
31985 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31986 y : minY + (this.unitWidth + this.gutter) * rand
31993 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31997 if(box[0].size == 'xs'){
32000 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32005 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32006 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32014 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32019 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32020 y : minY + (this.unitWidth + this.gutter) * 2
32027 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32031 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32034 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32039 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32040 y : minY + (this.unitWidth + this.gutter) * 1
32044 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32045 y : minY + (this.unitWidth + this.gutter) * 2
32052 if(box[0].size == 'xs' && box[1].size == 'xs'){
32055 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32060 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32065 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32066 y : minY + (this.unitWidth + this.gutter) * 1
32074 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32079 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32080 y : minY + (this.unitWidth + this.gutter) * 2
32084 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32085 y : minY + (this.unitWidth + this.gutter) * 2
32092 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32096 if(box[0].size == 'xs'){
32099 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32104 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32109 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),
32114 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32115 y : minY + (this.unitWidth + this.gutter) * 1
32123 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32128 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32129 y : minY + (this.unitWidth + this.gutter) * 2
32133 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32134 y : minY + (this.unitWidth + this.gutter) * 2
32138 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),
32139 y : minY + (this.unitWidth + this.gutter) * 2
32147 * remove a Masonry Brick
32148 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32150 removeBrick : function(brick_id)
32156 for (var i = 0; i<this.bricks.length; i++) {
32157 if (this.bricks[i].id == brick_id) {
32158 this.bricks.splice(i,1);
32159 this.el.dom.removeChild(Roo.get(brick_id).dom);
32166 * adds a Masonry Brick
32167 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32169 addBrick : function(cfg)
32171 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32172 //this.register(cn);
32173 cn.parentId = this.id;
32174 cn.render(this.el);
32179 * register a Masonry Brick
32180 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32183 register : function(brick)
32185 this.bricks.push(brick);
32186 brick.masonryId = this.id;
32190 * clear all the Masonry Brick
32192 clearAll : function()
32195 //this.getChildContainer().dom.innerHTML = "";
32196 this.el.dom.innerHTML = '';
32199 getSelected : function()
32201 if (!this.selectedBrick) {
32205 return this.selectedBrick;
32209 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32213 * register a Masonry Layout
32214 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32217 register : function(layout)
32219 this.groups[layout.id] = layout;
32222 * fetch a Masonry Layout based on the masonry layout ID
32223 * @param {string} the masonry layout to add
32224 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32227 get: function(layout_id) {
32228 if (typeof(this.groups[layout_id]) == 'undefined') {
32231 return this.groups[layout_id] ;
32243 * http://masonry.desandro.com
32245 * The idea is to render all the bricks based on vertical width...
32247 * The original code extends 'outlayer' - we might need to use that....
32253 * @class Roo.bootstrap.LayoutMasonryAuto
32254 * @extends Roo.bootstrap.Component
32255 * Bootstrap Layout Masonry class
32258 * Create a new Element
32259 * @param {Object} config The config object
32262 Roo.bootstrap.LayoutMasonryAuto = function(config){
32263 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32266 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32269 * @cfg {Boolean} isFitWidth - resize the width..
32271 isFitWidth : false, // options..
32273 * @cfg {Boolean} isOriginLeft = left align?
32275 isOriginLeft : true,
32277 * @cfg {Boolean} isOriginTop = top align?
32279 isOriginTop : false,
32281 * @cfg {Boolean} isLayoutInstant = no animation?
32283 isLayoutInstant : false, // needed?
32285 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32287 isResizingContainer : true,
32289 * @cfg {Number} columnWidth width of the columns
32295 * @cfg {Number} maxCols maximum number of columns
32300 * @cfg {Number} padHeight padding below box..
32306 * @cfg {Boolean} isAutoInitial defalut true
32309 isAutoInitial : true,
32315 initialColumnWidth : 0,
32316 currentSize : null,
32318 colYs : null, // array.
32325 bricks: null, //CompositeElement
32326 cols : 0, // array?
32327 // element : null, // wrapped now this.el
32328 _isLayoutInited : null,
32331 getAutoCreate : function(){
32335 cls: 'blog-masonary-wrapper ' + this.cls,
32337 cls : 'mas-boxes masonary'
32344 getChildContainer: function( )
32346 if (this.boxesEl) {
32347 return this.boxesEl;
32350 this.boxesEl = this.el.select('.mas-boxes').first();
32352 return this.boxesEl;
32356 initEvents : function()
32360 if(this.isAutoInitial){
32361 Roo.log('hook children rendered');
32362 this.on('childrenrendered', function() {
32363 Roo.log('children rendered');
32370 initial : function()
32372 this.reloadItems();
32374 this.currentSize = this.el.getBox(true);
32376 /// was window resize... - let's see if this works..
32377 Roo.EventManager.onWindowResize(this.resize, this);
32379 if(!this.isAutoInitial){
32384 this.layout.defer(500,this);
32387 reloadItems: function()
32389 this.bricks = this.el.select('.masonry-brick', true);
32391 this.bricks.each(function(b) {
32392 //Roo.log(b.getSize());
32393 if (!b.attr('originalwidth')) {
32394 b.attr('originalwidth', b.getSize().width);
32399 Roo.log(this.bricks.elements.length);
32402 resize : function()
32405 var cs = this.el.getBox(true);
32407 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32408 Roo.log("no change in with or X");
32411 this.currentSize = cs;
32415 layout : function()
32418 this._resetLayout();
32419 //this._manageStamps();
32421 // don't animate first layout
32422 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32423 this.layoutItems( isInstant );
32425 // flag for initalized
32426 this._isLayoutInited = true;
32429 layoutItems : function( isInstant )
32431 //var items = this._getItemsForLayout( this.items );
32432 // original code supports filtering layout items.. we just ignore it..
32434 this._layoutItems( this.bricks , isInstant );
32436 this._postLayout();
32438 _layoutItems : function ( items , isInstant)
32440 //this.fireEvent( 'layout', this, items );
32443 if ( !items || !items.elements.length ) {
32444 // no items, emit event with empty array
32449 items.each(function(item) {
32450 Roo.log("layout item");
32452 // get x/y object from method
32453 var position = this._getItemLayoutPosition( item );
32455 position.item = item;
32456 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32457 queue.push( position );
32460 this._processLayoutQueue( queue );
32462 /** Sets position of item in DOM
32463 * @param {Element} item
32464 * @param {Number} x - horizontal position
32465 * @param {Number} y - vertical position
32466 * @param {Boolean} isInstant - disables transitions
32468 _processLayoutQueue : function( queue )
32470 for ( var i=0, len = queue.length; i < len; i++ ) {
32471 var obj = queue[i];
32472 obj.item.position('absolute');
32473 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32479 * Any logic you want to do after each layout,
32480 * i.e. size the container
32482 _postLayout : function()
32484 this.resizeContainer();
32487 resizeContainer : function()
32489 if ( !this.isResizingContainer ) {
32492 var size = this._getContainerSize();
32494 this.el.setSize(size.width,size.height);
32495 this.boxesEl.setSize(size.width,size.height);
32501 _resetLayout : function()
32503 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32504 this.colWidth = this.el.getWidth();
32505 //this.gutter = this.el.getWidth();
32507 this.measureColumns();
32513 this.colYs.push( 0 );
32519 measureColumns : function()
32521 this.getContainerWidth();
32522 // if columnWidth is 0, default to outerWidth of first item
32523 if ( !this.columnWidth ) {
32524 var firstItem = this.bricks.first();
32525 Roo.log(firstItem);
32526 this.columnWidth = this.containerWidth;
32527 if (firstItem && firstItem.attr('originalwidth') ) {
32528 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32530 // columnWidth fall back to item of first element
32531 Roo.log("set column width?");
32532 this.initialColumnWidth = this.columnWidth ;
32534 // if first elem has no width, default to size of container
32539 if (this.initialColumnWidth) {
32540 this.columnWidth = this.initialColumnWidth;
32545 // column width is fixed at the top - however if container width get's smaller we should
32548 // this bit calcs how man columns..
32550 var columnWidth = this.columnWidth += this.gutter;
32552 // calculate columns
32553 var containerWidth = this.containerWidth + this.gutter;
32555 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32556 // fix rounding errors, typically with gutters
32557 var excess = columnWidth - containerWidth % columnWidth;
32560 // if overshoot is less than a pixel, round up, otherwise floor it
32561 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32562 cols = Math[ mathMethod ]( cols );
32563 this.cols = Math.max( cols, 1 );
32564 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32566 // padding positioning..
32567 var totalColWidth = this.cols * this.columnWidth;
32568 var padavail = this.containerWidth - totalColWidth;
32569 // so for 2 columns - we need 3 'pads'
32571 var padNeeded = (1+this.cols) * this.padWidth;
32573 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32575 this.columnWidth += padExtra
32576 //this.padWidth = Math.floor(padavail / ( this.cols));
32578 // adjust colum width so that padding is fixed??
32580 // we have 3 columns ... total = width * 3
32581 // we have X left over... that should be used by
32583 //if (this.expandC) {
32591 getContainerWidth : function()
32593 /* // container is parent if fit width
32594 var container = this.isFitWidth ? this.element.parentNode : this.element;
32595 // check that this.size and size are there
32596 // IE8 triggers resize on body size change, so they might not be
32598 var size = getSize( container ); //FIXME
32599 this.containerWidth = size && size.innerWidth; //FIXME
32602 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32606 _getItemLayoutPosition : function( item ) // what is item?
32608 // we resize the item to our columnWidth..
32610 item.setWidth(this.columnWidth);
32611 item.autoBoxAdjust = false;
32613 var sz = item.getSize();
32615 // how many columns does this brick span
32616 var remainder = this.containerWidth % this.columnWidth;
32618 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32619 // round if off by 1 pixel, otherwise use ceil
32620 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32621 colSpan = Math.min( colSpan, this.cols );
32623 // normally this should be '1' as we dont' currently allow multi width columns..
32625 var colGroup = this._getColGroup( colSpan );
32626 // get the minimum Y value from the columns
32627 var minimumY = Math.min.apply( Math, colGroup );
32628 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32630 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32632 // position the brick
32634 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32635 y: this.currentSize.y + minimumY + this.padHeight
32639 // apply setHeight to necessary columns
32640 var setHeight = minimumY + sz.height + this.padHeight;
32641 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32643 var setSpan = this.cols + 1 - colGroup.length;
32644 for ( var i = 0; i < setSpan; i++ ) {
32645 this.colYs[ shortColIndex + i ] = setHeight ;
32652 * @param {Number} colSpan - number of columns the element spans
32653 * @returns {Array} colGroup
32655 _getColGroup : function( colSpan )
32657 if ( colSpan < 2 ) {
32658 // if brick spans only one column, use all the column Ys
32663 // how many different places could this brick fit horizontally
32664 var groupCount = this.cols + 1 - colSpan;
32665 // for each group potential horizontal position
32666 for ( var i = 0; i < groupCount; i++ ) {
32667 // make an array of colY values for that one group
32668 var groupColYs = this.colYs.slice( i, i + colSpan );
32669 // and get the max value of the array
32670 colGroup[i] = Math.max.apply( Math, groupColYs );
32675 _manageStamp : function( stamp )
32677 var stampSize = stamp.getSize();
32678 var offset = stamp.getBox();
32679 // get the columns that this stamp affects
32680 var firstX = this.isOriginLeft ? offset.x : offset.right;
32681 var lastX = firstX + stampSize.width;
32682 var firstCol = Math.floor( firstX / this.columnWidth );
32683 firstCol = Math.max( 0, firstCol );
32685 var lastCol = Math.floor( lastX / this.columnWidth );
32686 // lastCol should not go over if multiple of columnWidth #425
32687 lastCol -= lastX % this.columnWidth ? 0 : 1;
32688 lastCol = Math.min( this.cols - 1, lastCol );
32690 // set colYs to bottom of the stamp
32691 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32694 for ( var i = firstCol; i <= lastCol; i++ ) {
32695 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32700 _getContainerSize : function()
32702 this.maxY = Math.max.apply( Math, this.colYs );
32707 if ( this.isFitWidth ) {
32708 size.width = this._getContainerFitWidth();
32714 _getContainerFitWidth : function()
32716 var unusedCols = 0;
32717 // count unused columns
32720 if ( this.colYs[i] !== 0 ) {
32725 // fit container to columns that have been used
32726 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32729 needsResizeLayout : function()
32731 var previousWidth = this.containerWidth;
32732 this.getContainerWidth();
32733 return previousWidth !== this.containerWidth;
32748 * @class Roo.bootstrap.MasonryBrick
32749 * @extends Roo.bootstrap.Component
32750 * Bootstrap MasonryBrick class
32753 * Create a new MasonryBrick
32754 * @param {Object} config The config object
32757 Roo.bootstrap.MasonryBrick = function(config){
32759 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32761 Roo.bootstrap.MasonryBrick.register(this);
32767 * When a MasonryBrick is clcik
32768 * @param {Roo.bootstrap.MasonryBrick} this
32769 * @param {Roo.EventObject} e
32775 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32778 * @cfg {String} title
32782 * @cfg {String} html
32786 * @cfg {String} bgimage
32790 * @cfg {String} videourl
32794 * @cfg {String} cls
32798 * @cfg {String} href
32802 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32807 * @cfg {String} placetitle (center|bottom)
32812 * @cfg {Boolean} isFitContainer defalut true
32814 isFitContainer : true,
32817 * @cfg {Boolean} preventDefault defalut false
32819 preventDefault : false,
32822 * @cfg {Boolean} inverse defalut false
32824 maskInverse : false,
32826 getAutoCreate : function()
32828 if(!this.isFitContainer){
32829 return this.getSplitAutoCreate();
32832 var cls = 'masonry-brick masonry-brick-full';
32834 if(this.href.length){
32835 cls += ' masonry-brick-link';
32838 if(this.bgimage.length){
32839 cls += ' masonry-brick-image';
32842 if(this.maskInverse){
32843 cls += ' mask-inverse';
32846 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32847 cls += ' enable-mask';
32851 cls += ' masonry-' + this.size + '-brick';
32854 if(this.placetitle.length){
32856 switch (this.placetitle) {
32858 cls += ' masonry-center-title';
32861 cls += ' masonry-bottom-title';
32868 if(!this.html.length && !this.bgimage.length){
32869 cls += ' masonry-center-title';
32872 if(!this.html.length && this.bgimage.length){
32873 cls += ' masonry-bottom-title';
32878 cls += ' ' + this.cls;
32882 tag: (this.href.length) ? 'a' : 'div',
32887 cls: 'masonry-brick-mask'
32891 cls: 'masonry-brick-paragraph',
32897 if(this.href.length){
32898 cfg.href = this.href;
32901 var cn = cfg.cn[1].cn;
32903 if(this.title.length){
32906 cls: 'masonry-brick-title',
32911 if(this.html.length){
32914 cls: 'masonry-brick-text',
32919 if (!this.title.length && !this.html.length) {
32920 cfg.cn[1].cls += ' hide';
32923 if(this.bgimage.length){
32926 cls: 'masonry-brick-image-view',
32931 if(this.videourl.length){
32932 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32933 // youtube support only?
32936 cls: 'masonry-brick-image-view',
32939 allowfullscreen : true
32947 getSplitAutoCreate : function()
32949 var cls = 'masonry-brick masonry-brick-split';
32951 if(this.href.length){
32952 cls += ' masonry-brick-link';
32955 if(this.bgimage.length){
32956 cls += ' masonry-brick-image';
32960 cls += ' masonry-' + this.size + '-brick';
32963 switch (this.placetitle) {
32965 cls += ' masonry-center-title';
32968 cls += ' masonry-bottom-title';
32971 if(!this.bgimage.length){
32972 cls += ' masonry-center-title';
32975 if(this.bgimage.length){
32976 cls += ' masonry-bottom-title';
32982 cls += ' ' + this.cls;
32986 tag: (this.href.length) ? 'a' : 'div',
32991 cls: 'masonry-brick-split-head',
32995 cls: 'masonry-brick-paragraph',
33002 cls: 'masonry-brick-split-body',
33008 if(this.href.length){
33009 cfg.href = this.href;
33012 if(this.title.length){
33013 cfg.cn[0].cn[0].cn.push({
33015 cls: 'masonry-brick-title',
33020 if(this.html.length){
33021 cfg.cn[1].cn.push({
33023 cls: 'masonry-brick-text',
33028 if(this.bgimage.length){
33029 cfg.cn[0].cn.push({
33031 cls: 'masonry-brick-image-view',
33036 if(this.videourl.length){
33037 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33038 // youtube support only?
33039 cfg.cn[0].cn.cn.push({
33041 cls: 'masonry-brick-image-view',
33044 allowfullscreen : true
33051 initEvents: function()
33053 switch (this.size) {
33086 this.el.on('touchstart', this.onTouchStart, this);
33087 this.el.on('touchmove', this.onTouchMove, this);
33088 this.el.on('touchend', this.onTouchEnd, this);
33089 this.el.on('contextmenu', this.onContextMenu, this);
33091 this.el.on('mouseenter' ,this.enter, this);
33092 this.el.on('mouseleave', this.leave, this);
33093 this.el.on('click', this.onClick, this);
33096 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33097 this.parent().bricks.push(this);
33102 onClick: function(e, el)
33104 var time = this.endTimer - this.startTimer;
33105 // Roo.log(e.preventDefault());
33108 e.preventDefault();
33113 if(!this.preventDefault){
33117 e.preventDefault();
33119 if (this.activeClass != '') {
33120 this.selectBrick();
33123 this.fireEvent('click', this, e);
33126 enter: function(e, el)
33128 e.preventDefault();
33130 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33134 if(this.bgimage.length && this.html.length){
33135 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33139 leave: function(e, el)
33141 e.preventDefault();
33143 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33147 if(this.bgimage.length && this.html.length){
33148 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33152 onTouchStart: function(e, el)
33154 // e.preventDefault();
33156 this.touchmoved = false;
33158 if(!this.isFitContainer){
33162 if(!this.bgimage.length || !this.html.length){
33166 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33168 this.timer = new Date().getTime();
33172 onTouchMove: function(e, el)
33174 this.touchmoved = true;
33177 onContextMenu : function(e,el)
33179 e.preventDefault();
33180 e.stopPropagation();
33184 onTouchEnd: function(e, el)
33186 // e.preventDefault();
33188 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33195 if(!this.bgimage.length || !this.html.length){
33197 if(this.href.length){
33198 window.location.href = this.href;
33204 if(!this.isFitContainer){
33208 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33210 window.location.href = this.href;
33213 //selection on single brick only
33214 selectBrick : function() {
33216 if (!this.parentId) {
33220 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33221 var index = m.selectedBrick.indexOf(this.id);
33224 m.selectedBrick.splice(index,1);
33225 this.el.removeClass(this.activeClass);
33229 for(var i = 0; i < m.selectedBrick.length; i++) {
33230 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33231 b.el.removeClass(b.activeClass);
33234 m.selectedBrick = [];
33236 m.selectedBrick.push(this.id);
33237 this.el.addClass(this.activeClass);
33241 isSelected : function(){
33242 return this.el.hasClass(this.activeClass);
33247 Roo.apply(Roo.bootstrap.MasonryBrick, {
33250 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33252 * register a Masonry Brick
33253 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33256 register : function(brick)
33258 //this.groups[brick.id] = brick;
33259 this.groups.add(brick.id, brick);
33262 * fetch a masonry brick based on the masonry brick ID
33263 * @param {string} the masonry brick to add
33264 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33267 get: function(brick_id)
33269 // if (typeof(this.groups[brick_id]) == 'undefined') {
33272 // return this.groups[brick_id] ;
33274 if(this.groups.key(brick_id)) {
33275 return this.groups.key(brick_id);
33293 * @class Roo.bootstrap.Brick
33294 * @extends Roo.bootstrap.Component
33295 * Bootstrap Brick class
33298 * Create a new Brick
33299 * @param {Object} config The config object
33302 Roo.bootstrap.Brick = function(config){
33303 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33309 * When a Brick is click
33310 * @param {Roo.bootstrap.Brick} this
33311 * @param {Roo.EventObject} e
33317 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33320 * @cfg {String} title
33324 * @cfg {String} html
33328 * @cfg {String} bgimage
33332 * @cfg {String} cls
33336 * @cfg {String} href
33340 * @cfg {String} video
33344 * @cfg {Boolean} square
33348 getAutoCreate : function()
33350 var cls = 'roo-brick';
33352 if(this.href.length){
33353 cls += ' roo-brick-link';
33356 if(this.bgimage.length){
33357 cls += ' roo-brick-image';
33360 if(!this.html.length && !this.bgimage.length){
33361 cls += ' roo-brick-center-title';
33364 if(!this.html.length && this.bgimage.length){
33365 cls += ' roo-brick-bottom-title';
33369 cls += ' ' + this.cls;
33373 tag: (this.href.length) ? 'a' : 'div',
33378 cls: 'roo-brick-paragraph',
33384 if(this.href.length){
33385 cfg.href = this.href;
33388 var cn = cfg.cn[0].cn;
33390 if(this.title.length){
33393 cls: 'roo-brick-title',
33398 if(this.html.length){
33401 cls: 'roo-brick-text',
33408 if(this.bgimage.length){
33411 cls: 'roo-brick-image-view',
33419 initEvents: function()
33421 if(this.title.length || this.html.length){
33422 this.el.on('mouseenter' ,this.enter, this);
33423 this.el.on('mouseleave', this.leave, this);
33426 Roo.EventManager.onWindowResize(this.resize, this);
33428 if(this.bgimage.length){
33429 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33430 this.imageEl.on('load', this.onImageLoad, this);
33437 onImageLoad : function()
33442 resize : function()
33444 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33446 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33448 if(this.bgimage.length){
33449 var image = this.el.select('.roo-brick-image-view', true).first();
33451 image.setWidth(paragraph.getWidth());
33454 image.setHeight(paragraph.getWidth());
33457 this.el.setHeight(image.getHeight());
33458 paragraph.setHeight(image.getHeight());
33464 enter: function(e, el)
33466 e.preventDefault();
33468 if(this.bgimage.length){
33469 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33470 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33474 leave: function(e, el)
33476 e.preventDefault();
33478 if(this.bgimage.length){
33479 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33480 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33495 * @class Roo.bootstrap.NumberField
33496 * @extends Roo.bootstrap.Input
33497 * Bootstrap NumberField class
33503 * Create a new NumberField
33504 * @param {Object} config The config object
33507 Roo.bootstrap.NumberField = function(config){
33508 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33511 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33514 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33516 allowDecimals : true,
33518 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33520 decimalSeparator : ".",
33522 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33524 decimalPrecision : 2,
33526 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33528 allowNegative : true,
33531 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33535 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33537 minValue : Number.NEGATIVE_INFINITY,
33539 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33541 maxValue : Number.MAX_VALUE,
33543 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33545 minText : "The minimum value for this field is {0}",
33547 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33549 maxText : "The maximum value for this field is {0}",
33551 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33552 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33554 nanText : "{0} is not a valid number",
33556 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33558 thousandsDelimiter : false,
33560 * @cfg {String} valueAlign alignment of value
33562 valueAlign : "left",
33564 getAutoCreate : function()
33566 var hiddenInput = {
33570 cls: 'hidden-number-input'
33574 hiddenInput.name = this.name;
33579 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33581 this.name = hiddenInput.name;
33583 if(cfg.cn.length > 0) {
33584 cfg.cn.push(hiddenInput);
33591 initEvents : function()
33593 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33595 var allowed = "0123456789";
33597 if(this.allowDecimals){
33598 allowed += this.decimalSeparator;
33601 if(this.allowNegative){
33605 if(this.thousandsDelimiter) {
33609 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33611 var keyPress = function(e){
33613 var k = e.getKey();
33615 var c = e.getCharCode();
33618 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33619 allowed.indexOf(String.fromCharCode(c)) === -1
33625 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33629 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33634 this.el.on("keypress", keyPress, this);
33637 validateValue : function(value)
33640 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33644 var num = this.parseValue(value);
33647 this.markInvalid(String.format(this.nanText, value));
33651 if(num < this.minValue){
33652 this.markInvalid(String.format(this.minText, this.minValue));
33656 if(num > this.maxValue){
33657 this.markInvalid(String.format(this.maxText, this.maxValue));
33664 getValue : function()
33666 var v = this.hiddenEl().getValue();
33668 return this.fixPrecision(this.parseValue(v));
33671 parseValue : function(value)
33673 if(this.thousandsDelimiter) {
33675 r = new RegExp(",", "g");
33676 value = value.replace(r, "");
33679 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33680 return isNaN(value) ? '' : value;
33683 fixPrecision : function(value)
33685 if(this.thousandsDelimiter) {
33687 r = new RegExp(",", "g");
33688 value = value.replace(r, "");
33691 var nan = isNaN(value);
33693 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33694 return nan ? '' : value;
33696 return parseFloat(value).toFixed(this.decimalPrecision);
33699 setValue : function(v)
33701 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33707 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33709 this.inputEl().dom.value = (v == '') ? '' :
33710 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33712 if(!this.allowZero && v === '0') {
33713 this.hiddenEl().dom.value = '';
33714 this.inputEl().dom.value = '';
33721 decimalPrecisionFcn : function(v)
33723 return Math.floor(v);
33726 beforeBlur : function()
33728 var v = this.parseValue(this.getRawValue());
33730 if(v || v === 0 || v === ''){
33735 hiddenEl : function()
33737 return this.el.select('input.hidden-number-input',true).first();
33749 * @class Roo.bootstrap.DocumentSlider
33750 * @extends Roo.bootstrap.Component
33751 * Bootstrap DocumentSlider class
33754 * Create a new DocumentViewer
33755 * @param {Object} config The config object
33758 Roo.bootstrap.DocumentSlider = function(config){
33759 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33766 * Fire after initEvent
33767 * @param {Roo.bootstrap.DocumentSlider} this
33772 * Fire after update
33773 * @param {Roo.bootstrap.DocumentSlider} this
33779 * @param {Roo.bootstrap.DocumentSlider} this
33785 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33791 getAutoCreate : function()
33795 cls : 'roo-document-slider',
33799 cls : 'roo-document-slider-header',
33803 cls : 'roo-document-slider-header-title'
33809 cls : 'roo-document-slider-body',
33813 cls : 'roo-document-slider-prev',
33817 cls : 'fa fa-chevron-left'
33823 cls : 'roo-document-slider-thumb',
33827 cls : 'roo-document-slider-image'
33833 cls : 'roo-document-slider-next',
33837 cls : 'fa fa-chevron-right'
33849 initEvents : function()
33851 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33852 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33854 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33855 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33857 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33858 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33860 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33861 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33863 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33864 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33866 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33867 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33869 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33870 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33872 this.thumbEl.on('click', this.onClick, this);
33874 this.prevIndicator.on('click', this.prev, this);
33876 this.nextIndicator.on('click', this.next, this);
33880 initial : function()
33882 if(this.files.length){
33883 this.indicator = 1;
33887 this.fireEvent('initial', this);
33890 update : function()
33892 this.imageEl.attr('src', this.files[this.indicator - 1]);
33894 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33896 this.prevIndicator.show();
33898 if(this.indicator == 1){
33899 this.prevIndicator.hide();
33902 this.nextIndicator.show();
33904 if(this.indicator == this.files.length){
33905 this.nextIndicator.hide();
33908 this.thumbEl.scrollTo('top');
33910 this.fireEvent('update', this);
33913 onClick : function(e)
33915 e.preventDefault();
33917 this.fireEvent('click', this);
33922 e.preventDefault();
33924 this.indicator = Math.max(1, this.indicator - 1);
33931 e.preventDefault();
33933 this.indicator = Math.min(this.files.length, this.indicator + 1);
33947 * @class Roo.bootstrap.RadioSet
33948 * @extends Roo.bootstrap.Input
33949 * Bootstrap RadioSet class
33950 * @cfg {String} indicatorpos (left|right) default left
33951 * @cfg {Boolean} inline (true|false) inline the element (default true)
33952 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33954 * Create a new RadioSet
33955 * @param {Object} config The config object
33958 Roo.bootstrap.RadioSet = function(config){
33960 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33964 Roo.bootstrap.RadioSet.register(this);
33969 * Fires when the element is checked or unchecked.
33970 * @param {Roo.bootstrap.RadioSet} this This radio
33971 * @param {Roo.bootstrap.Radio} item The checked item
33976 * Fires when the element is click.
33977 * @param {Roo.bootstrap.RadioSet} this This radio set
33978 * @param {Roo.bootstrap.Radio} item The checked item
33979 * @param {Roo.EventObject} e The event object
33986 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33994 indicatorpos : 'left',
33996 getAutoCreate : function()
34000 cls : 'roo-radio-set-label',
34004 html : this.fieldLabel
34009 if(this.indicatorpos == 'left'){
34012 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34013 tooltip : 'This field is required'
34018 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34019 tooltip : 'This field is required'
34025 cls : 'roo-radio-set-items'
34028 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34030 if (align === 'left' && this.fieldLabel.length) {
34033 cls : "roo-radio-set-right",
34039 if(this.labelWidth > 12){
34040 label.style = "width: " + this.labelWidth + 'px';
34043 if(this.labelWidth < 13 && this.labelmd == 0){
34044 this.labelmd = this.labelWidth;
34047 if(this.labellg > 0){
34048 label.cls += ' col-lg-' + this.labellg;
34049 items.cls += ' col-lg-' + (12 - this.labellg);
34052 if(this.labelmd > 0){
34053 label.cls += ' col-md-' + this.labelmd;
34054 items.cls += ' col-md-' + (12 - this.labelmd);
34057 if(this.labelsm > 0){
34058 label.cls += ' col-sm-' + this.labelsm;
34059 items.cls += ' col-sm-' + (12 - this.labelsm);
34062 if(this.labelxs > 0){
34063 label.cls += ' col-xs-' + this.labelxs;
34064 items.cls += ' col-xs-' + (12 - this.labelxs);
34070 cls : 'roo-radio-set',
34074 cls : 'roo-radio-set-input',
34077 value : this.value ? this.value : ''
34084 if(this.weight.length){
34085 cfg.cls += ' roo-radio-' + this.weight;
34089 cfg.cls += ' roo-radio-set-inline';
34093 ['xs','sm','md','lg'].map(function(size){
34094 if (settings[size]) {
34095 cfg.cls += ' col-' + size + '-' + settings[size];
34103 initEvents : function()
34105 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34106 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34108 if(!this.fieldLabel.length){
34109 this.labelEl.hide();
34112 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34113 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34115 this.indicator = this.indicatorEl();
34117 if(this.indicator){
34118 this.indicator.addClass('invisible');
34121 this.originalValue = this.getValue();
34125 inputEl: function ()
34127 return this.el.select('.roo-radio-set-input', true).first();
34130 getChildContainer : function()
34132 return this.itemsEl;
34135 register : function(item)
34137 this.radioes.push(item);
34141 validate : function()
34143 if(this.getVisibilityEl().hasClass('hidden')){
34149 Roo.each(this.radioes, function(i){
34158 if(this.allowBlank) {
34162 if(this.disabled || valid){
34167 this.markInvalid();
34172 markValid : function()
34174 if(this.labelEl.isVisible(true)){
34175 this.indicatorEl().removeClass('visible');
34176 this.indicatorEl().addClass('invisible');
34179 this.el.removeClass([this.invalidClass, this.validClass]);
34180 this.el.addClass(this.validClass);
34182 this.fireEvent('valid', this);
34185 markInvalid : function(msg)
34187 if(this.allowBlank || this.disabled){
34191 if(this.labelEl.isVisible(true)){
34192 this.indicatorEl().removeClass('invisible');
34193 this.indicatorEl().addClass('visible');
34196 this.el.removeClass([this.invalidClass, this.validClass]);
34197 this.el.addClass(this.invalidClass);
34199 this.fireEvent('invalid', this, msg);
34203 setValue : function(v, suppressEvent)
34205 if(this.value === v){
34212 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34215 Roo.each(this.radioes, function(i){
34217 i.el.removeClass('checked');
34220 Roo.each(this.radioes, function(i){
34222 if(i.value === v || i.value.toString() === v.toString()){
34224 i.el.addClass('checked');
34226 if(suppressEvent !== true){
34227 this.fireEvent('check', this, i);
34238 clearInvalid : function(){
34240 if(!this.el || this.preventMark){
34244 this.el.removeClass([this.invalidClass]);
34246 this.fireEvent('valid', this);
34251 Roo.apply(Roo.bootstrap.RadioSet, {
34255 register : function(set)
34257 this.groups[set.name] = set;
34260 get: function(name)
34262 if (typeof(this.groups[name]) == 'undefined') {
34266 return this.groups[name] ;
34272 * Ext JS Library 1.1.1
34273 * Copyright(c) 2006-2007, Ext JS, LLC.
34275 * Originally Released Under LGPL - original licence link has changed is not relivant.
34278 * <script type="text/javascript">
34283 * @class Roo.bootstrap.SplitBar
34284 * @extends Roo.util.Observable
34285 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34289 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34290 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34291 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34292 split.minSize = 100;
34293 split.maxSize = 600;
34294 split.animate = true;
34295 split.on('moved', splitterMoved);
34298 * Create a new SplitBar
34299 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34300 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34301 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34302 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34303 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34304 position of the SplitBar).
34306 Roo.bootstrap.SplitBar = function(cfg){
34311 // dragElement : elm
34312 // resizingElement: el,
34314 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34315 // placement : Roo.bootstrap.SplitBar.LEFT ,
34316 // existingProxy ???
34319 this.el = Roo.get(cfg.dragElement, true);
34320 this.el.dom.unselectable = "on";
34322 this.resizingEl = Roo.get(cfg.resizingElement, true);
34326 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34327 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34330 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34333 * The minimum size of the resizing element. (Defaults to 0)
34339 * The maximum size of the resizing element. (Defaults to 2000)
34342 this.maxSize = 2000;
34345 * Whether to animate the transition to the new size
34348 this.animate = false;
34351 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34354 this.useShim = false;
34359 if(!cfg.existingProxy){
34361 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34363 this.proxy = Roo.get(cfg.existingProxy).dom;
34366 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34369 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34372 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34375 this.dragSpecs = {};
34378 * @private The adapter to use to positon and resize elements
34380 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34381 this.adapter.init(this);
34383 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34385 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34386 this.el.addClass("roo-splitbar-h");
34389 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34390 this.el.addClass("roo-splitbar-v");
34396 * Fires when the splitter is moved (alias for {@link #event-moved})
34397 * @param {Roo.bootstrap.SplitBar} this
34398 * @param {Number} newSize the new width or height
34403 * Fires when the splitter is moved
34404 * @param {Roo.bootstrap.SplitBar} this
34405 * @param {Number} newSize the new width or height
34409 * @event beforeresize
34410 * Fires before the splitter is dragged
34411 * @param {Roo.bootstrap.SplitBar} this
34413 "beforeresize" : true,
34415 "beforeapply" : true
34418 Roo.util.Observable.call(this);
34421 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34422 onStartProxyDrag : function(x, y){
34423 this.fireEvent("beforeresize", this);
34425 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34427 o.enableDisplayMode("block");
34428 // all splitbars share the same overlay
34429 Roo.bootstrap.SplitBar.prototype.overlay = o;
34431 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34432 this.overlay.show();
34433 Roo.get(this.proxy).setDisplayed("block");
34434 var size = this.adapter.getElementSize(this);
34435 this.activeMinSize = this.getMinimumSize();;
34436 this.activeMaxSize = this.getMaximumSize();;
34437 var c1 = size - this.activeMinSize;
34438 var c2 = Math.max(this.activeMaxSize - size, 0);
34439 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34440 this.dd.resetConstraints();
34441 this.dd.setXConstraint(
34442 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34443 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34445 this.dd.setYConstraint(0, 0);
34447 this.dd.resetConstraints();
34448 this.dd.setXConstraint(0, 0);
34449 this.dd.setYConstraint(
34450 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34451 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34454 this.dragSpecs.startSize = size;
34455 this.dragSpecs.startPoint = [x, y];
34456 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34460 * @private Called after the drag operation by the DDProxy
34462 onEndProxyDrag : function(e){
34463 Roo.get(this.proxy).setDisplayed(false);
34464 var endPoint = Roo.lib.Event.getXY(e);
34466 this.overlay.hide();
34469 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34470 newSize = this.dragSpecs.startSize +
34471 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34472 endPoint[0] - this.dragSpecs.startPoint[0] :
34473 this.dragSpecs.startPoint[0] - endPoint[0]
34476 newSize = this.dragSpecs.startSize +
34477 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34478 endPoint[1] - this.dragSpecs.startPoint[1] :
34479 this.dragSpecs.startPoint[1] - endPoint[1]
34482 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34483 if(newSize != this.dragSpecs.startSize){
34484 if(this.fireEvent('beforeapply', this, newSize) !== false){
34485 this.adapter.setElementSize(this, newSize);
34486 this.fireEvent("moved", this, newSize);
34487 this.fireEvent("resize", this, newSize);
34493 * Get the adapter this SplitBar uses
34494 * @return The adapter object
34496 getAdapter : function(){
34497 return this.adapter;
34501 * Set the adapter this SplitBar uses
34502 * @param {Object} adapter A SplitBar adapter object
34504 setAdapter : function(adapter){
34505 this.adapter = adapter;
34506 this.adapter.init(this);
34510 * Gets the minimum size for the resizing element
34511 * @return {Number} The minimum size
34513 getMinimumSize : function(){
34514 return this.minSize;
34518 * Sets the minimum size for the resizing element
34519 * @param {Number} minSize The minimum size
34521 setMinimumSize : function(minSize){
34522 this.minSize = minSize;
34526 * Gets the maximum size for the resizing element
34527 * @return {Number} The maximum size
34529 getMaximumSize : function(){
34530 return this.maxSize;
34534 * Sets the maximum size for the resizing element
34535 * @param {Number} maxSize The maximum size
34537 setMaximumSize : function(maxSize){
34538 this.maxSize = maxSize;
34542 * Sets the initialize size for the resizing element
34543 * @param {Number} size The initial size
34545 setCurrentSize : function(size){
34546 var oldAnimate = this.animate;
34547 this.animate = false;
34548 this.adapter.setElementSize(this, size);
34549 this.animate = oldAnimate;
34553 * Destroy this splitbar.
34554 * @param {Boolean} removeEl True to remove the element
34556 destroy : function(removeEl){
34558 this.shim.remove();
34561 this.proxy.parentNode.removeChild(this.proxy);
34569 * @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.
34571 Roo.bootstrap.SplitBar.createProxy = function(dir){
34572 var proxy = new Roo.Element(document.createElement("div"));
34573 proxy.unselectable();
34574 var cls = 'roo-splitbar-proxy';
34575 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34576 document.body.appendChild(proxy.dom);
34581 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34582 * Default Adapter. It assumes the splitter and resizing element are not positioned
34583 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34585 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34588 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34589 // do nothing for now
34590 init : function(s){
34594 * Called before drag operations to get the current size of the resizing element.
34595 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34597 getElementSize : function(s){
34598 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34599 return s.resizingEl.getWidth();
34601 return s.resizingEl.getHeight();
34606 * Called after drag operations to set the size of the resizing element.
34607 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34608 * @param {Number} newSize The new size to set
34609 * @param {Function} onComplete A function to be invoked when resizing is complete
34611 setElementSize : function(s, newSize, onComplete){
34612 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34614 s.resizingEl.setWidth(newSize);
34616 onComplete(s, newSize);
34619 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34624 s.resizingEl.setHeight(newSize);
34626 onComplete(s, newSize);
34629 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34636 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34637 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34638 * Adapter that moves the splitter element to align with the resized sizing element.
34639 * Used with an absolute positioned SplitBar.
34640 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34641 * document.body, make sure you assign an id to the body element.
34643 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34644 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34645 this.container = Roo.get(container);
34648 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34649 init : function(s){
34650 this.basic.init(s);
34653 getElementSize : function(s){
34654 return this.basic.getElementSize(s);
34657 setElementSize : function(s, newSize, onComplete){
34658 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34661 moveSplitter : function(s){
34662 var yes = Roo.bootstrap.SplitBar;
34663 switch(s.placement){
34665 s.el.setX(s.resizingEl.getRight());
34668 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34671 s.el.setY(s.resizingEl.getBottom());
34674 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34681 * Orientation constant - Create a vertical SplitBar
34685 Roo.bootstrap.SplitBar.VERTICAL = 1;
34688 * Orientation constant - Create a horizontal SplitBar
34692 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34695 * Placement constant - The resizing element is to the left of the splitter element
34699 Roo.bootstrap.SplitBar.LEFT = 1;
34702 * Placement constant - The resizing element is to the right of the splitter element
34706 Roo.bootstrap.SplitBar.RIGHT = 2;
34709 * Placement constant - The resizing element is positioned above the splitter element
34713 Roo.bootstrap.SplitBar.TOP = 3;
34716 * Placement constant - The resizing element is positioned under splitter element
34720 Roo.bootstrap.SplitBar.BOTTOM = 4;
34721 Roo.namespace("Roo.bootstrap.layout");/*
34723 * Ext JS Library 1.1.1
34724 * Copyright(c) 2006-2007, Ext JS, LLC.
34726 * Originally Released Under LGPL - original licence link has changed is not relivant.
34729 * <script type="text/javascript">
34733 * @class Roo.bootstrap.layout.Manager
34734 * @extends Roo.bootstrap.Component
34735 * Base class for layout managers.
34737 Roo.bootstrap.layout.Manager = function(config)
34739 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34745 /** false to disable window resize monitoring @type Boolean */
34746 this.monitorWindowResize = true;
34751 * Fires when a layout is performed.
34752 * @param {Roo.LayoutManager} this
34756 * @event regionresized
34757 * Fires when the user resizes a region.
34758 * @param {Roo.LayoutRegion} region The resized region
34759 * @param {Number} newSize The new size (width for east/west, height for north/south)
34761 "regionresized" : true,
34763 * @event regioncollapsed
34764 * Fires when a region is collapsed.
34765 * @param {Roo.LayoutRegion} region The collapsed region
34767 "regioncollapsed" : true,
34769 * @event regionexpanded
34770 * Fires when a region is expanded.
34771 * @param {Roo.LayoutRegion} region The expanded region
34773 "regionexpanded" : true
34775 this.updating = false;
34778 this.el = Roo.get(config.el);
34784 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34789 monitorWindowResize : true,
34795 onRender : function(ct, position)
34798 this.el = Roo.get(ct);
34801 //this.fireEvent('render',this);
34805 initEvents: function()
34809 // ie scrollbar fix
34810 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34811 document.body.scroll = "no";
34812 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34813 this.el.position('relative');
34815 this.id = this.el.id;
34816 this.el.addClass("roo-layout-container");
34817 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34818 if(this.el.dom != document.body ) {
34819 this.el.on('resize', this.layout,this);
34820 this.el.on('show', this.layout,this);
34826 * Returns true if this layout is currently being updated
34827 * @return {Boolean}
34829 isUpdating : function(){
34830 return this.updating;
34834 * Suspend the LayoutManager from doing auto-layouts while
34835 * making multiple add or remove calls
34837 beginUpdate : function(){
34838 this.updating = true;
34842 * Restore auto-layouts and optionally disable the manager from performing a layout
34843 * @param {Boolean} noLayout true to disable a layout update
34845 endUpdate : function(noLayout){
34846 this.updating = false;
34852 layout: function(){
34856 onRegionResized : function(region, newSize){
34857 this.fireEvent("regionresized", region, newSize);
34861 onRegionCollapsed : function(region){
34862 this.fireEvent("regioncollapsed", region);
34865 onRegionExpanded : function(region){
34866 this.fireEvent("regionexpanded", region);
34870 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34871 * performs box-model adjustments.
34872 * @return {Object} The size as an object {width: (the width), height: (the height)}
34874 getViewSize : function()
34877 if(this.el.dom != document.body){
34878 size = this.el.getSize();
34880 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34882 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34883 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34888 * Returns the Element this layout is bound to.
34889 * @return {Roo.Element}
34891 getEl : function(){
34896 * Returns the specified region.
34897 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34898 * @return {Roo.LayoutRegion}
34900 getRegion : function(target){
34901 return this.regions[target.toLowerCase()];
34904 onWindowResize : function(){
34905 if(this.monitorWindowResize){
34912 * Ext JS Library 1.1.1
34913 * Copyright(c) 2006-2007, Ext JS, LLC.
34915 * Originally Released Under LGPL - original licence link has changed is not relivant.
34918 * <script type="text/javascript">
34921 * @class Roo.bootstrap.layout.Border
34922 * @extends Roo.bootstrap.layout.Manager
34923 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34924 * please see: examples/bootstrap/nested.html<br><br>
34926 <b>The container the layout is rendered into can be either the body element or any other element.
34927 If it is not the body element, the container needs to either be an absolute positioned element,
34928 or you will need to add "position:relative" to the css of the container. You will also need to specify
34929 the container size if it is not the body element.</b>
34932 * Create a new Border
34933 * @param {Object} config Configuration options
34935 Roo.bootstrap.layout.Border = function(config){
34936 config = config || {};
34937 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34941 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34942 if(config[region]){
34943 config[region].region = region;
34944 this.addRegion(config[region]);
34950 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34952 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34954 * Creates and adds a new region if it doesn't already exist.
34955 * @param {String} target The target region key (north, south, east, west or center).
34956 * @param {Object} config The regions config object
34957 * @return {BorderLayoutRegion} The new region
34959 addRegion : function(config)
34961 if(!this.regions[config.region]){
34962 var r = this.factory(config);
34963 this.bindRegion(r);
34965 return this.regions[config.region];
34969 bindRegion : function(r){
34970 this.regions[r.config.region] = r;
34972 r.on("visibilitychange", this.layout, this);
34973 r.on("paneladded", this.layout, this);
34974 r.on("panelremoved", this.layout, this);
34975 r.on("invalidated", this.layout, this);
34976 r.on("resized", this.onRegionResized, this);
34977 r.on("collapsed", this.onRegionCollapsed, this);
34978 r.on("expanded", this.onRegionExpanded, this);
34982 * Performs a layout update.
34984 layout : function()
34986 if(this.updating) {
34990 // render all the rebions if they have not been done alreayd?
34991 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34992 if(this.regions[region] && !this.regions[region].bodyEl){
34993 this.regions[region].onRender(this.el)
34997 var size = this.getViewSize();
34998 var w = size.width;
34999 var h = size.height;
35004 //var x = 0, y = 0;
35006 var rs = this.regions;
35007 var north = rs["north"];
35008 var south = rs["south"];
35009 var west = rs["west"];
35010 var east = rs["east"];
35011 var center = rs["center"];
35012 //if(this.hideOnLayout){ // not supported anymore
35013 //c.el.setStyle("display", "none");
35015 if(north && north.isVisible()){
35016 var b = north.getBox();
35017 var m = north.getMargins();
35018 b.width = w - (m.left+m.right);
35021 centerY = b.height + b.y + m.bottom;
35022 centerH -= centerY;
35023 north.updateBox(this.safeBox(b));
35025 if(south && south.isVisible()){
35026 var b = south.getBox();
35027 var m = south.getMargins();
35028 b.width = w - (m.left+m.right);
35030 var totalHeight = (b.height + m.top + m.bottom);
35031 b.y = h - totalHeight + m.top;
35032 centerH -= totalHeight;
35033 south.updateBox(this.safeBox(b));
35035 if(west && west.isVisible()){
35036 var b = west.getBox();
35037 var m = west.getMargins();
35038 b.height = centerH - (m.top+m.bottom);
35040 b.y = centerY + m.top;
35041 var totalWidth = (b.width + m.left + m.right);
35042 centerX += totalWidth;
35043 centerW -= totalWidth;
35044 west.updateBox(this.safeBox(b));
35046 if(east && east.isVisible()){
35047 var b = east.getBox();
35048 var m = east.getMargins();
35049 b.height = centerH - (m.top+m.bottom);
35050 var totalWidth = (b.width + m.left + m.right);
35051 b.x = w - totalWidth + m.left;
35052 b.y = centerY + m.top;
35053 centerW -= totalWidth;
35054 east.updateBox(this.safeBox(b));
35057 var m = center.getMargins();
35059 x: centerX + m.left,
35060 y: centerY + m.top,
35061 width: centerW - (m.left+m.right),
35062 height: centerH - (m.top+m.bottom)
35064 //if(this.hideOnLayout){
35065 //center.el.setStyle("display", "block");
35067 center.updateBox(this.safeBox(centerBox));
35070 this.fireEvent("layout", this);
35074 safeBox : function(box){
35075 box.width = Math.max(0, box.width);
35076 box.height = Math.max(0, box.height);
35081 * Adds a ContentPanel (or subclass) to this layout.
35082 * @param {String} target The target region key (north, south, east, west or center).
35083 * @param {Roo.ContentPanel} panel The panel to add
35084 * @return {Roo.ContentPanel} The added panel
35086 add : function(target, panel){
35088 target = target.toLowerCase();
35089 return this.regions[target].add(panel);
35093 * Remove a ContentPanel (or subclass) to this layout.
35094 * @param {String} target The target region key (north, south, east, west or center).
35095 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35096 * @return {Roo.ContentPanel} The removed panel
35098 remove : function(target, panel){
35099 target = target.toLowerCase();
35100 return this.regions[target].remove(panel);
35104 * Searches all regions for a panel with the specified id
35105 * @param {String} panelId
35106 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35108 findPanel : function(panelId){
35109 var rs = this.regions;
35110 for(var target in rs){
35111 if(typeof rs[target] != "function"){
35112 var p = rs[target].getPanel(panelId);
35122 * Searches all regions for a panel with the specified id and activates (shows) it.
35123 * @param {String/ContentPanel} panelId The panels id or the panel itself
35124 * @return {Roo.ContentPanel} The shown panel or null
35126 showPanel : function(panelId) {
35127 var rs = this.regions;
35128 for(var target in rs){
35129 var r = rs[target];
35130 if(typeof r != "function"){
35131 if(r.hasPanel(panelId)){
35132 return r.showPanel(panelId);
35140 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35141 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35144 restoreState : function(provider){
35146 provider = Roo.state.Manager;
35148 var sm = new Roo.LayoutStateManager();
35149 sm.init(this, provider);
35155 * Adds a xtype elements to the layout.
35159 xtype : 'ContentPanel',
35166 xtype : 'NestedLayoutPanel',
35172 items : [ ... list of content panels or nested layout panels.. ]
35176 * @param {Object} cfg Xtype definition of item to add.
35178 addxtype : function(cfg)
35180 // basically accepts a pannel...
35181 // can accept a layout region..!?!?
35182 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35185 // theory? children can only be panels??
35187 //if (!cfg.xtype.match(/Panel$/)) {
35192 if (typeof(cfg.region) == 'undefined') {
35193 Roo.log("Failed to add Panel, region was not set");
35197 var region = cfg.region;
35203 xitems = cfg.items;
35210 case 'Content': // ContentPanel (el, cfg)
35211 case 'Scroll': // ContentPanel (el, cfg)
35213 cfg.autoCreate = true;
35214 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35216 // var el = this.el.createChild();
35217 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35220 this.add(region, ret);
35224 case 'TreePanel': // our new panel!
35225 cfg.el = this.el.createChild();
35226 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35227 this.add(region, ret);
35232 // create a new Layout (which is a Border Layout...
35234 var clayout = cfg.layout;
35235 clayout.el = this.el.createChild();
35236 clayout.items = clayout.items || [];
35240 // replace this exitems with the clayout ones..
35241 xitems = clayout.items;
35243 // force background off if it's in center...
35244 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35245 cfg.background = false;
35247 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35250 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35251 //console.log('adding nested layout panel ' + cfg.toSource());
35252 this.add(region, ret);
35253 nb = {}; /// find first...
35258 // needs grid and region
35260 //var el = this.getRegion(region).el.createChild();
35262 *var el = this.el.createChild();
35263 // create the grid first...
35264 cfg.grid.container = el;
35265 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35268 if (region == 'center' && this.active ) {
35269 cfg.background = false;
35272 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35274 this.add(region, ret);
35276 if (cfg.background) {
35277 // render grid on panel activation (if panel background)
35278 ret.on('activate', function(gp) {
35279 if (!gp.grid.rendered) {
35280 // gp.grid.render(el);
35284 // cfg.grid.render(el);
35290 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35291 // it was the old xcomponent building that caused this before.
35292 // espeically if border is the top element in the tree.
35302 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35304 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35305 this.add(region, ret);
35309 throw "Can not add '" + cfg.xtype + "' to Border";
35315 this.beginUpdate();
35319 Roo.each(xitems, function(i) {
35320 region = nb && i.region ? i.region : false;
35322 var add = ret.addxtype(i);
35325 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35326 if (!i.background) {
35327 abn[region] = nb[region] ;
35334 // make the last non-background panel active..
35335 //if (nb) { Roo.log(abn); }
35338 for(var r in abn) {
35339 region = this.getRegion(r);
35341 // tried using nb[r], but it does not work..
35343 region.showPanel(abn[r]);
35354 factory : function(cfg)
35357 var validRegions = Roo.bootstrap.layout.Border.regions;
35359 var target = cfg.region;
35362 var r = Roo.bootstrap.layout;
35366 return new r.North(cfg);
35368 return new r.South(cfg);
35370 return new r.East(cfg);
35372 return new r.West(cfg);
35374 return new r.Center(cfg);
35376 throw 'Layout region "'+target+'" not supported.';
35383 * Ext JS Library 1.1.1
35384 * Copyright(c) 2006-2007, Ext JS, LLC.
35386 * Originally Released Under LGPL - original licence link has changed is not relivant.
35389 * <script type="text/javascript">
35393 * @class Roo.bootstrap.layout.Basic
35394 * @extends Roo.util.Observable
35395 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35396 * and does not have a titlebar, tabs or any other features. All it does is size and position
35397 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35398 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35399 * @cfg {string} region the region that it inhabits..
35400 * @cfg {bool} skipConfig skip config?
35404 Roo.bootstrap.layout.Basic = function(config){
35406 this.mgr = config.mgr;
35408 this.position = config.region;
35410 var skipConfig = config.skipConfig;
35414 * @scope Roo.BasicLayoutRegion
35418 * @event beforeremove
35419 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35420 * @param {Roo.LayoutRegion} this
35421 * @param {Roo.ContentPanel} panel The panel
35422 * @param {Object} e The cancel event object
35424 "beforeremove" : true,
35426 * @event invalidated
35427 * Fires when the layout for this region is changed.
35428 * @param {Roo.LayoutRegion} this
35430 "invalidated" : true,
35432 * @event visibilitychange
35433 * Fires when this region is shown or hidden
35434 * @param {Roo.LayoutRegion} this
35435 * @param {Boolean} visibility true or false
35437 "visibilitychange" : true,
35439 * @event paneladded
35440 * Fires when a panel is added.
35441 * @param {Roo.LayoutRegion} this
35442 * @param {Roo.ContentPanel} panel The panel
35444 "paneladded" : true,
35446 * @event panelremoved
35447 * Fires when a panel is removed.
35448 * @param {Roo.LayoutRegion} this
35449 * @param {Roo.ContentPanel} panel The panel
35451 "panelremoved" : true,
35453 * @event beforecollapse
35454 * Fires when this region before collapse.
35455 * @param {Roo.LayoutRegion} this
35457 "beforecollapse" : true,
35460 * Fires when this region is collapsed.
35461 * @param {Roo.LayoutRegion} this
35463 "collapsed" : true,
35466 * Fires when this region is expanded.
35467 * @param {Roo.LayoutRegion} this
35472 * Fires when this region is slid into view.
35473 * @param {Roo.LayoutRegion} this
35475 "slideshow" : true,
35478 * Fires when this region slides out of view.
35479 * @param {Roo.LayoutRegion} this
35481 "slidehide" : true,
35483 * @event panelactivated
35484 * Fires when a panel is activated.
35485 * @param {Roo.LayoutRegion} this
35486 * @param {Roo.ContentPanel} panel The activated panel
35488 "panelactivated" : true,
35491 * Fires when the user resizes this region.
35492 * @param {Roo.LayoutRegion} this
35493 * @param {Number} newSize The new size (width for east/west, height for north/south)
35497 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35498 this.panels = new Roo.util.MixedCollection();
35499 this.panels.getKey = this.getPanelId.createDelegate(this);
35501 this.activePanel = null;
35502 // ensure listeners are added...
35504 if (config.listeners || config.events) {
35505 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35506 listeners : config.listeners || {},
35507 events : config.events || {}
35511 if(skipConfig !== true){
35512 this.applyConfig(config);
35516 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35518 getPanelId : function(p){
35522 applyConfig : function(config){
35523 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35524 this.config = config;
35529 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35530 * the width, for horizontal (north, south) the height.
35531 * @param {Number} newSize The new width or height
35533 resizeTo : function(newSize){
35534 var el = this.el ? this.el :
35535 (this.activePanel ? this.activePanel.getEl() : null);
35537 switch(this.position){
35540 el.setWidth(newSize);
35541 this.fireEvent("resized", this, newSize);
35545 el.setHeight(newSize);
35546 this.fireEvent("resized", this, newSize);
35552 getBox : function(){
35553 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35556 getMargins : function(){
35557 return this.margins;
35560 updateBox : function(box){
35562 var el = this.activePanel.getEl();
35563 el.dom.style.left = box.x + "px";
35564 el.dom.style.top = box.y + "px";
35565 this.activePanel.setSize(box.width, box.height);
35569 * Returns the container element for this region.
35570 * @return {Roo.Element}
35572 getEl : function(){
35573 return this.activePanel;
35577 * Returns true if this region is currently visible.
35578 * @return {Boolean}
35580 isVisible : function(){
35581 return this.activePanel ? true : false;
35584 setActivePanel : function(panel){
35585 panel = this.getPanel(panel);
35586 if(this.activePanel && this.activePanel != panel){
35587 this.activePanel.setActiveState(false);
35588 this.activePanel.getEl().setLeftTop(-10000,-10000);
35590 this.activePanel = panel;
35591 panel.setActiveState(true);
35593 panel.setSize(this.box.width, this.box.height);
35595 this.fireEvent("panelactivated", this, panel);
35596 this.fireEvent("invalidated");
35600 * Show the specified panel.
35601 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35602 * @return {Roo.ContentPanel} The shown panel or null
35604 showPanel : function(panel){
35605 panel = this.getPanel(panel);
35607 this.setActivePanel(panel);
35613 * Get the active panel for this region.
35614 * @return {Roo.ContentPanel} The active panel or null
35616 getActivePanel : function(){
35617 return this.activePanel;
35621 * Add the passed ContentPanel(s)
35622 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35623 * @return {Roo.ContentPanel} The panel added (if only one was added)
35625 add : function(panel){
35626 if(arguments.length > 1){
35627 for(var i = 0, len = arguments.length; i < len; i++) {
35628 this.add(arguments[i]);
35632 if(this.hasPanel(panel)){
35633 this.showPanel(panel);
35636 var el = panel.getEl();
35637 if(el.dom.parentNode != this.mgr.el.dom){
35638 this.mgr.el.dom.appendChild(el.dom);
35640 if(panel.setRegion){
35641 panel.setRegion(this);
35643 this.panels.add(panel);
35644 el.setStyle("position", "absolute");
35645 if(!panel.background){
35646 this.setActivePanel(panel);
35647 if(this.config.initialSize && this.panels.getCount()==1){
35648 this.resizeTo(this.config.initialSize);
35651 this.fireEvent("paneladded", this, panel);
35656 * Returns true if the panel is in this region.
35657 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35658 * @return {Boolean}
35660 hasPanel : function(panel){
35661 if(typeof panel == "object"){ // must be panel obj
35662 panel = panel.getId();
35664 return this.getPanel(panel) ? true : false;
35668 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35669 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35670 * @param {Boolean} preservePanel Overrides the config preservePanel option
35671 * @return {Roo.ContentPanel} The panel that was removed
35673 remove : function(panel, preservePanel){
35674 panel = this.getPanel(panel);
35679 this.fireEvent("beforeremove", this, panel, e);
35680 if(e.cancel === true){
35683 var panelId = panel.getId();
35684 this.panels.removeKey(panelId);
35689 * Returns the panel specified or null if it's not in this region.
35690 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35691 * @return {Roo.ContentPanel}
35693 getPanel : function(id){
35694 if(typeof id == "object"){ // must be panel obj
35697 return this.panels.get(id);
35701 * Returns this regions position (north/south/east/west/center).
35704 getPosition: function(){
35705 return this.position;
35709 * Ext JS Library 1.1.1
35710 * Copyright(c) 2006-2007, Ext JS, LLC.
35712 * Originally Released Under LGPL - original licence link has changed is not relivant.
35715 * <script type="text/javascript">
35719 * @class Roo.bootstrap.layout.Region
35720 * @extends Roo.bootstrap.layout.Basic
35721 * This class represents a region in a layout manager.
35723 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35724 * @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})
35725 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35726 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35727 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35728 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35729 * @cfg {String} title The title for the region (overrides panel titles)
35730 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35731 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35732 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35733 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35734 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35735 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35736 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35737 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35738 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35739 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35741 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35742 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35743 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35744 * @cfg {Number} width For East/West panels
35745 * @cfg {Number} height For North/South panels
35746 * @cfg {Boolean} split To show the splitter
35747 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35749 * @cfg {string} cls Extra CSS classes to add to region
35751 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35752 * @cfg {string} region the region that it inhabits..
35755 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35756 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35758 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35759 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35760 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35762 Roo.bootstrap.layout.Region = function(config)
35764 this.applyConfig(config);
35766 var mgr = config.mgr;
35767 var pos = config.region;
35768 config.skipConfig = true;
35769 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35772 this.onRender(mgr.el);
35775 this.visible = true;
35776 this.collapsed = false;
35777 this.unrendered_panels = [];
35780 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35782 position: '', // set by wrapper (eg. north/south etc..)
35783 unrendered_panels : null, // unrendered panels.
35784 createBody : function(){
35785 /** This region's body element
35786 * @type Roo.Element */
35787 this.bodyEl = this.el.createChild({
35789 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35793 onRender: function(ctr, pos)
35795 var dh = Roo.DomHelper;
35796 /** This region's container element
35797 * @type Roo.Element */
35798 this.el = dh.append(ctr.dom, {
35800 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35802 /** This region's title element
35803 * @type Roo.Element */
35805 this.titleEl = dh.append(this.el.dom,
35808 unselectable: "on",
35809 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35811 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35812 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35815 this.titleEl.enableDisplayMode();
35816 /** This region's title text element
35817 * @type HTMLElement */
35818 this.titleTextEl = this.titleEl.dom.firstChild;
35819 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35821 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35822 this.closeBtn.enableDisplayMode();
35823 this.closeBtn.on("click", this.closeClicked, this);
35824 this.closeBtn.hide();
35826 this.createBody(this.config);
35827 if(this.config.hideWhenEmpty){
35829 this.on("paneladded", this.validateVisibility, this);
35830 this.on("panelremoved", this.validateVisibility, this);
35832 if(this.autoScroll){
35833 this.bodyEl.setStyle("overflow", "auto");
35835 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35837 //if(c.titlebar !== false){
35838 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35839 this.titleEl.hide();
35841 this.titleEl.show();
35842 if(this.config.title){
35843 this.titleTextEl.innerHTML = this.config.title;
35847 if(this.config.collapsed){
35848 this.collapse(true);
35850 if(this.config.hidden){
35854 if (this.unrendered_panels && this.unrendered_panels.length) {
35855 for (var i =0;i< this.unrendered_panels.length; i++) {
35856 this.add(this.unrendered_panels[i]);
35858 this.unrendered_panels = null;
35864 applyConfig : function(c)
35867 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35868 var dh = Roo.DomHelper;
35869 if(c.titlebar !== false){
35870 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35871 this.collapseBtn.on("click", this.collapse, this);
35872 this.collapseBtn.enableDisplayMode();
35874 if(c.showPin === true || this.showPin){
35875 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35876 this.stickBtn.enableDisplayMode();
35877 this.stickBtn.on("click", this.expand, this);
35878 this.stickBtn.hide();
35883 /** This region's collapsed element
35884 * @type Roo.Element */
35887 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35888 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35891 if(c.floatable !== false){
35892 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35893 this.collapsedEl.on("click", this.collapseClick, this);
35896 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35897 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35898 id: "message", unselectable: "on", style:{"float":"left"}});
35899 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35901 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35902 this.expandBtn.on("click", this.expand, this);
35906 if(this.collapseBtn){
35907 this.collapseBtn.setVisible(c.collapsible == true);
35910 this.cmargins = c.cmargins || this.cmargins ||
35911 (this.position == "west" || this.position == "east" ?
35912 {top: 0, left: 2, right:2, bottom: 0} :
35913 {top: 2, left: 0, right:0, bottom: 2});
35915 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35918 this.bottomTabs = c.tabPosition != "top";
35920 this.autoScroll = c.autoScroll || false;
35925 this.duration = c.duration || .30;
35926 this.slideDuration = c.slideDuration || .45;
35931 * Returns true if this region is currently visible.
35932 * @return {Boolean}
35934 isVisible : function(){
35935 return this.visible;
35939 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35940 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35942 //setCollapsedTitle : function(title){
35943 // title = title || " ";
35944 // if(this.collapsedTitleTextEl){
35945 // this.collapsedTitleTextEl.innerHTML = title;
35949 getBox : function(){
35951 // if(!this.collapsed){
35952 b = this.el.getBox(false, true);
35954 // b = this.collapsedEl.getBox(false, true);
35959 getMargins : function(){
35960 return this.margins;
35961 //return this.collapsed ? this.cmargins : this.margins;
35964 highlight : function(){
35965 this.el.addClass("x-layout-panel-dragover");
35968 unhighlight : function(){
35969 this.el.removeClass("x-layout-panel-dragover");
35972 updateBox : function(box)
35974 if (!this.bodyEl) {
35975 return; // not rendered yet..
35979 if(!this.collapsed){
35980 this.el.dom.style.left = box.x + "px";
35981 this.el.dom.style.top = box.y + "px";
35982 this.updateBody(box.width, box.height);
35984 this.collapsedEl.dom.style.left = box.x + "px";
35985 this.collapsedEl.dom.style.top = box.y + "px";
35986 this.collapsedEl.setSize(box.width, box.height);
35989 this.tabs.autoSizeTabs();
35993 updateBody : function(w, h)
35996 this.el.setWidth(w);
35997 w -= this.el.getBorderWidth("rl");
35998 if(this.config.adjustments){
35999 w += this.config.adjustments[0];
36002 if(h !== null && h > 0){
36003 this.el.setHeight(h);
36004 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36005 h -= this.el.getBorderWidth("tb");
36006 if(this.config.adjustments){
36007 h += this.config.adjustments[1];
36009 this.bodyEl.setHeight(h);
36011 h = this.tabs.syncHeight(h);
36014 if(this.panelSize){
36015 w = w !== null ? w : this.panelSize.width;
36016 h = h !== null ? h : this.panelSize.height;
36018 if(this.activePanel){
36019 var el = this.activePanel.getEl();
36020 w = w !== null ? w : el.getWidth();
36021 h = h !== null ? h : el.getHeight();
36022 this.panelSize = {width: w, height: h};
36023 this.activePanel.setSize(w, h);
36025 if(Roo.isIE && this.tabs){
36026 this.tabs.el.repaint();
36031 * Returns the container element for this region.
36032 * @return {Roo.Element}
36034 getEl : function(){
36039 * Hides this region.
36042 //if(!this.collapsed){
36043 this.el.dom.style.left = "-2000px";
36046 // this.collapsedEl.dom.style.left = "-2000px";
36047 // this.collapsedEl.hide();
36049 this.visible = false;
36050 this.fireEvent("visibilitychange", this, false);
36054 * Shows this region if it was previously hidden.
36057 //if(!this.collapsed){
36060 // this.collapsedEl.show();
36062 this.visible = true;
36063 this.fireEvent("visibilitychange", this, true);
36066 closeClicked : function(){
36067 if(this.activePanel){
36068 this.remove(this.activePanel);
36072 collapseClick : function(e){
36074 e.stopPropagation();
36077 e.stopPropagation();
36083 * Collapses this region.
36084 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36087 collapse : function(skipAnim, skipCheck = false){
36088 if(this.collapsed) {
36092 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36094 this.collapsed = true;
36096 this.split.el.hide();
36098 if(this.config.animate && skipAnim !== true){
36099 this.fireEvent("invalidated", this);
36100 this.animateCollapse();
36102 this.el.setLocation(-20000,-20000);
36104 this.collapsedEl.show();
36105 this.fireEvent("collapsed", this);
36106 this.fireEvent("invalidated", this);
36112 animateCollapse : function(){
36117 * Expands this region if it was previously collapsed.
36118 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36119 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36122 expand : function(e, skipAnim){
36124 e.stopPropagation();
36126 if(!this.collapsed || this.el.hasActiveFx()) {
36130 this.afterSlideIn();
36133 this.collapsed = false;
36134 if(this.config.animate && skipAnim !== true){
36135 this.animateExpand();
36139 this.split.el.show();
36141 this.collapsedEl.setLocation(-2000,-2000);
36142 this.collapsedEl.hide();
36143 this.fireEvent("invalidated", this);
36144 this.fireEvent("expanded", this);
36148 animateExpand : function(){
36152 initTabs : function()
36154 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36156 var ts = new Roo.bootstrap.panel.Tabs({
36157 el: this.bodyEl.dom,
36158 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36159 disableTooltips: this.config.disableTabTips,
36160 toolbar : this.config.toolbar
36163 if(this.config.hideTabs){
36164 ts.stripWrap.setDisplayed(false);
36167 ts.resizeTabs = this.config.resizeTabs === true;
36168 ts.minTabWidth = this.config.minTabWidth || 40;
36169 ts.maxTabWidth = this.config.maxTabWidth || 250;
36170 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36171 ts.monitorResize = false;
36172 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36173 ts.bodyEl.addClass('roo-layout-tabs-body');
36174 this.panels.each(this.initPanelAsTab, this);
36177 initPanelAsTab : function(panel){
36178 var ti = this.tabs.addTab(
36182 this.config.closeOnTab && panel.isClosable(),
36185 if(panel.tabTip !== undefined){
36186 ti.setTooltip(panel.tabTip);
36188 ti.on("activate", function(){
36189 this.setActivePanel(panel);
36192 if(this.config.closeOnTab){
36193 ti.on("beforeclose", function(t, e){
36195 this.remove(panel);
36199 panel.tabItem = ti;
36204 updatePanelTitle : function(panel, title)
36206 if(this.activePanel == panel){
36207 this.updateTitle(title);
36210 var ti = this.tabs.getTab(panel.getEl().id);
36212 if(panel.tabTip !== undefined){
36213 ti.setTooltip(panel.tabTip);
36218 updateTitle : function(title){
36219 if(this.titleTextEl && !this.config.title){
36220 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36224 setActivePanel : function(panel)
36226 panel = this.getPanel(panel);
36227 if(this.activePanel && this.activePanel != panel){
36228 if(this.activePanel.setActiveState(false) === false){
36232 this.activePanel = panel;
36233 panel.setActiveState(true);
36234 if(this.panelSize){
36235 panel.setSize(this.panelSize.width, this.panelSize.height);
36238 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36240 this.updateTitle(panel.getTitle());
36242 this.fireEvent("invalidated", this);
36244 this.fireEvent("panelactivated", this, panel);
36248 * Shows the specified panel.
36249 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36250 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36252 showPanel : function(panel)
36254 panel = this.getPanel(panel);
36257 var tab = this.tabs.getTab(panel.getEl().id);
36258 if(tab.isHidden()){
36259 this.tabs.unhideTab(tab.id);
36263 this.setActivePanel(panel);
36270 * Get the active panel for this region.
36271 * @return {Roo.ContentPanel} The active panel or null
36273 getActivePanel : function(){
36274 return this.activePanel;
36277 validateVisibility : function(){
36278 if(this.panels.getCount() < 1){
36279 this.updateTitle(" ");
36280 this.closeBtn.hide();
36283 if(!this.isVisible()){
36290 * Adds the passed ContentPanel(s) to this region.
36291 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36292 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36294 add : function(panel)
36296 if(arguments.length > 1){
36297 for(var i = 0, len = arguments.length; i < len; i++) {
36298 this.add(arguments[i]);
36303 // if we have not been rendered yet, then we can not really do much of this..
36304 if (!this.bodyEl) {
36305 this.unrendered_panels.push(panel);
36312 if(this.hasPanel(panel)){
36313 this.showPanel(panel);
36316 panel.setRegion(this);
36317 this.panels.add(panel);
36318 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36319 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36320 // and hide them... ???
36321 this.bodyEl.dom.appendChild(panel.getEl().dom);
36322 if(panel.background !== true){
36323 this.setActivePanel(panel);
36325 this.fireEvent("paneladded", this, panel);
36332 this.initPanelAsTab(panel);
36336 if(panel.background !== true){
36337 this.tabs.activate(panel.getEl().id);
36339 this.fireEvent("paneladded", this, panel);
36344 * Hides the tab for the specified panel.
36345 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36347 hidePanel : function(panel){
36348 if(this.tabs && (panel = this.getPanel(panel))){
36349 this.tabs.hideTab(panel.getEl().id);
36354 * Unhides the tab for a previously hidden panel.
36355 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36357 unhidePanel : function(panel){
36358 if(this.tabs && (panel = this.getPanel(panel))){
36359 this.tabs.unhideTab(panel.getEl().id);
36363 clearPanels : function(){
36364 while(this.panels.getCount() > 0){
36365 this.remove(this.panels.first());
36370 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36371 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36372 * @param {Boolean} preservePanel Overrides the config preservePanel option
36373 * @return {Roo.ContentPanel} The panel that was removed
36375 remove : function(panel, preservePanel)
36377 panel = this.getPanel(panel);
36382 this.fireEvent("beforeremove", this, panel, e);
36383 if(e.cancel === true){
36386 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36387 var panelId = panel.getId();
36388 this.panels.removeKey(panelId);
36390 document.body.appendChild(panel.getEl().dom);
36393 this.tabs.removeTab(panel.getEl().id);
36394 }else if (!preservePanel){
36395 this.bodyEl.dom.removeChild(panel.getEl().dom);
36397 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36398 var p = this.panels.first();
36399 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36400 tempEl.appendChild(p.getEl().dom);
36401 this.bodyEl.update("");
36402 this.bodyEl.dom.appendChild(p.getEl().dom);
36404 this.updateTitle(p.getTitle());
36406 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36407 this.setActivePanel(p);
36409 panel.setRegion(null);
36410 if(this.activePanel == panel){
36411 this.activePanel = null;
36413 if(this.config.autoDestroy !== false && preservePanel !== true){
36414 try{panel.destroy();}catch(e){}
36416 this.fireEvent("panelremoved", this, panel);
36421 * Returns the TabPanel component used by this region
36422 * @return {Roo.TabPanel}
36424 getTabs : function(){
36428 createTool : function(parentEl, className){
36429 var btn = Roo.DomHelper.append(parentEl, {
36431 cls: "x-layout-tools-button",
36434 cls: "roo-layout-tools-button-inner " + className,
36438 btn.addClassOnOver("roo-layout-tools-button-over");
36443 * Ext JS Library 1.1.1
36444 * Copyright(c) 2006-2007, Ext JS, LLC.
36446 * Originally Released Under LGPL - original licence link has changed is not relivant.
36449 * <script type="text/javascript">
36455 * @class Roo.SplitLayoutRegion
36456 * @extends Roo.LayoutRegion
36457 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36459 Roo.bootstrap.layout.Split = function(config){
36460 this.cursor = config.cursor;
36461 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36464 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36466 splitTip : "Drag to resize.",
36467 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36468 useSplitTips : false,
36470 applyConfig : function(config){
36471 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36474 onRender : function(ctr,pos) {
36476 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36477 if(!this.config.split){
36482 var splitEl = Roo.DomHelper.append(ctr.dom, {
36484 id: this.el.id + "-split",
36485 cls: "roo-layout-split roo-layout-split-"+this.position,
36488 /** The SplitBar for this region
36489 * @type Roo.SplitBar */
36490 // does not exist yet...
36491 Roo.log([this.position, this.orientation]);
36493 this.split = new Roo.bootstrap.SplitBar({
36494 dragElement : splitEl,
36495 resizingElement: this.el,
36496 orientation : this.orientation
36499 this.split.on("moved", this.onSplitMove, this);
36500 this.split.useShim = this.config.useShim === true;
36501 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36502 if(this.useSplitTips){
36503 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36505 //if(config.collapsible){
36506 // this.split.el.on("dblclick", this.collapse, this);
36509 if(typeof this.config.minSize != "undefined"){
36510 this.split.minSize = this.config.minSize;
36512 if(typeof this.config.maxSize != "undefined"){
36513 this.split.maxSize = this.config.maxSize;
36515 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36516 this.hideSplitter();
36521 getHMaxSize : function(){
36522 var cmax = this.config.maxSize || 10000;
36523 var center = this.mgr.getRegion("center");
36524 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36527 getVMaxSize : function(){
36528 var cmax = this.config.maxSize || 10000;
36529 var center = this.mgr.getRegion("center");
36530 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36533 onSplitMove : function(split, newSize){
36534 this.fireEvent("resized", this, newSize);
36538 * Returns the {@link Roo.SplitBar} for this region.
36539 * @return {Roo.SplitBar}
36541 getSplitBar : function(){
36546 this.hideSplitter();
36547 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36550 hideSplitter : function(){
36552 this.split.el.setLocation(-2000,-2000);
36553 this.split.el.hide();
36559 this.split.el.show();
36561 Roo.bootstrap.layout.Split.superclass.show.call(this);
36564 beforeSlide: function(){
36565 if(Roo.isGecko){// firefox overflow auto bug workaround
36566 this.bodyEl.clip();
36568 this.tabs.bodyEl.clip();
36570 if(this.activePanel){
36571 this.activePanel.getEl().clip();
36573 if(this.activePanel.beforeSlide){
36574 this.activePanel.beforeSlide();
36580 afterSlide : function(){
36581 if(Roo.isGecko){// firefox overflow auto bug workaround
36582 this.bodyEl.unclip();
36584 this.tabs.bodyEl.unclip();
36586 if(this.activePanel){
36587 this.activePanel.getEl().unclip();
36588 if(this.activePanel.afterSlide){
36589 this.activePanel.afterSlide();
36595 initAutoHide : function(){
36596 if(this.autoHide !== false){
36597 if(!this.autoHideHd){
36598 var st = new Roo.util.DelayedTask(this.slideIn, this);
36599 this.autoHideHd = {
36600 "mouseout": function(e){
36601 if(!e.within(this.el, true)){
36605 "mouseover" : function(e){
36611 this.el.on(this.autoHideHd);
36615 clearAutoHide : function(){
36616 if(this.autoHide !== false){
36617 this.el.un("mouseout", this.autoHideHd.mouseout);
36618 this.el.un("mouseover", this.autoHideHd.mouseover);
36622 clearMonitor : function(){
36623 Roo.get(document).un("click", this.slideInIf, this);
36626 // these names are backwards but not changed for compat
36627 slideOut : function(){
36628 if(this.isSlid || this.el.hasActiveFx()){
36631 this.isSlid = true;
36632 if(this.collapseBtn){
36633 this.collapseBtn.hide();
36635 this.closeBtnState = this.closeBtn.getStyle('display');
36636 this.closeBtn.hide();
36638 this.stickBtn.show();
36641 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36642 this.beforeSlide();
36643 this.el.setStyle("z-index", 10001);
36644 this.el.slideIn(this.getSlideAnchor(), {
36645 callback: function(){
36647 this.initAutoHide();
36648 Roo.get(document).on("click", this.slideInIf, this);
36649 this.fireEvent("slideshow", this);
36656 afterSlideIn : function(){
36657 this.clearAutoHide();
36658 this.isSlid = false;
36659 this.clearMonitor();
36660 this.el.setStyle("z-index", "");
36661 if(this.collapseBtn){
36662 this.collapseBtn.show();
36664 this.closeBtn.setStyle('display', this.closeBtnState);
36666 this.stickBtn.hide();
36668 this.fireEvent("slidehide", this);
36671 slideIn : function(cb){
36672 if(!this.isSlid || this.el.hasActiveFx()){
36676 this.isSlid = false;
36677 this.beforeSlide();
36678 this.el.slideOut(this.getSlideAnchor(), {
36679 callback: function(){
36680 this.el.setLeftTop(-10000, -10000);
36682 this.afterSlideIn();
36690 slideInIf : function(e){
36691 if(!e.within(this.el)){
36696 animateCollapse : function(){
36697 this.beforeSlide();
36698 this.el.setStyle("z-index", 20000);
36699 var anchor = this.getSlideAnchor();
36700 this.el.slideOut(anchor, {
36701 callback : function(){
36702 this.el.setStyle("z-index", "");
36703 this.collapsedEl.slideIn(anchor, {duration:.3});
36705 this.el.setLocation(-10000,-10000);
36707 this.fireEvent("collapsed", this);
36714 animateExpand : function(){
36715 this.beforeSlide();
36716 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36717 this.el.setStyle("z-index", 20000);
36718 this.collapsedEl.hide({
36721 this.el.slideIn(this.getSlideAnchor(), {
36722 callback : function(){
36723 this.el.setStyle("z-index", "");
36726 this.split.el.show();
36728 this.fireEvent("invalidated", this);
36729 this.fireEvent("expanded", this);
36757 getAnchor : function(){
36758 return this.anchors[this.position];
36761 getCollapseAnchor : function(){
36762 return this.canchors[this.position];
36765 getSlideAnchor : function(){
36766 return this.sanchors[this.position];
36769 getAlignAdj : function(){
36770 var cm = this.cmargins;
36771 switch(this.position){
36787 getExpandAdj : function(){
36788 var c = this.collapsedEl, cm = this.cmargins;
36789 switch(this.position){
36791 return [-(cm.right+c.getWidth()+cm.left), 0];
36794 return [cm.right+c.getWidth()+cm.left, 0];
36797 return [0, -(cm.top+cm.bottom+c.getHeight())];
36800 return [0, cm.top+cm.bottom+c.getHeight()];
36806 * Ext JS Library 1.1.1
36807 * Copyright(c) 2006-2007, Ext JS, LLC.
36809 * Originally Released Under LGPL - original licence link has changed is not relivant.
36812 * <script type="text/javascript">
36815 * These classes are private internal classes
36817 Roo.bootstrap.layout.Center = function(config){
36818 config.region = "center";
36819 Roo.bootstrap.layout.Region.call(this, config);
36820 this.visible = true;
36821 this.minWidth = config.minWidth || 20;
36822 this.minHeight = config.minHeight || 20;
36825 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36827 // center panel can't be hidden
36831 // center panel can't be hidden
36834 getMinWidth: function(){
36835 return this.minWidth;
36838 getMinHeight: function(){
36839 return this.minHeight;
36852 Roo.bootstrap.layout.North = function(config)
36854 config.region = 'north';
36855 config.cursor = 'n-resize';
36857 Roo.bootstrap.layout.Split.call(this, config);
36861 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36862 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36863 this.split.el.addClass("roo-layout-split-v");
36865 var size = config.initialSize || config.height;
36866 if(typeof size != "undefined"){
36867 this.el.setHeight(size);
36870 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36872 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36876 getBox : function(){
36877 if(this.collapsed){
36878 return this.collapsedEl.getBox();
36880 var box = this.el.getBox();
36882 box.height += this.split.el.getHeight();
36887 updateBox : function(box){
36888 if(this.split && !this.collapsed){
36889 box.height -= this.split.el.getHeight();
36890 this.split.el.setLeft(box.x);
36891 this.split.el.setTop(box.y+box.height);
36892 this.split.el.setWidth(box.width);
36894 if(this.collapsed){
36895 this.updateBody(box.width, null);
36897 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36905 Roo.bootstrap.layout.South = function(config){
36906 config.region = 'south';
36907 config.cursor = 's-resize';
36908 Roo.bootstrap.layout.Split.call(this, config);
36910 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36911 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36912 this.split.el.addClass("roo-layout-split-v");
36914 var size = config.initialSize || config.height;
36915 if(typeof size != "undefined"){
36916 this.el.setHeight(size);
36920 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36921 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36922 getBox : function(){
36923 if(this.collapsed){
36924 return this.collapsedEl.getBox();
36926 var box = this.el.getBox();
36928 var sh = this.split.el.getHeight();
36935 updateBox : function(box){
36936 if(this.split && !this.collapsed){
36937 var sh = this.split.el.getHeight();
36940 this.split.el.setLeft(box.x);
36941 this.split.el.setTop(box.y-sh);
36942 this.split.el.setWidth(box.width);
36944 if(this.collapsed){
36945 this.updateBody(box.width, null);
36947 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36951 Roo.bootstrap.layout.East = function(config){
36952 config.region = "east";
36953 config.cursor = "e-resize";
36954 Roo.bootstrap.layout.Split.call(this, config);
36956 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36957 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36958 this.split.el.addClass("roo-layout-split-h");
36960 var size = config.initialSize || config.width;
36961 if(typeof size != "undefined"){
36962 this.el.setWidth(size);
36965 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36966 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36967 getBox : function(){
36968 if(this.collapsed){
36969 return this.collapsedEl.getBox();
36971 var box = this.el.getBox();
36973 var sw = this.split.el.getWidth();
36980 updateBox : function(box){
36981 if(this.split && !this.collapsed){
36982 var sw = this.split.el.getWidth();
36984 this.split.el.setLeft(box.x);
36985 this.split.el.setTop(box.y);
36986 this.split.el.setHeight(box.height);
36989 if(this.collapsed){
36990 this.updateBody(null, box.height);
36992 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36996 Roo.bootstrap.layout.West = function(config){
36997 config.region = "west";
36998 config.cursor = "w-resize";
37000 Roo.bootstrap.layout.Split.call(this, config);
37002 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37003 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37004 this.split.el.addClass("roo-layout-split-h");
37008 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37009 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37011 onRender: function(ctr, pos)
37013 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37014 var size = this.config.initialSize || this.config.width;
37015 if(typeof size != "undefined"){
37016 this.el.setWidth(size);
37020 getBox : function(){
37021 if(this.collapsed){
37022 return this.collapsedEl.getBox();
37024 var box = this.el.getBox();
37026 box.width += this.split.el.getWidth();
37031 updateBox : function(box){
37032 if(this.split && !this.collapsed){
37033 var sw = this.split.el.getWidth();
37035 this.split.el.setLeft(box.x+box.width);
37036 this.split.el.setTop(box.y);
37037 this.split.el.setHeight(box.height);
37039 if(this.collapsed){
37040 this.updateBody(null, box.height);
37042 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37045 Roo.namespace("Roo.bootstrap.panel");/*
37047 * Ext JS Library 1.1.1
37048 * Copyright(c) 2006-2007, Ext JS, LLC.
37050 * Originally Released Under LGPL - original licence link has changed is not relivant.
37053 * <script type="text/javascript">
37056 * @class Roo.ContentPanel
37057 * @extends Roo.util.Observable
37058 * A basic ContentPanel element.
37059 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37060 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37061 * @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
37062 * @cfg {Boolean} closable True if the panel can be closed/removed
37063 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37064 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37065 * @cfg {Toolbar} toolbar A toolbar for this panel
37066 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37067 * @cfg {String} title The title for this panel
37068 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37069 * @cfg {String} url Calls {@link #setUrl} with this value
37070 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37071 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37072 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37073 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37074 * @cfg {Boolean} badges render the badges
37077 * Create a new ContentPanel.
37078 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37079 * @param {String/Object} config A string to set only the title or a config object
37080 * @param {String} content (optional) Set the HTML content for this panel
37081 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37083 Roo.bootstrap.panel.Content = function( config){
37085 this.tpl = config.tpl || false;
37087 var el = config.el;
37088 var content = config.content;
37090 if(config.autoCreate){ // xtype is available if this is called from factory
37093 this.el = Roo.get(el);
37094 if(!this.el && config && config.autoCreate){
37095 if(typeof config.autoCreate == "object"){
37096 if(!config.autoCreate.id){
37097 config.autoCreate.id = config.id||el;
37099 this.el = Roo.DomHelper.append(document.body,
37100 config.autoCreate, true);
37102 var elcfg = { tag: "div",
37103 cls: "roo-layout-inactive-content",
37107 elcfg.html = config.html;
37111 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37114 this.closable = false;
37115 this.loaded = false;
37116 this.active = false;
37119 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37121 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37123 this.wrapEl = this.el; //this.el.wrap();
37125 if (config.toolbar.items) {
37126 ti = config.toolbar.items ;
37127 delete config.toolbar.items ;
37131 this.toolbar.render(this.wrapEl, 'before');
37132 for(var i =0;i < ti.length;i++) {
37133 // Roo.log(['add child', items[i]]);
37134 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37136 this.toolbar.items = nitems;
37137 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37138 delete config.toolbar;
37142 // xtype created footer. - not sure if will work as we normally have to render first..
37143 if (this.footer && !this.footer.el && this.footer.xtype) {
37144 if (!this.wrapEl) {
37145 this.wrapEl = this.el.wrap();
37148 this.footer.container = this.wrapEl.createChild();
37150 this.footer = Roo.factory(this.footer, Roo);
37155 if(typeof config == "string"){
37156 this.title = config;
37158 Roo.apply(this, config);
37162 this.resizeEl = Roo.get(this.resizeEl, true);
37164 this.resizeEl = this.el;
37166 // handle view.xtype
37174 * Fires when this panel is activated.
37175 * @param {Roo.ContentPanel} this
37179 * @event deactivate
37180 * Fires when this panel is activated.
37181 * @param {Roo.ContentPanel} this
37183 "deactivate" : true,
37187 * Fires when this panel is resized if fitToFrame is true.
37188 * @param {Roo.ContentPanel} this
37189 * @param {Number} width The width after any component adjustments
37190 * @param {Number} height The height after any component adjustments
37196 * Fires when this tab is created
37197 * @param {Roo.ContentPanel} this
37208 if(this.autoScroll){
37209 this.resizeEl.setStyle("overflow", "auto");
37211 // fix randome scrolling
37212 //this.el.on('scroll', function() {
37213 // Roo.log('fix random scolling');
37214 // this.scrollTo('top',0);
37217 content = content || this.content;
37219 this.setContent(content);
37221 if(config && config.url){
37222 this.setUrl(this.url, this.params, this.loadOnce);
37227 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37229 if (this.view && typeof(this.view.xtype) != 'undefined') {
37230 this.view.el = this.el.appendChild(document.createElement("div"));
37231 this.view = Roo.factory(this.view);
37232 this.view.render && this.view.render(false, '');
37236 this.fireEvent('render', this);
37239 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37243 setRegion : function(region){
37244 this.region = region;
37245 this.setActiveClass(region && !this.background);
37249 setActiveClass: function(state)
37252 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37253 this.el.setStyle('position','relative');
37255 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37256 this.el.setStyle('position', 'absolute');
37261 * Returns the toolbar for this Panel if one was configured.
37262 * @return {Roo.Toolbar}
37264 getToolbar : function(){
37265 return this.toolbar;
37268 setActiveState : function(active)
37270 this.active = active;
37271 this.setActiveClass(active);
37273 if(this.fireEvent("deactivate", this) === false){
37278 this.fireEvent("activate", this);
37282 * Updates this panel's element
37283 * @param {String} content The new content
37284 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37286 setContent : function(content, loadScripts){
37287 this.el.update(content, loadScripts);
37290 ignoreResize : function(w, h){
37291 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37294 this.lastSize = {width: w, height: h};
37299 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37300 * @return {Roo.UpdateManager} The UpdateManager
37302 getUpdateManager : function(){
37303 return this.el.getUpdateManager();
37306 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37307 * @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:
37310 url: "your-url.php",
37311 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37312 callback: yourFunction,
37313 scope: yourObject, //(optional scope)
37316 text: "Loading...",
37321 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37322 * 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.
37323 * @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}
37324 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37325 * @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.
37326 * @return {Roo.ContentPanel} this
37329 var um = this.el.getUpdateManager();
37330 um.update.apply(um, arguments);
37336 * 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.
37337 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37338 * @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)
37339 * @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)
37340 * @return {Roo.UpdateManager} The UpdateManager
37342 setUrl : function(url, params, loadOnce){
37343 if(this.refreshDelegate){
37344 this.removeListener("activate", this.refreshDelegate);
37346 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37347 this.on("activate", this.refreshDelegate);
37348 return this.el.getUpdateManager();
37351 _handleRefresh : function(url, params, loadOnce){
37352 if(!loadOnce || !this.loaded){
37353 var updater = this.el.getUpdateManager();
37354 updater.update(url, params, this._setLoaded.createDelegate(this));
37358 _setLoaded : function(){
37359 this.loaded = true;
37363 * Returns this panel's id
37366 getId : function(){
37371 * Returns this panel's element - used by regiosn to add.
37372 * @return {Roo.Element}
37374 getEl : function(){
37375 return this.wrapEl || this.el;
37380 adjustForComponents : function(width, height)
37382 //Roo.log('adjustForComponents ');
37383 if(this.resizeEl != this.el){
37384 width -= this.el.getFrameWidth('lr');
37385 height -= this.el.getFrameWidth('tb');
37388 var te = this.toolbar.getEl();
37389 te.setWidth(width);
37390 height -= te.getHeight();
37393 var te = this.footer.getEl();
37394 te.setWidth(width);
37395 height -= te.getHeight();
37399 if(this.adjustments){
37400 width += this.adjustments[0];
37401 height += this.adjustments[1];
37403 return {"width": width, "height": height};
37406 setSize : function(width, height){
37407 if(this.fitToFrame && !this.ignoreResize(width, height)){
37408 if(this.fitContainer && this.resizeEl != this.el){
37409 this.el.setSize(width, height);
37411 var size = this.adjustForComponents(width, height);
37412 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37413 this.fireEvent('resize', this, size.width, size.height);
37418 * Returns this panel's title
37421 getTitle : function(){
37423 if (typeof(this.title) != 'object') {
37428 for (var k in this.title) {
37429 if (!this.title.hasOwnProperty(k)) {
37433 if (k.indexOf('-') >= 0) {
37434 var s = k.split('-');
37435 for (var i = 0; i<s.length; i++) {
37436 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37439 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37446 * Set this panel's title
37447 * @param {String} title
37449 setTitle : function(title){
37450 this.title = title;
37452 this.region.updatePanelTitle(this, title);
37457 * Returns true is this panel was configured to be closable
37458 * @return {Boolean}
37460 isClosable : function(){
37461 return this.closable;
37464 beforeSlide : function(){
37466 this.resizeEl.clip();
37469 afterSlide : function(){
37471 this.resizeEl.unclip();
37475 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37476 * Will fail silently if the {@link #setUrl} method has not been called.
37477 * This does not activate the panel, just updates its content.
37479 refresh : function(){
37480 if(this.refreshDelegate){
37481 this.loaded = false;
37482 this.refreshDelegate();
37487 * Destroys this panel
37489 destroy : function(){
37490 this.el.removeAllListeners();
37491 var tempEl = document.createElement("span");
37492 tempEl.appendChild(this.el.dom);
37493 tempEl.innerHTML = "";
37499 * form - if the content panel contains a form - this is a reference to it.
37500 * @type {Roo.form.Form}
37504 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37505 * This contains a reference to it.
37511 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37521 * @param {Object} cfg Xtype definition of item to add.
37525 getChildContainer: function () {
37526 return this.getEl();
37531 var ret = new Roo.factory(cfg);
37536 if (cfg.xtype.match(/^Form$/)) {
37539 //if (this.footer) {
37540 // el = this.footer.container.insertSibling(false, 'before');
37542 el = this.el.createChild();
37545 this.form = new Roo.form.Form(cfg);
37548 if ( this.form.allItems.length) {
37549 this.form.render(el.dom);
37553 // should only have one of theses..
37554 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37555 // views.. should not be just added - used named prop 'view''
37557 cfg.el = this.el.appendChild(document.createElement("div"));
37560 var ret = new Roo.factory(cfg);
37562 ret.render && ret.render(false, ''); // render blank..
37572 * @class Roo.bootstrap.panel.Grid
37573 * @extends Roo.bootstrap.panel.Content
37575 * Create a new GridPanel.
37576 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37577 * @param {Object} config A the config object
37583 Roo.bootstrap.panel.Grid = function(config)
37587 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37588 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37590 config.el = this.wrapper;
37591 //this.el = this.wrapper;
37593 if (config.container) {
37594 // ctor'ed from a Border/panel.grid
37597 this.wrapper.setStyle("overflow", "hidden");
37598 this.wrapper.addClass('roo-grid-container');
37603 if(config.toolbar){
37604 var tool_el = this.wrapper.createChild();
37605 this.toolbar = Roo.factory(config.toolbar);
37607 if (config.toolbar.items) {
37608 ti = config.toolbar.items ;
37609 delete config.toolbar.items ;
37613 this.toolbar.render(tool_el);
37614 for(var i =0;i < ti.length;i++) {
37615 // Roo.log(['add child', items[i]]);
37616 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37618 this.toolbar.items = nitems;
37620 delete config.toolbar;
37623 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37624 config.grid.scrollBody = true;;
37625 config.grid.monitorWindowResize = false; // turn off autosizing
37626 config.grid.autoHeight = false;
37627 config.grid.autoWidth = false;
37629 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37631 if (config.background) {
37632 // render grid on panel activation (if panel background)
37633 this.on('activate', function(gp) {
37634 if (!gp.grid.rendered) {
37635 gp.grid.render(this.wrapper);
37636 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37641 this.grid.render(this.wrapper);
37642 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37645 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37646 // ??? needed ??? config.el = this.wrapper;
37651 // xtype created footer. - not sure if will work as we normally have to render first..
37652 if (this.footer && !this.footer.el && this.footer.xtype) {
37654 var ctr = this.grid.getView().getFooterPanel(true);
37655 this.footer.dataSource = this.grid.dataSource;
37656 this.footer = Roo.factory(this.footer, Roo);
37657 this.footer.render(ctr);
37667 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37668 getId : function(){
37669 return this.grid.id;
37673 * Returns the grid for this panel
37674 * @return {Roo.bootstrap.Table}
37676 getGrid : function(){
37680 setSize : function(width, height){
37681 if(!this.ignoreResize(width, height)){
37682 var grid = this.grid;
37683 var size = this.adjustForComponents(width, height);
37684 var gridel = grid.getGridEl();
37685 gridel.setSize(size.width, size.height);
37687 var thd = grid.getGridEl().select('thead',true).first();
37688 var tbd = grid.getGridEl().select('tbody', true).first();
37690 tbd.setSize(width, height - thd.getHeight());
37699 beforeSlide : function(){
37700 this.grid.getView().scroller.clip();
37703 afterSlide : function(){
37704 this.grid.getView().scroller.unclip();
37707 destroy : function(){
37708 this.grid.destroy();
37710 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37715 * @class Roo.bootstrap.panel.Nest
37716 * @extends Roo.bootstrap.panel.Content
37718 * Create a new Panel, that can contain a layout.Border.
37721 * @param {Roo.BorderLayout} layout The layout for this panel
37722 * @param {String/Object} config A string to set only the title or a config object
37724 Roo.bootstrap.panel.Nest = function(config)
37726 // construct with only one argument..
37727 /* FIXME - implement nicer consturctors
37728 if (layout.layout) {
37730 layout = config.layout;
37731 delete config.layout;
37733 if (layout.xtype && !layout.getEl) {
37734 // then layout needs constructing..
37735 layout = Roo.factory(layout, Roo);
37739 config.el = config.layout.getEl();
37741 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37743 config.layout.monitorWindowResize = false; // turn off autosizing
37744 this.layout = config.layout;
37745 this.layout.getEl().addClass("roo-layout-nested-layout");
37752 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37754 setSize : function(width, height){
37755 if(!this.ignoreResize(width, height)){
37756 var size = this.adjustForComponents(width, height);
37757 var el = this.layout.getEl();
37758 if (size.height < 1) {
37759 el.setWidth(size.width);
37761 el.setSize(size.width, size.height);
37763 var touch = el.dom.offsetWidth;
37764 this.layout.layout();
37765 // ie requires a double layout on the first pass
37766 if(Roo.isIE && !this.initialized){
37767 this.initialized = true;
37768 this.layout.layout();
37773 // activate all subpanels if not currently active..
37775 setActiveState : function(active){
37776 this.active = active;
37777 this.setActiveClass(active);
37780 this.fireEvent("deactivate", this);
37784 this.fireEvent("activate", this);
37785 // not sure if this should happen before or after..
37786 if (!this.layout) {
37787 return; // should not happen..
37790 for (var r in this.layout.regions) {
37791 reg = this.layout.getRegion(r);
37792 if (reg.getActivePanel()) {
37793 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37794 reg.setActivePanel(reg.getActivePanel());
37797 if (!reg.panels.length) {
37800 reg.showPanel(reg.getPanel(0));
37809 * Returns the nested BorderLayout for this panel
37810 * @return {Roo.BorderLayout}
37812 getLayout : function(){
37813 return this.layout;
37817 * Adds a xtype elements to the layout of the nested panel
37821 xtype : 'ContentPanel',
37828 xtype : 'NestedLayoutPanel',
37834 items : [ ... list of content panels or nested layout panels.. ]
37838 * @param {Object} cfg Xtype definition of item to add.
37840 addxtype : function(cfg) {
37841 return this.layout.addxtype(cfg);
37846 * Ext JS Library 1.1.1
37847 * Copyright(c) 2006-2007, Ext JS, LLC.
37849 * Originally Released Under LGPL - original licence link has changed is not relivant.
37852 * <script type="text/javascript">
37855 * @class Roo.TabPanel
37856 * @extends Roo.util.Observable
37857 * A lightweight tab container.
37861 // basic tabs 1, built from existing content
37862 var tabs = new Roo.TabPanel("tabs1");
37863 tabs.addTab("script", "View Script");
37864 tabs.addTab("markup", "View Markup");
37865 tabs.activate("script");
37867 // more advanced tabs, built from javascript
37868 var jtabs = new Roo.TabPanel("jtabs");
37869 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37871 // set up the UpdateManager
37872 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37873 var updater = tab2.getUpdateManager();
37874 updater.setDefaultUrl("ajax1.htm");
37875 tab2.on('activate', updater.refresh, updater, true);
37877 // Use setUrl for Ajax loading
37878 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37879 tab3.setUrl("ajax2.htm", null, true);
37882 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37885 jtabs.activate("jtabs-1");
37888 * Create a new TabPanel.
37889 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37890 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37892 Roo.bootstrap.panel.Tabs = function(config){
37894 * The container element for this TabPanel.
37895 * @type Roo.Element
37897 this.el = Roo.get(config.el);
37900 if(typeof config == "boolean"){
37901 this.tabPosition = config ? "bottom" : "top";
37903 Roo.apply(this, config);
37907 if(this.tabPosition == "bottom"){
37908 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37909 this.el.addClass("roo-tabs-bottom");
37911 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37912 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37913 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37915 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37917 if(this.tabPosition != "bottom"){
37918 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37919 * @type Roo.Element
37921 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37922 this.el.addClass("roo-tabs-top");
37926 this.bodyEl.setStyle("position", "relative");
37928 this.active = null;
37929 this.activateDelegate = this.activate.createDelegate(this);
37934 * Fires when the active tab changes
37935 * @param {Roo.TabPanel} this
37936 * @param {Roo.TabPanelItem} activePanel The new active tab
37940 * @event beforetabchange
37941 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37942 * @param {Roo.TabPanel} this
37943 * @param {Object} e Set cancel to true on this object to cancel the tab change
37944 * @param {Roo.TabPanelItem} tab The tab being changed to
37946 "beforetabchange" : true
37949 Roo.EventManager.onWindowResize(this.onResize, this);
37950 this.cpad = this.el.getPadding("lr");
37951 this.hiddenCount = 0;
37954 // toolbar on the tabbar support...
37955 if (this.toolbar) {
37956 alert("no toolbar support yet");
37957 this.toolbar = false;
37959 var tcfg = this.toolbar;
37960 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37961 this.toolbar = new Roo.Toolbar(tcfg);
37962 if (Roo.isSafari) {
37963 var tbl = tcfg.container.child('table', true);
37964 tbl.setAttribute('width', '100%');
37972 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37975 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37977 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37979 tabPosition : "top",
37981 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37983 currentTabWidth : 0,
37985 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37989 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37993 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37995 preferredTabWidth : 175,
37997 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37999 resizeTabs : false,
38001 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38003 monitorResize : true,
38005 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38010 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38011 * @param {String} id The id of the div to use <b>or create</b>
38012 * @param {String} text The text for the tab
38013 * @param {String} content (optional) Content to put in the TabPanelItem body
38014 * @param {Boolean} closable (optional) True to create a close icon on the tab
38015 * @return {Roo.TabPanelItem} The created TabPanelItem
38017 addTab : function(id, text, content, closable, tpl)
38019 var item = new Roo.bootstrap.panel.TabItem({
38023 closable : closable,
38026 this.addTabItem(item);
38028 item.setContent(content);
38034 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38035 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38036 * @return {Roo.TabPanelItem}
38038 getTab : function(id){
38039 return this.items[id];
38043 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38044 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38046 hideTab : function(id){
38047 var t = this.items[id];
38050 this.hiddenCount++;
38051 this.autoSizeTabs();
38056 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38057 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38059 unhideTab : function(id){
38060 var t = this.items[id];
38062 t.setHidden(false);
38063 this.hiddenCount--;
38064 this.autoSizeTabs();
38069 * Adds an existing {@link Roo.TabPanelItem}.
38070 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38072 addTabItem : function(item){
38073 this.items[item.id] = item;
38074 this.items.push(item);
38075 // if(this.resizeTabs){
38076 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38077 // this.autoSizeTabs();
38079 // item.autoSize();
38084 * Removes a {@link Roo.TabPanelItem}.
38085 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38087 removeTab : function(id){
38088 var items = this.items;
38089 var tab = items[id];
38090 if(!tab) { return; }
38091 var index = items.indexOf(tab);
38092 if(this.active == tab && items.length > 1){
38093 var newTab = this.getNextAvailable(index);
38098 this.stripEl.dom.removeChild(tab.pnode.dom);
38099 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38100 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38102 items.splice(index, 1);
38103 delete this.items[tab.id];
38104 tab.fireEvent("close", tab);
38105 tab.purgeListeners();
38106 this.autoSizeTabs();
38109 getNextAvailable : function(start){
38110 var items = this.items;
38112 // look for a next tab that will slide over to
38113 // replace the one being removed
38114 while(index < items.length){
38115 var item = items[++index];
38116 if(item && !item.isHidden()){
38120 // if one isn't found select the previous tab (on the left)
38123 var item = items[--index];
38124 if(item && !item.isHidden()){
38132 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38133 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38135 disableTab : function(id){
38136 var tab = this.items[id];
38137 if(tab && this.active != tab){
38143 * Enables a {@link Roo.TabPanelItem} that is disabled.
38144 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38146 enableTab : function(id){
38147 var tab = this.items[id];
38152 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38153 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38154 * @return {Roo.TabPanelItem} The TabPanelItem.
38156 activate : function(id){
38157 var tab = this.items[id];
38161 if(tab == this.active || tab.disabled){
38165 this.fireEvent("beforetabchange", this, e, tab);
38166 if(e.cancel !== true && !tab.disabled){
38168 this.active.hide();
38170 this.active = this.items[id];
38171 this.active.show();
38172 this.fireEvent("tabchange", this, this.active);
38178 * Gets the active {@link Roo.TabPanelItem}.
38179 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38181 getActiveTab : function(){
38182 return this.active;
38186 * Updates the tab body element to fit the height of the container element
38187 * for overflow scrolling
38188 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38190 syncHeight : function(targetHeight){
38191 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38192 var bm = this.bodyEl.getMargins();
38193 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38194 this.bodyEl.setHeight(newHeight);
38198 onResize : function(){
38199 if(this.monitorResize){
38200 this.autoSizeTabs();
38205 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38207 beginUpdate : function(){
38208 this.updating = true;
38212 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38214 endUpdate : function(){
38215 this.updating = false;
38216 this.autoSizeTabs();
38220 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38222 autoSizeTabs : function(){
38223 var count = this.items.length;
38224 var vcount = count - this.hiddenCount;
38225 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38228 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38229 var availWidth = Math.floor(w / vcount);
38230 var b = this.stripBody;
38231 if(b.getWidth() > w){
38232 var tabs = this.items;
38233 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38234 if(availWidth < this.minTabWidth){
38235 /*if(!this.sleft){ // incomplete scrolling code
38236 this.createScrollButtons();
38239 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38242 if(this.currentTabWidth < this.preferredTabWidth){
38243 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38249 * Returns the number of tabs in this TabPanel.
38252 getCount : function(){
38253 return this.items.length;
38257 * Resizes all the tabs to the passed width
38258 * @param {Number} The new width
38260 setTabWidth : function(width){
38261 this.currentTabWidth = width;
38262 for(var i = 0, len = this.items.length; i < len; i++) {
38263 if(!this.items[i].isHidden()) {
38264 this.items[i].setWidth(width);
38270 * Destroys this TabPanel
38271 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38273 destroy : function(removeEl){
38274 Roo.EventManager.removeResizeListener(this.onResize, this);
38275 for(var i = 0, len = this.items.length; i < len; i++){
38276 this.items[i].purgeListeners();
38278 if(removeEl === true){
38279 this.el.update("");
38284 createStrip : function(container)
38286 var strip = document.createElement("nav");
38287 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
38288 container.appendChild(strip);
38292 createStripList : function(strip)
38294 // div wrapper for retard IE
38295 // returns the "tr" element.
38296 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38297 //'<div class="x-tabs-strip-wrap">'+
38298 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38299 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38300 return strip.firstChild; //.firstChild.firstChild.firstChild;
38302 createBody : function(container)
38304 var body = document.createElement("div");
38305 Roo.id(body, "tab-body");
38306 //Roo.fly(body).addClass("x-tabs-body");
38307 Roo.fly(body).addClass("tab-content");
38308 container.appendChild(body);
38311 createItemBody :function(bodyEl, id){
38312 var body = Roo.getDom(id);
38314 body = document.createElement("div");
38317 //Roo.fly(body).addClass("x-tabs-item-body");
38318 Roo.fly(body).addClass("tab-pane");
38319 bodyEl.insertBefore(body, bodyEl.firstChild);
38323 createStripElements : function(stripEl, text, closable, tpl)
38325 var td = document.createElement("li"); // was td..
38328 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38331 stripEl.appendChild(td);
38333 td.className = "x-tabs-closable";
38334 if(!this.closeTpl){
38335 this.closeTpl = new Roo.Template(
38336 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38337 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38338 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38341 var el = this.closeTpl.overwrite(td, {"text": text});
38342 var close = el.getElementsByTagName("div")[0];
38343 var inner = el.getElementsByTagName("em")[0];
38344 return {"el": el, "close": close, "inner": inner};
38347 // not sure what this is..
38348 // if(!this.tabTpl){
38349 //this.tabTpl = new Roo.Template(
38350 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38351 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38353 // this.tabTpl = new Roo.Template(
38354 // '<a href="#">' +
38355 // '<span unselectable="on"' +
38356 // (this.disableTooltips ? '' : ' title="{text}"') +
38357 // ' >{text}</span></a>'
38363 var template = tpl || this.tabTpl || false;
38367 template = new Roo.Template(
38369 '<span unselectable="on"' +
38370 (this.disableTooltips ? '' : ' title="{text}"') +
38371 ' >{text}</span></a>'
38375 switch (typeof(template)) {
38379 template = new Roo.Template(template);
38385 var el = template.overwrite(td, {"text": text});
38387 var inner = el.getElementsByTagName("span")[0];
38389 return {"el": el, "inner": inner};
38397 * @class Roo.TabPanelItem
38398 * @extends Roo.util.Observable
38399 * Represents an individual item (tab plus body) in a TabPanel.
38400 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38401 * @param {String} id The id of this TabPanelItem
38402 * @param {String} text The text for the tab of this TabPanelItem
38403 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38405 Roo.bootstrap.panel.TabItem = function(config){
38407 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38408 * @type Roo.TabPanel
38410 this.tabPanel = config.panel;
38412 * The id for this TabPanelItem
38415 this.id = config.id;
38417 this.disabled = false;
38419 this.text = config.text;
38421 this.loaded = false;
38422 this.closable = config.closable;
38425 * The body element for this TabPanelItem.
38426 * @type Roo.Element
38428 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38429 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38430 this.bodyEl.setStyle("display", "block");
38431 this.bodyEl.setStyle("zoom", "1");
38432 //this.hideAction();
38434 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38436 this.el = Roo.get(els.el);
38437 this.inner = Roo.get(els.inner, true);
38438 this.textEl = Roo.get(this.el.dom.firstChild, true);
38439 this.pnode = Roo.get(els.el.parentNode, true);
38440 // this.el.on("mousedown", this.onTabMouseDown, this);
38441 this.el.on("click", this.onTabClick, this);
38443 if(config.closable){
38444 var c = Roo.get(els.close, true);
38445 c.dom.title = this.closeText;
38446 c.addClassOnOver("close-over");
38447 c.on("click", this.closeClick, this);
38453 * Fires when this tab becomes the active tab.
38454 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38455 * @param {Roo.TabPanelItem} this
38459 * @event beforeclose
38460 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38461 * @param {Roo.TabPanelItem} this
38462 * @param {Object} e Set cancel to true on this object to cancel the close.
38464 "beforeclose": true,
38467 * Fires when this tab is closed.
38468 * @param {Roo.TabPanelItem} this
38472 * @event deactivate
38473 * Fires when this tab is no longer the active tab.
38474 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38475 * @param {Roo.TabPanelItem} this
38477 "deactivate" : true
38479 this.hidden = false;
38481 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38484 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38486 purgeListeners : function(){
38487 Roo.util.Observable.prototype.purgeListeners.call(this);
38488 this.el.removeAllListeners();
38491 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38494 this.pnode.addClass("active");
38497 this.tabPanel.stripWrap.repaint();
38499 this.fireEvent("activate", this.tabPanel, this);
38503 * Returns true if this tab is the active tab.
38504 * @return {Boolean}
38506 isActive : function(){
38507 return this.tabPanel.getActiveTab() == this;
38511 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38514 this.pnode.removeClass("active");
38516 this.fireEvent("deactivate", this.tabPanel, this);
38519 hideAction : function(){
38520 this.bodyEl.hide();
38521 this.bodyEl.setStyle("position", "absolute");
38522 this.bodyEl.setLeft("-20000px");
38523 this.bodyEl.setTop("-20000px");
38526 showAction : function(){
38527 this.bodyEl.setStyle("position", "relative");
38528 this.bodyEl.setTop("");
38529 this.bodyEl.setLeft("");
38530 this.bodyEl.show();
38534 * Set the tooltip for the tab.
38535 * @param {String} tooltip The tab's tooltip
38537 setTooltip : function(text){
38538 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38539 this.textEl.dom.qtip = text;
38540 this.textEl.dom.removeAttribute('title');
38542 this.textEl.dom.title = text;
38546 onTabClick : function(e){
38547 e.preventDefault();
38548 this.tabPanel.activate(this.id);
38551 onTabMouseDown : function(e){
38552 e.preventDefault();
38553 this.tabPanel.activate(this.id);
38556 getWidth : function(){
38557 return this.inner.getWidth();
38560 setWidth : function(width){
38561 var iwidth = width - this.pnode.getPadding("lr");
38562 this.inner.setWidth(iwidth);
38563 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38564 this.pnode.setWidth(width);
38568 * Show or hide the tab
38569 * @param {Boolean} hidden True to hide or false to show.
38571 setHidden : function(hidden){
38572 this.hidden = hidden;
38573 this.pnode.setStyle("display", hidden ? "none" : "");
38577 * Returns true if this tab is "hidden"
38578 * @return {Boolean}
38580 isHidden : function(){
38581 return this.hidden;
38585 * Returns the text for this tab
38588 getText : function(){
38592 autoSize : function(){
38593 //this.el.beginMeasure();
38594 this.textEl.setWidth(1);
38596 * #2804 [new] Tabs in Roojs
38597 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38599 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38600 //this.el.endMeasure();
38604 * Sets the text for the tab (Note: this also sets the tooltip text)
38605 * @param {String} text The tab's text and tooltip
38607 setText : function(text){
38609 this.textEl.update(text);
38610 this.setTooltip(text);
38611 //if(!this.tabPanel.resizeTabs){
38612 // this.autoSize();
38616 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38618 activate : function(){
38619 this.tabPanel.activate(this.id);
38623 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38625 disable : function(){
38626 if(this.tabPanel.active != this){
38627 this.disabled = true;
38628 this.pnode.addClass("disabled");
38633 * Enables this TabPanelItem if it was previously disabled.
38635 enable : function(){
38636 this.disabled = false;
38637 this.pnode.removeClass("disabled");
38641 * Sets the content for this TabPanelItem.
38642 * @param {String} content The content
38643 * @param {Boolean} loadScripts true to look for and load scripts
38645 setContent : function(content, loadScripts){
38646 this.bodyEl.update(content, loadScripts);
38650 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38651 * @return {Roo.UpdateManager} The UpdateManager
38653 getUpdateManager : function(){
38654 return this.bodyEl.getUpdateManager();
38658 * Set a URL to be used to load the content for this TabPanelItem.
38659 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38660 * @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)
38661 * @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)
38662 * @return {Roo.UpdateManager} The UpdateManager
38664 setUrl : function(url, params, loadOnce){
38665 if(this.refreshDelegate){
38666 this.un('activate', this.refreshDelegate);
38668 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38669 this.on("activate", this.refreshDelegate);
38670 return this.bodyEl.getUpdateManager();
38674 _handleRefresh : function(url, params, loadOnce){
38675 if(!loadOnce || !this.loaded){
38676 var updater = this.bodyEl.getUpdateManager();
38677 updater.update(url, params, this._setLoaded.createDelegate(this));
38682 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38683 * Will fail silently if the setUrl method has not been called.
38684 * This does not activate the panel, just updates its content.
38686 refresh : function(){
38687 if(this.refreshDelegate){
38688 this.loaded = false;
38689 this.refreshDelegate();
38694 _setLoaded : function(){
38695 this.loaded = true;
38699 closeClick : function(e){
38702 this.fireEvent("beforeclose", this, o);
38703 if(o.cancel !== true){
38704 this.tabPanel.removeTab(this.id);
38708 * The text displayed in the tooltip for the close icon.
38711 closeText : "Close this tab"
38714 * This script refer to:
38715 * Title: International Telephone Input
38716 * Author: Jack O'Connor
38717 * Code version: v12.1.12
38718 * Availability: https://github.com/jackocnr/intl-tel-input.git
38721 Roo.bootstrap.PhoneInputData = function() {
38724 "Afghanistan (افغانستان)",
38729 "Albania (Shqipëri)",
38734 "Algeria (الجزائر)",
38759 "Antigua and Barbuda",
38769 "Armenia (Հայաստան)",
38785 "Austria (Österreich)",
38790 "Azerbaijan (Azərbaycan)",
38800 "Bahrain (البحرين)",
38805 "Bangladesh (বাংলাদেশ)",
38815 "Belarus (Беларусь)",
38820 "Belgium (België)",
38850 "Bosnia and Herzegovina (Босна и Херцеговина)",
38865 "British Indian Ocean Territory",
38870 "British Virgin Islands",
38880 "Bulgaria (България)",
38890 "Burundi (Uburundi)",
38895 "Cambodia (កម្ពុជា)",
38900 "Cameroon (Cameroun)",
38909 ["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"]
38912 "Cape Verde (Kabu Verdi)",
38917 "Caribbean Netherlands",
38928 "Central African Republic (République centrafricaine)",
38948 "Christmas Island",
38954 "Cocos (Keeling) Islands",
38965 "Comoros (جزر القمر)",
38970 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38975 "Congo (Republic) (Congo-Brazzaville)",
38995 "Croatia (Hrvatska)",
39016 "Czech Republic (Česká republika)",
39021 "Denmark (Danmark)",
39036 "Dominican Republic (República Dominicana)",
39040 ["809", "829", "849"]
39058 "Equatorial Guinea (Guinea Ecuatorial)",
39078 "Falkland Islands (Islas Malvinas)",
39083 "Faroe Islands (Føroyar)",
39104 "French Guiana (Guyane française)",
39109 "French Polynesia (Polynésie française)",
39124 "Georgia (საქართველო)",
39129 "Germany (Deutschland)",
39149 "Greenland (Kalaallit Nunaat)",
39186 "Guinea-Bissau (Guiné Bissau)",
39211 "Hungary (Magyarország)",
39216 "Iceland (Ísland)",
39236 "Iraq (العراق)",
39252 "Israel (ישראל)",
39279 "Jordan (الأردن)",
39284 "Kazakhstan (Казахстан)",
39305 "Kuwait (الكويت)",
39310 "Kyrgyzstan (Кыргызстан)",
39320 "Latvia (Latvija)",
39325 "Lebanon (لبنان)",
39340 "Libya (ليبيا)",
39350 "Lithuania (Lietuva)",
39365 "Macedonia (FYROM) (Македонија)",
39370 "Madagascar (Madagasikara)",
39400 "Marshall Islands",
39410 "Mauritania (موريتانيا)",
39415 "Mauritius (Moris)",
39436 "Moldova (Republica Moldova)",
39446 "Mongolia (Монгол)",
39451 "Montenegro (Crna Gora)",
39461 "Morocco (المغرب)",
39467 "Mozambique (Moçambique)",
39472 "Myanmar (Burma) (မြန်မာ)",
39477 "Namibia (Namibië)",
39492 "Netherlands (Nederland)",
39497 "New Caledonia (Nouvelle-Calédonie)",
39532 "North Korea (조선 민주주의 인민 공화국)",
39537 "Northern Mariana Islands",
39553 "Pakistan (پاکستان)",
39563 "Palestine (فلسطين)",
39573 "Papua New Guinea",
39615 "Réunion (La Réunion)",
39621 "Romania (România)",
39637 "Saint Barthélemy",
39648 "Saint Kitts and Nevis",
39658 "Saint Martin (Saint-Martin (partie française))",
39664 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39669 "Saint Vincent and the Grenadines",
39684 "São Tomé and Príncipe (São Tomé e Príncipe)",
39689 "Saudi Arabia (المملكة العربية السعودية)",
39694 "Senegal (Sénégal)",
39724 "Slovakia (Slovensko)",
39729 "Slovenia (Slovenija)",
39739 "Somalia (Soomaaliya)",
39749 "South Korea (대한민국)",
39754 "South Sudan (جنوب السودان)",
39764 "Sri Lanka (ශ්රී ලංකාව)",
39769 "Sudan (السودان)",
39779 "Svalbard and Jan Mayen",
39790 "Sweden (Sverige)",
39795 "Switzerland (Schweiz)",
39800 "Syria (سوريا)",
39845 "Trinidad and Tobago",
39850 "Tunisia (تونس)",
39855 "Turkey (Türkiye)",
39865 "Turks and Caicos Islands",
39875 "U.S. Virgin Islands",
39885 "Ukraine (Україна)",
39890 "United Arab Emirates (الإمارات العربية المتحدة)",
39912 "Uzbekistan (Oʻzbekiston)",
39922 "Vatican City (Città del Vaticano)",
39933 "Vietnam (Việt Nam)",
39938 "Wallis and Futuna (Wallis-et-Futuna)",
39943 "Western Sahara (الصحراء الغربية)",
39949 "Yemen (اليمن)",
39973 * This script refer to:
39974 * Title: International Telephone Input
39975 * Author: Jack O'Connor
39976 * Code version: v12.1.12
39977 * Availability: https://github.com/jackocnr/intl-tel-input.git
39981 * @class Roo.bootstrap.PhoneInput
39982 * @extends Roo.bootstrap.TriggerField
39983 * An input with International dial-code selection
39985 * @cfg {String} defaultDialCode default '+852'
39986 * @cfg {Array} preferedCountries default []
39989 * Create a new PhoneInput.
39990 * @param {Object} config Configuration options
39993 Roo.bootstrap.PhoneInput = function(config) {
39994 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39997 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39999 listWidth: undefined,
40001 selectedClass: 'active',
40003 invalidClass : "has-warning",
40005 validClass: 'has-success',
40007 allowed: '0123456789',
40012 * @cfg {String} defaultDialCode The default dial code when initializing the input
40014 defaultDialCode: '+852',
40017 * @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
40019 preferedCountries: false,
40021 getAutoCreate : function()
40023 var data = Roo.bootstrap.PhoneInputData();
40024 var align = this.labelAlign || this.parentLabelAlign();
40027 this.allCountries = [];
40028 this.dialCodeMapping = [];
40030 for (var i = 0; i < data.length; i++) {
40032 this.allCountries[i] = {
40036 priority: c[3] || 0,
40037 areaCodes: c[4] || null
40039 this.dialCodeMapping[c[2]] = {
40042 priority: c[3] || 0,
40043 areaCodes: c[4] || null
40055 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40056 maxlength: this.max_length,
40057 cls : 'form-control tel-input',
40058 autocomplete: 'new-password'
40061 var hiddenInput = {
40064 cls: 'hidden-tel-input'
40068 hiddenInput.name = this.name;
40071 if (this.disabled) {
40072 input.disabled = true;
40075 var flag_container = {
40092 cls: this.hasFeedback ? 'has-feedback' : '',
40098 cls: 'dial-code-holder',
40105 cls: 'roo-select2-container input-group',
40112 if (this.fieldLabel.length) {
40115 tooltip: 'This field is required'
40121 cls: 'control-label',
40127 html: this.fieldLabel
40130 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40136 if(this.indicatorpos == 'right') {
40137 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40144 if(align == 'left') {
40152 if(this.labelWidth > 12){
40153 label.style = "width: " + this.labelWidth + 'px';
40155 if(this.labelWidth < 13 && this.labelmd == 0){
40156 this.labelmd = this.labelWidth;
40158 if(this.labellg > 0){
40159 label.cls += ' col-lg-' + this.labellg;
40160 input.cls += ' col-lg-' + (12 - this.labellg);
40162 if(this.labelmd > 0){
40163 label.cls += ' col-md-' + this.labelmd;
40164 container.cls += ' col-md-' + (12 - this.labelmd);
40166 if(this.labelsm > 0){
40167 label.cls += ' col-sm-' + this.labelsm;
40168 container.cls += ' col-sm-' + (12 - this.labelsm);
40170 if(this.labelxs > 0){
40171 label.cls += ' col-xs-' + this.labelxs;
40172 container.cls += ' col-xs-' + (12 - this.labelxs);
40182 var settings = this;
40184 ['xs','sm','md','lg'].map(function(size){
40185 if (settings[size]) {
40186 cfg.cls += ' col-' + size + '-' + settings[size];
40190 this.store = new Roo.data.Store({
40191 proxy : new Roo.data.MemoryProxy({}),
40192 reader : new Roo.data.JsonReader({
40203 'name' : 'dialCode',
40207 'name' : 'priority',
40211 'name' : 'areaCodes',
40218 if(!this.preferedCountries) {
40219 this.preferedCountries = [
40226 var p = this.preferedCountries.reverse();
40229 for (var i = 0; i < p.length; i++) {
40230 for (var j = 0; j < this.allCountries.length; j++) {
40231 if(this.allCountries[j].iso2 == p[i]) {
40232 var t = this.allCountries[j];
40233 this.allCountries.splice(j,1);
40234 this.allCountries.unshift(t);
40240 this.store.proxy.data = {
40242 data: this.allCountries
40248 initEvents : function()
40251 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40253 this.indicator = this.indicatorEl();
40254 this.flag = this.flagEl();
40255 this.dialCodeHolder = this.dialCodeHolderEl();
40257 this.trigger = this.el.select('div.flag-box',true).first();
40258 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40263 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40264 _this.list.setWidth(lw);
40267 this.list.on('mouseover', this.onViewOver, this);
40268 this.list.on('mousemove', this.onViewMove, this);
40269 this.inputEl().on("keyup", this.onKeyUp, this);
40270 this.inputEl().on("keypress", this.onKeyPress, this);
40272 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40274 this.view = new Roo.View(this.list, this.tpl, {
40275 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40278 this.view.on('click', this.onViewClick, this);
40279 this.setValue(this.defaultDialCode);
40282 onTriggerClick : function(e)
40284 Roo.log('trigger click');
40289 if(this.isExpanded()){
40291 this.hasFocus = false;
40293 this.store.load({});
40294 this.hasFocus = true;
40299 isExpanded : function()
40301 return this.list.isVisible();
40304 collapse : function()
40306 if(!this.isExpanded()){
40310 Roo.get(document).un('mousedown', this.collapseIf, this);
40311 Roo.get(document).un('mousewheel', this.collapseIf, this);
40312 this.fireEvent('collapse', this);
40316 expand : function()
40320 if(this.isExpanded() || !this.hasFocus){
40324 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40325 this.list.setWidth(lw);
40328 this.restrictHeight();
40330 Roo.get(document).on('mousedown', this.collapseIf, this);
40331 Roo.get(document).on('mousewheel', this.collapseIf, this);
40333 this.fireEvent('expand', this);
40336 restrictHeight : function()
40338 this.list.alignTo(this.inputEl(), this.listAlign);
40339 this.list.alignTo(this.inputEl(), this.listAlign);
40342 onViewOver : function(e, t)
40344 if(this.inKeyMode){
40347 var item = this.view.findItemFromChild(t);
40350 var index = this.view.indexOf(item);
40351 this.select(index, false);
40356 onViewClick : function(view, doFocus, el, e)
40358 var index = this.view.getSelectedIndexes()[0];
40360 var r = this.store.getAt(index);
40363 this.onSelect(r, index);
40365 if(doFocus !== false && !this.blockFocus){
40366 this.inputEl().focus();
40370 onViewMove : function(e, t)
40372 this.inKeyMode = false;
40375 select : function(index, scrollIntoView)
40377 this.selectedIndex = index;
40378 this.view.select(index);
40379 if(scrollIntoView !== false){
40380 var el = this.view.getNode(index);
40382 this.list.scrollChildIntoView(el, false);
40387 createList : function()
40389 this.list = Roo.get(document.body).createChild({
40391 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40392 style: 'display:none'
40395 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40398 collapseIf : function(e)
40400 var in_combo = e.within(this.el);
40401 var in_list = e.within(this.list);
40402 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40404 if (in_combo || in_list || is_list) {
40410 onSelect : function(record, index)
40412 if(this.fireEvent('beforeselect', this, record, index) !== false){
40414 this.setFlagClass(record.data.iso2);
40415 this.setDialCode(record.data.dialCode);
40416 this.hasFocus = false;
40418 this.fireEvent('select', this, record, index);
40422 flagEl : function()
40424 var flag = this.el.select('div.flag',true).first();
40431 dialCodeHolderEl : function()
40433 var d = this.el.select('input.dial-code-holder',true).first();
40440 setDialCode : function(v)
40442 this.dialCodeHolder.dom.value = '+'+v;
40445 setFlagClass : function(n)
40447 this.flag.dom.className = 'flag '+n;
40450 getValue : function()
40452 var v = this.inputEl().getValue();
40453 if(this.dialCodeHolder) {
40454 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40459 setValue : function(v)
40461 var d = this.getDialCode(v);
40463 //invalid dial code
40464 if(v.length == 0 || !d || d.length == 0) {
40466 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40467 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40473 this.setFlagClass(this.dialCodeMapping[d].iso2);
40474 this.setDialCode(d);
40475 this.inputEl().dom.value = v.replace('+'+d,'');
40476 this.hiddenEl().dom.value = this.getValue();
40481 getDialCode : function(v)
40485 if (v.length == 0) {
40486 return this.dialCodeHolder.dom.value;
40490 if (v.charAt(0) != "+") {
40493 var numericChars = "";
40494 for (var i = 1; i < v.length; i++) {
40495 var c = v.charAt(i);
40498 if (this.dialCodeMapping[numericChars]) {
40499 dialCode = v.substr(1, i);
40501 if (numericChars.length == 4) {
40511 this.setValue(this.defaultDialCode);
40515 hiddenEl : function()
40517 return this.el.select('input.hidden-tel-input',true).first();
40520 // after setting val
40521 onKeyUp : function(e){
40522 this.setValue(this.getValue());
40525 onKeyPress : function(e){
40526 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40533 * @class Roo.bootstrap.MoneyField
40534 * @extends Roo.bootstrap.ComboBox
40535 * Bootstrap MoneyField class
40538 * Create a new MoneyField.
40539 * @param {Object} config Configuration options
40542 Roo.bootstrap.MoneyField = function(config) {
40544 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40548 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40551 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40553 allowDecimals : true,
40555 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40557 decimalSeparator : ".",
40559 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40561 decimalPrecision : 0,
40563 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40565 allowNegative : true,
40567 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40571 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40573 minValue : Number.NEGATIVE_INFINITY,
40575 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40577 maxValue : Number.MAX_VALUE,
40579 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40581 minText : "The minimum value for this field is {0}",
40583 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40585 maxText : "The maximum value for this field is {0}",
40587 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40588 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40590 nanText : "{0} is not a valid number",
40592 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40596 * @cfg {String} defaults currency of the MoneyField
40597 * value should be in lkey
40599 defaultCurrency : false,
40601 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40603 thousandsDelimiter : false,
40605 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40616 getAutoCreate : function()
40618 var align = this.labelAlign || this.parentLabelAlign();
40630 cls : 'form-control roo-money-amount-input',
40631 autocomplete: 'new-password'
40634 var hiddenInput = {
40638 cls: 'hidden-number-input'
40641 if(this.max_length) {
40642 input.maxlength = this.max_length;
40646 hiddenInput.name = this.name;
40649 if (this.disabled) {
40650 input.disabled = true;
40653 var clg = 12 - this.inputlg;
40654 var cmd = 12 - this.inputmd;
40655 var csm = 12 - this.inputsm;
40656 var cxs = 12 - this.inputxs;
40660 cls : 'row roo-money-field',
40664 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40668 cls: 'roo-select2-container input-group',
40672 cls : 'form-control roo-money-currency-input',
40673 autocomplete: 'new-password',
40675 name : this.currencyName
40679 cls : 'input-group-addon',
40693 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40697 cls: this.hasFeedback ? 'has-feedback' : '',
40708 if (this.fieldLabel.length) {
40711 tooltip: 'This field is required'
40717 cls: 'control-label',
40723 html: this.fieldLabel
40726 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40732 if(this.indicatorpos == 'right') {
40733 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40740 if(align == 'left') {
40748 if(this.labelWidth > 12){
40749 label.style = "width: " + this.labelWidth + 'px';
40751 if(this.labelWidth < 13 && this.labelmd == 0){
40752 this.labelmd = this.labelWidth;
40754 if(this.labellg > 0){
40755 label.cls += ' col-lg-' + this.labellg;
40756 input.cls += ' col-lg-' + (12 - this.labellg);
40758 if(this.labelmd > 0){
40759 label.cls += ' col-md-' + this.labelmd;
40760 container.cls += ' col-md-' + (12 - this.labelmd);
40762 if(this.labelsm > 0){
40763 label.cls += ' col-sm-' + this.labelsm;
40764 container.cls += ' col-sm-' + (12 - this.labelsm);
40766 if(this.labelxs > 0){
40767 label.cls += ' col-xs-' + this.labelxs;
40768 container.cls += ' col-xs-' + (12 - this.labelxs);
40779 var settings = this;
40781 ['xs','sm','md','lg'].map(function(size){
40782 if (settings[size]) {
40783 cfg.cls += ' col-' + size + '-' + settings[size];
40790 initEvents : function()
40792 this.indicator = this.indicatorEl();
40794 this.initCurrencyEvent();
40796 this.initNumberEvent();
40799 initCurrencyEvent : function()
40802 throw "can not find store for combo";
40805 this.store = Roo.factory(this.store, Roo.data);
40806 this.store.parent = this;
40810 this.triggerEl = this.el.select('.input-group-addon', true).first();
40812 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40817 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40818 _this.list.setWidth(lw);
40821 this.list.on('mouseover', this.onViewOver, this);
40822 this.list.on('mousemove', this.onViewMove, this);
40823 this.list.on('scroll', this.onViewScroll, this);
40826 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40829 this.view = new Roo.View(this.list, this.tpl, {
40830 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40833 this.view.on('click', this.onViewClick, this);
40835 this.store.on('beforeload', this.onBeforeLoad, this);
40836 this.store.on('load', this.onLoad, this);
40837 this.store.on('loadexception', this.onLoadException, this);
40839 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40840 "up" : function(e){
40841 this.inKeyMode = true;
40845 "down" : function(e){
40846 if(!this.isExpanded()){
40847 this.onTriggerClick();
40849 this.inKeyMode = true;
40854 "enter" : function(e){
40857 if(this.fireEvent("specialkey", this, e)){
40858 this.onViewClick(false);
40864 "esc" : function(e){
40868 "tab" : function(e){
40871 if(this.fireEvent("specialkey", this, e)){
40872 this.onViewClick(false);
40880 doRelay : function(foo, bar, hname){
40881 if(hname == 'down' || this.scope.isExpanded()){
40882 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40890 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40894 initNumberEvent : function(e)
40896 this.inputEl().on("keydown" , this.fireKey, this);
40897 this.inputEl().on("focus", this.onFocus, this);
40898 this.inputEl().on("blur", this.onBlur, this);
40900 this.inputEl().relayEvent('keyup', this);
40902 if(this.indicator){
40903 this.indicator.addClass('invisible');
40906 this.originalValue = this.getValue();
40908 if(this.validationEvent == 'keyup'){
40909 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40910 this.inputEl().on('keyup', this.filterValidation, this);
40912 else if(this.validationEvent !== false){
40913 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40916 if(this.selectOnFocus){
40917 this.on("focus", this.preFocus, this);
40920 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40921 this.inputEl().on("keypress", this.filterKeys, this);
40923 this.inputEl().relayEvent('keypress', this);
40926 var allowed = "0123456789";
40928 if(this.allowDecimals){
40929 allowed += this.decimalSeparator;
40932 if(this.allowNegative){
40936 if(this.thousandsDelimiter) {
40940 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40942 var keyPress = function(e){
40944 var k = e.getKey();
40946 var c = e.getCharCode();
40949 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40950 allowed.indexOf(String.fromCharCode(c)) === -1
40956 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40960 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40965 this.inputEl().on("keypress", keyPress, this);
40969 onTriggerClick : function(e)
40976 this.loadNext = false;
40978 if(this.isExpanded()){
40983 this.hasFocus = true;
40985 if(this.triggerAction == 'all') {
40986 this.doQuery(this.allQuery, true);
40990 this.doQuery(this.getRawValue());
40993 getCurrency : function()
40995 var v = this.currencyEl().getValue();
41000 restrictHeight : function()
41002 this.list.alignTo(this.currencyEl(), this.listAlign);
41003 this.list.alignTo(this.currencyEl(), this.listAlign);
41006 onViewClick : function(view, doFocus, el, e)
41008 var index = this.view.getSelectedIndexes()[0];
41010 var r = this.store.getAt(index);
41013 this.onSelect(r, index);
41017 onSelect : function(record, index){
41019 if(this.fireEvent('beforeselect', this, record, index) !== false){
41021 this.setFromCurrencyData(index > -1 ? record.data : false);
41025 this.fireEvent('select', this, record, index);
41029 setFromCurrencyData : function(o)
41033 this.lastCurrency = o;
41035 if (this.currencyField) {
41036 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41038 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41041 this.lastSelectionText = currency;
41043 //setting default currency
41044 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41045 this.setCurrency(this.defaultCurrency);
41049 this.setCurrency(currency);
41052 setFromData : function(o)
41056 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41058 this.setFromCurrencyData(c);
41063 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41065 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41068 this.setValue(value);
41072 setCurrency : function(v)
41074 this.currencyValue = v;
41077 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41082 setValue : function(v)
41084 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41090 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41092 this.inputEl().dom.value = (v == '') ? '' :
41093 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41095 if(!this.allowZero && v === '0') {
41096 this.hiddenEl().dom.value = '';
41097 this.inputEl().dom.value = '';
41104 getRawValue : function()
41106 var v = this.inputEl().getValue();
41111 getValue : function()
41113 return this.fixPrecision(this.parseValue(this.getRawValue()));
41116 parseValue : function(value)
41118 if(this.thousandsDelimiter) {
41120 r = new RegExp(",", "g");
41121 value = value.replace(r, "");
41124 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41125 return isNaN(value) ? '' : value;
41129 fixPrecision : function(value)
41131 if(this.thousandsDelimiter) {
41133 r = new RegExp(",", "g");
41134 value = value.replace(r, "");
41137 var nan = isNaN(value);
41139 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41140 return nan ? '' : value;
41142 return parseFloat(value).toFixed(this.decimalPrecision);
41145 decimalPrecisionFcn : function(v)
41147 return Math.floor(v);
41150 validateValue : function(value)
41152 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41156 var num = this.parseValue(value);
41159 this.markInvalid(String.format(this.nanText, value));
41163 if(num < this.minValue){
41164 this.markInvalid(String.format(this.minText, this.minValue));
41168 if(num > this.maxValue){
41169 this.markInvalid(String.format(this.maxText, this.maxValue));
41176 validate : function()
41178 if(this.disabled || this.allowBlank){
41183 var currency = this.getCurrency();
41185 if(this.validateValue(this.getRawValue()) && currency.length){
41190 this.markInvalid();
41194 getName: function()
41199 beforeBlur : function()
41205 var v = this.parseValue(this.getRawValue());
41212 onBlur : function()
41216 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41217 //this.el.removeClass(this.focusClass);
41220 this.hasFocus = false;
41222 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41226 var v = this.getValue();
41228 if(String(v) !== String(this.startValue)){
41229 this.fireEvent('change', this, v, this.startValue);
41232 this.fireEvent("blur", this);
41235 inputEl : function()
41237 return this.el.select('.roo-money-amount-input', true).first();
41240 currencyEl : function()
41242 return this.el.select('.roo-money-currency-input', true).first();
41245 hiddenEl : function()
41247 return this.el.select('input.hidden-number-input',true).first();