2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets[0], function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
585 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
586 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
587 * @cfg {String} size ( lg | sm | xs)
588 * @cfg {String} tag ( a | input | submit)
589 * @cfg {String} href empty or href
590 * @cfg {Boolean} disabled default false;
591 * @cfg {Boolean} isClose default false;
592 * @cfg {String} glyphicon depricated - use fa
593 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
594 * @cfg {String} badge text for badge
595 * @cfg {String} theme (default|glow)
596 * @cfg {Boolean} inverse dark themed version
597 * @cfg {Boolean} toggle is it a slidy toggle button
598 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
599 * @cfg {String} ontext text for on slidy toggle state
600 * @cfg {String} offtext text for off slidy toggle state
601 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
602 * @cfg {Boolean} removeClass remove the standard class..
603 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
606 * Create a new button
607 * @param {Object} config The config object
611 Roo.bootstrap.Button = function(config){
612 Roo.bootstrap.Button.superclass.constructor.call(this, config);
613 this.weightClass = ["btn-default btn-outline-secondary",
625 * When a butotn is pressed
626 * @param {Roo.bootstrap.Button} btn
627 * @param {Roo.EventObject} e
632 * After the button has been toggles
633 * @param {Roo.bootstrap.Button} btn
634 * @param {Roo.EventObject} e
635 * @param {boolean} pressed (also available as button.pressed)
641 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
662 preventDefault: true,
670 getAutoCreate : function(){
678 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
679 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
684 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
686 if (this.toggle == true) {
689 cls: 'slider-frame roo-button',
694 'data-off-text':'OFF',
695 cls: 'slider-button',
701 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
702 cfg.cls += ' '+this.weight;
711 cfg["aria-hidden"] = true;
713 cfg.html = "×";
719 if (this.theme==='default') {
720 cfg.cls = 'btn roo-button';
722 //if (this.parentType != 'Navbar') {
723 this.weight = this.weight.length ? this.weight : 'default';
725 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
727 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
728 var weight = this.weight == 'default' ? 'secondary' : this.weight;
729 cfg.cls += ' btn-' + outline + weight;
730 if (this.weight == 'default') {
732 cfg.cls += ' btn-' + this.weight;
735 } else if (this.theme==='glow') {
738 cfg.cls = 'btn-glow roo-button';
740 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
742 cfg.cls += ' ' + this.weight;
748 this.cls += ' inverse';
752 if (this.active || this.pressed === true) {
753 cfg.cls += ' active';
757 cfg.disabled = 'disabled';
761 Roo.log('changing to ul' );
763 this.glyphicon = 'caret';
764 if (Roo.bootstrap.version == 4) {
765 this.fa = 'caret-down';
770 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
772 //gsRoo.log(this.parentType);
773 if (this.parentType === 'Navbar' && !this.parent().bar) {
774 Roo.log('changing to li?');
783 href : this.href || '#'
786 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
787 cfg.cls += ' dropdown';
794 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
796 if (this.glyphicon) {
797 cfg.html = ' ' + cfg.html;
802 cls: 'glyphicon glyphicon-' + this.glyphicon
807 cfg.html = ' ' + cfg.html;
812 cls: 'fa fas fa-' + this.fa
822 // cfg.cls='btn roo-button';
826 var value = cfg.html;
831 cls: 'glyphicon glyphicon-' + this.glyphicon,
838 cls: 'fa fas fa-' + this.fa,
843 var bw = this.badge_weight.length ? this.badge_weight :
844 (this.weight.length ? this.weight : 'secondary');
845 bw = bw == 'default' ? 'secondary' : bw;
851 cls: 'badge badge-' + bw,
860 cfg.cls += ' dropdown';
861 cfg.html = typeof(cfg.html) != 'undefined' ?
862 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
865 if (cfg.tag !== 'a' && this.href !== '') {
866 throw "Tag must be a to set href.";
867 } else if (this.href.length > 0) {
868 cfg.href = this.href;
871 if(this.removeClass){
876 cfg.target = this.target;
881 initEvents: function() {
882 // Roo.log('init events?');
883 // Roo.log(this.el.dom);
886 if (typeof (this.menu) != 'undefined') {
887 this.menu.parentType = this.xtype;
888 this.menu.triggerEl = this.el;
889 this.addxtype(Roo.apply({}, this.menu));
893 if (this.el.hasClass('roo-button')) {
894 this.el.on('click', this.onClick, this);
896 this.el.select('.roo-button').on('click', this.onClick, this);
899 if(this.removeClass){
900 this.el.on('click', this.onClick, this);
903 this.el.enableDisplayMode();
906 onClick : function(e)
912 Roo.log('button on click ');
913 if(this.preventDefault){
917 if (this.pressed === true || this.pressed === false) {
918 this.toggleActive(e);
922 this.fireEvent('click', this, e);
926 * Enables this button
930 this.disabled = false;
931 this.el.removeClass('disabled');
935 * Disable this button
939 this.disabled = true;
940 this.el.addClass('disabled');
943 * sets the active state on/off,
944 * @param {Boolean} state (optional) Force a particular state
946 setActive : function(v) {
948 this.el[v ? 'addClass' : 'removeClass']('active');
952 * toggles the current active state
954 toggleActive : function(e)
956 this.setActive(!this.pressed);
957 this.fireEvent('toggle', this, e, !this.pressed);
960 * get the current active state
961 * @return {boolean} true if it's active
963 isActive : function()
965 return this.el.hasClass('active');
968 * set the text of the first selected button
970 setText : function(str)
972 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
975 * get the text of the first selected button
979 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
982 setWeight : function(str)
984 this.el.removeClass(this.weightClass);
986 var outline = this.outline ? 'outline-' : '';
987 if (str == 'default') {
988 this.el.addClass('btn-default btn-outline-secondary');
991 this.el.addClass('btn-' + outline + str);
1005 * @class Roo.bootstrap.Column
1006 * @extends Roo.bootstrap.Component
1007 * Bootstrap Column class
1008 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1009 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1010 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1011 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1012 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1013 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1014 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1015 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1018 * @cfg {Boolean} hidden (true|false) hide the element
1019 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1020 * @cfg {String} fa (ban|check|...) font awesome icon
1021 * @cfg {Number} fasize (1|2|....) font awsome size
1023 * @cfg {String} icon (info-sign|check|...) glyphicon name
1025 * @cfg {String} html content of column.
1028 * Create a new Column
1029 * @param {Object} config The config object
1032 Roo.bootstrap.Column = function(config){
1033 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1036 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1054 getAutoCreate : function(){
1055 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1063 ['xs','sm','md','lg'].map(function(size){
1064 //Roo.log( size + ':' + settings[size]);
1066 if (settings[size+'off'] !== false) {
1067 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1070 if (settings[size] === false) {
1074 if (!settings[size]) { // 0 = hidden
1075 cfg.cls += ' hidden-' + size;
1078 cfg.cls += ' col-' + size + '-' + settings[size];
1083 cfg.cls += ' hidden';
1086 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1087 cfg.cls +=' alert alert-' + this.alert;
1091 if (this.html.length) {
1092 cfg.html = this.html;
1096 if (this.fasize > 1) {
1097 fasize = ' fa-' + this.fasize + 'x';
1099 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1104 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1123 * @class Roo.bootstrap.Container
1124 * @extends Roo.bootstrap.Component
1125 * Bootstrap Container class
1126 * @cfg {Boolean} jumbotron is it a jumbotron element
1127 * @cfg {String} html content of element
1128 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1129 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1130 * @cfg {String} header content of header (for panel)
1131 * @cfg {String} footer content of footer (for panel)
1132 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1133 * @cfg {String} tag (header|aside|section) type of HTML tag.
1134 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1135 * @cfg {String} fa font awesome icon
1136 * @cfg {String} icon (info-sign|check|...) glyphicon name
1137 * @cfg {Boolean} hidden (true|false) hide the element
1138 * @cfg {Boolean} expandable (true|false) default false
1139 * @cfg {Boolean} expanded (true|false) default true
1140 * @cfg {String} rheader contet on the right of header
1141 * @cfg {Boolean} clickable (true|false) default false
1145 * Create a new Container
1146 * @param {Object} config The config object
1149 Roo.bootstrap.Container = function(config){
1150 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1156 * After the panel has been expand
1158 * @param {Roo.bootstrap.Container} this
1163 * After the panel has been collapsed
1165 * @param {Roo.bootstrap.Container} this
1170 * When a element is chick
1171 * @param {Roo.bootstrap.Container} this
1172 * @param {Roo.EventObject} e
1178 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1196 getChildContainer : function() {
1202 if (this.panel.length) {
1203 return this.el.select('.panel-body',true).first();
1210 getAutoCreate : function(){
1213 tag : this.tag || 'div',
1217 if (this.jumbotron) {
1218 cfg.cls = 'jumbotron';
1223 // - this is applied by the parent..
1225 // cfg.cls = this.cls + '';
1228 if (this.sticky.length) {
1230 var bd = Roo.get(document.body);
1231 if (!bd.hasClass('bootstrap-sticky')) {
1232 bd.addClass('bootstrap-sticky');
1233 Roo.select('html',true).setStyle('height', '100%');
1236 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1240 if (this.well.length) {
1241 switch (this.well) {
1244 cfg.cls +=' well well-' +this.well;
1253 cfg.cls += ' hidden';
1257 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1258 cfg.cls +=' alert alert-' + this.alert;
1263 if (this.panel.length) {
1264 cfg.cls += ' panel panel-' + this.panel;
1266 if (this.header.length) {
1270 if(this.expandable){
1272 cfg.cls = cfg.cls + ' expandable';
1276 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1284 cls : 'panel-title',
1285 html : (this.expandable ? ' ' : '') + this.header
1289 cls: 'panel-header-right',
1295 cls : 'panel-heading',
1296 style : this.expandable ? 'cursor: pointer' : '',
1304 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1309 if (this.footer.length) {
1311 cls : 'panel-footer',
1320 body.html = this.html || cfg.html;
1321 // prefix with the icons..
1323 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1326 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1331 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1332 cfg.cls = 'container';
1338 initEvents: function()
1340 if(this.expandable){
1341 var headerEl = this.headerEl();
1344 headerEl.on('click', this.onToggleClick, this);
1349 this.el.on('click', this.onClick, this);
1354 onToggleClick : function()
1356 var headerEl = this.headerEl();
1372 if(this.fireEvent('expand', this)) {
1374 this.expanded = true;
1376 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1378 this.el.select('.panel-body',true).first().removeClass('hide');
1380 var toggleEl = this.toggleEl();
1386 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1391 collapse : function()
1393 if(this.fireEvent('collapse', this)) {
1395 this.expanded = false;
1397 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1398 this.el.select('.panel-body',true).first().addClass('hide');
1400 var toggleEl = this.toggleEl();
1406 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1410 toggleEl : function()
1412 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1416 return this.el.select('.panel-heading .fa',true).first();
1419 headerEl : function()
1421 if(!this.el || !this.panel.length || !this.header.length){
1425 return this.el.select('.panel-heading',true).first()
1430 if(!this.el || !this.panel.length){
1434 return this.el.select('.panel-body',true).first()
1437 titleEl : function()
1439 if(!this.el || !this.panel.length || !this.header.length){
1443 return this.el.select('.panel-title',true).first();
1446 setTitle : function(v)
1448 var titleEl = this.titleEl();
1454 titleEl.dom.innerHTML = v;
1457 getTitle : function()
1460 var titleEl = this.titleEl();
1466 return titleEl.dom.innerHTML;
1469 setRightTitle : function(v)
1471 var t = this.el.select('.panel-header-right',true).first();
1477 t.dom.innerHTML = v;
1480 onClick : function(e)
1484 this.fireEvent('click', this, e);
1497 * @class Roo.bootstrap.Img
1498 * @extends Roo.bootstrap.Component
1499 * Bootstrap Img class
1500 * @cfg {Boolean} imgResponsive false | true
1501 * @cfg {String} border rounded | circle | thumbnail
1502 * @cfg {String} src image source
1503 * @cfg {String} alt image alternative text
1504 * @cfg {String} href a tag href
1505 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1506 * @cfg {String} xsUrl xs image source
1507 * @cfg {String} smUrl sm image source
1508 * @cfg {String} mdUrl md image source
1509 * @cfg {String} lgUrl lg image source
1512 * Create a new Input
1513 * @param {Object} config The config object
1516 Roo.bootstrap.Img = function(config){
1517 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1523 * The img click event for the img.
1524 * @param {Roo.EventObject} e
1530 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1532 imgResponsive: true,
1542 getAutoCreate : function()
1544 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1545 return this.createSingleImg();
1550 cls: 'roo-image-responsive-group',
1555 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1557 if(!_this[size + 'Url']){
1563 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1564 html: _this.html || cfg.html,
1565 src: _this[size + 'Url']
1568 img.cls += ' roo-image-responsive-' + size;
1570 var s = ['xs', 'sm', 'md', 'lg'];
1572 s.splice(s.indexOf(size), 1);
1574 Roo.each(s, function(ss){
1575 img.cls += ' hidden-' + ss;
1578 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1579 cfg.cls += ' img-' + _this.border;
1583 cfg.alt = _this.alt;
1596 a.target = _this.target;
1600 cfg.cn.push((_this.href) ? a : img);
1607 createSingleImg : function()
1611 cls: (this.imgResponsive) ? 'img-responsive' : '',
1613 src : 'about:blank' // just incase src get's set to undefined?!?
1616 cfg.html = this.html || cfg.html;
1618 cfg.src = this.src || cfg.src;
1620 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1621 cfg.cls += ' img-' + this.border;
1638 a.target = this.target;
1643 return (this.href) ? a : cfg;
1646 initEvents: function()
1649 this.el.on('click', this.onClick, this);
1654 onClick : function(e)
1656 Roo.log('img onclick');
1657 this.fireEvent('click', this, e);
1660 * Sets the url of the image - used to update it
1661 * @param {String} url the url of the image
1664 setSrc : function(url)
1668 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1669 this.el.dom.src = url;
1673 this.el.select('img', true).first().dom.src = url;
1689 * @class Roo.bootstrap.Link
1690 * @extends Roo.bootstrap.Component
1691 * Bootstrap Link Class
1692 * @cfg {String} alt image alternative text
1693 * @cfg {String} href a tag href
1694 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1695 * @cfg {String} html the content of the link.
1696 * @cfg {String} anchor name for the anchor link
1697 * @cfg {String} fa - favicon
1699 * @cfg {Boolean} preventDefault (true | false) default false
1703 * Create a new Input
1704 * @param {Object} config The config object
1707 Roo.bootstrap.Link = function(config){
1708 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1714 * The img click event for the img.
1715 * @param {Roo.EventObject} e
1721 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1725 preventDefault: false,
1731 getAutoCreate : function()
1733 var html = this.html || '';
1735 if (this.fa !== false) {
1736 html = '<i class="fa fa-' + this.fa + '"></i>';
1741 // anchor's do not require html/href...
1742 if (this.anchor === false) {
1744 cfg.href = this.href || '#';
1746 cfg.name = this.anchor;
1747 if (this.html !== false || this.fa !== false) {
1750 if (this.href !== false) {
1751 cfg.href = this.href;
1755 if(this.alt !== false){
1760 if(this.target !== false) {
1761 cfg.target = this.target;
1767 initEvents: function() {
1769 if(!this.href || this.preventDefault){
1770 this.el.on('click', this.onClick, this);
1774 onClick : function(e)
1776 if(this.preventDefault){
1779 //Roo.log('img onclick');
1780 this.fireEvent('click', this, e);
1793 * @class Roo.bootstrap.Header
1794 * @extends Roo.bootstrap.Component
1795 * Bootstrap Header class
1796 * @cfg {String} html content of header
1797 * @cfg {Number} level (1|2|3|4|5|6) default 1
1800 * Create a new Header
1801 * @param {Object} config The config object
1805 Roo.bootstrap.Header = function(config){
1806 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1809 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1817 getAutoCreate : function(){
1822 tag: 'h' + (1 *this.level),
1823 html: this.html || ''
1835 * Ext JS Library 1.1.1
1836 * Copyright(c) 2006-2007, Ext JS, LLC.
1838 * Originally Released Under LGPL - original licence link has changed is not relivant.
1841 * <script type="text/javascript">
1845 * @class Roo.bootstrap.MenuMgr
1846 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1849 Roo.bootstrap.MenuMgr = function(){
1850 var menus, active, groups = {}, attached = false, lastShow = new Date();
1852 // private - called when first menu is created
1855 active = new Roo.util.MixedCollection();
1856 Roo.get(document).addKeyListener(27, function(){
1857 if(active.length > 0){
1865 if(active && active.length > 0){
1866 var c = active.clone();
1876 if(active.length < 1){
1877 Roo.get(document).un("mouseup", onMouseDown);
1885 var last = active.last();
1886 lastShow = new Date();
1889 Roo.get(document).on("mouseup", onMouseDown);
1894 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1895 m.parentMenu.activeChild = m;
1896 }else if(last && last.isVisible()){
1897 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1902 function onBeforeHide(m){
1904 m.activeChild.hide();
1906 if(m.autoHideTimer){
1907 clearTimeout(m.autoHideTimer);
1908 delete m.autoHideTimer;
1913 function onBeforeShow(m){
1914 var pm = m.parentMenu;
1915 if(!pm && !m.allowOtherMenus){
1917 }else if(pm && pm.activeChild && active != m){
1918 pm.activeChild.hide();
1922 // private this should really trigger on mouseup..
1923 function onMouseDown(e){
1924 Roo.log("on Mouse Up");
1926 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1927 Roo.log("MenuManager hideAll");
1936 function onBeforeCheck(mi, state){
1938 var g = groups[mi.group];
1939 for(var i = 0, l = g.length; i < l; i++){
1941 g[i].setChecked(false);
1950 * Hides all menus that are currently visible
1952 hideAll : function(){
1957 register : function(menu){
1961 menus[menu.id] = menu;
1962 menu.on("beforehide", onBeforeHide);
1963 menu.on("hide", onHide);
1964 menu.on("beforeshow", onBeforeShow);
1965 menu.on("show", onShow);
1967 if(g && menu.events["checkchange"]){
1971 groups[g].push(menu);
1972 menu.on("checkchange", onCheck);
1977 * Returns a {@link Roo.menu.Menu} object
1978 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1979 * be used to generate and return a new Menu instance.
1981 get : function(menu){
1982 if(typeof menu == "string"){ // menu id
1984 }else if(menu.events){ // menu instance
1987 /*else if(typeof menu.length == 'number'){ // array of menu items?
1988 return new Roo.bootstrap.Menu({items:menu});
1989 }else{ // otherwise, must be a config
1990 return new Roo.bootstrap.Menu(menu);
1997 unregister : function(menu){
1998 delete menus[menu.id];
1999 menu.un("beforehide", onBeforeHide);
2000 menu.un("hide", onHide);
2001 menu.un("beforeshow", onBeforeShow);
2002 menu.un("show", onShow);
2004 if(g && menu.events["checkchange"]){
2005 groups[g].remove(menu);
2006 menu.un("checkchange", onCheck);
2011 registerCheckable : function(menuItem){
2012 var g = menuItem.group;
2017 groups[g].push(menuItem);
2018 menuItem.on("beforecheckchange", onBeforeCheck);
2023 unregisterCheckable : function(menuItem){
2024 var g = menuItem.group;
2026 groups[g].remove(menuItem);
2027 menuItem.un("beforecheckchange", onBeforeCheck);
2039 * @class Roo.bootstrap.Menu
2040 * @extends Roo.bootstrap.Component
2041 * Bootstrap Menu class - container for MenuItems
2042 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2043 * @cfg {bool} hidden if the menu should be hidden when rendered.
2044 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2045 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2049 * @param {Object} config The config object
2053 Roo.bootstrap.Menu = function(config){
2054 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2055 if (this.registerMenu && this.type != 'treeview') {
2056 Roo.bootstrap.MenuMgr.register(this);
2063 * Fires before this menu is displayed (return false to block)
2064 * @param {Roo.menu.Menu} this
2069 * Fires before this menu is hidden (return false to block)
2070 * @param {Roo.menu.Menu} this
2075 * Fires after this menu is displayed
2076 * @param {Roo.menu.Menu} this
2081 * Fires after this menu is hidden
2082 * @param {Roo.menu.Menu} this
2087 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2088 * @param {Roo.menu.Menu} this
2089 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2090 * @param {Roo.EventObject} e
2095 * Fires when the mouse is hovering over this menu
2096 * @param {Roo.menu.Menu} this
2097 * @param {Roo.EventObject} e
2098 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2103 * Fires when the mouse exits this menu
2104 * @param {Roo.menu.Menu} this
2105 * @param {Roo.EventObject} e
2106 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2111 * Fires when a menu item contained in this menu is clicked
2112 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2113 * @param {Roo.EventObject} e
2117 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2120 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2124 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2127 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2129 registerMenu : true,
2131 menuItems :false, // stores the menu items..
2141 getChildContainer : function() {
2145 getAutoCreate : function(){
2147 //if (['right'].indexOf(this.align)!==-1) {
2148 // cfg.cn[1].cls += ' pull-right'
2154 cls : 'dropdown-menu' ,
2155 style : 'z-index:1000'
2159 if (this.type === 'submenu') {
2160 cfg.cls = 'submenu active';
2162 if (this.type === 'treeview') {
2163 cfg.cls = 'treeview-menu';
2168 initEvents : function() {
2170 // Roo.log("ADD event");
2171 // Roo.log(this.triggerEl.dom);
2173 this.triggerEl.on('click', this.onTriggerClick, this);
2175 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2178 if (this.triggerEl.hasClass('nav-item')) {
2179 // dropdown toggle on the 'a' in BS4?
2180 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2182 this.triggerEl.addClass('dropdown-toggle');
2185 this.el.on('touchstart' , this.onTouch, this);
2187 this.el.on('click' , this.onClick, this);
2189 this.el.on("mouseover", this.onMouseOver, this);
2190 this.el.on("mouseout", this.onMouseOut, this);
2194 findTargetItem : function(e)
2196 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2200 //Roo.log(t); Roo.log(t.id);
2202 //Roo.log(this.menuitems);
2203 return this.menuitems.get(t.id);
2205 //return this.items.get(t.menuItemId);
2211 onTouch : function(e)
2213 Roo.log("menu.onTouch");
2214 //e.stopEvent(); this make the user popdown broken
2218 onClick : function(e)
2220 Roo.log("menu.onClick");
2222 var t = this.findTargetItem(e);
2223 if(!t || t.isContainer){
2228 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2229 if(t == this.activeItem && t.shouldDeactivate(e)){
2230 this.activeItem.deactivate();
2231 delete this.activeItem;
2235 this.setActiveItem(t, true);
2243 Roo.log('pass click event');
2247 this.fireEvent("click", this, t, e);
2251 if(!t.href.length || t.href == '#'){
2252 (function() { _this.hide(); }).defer(100);
2257 onMouseOver : function(e){
2258 var t = this.findTargetItem(e);
2261 // if(t.canActivate && !t.disabled){
2262 // this.setActiveItem(t, true);
2266 this.fireEvent("mouseover", this, e, t);
2268 isVisible : function(){
2269 return !this.hidden;
2271 onMouseOut : function(e){
2272 var t = this.findTargetItem(e);
2275 // if(t == this.activeItem && t.shouldDeactivate(e)){
2276 // this.activeItem.deactivate();
2277 // delete this.activeItem;
2280 this.fireEvent("mouseout", this, e, t);
2285 * Displays this menu relative to another element
2286 * @param {String/HTMLElement/Roo.Element} element The element to align to
2287 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2288 * the element (defaults to this.defaultAlign)
2289 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2291 show : function(el, pos, parentMenu)
2293 if (false === this.fireEvent("beforeshow", this)) {
2294 Roo.log("show canceled");
2297 this.parentMenu = parentMenu;
2302 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2305 * Displays this menu at a specific xy position
2306 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2307 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2309 showAt : function(xy, parentMenu, /* private: */_e){
2310 this.parentMenu = parentMenu;
2315 this.fireEvent("beforeshow", this);
2316 //xy = this.el.adjustForConstraints(xy);
2320 this.hideMenuItems();
2321 this.hidden = false;
2322 this.triggerEl.addClass('open');
2323 this.el.addClass('show');
2325 // reassign x when hitting right
2326 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2327 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2330 // reassign y when hitting bottom
2331 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2332 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2335 // but the list may align on trigger left or trigger top... should it be a properity?
2337 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2342 this.fireEvent("show", this);
2348 this.doFocus.defer(50, this);
2352 doFocus : function(){
2354 this.focusEl.focus();
2359 * Hides this menu and optionally all parent menus
2360 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2362 hide : function(deep)
2364 if (false === this.fireEvent("beforehide", this)) {
2365 Roo.log("hide canceled");
2368 this.hideMenuItems();
2369 if(this.el && this.isVisible()){
2371 if(this.activeItem){
2372 this.activeItem.deactivate();
2373 this.activeItem = null;
2375 this.triggerEl.removeClass('open');;
2376 this.el.removeClass('show');
2378 this.fireEvent("hide", this);
2380 if(deep === true && this.parentMenu){
2381 this.parentMenu.hide(true);
2385 onTriggerClick : function(e)
2387 Roo.log('trigger click');
2389 var target = e.getTarget();
2391 Roo.log(target.nodeName.toLowerCase());
2393 if(target.nodeName.toLowerCase() === 'i'){
2399 onTriggerPress : function(e)
2401 Roo.log('trigger press');
2402 //Roo.log(e.getTarget());
2403 // Roo.log(this.triggerEl.dom);
2405 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2406 var pel = Roo.get(e.getTarget());
2407 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2408 Roo.log('is treeview or dropdown?');
2412 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2416 if (this.isVisible()) {
2421 this.show(this.triggerEl, '?', false);
2424 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2431 hideMenuItems : function()
2433 Roo.log("hide Menu Items");
2438 this.el.select('.open',true).each(function(aa) {
2440 aa.removeClass('open');
2444 addxtypeChild : function (tree, cntr) {
2445 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2447 this.menuitems.add(comp);
2459 this.getEl().dom.innerHTML = '';
2460 this.menuitems.clear();
2474 * @class Roo.bootstrap.MenuItem
2475 * @extends Roo.bootstrap.Component
2476 * Bootstrap MenuItem class
2477 * @cfg {String} html the menu label
2478 * @cfg {String} href the link
2479 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2480 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2481 * @cfg {Boolean} active used on sidebars to highlight active itesm
2482 * @cfg {String} fa favicon to show on left of menu item.
2483 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2487 * Create a new MenuItem
2488 * @param {Object} config The config object
2492 Roo.bootstrap.MenuItem = function(config){
2493 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2498 * The raw click event for the entire grid.
2499 * @param {Roo.bootstrap.MenuItem} this
2500 * @param {Roo.EventObject} e
2506 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2510 preventDefault: false,
2511 isContainer : false,
2515 getAutoCreate : function(){
2517 if(this.isContainer){
2520 cls: 'dropdown-menu-item '
2530 cls : 'dropdown-item',
2535 if (this.fa !== false) {
2538 cls : 'fa fa-' + this.fa
2547 cls: 'dropdown-menu-item',
2550 if (this.parent().type == 'treeview') {
2551 cfg.cls = 'treeview-menu';
2554 cfg.cls += ' active';
2559 anc.href = this.href || cfg.cn[0].href ;
2560 ctag.html = this.html || cfg.cn[0].html ;
2564 initEvents: function()
2566 if (this.parent().type == 'treeview') {
2567 this.el.select('a').on('click', this.onClick, this);
2571 this.menu.parentType = this.xtype;
2572 this.menu.triggerEl = this.el;
2573 this.menu = this.addxtype(Roo.apply({}, this.menu));
2577 onClick : function(e)
2579 Roo.log('item on click ');
2581 if(this.preventDefault){
2584 //this.parent().hideMenuItems();
2586 this.fireEvent('click', this, e);
2605 * @class Roo.bootstrap.MenuSeparator
2606 * @extends Roo.bootstrap.Component
2607 * Bootstrap MenuSeparator class
2610 * Create a new MenuItem
2611 * @param {Object} config The config object
2615 Roo.bootstrap.MenuSeparator = function(config){
2616 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2619 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2621 getAutoCreate : function(){
2640 * @class Roo.bootstrap.Modal
2641 * @extends Roo.bootstrap.Component
2642 * Bootstrap Modal class
2643 * @cfg {String} title Title of dialog
2644 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2645 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2646 * @cfg {Boolean} specificTitle default false
2647 * @cfg {Array} buttons Array of buttons or standard button set..
2648 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2649 * @cfg {Boolean} animate default true
2650 * @cfg {Boolean} allow_close default true
2651 * @cfg {Boolean} fitwindow default false
2652 * @cfg {String} size (sm|lg) default empty
2653 * @cfg {Number} max_width set the max width of modal
2657 * Create a new Modal Dialog
2658 * @param {Object} config The config object
2661 Roo.bootstrap.Modal = function(config){
2662 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2667 * The raw btnclick event for the button
2668 * @param {Roo.EventObject} e
2673 * Fire when dialog resize
2674 * @param {Roo.bootstrap.Modal} this
2675 * @param {Roo.EventObject} e
2679 this.buttons = this.buttons || [];
2682 this.tmpl = Roo.factory(this.tmpl);
2687 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2689 title : 'test dialog',
2699 specificTitle: false,
2701 buttonPosition: 'right',
2724 onRender : function(ct, position)
2726 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2729 var cfg = Roo.apply({}, this.getAutoCreate());
2732 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2734 //if (!cfg.name.length) {
2738 cfg.cls += ' ' + this.cls;
2741 cfg.style = this.style;
2743 this.el = Roo.get(document.body).createChild(cfg, position);
2745 //var type = this.el.dom.type;
2748 if(this.tabIndex !== undefined){
2749 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2752 this.dialogEl = this.el.select('.modal-dialog',true).first();
2753 this.bodyEl = this.el.select('.modal-body',true).first();
2754 this.closeEl = this.el.select('.modal-header .close', true).first();
2755 this.headerEl = this.el.select('.modal-header',true).first();
2756 this.titleEl = this.el.select('.modal-title',true).first();
2757 this.footerEl = this.el.select('.modal-footer',true).first();
2759 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2761 //this.el.addClass("x-dlg-modal");
2763 if (this.buttons.length) {
2764 Roo.each(this.buttons, function(bb) {
2765 var b = Roo.apply({}, bb);
2766 b.xns = b.xns || Roo.bootstrap;
2767 b.xtype = b.xtype || 'Button';
2768 if (typeof(b.listeners) == 'undefined') {
2769 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2772 var btn = Roo.factory(b);
2774 btn.render(this.getButtonContainer());
2778 // render the children.
2781 if(typeof(this.items) != 'undefined'){
2782 var items = this.items;
2785 for(var i =0;i < items.length;i++) {
2786 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2790 this.items = nitems;
2792 // where are these used - they used to be body/close/footer
2796 //this.el.addClass([this.fieldClass, this.cls]);
2800 getAutoCreate : function()
2804 html : this.html || ''
2809 cls : 'modal-title',
2813 if(this.specificTitle){
2819 if (this.allow_close && Roo.bootstrap.version == 3) {
2829 if (this.allow_close && Roo.bootstrap.version == 4) {
2839 if(this.size.length){
2840 size = 'modal-' + this.size;
2843 var footer = Roo.bootstrap.version == 3 ?
2845 cls : 'modal-footer',
2849 cls: 'btn-' + this.buttonPosition
2854 { // BS4 uses mr-auto on left buttons....
2855 cls : 'modal-footer'
2866 cls: "modal-dialog " + size,
2869 cls : "modal-content",
2872 cls : 'modal-header',
2887 modal.cls += ' fade';
2893 getChildContainer : function() {
2898 getButtonContainer : function() {
2900 return Roo.bootstrap.version == 4 ?
2901 this.el.select('.modal-footer',true).first()
2902 : this.el.select('.modal-footer div',true).first();
2905 initEvents : function()
2907 if (this.allow_close) {
2908 this.closeEl.on('click', this.hide, this);
2910 Roo.EventManager.onWindowResize(this.resize, this, true);
2918 this.maskEl.setSize(
2919 Roo.lib.Dom.getViewWidth(true),
2920 Roo.lib.Dom.getViewHeight(true)
2923 if (this.fitwindow) {
2927 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2928 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2933 if(this.max_width !== 0) {
2935 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2938 this.setSize(w, this.height);
2942 if(this.max_height) {
2943 this.setSize(w,Math.min(
2945 Roo.lib.Dom.getViewportHeight(true) - 60
2951 if(!this.fit_content) {
2952 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2956 this.setSize(w, Math.min(
2958 this.headerEl.getHeight() +
2959 this.footerEl.getHeight() +
2960 this.getChildHeight(this.bodyEl.dom.childNodes),
2961 Roo.lib.Dom.getViewportHeight(true) - 60)
2967 setSize : function(w,h)
2978 if (!this.rendered) {
2982 //this.el.setStyle('display', 'block');
2983 this.el.removeClass('hideing');
2984 this.el.dom.style.display='block';
2986 Roo.get(document.body).addClass('modal-open');
2988 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2991 this.el.addClass('show');
2992 this.el.addClass('in');
2995 this.el.addClass('show');
2996 this.el.addClass('in');
2999 // not sure how we can show data in here..
3001 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3004 Roo.get(document.body).addClass("x-body-masked");
3006 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3007 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3008 this.maskEl.dom.style.display = 'block';
3009 this.maskEl.addClass('show');
3014 this.fireEvent('show', this);
3016 // set zindex here - otherwise it appears to be ignored...
3017 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3020 this.items.forEach( function(e) {
3021 e.layout ? e.layout() : false;
3029 if(this.fireEvent("beforehide", this) !== false){
3031 this.maskEl.removeClass('show');
3033 this.maskEl.dom.style.display = '';
3034 Roo.get(document.body).removeClass("x-body-masked");
3035 this.el.removeClass('in');
3036 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3038 if(this.animate){ // why
3039 this.el.addClass('hideing');
3040 this.el.removeClass('show');
3042 if (!this.el.hasClass('hideing')) {
3043 return; // it's been shown again...
3046 this.el.dom.style.display='';
3048 Roo.get(document.body).removeClass('modal-open');
3049 this.el.removeClass('hideing');
3053 this.el.removeClass('show');
3054 this.el.dom.style.display='';
3055 Roo.get(document.body).removeClass('modal-open');
3058 this.fireEvent('hide', this);
3061 isVisible : function()
3064 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3068 addButton : function(str, cb)
3072 var b = Roo.apply({}, { html : str } );
3073 b.xns = b.xns || Roo.bootstrap;
3074 b.xtype = b.xtype || 'Button';
3075 if (typeof(b.listeners) == 'undefined') {
3076 b.listeners = { click : cb.createDelegate(this) };
3079 var btn = Roo.factory(b);
3081 btn.render(this.getButtonContainer());
3087 setDefaultButton : function(btn)
3089 //this.el.select('.modal-footer').()
3092 resizeTo: function(w,h)
3094 this.dialogEl.setWidth(w);
3096 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3098 this.bodyEl.setHeight(h - diff);
3100 this.fireEvent('resize', this);
3103 setContentSize : function(w, h)
3107 onButtonClick: function(btn,e)
3110 this.fireEvent('btnclick', btn.name, e);
3113 * Set the title of the Dialog
3114 * @param {String} str new Title
3116 setTitle: function(str) {
3117 this.titleEl.dom.innerHTML = str;
3120 * Set the body of the Dialog
3121 * @param {String} str new Title
3123 setBody: function(str) {
3124 this.bodyEl.dom.innerHTML = str;
3127 * Set the body of the Dialog using the template
3128 * @param {Obj} data - apply this data to the template and replace the body contents.
3130 applyBody: function(obj)
3133 Roo.log("Error - using apply Body without a template");
3136 this.tmpl.overwrite(this.bodyEl, obj);
3139 getChildHeight : function(child_nodes)
3143 child_nodes.length == 0
3148 var child_height = 0;
3150 for(var i = 0; i < child_nodes.length; i++) {
3153 * for modal with tabs...
3154 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3156 var layout_childs = child_nodes[i].childNodes;
3158 for(var j = 0; j < layout_childs.length; j++) {
3160 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3162 var layout_body_childs = layout_childs[j].childNodes;
3164 for(var k = 0; k < layout_body_childs.length; k++) {
3166 if(layout_body_childs[k].classList.contains('navbar')) {
3167 child_height += layout_body_childs[k].offsetHeight;
3171 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3173 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3175 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3177 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3178 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3193 child_height += child_nodes[i].offsetHeight;
3194 // Roo.log(child_nodes[i].offsetHeight);
3197 return child_height;
3203 Roo.apply(Roo.bootstrap.Modal, {
3205 * Button config that displays a single OK button
3214 * Button config that displays Yes and No buttons
3230 * Button config that displays OK and Cancel buttons
3245 * Button config that displays Yes, No and Cancel buttons
3269 * messagebox - can be used as a replace
3273 * @class Roo.MessageBox
3274 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3278 Roo.Msg.alert('Status', 'Changes saved successfully.');
3280 // Prompt for user data:
3281 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3283 // process text value...
3287 // Show a dialog using config options:
3289 title:'Save Changes?',
3290 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3291 buttons: Roo.Msg.YESNOCANCEL,
3298 Roo.bootstrap.MessageBox = function(){
3299 var dlg, opt, mask, waitTimer;
3300 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3301 var buttons, activeTextEl, bwidth;
3305 var handleButton = function(button){
3307 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3311 var handleHide = function(){
3313 dlg.el.removeClass(opt.cls);
3316 // Roo.TaskMgr.stop(waitTimer);
3317 // waitTimer = null;
3322 var updateButtons = function(b){
3325 buttons["ok"].hide();
3326 buttons["cancel"].hide();
3327 buttons["yes"].hide();
3328 buttons["no"].hide();
3329 dlg.footerEl.hide();
3333 dlg.footerEl.show();
3334 for(var k in buttons){
3335 if(typeof buttons[k] != "function"){
3338 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3339 width += buttons[k].el.getWidth()+15;
3349 var handleEsc = function(d, k, e){
3350 if(opt && opt.closable !== false){
3360 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3361 * @return {Roo.BasicDialog} The BasicDialog element
3363 getDialog : function(){
3365 dlg = new Roo.bootstrap.Modal( {
3368 //constraintoviewport:false,
3370 //collapsible : false,
3375 //buttonAlign:"center",
3376 closeClick : function(){
3377 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3380 handleButton("cancel");
3385 dlg.on("hide", handleHide);
3387 //dlg.addKeyListener(27, handleEsc);
3389 this.buttons = buttons;
3390 var bt = this.buttonText;
3391 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3392 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3393 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3394 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3396 bodyEl = dlg.bodyEl.createChild({
3398 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3399 '<textarea class="roo-mb-textarea"></textarea>' +
3400 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3402 msgEl = bodyEl.dom.firstChild;
3403 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3404 textboxEl.enableDisplayMode();
3405 textboxEl.addKeyListener([10,13], function(){
3406 if(dlg.isVisible() && opt && opt.buttons){
3409 }else if(opt.buttons.yes){
3410 handleButton("yes");
3414 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3415 textareaEl.enableDisplayMode();
3416 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3417 progressEl.enableDisplayMode();
3419 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3420 var pf = progressEl.dom.firstChild;
3422 pp = Roo.get(pf.firstChild);
3423 pp.setHeight(pf.offsetHeight);
3431 * Updates the message box body text
3432 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3433 * the XHTML-compliant non-breaking space character '&#160;')
3434 * @return {Roo.MessageBox} This message box
3436 updateText : function(text)
3438 if(!dlg.isVisible() && !opt.width){
3439 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3440 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3442 msgEl.innerHTML = text || ' ';
3444 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3445 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3447 Math.min(opt.width || cw , this.maxWidth),
3448 Math.max(opt.minWidth || this.minWidth, bwidth)
3451 activeTextEl.setWidth(w);
3453 if(dlg.isVisible()){
3454 dlg.fixedcenter = false;
3456 // to big, make it scroll. = But as usual stupid IE does not support
3459 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3460 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3461 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3463 bodyEl.dom.style.height = '';
3464 bodyEl.dom.style.overflowY = '';
3467 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3469 bodyEl.dom.style.overflowX = '';
3472 dlg.setContentSize(w, bodyEl.getHeight());
3473 if(dlg.isVisible()){
3474 dlg.fixedcenter = true;
3480 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3481 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3482 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3483 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3484 * @return {Roo.MessageBox} This message box
3486 updateProgress : function(value, text){
3488 this.updateText(text);
3491 if (pp) { // weird bug on my firefox - for some reason this is not defined
3492 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3493 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3499 * Returns true if the message box is currently displayed
3500 * @return {Boolean} True if the message box is visible, else false
3502 isVisible : function(){
3503 return dlg && dlg.isVisible();
3507 * Hides the message box if it is displayed
3510 if(this.isVisible()){
3516 * Displays a new message box, or reinitializes an existing message box, based on the config options
3517 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3518 * The following config object properties are supported:
3520 Property Type Description
3521 ---------- --------------- ------------------------------------------------------------------------------------
3522 animEl String/Element An id or Element from which the message box should animate as it opens and
3523 closes (defaults to undefined)
3524 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3525 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3526 closable Boolean False to hide the top-right close button (defaults to true). Note that
3527 progress and wait dialogs will ignore this property and always hide the
3528 close button as they can only be closed programmatically.
3529 cls String A custom CSS class to apply to the message box element
3530 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3531 displayed (defaults to 75)
3532 fn Function A callback function to execute after closing the dialog. The arguments to the
3533 function will be btn (the name of the button that was clicked, if applicable,
3534 e.g. "ok"), and text (the value of the active text field, if applicable).
3535 Progress and wait dialogs will ignore this option since they do not respond to
3536 user actions and can only be closed programmatically, so any required function
3537 should be called by the same code after it closes the dialog.
3538 icon String A CSS class that provides a background image to be used as an icon for
3539 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3540 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3541 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3542 modal Boolean False to allow user interaction with the page while the message box is
3543 displayed (defaults to true)
3544 msg String A string that will replace the existing message box body text (defaults
3545 to the XHTML-compliant non-breaking space character ' ')
3546 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3547 progress Boolean True to display a progress bar (defaults to false)
3548 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3549 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3550 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3551 title String The title text
3552 value String The string value to set into the active textbox element if displayed
3553 wait Boolean True to display a progress bar (defaults to false)
3554 width Number The width of the dialog in pixels
3561 msg: 'Please enter your address:',
3563 buttons: Roo.MessageBox.OKCANCEL,
3566 animEl: 'addAddressBtn'
3569 * @param {Object} config Configuration options
3570 * @return {Roo.MessageBox} This message box
3572 show : function(options)
3575 // this causes nightmares if you show one dialog after another
3576 // especially on callbacks..
3578 if(this.isVisible()){
3581 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3582 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3583 Roo.log("New Dialog Message:" + options.msg )
3584 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3585 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3588 var d = this.getDialog();
3590 d.setTitle(opt.title || " ");
3591 d.closeEl.setDisplayed(opt.closable !== false);
3592 activeTextEl = textboxEl;
3593 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3598 textareaEl.setHeight(typeof opt.multiline == "number" ?
3599 opt.multiline : this.defaultTextHeight);
3600 activeTextEl = textareaEl;
3609 progressEl.setDisplayed(opt.progress === true);
3611 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3613 this.updateProgress(0);
3614 activeTextEl.dom.value = opt.value || "";
3616 dlg.setDefaultButton(activeTextEl);
3618 var bs = opt.buttons;
3622 }else if(bs && bs.yes){
3623 db = buttons["yes"];
3625 dlg.setDefaultButton(db);
3627 bwidth = updateButtons(opt.buttons);
3628 this.updateText(opt.msg);
3630 d.el.addClass(opt.cls);
3632 d.proxyDrag = opt.proxyDrag === true;
3633 d.modal = opt.modal !== false;
3634 d.mask = opt.modal !== false ? mask : false;
3636 // force it to the end of the z-index stack so it gets a cursor in FF
3637 document.body.appendChild(dlg.el.dom);
3638 d.animateTarget = null;
3639 d.show(options.animEl);
3645 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3646 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3647 * and closing the message box when the process is complete.
3648 * @param {String} title The title bar text
3649 * @param {String} msg The message box body text
3650 * @return {Roo.MessageBox} This message box
3652 progress : function(title, msg){
3659 minWidth: this.minProgressWidth,
3666 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3667 * If a callback function is passed it will be called after the user clicks the button, and the
3668 * id of the button that was clicked will be passed as the only parameter to the callback
3669 * (could also be the top-right close button).
3670 * @param {String} title The title bar text
3671 * @param {String} msg The message box body text
3672 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3673 * @param {Object} scope (optional) The scope of the callback function
3674 * @return {Roo.MessageBox} This message box
3676 alert : function(title, msg, fn, scope)
3691 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3692 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3693 * You are responsible for closing the message box when the process is complete.
3694 * @param {String} msg The message box body text
3695 * @param {String} title (optional) The title bar text
3696 * @return {Roo.MessageBox} This message box
3698 wait : function(msg, title){
3709 waitTimer = Roo.TaskMgr.start({
3711 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3719 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3720 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3721 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3722 * @param {String} title The title bar text
3723 * @param {String} msg The message box body text
3724 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3725 * @param {Object} scope (optional) The scope of the callback function
3726 * @return {Roo.MessageBox} This message box
3728 confirm : function(title, msg, fn, scope){
3732 buttons: this.YESNO,
3741 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3742 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3743 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3744 * (could also be the top-right close button) and the text that was entered will be passed as the two
3745 * parameters to the callback.
3746 * @param {String} title The title bar text
3747 * @param {String} msg The message box body text
3748 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3749 * @param {Object} scope (optional) The scope of the callback function
3750 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3751 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3752 * @return {Roo.MessageBox} This message box
3754 prompt : function(title, msg, fn, scope, multiline){
3758 buttons: this.OKCANCEL,
3763 multiline: multiline,
3770 * Button config that displays a single OK button
3775 * Button config that displays Yes and No buttons
3778 YESNO : {yes:true, no:true},
3780 * Button config that displays OK and Cancel buttons
3783 OKCANCEL : {ok:true, cancel:true},
3785 * Button config that displays Yes, No and Cancel buttons
3788 YESNOCANCEL : {yes:true, no:true, cancel:true},
3791 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3794 defaultTextHeight : 75,
3796 * The maximum width in pixels of the message box (defaults to 600)
3801 * The minimum width in pixels of the message box (defaults to 100)
3806 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3807 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3810 minProgressWidth : 250,
3812 * An object containing the default button text strings that can be overriden for localized language support.
3813 * Supported properties are: ok, cancel, yes and no.
3814 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3827 * Shorthand for {@link Roo.MessageBox}
3829 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3830 Roo.Msg = Roo.Msg || Roo.MessageBox;
3839 * @class Roo.bootstrap.Navbar
3840 * @extends Roo.bootstrap.Component
3841 * Bootstrap Navbar class
3844 * Create a new Navbar
3845 * @param {Object} config The config object
3849 Roo.bootstrap.Navbar = function(config){
3850 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3854 * @event beforetoggle
3855 * Fire before toggle the menu
3856 * @param {Roo.EventObject} e
3858 "beforetoggle" : true
3862 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3871 getAutoCreate : function(){
3874 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3878 initEvents :function ()
3880 //Roo.log(this.el.select('.navbar-toggle',true));
3881 this.el.select('.navbar-toggle',true).on('click', function() {
3882 if(this.fireEvent('beforetoggle', this) !== false){
3883 var ce = this.el.select('.navbar-collapse',true).first();
3884 ce.toggleClass('in'); // old...
3885 if (ce.hasClass('collapse')) {
3887 ce.removeClass('collapse');
3888 ce.addClass('show');
3889 var h = ce.getHeight();
3891 ce.removeClass('show');
3892 // at this point we should be able to see it..
3893 ce.addClass('collapsing');
3895 ce.setHeight(0); // resize it ...
3896 ce.on('transitionend', function() {
3897 Roo.log('done transition');
3898 ce.removeClass('collapsing');
3899 ce.addClass('show');
3900 ce.removeClass('collapse');
3902 ce.dom.style.height = '';
3903 }, this, { single: true} );
3907 ce.setHeight(ce.getHeight());
3908 ce.removeClass('show');
3909 ce.addClass('collapsing');
3911 ce.on('transitionend', function() {
3912 ce.dom.style.height = '';
3913 ce.removeClass('collapsing');
3914 ce.addClass('collapse');
3915 }, this, { single: true} );
3927 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3929 var size = this.el.getSize();
3930 this.maskEl.setSize(size.width, size.height);
3931 this.maskEl.enableDisplayMode("block");
3940 getChildContainer : function()
3942 if (this.el && this.el.select('.collapse').getCount()) {
3943 return this.el.select('.collapse',true).first();
3976 * @class Roo.bootstrap.NavSimplebar
3977 * @extends Roo.bootstrap.Navbar
3978 * Bootstrap Sidebar class
3980 * @cfg {Boolean} inverse is inverted color
3982 * @cfg {String} type (nav | pills | tabs)
3983 * @cfg {Boolean} arrangement stacked | justified
3984 * @cfg {String} align (left | right) alignment
3986 * @cfg {Boolean} main (true|false) main nav bar? default false
3987 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3989 * @cfg {String} tag (header|footer|nav|div) default is nav
3991 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
3995 * Create a new Sidebar
3996 * @param {Object} config The config object
4000 Roo.bootstrap.NavSimplebar = function(config){
4001 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4004 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4020 getAutoCreate : function(){
4024 tag : this.tag || 'div',
4025 cls : 'navbar navbar-expand-lg roo-navbar-simple'
4027 if (['light','white'].indexOf(this.weight) > -1) {
4028 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4030 cfg.cls += ' bg-' + this.weight;
4033 cfg.cls += ' navbar-inverse';
4037 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4039 //if (Roo.bootstrap.version == 4) {
4051 this.type = this.type || 'nav';
4052 if (['tabs','pills'].indexOf(this.type) != -1) {
4053 cfg.cn[0].cls += ' nav-' + this.type
4057 if (this.type!=='nav') {
4058 Roo.log('nav type must be nav/tabs/pills')
4060 cfg.cn[0].cls += ' navbar-nav'
4066 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4067 cfg.cn[0].cls += ' nav-' + this.arrangement;
4071 if (this.align === 'right') {
4072 cfg.cn[0].cls += ' navbar-right';
4097 * navbar-expand-md fixed-top
4101 * @class Roo.bootstrap.NavHeaderbar
4102 * @extends Roo.bootstrap.NavSimplebar
4103 * Bootstrap Sidebar class
4105 * @cfg {String} brand what is brand
4106 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4107 * @cfg {String} brand_href href of the brand
4108 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4109 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4110 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4111 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4114 * Create a new Sidebar
4115 * @param {Object} config The config object
4119 Roo.bootstrap.NavHeaderbar = function(config){
4120 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4124 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4131 desktopCenter : false,
4134 getAutoCreate : function(){
4137 tag: this.nav || 'nav',
4138 cls: 'navbar navbar-expand-md',
4144 if (this.desktopCenter) {
4145 cn.push({cls : 'container', cn : []});
4153 cls: 'navbar-toggle navbar-toggler',
4154 'data-toggle': 'collapse',
4159 html: 'Toggle navigation'
4163 cls: 'icon-bar navbar-toggler-icon'
4176 cn.push( Roo.bootstrap.version == 4 ? btn : {
4178 cls: 'navbar-header',
4187 cls: 'collapse navbar-collapse',
4191 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4193 if (['light','white'].indexOf(this.weight) > -1) {
4194 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4196 cfg.cls += ' bg-' + this.weight;
4199 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4200 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4202 // tag can override this..
4204 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4207 if (this.brand !== '') {
4208 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4209 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4211 href: this.brand_href ? this.brand_href : '#',
4212 cls: 'navbar-brand',
4220 cfg.cls += ' main-nav';
4228 getHeaderChildContainer : function()
4230 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4231 return this.el.select('.navbar-header',true).first();
4234 return this.getChildContainer();
4238 initEvents : function()
4240 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4242 if (this.autohide) {
4247 Roo.get(document).on('scroll',function(e) {
4248 var ns = Roo.get(document).getScroll().top;
4249 var os = prevScroll;
4253 ft.removeClass('slideDown');
4254 ft.addClass('slideUp');
4257 ft.removeClass('slideUp');
4258 ft.addClass('slideDown');
4279 * @class Roo.bootstrap.NavSidebar
4280 * @extends Roo.bootstrap.Navbar
4281 * Bootstrap Sidebar class
4284 * Create a new Sidebar
4285 * @param {Object} config The config object
4289 Roo.bootstrap.NavSidebar = function(config){
4290 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4293 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4295 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4297 getAutoCreate : function(){
4302 cls: 'sidebar sidebar-nav'
4324 * @class Roo.bootstrap.NavGroup
4325 * @extends Roo.bootstrap.Component
4326 * Bootstrap NavGroup class
4327 * @cfg {String} align (left|right)
4328 * @cfg {Boolean} inverse
4329 * @cfg {String} type (nav|pills|tab) default nav
4330 * @cfg {String} navId - reference Id for navbar.
4334 * Create a new nav group
4335 * @param {Object} config The config object
4338 Roo.bootstrap.NavGroup = function(config){
4339 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4342 Roo.bootstrap.NavGroup.register(this);
4346 * Fires when the active item changes
4347 * @param {Roo.bootstrap.NavGroup} this
4348 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4349 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4356 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4367 getAutoCreate : function()
4369 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4375 if (Roo.bootstrap.version == 4) {
4376 if (['tabs','pills'].indexOf(this.type) != -1) {
4377 cfg.cls += ' nav-' + this.type;
4379 cfg.cls += ' navbar-nav';
4382 if (['tabs','pills'].indexOf(this.type) != -1) {
4383 cfg.cls += ' nav-' + this.type
4385 if (this.type !== 'nav') {
4386 Roo.log('nav type must be nav/tabs/pills')
4388 cfg.cls += ' navbar-nav'
4392 if (this.parent() && this.parent().sidebar) {
4395 cls: 'dashboard-menu sidebar-menu'
4401 if (this.form === true) {
4404 cls: 'navbar-form form-inline'
4407 if (this.align === 'right') {
4408 cfg.cls += ' navbar-right ml-md-auto';
4410 cfg.cls += ' navbar-left';
4414 if (this.align === 'right') {
4415 cfg.cls += ' navbar-right ml-md-auto';
4417 cfg.cls += ' mr-auto';
4421 cfg.cls += ' navbar-inverse';
4429 * sets the active Navigation item
4430 * @param {Roo.bootstrap.NavItem} the new current navitem
4432 setActiveItem : function(item)
4435 Roo.each(this.navItems, function(v){
4440 v.setActive(false, true);
4447 item.setActive(true, true);
4448 this.fireEvent('changed', this, item, prev);
4453 * gets the active Navigation item
4454 * @return {Roo.bootstrap.NavItem} the current navitem
4456 getActive : function()
4460 Roo.each(this.navItems, function(v){
4471 indexOfNav : function()
4475 Roo.each(this.navItems, function(v,i){
4486 * adds a Navigation item
4487 * @param {Roo.bootstrap.NavItem} the navitem to add
4489 addItem : function(cfg)
4491 if (this.form && Roo.bootstrap.version == 4) {
4494 var cn = new Roo.bootstrap.NavItem(cfg);
4496 cn.parentId = this.id;
4497 cn.onRender(this.el, null);
4501 * register a Navigation item
4502 * @param {Roo.bootstrap.NavItem} the navitem to add
4504 register : function(item)
4506 this.navItems.push( item);
4507 item.navId = this.navId;
4512 * clear all the Navigation item
4515 clearAll : function()
4518 this.el.dom.innerHTML = '';
4521 getNavItem: function(tabId)
4524 Roo.each(this.navItems, function(e) {
4525 if (e.tabId == tabId) {
4535 setActiveNext : function()
4537 var i = this.indexOfNav(this.getActive());
4538 if (i > this.navItems.length) {
4541 this.setActiveItem(this.navItems[i+1]);
4543 setActivePrev : function()
4545 var i = this.indexOfNav(this.getActive());
4549 this.setActiveItem(this.navItems[i-1]);
4551 clearWasActive : function(except) {
4552 Roo.each(this.navItems, function(e) {
4553 if (e.tabId != except.tabId && e.was_active) {
4554 e.was_active = false;
4561 getWasActive : function ()
4564 Roo.each(this.navItems, function(e) {
4579 Roo.apply(Roo.bootstrap.NavGroup, {
4583 * register a Navigation Group
4584 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4586 register : function(navgrp)
4588 this.groups[navgrp.navId] = navgrp;
4592 * fetch a Navigation Group based on the navigation ID
4593 * @param {string} the navgroup to add
4594 * @returns {Roo.bootstrap.NavGroup} the navgroup
4596 get: function(navId) {
4597 if (typeof(this.groups[navId]) == 'undefined') {
4599 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4601 return this.groups[navId] ;
4616 * @class Roo.bootstrap.NavItem
4617 * @extends Roo.bootstrap.Component
4618 * Bootstrap Navbar.NavItem class
4619 * @cfg {String} href link to
4620 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4622 * @cfg {String} html content of button
4623 * @cfg {String} badge text inside badge
4624 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4625 * @cfg {String} glyphicon DEPRICATED - use fa
4626 * @cfg {String} icon DEPRICATED - use fa
4627 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4628 * @cfg {Boolean} active Is item active
4629 * @cfg {Boolean} disabled Is item disabled
4631 * @cfg {Boolean} preventDefault (true | false) default false
4632 * @cfg {String} tabId the tab that this item activates.
4633 * @cfg {String} tagtype (a|span) render as a href or span?
4634 * @cfg {Boolean} animateRef (true|false) link to element default false
4637 * Create a new Navbar Item
4638 * @param {Object} config The config object
4640 Roo.bootstrap.NavItem = function(config){
4641 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4646 * The raw click event for the entire grid.
4647 * @param {Roo.EventObject} e
4652 * Fires when the active item active state changes
4653 * @param {Roo.bootstrap.NavItem} this
4654 * @param {boolean} state the new state
4660 * Fires when scroll to element
4661 * @param {Roo.bootstrap.NavItem} this
4662 * @param {Object} options
4663 * @param {Roo.EventObject} e
4671 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4680 preventDefault : false,
4688 button_outline : false,
4692 getAutoCreate : function(){
4700 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4702 if (this.disabled) {
4703 cfg.cls += ' disabled';
4707 if (this.button_weight.length) {
4708 cfg.tag = this.href ? 'a' : 'button';
4709 cfg.html = this.html || '';
4710 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4712 cfg.href = this.href;
4715 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4718 // menu .. should add dropdown-menu class - so no need for carat..
4720 if (this.badge !== '') {
4722 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4727 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4731 href : this.href || "#",
4732 html: this.html || ''
4735 if (this.tagtype == 'a') {
4736 cfg.cn[0].cls = 'nav-link';
4739 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4742 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4744 if(this.glyphicon) {
4745 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4750 cfg.cn[0].html += " <span class='caret'></span>";
4754 if (this.badge !== '') {
4756 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4764 onRender : function(ct, position)
4766 // Roo.log("Call onRender: " + this.xtype);
4767 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4771 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4772 this.navLink = this.el.select('.nav-link',true).first();
4777 initEvents: function()
4779 if (typeof (this.menu) != 'undefined') {
4780 this.menu.parentType = this.xtype;
4781 this.menu.triggerEl = this.el;
4782 this.menu = this.addxtype(Roo.apply({}, this.menu));
4785 this.el.select('a',true).on('click', this.onClick, this);
4787 if(this.tagtype == 'span'){
4788 this.el.select('span',true).on('click', this.onClick, this);
4791 // at this point parent should be available..
4792 this.parent().register(this);
4795 onClick : function(e)
4797 if (e.getTarget('.dropdown-menu-item')) {
4798 // did you click on a menu itemm.... - then don't trigger onclick..
4803 this.preventDefault ||
4806 Roo.log("NavItem - prevent Default?");
4810 if (this.disabled) {
4814 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4815 if (tg && tg.transition) {
4816 Roo.log("waiting for the transitionend");
4822 //Roo.log("fire event clicked");
4823 if(this.fireEvent('click', this, e) === false){
4827 if(this.tagtype == 'span'){
4831 //Roo.log(this.href);
4832 var ael = this.el.select('a',true).first();
4835 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4836 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4837 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4838 return; // ignore... - it's a 'hash' to another page.
4840 Roo.log("NavItem - prevent Default?");
4842 this.scrollToElement(e);
4846 var p = this.parent();
4848 if (['tabs','pills'].indexOf(p.type)!==-1) {
4849 if (typeof(p.setActiveItem) !== 'undefined') {
4850 p.setActiveItem(this);
4854 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4855 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4856 // remove the collapsed menu expand...
4857 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4861 isActive: function () {
4864 setActive : function(state, fire, is_was_active)
4866 if (this.active && !state && this.navId) {
4867 this.was_active = true;
4868 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4870 nv.clearWasActive(this);
4874 this.active = state;
4877 this.el.removeClass('active');
4878 this.navLink ? this.navLink.removeClass('active') : false;
4879 } else if (!this.el.hasClass('active')) {
4881 this.el.addClass('active');
4882 if (Roo.bootstrap.version == 4 && this.navLink ) {
4883 this.navLink.addClass('active');
4888 this.fireEvent('changed', this, state);
4891 // show a panel if it's registered and related..
4893 if (!this.navId || !this.tabId || !state || is_was_active) {
4897 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4901 var pan = tg.getPanelByName(this.tabId);
4905 // if we can not flip to new panel - go back to old nav highlight..
4906 if (false == tg.showPanel(pan)) {
4907 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4909 var onav = nv.getWasActive();
4911 onav.setActive(true, false, true);
4920 // this should not be here...
4921 setDisabled : function(state)
4923 this.disabled = state;
4925 this.el.removeClass('disabled');
4926 } else if (!this.el.hasClass('disabled')) {
4927 this.el.addClass('disabled');
4933 * Fetch the element to display the tooltip on.
4934 * @return {Roo.Element} defaults to this.el
4936 tooltipEl : function()
4938 return this.el.select('' + this.tagtype + '', true).first();
4941 scrollToElement : function(e)
4943 var c = document.body;
4946 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4948 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4949 c = document.documentElement;
4952 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4958 var o = target.calcOffsetsTo(c);
4965 this.fireEvent('scrollto', this, options, e);
4967 Roo.get(c).scrollTo('top', options.value, true);
4980 * <span> icon </span>
4981 * <span> text </span>
4982 * <span>badge </span>
4986 * @class Roo.bootstrap.NavSidebarItem
4987 * @extends Roo.bootstrap.NavItem
4988 * Bootstrap Navbar.NavSidebarItem class
4989 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4990 * {Boolean} open is the menu open
4991 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4992 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4993 * {String} buttonSize (sm|md|lg)the extra classes for the button
4994 * {Boolean} showArrow show arrow next to the text (default true)
4996 * Create a new Navbar Button
4997 * @param {Object} config The config object
4999 Roo.bootstrap.NavSidebarItem = function(config){
5000 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5005 * The raw click event for the entire grid.
5006 * @param {Roo.EventObject} e
5011 * Fires when the active item active state changes
5012 * @param {Roo.bootstrap.NavSidebarItem} this
5013 * @param {boolean} state the new state
5021 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5023 badgeWeight : 'default',
5029 buttonWeight : 'default',
5035 getAutoCreate : function(){
5040 href : this.href || '#',
5046 if(this.buttonView){
5049 href : this.href || '#',
5050 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5063 cfg.cls += ' active';
5066 if (this.disabled) {
5067 cfg.cls += ' disabled';
5070 cfg.cls += ' open x-open';
5073 if (this.glyphicon || this.icon) {
5074 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5075 a.cn.push({ tag : 'i', cls : c }) ;
5078 if(!this.buttonView){
5081 html : this.html || ''
5088 if (this.badge !== '') {
5089 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5095 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5098 a.cls += ' dropdown-toggle treeview' ;
5104 initEvents : function()
5106 if (typeof (this.menu) != 'undefined') {
5107 this.menu.parentType = this.xtype;
5108 this.menu.triggerEl = this.el;
5109 this.menu = this.addxtype(Roo.apply({}, this.menu));
5112 this.el.on('click', this.onClick, this);
5114 if(this.badge !== ''){
5115 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5120 onClick : function(e)
5127 if(this.preventDefault){
5131 this.fireEvent('click', this, e);
5134 disable : function()
5136 this.setDisabled(true);
5141 this.setDisabled(false);
5144 setDisabled : function(state)
5146 if(this.disabled == state){
5150 this.disabled = state;
5153 this.el.addClass('disabled');
5157 this.el.removeClass('disabled');
5162 setActive : function(state)
5164 if(this.active == state){
5168 this.active = state;
5171 this.el.addClass('active');
5175 this.el.removeClass('active');
5180 isActive: function ()
5185 setBadge : function(str)
5191 this.badgeEl.dom.innerHTML = str;
5208 * @class Roo.bootstrap.Row
5209 * @extends Roo.bootstrap.Component
5210 * Bootstrap Row class (contains columns...)
5214 * @param {Object} config The config object
5217 Roo.bootstrap.Row = function(config){
5218 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5221 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5223 getAutoCreate : function(){
5242 * @class Roo.bootstrap.Element
5243 * @extends Roo.bootstrap.Component
5244 * Bootstrap Element class
5245 * @cfg {String} html contents of the element
5246 * @cfg {String} tag tag of the element
5247 * @cfg {String} cls class of the element
5248 * @cfg {Boolean} preventDefault (true|false) default false
5249 * @cfg {Boolean} clickable (true|false) default false
5252 * Create a new Element
5253 * @param {Object} config The config object
5256 Roo.bootstrap.Element = function(config){
5257 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5263 * When a element is chick
5264 * @param {Roo.bootstrap.Element} this
5265 * @param {Roo.EventObject} e
5271 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5276 preventDefault: false,
5279 getAutoCreate : function(){
5283 // cls: this.cls, double assign in parent class Component.js :: onRender
5290 initEvents: function()
5292 Roo.bootstrap.Element.superclass.initEvents.call(this);
5295 this.el.on('click', this.onClick, this);
5300 onClick : function(e)
5302 if(this.preventDefault){
5306 this.fireEvent('click', this, e);
5309 getValue : function()
5311 return this.el.dom.innerHTML;
5314 setValue : function(value)
5316 this.el.dom.innerHTML = value;
5331 * @class Roo.bootstrap.Pagination
5332 * @extends Roo.bootstrap.Component
5333 * Bootstrap Pagination class
5334 * @cfg {String} size xs | sm | md | lg
5335 * @cfg {Boolean} inverse false | true
5338 * Create a new Pagination
5339 * @param {Object} config The config object
5342 Roo.bootstrap.Pagination = function(config){
5343 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5346 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5352 getAutoCreate : function(){
5358 cfg.cls += ' inverse';
5364 cfg.cls += " " + this.cls;
5382 * @class Roo.bootstrap.PaginationItem
5383 * @extends Roo.bootstrap.Component
5384 * Bootstrap PaginationItem class
5385 * @cfg {String} html text
5386 * @cfg {String} href the link
5387 * @cfg {Boolean} preventDefault (true | false) default true
5388 * @cfg {Boolean} active (true | false) default false
5389 * @cfg {Boolean} disabled default false
5393 * Create a new PaginationItem
5394 * @param {Object} config The config object
5398 Roo.bootstrap.PaginationItem = function(config){
5399 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5404 * The raw click event for the entire grid.
5405 * @param {Roo.EventObject} e
5411 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5415 preventDefault: true,
5420 getAutoCreate : function(){
5426 href : this.href ? this.href : '#',
5427 html : this.html ? this.html : ''
5437 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5441 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5447 initEvents: function() {
5449 this.el.on('click', this.onClick, this);
5452 onClick : function(e)
5454 Roo.log('PaginationItem on click ');
5455 if(this.preventDefault){
5463 this.fireEvent('click', this, e);
5479 * @class Roo.bootstrap.Slider
5480 * @extends Roo.bootstrap.Component
5481 * Bootstrap Slider class
5484 * Create a new Slider
5485 * @param {Object} config The config object
5488 Roo.bootstrap.Slider = function(config){
5489 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5492 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5494 getAutoCreate : function(){
5498 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5502 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5514 * Ext JS Library 1.1.1
5515 * Copyright(c) 2006-2007, Ext JS, LLC.
5517 * Originally Released Under LGPL - original licence link has changed is not relivant.
5520 * <script type="text/javascript">
5525 * @class Roo.grid.ColumnModel
5526 * @extends Roo.util.Observable
5527 * This is the default implementation of a ColumnModel used by the Grid. It defines
5528 * the columns in the grid.
5531 var colModel = new Roo.grid.ColumnModel([
5532 {header: "Ticker", width: 60, sortable: true, locked: true},
5533 {header: "Company Name", width: 150, sortable: true},
5534 {header: "Market Cap.", width: 100, sortable: true},
5535 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5536 {header: "Employees", width: 100, sortable: true, resizable: false}
5541 * The config options listed for this class are options which may appear in each
5542 * individual column definition.
5543 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5545 * @param {Object} config An Array of column config objects. See this class's
5546 * config objects for details.
5548 Roo.grid.ColumnModel = function(config){
5550 * The config passed into the constructor
5552 this.config = config;
5555 // if no id, create one
5556 // if the column does not have a dataIndex mapping,
5557 // map it to the order it is in the config
5558 for(var i = 0, len = config.length; i < len; i++){
5560 if(typeof c.dataIndex == "undefined"){
5563 if(typeof c.renderer == "string"){
5564 c.renderer = Roo.util.Format[c.renderer];
5566 if(typeof c.id == "undefined"){
5569 if(c.editor && c.editor.xtype){
5570 c.editor = Roo.factory(c.editor, Roo.grid);
5572 if(c.editor && c.editor.isFormField){
5573 c.editor = new Roo.grid.GridEditor(c.editor);
5575 this.lookup[c.id] = c;
5579 * The width of columns which have no width specified (defaults to 100)
5582 this.defaultWidth = 100;
5585 * Default sortable of columns which have no sortable specified (defaults to false)
5588 this.defaultSortable = false;
5592 * @event widthchange
5593 * Fires when the width of a column changes.
5594 * @param {ColumnModel} this
5595 * @param {Number} columnIndex The column index
5596 * @param {Number} newWidth The new width
5598 "widthchange": true,
5600 * @event headerchange
5601 * Fires when the text of a header changes.
5602 * @param {ColumnModel} this
5603 * @param {Number} columnIndex The column index
5604 * @param {Number} newText The new header text
5606 "headerchange": true,
5608 * @event hiddenchange
5609 * Fires when a column is hidden or "unhidden".
5610 * @param {ColumnModel} this
5611 * @param {Number} columnIndex The column index
5612 * @param {Boolean} hidden true if hidden, false otherwise
5614 "hiddenchange": true,
5616 * @event columnmoved
5617 * Fires when a column is moved.
5618 * @param {ColumnModel} this
5619 * @param {Number} oldIndex
5620 * @param {Number} newIndex
5622 "columnmoved" : true,
5624 * @event columlockchange
5625 * Fires when a column's locked state is changed
5626 * @param {ColumnModel} this
5627 * @param {Number} colIndex
5628 * @param {Boolean} locked true if locked
5630 "columnlockchange" : true
5632 Roo.grid.ColumnModel.superclass.constructor.call(this);
5634 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5636 * @cfg {String} header The header text to display in the Grid view.
5639 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5640 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5641 * specified, the column's index is used as an index into the Record's data Array.
5644 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5645 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5648 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5649 * Defaults to the value of the {@link #defaultSortable} property.
5650 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5653 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5656 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5659 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5662 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5665 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5666 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5667 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5668 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5671 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5674 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5677 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5680 * @cfg {String} cursor (Optional)
5683 * @cfg {String} tooltip (Optional)
5686 * @cfg {Number} xs (Optional)
5689 * @cfg {Number} sm (Optional)
5692 * @cfg {Number} md (Optional)
5695 * @cfg {Number} lg (Optional)
5698 * Returns the id of the column at the specified index.
5699 * @param {Number} index The column index
5700 * @return {String} the id
5702 getColumnId : function(index){
5703 return this.config[index].id;
5707 * Returns the column for a specified id.
5708 * @param {String} id The column id
5709 * @return {Object} the column
5711 getColumnById : function(id){
5712 return this.lookup[id];
5717 * Returns the column for a specified dataIndex.
5718 * @param {String} dataIndex The column dataIndex
5719 * @return {Object|Boolean} the column or false if not found
5721 getColumnByDataIndex: function(dataIndex){
5722 var index = this.findColumnIndex(dataIndex);
5723 return index > -1 ? this.config[index] : false;
5727 * Returns the index for a specified column id.
5728 * @param {String} id The column id
5729 * @return {Number} the index, or -1 if not found
5731 getIndexById : function(id){
5732 for(var i = 0, len = this.config.length; i < len; i++){
5733 if(this.config[i].id == id){
5741 * Returns the index for a specified column dataIndex.
5742 * @param {String} dataIndex The column dataIndex
5743 * @return {Number} the index, or -1 if not found
5746 findColumnIndex : function(dataIndex){
5747 for(var i = 0, len = this.config.length; i < len; i++){
5748 if(this.config[i].dataIndex == dataIndex){
5756 moveColumn : function(oldIndex, newIndex){
5757 var c = this.config[oldIndex];
5758 this.config.splice(oldIndex, 1);
5759 this.config.splice(newIndex, 0, c);
5760 this.dataMap = null;
5761 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5764 isLocked : function(colIndex){
5765 return this.config[colIndex].locked === true;
5768 setLocked : function(colIndex, value, suppressEvent){
5769 if(this.isLocked(colIndex) == value){
5772 this.config[colIndex].locked = value;
5774 this.fireEvent("columnlockchange", this, colIndex, value);
5778 getTotalLockedWidth : function(){
5780 for(var i = 0; i < this.config.length; i++){
5781 if(this.isLocked(i) && !this.isHidden(i)){
5782 this.totalWidth += this.getColumnWidth(i);
5788 getLockedCount : function(){
5789 for(var i = 0, len = this.config.length; i < len; i++){
5790 if(!this.isLocked(i)){
5795 return this.config.length;
5799 * Returns the number of columns.
5802 getColumnCount : function(visibleOnly){
5803 if(visibleOnly === true){
5805 for(var i = 0, len = this.config.length; i < len; i++){
5806 if(!this.isHidden(i)){
5812 return this.config.length;
5816 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5817 * @param {Function} fn
5818 * @param {Object} scope (optional)
5819 * @return {Array} result
5821 getColumnsBy : function(fn, scope){
5823 for(var i = 0, len = this.config.length; i < len; i++){
5824 var c = this.config[i];
5825 if(fn.call(scope||this, c, i) === true){
5833 * Returns true if the specified column is sortable.
5834 * @param {Number} col The column index
5837 isSortable : function(col){
5838 if(typeof this.config[col].sortable == "undefined"){
5839 return this.defaultSortable;
5841 return this.config[col].sortable;
5845 * Returns the rendering (formatting) function defined for the column.
5846 * @param {Number} col The column index.
5847 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5849 getRenderer : function(col){
5850 if(!this.config[col].renderer){
5851 return Roo.grid.ColumnModel.defaultRenderer;
5853 return this.config[col].renderer;
5857 * Sets the rendering (formatting) function for a column.
5858 * @param {Number} col The column index
5859 * @param {Function} fn The function to use to process the cell's raw data
5860 * to return HTML markup for the grid view. The render function is called with
5861 * the following parameters:<ul>
5862 * <li>Data value.</li>
5863 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5864 * <li>css A CSS style string to apply to the table cell.</li>
5865 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5866 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5867 * <li>Row index</li>
5868 * <li>Column index</li>
5869 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5871 setRenderer : function(col, fn){
5872 this.config[col].renderer = fn;
5876 * Returns the width for the specified column.
5877 * @param {Number} col The column index
5880 getColumnWidth : function(col){
5881 return this.config[col].width * 1 || this.defaultWidth;
5885 * Sets the width for a column.
5886 * @param {Number} col The column index
5887 * @param {Number} width The new width
5889 setColumnWidth : function(col, width, suppressEvent){
5890 this.config[col].width = width;
5891 this.totalWidth = null;
5893 this.fireEvent("widthchange", this, col, width);
5898 * Returns the total width of all columns.
5899 * @param {Boolean} includeHidden True to include hidden column widths
5902 getTotalWidth : function(includeHidden){
5903 if(!this.totalWidth){
5904 this.totalWidth = 0;
5905 for(var i = 0, len = this.config.length; i < len; i++){
5906 if(includeHidden || !this.isHidden(i)){
5907 this.totalWidth += this.getColumnWidth(i);
5911 return this.totalWidth;
5915 * Returns the header for the specified column.
5916 * @param {Number} col The column index
5919 getColumnHeader : function(col){
5920 return this.config[col].header;
5924 * Sets the header for a column.
5925 * @param {Number} col The column index
5926 * @param {String} header The new header
5928 setColumnHeader : function(col, header){
5929 this.config[col].header = header;
5930 this.fireEvent("headerchange", this, col, header);
5934 * Returns the tooltip for the specified column.
5935 * @param {Number} col The column index
5938 getColumnTooltip : function(col){
5939 return this.config[col].tooltip;
5942 * Sets the tooltip for a column.
5943 * @param {Number} col The column index
5944 * @param {String} tooltip The new tooltip
5946 setColumnTooltip : function(col, tooltip){
5947 this.config[col].tooltip = tooltip;
5951 * Returns the dataIndex for the specified column.
5952 * @param {Number} col The column index
5955 getDataIndex : function(col){
5956 return this.config[col].dataIndex;
5960 * Sets the dataIndex for a column.
5961 * @param {Number} col The column index
5962 * @param {Number} dataIndex The new dataIndex
5964 setDataIndex : function(col, dataIndex){
5965 this.config[col].dataIndex = dataIndex;
5971 * Returns true if the cell is editable.
5972 * @param {Number} colIndex The column index
5973 * @param {Number} rowIndex The row index - this is nto actually used..?
5976 isCellEditable : function(colIndex, rowIndex){
5977 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5981 * Returns the editor defined for the cell/column.
5982 * return false or null to disable editing.
5983 * @param {Number} colIndex The column index
5984 * @param {Number} rowIndex The row index
5987 getCellEditor : function(colIndex, rowIndex){
5988 return this.config[colIndex].editor;
5992 * Sets if a column is editable.
5993 * @param {Number} col The column index
5994 * @param {Boolean} editable True if the column is editable
5996 setEditable : function(col, editable){
5997 this.config[col].editable = editable;
6002 * Returns true if the column is hidden.
6003 * @param {Number} colIndex The column index
6006 isHidden : function(colIndex){
6007 return this.config[colIndex].hidden;
6012 * Returns true if the column width cannot be changed
6014 isFixed : function(colIndex){
6015 return this.config[colIndex].fixed;
6019 * Returns true if the column can be resized
6022 isResizable : function(colIndex){
6023 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6026 * Sets if a column is hidden.
6027 * @param {Number} colIndex The column index
6028 * @param {Boolean} hidden True if the column is hidden
6030 setHidden : function(colIndex, hidden){
6031 this.config[colIndex].hidden = hidden;
6032 this.totalWidth = null;
6033 this.fireEvent("hiddenchange", this, colIndex, hidden);
6037 * Sets the editor for a column.
6038 * @param {Number} col The column index
6039 * @param {Object} editor The editor object
6041 setEditor : function(col, editor){
6042 this.config[col].editor = editor;
6046 Roo.grid.ColumnModel.defaultRenderer = function(value)
6048 if(typeof value == "object") {
6051 if(typeof value == "string" && value.length < 1){
6055 return String.format("{0}", value);
6058 // Alias for backwards compatibility
6059 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6062 * Ext JS Library 1.1.1
6063 * Copyright(c) 2006-2007, Ext JS, LLC.
6065 * Originally Released Under LGPL - original licence link has changed is not relivant.
6068 * <script type="text/javascript">
6072 * @class Roo.LoadMask
6073 * A simple utility class for generically masking elements while loading data. If the element being masked has
6074 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6075 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6076 * element's UpdateManager load indicator and will be destroyed after the initial load.
6078 * Create a new LoadMask
6079 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6080 * @param {Object} config The config object
6082 Roo.LoadMask = function(el, config){
6083 this.el = Roo.get(el);
6084 Roo.apply(this, config);
6086 this.store.on('beforeload', this.onBeforeLoad, this);
6087 this.store.on('load', this.onLoad, this);
6088 this.store.on('loadexception', this.onLoadException, this);
6089 this.removeMask = false;
6091 var um = this.el.getUpdateManager();
6092 um.showLoadIndicator = false; // disable the default indicator
6093 um.on('beforeupdate', this.onBeforeLoad, this);
6094 um.on('update', this.onLoad, this);
6095 um.on('failure', this.onLoad, this);
6096 this.removeMask = true;
6100 Roo.LoadMask.prototype = {
6102 * @cfg {Boolean} removeMask
6103 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6104 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6108 * The text to display in a centered loading message box (defaults to 'Loading...')
6112 * @cfg {String} msgCls
6113 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6115 msgCls : 'x-mask-loading',
6118 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6124 * Disables the mask to prevent it from being displayed
6126 disable : function(){
6127 this.disabled = true;
6131 * Enables the mask so that it can be displayed
6133 enable : function(){
6134 this.disabled = false;
6137 onLoadException : function()
6141 if (typeof(arguments[3]) != 'undefined') {
6142 Roo.MessageBox.alert("Error loading",arguments[3]);
6146 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6147 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6154 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6159 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6163 onBeforeLoad : function(){
6165 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6170 destroy : function(){
6172 this.store.un('beforeload', this.onBeforeLoad, this);
6173 this.store.un('load', this.onLoad, this);
6174 this.store.un('loadexception', this.onLoadException, this);
6176 var um = this.el.getUpdateManager();
6177 um.un('beforeupdate', this.onBeforeLoad, this);
6178 um.un('update', this.onLoad, this);
6179 um.un('failure', this.onLoad, this);
6190 * @class Roo.bootstrap.Table
6191 * @extends Roo.bootstrap.Component
6192 * Bootstrap Table class
6193 * @cfg {String} cls table class
6194 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6195 * @cfg {String} bgcolor Specifies the background color for a table
6196 * @cfg {Number} border Specifies whether the table cells should have borders or not
6197 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6198 * @cfg {Number} cellspacing Specifies the space between cells
6199 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6200 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6201 * @cfg {String} sortable Specifies that the table should be sortable
6202 * @cfg {String} summary Specifies a summary of the content of a table
6203 * @cfg {Number} width Specifies the width of a table
6204 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6206 * @cfg {boolean} striped Should the rows be alternative striped
6207 * @cfg {boolean} bordered Add borders to the table
6208 * @cfg {boolean} hover Add hover highlighting
6209 * @cfg {boolean} condensed Format condensed
6210 * @cfg {boolean} responsive Format condensed
6211 * @cfg {Boolean} loadMask (true|false) default false
6212 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6213 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6214 * @cfg {Boolean} rowSelection (true|false) default false
6215 * @cfg {Boolean} cellSelection (true|false) default false
6216 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6217 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6218 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6219 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6223 * Create a new Table
6224 * @param {Object} config The config object
6227 Roo.bootstrap.Table = function(config){
6228 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6233 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6234 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6235 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6236 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6238 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6240 this.sm.grid = this;
6241 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6242 this.sm = this.selModel;
6243 this.sm.xmodule = this.xmodule || false;
6246 if (this.cm && typeof(this.cm.config) == 'undefined') {
6247 this.colModel = new Roo.grid.ColumnModel(this.cm);
6248 this.cm = this.colModel;
6249 this.cm.xmodule = this.xmodule || false;
6252 this.store= Roo.factory(this.store, Roo.data);
6253 this.ds = this.store;
6254 this.ds.xmodule = this.xmodule || false;
6257 if (this.footer && this.store) {
6258 this.footer.dataSource = this.ds;
6259 this.footer = Roo.factory(this.footer);
6266 * Fires when a cell is clicked
6267 * @param {Roo.bootstrap.Table} this
6268 * @param {Roo.Element} el
6269 * @param {Number} rowIndex
6270 * @param {Number} columnIndex
6271 * @param {Roo.EventObject} e
6275 * @event celldblclick
6276 * Fires when a cell is double clicked
6277 * @param {Roo.bootstrap.Table} this
6278 * @param {Roo.Element} el
6279 * @param {Number} rowIndex
6280 * @param {Number} columnIndex
6281 * @param {Roo.EventObject} e
6283 "celldblclick" : true,
6286 * Fires when a row is clicked
6287 * @param {Roo.bootstrap.Table} this
6288 * @param {Roo.Element} el
6289 * @param {Number} rowIndex
6290 * @param {Roo.EventObject} e
6294 * @event rowdblclick
6295 * Fires when a row is double clicked
6296 * @param {Roo.bootstrap.Table} this
6297 * @param {Roo.Element} el
6298 * @param {Number} rowIndex
6299 * @param {Roo.EventObject} e
6301 "rowdblclick" : true,
6304 * Fires when a mouseover occur
6305 * @param {Roo.bootstrap.Table} this
6306 * @param {Roo.Element} el
6307 * @param {Number} rowIndex
6308 * @param {Number} columnIndex
6309 * @param {Roo.EventObject} e
6314 * Fires when a mouseout occur
6315 * @param {Roo.bootstrap.Table} this
6316 * @param {Roo.Element} el
6317 * @param {Number} rowIndex
6318 * @param {Number} columnIndex
6319 * @param {Roo.EventObject} e
6324 * Fires when a row is rendered, so you can change add a style to it.
6325 * @param {Roo.bootstrap.Table} this
6326 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6330 * @event rowsrendered
6331 * Fires when all the rows have been rendered
6332 * @param {Roo.bootstrap.Table} this
6334 'rowsrendered' : true,
6336 * @event contextmenu
6337 * The raw contextmenu event for the entire grid.
6338 * @param {Roo.EventObject} e
6340 "contextmenu" : true,
6342 * @event rowcontextmenu
6343 * Fires when a row is right clicked
6344 * @param {Roo.bootstrap.Table} this
6345 * @param {Number} rowIndex
6346 * @param {Roo.EventObject} e
6348 "rowcontextmenu" : true,
6350 * @event cellcontextmenu
6351 * Fires when a cell is right clicked
6352 * @param {Roo.bootstrap.Table} this
6353 * @param {Number} rowIndex
6354 * @param {Number} cellIndex
6355 * @param {Roo.EventObject} e
6357 "cellcontextmenu" : true,
6359 * @event headercontextmenu
6360 * Fires when a header is right clicked
6361 * @param {Roo.bootstrap.Table} this
6362 * @param {Number} columnIndex
6363 * @param {Roo.EventObject} e
6365 "headercontextmenu" : true
6369 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6395 rowSelection : false,
6396 cellSelection : false,
6399 // Roo.Element - the tbody
6401 // Roo.Element - thead element
6404 container: false, // used by gridpanel...
6410 auto_hide_footer : false,
6412 getAutoCreate : function()
6414 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6421 if (this.scrollBody) {
6422 cfg.cls += ' table-body-fixed';
6425 cfg.cls += ' table-striped';
6429 cfg.cls += ' table-hover';
6431 if (this.bordered) {
6432 cfg.cls += ' table-bordered';
6434 if (this.condensed) {
6435 cfg.cls += ' table-condensed';
6437 if (this.responsive) {
6438 cfg.cls += ' table-responsive';
6442 cfg.cls+= ' ' +this.cls;
6445 // this lot should be simplifed...
6458 ].forEach(function(k) {
6466 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6469 if(this.store || this.cm){
6470 if(this.headerShow){
6471 cfg.cn.push(this.renderHeader());
6474 cfg.cn.push(this.renderBody());
6476 if(this.footerShow){
6477 cfg.cn.push(this.renderFooter());
6479 // where does this come from?
6480 //cfg.cls+= ' TableGrid';
6483 return { cn : [ cfg ] };
6486 initEvents : function()
6488 if(!this.store || !this.cm){
6491 if (this.selModel) {
6492 this.selModel.initEvents();
6496 //Roo.log('initEvents with ds!!!!');
6498 this.mainBody = this.el.select('tbody', true).first();
6499 this.mainHead = this.el.select('thead', true).first();
6500 this.mainFoot = this.el.select('tfoot', true).first();
6506 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6507 e.on('click', _this.sort, _this);
6510 this.mainBody.on("click", this.onClick, this);
6511 this.mainBody.on("dblclick", this.onDblClick, this);
6513 // why is this done????? = it breaks dialogs??
6514 //this.parent().el.setStyle('position', 'relative');
6518 this.footer.parentId = this.id;
6519 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6522 this.el.select('tfoot tr td').first().addClass('hide');
6527 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6530 this.store.on('load', this.onLoad, this);
6531 this.store.on('beforeload', this.onBeforeLoad, this);
6532 this.store.on('update', this.onUpdate, this);
6533 this.store.on('add', this.onAdd, this);
6534 this.store.on("clear", this.clear, this);
6536 this.el.on("contextmenu", this.onContextMenu, this);
6538 this.mainBody.on('scroll', this.onBodyScroll, this);
6540 this.cm.on("headerchange", this.onHeaderChange, this);
6542 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6546 onContextMenu : function(e, t)
6548 this.processEvent("contextmenu", e);
6551 processEvent : function(name, e)
6553 if (name != 'touchstart' ) {
6554 this.fireEvent(name, e);
6557 var t = e.getTarget();
6559 var cell = Roo.get(t);
6565 if(cell.findParent('tfoot', false, true)){
6569 if(cell.findParent('thead', false, true)){
6571 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6572 cell = Roo.get(t).findParent('th', false, true);
6574 Roo.log("failed to find th in thead?");
6575 Roo.log(e.getTarget());
6580 var cellIndex = cell.dom.cellIndex;
6582 var ename = name == 'touchstart' ? 'click' : name;
6583 this.fireEvent("header" + ename, this, cellIndex, e);
6588 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6589 cell = Roo.get(t).findParent('td', false, true);
6591 Roo.log("failed to find th in tbody?");
6592 Roo.log(e.getTarget());
6597 var row = cell.findParent('tr', false, true);
6598 var cellIndex = cell.dom.cellIndex;
6599 var rowIndex = row.dom.rowIndex - 1;
6603 this.fireEvent("row" + name, this, rowIndex, e);
6607 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6613 onMouseover : function(e, el)
6615 var cell = Roo.get(el);
6621 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6622 cell = cell.findParent('td', false, true);
6625 var row = cell.findParent('tr', false, true);
6626 var cellIndex = cell.dom.cellIndex;
6627 var rowIndex = row.dom.rowIndex - 1; // start from 0
6629 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6633 onMouseout : function(e, el)
6635 var cell = Roo.get(el);
6641 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6642 cell = cell.findParent('td', false, true);
6645 var row = cell.findParent('tr', false, true);
6646 var cellIndex = cell.dom.cellIndex;
6647 var rowIndex = row.dom.rowIndex - 1; // start from 0
6649 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6653 onClick : function(e, el)
6655 var cell = Roo.get(el);
6657 if(!cell || (!this.cellSelection && !this.rowSelection)){
6661 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6662 cell = cell.findParent('td', false, true);
6665 if(!cell || typeof(cell) == 'undefined'){
6669 var row = cell.findParent('tr', false, true);
6671 if(!row || typeof(row) == 'undefined'){
6675 var cellIndex = cell.dom.cellIndex;
6676 var rowIndex = this.getRowIndex(row);
6678 // why??? - should these not be based on SelectionModel?
6679 if(this.cellSelection){
6680 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6683 if(this.rowSelection){
6684 this.fireEvent('rowclick', this, row, rowIndex, e);
6690 onDblClick : function(e,el)
6692 var cell = Roo.get(el);
6694 if(!cell || (!this.cellSelection && !this.rowSelection)){
6698 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6699 cell = cell.findParent('td', false, true);
6702 if(!cell || typeof(cell) == 'undefined'){
6706 var row = cell.findParent('tr', false, true);
6708 if(!row || typeof(row) == 'undefined'){
6712 var cellIndex = cell.dom.cellIndex;
6713 var rowIndex = this.getRowIndex(row);
6715 if(this.cellSelection){
6716 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6719 if(this.rowSelection){
6720 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6724 sort : function(e,el)
6726 var col = Roo.get(el);
6728 if(!col.hasClass('sortable')){
6732 var sort = col.attr('sort');
6735 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6739 this.store.sortInfo = {field : sort, direction : dir};
6742 Roo.log("calling footer first");
6743 this.footer.onClick('first');
6746 this.store.load({ params : { start : 0 } });
6750 renderHeader : function()
6758 this.totalWidth = 0;
6760 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6762 var config = cm.config[i];
6766 cls : 'x-hcol-' + i,
6768 html: cm.getColumnHeader(i)
6773 if(typeof(config.sortable) != 'undefined' && config.sortable){
6775 c.html = '<i class="glyphicon"></i>' + c.html;
6778 if(typeof(config.lgHeader) != 'undefined'){
6779 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6782 if(typeof(config.mdHeader) != 'undefined'){
6783 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6786 if(typeof(config.smHeader) != 'undefined'){
6787 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6790 if(typeof(config.xsHeader) != 'undefined'){
6791 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6798 if(typeof(config.tooltip) != 'undefined'){
6799 c.tooltip = config.tooltip;
6802 if(typeof(config.colspan) != 'undefined'){
6803 c.colspan = config.colspan;
6806 if(typeof(config.hidden) != 'undefined' && config.hidden){
6807 c.style += ' display:none;';
6810 if(typeof(config.dataIndex) != 'undefined'){
6811 c.sort = config.dataIndex;
6816 if(typeof(config.align) != 'undefined' && config.align.length){
6817 c.style += ' text-align:' + config.align + ';';
6820 if(typeof(config.width) != 'undefined'){
6821 c.style += ' width:' + config.width + 'px;';
6822 this.totalWidth += config.width;
6824 this.totalWidth += 100; // assume minimum of 100 per column?
6827 if(typeof(config.cls) != 'undefined'){
6828 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6831 ['xs','sm','md','lg'].map(function(size){
6833 if(typeof(config[size]) == 'undefined'){
6837 if (!config[size]) { // 0 = hidden
6838 c.cls += ' hidden-' + size;
6842 c.cls += ' col-' + size + '-' + config[size];
6852 renderBody : function()
6862 colspan : this.cm.getColumnCount()
6872 renderFooter : function()
6882 colspan : this.cm.getColumnCount()
6896 // Roo.log('ds onload');
6901 var ds = this.store;
6903 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6904 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6905 if (_this.store.sortInfo) {
6907 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6908 e.select('i', true).addClass(['glyphicon-arrow-up']);
6911 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6912 e.select('i', true).addClass(['glyphicon-arrow-down']);
6917 var tbody = this.mainBody;
6919 if(ds.getCount() > 0){
6920 ds.data.each(function(d,rowIndex){
6921 var row = this.renderRow(cm, ds, rowIndex);
6923 tbody.createChild(row);
6927 if(row.cellObjects.length){
6928 Roo.each(row.cellObjects, function(r){
6929 _this.renderCellObject(r);
6936 var tfoot = this.el.select('tfoot', true).first();
6938 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6940 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6942 var total = this.ds.getTotalCount();
6944 if(this.footer.pageSize < total){
6945 this.mainFoot.show();
6949 Roo.each(this.el.select('tbody td', true).elements, function(e){
6950 e.on('mouseover', _this.onMouseover, _this);
6953 Roo.each(this.el.select('tbody td', true).elements, function(e){
6954 e.on('mouseout', _this.onMouseout, _this);
6956 this.fireEvent('rowsrendered', this);
6962 onUpdate : function(ds,record)
6964 this.refreshRow(record);
6968 onRemove : function(ds, record, index, isUpdate){
6969 if(isUpdate !== true){
6970 this.fireEvent("beforerowremoved", this, index, record);
6972 var bt = this.mainBody.dom;
6974 var rows = this.el.select('tbody > tr', true).elements;
6976 if(typeof(rows[index]) != 'undefined'){
6977 bt.removeChild(rows[index].dom);
6980 // if(bt.rows[index]){
6981 // bt.removeChild(bt.rows[index]);
6984 if(isUpdate !== true){
6985 //this.stripeRows(index);
6986 //this.syncRowHeights(index, index);
6988 this.fireEvent("rowremoved", this, index, record);
6992 onAdd : function(ds, records, rowIndex)
6994 //Roo.log('on Add called');
6995 // - note this does not handle multiple adding very well..
6996 var bt = this.mainBody.dom;
6997 for (var i =0 ; i < records.length;i++) {
6998 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6999 //Roo.log(records[i]);
7000 //Roo.log(this.store.getAt(rowIndex+i));
7001 this.insertRow(this.store, rowIndex + i, false);
7008 refreshRow : function(record){
7009 var ds = this.store, index;
7010 if(typeof record == 'number'){
7012 record = ds.getAt(index);
7014 index = ds.indexOf(record);
7016 this.insertRow(ds, index, true);
7018 this.onRemove(ds, record, index+1, true);
7020 //this.syncRowHeights(index, index);
7022 this.fireEvent("rowupdated", this, index, record);
7025 insertRow : function(dm, rowIndex, isUpdate){
7028 this.fireEvent("beforerowsinserted", this, rowIndex);
7030 //var s = this.getScrollState();
7031 var row = this.renderRow(this.cm, this.store, rowIndex);
7032 // insert before rowIndex..
7033 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7037 if(row.cellObjects.length){
7038 Roo.each(row.cellObjects, function(r){
7039 _this.renderCellObject(r);
7044 this.fireEvent("rowsinserted", this, rowIndex);
7045 //this.syncRowHeights(firstRow, lastRow);
7046 //this.stripeRows(firstRow);
7053 getRowDom : function(rowIndex)
7055 var rows = this.el.select('tbody > tr', true).elements;
7057 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7060 // returns the object tree for a tr..
7063 renderRow : function(cm, ds, rowIndex)
7065 var d = ds.getAt(rowIndex);
7069 cls : 'x-row-' + rowIndex,
7073 var cellObjects = [];
7075 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7076 var config = cm.config[i];
7078 var renderer = cm.getRenderer(i);
7082 if(typeof(renderer) !== 'undefined'){
7083 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7085 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7086 // and are rendered into the cells after the row is rendered - using the id for the element.
7088 if(typeof(value) === 'object'){
7098 rowIndex : rowIndex,
7103 this.fireEvent('rowclass', this, rowcfg);
7107 cls : rowcfg.rowClass + ' x-col-' + i,
7109 html: (typeof(value) === 'object') ? '' : value
7116 if(typeof(config.colspan) != 'undefined'){
7117 td.colspan = config.colspan;
7120 if(typeof(config.hidden) != 'undefined' && config.hidden){
7121 td.style += ' display:none;';
7124 if(typeof(config.align) != 'undefined' && config.align.length){
7125 td.style += ' text-align:' + config.align + ';';
7127 if(typeof(config.valign) != 'undefined' && config.valign.length){
7128 td.style += ' vertical-align:' + config.valign + ';';
7131 if(typeof(config.width) != 'undefined'){
7132 td.style += ' width:' + config.width + 'px;';
7135 if(typeof(config.cursor) != 'undefined'){
7136 td.style += ' cursor:' + config.cursor + ';';
7139 if(typeof(config.cls) != 'undefined'){
7140 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7143 ['xs','sm','md','lg'].map(function(size){
7145 if(typeof(config[size]) == 'undefined'){
7149 if (!config[size]) { // 0 = hidden
7150 td.cls += ' hidden-' + size;
7154 td.cls += ' col-' + size + '-' + config[size];
7162 row.cellObjects = cellObjects;
7170 onBeforeLoad : function()
7179 this.el.select('tbody', true).first().dom.innerHTML = '';
7182 * Show or hide a row.
7183 * @param {Number} rowIndex to show or hide
7184 * @param {Boolean} state hide
7186 setRowVisibility : function(rowIndex, state)
7188 var bt = this.mainBody.dom;
7190 var rows = this.el.select('tbody > tr', true).elements;
7192 if(typeof(rows[rowIndex]) == 'undefined'){
7195 rows[rowIndex].dom.style.display = state ? '' : 'none';
7199 getSelectionModel : function(){
7201 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7203 return this.selModel;
7206 * Render the Roo.bootstrap object from renderder
7208 renderCellObject : function(r)
7212 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7214 var t = r.cfg.render(r.container);
7217 Roo.each(r.cfg.cn, function(c){
7219 container: t.getChildContainer(),
7222 _this.renderCellObject(child);
7227 getRowIndex : function(row)
7231 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7242 * Returns the grid's underlying element = used by panel.Grid
7243 * @return {Element} The element
7245 getGridEl : function(){
7249 * Forces a resize - used by panel.Grid
7250 * @return {Element} The element
7252 autoSize : function()
7254 //var ctr = Roo.get(this.container.dom.parentElement);
7255 var ctr = Roo.get(this.el.dom);
7257 var thd = this.getGridEl().select('thead',true).first();
7258 var tbd = this.getGridEl().select('tbody', true).first();
7259 var tfd = this.getGridEl().select('tfoot', true).first();
7261 var cw = ctr.getWidth();
7265 tbd.setSize(ctr.getWidth(),
7266 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7268 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7271 cw = Math.max(cw, this.totalWidth);
7272 this.getGridEl().select('tr',true).setWidth(cw);
7273 // resize 'expandable coloumn?
7275 return; // we doe not have a view in this design..
7278 onBodyScroll: function()
7280 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7282 this.mainHead.setStyle({
7283 'position' : 'relative',
7284 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7290 var scrollHeight = this.mainBody.dom.scrollHeight;
7292 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7294 var height = this.mainBody.getHeight();
7296 if(scrollHeight - height == scrollTop) {
7298 var total = this.ds.getTotalCount();
7300 if(this.footer.cursor + this.footer.pageSize < total){
7302 this.footer.ds.load({
7304 start : this.footer.cursor + this.footer.pageSize,
7305 limit : this.footer.pageSize
7315 onHeaderChange : function()
7317 var header = this.renderHeader();
7318 var table = this.el.select('table', true).first();
7320 this.mainHead.remove();
7321 this.mainHead = table.createChild(header, this.mainBody, false);
7324 onHiddenChange : function(colModel, colIndex, hidden)
7326 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7327 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7329 this.CSS.updateRule(thSelector, "display", "");
7330 this.CSS.updateRule(tdSelector, "display", "");
7333 this.CSS.updateRule(thSelector, "display", "none");
7334 this.CSS.updateRule(tdSelector, "display", "none");
7337 this.onHeaderChange();
7341 setColumnWidth: function(col_index, width)
7343 // width = "md-2 xs-2..."
7344 if(!this.colModel.config[col_index]) {
7348 var w = width.split(" ");
7350 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7352 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7355 for(var j = 0; j < w.length; j++) {
7361 var size_cls = w[j].split("-");
7363 if(!Number.isInteger(size_cls[1] * 1)) {
7367 if(!this.colModel.config[col_index][size_cls[0]]) {
7371 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7375 h_row[0].classList.replace(
7376 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7377 "col-"+size_cls[0]+"-"+size_cls[1]
7380 for(var i = 0; i < rows.length; i++) {
7382 var size_cls = w[j].split("-");
7384 if(!Number.isInteger(size_cls[1] * 1)) {
7388 if(!this.colModel.config[col_index][size_cls[0]]) {
7392 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7396 rows[i].classList.replace(
7397 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7398 "col-"+size_cls[0]+"-"+size_cls[1]
7402 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7417 * @class Roo.bootstrap.TableCell
7418 * @extends Roo.bootstrap.Component
7419 * Bootstrap TableCell class
7420 * @cfg {String} html cell contain text
7421 * @cfg {String} cls cell class
7422 * @cfg {String} tag cell tag (td|th) default td
7423 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7424 * @cfg {String} align Aligns the content in a cell
7425 * @cfg {String} axis Categorizes cells
7426 * @cfg {String} bgcolor Specifies the background color of a cell
7427 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7428 * @cfg {Number} colspan Specifies the number of columns a cell should span
7429 * @cfg {String} headers Specifies one or more header cells a cell is related to
7430 * @cfg {Number} height Sets the height of a cell
7431 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7432 * @cfg {Number} rowspan Sets the number of rows a cell should span
7433 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7434 * @cfg {String} valign Vertical aligns the content in a cell
7435 * @cfg {Number} width Specifies the width of a cell
7438 * Create a new TableCell
7439 * @param {Object} config The config object
7442 Roo.bootstrap.TableCell = function(config){
7443 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7446 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7466 getAutoCreate : function(){
7467 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7487 cfg.align=this.align
7493 cfg.bgcolor=this.bgcolor
7496 cfg.charoff=this.charoff
7499 cfg.colspan=this.colspan
7502 cfg.headers=this.headers
7505 cfg.height=this.height
7508 cfg.nowrap=this.nowrap
7511 cfg.rowspan=this.rowspan
7514 cfg.scope=this.scope
7517 cfg.valign=this.valign
7520 cfg.width=this.width
7539 * @class Roo.bootstrap.TableRow
7540 * @extends Roo.bootstrap.Component
7541 * Bootstrap TableRow class
7542 * @cfg {String} cls row class
7543 * @cfg {String} align Aligns the content in a table row
7544 * @cfg {String} bgcolor Specifies a background color for a table row
7545 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7546 * @cfg {String} valign Vertical aligns the content in a table row
7549 * Create a new TableRow
7550 * @param {Object} config The config object
7553 Roo.bootstrap.TableRow = function(config){
7554 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7557 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7565 getAutoCreate : function(){
7566 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7576 cfg.align = this.align;
7579 cfg.bgcolor = this.bgcolor;
7582 cfg.charoff = this.charoff;
7585 cfg.valign = this.valign;
7603 * @class Roo.bootstrap.TableBody
7604 * @extends Roo.bootstrap.Component
7605 * Bootstrap TableBody class
7606 * @cfg {String} cls element class
7607 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7608 * @cfg {String} align Aligns the content inside the element
7609 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7610 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7613 * Create a new TableBody
7614 * @param {Object} config The config object
7617 Roo.bootstrap.TableBody = function(config){
7618 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7621 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7629 getAutoCreate : function(){
7630 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7644 cfg.align = this.align;
7647 cfg.charoff = this.charoff;
7650 cfg.valign = this.valign;
7657 // initEvents : function()
7664 // this.store = Roo.factory(this.store, Roo.data);
7665 // this.store.on('load', this.onLoad, this);
7667 // this.store.load();
7671 // onLoad: function ()
7673 // this.fireEvent('load', this);
7683 * Ext JS Library 1.1.1
7684 * Copyright(c) 2006-2007, Ext JS, LLC.
7686 * Originally Released Under LGPL - original licence link has changed is not relivant.
7689 * <script type="text/javascript">
7692 // as we use this in bootstrap.
7693 Roo.namespace('Roo.form');
7695 * @class Roo.form.Action
7696 * Internal Class used to handle form actions
7698 * @param {Roo.form.BasicForm} el The form element or its id
7699 * @param {Object} config Configuration options
7704 // define the action interface
7705 Roo.form.Action = function(form, options){
7707 this.options = options || {};
7710 * Client Validation Failed
7713 Roo.form.Action.CLIENT_INVALID = 'client';
7715 * Server Validation Failed
7718 Roo.form.Action.SERVER_INVALID = 'server';
7720 * Connect to Server Failed
7723 Roo.form.Action.CONNECT_FAILURE = 'connect';
7725 * Reading Data from Server Failed
7728 Roo.form.Action.LOAD_FAILURE = 'load';
7730 Roo.form.Action.prototype = {
7732 failureType : undefined,
7733 response : undefined,
7737 run : function(options){
7742 success : function(response){
7747 handleResponse : function(response){
7751 // default connection failure
7752 failure : function(response){
7754 this.response = response;
7755 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7756 this.form.afterAction(this, false);
7759 processResponse : function(response){
7760 this.response = response;
7761 if(!response.responseText){
7764 this.result = this.handleResponse(response);
7768 // utility functions used internally
7769 getUrl : function(appendParams){
7770 var url = this.options.url || this.form.url || this.form.el.dom.action;
7772 var p = this.getParams();
7774 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7780 getMethod : function(){
7781 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7784 getParams : function(){
7785 var bp = this.form.baseParams;
7786 var p = this.options.params;
7788 if(typeof p == "object"){
7789 p = Roo.urlEncode(Roo.applyIf(p, bp));
7790 }else if(typeof p == 'string' && bp){
7791 p += '&' + Roo.urlEncode(bp);
7794 p = Roo.urlEncode(bp);
7799 createCallback : function(){
7801 success: this.success,
7802 failure: this.failure,
7804 timeout: (this.form.timeout*1000),
7805 upload: this.form.fileUpload ? this.success : undefined
7810 Roo.form.Action.Submit = function(form, options){
7811 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7814 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7817 haveProgress : false,
7818 uploadComplete : false,
7820 // uploadProgress indicator.
7821 uploadProgress : function()
7823 if (!this.form.progressUrl) {
7827 if (!this.haveProgress) {
7828 Roo.MessageBox.progress("Uploading", "Uploading");
7830 if (this.uploadComplete) {
7831 Roo.MessageBox.hide();
7835 this.haveProgress = true;
7837 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7839 var c = new Roo.data.Connection();
7841 url : this.form.progressUrl,
7846 success : function(req){
7847 //console.log(data);
7851 rdata = Roo.decode(req.responseText)
7853 Roo.log("Invalid data from server..");
7857 if (!rdata || !rdata.success) {
7859 Roo.MessageBox.alert(Roo.encode(rdata));
7862 var data = rdata.data;
7864 if (this.uploadComplete) {
7865 Roo.MessageBox.hide();
7870 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7871 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7874 this.uploadProgress.defer(2000,this);
7877 failure: function(data) {
7878 Roo.log('progress url failed ');
7889 // run get Values on the form, so it syncs any secondary forms.
7890 this.form.getValues();
7892 var o = this.options;
7893 var method = this.getMethod();
7894 var isPost = method == 'POST';
7895 if(o.clientValidation === false || this.form.isValid()){
7897 if (this.form.progressUrl) {
7898 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7899 (new Date() * 1) + '' + Math.random());
7904 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7905 form:this.form.el.dom,
7906 url:this.getUrl(!isPost),
7908 params:isPost ? this.getParams() : null,
7909 isUpload: this.form.fileUpload,
7910 formData : this.form.formData
7913 this.uploadProgress();
7915 }else if (o.clientValidation !== false){ // client validation failed
7916 this.failureType = Roo.form.Action.CLIENT_INVALID;
7917 this.form.afterAction(this, false);
7921 success : function(response)
7923 this.uploadComplete= true;
7924 if (this.haveProgress) {
7925 Roo.MessageBox.hide();
7929 var result = this.processResponse(response);
7930 if(result === true || result.success){
7931 this.form.afterAction(this, true);
7935 this.form.markInvalid(result.errors);
7936 this.failureType = Roo.form.Action.SERVER_INVALID;
7938 this.form.afterAction(this, false);
7940 failure : function(response)
7942 this.uploadComplete= true;
7943 if (this.haveProgress) {
7944 Roo.MessageBox.hide();
7947 this.response = response;
7948 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7949 this.form.afterAction(this, false);
7952 handleResponse : function(response){
7953 if(this.form.errorReader){
7954 var rs = this.form.errorReader.read(response);
7957 for(var i = 0, len = rs.records.length; i < len; i++) {
7958 var r = rs.records[i];
7962 if(errors.length < 1){
7966 success : rs.success,
7972 ret = Roo.decode(response.responseText);
7976 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7986 Roo.form.Action.Load = function(form, options){
7987 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7988 this.reader = this.form.reader;
7991 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7996 Roo.Ajax.request(Roo.apply(
7997 this.createCallback(), {
7998 method:this.getMethod(),
7999 url:this.getUrl(false),
8000 params:this.getParams()
8004 success : function(response){
8006 var result = this.processResponse(response);
8007 if(result === true || !result.success || !result.data){
8008 this.failureType = Roo.form.Action.LOAD_FAILURE;
8009 this.form.afterAction(this, false);
8012 this.form.clearInvalid();
8013 this.form.setValues(result.data);
8014 this.form.afterAction(this, true);
8017 handleResponse : function(response){
8018 if(this.form.reader){
8019 var rs = this.form.reader.read(response);
8020 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8022 success : rs.success,
8026 return Roo.decode(response.responseText);
8030 Roo.form.Action.ACTION_TYPES = {
8031 'load' : Roo.form.Action.Load,
8032 'submit' : Roo.form.Action.Submit
8041 * @class Roo.bootstrap.Form
8042 * @extends Roo.bootstrap.Component
8043 * Bootstrap Form class
8044 * @cfg {String} method GET | POST (default POST)
8045 * @cfg {String} labelAlign top | left (default top)
8046 * @cfg {String} align left | right - for navbars
8047 * @cfg {Boolean} loadMask load mask when submit (default true)
8052 * @param {Object} config The config object
8056 Roo.bootstrap.Form = function(config){
8058 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8060 Roo.bootstrap.Form.popover.apply();
8064 * @event clientvalidation
8065 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8066 * @param {Form} this
8067 * @param {Boolean} valid true if the form has passed client-side validation
8069 clientvalidation: true,
8071 * @event beforeaction
8072 * Fires before any action is performed. Return false to cancel the action.
8073 * @param {Form} this
8074 * @param {Action} action The action to be performed
8078 * @event actionfailed
8079 * Fires when an action fails.
8080 * @param {Form} this
8081 * @param {Action} action The action that failed
8083 actionfailed : true,
8085 * @event actioncomplete
8086 * Fires when an action is completed.
8087 * @param {Form} this
8088 * @param {Action} action The action that completed
8090 actioncomplete : true
8094 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8097 * @cfg {String} method
8098 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8103 * The URL to use for form actions if one isn't supplied in the action options.
8106 * @cfg {Boolean} fileUpload
8107 * Set to true if this form is a file upload.
8111 * @cfg {Object} baseParams
8112 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8116 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8120 * @cfg {Sting} align (left|right) for navbar forms
8125 activeAction : null,
8128 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8129 * element by passing it or its id or mask the form itself by passing in true.
8132 waitMsgTarget : false,
8137 * @cfg {Boolean} errorMask (true|false) default false
8142 * @cfg {Number} maskOffset Default 100
8147 * @cfg {Boolean} maskBody
8151 getAutoCreate : function(){
8155 method : this.method || 'POST',
8156 id : this.id || Roo.id(),
8159 if (this.parent().xtype.match(/^Nav/)) {
8160 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8164 if (this.labelAlign == 'left' ) {
8165 cfg.cls += ' form-horizontal';
8171 initEvents : function()
8173 this.el.on('submit', this.onSubmit, this);
8174 // this was added as random key presses on the form where triggering form submit.
8175 this.el.on('keypress', function(e) {
8176 if (e.getCharCode() != 13) {
8179 // we might need to allow it for textareas.. and some other items.
8180 // check e.getTarget().
8182 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8186 Roo.log("keypress blocked");
8194 onSubmit : function(e){
8199 * Returns true if client-side validation on the form is successful.
8202 isValid : function(){
8203 var items = this.getItems();
8207 items.each(function(f){
8213 Roo.log('invalid field: ' + f.name);
8217 if(!target && f.el.isVisible(true)){
8223 if(this.errorMask && !valid){
8224 Roo.bootstrap.Form.popover.mask(this, target);
8231 * Returns true if any fields in this form have changed since their original load.
8234 isDirty : function(){
8236 var items = this.getItems();
8237 items.each(function(f){
8247 * Performs a predefined action (submit or load) or custom actions you define on this form.
8248 * @param {String} actionName The name of the action type
8249 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8250 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8251 * accept other config options):
8253 Property Type Description
8254 ---------------- --------------- ----------------------------------------------------------------------------------
8255 url String The url for the action (defaults to the form's url)
8256 method String The form method to use (defaults to the form's method, or POST if not defined)
8257 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8258 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8259 validate the form on the client (defaults to false)
8261 * @return {BasicForm} this
8263 doAction : function(action, options){
8264 if(typeof action == 'string'){
8265 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8267 if(this.fireEvent('beforeaction', this, action) !== false){
8268 this.beforeAction(action);
8269 action.run.defer(100, action);
8275 beforeAction : function(action){
8276 var o = action.options;
8281 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8283 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8286 // not really supported yet.. ??
8288 //if(this.waitMsgTarget === true){
8289 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8290 //}else if(this.waitMsgTarget){
8291 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8292 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8294 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8300 afterAction : function(action, success){
8301 this.activeAction = null;
8302 var o = action.options;
8307 Roo.get(document.body).unmask();
8313 //if(this.waitMsgTarget === true){
8314 // this.el.unmask();
8315 //}else if(this.waitMsgTarget){
8316 // this.waitMsgTarget.unmask();
8318 // Roo.MessageBox.updateProgress(1);
8319 // Roo.MessageBox.hide();
8326 Roo.callback(o.success, o.scope, [this, action]);
8327 this.fireEvent('actioncomplete', this, action);
8331 // failure condition..
8332 // we have a scenario where updates need confirming.
8333 // eg. if a locking scenario exists..
8334 // we look for { errors : { needs_confirm : true }} in the response.
8336 (typeof(action.result) != 'undefined') &&
8337 (typeof(action.result.errors) != 'undefined') &&
8338 (typeof(action.result.errors.needs_confirm) != 'undefined')
8341 Roo.log("not supported yet");
8344 Roo.MessageBox.confirm(
8345 "Change requires confirmation",
8346 action.result.errorMsg,
8351 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8361 Roo.callback(o.failure, o.scope, [this, action]);
8362 // show an error message if no failed handler is set..
8363 if (!this.hasListener('actionfailed')) {
8364 Roo.log("need to add dialog support");
8366 Roo.MessageBox.alert("Error",
8367 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8368 action.result.errorMsg :
8369 "Saving Failed, please check your entries or try again"
8374 this.fireEvent('actionfailed', this, action);
8379 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8380 * @param {String} id The value to search for
8383 findField : function(id){
8384 var items = this.getItems();
8385 var field = items.get(id);
8387 items.each(function(f){
8388 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8395 return field || null;
8398 * Mark fields in this form invalid in bulk.
8399 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8400 * @return {BasicForm} this
8402 markInvalid : function(errors){
8403 if(errors instanceof Array){
8404 for(var i = 0, len = errors.length; i < len; i++){
8405 var fieldError = errors[i];
8406 var f = this.findField(fieldError.id);
8408 f.markInvalid(fieldError.msg);
8414 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8415 field.markInvalid(errors[id]);
8419 //Roo.each(this.childForms || [], function (f) {
8420 // f.markInvalid(errors);
8427 * Set values for fields in this form in bulk.
8428 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8429 * @return {BasicForm} this
8431 setValues : function(values){
8432 if(values instanceof Array){ // array of objects
8433 for(var i = 0, len = values.length; i < len; i++){
8435 var f = this.findField(v.id);
8437 f.setValue(v.value);
8438 if(this.trackResetOnLoad){
8439 f.originalValue = f.getValue();
8443 }else{ // object hash
8446 if(typeof values[id] != 'function' && (field = this.findField(id))){
8448 if (field.setFromData &&
8450 field.displayField &&
8451 // combos' with local stores can
8452 // be queried via setValue()
8453 // to set their value..
8454 (field.store && !field.store.isLocal)
8458 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8459 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8460 field.setFromData(sd);
8462 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8464 field.setFromData(values);
8467 field.setValue(values[id]);
8471 if(this.trackResetOnLoad){
8472 field.originalValue = field.getValue();
8478 //Roo.each(this.childForms || [], function (f) {
8479 // f.setValues(values);
8486 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8487 * they are returned as an array.
8488 * @param {Boolean} asString
8491 getValues : function(asString){
8492 //if (this.childForms) {
8493 // copy values from the child forms
8494 // Roo.each(this.childForms, function (f) {
8495 // this.setValues(f.getValues());
8501 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8502 if(asString === true){
8505 return Roo.urlDecode(fs);
8509 * Returns the fields in this form as an object with key/value pairs.
8510 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8513 getFieldValues : function(with_hidden)
8515 var items = this.getItems();
8517 items.each(function(f){
8523 var v = f.getValue();
8525 if (f.inputType =='radio') {
8526 if (typeof(ret[f.getName()]) == 'undefined') {
8527 ret[f.getName()] = ''; // empty..
8530 if (!f.el.dom.checked) {
8538 if(f.xtype == 'MoneyField'){
8539 ret[f.currencyName] = f.getCurrency();
8542 // not sure if this supported any more..
8543 if ((typeof(v) == 'object') && f.getRawValue) {
8544 v = f.getRawValue() ; // dates..
8546 // combo boxes where name != hiddenName...
8547 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8548 ret[f.name] = f.getRawValue();
8550 ret[f.getName()] = v;
8557 * Clears all invalid messages in this form.
8558 * @return {BasicForm} this
8560 clearInvalid : function(){
8561 var items = this.getItems();
8563 items.each(function(f){
8572 * @return {BasicForm} this
8575 var items = this.getItems();
8576 items.each(function(f){
8580 Roo.each(this.childForms || [], function (f) {
8588 getItems : function()
8590 var r=new Roo.util.MixedCollection(false, function(o){
8591 return o.id || (o.id = Roo.id());
8593 var iter = function(el) {
8600 Roo.each(el.items,function(e) {
8609 hideFields : function(items)
8611 Roo.each(items, function(i){
8613 var f = this.findField(i);
8624 showFields : function(items)
8626 Roo.each(items, function(i){
8628 var f = this.findField(i);
8641 Roo.apply(Roo.bootstrap.Form, {
8668 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8669 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8670 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8671 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8674 this.maskEl.top.enableDisplayMode("block");
8675 this.maskEl.left.enableDisplayMode("block");
8676 this.maskEl.bottom.enableDisplayMode("block");
8677 this.maskEl.right.enableDisplayMode("block");
8679 this.toolTip = new Roo.bootstrap.Tooltip({
8680 cls : 'roo-form-error-popover',
8682 'left' : ['r-l', [-2,0], 'right'],
8683 'right' : ['l-r', [2,0], 'left'],
8684 'bottom' : ['tl-bl', [0,2], 'top'],
8685 'top' : [ 'bl-tl', [0,-2], 'bottom']
8689 this.toolTip.render(Roo.get(document.body));
8691 this.toolTip.el.enableDisplayMode("block");
8693 Roo.get(document.body).on('click', function(){
8697 Roo.get(document.body).on('touchstart', function(){
8701 this.isApplied = true
8704 mask : function(form, target)
8708 this.target = target;
8710 if(!this.form.errorMask || !target.el){
8714 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8716 Roo.log(scrollable);
8718 var ot = this.target.el.calcOffsetsTo(scrollable);
8720 var scrollTo = ot[1] - this.form.maskOffset;
8722 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8724 scrollable.scrollTo('top', scrollTo);
8726 var box = this.target.el.getBox();
8728 var zIndex = Roo.bootstrap.Modal.zIndex++;
8731 this.maskEl.top.setStyle('position', 'absolute');
8732 this.maskEl.top.setStyle('z-index', zIndex);
8733 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8734 this.maskEl.top.setLeft(0);
8735 this.maskEl.top.setTop(0);
8736 this.maskEl.top.show();
8738 this.maskEl.left.setStyle('position', 'absolute');
8739 this.maskEl.left.setStyle('z-index', zIndex);
8740 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8741 this.maskEl.left.setLeft(0);
8742 this.maskEl.left.setTop(box.y - this.padding);
8743 this.maskEl.left.show();
8745 this.maskEl.bottom.setStyle('position', 'absolute');
8746 this.maskEl.bottom.setStyle('z-index', zIndex);
8747 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8748 this.maskEl.bottom.setLeft(0);
8749 this.maskEl.bottom.setTop(box.bottom + this.padding);
8750 this.maskEl.bottom.show();
8752 this.maskEl.right.setStyle('position', 'absolute');
8753 this.maskEl.right.setStyle('z-index', zIndex);
8754 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8755 this.maskEl.right.setLeft(box.right + this.padding);
8756 this.maskEl.right.setTop(box.y - this.padding);
8757 this.maskEl.right.show();
8759 this.toolTip.bindEl = this.target.el;
8761 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8763 var tip = this.target.blankText;
8765 if(this.target.getValue() !== '' ) {
8767 if (this.target.invalidText.length) {
8768 tip = this.target.invalidText;
8769 } else if (this.target.regexText.length){
8770 tip = this.target.regexText;
8774 this.toolTip.show(tip);
8776 this.intervalID = window.setInterval(function() {
8777 Roo.bootstrap.Form.popover.unmask();
8780 window.onwheel = function(){ return false;};
8782 (function(){ this.isMasked = true; }).defer(500, this);
8788 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8792 this.maskEl.top.setStyle('position', 'absolute');
8793 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8794 this.maskEl.top.hide();
8796 this.maskEl.left.setStyle('position', 'absolute');
8797 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8798 this.maskEl.left.hide();
8800 this.maskEl.bottom.setStyle('position', 'absolute');
8801 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8802 this.maskEl.bottom.hide();
8804 this.maskEl.right.setStyle('position', 'absolute');
8805 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8806 this.maskEl.right.hide();
8808 this.toolTip.hide();
8810 this.toolTip.el.hide();
8812 window.onwheel = function(){ return true;};
8814 if(this.intervalID){
8815 window.clearInterval(this.intervalID);
8816 this.intervalID = false;
8819 this.isMasked = false;
8829 * Ext JS Library 1.1.1
8830 * Copyright(c) 2006-2007, Ext JS, LLC.
8832 * Originally Released Under LGPL - original licence link has changed is not relivant.
8835 * <script type="text/javascript">
8838 * @class Roo.form.VTypes
8839 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8842 Roo.form.VTypes = function(){
8843 // closure these in so they are only created once.
8844 var alpha = /^[a-zA-Z_]+$/;
8845 var alphanum = /^[a-zA-Z0-9_]+$/;
8846 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8847 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8849 // All these messages and functions are configurable
8852 * The function used to validate email addresses
8853 * @param {String} value The email address
8855 'email' : function(v){
8856 return email.test(v);
8859 * The error text to display when the email validation function returns false
8862 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8864 * The keystroke filter mask to be applied on email input
8867 'emailMask' : /[a-z0-9_\.\-@]/i,
8870 * The function used to validate URLs
8871 * @param {String} value The URL
8873 'url' : function(v){
8877 * The error text to display when the url validation function returns false
8880 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8883 * The function used to validate alpha values
8884 * @param {String} value The value
8886 'alpha' : function(v){
8887 return alpha.test(v);
8890 * The error text to display when the alpha validation function returns false
8893 'alphaText' : 'This field should only contain letters and _',
8895 * The keystroke filter mask to be applied on alpha input
8898 'alphaMask' : /[a-z_]/i,
8901 * The function used to validate alphanumeric values
8902 * @param {String} value The value
8904 'alphanum' : function(v){
8905 return alphanum.test(v);
8908 * The error text to display when the alphanumeric validation function returns false
8911 'alphanumText' : 'This field should only contain letters, numbers and _',
8913 * The keystroke filter mask to be applied on alphanumeric input
8916 'alphanumMask' : /[a-z0-9_]/i
8926 * @class Roo.bootstrap.Input
8927 * @extends Roo.bootstrap.Component
8928 * Bootstrap Input class
8929 * @cfg {Boolean} disabled is it disabled
8930 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8931 * @cfg {String} name name of the input
8932 * @cfg {string} fieldLabel - the label associated
8933 * @cfg {string} placeholder - placeholder to put in text.
8934 * @cfg {string} before - input group add on before
8935 * @cfg {string} after - input group add on after
8936 * @cfg {string} size - (lg|sm) or leave empty..
8937 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8938 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8939 * @cfg {Number} md colspan out of 12 for computer-sized screens
8940 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8941 * @cfg {string} value default value of the input
8942 * @cfg {Number} labelWidth set the width of label
8943 * @cfg {Number} labellg set the width of label (1-12)
8944 * @cfg {Number} labelmd set the width of label (1-12)
8945 * @cfg {Number} labelsm set the width of label (1-12)
8946 * @cfg {Number} labelxs set the width of label (1-12)
8947 * @cfg {String} labelAlign (top|left)
8948 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8949 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8950 * @cfg {String} indicatorpos (left|right) default left
8951 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8952 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8954 * @cfg {String} align (left|center|right) Default left
8955 * @cfg {Boolean} forceFeedback (true|false) Default false
8958 * Create a new Input
8959 * @param {Object} config The config object
8962 Roo.bootstrap.Input = function(config){
8964 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8969 * Fires when this field receives input focus.
8970 * @param {Roo.form.Field} this
8975 * Fires when this field loses input focus.
8976 * @param {Roo.form.Field} this
8981 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8982 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8983 * @param {Roo.form.Field} this
8984 * @param {Roo.EventObject} e The event object
8989 * Fires just before the field blurs if the field value has changed.
8990 * @param {Roo.form.Field} this
8991 * @param {Mixed} newValue The new value
8992 * @param {Mixed} oldValue The original value
8997 * Fires after the field has been marked as invalid.
8998 * @param {Roo.form.Field} this
8999 * @param {String} msg The validation message
9004 * Fires after the field has been validated with no errors.
9005 * @param {Roo.form.Field} this
9010 * Fires after the key up
9011 * @param {Roo.form.Field} this
9012 * @param {Roo.EventObject} e The event Object
9018 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9020 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9021 automatic validation (defaults to "keyup").
9023 validationEvent : "keyup",
9025 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9027 validateOnBlur : true,
9029 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9031 validationDelay : 250,
9033 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9035 focusClass : "x-form-focus", // not needed???
9039 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9041 invalidClass : "has-warning",
9044 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9046 validClass : "has-success",
9049 * @cfg {Boolean} hasFeedback (true|false) default true
9054 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9056 invalidFeedbackClass : "glyphicon-warning-sign",
9059 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9061 validFeedbackClass : "glyphicon-ok",
9064 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9066 selectOnFocus : false,
9069 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9073 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9078 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9080 disableKeyFilter : false,
9083 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9087 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9091 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9093 blankText : "Please complete this mandatory field",
9096 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9100 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9102 maxLength : Number.MAX_VALUE,
9104 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9106 minLengthText : "The minimum length for this field is {0}",
9108 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9110 maxLengthText : "The maximum length for this field is {0}",
9114 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9115 * If available, this function will be called only after the basic validators all return true, and will be passed the
9116 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9120 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9121 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9122 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9126 * @cfg {String} regexText -- Depricated - use Invalid Text
9131 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9137 autocomplete: false,
9156 formatedValue : false,
9157 forceFeedback : false,
9159 indicatorpos : 'left',
9169 parentLabelAlign : function()
9172 while (parent.parent()) {
9173 parent = parent.parent();
9174 if (typeof(parent.labelAlign) !='undefined') {
9175 return parent.labelAlign;
9182 getAutoCreate : function()
9184 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9190 if(this.inputType != 'hidden'){
9191 cfg.cls = 'form-group' //input-group
9197 type : this.inputType,
9199 cls : 'form-control',
9200 placeholder : this.placeholder || '',
9201 autocomplete : this.autocomplete || 'new-password'
9204 if(this.capture.length){
9205 input.capture = this.capture;
9208 if(this.accept.length){
9209 input.accept = this.accept + "/*";
9213 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9216 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9217 input.maxLength = this.maxLength;
9220 if (this.disabled) {
9221 input.disabled=true;
9224 if (this.readOnly) {
9225 input.readonly=true;
9229 input.name = this.name;
9233 input.cls += ' input-' + this.size;
9237 ['xs','sm','md','lg'].map(function(size){
9238 if (settings[size]) {
9239 cfg.cls += ' col-' + size + '-' + settings[size];
9243 var inputblock = input;
9247 cls: 'glyphicon form-control-feedback'
9250 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9253 cls : 'has-feedback',
9261 if (this.before || this.after) {
9264 cls : 'input-group',
9268 if (this.before && typeof(this.before) == 'string') {
9270 inputblock.cn.push({
9272 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9276 if (this.before && typeof(this.before) == 'object') {
9277 this.before = Roo.factory(this.before);
9279 inputblock.cn.push({
9281 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9282 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9286 inputblock.cn.push(input);
9288 if (this.after && typeof(this.after) == 'string') {
9289 inputblock.cn.push({
9291 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9295 if (this.after && typeof(this.after) == 'object') {
9296 this.after = Roo.factory(this.after);
9298 inputblock.cn.push({
9300 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9301 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9305 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9306 inputblock.cls += ' has-feedback';
9307 inputblock.cn.push(feedback);
9312 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9313 tooltip : 'This field is required'
9315 if (Roo.bootstrap.version == 4) {
9318 style : 'display-none'
9321 if (align ==='left' && this.fieldLabel.length) {
9323 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9330 cls : 'control-label col-form-label',
9331 html : this.fieldLabel
9342 var labelCfg = cfg.cn[1];
9343 var contentCfg = cfg.cn[2];
9345 if(this.indicatorpos == 'right'){
9350 cls : 'control-label col-form-label',
9354 html : this.fieldLabel
9368 labelCfg = cfg.cn[0];
9369 contentCfg = cfg.cn[1];
9373 if(this.labelWidth > 12){
9374 labelCfg.style = "width: " + this.labelWidth + 'px';
9377 if(this.labelWidth < 13 && this.labelmd == 0){
9378 this.labelmd = this.labelWidth;
9381 if(this.labellg > 0){
9382 labelCfg.cls += ' col-lg-' + this.labellg;
9383 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9386 if(this.labelmd > 0){
9387 labelCfg.cls += ' col-md-' + this.labelmd;
9388 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9391 if(this.labelsm > 0){
9392 labelCfg.cls += ' col-sm-' + this.labelsm;
9393 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9396 if(this.labelxs > 0){
9397 labelCfg.cls += ' col-xs-' + this.labelxs;
9398 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9402 } else if ( this.fieldLabel.length) {
9407 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9408 tooltip : 'This field is required'
9412 //cls : 'input-group-addon',
9413 html : this.fieldLabel
9421 if(this.indicatorpos == 'right'){
9426 //cls : 'input-group-addon',
9427 html : this.fieldLabel
9432 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9433 tooltip : 'This field is required'
9453 if (this.parentType === 'Navbar' && this.parent().bar) {
9454 cfg.cls += ' navbar-form';
9457 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9458 // on BS4 we do this only if not form
9459 cfg.cls += ' navbar-form';
9467 * return the real input element.
9469 inputEl: function ()
9471 return this.el.select('input.form-control',true).first();
9474 tooltipEl : function()
9476 return this.inputEl();
9479 indicatorEl : function()
9481 if (Roo.bootstrap.version == 4) {
9482 return false; // not enabled in v4 yet.
9485 var indicator = this.el.select('i.roo-required-indicator',true).first();
9495 setDisabled : function(v)
9497 var i = this.inputEl().dom;
9499 i.removeAttribute('disabled');
9503 i.setAttribute('disabled','true');
9505 initEvents : function()
9508 this.inputEl().on("keydown" , this.fireKey, this);
9509 this.inputEl().on("focus", this.onFocus, this);
9510 this.inputEl().on("blur", this.onBlur, this);
9512 this.inputEl().relayEvent('keyup', this);
9514 this.indicator = this.indicatorEl();
9517 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9520 // reference to original value for reset
9521 this.originalValue = this.getValue();
9522 //Roo.form.TextField.superclass.initEvents.call(this);
9523 if(this.validationEvent == 'keyup'){
9524 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9525 this.inputEl().on('keyup', this.filterValidation, this);
9527 else if(this.validationEvent !== false){
9528 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9531 if(this.selectOnFocus){
9532 this.on("focus", this.preFocus, this);
9535 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9536 this.inputEl().on("keypress", this.filterKeys, this);
9538 this.inputEl().relayEvent('keypress', this);
9541 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9542 this.el.on("click", this.autoSize, this);
9545 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9546 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9549 if (typeof(this.before) == 'object') {
9550 this.before.render(this.el.select('.roo-input-before',true).first());
9552 if (typeof(this.after) == 'object') {
9553 this.after.render(this.el.select('.roo-input-after',true).first());
9556 this.inputEl().on('change', this.onChange, this);
9559 filterValidation : function(e){
9560 if(!e.isNavKeyPress()){
9561 this.validationTask.delay(this.validationDelay);
9565 * Validates the field value
9566 * @return {Boolean} True if the value is valid, else false
9568 validate : function(){
9569 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9570 if(this.disabled || this.validateValue(this.getRawValue())){
9581 * Validates a value according to the field's validation rules and marks the field as invalid
9582 * if the validation fails
9583 * @param {Mixed} value The value to validate
9584 * @return {Boolean} True if the value is valid, else false
9586 validateValue : function(value)
9588 if(this.getVisibilityEl().hasClass('hidden')){
9592 if(value.length < 1) { // if it's blank
9593 if(this.allowBlank){
9599 if(value.length < this.minLength){
9602 if(value.length > this.maxLength){
9606 var vt = Roo.form.VTypes;
9607 if(!vt[this.vtype](value, this)){
9611 if(typeof this.validator == "function"){
9612 var msg = this.validator(value);
9616 if (typeof(msg) == 'string') {
9617 this.invalidText = msg;
9621 if(this.regex && !this.regex.test(value)){
9629 fireKey : function(e){
9630 //Roo.log('field ' + e.getKey());
9631 if(e.isNavKeyPress()){
9632 this.fireEvent("specialkey", this, e);
9635 focus : function (selectText){
9637 this.inputEl().focus();
9638 if(selectText === true){
9639 this.inputEl().dom.select();
9645 onFocus : function(){
9646 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9647 // this.el.addClass(this.focusClass);
9650 this.hasFocus = true;
9651 this.startValue = this.getValue();
9652 this.fireEvent("focus", this);
9656 beforeBlur : Roo.emptyFn,
9660 onBlur : function(){
9662 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9663 //this.el.removeClass(this.focusClass);
9665 this.hasFocus = false;
9666 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9669 var v = this.getValue();
9670 if(String(v) !== String(this.startValue)){
9671 this.fireEvent('change', this, v, this.startValue);
9673 this.fireEvent("blur", this);
9676 onChange : function(e)
9678 var v = this.getValue();
9679 if(String(v) !== String(this.startValue)){
9680 this.fireEvent('change', this, v, this.startValue);
9686 * Resets the current field value to the originally loaded value and clears any validation messages
9689 this.setValue(this.originalValue);
9693 * Returns the name of the field
9694 * @return {Mixed} name The name field
9696 getName: function(){
9700 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9701 * @return {Mixed} value The field value
9703 getValue : function(){
9705 var v = this.inputEl().getValue();
9710 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9711 * @return {Mixed} value The field value
9713 getRawValue : function(){
9714 var v = this.inputEl().getValue();
9720 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9721 * @param {Mixed} value The value to set
9723 setRawValue : function(v){
9724 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9727 selectText : function(start, end){
9728 var v = this.getRawValue();
9730 start = start === undefined ? 0 : start;
9731 end = end === undefined ? v.length : end;
9732 var d = this.inputEl().dom;
9733 if(d.setSelectionRange){
9734 d.setSelectionRange(start, end);
9735 }else if(d.createTextRange){
9736 var range = d.createTextRange();
9737 range.moveStart("character", start);
9738 range.moveEnd("character", v.length-end);
9745 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9746 * @param {Mixed} value The value to set
9748 setValue : function(v){
9751 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9757 processValue : function(value){
9758 if(this.stripCharsRe){
9759 var newValue = value.replace(this.stripCharsRe, '');
9760 if(newValue !== value){
9761 this.setRawValue(newValue);
9768 preFocus : function(){
9770 if(this.selectOnFocus){
9771 this.inputEl().dom.select();
9774 filterKeys : function(e){
9776 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9779 var c = e.getCharCode(), cc = String.fromCharCode(c);
9780 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9783 if(!this.maskRe.test(cc)){
9788 * Clear any invalid styles/messages for this field
9790 clearInvalid : function(){
9792 if(!this.el || this.preventMark){ // not rendered
9797 this.el.removeClass([this.invalidClass, 'is-invalid']);
9799 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9801 var feedback = this.el.select('.form-control-feedback', true).first();
9804 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9810 this.indicator.removeClass('visible');
9811 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9814 this.fireEvent('valid', this);
9818 * Mark this field as valid
9820 markValid : function()
9822 if(!this.el || this.preventMark){ // not rendered...
9826 this.el.removeClass([this.invalidClass, this.validClass]);
9827 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9829 var feedback = this.el.select('.form-control-feedback', true).first();
9832 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9836 this.indicator.removeClass('visible');
9837 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9844 if(this.allowBlank && !this.getRawValue().length){
9847 if (Roo.bootstrap.version == 3) {
9848 this.el.addClass(this.validClass);
9850 this.inputEl().addClass('is-valid');
9853 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9855 var feedback = this.el.select('.form-control-feedback', true).first();
9858 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9859 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9864 this.fireEvent('valid', this);
9868 * Mark this field as invalid
9869 * @param {String} msg The validation message
9871 markInvalid : function(msg)
9873 if(!this.el || this.preventMark){ // not rendered
9877 this.el.removeClass([this.invalidClass, this.validClass]);
9878 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9880 var feedback = this.el.select('.form-control-feedback', true).first();
9883 this.el.select('.form-control-feedback', true).first().removeClass(
9884 [this.invalidFeedbackClass, this.validFeedbackClass]);
9891 if(this.allowBlank && !this.getRawValue().length){
9896 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9897 this.indicator.addClass('visible');
9899 if (Roo.bootstrap.version == 3) {
9900 this.el.addClass(this.invalidClass);
9902 this.inputEl().addClass('is-invalid');
9907 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9909 var feedback = this.el.select('.form-control-feedback', true).first();
9912 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9914 if(this.getValue().length || this.forceFeedback){
9915 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9922 this.fireEvent('invalid', this, msg);
9925 SafariOnKeyDown : function(event)
9927 // this is a workaround for a password hang bug on chrome/ webkit.
9928 if (this.inputEl().dom.type != 'password') {
9932 var isSelectAll = false;
9934 if(this.inputEl().dom.selectionEnd > 0){
9935 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9937 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9938 event.preventDefault();
9943 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9945 event.preventDefault();
9946 // this is very hacky as keydown always get's upper case.
9948 var cc = String.fromCharCode(event.getCharCode());
9949 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9953 adjustWidth : function(tag, w){
9954 tag = tag.toLowerCase();
9955 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9956 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9960 if(tag == 'textarea'){
9963 }else if(Roo.isOpera){
9967 if(tag == 'textarea'){
9975 setFieldLabel : function(v)
9981 if(this.indicatorEl()){
9982 var ar = this.el.select('label > span',true);
9984 if (ar.elements.length) {
9985 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9986 this.fieldLabel = v;
9990 var br = this.el.select('label',true);
9992 if(br.elements.length) {
9993 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9994 this.fieldLabel = v;
9998 Roo.log('Cannot Found any of label > span || label in input');
10002 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10003 this.fieldLabel = v;
10018 * @class Roo.bootstrap.TextArea
10019 * @extends Roo.bootstrap.Input
10020 * Bootstrap TextArea class
10021 * @cfg {Number} cols Specifies the visible width of a text area
10022 * @cfg {Number} rows Specifies the visible number of lines in a text area
10023 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10024 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10025 * @cfg {string} html text
10028 * Create a new TextArea
10029 * @param {Object} config The config object
10032 Roo.bootstrap.TextArea = function(config){
10033 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10037 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10047 getAutoCreate : function(){
10049 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10055 if(this.inputType != 'hidden'){
10056 cfg.cls = 'form-group' //input-group
10064 value : this.value || '',
10065 html: this.html || '',
10066 cls : 'form-control',
10067 placeholder : this.placeholder || ''
10071 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10072 input.maxLength = this.maxLength;
10076 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10080 input.cols = this.cols;
10083 if (this.readOnly) {
10084 input.readonly = true;
10088 input.name = this.name;
10092 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10096 ['xs','sm','md','lg'].map(function(size){
10097 if (settings[size]) {
10098 cfg.cls += ' col-' + size + '-' + settings[size];
10102 var inputblock = input;
10104 if(this.hasFeedback && !this.allowBlank){
10108 cls: 'glyphicon form-control-feedback'
10112 cls : 'has-feedback',
10121 if (this.before || this.after) {
10124 cls : 'input-group',
10128 inputblock.cn.push({
10130 cls : 'input-group-addon',
10135 inputblock.cn.push(input);
10137 if(this.hasFeedback && !this.allowBlank){
10138 inputblock.cls += ' has-feedback';
10139 inputblock.cn.push(feedback);
10143 inputblock.cn.push({
10145 cls : 'input-group-addon',
10152 if (align ==='left' && this.fieldLabel.length) {
10157 cls : 'control-label',
10158 html : this.fieldLabel
10169 if(this.labelWidth > 12){
10170 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10173 if(this.labelWidth < 13 && this.labelmd == 0){
10174 this.labelmd = this.labelWidth;
10177 if(this.labellg > 0){
10178 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10179 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10182 if(this.labelmd > 0){
10183 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10184 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10187 if(this.labelsm > 0){
10188 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10189 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10192 if(this.labelxs > 0){
10193 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10194 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10197 } else if ( this.fieldLabel.length) {
10202 //cls : 'input-group-addon',
10203 html : this.fieldLabel
10221 if (this.disabled) {
10222 input.disabled=true;
10229 * return the real textarea element.
10231 inputEl: function ()
10233 return this.el.select('textarea.form-control',true).first();
10237 * Clear any invalid styles/messages for this field
10239 clearInvalid : function()
10242 if(!this.el || this.preventMark){ // not rendered
10246 var label = this.el.select('label', true).first();
10247 var icon = this.el.select('i.fa-star', true).first();
10252 this.el.removeClass( this.validClass);
10253 this.inputEl().removeClass('is-invalid');
10255 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10257 var feedback = this.el.select('.form-control-feedback', true).first();
10260 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10265 this.fireEvent('valid', this);
10269 * Mark this field as valid
10271 markValid : function()
10273 if(!this.el || this.preventMark){ // not rendered
10277 this.el.removeClass([this.invalidClass, this.validClass]);
10278 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10280 var feedback = this.el.select('.form-control-feedback', true).first();
10283 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10286 if(this.disabled || this.allowBlank){
10290 var label = this.el.select('label', true).first();
10291 var icon = this.el.select('i.fa-star', true).first();
10296 if (Roo.bootstrap.version == 3) {
10297 this.el.addClass(this.validClass);
10299 this.inputEl().addClass('is-valid');
10303 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10305 var feedback = this.el.select('.form-control-feedback', true).first();
10308 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10309 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10314 this.fireEvent('valid', this);
10318 * Mark this field as invalid
10319 * @param {String} msg The validation message
10321 markInvalid : function(msg)
10323 if(!this.el || this.preventMark){ // not rendered
10327 this.el.removeClass([this.invalidClass, this.validClass]);
10328 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10330 var feedback = this.el.select('.form-control-feedback', true).first();
10333 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10336 if(this.disabled || this.allowBlank){
10340 var label = this.el.select('label', true).first();
10341 var icon = this.el.select('i.fa-star', true).first();
10343 if(!this.getValue().length && label && !icon){
10344 this.el.createChild({
10346 cls : 'text-danger fa fa-lg fa-star',
10347 tooltip : 'This field is required',
10348 style : 'margin-right:5px;'
10352 if (Roo.bootstrap.version == 3) {
10353 this.el.addClass(this.invalidClass);
10355 this.inputEl().addClass('is-invalid');
10358 // fixme ... this may be depricated need to test..
10359 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10361 var feedback = this.el.select('.form-control-feedback', true).first();
10364 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10366 if(this.getValue().length || this.forceFeedback){
10367 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10374 this.fireEvent('invalid', this, msg);
10382 * trigger field - base class for combo..
10387 * @class Roo.bootstrap.TriggerField
10388 * @extends Roo.bootstrap.Input
10389 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10390 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10391 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10392 * for which you can provide a custom implementation. For example:
10394 var trigger = new Roo.bootstrap.TriggerField();
10395 trigger.onTriggerClick = myTriggerFn;
10396 trigger.applyTo('my-field');
10399 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10400 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10401 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10402 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10403 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10406 * Create a new TriggerField.
10407 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10408 * to the base TextField)
10410 Roo.bootstrap.TriggerField = function(config){
10411 this.mimicing = false;
10412 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10415 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10417 * @cfg {String} triggerClass A CSS class to apply to the trigger
10420 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10425 * @cfg {Boolean} removable (true|false) special filter default false
10429 /** @cfg {Boolean} grow @hide */
10430 /** @cfg {Number} growMin @hide */
10431 /** @cfg {Number} growMax @hide */
10437 autoSize: Roo.emptyFn,
10441 deferHeight : true,
10444 actionMode : 'wrap',
10449 getAutoCreate : function(){
10451 var align = this.labelAlign || this.parentLabelAlign();
10456 cls: 'form-group' //input-group
10463 type : this.inputType,
10464 cls : 'form-control',
10465 autocomplete: 'new-password',
10466 placeholder : this.placeholder || ''
10470 input.name = this.name;
10473 input.cls += ' input-' + this.size;
10476 if (this.disabled) {
10477 input.disabled=true;
10480 var inputblock = input;
10482 if(this.hasFeedback && !this.allowBlank){
10486 cls: 'glyphicon form-control-feedback'
10489 if(this.removable && !this.editable && !this.tickable){
10491 cls : 'has-feedback',
10497 cls : 'roo-combo-removable-btn close'
10504 cls : 'has-feedback',
10513 if(this.removable && !this.editable && !this.tickable){
10515 cls : 'roo-removable',
10521 cls : 'roo-combo-removable-btn close'
10528 if (this.before || this.after) {
10531 cls : 'input-group',
10535 inputblock.cn.push({
10537 cls : 'input-group-addon input-group-prepend input-group-text',
10542 inputblock.cn.push(input);
10544 if(this.hasFeedback && !this.allowBlank){
10545 inputblock.cls += ' has-feedback';
10546 inputblock.cn.push(feedback);
10550 inputblock.cn.push({
10552 cls : 'input-group-addon input-group-append input-group-text',
10561 var ibwrap = inputblock;
10566 cls: 'roo-select2-choices',
10570 cls: 'roo-select2-search-field',
10582 cls: 'roo-select2-container input-group',
10587 cls: 'form-hidden-field'
10593 if(!this.multiple && this.showToggleBtn){
10599 if (this.caret != false) {
10602 cls: 'fa fa-' + this.caret
10609 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10614 cls: 'combobox-clear',
10628 combobox.cls += ' roo-select2-container-multi';
10632 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10633 tooltip : 'This field is required'
10635 if (Roo.bootstrap.version == 4) {
10638 style : 'display:none'
10643 if (align ==='left' && this.fieldLabel.length) {
10645 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10652 cls : 'control-label',
10653 html : this.fieldLabel
10665 var labelCfg = cfg.cn[1];
10666 var contentCfg = cfg.cn[2];
10668 if(this.indicatorpos == 'right'){
10673 cls : 'control-label',
10677 html : this.fieldLabel
10691 labelCfg = cfg.cn[0];
10692 contentCfg = cfg.cn[1];
10695 if(this.labelWidth > 12){
10696 labelCfg.style = "width: " + this.labelWidth + 'px';
10699 if(this.labelWidth < 13 && this.labelmd == 0){
10700 this.labelmd = this.labelWidth;
10703 if(this.labellg > 0){
10704 labelCfg.cls += ' col-lg-' + this.labellg;
10705 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10708 if(this.labelmd > 0){
10709 labelCfg.cls += ' col-md-' + this.labelmd;
10710 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10713 if(this.labelsm > 0){
10714 labelCfg.cls += ' col-sm-' + this.labelsm;
10715 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10718 if(this.labelxs > 0){
10719 labelCfg.cls += ' col-xs-' + this.labelxs;
10720 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10723 } else if ( this.fieldLabel.length) {
10724 // Roo.log(" label");
10729 //cls : 'input-group-addon',
10730 html : this.fieldLabel
10738 if(this.indicatorpos == 'right'){
10746 html : this.fieldLabel
10760 // Roo.log(" no label && no align");
10767 ['xs','sm','md','lg'].map(function(size){
10768 if (settings[size]) {
10769 cfg.cls += ' col-' + size + '-' + settings[size];
10780 onResize : function(w, h){
10781 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10782 // if(typeof w == 'number'){
10783 // var x = w - this.trigger.getWidth();
10784 // this.inputEl().setWidth(this.adjustWidth('input', x));
10785 // this.trigger.setStyle('left', x+'px');
10790 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10793 getResizeEl : function(){
10794 return this.inputEl();
10798 getPositionEl : function(){
10799 return this.inputEl();
10803 alignErrorIcon : function(){
10804 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10808 initEvents : function(){
10812 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10813 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10814 if(!this.multiple && this.showToggleBtn){
10815 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10816 if(this.hideTrigger){
10817 this.trigger.setDisplayed(false);
10819 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10823 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10826 if(this.removable && !this.editable && !this.tickable){
10827 var close = this.closeTriggerEl();
10830 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10831 close.on('click', this.removeBtnClick, this, close);
10835 //this.trigger.addClassOnOver('x-form-trigger-over');
10836 //this.trigger.addClassOnClick('x-form-trigger-click');
10839 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10843 closeTriggerEl : function()
10845 var close = this.el.select('.roo-combo-removable-btn', true).first();
10846 return close ? close : false;
10849 removeBtnClick : function(e, h, el)
10851 e.preventDefault();
10853 if(this.fireEvent("remove", this) !== false){
10855 this.fireEvent("afterremove", this)
10859 createList : function()
10861 this.list = Roo.get(document.body).createChild({
10862 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10863 cls: 'typeahead typeahead-long dropdown-menu',
10864 style: 'display:none'
10867 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10872 initTrigger : function(){
10877 onDestroy : function(){
10879 this.trigger.removeAllListeners();
10880 // this.trigger.remove();
10883 // this.wrap.remove();
10885 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10889 onFocus : function(){
10890 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10892 if(!this.mimicing){
10893 this.wrap.addClass('x-trigger-wrap-focus');
10894 this.mimicing = true;
10895 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10896 if(this.monitorTab){
10897 this.el.on("keydown", this.checkTab, this);
10904 checkTab : function(e){
10905 if(e.getKey() == e.TAB){
10906 this.triggerBlur();
10911 onBlur : function(){
10916 mimicBlur : function(e, t){
10918 if(!this.wrap.contains(t) && this.validateBlur()){
10919 this.triggerBlur();
10925 triggerBlur : function(){
10926 this.mimicing = false;
10927 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10928 if(this.monitorTab){
10929 this.el.un("keydown", this.checkTab, this);
10931 //this.wrap.removeClass('x-trigger-wrap-focus');
10932 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10936 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10937 validateBlur : function(e, t){
10942 onDisable : function(){
10943 this.inputEl().dom.disabled = true;
10944 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10946 // this.wrap.addClass('x-item-disabled');
10951 onEnable : function(){
10952 this.inputEl().dom.disabled = false;
10953 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10955 // this.el.removeClass('x-item-disabled');
10960 onShow : function(){
10961 var ae = this.getActionEl();
10964 ae.dom.style.display = '';
10965 ae.dom.style.visibility = 'visible';
10971 onHide : function(){
10972 var ae = this.getActionEl();
10973 ae.dom.style.display = 'none';
10977 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10978 * by an implementing function.
10980 * @param {EventObject} e
10982 onTriggerClick : Roo.emptyFn
10986 * Ext JS Library 1.1.1
10987 * Copyright(c) 2006-2007, Ext JS, LLC.
10989 * Originally Released Under LGPL - original licence link has changed is not relivant.
10992 * <script type="text/javascript">
10997 * @class Roo.data.SortTypes
10999 * Defines the default sorting (casting?) comparison functions used when sorting data.
11001 Roo.data.SortTypes = {
11003 * Default sort that does nothing
11004 * @param {Mixed} s The value being converted
11005 * @return {Mixed} The comparison value
11007 none : function(s){
11012 * The regular expression used to strip tags
11016 stripTagsRE : /<\/?[^>]+>/gi,
11019 * Strips all HTML tags to sort on text only
11020 * @param {Mixed} s The value being converted
11021 * @return {String} The comparison value
11023 asText : function(s){
11024 return String(s).replace(this.stripTagsRE, "");
11028 * Strips all HTML tags to sort on text only - Case insensitive
11029 * @param {Mixed} s The value being converted
11030 * @return {String} The comparison value
11032 asUCText : function(s){
11033 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11037 * Case insensitive string
11038 * @param {Mixed} s The value being converted
11039 * @return {String} The comparison value
11041 asUCString : function(s) {
11042 return String(s).toUpperCase();
11047 * @param {Mixed} s The value being converted
11048 * @return {Number} The comparison value
11050 asDate : function(s) {
11054 if(s instanceof Date){
11055 return s.getTime();
11057 return Date.parse(String(s));
11062 * @param {Mixed} s The value being converted
11063 * @return {Float} The comparison value
11065 asFloat : function(s) {
11066 var val = parseFloat(String(s).replace(/,/g, ""));
11075 * @param {Mixed} s The value being converted
11076 * @return {Number} The comparison value
11078 asInt : function(s) {
11079 var val = parseInt(String(s).replace(/,/g, ""));
11087 * Ext JS Library 1.1.1
11088 * Copyright(c) 2006-2007, Ext JS, LLC.
11090 * Originally Released Under LGPL - original licence link has changed is not relivant.
11093 * <script type="text/javascript">
11097 * @class Roo.data.Record
11098 * Instances of this class encapsulate both record <em>definition</em> information, and record
11099 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11100 * to access Records cached in an {@link Roo.data.Store} object.<br>
11102 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11103 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11106 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11108 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11109 * {@link #create}. The parameters are the same.
11110 * @param {Array} data An associative Array of data values keyed by the field name.
11111 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11112 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11113 * not specified an integer id is generated.
11115 Roo.data.Record = function(data, id){
11116 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11121 * Generate a constructor for a specific record layout.
11122 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11123 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11124 * Each field definition object may contain the following properties: <ul>
11125 * <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,
11126 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11127 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11128 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11129 * is being used, then this is a string containing the javascript expression to reference the data relative to
11130 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11131 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11132 * this may be omitted.</p></li>
11133 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11134 * <ul><li>auto (Default, implies no conversion)</li>
11139 * <li>date</li></ul></p></li>
11140 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11141 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11142 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11143 * by the Reader into an object that will be stored in the Record. It is passed the
11144 * following parameters:<ul>
11145 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11147 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11149 * <br>usage:<br><pre><code>
11150 var TopicRecord = Roo.data.Record.create(
11151 {name: 'title', mapping: 'topic_title'},
11152 {name: 'author', mapping: 'username'},
11153 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11154 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11155 {name: 'lastPoster', mapping: 'user2'},
11156 {name: 'excerpt', mapping: 'post_text'}
11159 var myNewRecord = new TopicRecord({
11160 title: 'Do my job please',
11163 lastPost: new Date(),
11164 lastPoster: 'Animal',
11165 excerpt: 'No way dude!'
11167 myStore.add(myNewRecord);
11172 Roo.data.Record.create = function(o){
11173 var f = function(){
11174 f.superclass.constructor.apply(this, arguments);
11176 Roo.extend(f, Roo.data.Record);
11177 var p = f.prototype;
11178 p.fields = new Roo.util.MixedCollection(false, function(field){
11181 for(var i = 0, len = o.length; i < len; i++){
11182 p.fields.add(new Roo.data.Field(o[i]));
11184 f.getField = function(name){
11185 return p.fields.get(name);
11190 Roo.data.Record.AUTO_ID = 1000;
11191 Roo.data.Record.EDIT = 'edit';
11192 Roo.data.Record.REJECT = 'reject';
11193 Roo.data.Record.COMMIT = 'commit';
11195 Roo.data.Record.prototype = {
11197 * Readonly flag - true if this record has been modified.
11206 join : function(store){
11207 this.store = store;
11211 * Set the named field to the specified value.
11212 * @param {String} name The name of the field to set.
11213 * @param {Object} value The value to set the field to.
11215 set : function(name, value){
11216 if(this.data[name] == value){
11220 if(!this.modified){
11221 this.modified = {};
11223 if(typeof this.modified[name] == 'undefined'){
11224 this.modified[name] = this.data[name];
11226 this.data[name] = value;
11227 if(!this.editing && this.store){
11228 this.store.afterEdit(this);
11233 * Get the value of the named field.
11234 * @param {String} name The name of the field to get the value of.
11235 * @return {Object} The value of the field.
11237 get : function(name){
11238 return this.data[name];
11242 beginEdit : function(){
11243 this.editing = true;
11244 this.modified = {};
11248 cancelEdit : function(){
11249 this.editing = false;
11250 delete this.modified;
11254 endEdit : function(){
11255 this.editing = false;
11256 if(this.dirty && this.store){
11257 this.store.afterEdit(this);
11262 * Usually called by the {@link Roo.data.Store} which owns the Record.
11263 * Rejects all changes made to the Record since either creation, or the last commit operation.
11264 * Modified fields are reverted to their original values.
11266 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11267 * of reject operations.
11269 reject : function(){
11270 var m = this.modified;
11272 if(typeof m[n] != "function"){
11273 this.data[n] = m[n];
11276 this.dirty = false;
11277 delete this.modified;
11278 this.editing = false;
11280 this.store.afterReject(this);
11285 * Usually called by the {@link Roo.data.Store} which owns the Record.
11286 * Commits all changes made to the Record since either creation, or the last commit operation.
11288 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11289 * of commit operations.
11291 commit : function(){
11292 this.dirty = false;
11293 delete this.modified;
11294 this.editing = false;
11296 this.store.afterCommit(this);
11301 hasError : function(){
11302 return this.error != null;
11306 clearError : function(){
11311 * Creates a copy of this record.
11312 * @param {String} id (optional) A new record id if you don't want to use this record's id
11315 copy : function(newId) {
11316 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11320 * Ext JS Library 1.1.1
11321 * Copyright(c) 2006-2007, Ext JS, LLC.
11323 * Originally Released Under LGPL - original licence link has changed is not relivant.
11326 * <script type="text/javascript">
11332 * @class Roo.data.Store
11333 * @extends Roo.util.Observable
11334 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11335 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11337 * 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
11338 * has no knowledge of the format of the data returned by the Proxy.<br>
11340 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11341 * instances from the data object. These records are cached and made available through accessor functions.
11343 * Creates a new Store.
11344 * @param {Object} config A config object containing the objects needed for the Store to access data,
11345 * and read the data into Records.
11347 Roo.data.Store = function(config){
11348 this.data = new Roo.util.MixedCollection(false);
11349 this.data.getKey = function(o){
11352 this.baseParams = {};
11354 this.paramNames = {
11359 "multisort" : "_multisort"
11362 if(config && config.data){
11363 this.inlineData = config.data;
11364 delete config.data;
11367 Roo.apply(this, config);
11369 if(this.reader){ // reader passed
11370 this.reader = Roo.factory(this.reader, Roo.data);
11371 this.reader.xmodule = this.xmodule || false;
11372 if(!this.recordType){
11373 this.recordType = this.reader.recordType;
11375 if(this.reader.onMetaChange){
11376 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11380 if(this.recordType){
11381 this.fields = this.recordType.prototype.fields;
11383 this.modified = [];
11387 * @event datachanged
11388 * Fires when the data cache has changed, and a widget which is using this Store
11389 * as a Record cache should refresh its view.
11390 * @param {Store} this
11392 datachanged : true,
11394 * @event metachange
11395 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11396 * @param {Store} this
11397 * @param {Object} meta The JSON metadata
11402 * Fires when Records have been added to the Store
11403 * @param {Store} this
11404 * @param {Roo.data.Record[]} records The array of Records added
11405 * @param {Number} index The index at which the record(s) were added
11410 * Fires when a Record has been removed from the Store
11411 * @param {Store} this
11412 * @param {Roo.data.Record} record The Record that was removed
11413 * @param {Number} index The index at which the record was removed
11418 * Fires when a Record has been updated
11419 * @param {Store} this
11420 * @param {Roo.data.Record} record The Record that was updated
11421 * @param {String} operation The update operation being performed. Value may be one of:
11423 Roo.data.Record.EDIT
11424 Roo.data.Record.REJECT
11425 Roo.data.Record.COMMIT
11431 * Fires when the data cache has been cleared.
11432 * @param {Store} this
11436 * @event beforeload
11437 * Fires before a request is made for a new data object. If the beforeload handler returns false
11438 * the load action will be canceled.
11439 * @param {Store} this
11440 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11444 * @event beforeloadadd
11445 * Fires after a new set of Records has been loaded.
11446 * @param {Store} this
11447 * @param {Roo.data.Record[]} records The Records that were loaded
11448 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11450 beforeloadadd : true,
11453 * Fires after a new set of Records has been loaded, before they are added to the store.
11454 * @param {Store} this
11455 * @param {Roo.data.Record[]} records The Records that were loaded
11456 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11457 * @params {Object} return from reader
11461 * @event loadexception
11462 * Fires if an exception occurs in the Proxy during loading.
11463 * Called with the signature of the Proxy's "loadexception" event.
11464 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11467 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11468 * @param {Object} load options
11469 * @param {Object} jsonData from your request (normally this contains the Exception)
11471 loadexception : true
11475 this.proxy = Roo.factory(this.proxy, Roo.data);
11476 this.proxy.xmodule = this.xmodule || false;
11477 this.relayEvents(this.proxy, ["loadexception"]);
11479 this.sortToggle = {};
11480 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11482 Roo.data.Store.superclass.constructor.call(this);
11484 if(this.inlineData){
11485 this.loadData(this.inlineData);
11486 delete this.inlineData;
11490 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11492 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11493 * without a remote query - used by combo/forms at present.
11497 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11500 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11503 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11504 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11507 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11508 * on any HTTP request
11511 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11514 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11518 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11519 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11521 remoteSort : false,
11524 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11525 * loaded or when a record is removed. (defaults to false).
11527 pruneModifiedRecords : false,
11530 lastOptions : null,
11533 * Add Records to the Store and fires the add event.
11534 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11536 add : function(records){
11537 records = [].concat(records);
11538 for(var i = 0, len = records.length; i < len; i++){
11539 records[i].join(this);
11541 var index = this.data.length;
11542 this.data.addAll(records);
11543 this.fireEvent("add", this, records, index);
11547 * Remove a Record from the Store and fires the remove event.
11548 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11550 remove : function(record){
11551 var index = this.data.indexOf(record);
11552 this.data.removeAt(index);
11554 if(this.pruneModifiedRecords){
11555 this.modified.remove(record);
11557 this.fireEvent("remove", this, record, index);
11561 * Remove all Records from the Store and fires the clear event.
11563 removeAll : function(){
11565 if(this.pruneModifiedRecords){
11566 this.modified = [];
11568 this.fireEvent("clear", this);
11572 * Inserts Records to the Store at the given index and fires the add event.
11573 * @param {Number} index The start index at which to insert the passed Records.
11574 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11576 insert : function(index, records){
11577 records = [].concat(records);
11578 for(var i = 0, len = records.length; i < len; i++){
11579 this.data.insert(index, records[i]);
11580 records[i].join(this);
11582 this.fireEvent("add", this, records, index);
11586 * Get the index within the cache of the passed Record.
11587 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11588 * @return {Number} The index of the passed Record. Returns -1 if not found.
11590 indexOf : function(record){
11591 return this.data.indexOf(record);
11595 * Get the index within the cache of the Record with the passed id.
11596 * @param {String} id The id of the Record to find.
11597 * @return {Number} The index of the Record. Returns -1 if not found.
11599 indexOfId : function(id){
11600 return this.data.indexOfKey(id);
11604 * Get the Record with the specified id.
11605 * @param {String} id The id of the Record to find.
11606 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11608 getById : function(id){
11609 return this.data.key(id);
11613 * Get the Record at the specified index.
11614 * @param {Number} index The index of the Record to find.
11615 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11617 getAt : function(index){
11618 return this.data.itemAt(index);
11622 * Returns a range of Records between specified indices.
11623 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11624 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11625 * @return {Roo.data.Record[]} An array of Records
11627 getRange : function(start, end){
11628 return this.data.getRange(start, end);
11632 storeOptions : function(o){
11633 o = Roo.apply({}, o);
11636 this.lastOptions = o;
11640 * Loads the Record cache from the configured Proxy using the configured Reader.
11642 * If using remote paging, then the first load call must specify the <em>start</em>
11643 * and <em>limit</em> properties in the options.params property to establish the initial
11644 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11646 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11647 * and this call will return before the new data has been loaded. Perform any post-processing
11648 * in a callback function, or in a "load" event handler.</strong>
11650 * @param {Object} options An object containing properties which control loading options:<ul>
11651 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11652 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11653 * passed the following arguments:<ul>
11654 * <li>r : Roo.data.Record[]</li>
11655 * <li>options: Options object from the load call</li>
11656 * <li>success: Boolean success indicator</li></ul></li>
11657 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11658 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11661 load : function(options){
11662 options = options || {};
11663 if(this.fireEvent("beforeload", this, options) !== false){
11664 this.storeOptions(options);
11665 var p = Roo.apply(options.params || {}, this.baseParams);
11666 // if meta was not loaded from remote source.. try requesting it.
11667 if (!this.reader.metaFromRemote) {
11668 p._requestMeta = 1;
11670 if(this.sortInfo && this.remoteSort){
11671 var pn = this.paramNames;
11672 p[pn["sort"]] = this.sortInfo.field;
11673 p[pn["dir"]] = this.sortInfo.direction;
11675 if (this.multiSort) {
11676 var pn = this.paramNames;
11677 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11680 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11685 * Reloads the Record cache from the configured Proxy using the configured Reader and
11686 * the options from the last load operation performed.
11687 * @param {Object} options (optional) An object containing properties which may override the options
11688 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11689 * the most recently used options are reused).
11691 reload : function(options){
11692 this.load(Roo.applyIf(options||{}, this.lastOptions));
11696 // Called as a callback by the Reader during a load operation.
11697 loadRecords : function(o, options, success){
11698 if(!o || success === false){
11699 if(success !== false){
11700 this.fireEvent("load", this, [], options, o);
11702 if(options.callback){
11703 options.callback.call(options.scope || this, [], options, false);
11707 // if data returned failure - throw an exception.
11708 if (o.success === false) {
11709 // show a message if no listener is registered.
11710 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11711 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11713 // loadmask wil be hooked into this..
11714 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11717 var r = o.records, t = o.totalRecords || r.length;
11719 this.fireEvent("beforeloadadd", this, r, options, o);
11721 if(!options || options.add !== true){
11722 if(this.pruneModifiedRecords){
11723 this.modified = [];
11725 for(var i = 0, len = r.length; i < len; i++){
11729 this.data = this.snapshot;
11730 delete this.snapshot;
11733 this.data.addAll(r);
11734 this.totalLength = t;
11736 this.fireEvent("datachanged", this);
11738 this.totalLength = Math.max(t, this.data.length+r.length);
11742 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11744 var e = new Roo.data.Record({});
11746 e.set(this.parent.displayField, this.parent.emptyTitle);
11747 e.set(this.parent.valueField, '');
11752 this.fireEvent("load", this, r, options, o);
11753 if(options.callback){
11754 options.callback.call(options.scope || this, r, options, true);
11760 * Loads data from a passed data block. A Reader which understands the format of the data
11761 * must have been configured in the constructor.
11762 * @param {Object} data The data block from which to read the Records. The format of the data expected
11763 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11764 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11766 loadData : function(o, append){
11767 var r = this.reader.readRecords(o);
11768 this.loadRecords(r, {add: append}, true);
11772 * Gets the number of cached records.
11774 * <em>If using paging, this may not be the total size of the dataset. If the data object
11775 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11776 * the data set size</em>
11778 getCount : function(){
11779 return this.data.length || 0;
11783 * Gets the total number of records in the dataset as returned by the server.
11785 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11786 * the dataset size</em>
11788 getTotalCount : function(){
11789 return this.totalLength || 0;
11793 * Returns the sort state of the Store as an object with two properties:
11795 field {String} The name of the field by which the Records are sorted
11796 direction {String} The sort order, "ASC" or "DESC"
11799 getSortState : function(){
11800 return this.sortInfo;
11804 applySort : function(){
11805 if(this.sortInfo && !this.remoteSort){
11806 var s = this.sortInfo, f = s.field;
11807 var st = this.fields.get(f).sortType;
11808 var fn = function(r1, r2){
11809 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11810 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11812 this.data.sort(s.direction, fn);
11813 if(this.snapshot && this.snapshot != this.data){
11814 this.snapshot.sort(s.direction, fn);
11820 * Sets the default sort column and order to be used by the next load operation.
11821 * @param {String} fieldName The name of the field to sort by.
11822 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11824 setDefaultSort : function(field, dir){
11825 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11829 * Sort the Records.
11830 * If remote sorting is used, the sort is performed on the server, and the cache is
11831 * reloaded. If local sorting is used, the cache is sorted internally.
11832 * @param {String} fieldName The name of the field to sort by.
11833 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11835 sort : function(fieldName, dir){
11836 var f = this.fields.get(fieldName);
11838 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11840 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11841 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11846 this.sortToggle[f.name] = dir;
11847 this.sortInfo = {field: f.name, direction: dir};
11848 if(!this.remoteSort){
11850 this.fireEvent("datachanged", this);
11852 this.load(this.lastOptions);
11857 * Calls the specified function for each of the Records in the cache.
11858 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11859 * Returning <em>false</em> aborts and exits the iteration.
11860 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11862 each : function(fn, scope){
11863 this.data.each(fn, scope);
11867 * Gets all records modified since the last commit. Modified records are persisted across load operations
11868 * (e.g., during paging).
11869 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11871 getModifiedRecords : function(){
11872 return this.modified;
11876 createFilterFn : function(property, value, anyMatch){
11877 if(!value.exec){ // not a regex
11878 value = String(value);
11879 if(value.length == 0){
11882 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11884 return function(r){
11885 return value.test(r.data[property]);
11890 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11891 * @param {String} property A field on your records
11892 * @param {Number} start The record index to start at (defaults to 0)
11893 * @param {Number} end The last record index to include (defaults to length - 1)
11894 * @return {Number} The sum
11896 sum : function(property, start, end){
11897 var rs = this.data.items, v = 0;
11898 start = start || 0;
11899 end = (end || end === 0) ? end : rs.length-1;
11901 for(var i = start; i <= end; i++){
11902 v += (rs[i].data[property] || 0);
11908 * Filter the records by a specified property.
11909 * @param {String} field A field on your records
11910 * @param {String/RegExp} value Either a string that the field
11911 * should start with or a RegExp to test against the field
11912 * @param {Boolean} anyMatch True to match any part not just the beginning
11914 filter : function(property, value, anyMatch){
11915 var fn = this.createFilterFn(property, value, anyMatch);
11916 return fn ? this.filterBy(fn) : this.clearFilter();
11920 * Filter by a function. The specified function will be called with each
11921 * record in this data source. If the function returns true the record is included,
11922 * otherwise it is filtered.
11923 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11924 * @param {Object} scope (optional) The scope of the function (defaults to this)
11926 filterBy : function(fn, scope){
11927 this.snapshot = this.snapshot || this.data;
11928 this.data = this.queryBy(fn, scope||this);
11929 this.fireEvent("datachanged", this);
11933 * Query the records by a specified property.
11934 * @param {String} field A field on your records
11935 * @param {String/RegExp} value Either a string that the field
11936 * should start with or a RegExp to test against the field
11937 * @param {Boolean} anyMatch True to match any part not just the beginning
11938 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11940 query : function(property, value, anyMatch){
11941 var fn = this.createFilterFn(property, value, anyMatch);
11942 return fn ? this.queryBy(fn) : this.data.clone();
11946 * Query by a function. The specified function will be called with each
11947 * record in this data source. If the function returns true the record is included
11949 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11950 * @param {Object} scope (optional) The scope of the function (defaults to this)
11951 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11953 queryBy : function(fn, scope){
11954 var data = this.snapshot || this.data;
11955 return data.filterBy(fn, scope||this);
11959 * Collects unique values for a particular dataIndex from this store.
11960 * @param {String} dataIndex The property to collect
11961 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11962 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11963 * @return {Array} An array of the unique values
11965 collect : function(dataIndex, allowNull, bypassFilter){
11966 var d = (bypassFilter === true && this.snapshot) ?
11967 this.snapshot.items : this.data.items;
11968 var v, sv, r = [], l = {};
11969 for(var i = 0, len = d.length; i < len; i++){
11970 v = d[i].data[dataIndex];
11972 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11981 * Revert to a view of the Record cache with no filtering applied.
11982 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11984 clearFilter : function(suppressEvent){
11985 if(this.snapshot && this.snapshot != this.data){
11986 this.data = this.snapshot;
11987 delete this.snapshot;
11988 if(suppressEvent !== true){
11989 this.fireEvent("datachanged", this);
11995 afterEdit : function(record){
11996 if(this.modified.indexOf(record) == -1){
11997 this.modified.push(record);
11999 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12003 afterReject : function(record){
12004 this.modified.remove(record);
12005 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12009 afterCommit : function(record){
12010 this.modified.remove(record);
12011 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12015 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12016 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12018 commitChanges : function(){
12019 var m = this.modified.slice(0);
12020 this.modified = [];
12021 for(var i = 0, len = m.length; i < len; i++){
12027 * Cancel outstanding changes on all changed records.
12029 rejectChanges : function(){
12030 var m = this.modified.slice(0);
12031 this.modified = [];
12032 for(var i = 0, len = m.length; i < len; i++){
12037 onMetaChange : function(meta, rtype, o){
12038 this.recordType = rtype;
12039 this.fields = rtype.prototype.fields;
12040 delete this.snapshot;
12041 this.sortInfo = meta.sortInfo || this.sortInfo;
12042 this.modified = [];
12043 this.fireEvent('metachange', this, this.reader.meta);
12046 moveIndex : function(data, type)
12048 var index = this.indexOf(data);
12050 var newIndex = index + type;
12054 this.insert(newIndex, data);
12059 * Ext JS Library 1.1.1
12060 * Copyright(c) 2006-2007, Ext JS, LLC.
12062 * Originally Released Under LGPL - original licence link has changed is not relivant.
12065 * <script type="text/javascript">
12069 * @class Roo.data.SimpleStore
12070 * @extends Roo.data.Store
12071 * Small helper class to make creating Stores from Array data easier.
12072 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12073 * @cfg {Array} fields An array of field definition objects, or field name strings.
12074 * @cfg {Array} data The multi-dimensional array of data
12076 * @param {Object} config
12078 Roo.data.SimpleStore = function(config){
12079 Roo.data.SimpleStore.superclass.constructor.call(this, {
12081 reader: new Roo.data.ArrayReader({
12084 Roo.data.Record.create(config.fields)
12086 proxy : new Roo.data.MemoryProxy(config.data)
12090 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12092 * Ext JS Library 1.1.1
12093 * Copyright(c) 2006-2007, Ext JS, LLC.
12095 * Originally Released Under LGPL - original licence link has changed is not relivant.
12098 * <script type="text/javascript">
12103 * @extends Roo.data.Store
12104 * @class Roo.data.JsonStore
12105 * Small helper class to make creating Stores for JSON data easier. <br/>
12107 var store = new Roo.data.JsonStore({
12108 url: 'get-images.php',
12110 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12113 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12114 * JsonReader and HttpProxy (unless inline data is provided).</b>
12115 * @cfg {Array} fields An array of field definition objects, or field name strings.
12117 * @param {Object} config
12119 Roo.data.JsonStore = function(c){
12120 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12121 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12122 reader: new Roo.data.JsonReader(c, c.fields)
12125 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12127 * Ext JS Library 1.1.1
12128 * Copyright(c) 2006-2007, Ext JS, LLC.
12130 * Originally Released Under LGPL - original licence link has changed is not relivant.
12133 * <script type="text/javascript">
12137 Roo.data.Field = function(config){
12138 if(typeof config == "string"){
12139 config = {name: config};
12141 Roo.apply(this, config);
12144 this.type = "auto";
12147 var st = Roo.data.SortTypes;
12148 // named sortTypes are supported, here we look them up
12149 if(typeof this.sortType == "string"){
12150 this.sortType = st[this.sortType];
12153 // set default sortType for strings and dates
12154 if(!this.sortType){
12157 this.sortType = st.asUCString;
12160 this.sortType = st.asDate;
12163 this.sortType = st.none;
12168 var stripRe = /[\$,%]/g;
12170 // prebuilt conversion function for this field, instead of
12171 // switching every time we're reading a value
12173 var cv, dateFormat = this.dateFormat;
12178 cv = function(v){ return v; };
12181 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12185 return v !== undefined && v !== null && v !== '' ?
12186 parseInt(String(v).replace(stripRe, ""), 10) : '';
12191 return v !== undefined && v !== null && v !== '' ?
12192 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12197 cv = function(v){ return v === true || v === "true" || v == 1; };
12204 if(v instanceof Date){
12208 if(dateFormat == "timestamp"){
12209 return new Date(v*1000);
12211 return Date.parseDate(v, dateFormat);
12213 var parsed = Date.parse(v);
12214 return parsed ? new Date(parsed) : null;
12223 Roo.data.Field.prototype = {
12231 * Ext JS Library 1.1.1
12232 * Copyright(c) 2006-2007, Ext JS, LLC.
12234 * Originally Released Under LGPL - original licence link has changed is not relivant.
12237 * <script type="text/javascript">
12240 // Base class for reading structured data from a data source. This class is intended to be
12241 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12244 * @class Roo.data.DataReader
12245 * Base class for reading structured data from a data source. This class is intended to be
12246 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12249 Roo.data.DataReader = function(meta, recordType){
12253 this.recordType = recordType instanceof Array ?
12254 Roo.data.Record.create(recordType) : recordType;
12257 Roo.data.DataReader.prototype = {
12259 * Create an empty record
12260 * @param {Object} data (optional) - overlay some values
12261 * @return {Roo.data.Record} record created.
12263 newRow : function(d) {
12265 this.recordType.prototype.fields.each(function(c) {
12267 case 'int' : da[c.name] = 0; break;
12268 case 'date' : da[c.name] = new Date(); break;
12269 case 'float' : da[c.name] = 0.0; break;
12270 case 'boolean' : da[c.name] = false; break;
12271 default : da[c.name] = ""; break;
12275 return new this.recordType(Roo.apply(da, d));
12280 * Ext JS Library 1.1.1
12281 * Copyright(c) 2006-2007, Ext JS, LLC.
12283 * Originally Released Under LGPL - original licence link has changed is not relivant.
12286 * <script type="text/javascript">
12290 * @class Roo.data.DataProxy
12291 * @extends Roo.data.Observable
12292 * This class is an abstract base class for implementations which provide retrieval of
12293 * unformatted data objects.<br>
12295 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12296 * (of the appropriate type which knows how to parse the data object) to provide a block of
12297 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12299 * Custom implementations must implement the load method as described in
12300 * {@link Roo.data.HttpProxy#load}.
12302 Roo.data.DataProxy = function(){
12305 * @event beforeload
12306 * Fires before a network request is made to retrieve a data object.
12307 * @param {Object} This DataProxy object.
12308 * @param {Object} params The params parameter to the load function.
12313 * Fires before the load method's callback is called.
12314 * @param {Object} This DataProxy object.
12315 * @param {Object} o The data object.
12316 * @param {Object} arg The callback argument object passed to the load function.
12320 * @event loadexception
12321 * Fires if an Exception occurs during data retrieval.
12322 * @param {Object} This DataProxy object.
12323 * @param {Object} o The data object.
12324 * @param {Object} arg The callback argument object passed to the load function.
12325 * @param {Object} e The Exception.
12327 loadexception : true
12329 Roo.data.DataProxy.superclass.constructor.call(this);
12332 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12335 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12339 * Ext JS Library 1.1.1
12340 * Copyright(c) 2006-2007, Ext JS, LLC.
12342 * Originally Released Under LGPL - original licence link has changed is not relivant.
12345 * <script type="text/javascript">
12348 * @class Roo.data.MemoryProxy
12349 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12350 * to the Reader when its load method is called.
12352 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12354 Roo.data.MemoryProxy = function(data){
12358 Roo.data.MemoryProxy.superclass.constructor.call(this);
12362 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12365 * Load data from the requested source (in this case an in-memory
12366 * data object passed to the constructor), read the data object into
12367 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12368 * process that block using the passed callback.
12369 * @param {Object} params This parameter is not used by the MemoryProxy class.
12370 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12371 * object into a block of Roo.data.Records.
12372 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12373 * The function must be passed <ul>
12374 * <li>The Record block object</li>
12375 * <li>The "arg" argument from the load function</li>
12376 * <li>A boolean success indicator</li>
12378 * @param {Object} scope The scope in which to call the callback
12379 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12381 load : function(params, reader, callback, scope, arg){
12382 params = params || {};
12385 result = reader.readRecords(params.data ? params.data :this.data);
12387 this.fireEvent("loadexception", this, arg, null, e);
12388 callback.call(scope, null, arg, false);
12391 callback.call(scope, result, arg, true);
12395 update : function(params, records){
12400 * Ext JS Library 1.1.1
12401 * Copyright(c) 2006-2007, Ext JS, LLC.
12403 * Originally Released Under LGPL - original licence link has changed is not relivant.
12406 * <script type="text/javascript">
12409 * @class Roo.data.HttpProxy
12410 * @extends Roo.data.DataProxy
12411 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12412 * configured to reference a certain URL.<br><br>
12414 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12415 * from which the running page was served.<br><br>
12417 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12419 * Be aware that to enable the browser to parse an XML document, the server must set
12420 * the Content-Type header in the HTTP response to "text/xml".
12422 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12423 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12424 * will be used to make the request.
12426 Roo.data.HttpProxy = function(conn){
12427 Roo.data.HttpProxy.superclass.constructor.call(this);
12428 // is conn a conn config or a real conn?
12430 this.useAjax = !conn || !conn.events;
12434 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12435 // thse are take from connection...
12438 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12441 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12442 * extra parameters to each request made by this object. (defaults to undefined)
12445 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12446 * to each request made by this object. (defaults to undefined)
12449 * @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)
12452 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12455 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12461 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12465 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12466 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12467 * a finer-grained basis than the DataProxy events.
12469 getConnection : function(){
12470 return this.useAjax ? Roo.Ajax : this.conn;
12474 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12475 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12476 * process that block using the passed callback.
12477 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12478 * for the request to the remote server.
12479 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12480 * object into a block of Roo.data.Records.
12481 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12482 * The function must be passed <ul>
12483 * <li>The Record block object</li>
12484 * <li>The "arg" argument from the load function</li>
12485 * <li>A boolean success indicator</li>
12487 * @param {Object} scope The scope in which to call the callback
12488 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12490 load : function(params, reader, callback, scope, arg){
12491 if(this.fireEvent("beforeload", this, params) !== false){
12493 params : params || {},
12495 callback : callback,
12500 callback : this.loadResponse,
12504 Roo.applyIf(o, this.conn);
12505 if(this.activeRequest){
12506 Roo.Ajax.abort(this.activeRequest);
12508 this.activeRequest = Roo.Ajax.request(o);
12510 this.conn.request(o);
12513 callback.call(scope||this, null, arg, false);
12518 loadResponse : function(o, success, response){
12519 delete this.activeRequest;
12521 this.fireEvent("loadexception", this, o, response);
12522 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12527 result = o.reader.read(response);
12529 this.fireEvent("loadexception", this, o, response, e);
12530 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12534 this.fireEvent("load", this, o, o.request.arg);
12535 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12539 update : function(dataSet){
12544 updateResponse : function(dataSet){
12549 * Ext JS Library 1.1.1
12550 * Copyright(c) 2006-2007, Ext JS, LLC.
12552 * Originally Released Under LGPL - original licence link has changed is not relivant.
12555 * <script type="text/javascript">
12559 * @class Roo.data.ScriptTagProxy
12560 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12561 * other than the originating domain of the running page.<br><br>
12563 * <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
12564 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12566 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12567 * source code that is used as the source inside a <script> tag.<br><br>
12569 * In order for the browser to process the returned data, the server must wrap the data object
12570 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12571 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12572 * depending on whether the callback name was passed:
12575 boolean scriptTag = false;
12576 String cb = request.getParameter("callback");
12579 response.setContentType("text/javascript");
12581 response.setContentType("application/x-json");
12583 Writer out = response.getWriter();
12585 out.write(cb + "(");
12587 out.print(dataBlock.toJsonString());
12594 * @param {Object} config A configuration object.
12596 Roo.data.ScriptTagProxy = function(config){
12597 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12598 Roo.apply(this, config);
12599 this.head = document.getElementsByTagName("head")[0];
12602 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12604 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12606 * @cfg {String} url The URL from which to request the data object.
12609 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12613 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12614 * the server the name of the callback function set up by the load call to process the returned data object.
12615 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12616 * javascript output which calls this named function passing the data object as its only parameter.
12618 callbackParam : "callback",
12620 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12621 * name to the request.
12626 * Load data from the configured URL, read the data object into
12627 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12628 * process that block using the passed callback.
12629 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12630 * for the request to the remote server.
12631 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12632 * object into a block of Roo.data.Records.
12633 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12634 * The function must be passed <ul>
12635 * <li>The Record block object</li>
12636 * <li>The "arg" argument from the load function</li>
12637 * <li>A boolean success indicator</li>
12639 * @param {Object} scope The scope in which to call the callback
12640 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12642 load : function(params, reader, callback, scope, arg){
12643 if(this.fireEvent("beforeload", this, params) !== false){
12645 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12647 var url = this.url;
12648 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12650 url += "&_dc=" + (new Date().getTime());
12652 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12655 cb : "stcCallback"+transId,
12656 scriptId : "stcScript"+transId,
12660 callback : callback,
12666 window[trans.cb] = function(o){
12667 conn.handleResponse(o, trans);
12670 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12672 if(this.autoAbort !== false){
12676 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12678 var script = document.createElement("script");
12679 script.setAttribute("src", url);
12680 script.setAttribute("type", "text/javascript");
12681 script.setAttribute("id", trans.scriptId);
12682 this.head.appendChild(script);
12684 this.trans = trans;
12686 callback.call(scope||this, null, arg, false);
12691 isLoading : function(){
12692 return this.trans ? true : false;
12696 * Abort the current server request.
12698 abort : function(){
12699 if(this.isLoading()){
12700 this.destroyTrans(this.trans);
12705 destroyTrans : function(trans, isLoaded){
12706 this.head.removeChild(document.getElementById(trans.scriptId));
12707 clearTimeout(trans.timeoutId);
12709 window[trans.cb] = undefined;
12711 delete window[trans.cb];
12714 // if hasn't been loaded, wait for load to remove it to prevent script error
12715 window[trans.cb] = function(){
12716 window[trans.cb] = undefined;
12718 delete window[trans.cb];
12725 handleResponse : function(o, trans){
12726 this.trans = false;
12727 this.destroyTrans(trans, true);
12730 result = trans.reader.readRecords(o);
12732 this.fireEvent("loadexception", this, o, trans.arg, e);
12733 trans.callback.call(trans.scope||window, null, trans.arg, false);
12736 this.fireEvent("load", this, o, trans.arg);
12737 trans.callback.call(trans.scope||window, result, trans.arg, true);
12741 handleFailure : function(trans){
12742 this.trans = false;
12743 this.destroyTrans(trans, false);
12744 this.fireEvent("loadexception", this, null, trans.arg);
12745 trans.callback.call(trans.scope||window, null, trans.arg, false);
12749 * Ext JS Library 1.1.1
12750 * Copyright(c) 2006-2007, Ext JS, LLC.
12752 * Originally Released Under LGPL - original licence link has changed is not relivant.
12755 * <script type="text/javascript">
12759 * @class Roo.data.JsonReader
12760 * @extends Roo.data.DataReader
12761 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12762 * based on mappings in a provided Roo.data.Record constructor.
12764 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12765 * in the reply previously.
12770 var RecordDef = Roo.data.Record.create([
12771 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12772 {name: 'occupation'} // This field will use "occupation" as the mapping.
12774 var myReader = new Roo.data.JsonReader({
12775 totalProperty: "results", // The property which contains the total dataset size (optional)
12776 root: "rows", // The property which contains an Array of row objects
12777 id: "id" // The property within each row object that provides an ID for the record (optional)
12781 * This would consume a JSON file like this:
12783 { 'results': 2, 'rows': [
12784 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12785 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12788 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12789 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12790 * paged from the remote server.
12791 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12792 * @cfg {String} root name of the property which contains the Array of row objects.
12793 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12794 * @cfg {Array} fields Array of field definition objects
12796 * Create a new JsonReader
12797 * @param {Object} meta Metadata configuration options
12798 * @param {Object} recordType Either an Array of field definition objects,
12799 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12801 Roo.data.JsonReader = function(meta, recordType){
12804 // set some defaults:
12805 Roo.applyIf(meta, {
12806 totalProperty: 'total',
12807 successProperty : 'success',
12812 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12814 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12817 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12818 * Used by Store query builder to append _requestMeta to params.
12821 metaFromRemote : false,
12823 * This method is only used by a DataProxy which has retrieved data from a remote server.
12824 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12825 * @return {Object} data A data block which is used by an Roo.data.Store object as
12826 * a cache of Roo.data.Records.
12828 read : function(response){
12829 var json = response.responseText;
12831 var o = /* eval:var:o */ eval("("+json+")");
12833 throw {message: "JsonReader.read: Json object not found"};
12839 this.metaFromRemote = true;
12840 this.meta = o.metaData;
12841 this.recordType = Roo.data.Record.create(o.metaData.fields);
12842 this.onMetaChange(this.meta, this.recordType, o);
12844 return this.readRecords(o);
12847 // private function a store will implement
12848 onMetaChange : function(meta, recordType, o){
12855 simpleAccess: function(obj, subsc) {
12862 getJsonAccessor: function(){
12864 return function(expr) {
12866 return(re.test(expr))
12867 ? new Function("obj", "return obj." + expr)
12872 return Roo.emptyFn;
12877 * Create a data block containing Roo.data.Records from an XML document.
12878 * @param {Object} o An object which contains an Array of row objects in the property specified
12879 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12880 * which contains the total size of the dataset.
12881 * @return {Object} data A data block which is used by an Roo.data.Store object as
12882 * a cache of Roo.data.Records.
12884 readRecords : function(o){
12886 * After any data loads, the raw JSON data is available for further custom processing.
12890 var s = this.meta, Record = this.recordType,
12891 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12893 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12895 if(s.totalProperty) {
12896 this.getTotal = this.getJsonAccessor(s.totalProperty);
12898 if(s.successProperty) {
12899 this.getSuccess = this.getJsonAccessor(s.successProperty);
12901 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12903 var g = this.getJsonAccessor(s.id);
12904 this.getId = function(rec) {
12906 return (r === undefined || r === "") ? null : r;
12909 this.getId = function(){return null;};
12912 for(var jj = 0; jj < fl; jj++){
12914 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12915 this.ef[jj] = this.getJsonAccessor(map);
12919 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12920 if(s.totalProperty){
12921 var vt = parseInt(this.getTotal(o), 10);
12926 if(s.successProperty){
12927 var vs = this.getSuccess(o);
12928 if(vs === false || vs === 'false'){
12933 for(var i = 0; i < c; i++){
12936 var id = this.getId(n);
12937 for(var j = 0; j < fl; j++){
12939 var v = this.ef[j](n);
12941 Roo.log('missing convert for ' + f.name);
12945 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12947 var record = new Record(values, id);
12949 records[i] = record;
12955 totalRecords : totalRecords
12960 * Ext JS Library 1.1.1
12961 * Copyright(c) 2006-2007, Ext JS, LLC.
12963 * Originally Released Under LGPL - original licence link has changed is not relivant.
12966 * <script type="text/javascript">
12970 * @class Roo.data.ArrayReader
12971 * @extends Roo.data.DataReader
12972 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12973 * Each element of that Array represents a row of data fields. The
12974 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12975 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12979 var RecordDef = Roo.data.Record.create([
12980 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12981 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12983 var myReader = new Roo.data.ArrayReader({
12984 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12988 * This would consume an Array like this:
12990 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12992 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12994 * Create a new JsonReader
12995 * @param {Object} meta Metadata configuration options.
12996 * @param {Object} recordType Either an Array of field definition objects
12997 * @cfg {Array} fields Array of field definition objects
12998 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12999 * as specified to {@link Roo.data.Record#create},
13000 * or an {@link Roo.data.Record} object
13001 * created using {@link Roo.data.Record#create}.
13003 Roo.data.ArrayReader = function(meta, recordType){
13006 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13009 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13011 * Create a data block containing Roo.data.Records from an XML document.
13012 * @param {Object} o An Array of row objects which represents the dataset.
13013 * @return {Object} data A data block which is used by an Roo.data.Store object as
13014 * a cache of Roo.data.Records.
13016 readRecords : function(o){
13017 var sid = this.meta ? this.meta.id : null;
13018 var recordType = this.recordType, fields = recordType.prototype.fields;
13021 for(var i = 0; i < root.length; i++){
13024 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13025 for(var j = 0, jlen = fields.length; j < jlen; j++){
13026 var f = fields.items[j];
13027 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13028 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13030 values[f.name] = v;
13032 var record = new recordType(values, id);
13034 records[records.length] = record;
13038 totalRecords : records.length
13047 * @class Roo.bootstrap.ComboBox
13048 * @extends Roo.bootstrap.TriggerField
13049 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13050 * @cfg {Boolean} append (true|false) default false
13051 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13052 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13053 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13054 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13055 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13056 * @cfg {Boolean} animate default true
13057 * @cfg {Boolean} emptyResultText only for touch device
13058 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13059 * @cfg {String} emptyTitle default ''
13061 * Create a new ComboBox.
13062 * @param {Object} config Configuration options
13064 Roo.bootstrap.ComboBox = function(config){
13065 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13069 * Fires when the dropdown list is expanded
13070 * @param {Roo.bootstrap.ComboBox} combo This combo box
13075 * Fires when the dropdown list is collapsed
13076 * @param {Roo.bootstrap.ComboBox} combo This combo box
13080 * @event beforeselect
13081 * Fires before a list item is selected. Return false to cancel the selection.
13082 * @param {Roo.bootstrap.ComboBox} combo This combo box
13083 * @param {Roo.data.Record} record The data record returned from the underlying store
13084 * @param {Number} index The index of the selected item in the dropdown list
13086 'beforeselect' : true,
13089 * Fires when a list item is selected
13090 * @param {Roo.bootstrap.ComboBox} combo This combo box
13091 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13092 * @param {Number} index The index of the selected item in the dropdown list
13096 * @event beforequery
13097 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13098 * The event object passed has these properties:
13099 * @param {Roo.bootstrap.ComboBox} combo This combo box
13100 * @param {String} query The query
13101 * @param {Boolean} forceAll true to force "all" query
13102 * @param {Boolean} cancel true to cancel the query
13103 * @param {Object} e The query event object
13105 'beforequery': true,
13108 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13109 * @param {Roo.bootstrap.ComboBox} combo This combo box
13114 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13115 * @param {Roo.bootstrap.ComboBox} combo This combo box
13116 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13121 * Fires when the remove value from the combobox array
13122 * @param {Roo.bootstrap.ComboBox} combo This combo box
13126 * @event afterremove
13127 * Fires when the remove value from the combobox array
13128 * @param {Roo.bootstrap.ComboBox} combo This combo box
13130 'afterremove' : true,
13132 * @event specialfilter
13133 * Fires when specialfilter
13134 * @param {Roo.bootstrap.ComboBox} combo This combo box
13136 'specialfilter' : true,
13139 * Fires when tick the element
13140 * @param {Roo.bootstrap.ComboBox} combo This combo box
13144 * @event touchviewdisplay
13145 * Fires when touch view require special display (default is using displayField)
13146 * @param {Roo.bootstrap.ComboBox} combo This combo box
13147 * @param {Object} cfg set html .
13149 'touchviewdisplay' : true
13154 this.tickItems = [];
13156 this.selectedIndex = -1;
13157 if(this.mode == 'local'){
13158 if(config.queryDelay === undefined){
13159 this.queryDelay = 10;
13161 if(config.minChars === undefined){
13167 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13170 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13171 * rendering into an Roo.Editor, defaults to false)
13174 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13175 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13178 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13181 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13182 * the dropdown list (defaults to undefined, with no header element)
13186 * @cfg {String/Roo.Template} tpl The template to use to render the output
13190 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13192 listWidth: undefined,
13194 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13195 * mode = 'remote' or 'text' if mode = 'local')
13197 displayField: undefined,
13200 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13201 * mode = 'remote' or 'value' if mode = 'local').
13202 * Note: use of a valueField requires the user make a selection
13203 * in order for a value to be mapped.
13205 valueField: undefined,
13207 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13212 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13213 * field's data value (defaults to the underlying DOM element's name)
13215 hiddenName: undefined,
13217 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13221 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13223 selectedClass: 'active',
13226 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13230 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13231 * anchor positions (defaults to 'tl-bl')
13233 listAlign: 'tl-bl?',
13235 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13239 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13240 * query specified by the allQuery config option (defaults to 'query')
13242 triggerAction: 'query',
13244 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13245 * (defaults to 4, does not apply if editable = false)
13249 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13250 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13254 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13255 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13259 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13260 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13264 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13265 * when editable = true (defaults to false)
13267 selectOnFocus:false,
13269 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13271 queryParam: 'query',
13273 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13274 * when mode = 'remote' (defaults to 'Loading...')
13276 loadingText: 'Loading...',
13278 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13282 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13286 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13287 * traditional select (defaults to true)
13291 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13295 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13299 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13300 * listWidth has a higher value)
13304 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13305 * allow the user to set arbitrary text into the field (defaults to false)
13307 forceSelection:false,
13309 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13310 * if typeAhead = true (defaults to 250)
13312 typeAheadDelay : 250,
13314 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13315 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13317 valueNotFoundText : undefined,
13319 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13321 blockFocus : false,
13324 * @cfg {Boolean} disableClear Disable showing of clear button.
13326 disableClear : false,
13328 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13330 alwaysQuery : false,
13333 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13338 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13340 invalidClass : "has-warning",
13343 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13345 validClass : "has-success",
13348 * @cfg {Boolean} specialFilter (true|false) special filter default false
13350 specialFilter : false,
13353 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13355 mobileTouchView : true,
13358 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13360 useNativeIOS : false,
13363 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13365 mobile_restrict_height : false,
13367 ios_options : false,
13379 btnPosition : 'right',
13380 triggerList : true,
13381 showToggleBtn : true,
13383 emptyResultText: 'Empty',
13384 triggerText : 'Select',
13387 // element that contains real text value.. (when hidden is used..)
13389 getAutoCreate : function()
13394 * Render classic select for iso
13397 if(Roo.isIOS && this.useNativeIOS){
13398 cfg = this.getAutoCreateNativeIOS();
13406 if(Roo.isTouch && this.mobileTouchView){
13407 cfg = this.getAutoCreateTouchView();
13414 if(!this.tickable){
13415 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13420 * ComboBox with tickable selections
13423 var align = this.labelAlign || this.parentLabelAlign();
13426 cls : 'form-group roo-combobox-tickable' //input-group
13429 var btn_text_select = '';
13430 var btn_text_done = '';
13431 var btn_text_cancel = '';
13433 if (this.btn_text_show) {
13434 btn_text_select = 'Select';
13435 btn_text_done = 'Done';
13436 btn_text_cancel = 'Cancel';
13441 cls : 'tickable-buttons',
13446 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13447 //html : this.triggerText
13448 html: btn_text_select
13454 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13456 html: btn_text_done
13462 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13464 html: btn_text_cancel
13470 buttons.cn.unshift({
13472 cls: 'roo-select2-search-field-input'
13478 Roo.each(buttons.cn, function(c){
13480 c.cls += ' btn-' + _this.size;
13483 if (_this.disabled) {
13490 style : 'display: contents',
13495 cls: 'form-hidden-field'
13499 cls: 'roo-select2-choices',
13503 cls: 'roo-select2-search-field',
13514 cls: 'roo-select2-container input-group roo-select2-container-multi',
13520 // cls: 'typeahead typeahead-long dropdown-menu',
13521 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13526 if(this.hasFeedback && !this.allowBlank){
13530 cls: 'glyphicon form-control-feedback'
13533 combobox.cn.push(feedback);
13538 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13539 tooltip : 'This field is required'
13541 if (Roo.bootstrap.version == 4) {
13544 style : 'display:none'
13547 if (align ==='left' && this.fieldLabel.length) {
13549 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13556 cls : 'control-label col-form-label',
13557 html : this.fieldLabel
13569 var labelCfg = cfg.cn[1];
13570 var contentCfg = cfg.cn[2];
13573 if(this.indicatorpos == 'right'){
13579 cls : 'control-label col-form-label',
13583 html : this.fieldLabel
13599 labelCfg = cfg.cn[0];
13600 contentCfg = cfg.cn[1];
13604 if(this.labelWidth > 12){
13605 labelCfg.style = "width: " + this.labelWidth + 'px';
13608 if(this.labelWidth < 13 && this.labelmd == 0){
13609 this.labelmd = this.labelWidth;
13612 if(this.labellg > 0){
13613 labelCfg.cls += ' col-lg-' + this.labellg;
13614 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13617 if(this.labelmd > 0){
13618 labelCfg.cls += ' col-md-' + this.labelmd;
13619 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13622 if(this.labelsm > 0){
13623 labelCfg.cls += ' col-sm-' + this.labelsm;
13624 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13627 if(this.labelxs > 0){
13628 labelCfg.cls += ' col-xs-' + this.labelxs;
13629 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13633 } else if ( this.fieldLabel.length) {
13634 // Roo.log(" label");
13639 //cls : 'input-group-addon',
13640 html : this.fieldLabel
13645 if(this.indicatorpos == 'right'){
13649 //cls : 'input-group-addon',
13650 html : this.fieldLabel
13660 // Roo.log(" no label && no align");
13667 ['xs','sm','md','lg'].map(function(size){
13668 if (settings[size]) {
13669 cfg.cls += ' col-' + size + '-' + settings[size];
13677 _initEventsCalled : false,
13680 initEvents: function()
13682 if (this._initEventsCalled) { // as we call render... prevent looping...
13685 this._initEventsCalled = true;
13688 throw "can not find store for combo";
13691 this.indicator = this.indicatorEl();
13693 this.store = Roo.factory(this.store, Roo.data);
13694 this.store.parent = this;
13696 // if we are building from html. then this element is so complex, that we can not really
13697 // use the rendered HTML.
13698 // so we have to trash and replace the previous code.
13699 if (Roo.XComponent.build_from_html) {
13700 // remove this element....
13701 var e = this.el.dom, k=0;
13702 while (e ) { e = e.previousSibling; ++k;}
13707 this.rendered = false;
13709 this.render(this.parent().getChildContainer(true), k);
13712 if(Roo.isIOS && this.useNativeIOS){
13713 this.initIOSView();
13721 if(Roo.isTouch && this.mobileTouchView){
13722 this.initTouchView();
13727 this.initTickableEvents();
13731 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13733 if(this.hiddenName){
13735 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13737 this.hiddenField.dom.value =
13738 this.hiddenValue !== undefined ? this.hiddenValue :
13739 this.value !== undefined ? this.value : '';
13741 // prevent input submission
13742 this.el.dom.removeAttribute('name');
13743 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13748 // this.el.dom.setAttribute('autocomplete', 'off');
13751 var cls = 'x-combo-list';
13753 //this.list = new Roo.Layer({
13754 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13760 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13761 _this.list.setWidth(lw);
13764 this.list.on('mouseover', this.onViewOver, this);
13765 this.list.on('mousemove', this.onViewMove, this);
13766 this.list.on('scroll', this.onViewScroll, this);
13769 this.list.swallowEvent('mousewheel');
13770 this.assetHeight = 0;
13773 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13774 this.assetHeight += this.header.getHeight();
13777 this.innerList = this.list.createChild({cls:cls+'-inner'});
13778 this.innerList.on('mouseover', this.onViewOver, this);
13779 this.innerList.on('mousemove', this.onViewMove, this);
13780 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13782 if(this.allowBlank && !this.pageSize && !this.disableClear){
13783 this.footer = this.list.createChild({cls:cls+'-ft'});
13784 this.pageTb = new Roo.Toolbar(this.footer);
13788 this.footer = this.list.createChild({cls:cls+'-ft'});
13789 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13790 {pageSize: this.pageSize});
13794 if (this.pageTb && this.allowBlank && !this.disableClear) {
13796 this.pageTb.add(new Roo.Toolbar.Fill(), {
13797 cls: 'x-btn-icon x-btn-clear',
13799 handler: function()
13802 _this.clearValue();
13803 _this.onSelect(false, -1);
13808 this.assetHeight += this.footer.getHeight();
13813 this.tpl = Roo.bootstrap.version == 4 ?
13814 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13815 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13818 this.view = new Roo.View(this.list, this.tpl, {
13819 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13821 //this.view.wrapEl.setDisplayed(false);
13822 this.view.on('click', this.onViewClick, this);
13825 this.store.on('beforeload', this.onBeforeLoad, this);
13826 this.store.on('load', this.onLoad, this);
13827 this.store.on('loadexception', this.onLoadException, this);
13829 if(this.resizable){
13830 this.resizer = new Roo.Resizable(this.list, {
13831 pinned:true, handles:'se'
13833 this.resizer.on('resize', function(r, w, h){
13834 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13835 this.listWidth = w;
13836 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13837 this.restrictHeight();
13839 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13842 if(!this.editable){
13843 this.editable = true;
13844 this.setEditable(false);
13849 if (typeof(this.events.add.listeners) != 'undefined') {
13851 this.addicon = this.wrap.createChild(
13852 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13854 this.addicon.on('click', function(e) {
13855 this.fireEvent('add', this);
13858 if (typeof(this.events.edit.listeners) != 'undefined') {
13860 this.editicon = this.wrap.createChild(
13861 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13862 if (this.addicon) {
13863 this.editicon.setStyle('margin-left', '40px');
13865 this.editicon.on('click', function(e) {
13867 // we fire even if inothing is selected..
13868 this.fireEvent('edit', this, this.lastData );
13874 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13875 "up" : function(e){
13876 this.inKeyMode = true;
13880 "down" : function(e){
13881 if(!this.isExpanded()){
13882 this.onTriggerClick();
13884 this.inKeyMode = true;
13889 "enter" : function(e){
13890 // this.onViewClick();
13894 if(this.fireEvent("specialkey", this, e)){
13895 this.onViewClick(false);
13901 "esc" : function(e){
13905 "tab" : function(e){
13908 if(this.fireEvent("specialkey", this, e)){
13909 this.onViewClick(false);
13917 doRelay : function(foo, bar, hname){
13918 if(hname == 'down' || this.scope.isExpanded()){
13919 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13928 this.queryDelay = Math.max(this.queryDelay || 10,
13929 this.mode == 'local' ? 10 : 250);
13932 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13934 if(this.typeAhead){
13935 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13937 if(this.editable !== false){
13938 this.inputEl().on("keyup", this.onKeyUp, this);
13940 if(this.forceSelection){
13941 this.inputEl().on('blur', this.doForce, this);
13945 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13946 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13950 initTickableEvents: function()
13954 if(this.hiddenName){
13956 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13958 this.hiddenField.dom.value =
13959 this.hiddenValue !== undefined ? this.hiddenValue :
13960 this.value !== undefined ? this.value : '';
13962 // prevent input submission
13963 this.el.dom.removeAttribute('name');
13964 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13969 // this.list = this.el.select('ul.dropdown-menu',true).first();
13971 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13972 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13973 if(this.triggerList){
13974 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13977 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13978 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13980 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13981 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13983 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13984 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13986 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13987 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13988 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13991 this.cancelBtn.hide();
13996 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13997 _this.list.setWidth(lw);
14000 this.list.on('mouseover', this.onViewOver, this);
14001 this.list.on('mousemove', this.onViewMove, this);
14003 this.list.on('scroll', this.onViewScroll, this);
14006 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14007 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14010 this.view = new Roo.View(this.list, this.tpl, {
14015 selectedClass: this.selectedClass
14018 //this.view.wrapEl.setDisplayed(false);
14019 this.view.on('click', this.onViewClick, this);
14023 this.store.on('beforeload', this.onBeforeLoad, this);
14024 this.store.on('load', this.onLoad, this);
14025 this.store.on('loadexception', this.onLoadException, this);
14028 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14029 "up" : function(e){
14030 this.inKeyMode = true;
14034 "down" : function(e){
14035 this.inKeyMode = true;
14039 "enter" : function(e){
14040 if(this.fireEvent("specialkey", this, e)){
14041 this.onViewClick(false);
14047 "esc" : function(e){
14048 this.onTickableFooterButtonClick(e, false, false);
14051 "tab" : function(e){
14052 this.fireEvent("specialkey", this, e);
14054 this.onTickableFooterButtonClick(e, false, false);
14061 doRelay : function(e, fn, key){
14062 if(this.scope.isExpanded()){
14063 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14072 this.queryDelay = Math.max(this.queryDelay || 10,
14073 this.mode == 'local' ? 10 : 250);
14076 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14078 if(this.typeAhead){
14079 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14082 if(this.editable !== false){
14083 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14086 this.indicator = this.indicatorEl();
14088 if(this.indicator){
14089 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14090 this.indicator.hide();
14095 onDestroy : function(){
14097 this.view.setStore(null);
14098 this.view.el.removeAllListeners();
14099 this.view.el.remove();
14100 this.view.purgeListeners();
14103 this.list.dom.innerHTML = '';
14107 this.store.un('beforeload', this.onBeforeLoad, this);
14108 this.store.un('load', this.onLoad, this);
14109 this.store.un('loadexception', this.onLoadException, this);
14111 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14115 fireKey : function(e){
14116 if(e.isNavKeyPress() && !this.list.isVisible()){
14117 this.fireEvent("specialkey", this, e);
14122 onResize: function(w, h){
14123 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14125 // if(typeof w != 'number'){
14126 // // we do not handle it!?!?
14129 // var tw = this.trigger.getWidth();
14130 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14131 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14133 // this.inputEl().setWidth( this.adjustWidth('input', x));
14135 // //this.trigger.setStyle('left', x+'px');
14137 // if(this.list && this.listWidth === undefined){
14138 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14139 // this.list.setWidth(lw);
14140 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14148 * Allow or prevent the user from directly editing the field text. If false is passed,
14149 * the user will only be able to select from the items defined in the dropdown list. This method
14150 * is the runtime equivalent of setting the 'editable' config option at config time.
14151 * @param {Boolean} value True to allow the user to directly edit the field text
14153 setEditable : function(value){
14154 if(value == this.editable){
14157 this.editable = value;
14159 this.inputEl().dom.setAttribute('readOnly', true);
14160 this.inputEl().on('mousedown', this.onTriggerClick, this);
14161 this.inputEl().addClass('x-combo-noedit');
14163 this.inputEl().dom.setAttribute('readOnly', false);
14164 this.inputEl().un('mousedown', this.onTriggerClick, this);
14165 this.inputEl().removeClass('x-combo-noedit');
14171 onBeforeLoad : function(combo,opts){
14172 if(!this.hasFocus){
14176 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14178 this.restrictHeight();
14179 this.selectedIndex = -1;
14183 onLoad : function(){
14185 this.hasQuery = false;
14187 if(!this.hasFocus){
14191 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14192 this.loading.hide();
14195 if(this.store.getCount() > 0){
14198 this.restrictHeight();
14199 if(this.lastQuery == this.allQuery){
14200 if(this.editable && !this.tickable){
14201 this.inputEl().dom.select();
14205 !this.selectByValue(this.value, true) &&
14208 !this.store.lastOptions ||
14209 typeof(this.store.lastOptions.add) == 'undefined' ||
14210 this.store.lastOptions.add != true
14213 this.select(0, true);
14216 if(this.autoFocus){
14219 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14220 this.taTask.delay(this.typeAheadDelay);
14224 this.onEmptyResults();
14230 onLoadException : function()
14232 this.hasQuery = false;
14234 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14235 this.loading.hide();
14238 if(this.tickable && this.editable){
14243 // only causes errors at present
14244 //Roo.log(this.store.reader.jsonData);
14245 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14247 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14253 onTypeAhead : function(){
14254 if(this.store.getCount() > 0){
14255 var r = this.store.getAt(0);
14256 var newValue = r.data[this.displayField];
14257 var len = newValue.length;
14258 var selStart = this.getRawValue().length;
14260 if(selStart != len){
14261 this.setRawValue(newValue);
14262 this.selectText(selStart, newValue.length);
14268 onSelect : function(record, index){
14270 if(this.fireEvent('beforeselect', this, record, index) !== false){
14272 this.setFromData(index > -1 ? record.data : false);
14275 this.fireEvent('select', this, record, index);
14280 * Returns the currently selected field value or empty string if no value is set.
14281 * @return {String} value The selected value
14283 getValue : function()
14285 if(Roo.isIOS && this.useNativeIOS){
14286 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14290 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14293 if(this.valueField){
14294 return typeof this.value != 'undefined' ? this.value : '';
14296 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14300 getRawValue : function()
14302 if(Roo.isIOS && this.useNativeIOS){
14303 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14306 var v = this.inputEl().getValue();
14312 * Clears any text/value currently set in the field
14314 clearValue : function(){
14316 if(this.hiddenField){
14317 this.hiddenField.dom.value = '';
14320 this.setRawValue('');
14321 this.lastSelectionText = '';
14322 this.lastData = false;
14324 var close = this.closeTriggerEl();
14335 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14336 * will be displayed in the field. If the value does not match the data value of an existing item,
14337 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14338 * Otherwise the field will be blank (although the value will still be set).
14339 * @param {String} value The value to match
14341 setValue : function(v)
14343 if(Roo.isIOS && this.useNativeIOS){
14344 this.setIOSValue(v);
14354 if(this.valueField){
14355 var r = this.findRecord(this.valueField, v);
14357 text = r.data[this.displayField];
14358 }else if(this.valueNotFoundText !== undefined){
14359 text = this.valueNotFoundText;
14362 this.lastSelectionText = text;
14363 if(this.hiddenField){
14364 this.hiddenField.dom.value = v;
14366 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14369 var close = this.closeTriggerEl();
14372 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14378 * @property {Object} the last set data for the element
14383 * Sets the value of the field based on a object which is related to the record format for the store.
14384 * @param {Object} value the value to set as. or false on reset?
14386 setFromData : function(o){
14393 var dv = ''; // display value
14394 var vv = ''; // value value..
14396 if (this.displayField) {
14397 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14399 // this is an error condition!!!
14400 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14403 if(this.valueField){
14404 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14407 var close = this.closeTriggerEl();
14410 if(dv.length || vv * 1 > 0){
14412 this.blockFocus=true;
14418 if(this.hiddenField){
14419 this.hiddenField.dom.value = vv;
14421 this.lastSelectionText = dv;
14422 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14426 // no hidden field.. - we store the value in 'value', but still display
14427 // display field!!!!
14428 this.lastSelectionText = dv;
14429 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14436 reset : function(){
14437 // overridden so that last data is reset..
14444 this.setValue(this.originalValue);
14445 //this.clearInvalid();
14446 this.lastData = false;
14448 this.view.clearSelections();
14454 findRecord : function(prop, value){
14456 if(this.store.getCount() > 0){
14457 this.store.each(function(r){
14458 if(r.data[prop] == value){
14468 getName: function()
14470 // returns hidden if it's set..
14471 if (!this.rendered) {return ''};
14472 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14476 onViewMove : function(e, t){
14477 this.inKeyMode = false;
14481 onViewOver : function(e, t){
14482 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14485 var item = this.view.findItemFromChild(t);
14488 var index = this.view.indexOf(item);
14489 this.select(index, false);
14494 onViewClick : function(view, doFocus, el, e)
14496 var index = this.view.getSelectedIndexes()[0];
14498 var r = this.store.getAt(index);
14502 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14509 Roo.each(this.tickItems, function(v,k){
14511 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14513 _this.tickItems.splice(k, 1);
14515 if(typeof(e) == 'undefined' && view == false){
14516 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14528 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14529 this.tickItems.push(r.data);
14532 if(typeof(e) == 'undefined' && view == false){
14533 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14540 this.onSelect(r, index);
14542 if(doFocus !== false && !this.blockFocus){
14543 this.inputEl().focus();
14548 restrictHeight : function(){
14549 //this.innerList.dom.style.height = '';
14550 //var inner = this.innerList.dom;
14551 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14552 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14553 //this.list.beginUpdate();
14554 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14555 this.list.alignTo(this.inputEl(), this.listAlign);
14556 this.list.alignTo(this.inputEl(), this.listAlign);
14557 //this.list.endUpdate();
14561 onEmptyResults : function(){
14563 if(this.tickable && this.editable){
14564 this.hasFocus = false;
14565 this.restrictHeight();
14573 * Returns true if the dropdown list is expanded, else false.
14575 isExpanded : function(){
14576 return this.list.isVisible();
14580 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14581 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14582 * @param {String} value The data value of the item to select
14583 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14584 * selected item if it is not currently in view (defaults to true)
14585 * @return {Boolean} True if the value matched an item in the list, else false
14587 selectByValue : function(v, scrollIntoView){
14588 if(v !== undefined && v !== null){
14589 var r = this.findRecord(this.valueField || this.displayField, v);
14591 this.select(this.store.indexOf(r), scrollIntoView);
14599 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14600 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14601 * @param {Number} index The zero-based index of the list item to select
14602 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14603 * selected item if it is not currently in view (defaults to true)
14605 select : function(index, scrollIntoView){
14606 this.selectedIndex = index;
14607 this.view.select(index);
14608 if(scrollIntoView !== false){
14609 var el = this.view.getNode(index);
14611 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14614 this.list.scrollChildIntoView(el, false);
14620 selectNext : function(){
14621 var ct = this.store.getCount();
14623 if(this.selectedIndex == -1){
14625 }else if(this.selectedIndex < ct-1){
14626 this.select(this.selectedIndex+1);
14632 selectPrev : function(){
14633 var ct = this.store.getCount();
14635 if(this.selectedIndex == -1){
14637 }else if(this.selectedIndex != 0){
14638 this.select(this.selectedIndex-1);
14644 onKeyUp : function(e){
14645 if(this.editable !== false && !e.isSpecialKey()){
14646 this.lastKey = e.getKey();
14647 this.dqTask.delay(this.queryDelay);
14652 validateBlur : function(){
14653 return !this.list || !this.list.isVisible();
14657 initQuery : function(){
14659 var v = this.getRawValue();
14661 if(this.tickable && this.editable){
14662 v = this.tickableInputEl().getValue();
14669 doForce : function(){
14670 if(this.inputEl().dom.value.length > 0){
14671 this.inputEl().dom.value =
14672 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14678 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14679 * query allowing the query action to be canceled if needed.
14680 * @param {String} query The SQL query to execute
14681 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14682 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14683 * saved in the current store (defaults to false)
14685 doQuery : function(q, forceAll){
14687 if(q === undefined || q === null){
14692 forceAll: forceAll,
14696 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14701 forceAll = qe.forceAll;
14702 if(forceAll === true || (q.length >= this.minChars)){
14704 this.hasQuery = true;
14706 if(this.lastQuery != q || this.alwaysQuery){
14707 this.lastQuery = q;
14708 if(this.mode == 'local'){
14709 this.selectedIndex = -1;
14711 this.store.clearFilter();
14714 if(this.specialFilter){
14715 this.fireEvent('specialfilter', this);
14720 this.store.filter(this.displayField, q);
14723 this.store.fireEvent("datachanged", this.store);
14730 this.store.baseParams[this.queryParam] = q;
14732 var options = {params : this.getParams(q)};
14735 options.add = true;
14736 options.params.start = this.page * this.pageSize;
14739 this.store.load(options);
14742 * this code will make the page width larger, at the beginning, the list not align correctly,
14743 * we should expand the list on onLoad
14744 * so command out it
14749 this.selectedIndex = -1;
14754 this.loadNext = false;
14758 getParams : function(q){
14760 //p[this.queryParam] = q;
14764 p.limit = this.pageSize;
14770 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14772 collapse : function(){
14773 if(!this.isExpanded()){
14779 this.hasFocus = false;
14783 this.cancelBtn.hide();
14784 this.trigger.show();
14787 this.tickableInputEl().dom.value = '';
14788 this.tickableInputEl().blur();
14793 Roo.get(document).un('mousedown', this.collapseIf, this);
14794 Roo.get(document).un('mousewheel', this.collapseIf, this);
14795 if (!this.editable) {
14796 Roo.get(document).un('keydown', this.listKeyPress, this);
14798 this.fireEvent('collapse', this);
14804 collapseIf : function(e){
14805 var in_combo = e.within(this.el);
14806 var in_list = e.within(this.list);
14807 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14809 if (in_combo || in_list || is_list) {
14810 //e.stopPropagation();
14815 this.onTickableFooterButtonClick(e, false, false);
14823 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14825 expand : function(){
14827 if(this.isExpanded() || !this.hasFocus){
14831 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14832 this.list.setWidth(lw);
14838 this.restrictHeight();
14842 this.tickItems = Roo.apply([], this.item);
14845 this.cancelBtn.show();
14846 this.trigger.hide();
14849 this.tickableInputEl().focus();
14854 Roo.get(document).on('mousedown', this.collapseIf, this);
14855 Roo.get(document).on('mousewheel', this.collapseIf, this);
14856 if (!this.editable) {
14857 Roo.get(document).on('keydown', this.listKeyPress, this);
14860 this.fireEvent('expand', this);
14864 // Implements the default empty TriggerField.onTriggerClick function
14865 onTriggerClick : function(e)
14867 Roo.log('trigger click');
14869 if(this.disabled || !this.triggerList){
14874 this.loadNext = false;
14876 if(this.isExpanded()){
14878 if (!this.blockFocus) {
14879 this.inputEl().focus();
14883 this.hasFocus = true;
14884 if(this.triggerAction == 'all') {
14885 this.doQuery(this.allQuery, true);
14887 this.doQuery(this.getRawValue());
14889 if (!this.blockFocus) {
14890 this.inputEl().focus();
14895 onTickableTriggerClick : function(e)
14902 this.loadNext = false;
14903 this.hasFocus = true;
14905 if(this.triggerAction == 'all') {
14906 this.doQuery(this.allQuery, true);
14908 this.doQuery(this.getRawValue());
14912 onSearchFieldClick : function(e)
14914 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14915 this.onTickableFooterButtonClick(e, false, false);
14919 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14924 this.loadNext = false;
14925 this.hasFocus = true;
14927 if(this.triggerAction == 'all') {
14928 this.doQuery(this.allQuery, true);
14930 this.doQuery(this.getRawValue());
14934 listKeyPress : function(e)
14936 //Roo.log('listkeypress');
14937 // scroll to first matching element based on key pres..
14938 if (e.isSpecialKey()) {
14941 var k = String.fromCharCode(e.getKey()).toUpperCase();
14944 var csel = this.view.getSelectedNodes();
14945 var cselitem = false;
14947 var ix = this.view.indexOf(csel[0]);
14948 cselitem = this.store.getAt(ix);
14949 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14955 this.store.each(function(v) {
14957 // start at existing selection.
14958 if (cselitem.id == v.id) {
14964 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14965 match = this.store.indexOf(v);
14971 if (match === false) {
14972 return true; // no more action?
14975 this.view.select(match);
14976 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14977 sn.scrollIntoView(sn.dom.parentNode, false);
14980 onViewScroll : function(e, t){
14982 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){
14986 this.hasQuery = true;
14988 this.loading = this.list.select('.loading', true).first();
14990 if(this.loading === null){
14991 this.list.createChild({
14993 cls: 'loading roo-select2-more-results roo-select2-active',
14994 html: 'Loading more results...'
14997 this.loading = this.list.select('.loading', true).first();
14999 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15001 this.loading.hide();
15004 this.loading.show();
15009 this.loadNext = true;
15011 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15016 addItem : function(o)
15018 var dv = ''; // display value
15020 if (this.displayField) {
15021 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15023 // this is an error condition!!!
15024 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15031 var choice = this.choices.createChild({
15033 cls: 'roo-select2-search-choice',
15042 cls: 'roo-select2-search-choice-close fa fa-times',
15047 }, this.searchField);
15049 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15051 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15059 this.inputEl().dom.value = '';
15064 onRemoveItem : function(e, _self, o)
15066 e.preventDefault();
15068 this.lastItem = Roo.apply([], this.item);
15070 var index = this.item.indexOf(o.data) * 1;
15073 Roo.log('not this item?!');
15077 this.item.splice(index, 1);
15082 this.fireEvent('remove', this, e);
15088 syncValue : function()
15090 if(!this.item.length){
15097 Roo.each(this.item, function(i){
15098 if(_this.valueField){
15099 value.push(i[_this.valueField]);
15106 this.value = value.join(',');
15108 if(this.hiddenField){
15109 this.hiddenField.dom.value = this.value;
15112 this.store.fireEvent("datachanged", this.store);
15117 clearItem : function()
15119 if(!this.multiple){
15125 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15133 if(this.tickable && !Roo.isTouch){
15134 this.view.refresh();
15138 inputEl: function ()
15140 if(Roo.isIOS && this.useNativeIOS){
15141 return this.el.select('select.roo-ios-select', true).first();
15144 if(Roo.isTouch && this.mobileTouchView){
15145 return this.el.select('input.form-control',true).first();
15149 return this.searchField;
15152 return this.el.select('input.form-control',true).first();
15155 onTickableFooterButtonClick : function(e, btn, el)
15157 e.preventDefault();
15159 this.lastItem = Roo.apply([], this.item);
15161 if(btn && btn.name == 'cancel'){
15162 this.tickItems = Roo.apply([], this.item);
15171 Roo.each(this.tickItems, function(o){
15179 validate : function()
15181 if(this.getVisibilityEl().hasClass('hidden')){
15185 var v = this.getRawValue();
15188 v = this.getValue();
15191 if(this.disabled || this.allowBlank || v.length){
15196 this.markInvalid();
15200 tickableInputEl : function()
15202 if(!this.tickable || !this.editable){
15203 return this.inputEl();
15206 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15210 getAutoCreateTouchView : function()
15215 cls: 'form-group' //input-group
15221 type : this.inputType,
15222 cls : 'form-control x-combo-noedit',
15223 autocomplete: 'new-password',
15224 placeholder : this.placeholder || '',
15229 input.name = this.name;
15233 input.cls += ' input-' + this.size;
15236 if (this.disabled) {
15237 input.disabled = true;
15248 inputblock.cls += ' input-group';
15250 inputblock.cn.unshift({
15252 cls : 'input-group-addon input-group-prepend input-group-text',
15257 if(this.removable && !this.multiple){
15258 inputblock.cls += ' roo-removable';
15260 inputblock.cn.push({
15263 cls : 'roo-combo-removable-btn close'
15267 if(this.hasFeedback && !this.allowBlank){
15269 inputblock.cls += ' has-feedback';
15271 inputblock.cn.push({
15273 cls: 'glyphicon form-control-feedback'
15280 inputblock.cls += (this.before) ? '' : ' input-group';
15282 inputblock.cn.push({
15284 cls : 'input-group-addon input-group-append input-group-text',
15290 var ibwrap = inputblock;
15295 cls: 'roo-select2-choices',
15299 cls: 'roo-select2-search-field',
15312 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15317 cls: 'form-hidden-field'
15323 if(!this.multiple && this.showToggleBtn){
15330 if (this.caret != false) {
15333 cls: 'fa fa-' + this.caret
15340 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15345 cls: 'combobox-clear',
15359 combobox.cls += ' roo-select2-container-multi';
15362 var align = this.labelAlign || this.parentLabelAlign();
15364 if (align ==='left' && this.fieldLabel.length) {
15369 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15370 tooltip : 'This field is required'
15374 cls : 'control-label col-form-label',
15375 html : this.fieldLabel
15386 var labelCfg = cfg.cn[1];
15387 var contentCfg = cfg.cn[2];
15390 if(this.indicatorpos == 'right'){
15395 cls : 'control-label col-form-label',
15399 html : this.fieldLabel
15403 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15404 tooltip : 'This field is required'
15417 labelCfg = cfg.cn[0];
15418 contentCfg = cfg.cn[1];
15423 if(this.labelWidth > 12){
15424 labelCfg.style = "width: " + this.labelWidth + 'px';
15427 if(this.labelWidth < 13 && this.labelmd == 0){
15428 this.labelmd = this.labelWidth;
15431 if(this.labellg > 0){
15432 labelCfg.cls += ' col-lg-' + this.labellg;
15433 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15436 if(this.labelmd > 0){
15437 labelCfg.cls += ' col-md-' + this.labelmd;
15438 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15441 if(this.labelsm > 0){
15442 labelCfg.cls += ' col-sm-' + this.labelsm;
15443 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15446 if(this.labelxs > 0){
15447 labelCfg.cls += ' col-xs-' + this.labelxs;
15448 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15452 } else if ( this.fieldLabel.length) {
15456 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15457 tooltip : 'This field is required'
15461 cls : 'control-label',
15462 html : this.fieldLabel
15473 if(this.indicatorpos == 'right'){
15477 cls : 'control-label',
15478 html : this.fieldLabel,
15482 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15483 tooltip : 'This field is required'
15500 var settings = this;
15502 ['xs','sm','md','lg'].map(function(size){
15503 if (settings[size]) {
15504 cfg.cls += ' col-' + size + '-' + settings[size];
15511 initTouchView : function()
15513 this.renderTouchView();
15515 this.touchViewEl.on('scroll', function(){
15516 this.el.dom.scrollTop = 0;
15519 this.originalValue = this.getValue();
15521 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15523 this.inputEl().on("click", this.showTouchView, this);
15524 if (this.triggerEl) {
15525 this.triggerEl.on("click", this.showTouchView, this);
15529 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15530 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15532 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15534 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15535 this.store.on('load', this.onTouchViewLoad, this);
15536 this.store.on('loadexception', this.onTouchViewLoadException, this);
15538 if(this.hiddenName){
15540 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15542 this.hiddenField.dom.value =
15543 this.hiddenValue !== undefined ? this.hiddenValue :
15544 this.value !== undefined ? this.value : '';
15546 this.el.dom.removeAttribute('name');
15547 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15551 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15552 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15555 if(this.removable && !this.multiple){
15556 var close = this.closeTriggerEl();
15558 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15559 close.on('click', this.removeBtnClick, this, close);
15563 * fix the bug in Safari iOS8
15565 this.inputEl().on("focus", function(e){
15566 document.activeElement.blur();
15569 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15576 renderTouchView : function()
15578 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15579 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15581 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15582 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15584 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15585 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15586 this.touchViewBodyEl.setStyle('overflow', 'auto');
15588 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15589 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15591 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15592 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15596 showTouchView : function()
15602 this.touchViewHeaderEl.hide();
15604 if(this.modalTitle.length){
15605 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15606 this.touchViewHeaderEl.show();
15609 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15610 this.touchViewEl.show();
15612 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15614 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15615 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15617 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15619 if(this.modalTitle.length){
15620 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15623 this.touchViewBodyEl.setHeight(bodyHeight);
15627 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15629 this.touchViewEl.addClass('in');
15632 if(this._touchViewMask){
15633 Roo.get(document.body).addClass("x-body-masked");
15634 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15635 this._touchViewMask.setStyle('z-index', 10000);
15636 this._touchViewMask.addClass('show');
15639 this.doTouchViewQuery();
15643 hideTouchView : function()
15645 this.touchViewEl.removeClass('in');
15649 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15651 this.touchViewEl.setStyle('display', 'none');
15654 if(this._touchViewMask){
15655 this._touchViewMask.removeClass('show');
15656 Roo.get(document.body).removeClass("x-body-masked");
15660 setTouchViewValue : function()
15667 Roo.each(this.tickItems, function(o){
15672 this.hideTouchView();
15675 doTouchViewQuery : function()
15684 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15688 if(!this.alwaysQuery || this.mode == 'local'){
15689 this.onTouchViewLoad();
15696 onTouchViewBeforeLoad : function(combo,opts)
15702 onTouchViewLoad : function()
15704 if(this.store.getCount() < 1){
15705 this.onTouchViewEmptyResults();
15709 this.clearTouchView();
15711 var rawValue = this.getRawValue();
15713 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15715 this.tickItems = [];
15717 this.store.data.each(function(d, rowIndex){
15718 var row = this.touchViewListGroup.createChild(template);
15720 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15721 row.addClass(d.data.cls);
15724 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15727 html : d.data[this.displayField]
15730 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15731 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15734 row.removeClass('selected');
15735 if(!this.multiple && this.valueField &&
15736 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15739 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15740 row.addClass('selected');
15743 if(this.multiple && this.valueField &&
15744 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15748 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15749 this.tickItems.push(d.data);
15752 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15756 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15758 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15760 if(this.modalTitle.length){
15761 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15764 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15766 if(this.mobile_restrict_height && listHeight < bodyHeight){
15767 this.touchViewBodyEl.setHeight(listHeight);
15772 if(firstChecked && listHeight > bodyHeight){
15773 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15778 onTouchViewLoadException : function()
15780 this.hideTouchView();
15783 onTouchViewEmptyResults : function()
15785 this.clearTouchView();
15787 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15789 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15793 clearTouchView : function()
15795 this.touchViewListGroup.dom.innerHTML = '';
15798 onTouchViewClick : function(e, el, o)
15800 e.preventDefault();
15803 var rowIndex = o.rowIndex;
15805 var r = this.store.getAt(rowIndex);
15807 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15809 if(!this.multiple){
15810 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15811 c.dom.removeAttribute('checked');
15814 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15816 this.setFromData(r.data);
15818 var close = this.closeTriggerEl();
15824 this.hideTouchView();
15826 this.fireEvent('select', this, r, rowIndex);
15831 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15832 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15833 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15837 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15838 this.addItem(r.data);
15839 this.tickItems.push(r.data);
15843 getAutoCreateNativeIOS : function()
15846 cls: 'form-group' //input-group,
15851 cls : 'roo-ios-select'
15855 combobox.name = this.name;
15858 if (this.disabled) {
15859 combobox.disabled = true;
15862 var settings = this;
15864 ['xs','sm','md','lg'].map(function(size){
15865 if (settings[size]) {
15866 cfg.cls += ' col-' + size + '-' + settings[size];
15876 initIOSView : function()
15878 this.store.on('load', this.onIOSViewLoad, this);
15883 onIOSViewLoad : function()
15885 if(this.store.getCount() < 1){
15889 this.clearIOSView();
15891 if(this.allowBlank) {
15893 var default_text = '-- SELECT --';
15895 if(this.placeholder.length){
15896 default_text = this.placeholder;
15899 if(this.emptyTitle.length){
15900 default_text += ' - ' + this.emptyTitle + ' -';
15903 var opt = this.inputEl().createChild({
15906 html : default_text
15910 o[this.valueField] = 0;
15911 o[this.displayField] = default_text;
15913 this.ios_options.push({
15920 this.store.data.each(function(d, rowIndex){
15924 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15925 html = d.data[this.displayField];
15930 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15931 value = d.data[this.valueField];
15940 if(this.value == d.data[this.valueField]){
15941 option['selected'] = true;
15944 var opt = this.inputEl().createChild(option);
15946 this.ios_options.push({
15953 this.inputEl().on('change', function(){
15954 this.fireEvent('select', this);
15959 clearIOSView: function()
15961 this.inputEl().dom.innerHTML = '';
15963 this.ios_options = [];
15966 setIOSValue: function(v)
15970 if(!this.ios_options){
15974 Roo.each(this.ios_options, function(opts){
15976 opts.el.dom.removeAttribute('selected');
15978 if(opts.data[this.valueField] != v){
15982 opts.el.dom.setAttribute('selected', true);
15988 * @cfg {Boolean} grow
15992 * @cfg {Number} growMin
15996 * @cfg {Number} growMax
16005 Roo.apply(Roo.bootstrap.ComboBox, {
16009 cls: 'modal-header',
16031 cls: 'list-group-item',
16035 cls: 'roo-combobox-list-group-item-value'
16039 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16053 listItemCheckbox : {
16055 cls: 'list-group-item',
16059 cls: 'roo-combobox-list-group-item-value'
16063 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16079 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16084 cls: 'modal-footer',
16092 cls: 'col-xs-6 text-left',
16095 cls: 'btn btn-danger roo-touch-view-cancel',
16101 cls: 'col-xs-6 text-right',
16104 cls: 'btn btn-success roo-touch-view-ok',
16115 Roo.apply(Roo.bootstrap.ComboBox, {
16117 touchViewTemplate : {
16119 cls: 'modal fade roo-combobox-touch-view',
16123 cls: 'modal-dialog',
16124 style : 'position:fixed', // we have to fix position....
16128 cls: 'modal-content',
16130 Roo.bootstrap.ComboBox.header,
16131 Roo.bootstrap.ComboBox.body,
16132 Roo.bootstrap.ComboBox.footer
16141 * Ext JS Library 1.1.1
16142 * Copyright(c) 2006-2007, Ext JS, LLC.
16144 * Originally Released Under LGPL - original licence link has changed is not relivant.
16147 * <script type="text/javascript">
16152 * @extends Roo.util.Observable
16153 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16154 * This class also supports single and multi selection modes. <br>
16155 * Create a data model bound view:
16157 var store = new Roo.data.Store(...);
16159 var view = new Roo.View({
16161 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16163 singleSelect: true,
16164 selectedClass: "ydataview-selected",
16168 // listen for node click?
16169 view.on("click", function(vw, index, node, e){
16170 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16174 dataModel.load("foobar.xml");
16176 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16178 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16179 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16181 * Note: old style constructor is still suported (container, template, config)
16184 * Create a new View
16185 * @param {Object} config The config object
16188 Roo.View = function(config, depreciated_tpl, depreciated_config){
16190 this.parent = false;
16192 if (typeof(depreciated_tpl) == 'undefined') {
16193 // new way.. - universal constructor.
16194 Roo.apply(this, config);
16195 this.el = Roo.get(this.el);
16198 this.el = Roo.get(config);
16199 this.tpl = depreciated_tpl;
16200 Roo.apply(this, depreciated_config);
16202 this.wrapEl = this.el.wrap().wrap();
16203 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16206 if(typeof(this.tpl) == "string"){
16207 this.tpl = new Roo.Template(this.tpl);
16209 // support xtype ctors..
16210 this.tpl = new Roo.factory(this.tpl, Roo);
16214 this.tpl.compile();
16219 * @event beforeclick
16220 * Fires before a click is processed. Returns false to cancel the default action.
16221 * @param {Roo.View} this
16222 * @param {Number} index The index of the target node
16223 * @param {HTMLElement} node The target node
16224 * @param {Roo.EventObject} e The raw event object
16226 "beforeclick" : true,
16229 * Fires when a template node is clicked.
16230 * @param {Roo.View} this
16231 * @param {Number} index The index of the target node
16232 * @param {HTMLElement} node The target node
16233 * @param {Roo.EventObject} e The raw event object
16238 * Fires when a template node is double clicked.
16239 * @param {Roo.View} this
16240 * @param {Number} index The index of the target node
16241 * @param {HTMLElement} node The target node
16242 * @param {Roo.EventObject} e The raw event object
16246 * @event contextmenu
16247 * Fires when a template node is right clicked.
16248 * @param {Roo.View} this
16249 * @param {Number} index The index of the target node
16250 * @param {HTMLElement} node The target node
16251 * @param {Roo.EventObject} e The raw event object
16253 "contextmenu" : true,
16255 * @event selectionchange
16256 * Fires when the selected nodes change.
16257 * @param {Roo.View} this
16258 * @param {Array} selections Array of the selected nodes
16260 "selectionchange" : true,
16263 * @event beforeselect
16264 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16265 * @param {Roo.View} this
16266 * @param {HTMLElement} node The node to be selected
16267 * @param {Array} selections Array of currently selected nodes
16269 "beforeselect" : true,
16271 * @event preparedata
16272 * Fires on every row to render, to allow you to change the data.
16273 * @param {Roo.View} this
16274 * @param {Object} data to be rendered (change this)
16276 "preparedata" : true
16284 "click": this.onClick,
16285 "dblclick": this.onDblClick,
16286 "contextmenu": this.onContextMenu,
16290 this.selections = [];
16292 this.cmp = new Roo.CompositeElementLite([]);
16294 this.store = Roo.factory(this.store, Roo.data);
16295 this.setStore(this.store, true);
16298 if ( this.footer && this.footer.xtype) {
16300 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16302 this.footer.dataSource = this.store;
16303 this.footer.container = fctr;
16304 this.footer = Roo.factory(this.footer, Roo);
16305 fctr.insertFirst(this.el);
16307 // this is a bit insane - as the paging toolbar seems to detach the el..
16308 // dom.parentNode.parentNode.parentNode
16309 // they get detached?
16313 Roo.View.superclass.constructor.call(this);
16318 Roo.extend(Roo.View, Roo.util.Observable, {
16321 * @cfg {Roo.data.Store} store Data store to load data from.
16326 * @cfg {String|Roo.Element} el The container element.
16331 * @cfg {String|Roo.Template} tpl The template used by this View
16335 * @cfg {String} dataName the named area of the template to use as the data area
16336 * Works with domtemplates roo-name="name"
16340 * @cfg {String} selectedClass The css class to add to selected nodes
16342 selectedClass : "x-view-selected",
16344 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16349 * @cfg {String} text to display on mask (default Loading)
16353 * @cfg {Boolean} multiSelect Allow multiple selection
16355 multiSelect : false,
16357 * @cfg {Boolean} singleSelect Allow single selection
16359 singleSelect: false,
16362 * @cfg {Boolean} toggleSelect - selecting
16364 toggleSelect : false,
16367 * @cfg {Boolean} tickable - selecting
16372 * Returns the element this view is bound to.
16373 * @return {Roo.Element}
16375 getEl : function(){
16376 return this.wrapEl;
16382 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16384 refresh : function(){
16385 //Roo.log('refresh');
16388 // if we are using something like 'domtemplate', then
16389 // the what gets used is:
16390 // t.applySubtemplate(NAME, data, wrapping data..)
16391 // the outer template then get' applied with
16392 // the store 'extra data'
16393 // and the body get's added to the
16394 // roo-name="data" node?
16395 // <span class='roo-tpl-{name}'></span> ?????
16399 this.clearSelections();
16400 this.el.update("");
16402 var records = this.store.getRange();
16403 if(records.length < 1) {
16405 // is this valid?? = should it render a template??
16407 this.el.update(this.emptyText);
16411 if (this.dataName) {
16412 this.el.update(t.apply(this.store.meta)); //????
16413 el = this.el.child('.roo-tpl-' + this.dataName);
16416 for(var i = 0, len = records.length; i < len; i++){
16417 var data = this.prepareData(records[i].data, i, records[i]);
16418 this.fireEvent("preparedata", this, data, i, records[i]);
16420 var d = Roo.apply({}, data);
16423 Roo.apply(d, {'roo-id' : Roo.id()});
16427 Roo.each(this.parent.item, function(item){
16428 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16431 Roo.apply(d, {'roo-data-checked' : 'checked'});
16435 html[html.length] = Roo.util.Format.trim(
16437 t.applySubtemplate(this.dataName, d, this.store.meta) :
16444 el.update(html.join(""));
16445 this.nodes = el.dom.childNodes;
16446 this.updateIndexes(0);
16451 * Function to override to reformat the data that is sent to
16452 * the template for each node.
16453 * DEPRICATED - use the preparedata event handler.
16454 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16455 * a JSON object for an UpdateManager bound view).
16457 prepareData : function(data, index, record)
16459 this.fireEvent("preparedata", this, data, index, record);
16463 onUpdate : function(ds, record){
16464 // Roo.log('on update');
16465 this.clearSelections();
16466 var index = this.store.indexOf(record);
16467 var n = this.nodes[index];
16468 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16469 n.parentNode.removeChild(n);
16470 this.updateIndexes(index, index);
16476 onAdd : function(ds, records, index)
16478 //Roo.log(['on Add', ds, records, index] );
16479 this.clearSelections();
16480 if(this.nodes.length == 0){
16484 var n = this.nodes[index];
16485 for(var i = 0, len = records.length; i < len; i++){
16486 var d = this.prepareData(records[i].data, i, records[i]);
16488 this.tpl.insertBefore(n, d);
16491 this.tpl.append(this.el, d);
16494 this.updateIndexes(index);
16497 onRemove : function(ds, record, index){
16498 // Roo.log('onRemove');
16499 this.clearSelections();
16500 var el = this.dataName ?
16501 this.el.child('.roo-tpl-' + this.dataName) :
16504 el.dom.removeChild(this.nodes[index]);
16505 this.updateIndexes(index);
16509 * Refresh an individual node.
16510 * @param {Number} index
16512 refreshNode : function(index){
16513 this.onUpdate(this.store, this.store.getAt(index));
16516 updateIndexes : function(startIndex, endIndex){
16517 var ns = this.nodes;
16518 startIndex = startIndex || 0;
16519 endIndex = endIndex || ns.length - 1;
16520 for(var i = startIndex; i <= endIndex; i++){
16521 ns[i].nodeIndex = i;
16526 * Changes the data store this view uses and refresh the view.
16527 * @param {Store} store
16529 setStore : function(store, initial){
16530 if(!initial && this.store){
16531 this.store.un("datachanged", this.refresh);
16532 this.store.un("add", this.onAdd);
16533 this.store.un("remove", this.onRemove);
16534 this.store.un("update", this.onUpdate);
16535 this.store.un("clear", this.refresh);
16536 this.store.un("beforeload", this.onBeforeLoad);
16537 this.store.un("load", this.onLoad);
16538 this.store.un("loadexception", this.onLoad);
16542 store.on("datachanged", this.refresh, this);
16543 store.on("add", this.onAdd, this);
16544 store.on("remove", this.onRemove, this);
16545 store.on("update", this.onUpdate, this);
16546 store.on("clear", this.refresh, this);
16547 store.on("beforeload", this.onBeforeLoad, this);
16548 store.on("load", this.onLoad, this);
16549 store.on("loadexception", this.onLoad, this);
16557 * onbeforeLoad - masks the loading area.
16560 onBeforeLoad : function(store,opts)
16562 //Roo.log('onBeforeLoad');
16564 this.el.update("");
16566 this.el.mask(this.mask ? this.mask : "Loading" );
16568 onLoad : function ()
16575 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16576 * @param {HTMLElement} node
16577 * @return {HTMLElement} The template node
16579 findItemFromChild : function(node){
16580 var el = this.dataName ?
16581 this.el.child('.roo-tpl-' + this.dataName,true) :
16584 if(!node || node.parentNode == el){
16587 var p = node.parentNode;
16588 while(p && p != el){
16589 if(p.parentNode == el){
16598 onClick : function(e){
16599 var item = this.findItemFromChild(e.getTarget());
16601 var index = this.indexOf(item);
16602 if(this.onItemClick(item, index, e) !== false){
16603 this.fireEvent("click", this, index, item, e);
16606 this.clearSelections();
16611 onContextMenu : function(e){
16612 var item = this.findItemFromChild(e.getTarget());
16614 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16619 onDblClick : function(e){
16620 var item = this.findItemFromChild(e.getTarget());
16622 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16626 onItemClick : function(item, index, e)
16628 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16631 if (this.toggleSelect) {
16632 var m = this.isSelected(item) ? 'unselect' : 'select';
16635 _t[m](item, true, false);
16638 if(this.multiSelect || this.singleSelect){
16639 if(this.multiSelect && e.shiftKey && this.lastSelection){
16640 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16642 this.select(item, this.multiSelect && e.ctrlKey);
16643 this.lastSelection = item;
16646 if(!this.tickable){
16647 e.preventDefault();
16655 * Get the number of selected nodes.
16658 getSelectionCount : function(){
16659 return this.selections.length;
16663 * Get the currently selected nodes.
16664 * @return {Array} An array of HTMLElements
16666 getSelectedNodes : function(){
16667 return this.selections;
16671 * Get the indexes of the selected nodes.
16674 getSelectedIndexes : function(){
16675 var indexes = [], s = this.selections;
16676 for(var i = 0, len = s.length; i < len; i++){
16677 indexes.push(s[i].nodeIndex);
16683 * Clear all selections
16684 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16686 clearSelections : function(suppressEvent){
16687 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16688 this.cmp.elements = this.selections;
16689 this.cmp.removeClass(this.selectedClass);
16690 this.selections = [];
16691 if(!suppressEvent){
16692 this.fireEvent("selectionchange", this, this.selections);
16698 * Returns true if the passed node is selected
16699 * @param {HTMLElement/Number} node The node or node index
16700 * @return {Boolean}
16702 isSelected : function(node){
16703 var s = this.selections;
16707 node = this.getNode(node);
16708 return s.indexOf(node) !== -1;
16713 * @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
16714 * @param {Boolean} keepExisting (optional) true to keep existing selections
16715 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16717 select : function(nodeInfo, keepExisting, suppressEvent){
16718 if(nodeInfo instanceof Array){
16720 this.clearSelections(true);
16722 for(var i = 0, len = nodeInfo.length; i < len; i++){
16723 this.select(nodeInfo[i], true, true);
16727 var node = this.getNode(nodeInfo);
16728 if(!node || this.isSelected(node)){
16729 return; // already selected.
16732 this.clearSelections(true);
16735 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16736 Roo.fly(node).addClass(this.selectedClass);
16737 this.selections.push(node);
16738 if(!suppressEvent){
16739 this.fireEvent("selectionchange", this, this.selections);
16747 * @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
16748 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16749 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16751 unselect : function(nodeInfo, keepExisting, suppressEvent)
16753 if(nodeInfo instanceof Array){
16754 Roo.each(this.selections, function(s) {
16755 this.unselect(s, nodeInfo);
16759 var node = this.getNode(nodeInfo);
16760 if(!node || !this.isSelected(node)){
16761 //Roo.log("not selected");
16762 return; // not selected.
16766 Roo.each(this.selections, function(s) {
16768 Roo.fly(node).removeClass(this.selectedClass);
16775 this.selections= ns;
16776 this.fireEvent("selectionchange", this, this.selections);
16780 * Gets a template node.
16781 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16782 * @return {HTMLElement} The node or null if it wasn't found
16784 getNode : function(nodeInfo){
16785 if(typeof nodeInfo == "string"){
16786 return document.getElementById(nodeInfo);
16787 }else if(typeof nodeInfo == "number"){
16788 return this.nodes[nodeInfo];
16794 * Gets a range template nodes.
16795 * @param {Number} startIndex
16796 * @param {Number} endIndex
16797 * @return {Array} An array of nodes
16799 getNodes : function(start, end){
16800 var ns = this.nodes;
16801 start = start || 0;
16802 end = typeof end == "undefined" ? ns.length - 1 : end;
16805 for(var i = start; i <= end; i++){
16809 for(var i = start; i >= end; i--){
16817 * Finds the index of the passed node
16818 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16819 * @return {Number} The index of the node or -1
16821 indexOf : function(node){
16822 node = this.getNode(node);
16823 if(typeof node.nodeIndex == "number"){
16824 return node.nodeIndex;
16826 var ns = this.nodes;
16827 for(var i = 0, len = ns.length; i < len; i++){
16838 * based on jquery fullcalendar
16842 Roo.bootstrap = Roo.bootstrap || {};
16844 * @class Roo.bootstrap.Calendar
16845 * @extends Roo.bootstrap.Component
16846 * Bootstrap Calendar class
16847 * @cfg {Boolean} loadMask (true|false) default false
16848 * @cfg {Object} header generate the user specific header of the calendar, default false
16851 * Create a new Container
16852 * @param {Object} config The config object
16857 Roo.bootstrap.Calendar = function(config){
16858 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16862 * Fires when a date is selected
16863 * @param {DatePicker} this
16864 * @param {Date} date The selected date
16868 * @event monthchange
16869 * Fires when the displayed month changes
16870 * @param {DatePicker} this
16871 * @param {Date} date The selected month
16873 'monthchange': true,
16875 * @event evententer
16876 * Fires when mouse over an event
16877 * @param {Calendar} this
16878 * @param {event} Event
16880 'evententer': true,
16882 * @event eventleave
16883 * Fires when the mouse leaves an
16884 * @param {Calendar} this
16887 'eventleave': true,
16889 * @event eventclick
16890 * Fires when the mouse click an
16891 * @param {Calendar} this
16900 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16903 * @cfg {Number} startDay
16904 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16912 getAutoCreate : function(){
16915 var fc_button = function(name, corner, style, content ) {
16916 return Roo.apply({},{
16918 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16920 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16923 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16934 style : 'width:100%',
16941 cls : 'fc-header-left',
16943 fc_button('prev', 'left', 'arrow', '‹' ),
16944 fc_button('next', 'right', 'arrow', '›' ),
16945 { tag: 'span', cls: 'fc-header-space' },
16946 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16954 cls : 'fc-header-center',
16958 cls: 'fc-header-title',
16961 html : 'month / year'
16969 cls : 'fc-header-right',
16971 /* fc_button('month', 'left', '', 'month' ),
16972 fc_button('week', '', '', 'week' ),
16973 fc_button('day', 'right', '', 'day' )
16985 header = this.header;
16988 var cal_heads = function() {
16990 // fixme - handle this.
16992 for (var i =0; i < Date.dayNames.length; i++) {
16993 var d = Date.dayNames[i];
16996 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16997 html : d.substring(0,3)
17001 ret[0].cls += ' fc-first';
17002 ret[6].cls += ' fc-last';
17005 var cal_cell = function(n) {
17008 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17013 cls: 'fc-day-number',
17017 cls: 'fc-day-content',
17021 style: 'position: relative;' // height: 17px;
17033 var cal_rows = function() {
17036 for (var r = 0; r < 6; r++) {
17043 for (var i =0; i < Date.dayNames.length; i++) {
17044 var d = Date.dayNames[i];
17045 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17048 row.cn[0].cls+=' fc-first';
17049 row.cn[0].cn[0].style = 'min-height:90px';
17050 row.cn[6].cls+=' fc-last';
17054 ret[0].cls += ' fc-first';
17055 ret[4].cls += ' fc-prev-last';
17056 ret[5].cls += ' fc-last';
17063 cls: 'fc-border-separate',
17064 style : 'width:100%',
17072 cls : 'fc-first fc-last',
17090 cls : 'fc-content',
17091 style : "position: relative;",
17094 cls : 'fc-view fc-view-month fc-grid',
17095 style : 'position: relative',
17096 unselectable : 'on',
17099 cls : 'fc-event-container',
17100 style : 'position:absolute;z-index:8;top:0;left:0;'
17118 initEvents : function()
17121 throw "can not find store for calendar";
17127 style: "text-align:center",
17131 style: "background-color:white;width:50%;margin:250 auto",
17135 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17146 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17148 var size = this.el.select('.fc-content', true).first().getSize();
17149 this.maskEl.setSize(size.width, size.height);
17150 this.maskEl.enableDisplayMode("block");
17151 if(!this.loadMask){
17152 this.maskEl.hide();
17155 this.store = Roo.factory(this.store, Roo.data);
17156 this.store.on('load', this.onLoad, this);
17157 this.store.on('beforeload', this.onBeforeLoad, this);
17161 this.cells = this.el.select('.fc-day',true);
17162 //Roo.log(this.cells);
17163 this.textNodes = this.el.query('.fc-day-number');
17164 this.cells.addClassOnOver('fc-state-hover');
17166 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17167 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17168 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17169 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17171 this.on('monthchange', this.onMonthChange, this);
17173 this.update(new Date().clearTime());
17176 resize : function() {
17177 var sz = this.el.getSize();
17179 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17180 this.el.select('.fc-day-content div',true).setHeight(34);
17185 showPrevMonth : function(e){
17186 this.update(this.activeDate.add("mo", -1));
17188 showToday : function(e){
17189 this.update(new Date().clearTime());
17192 showNextMonth : function(e){
17193 this.update(this.activeDate.add("mo", 1));
17197 showPrevYear : function(){
17198 this.update(this.activeDate.add("y", -1));
17202 showNextYear : function(){
17203 this.update(this.activeDate.add("y", 1));
17208 update : function(date)
17210 var vd = this.activeDate;
17211 this.activeDate = date;
17212 // if(vd && this.el){
17213 // var t = date.getTime();
17214 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17215 // Roo.log('using add remove');
17217 // this.fireEvent('monthchange', this, date);
17219 // this.cells.removeClass("fc-state-highlight");
17220 // this.cells.each(function(c){
17221 // if(c.dateValue == t){
17222 // c.addClass("fc-state-highlight");
17223 // setTimeout(function(){
17224 // try{c.dom.firstChild.focus();}catch(e){}
17234 var days = date.getDaysInMonth();
17236 var firstOfMonth = date.getFirstDateOfMonth();
17237 var startingPos = firstOfMonth.getDay()-this.startDay;
17239 if(startingPos < this.startDay){
17243 var pm = date.add(Date.MONTH, -1);
17244 var prevStart = pm.getDaysInMonth()-startingPos;
17246 this.cells = this.el.select('.fc-day',true);
17247 this.textNodes = this.el.query('.fc-day-number');
17248 this.cells.addClassOnOver('fc-state-hover');
17250 var cells = this.cells.elements;
17251 var textEls = this.textNodes;
17253 Roo.each(cells, function(cell){
17254 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17257 days += startingPos;
17259 // convert everything to numbers so it's fast
17260 var day = 86400000;
17261 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17264 //Roo.log(prevStart);
17266 var today = new Date().clearTime().getTime();
17267 var sel = date.clearTime().getTime();
17268 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17269 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17270 var ddMatch = this.disabledDatesRE;
17271 var ddText = this.disabledDatesText;
17272 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17273 var ddaysText = this.disabledDaysText;
17274 var format = this.format;
17276 var setCellClass = function(cal, cell){
17280 //Roo.log('set Cell Class');
17282 var t = d.getTime();
17286 cell.dateValue = t;
17288 cell.className += " fc-today";
17289 cell.className += " fc-state-highlight";
17290 cell.title = cal.todayText;
17293 // disable highlight in other month..
17294 //cell.className += " fc-state-highlight";
17299 cell.className = " fc-state-disabled";
17300 cell.title = cal.minText;
17304 cell.className = " fc-state-disabled";
17305 cell.title = cal.maxText;
17309 if(ddays.indexOf(d.getDay()) != -1){
17310 cell.title = ddaysText;
17311 cell.className = " fc-state-disabled";
17314 if(ddMatch && format){
17315 var fvalue = d.dateFormat(format);
17316 if(ddMatch.test(fvalue)){
17317 cell.title = ddText.replace("%0", fvalue);
17318 cell.className = " fc-state-disabled";
17322 if (!cell.initialClassName) {
17323 cell.initialClassName = cell.dom.className;
17326 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17331 for(; i < startingPos; i++) {
17332 textEls[i].innerHTML = (++prevStart);
17333 d.setDate(d.getDate()+1);
17335 cells[i].className = "fc-past fc-other-month";
17336 setCellClass(this, cells[i]);
17341 for(; i < days; i++){
17342 intDay = i - startingPos + 1;
17343 textEls[i].innerHTML = (intDay);
17344 d.setDate(d.getDate()+1);
17346 cells[i].className = ''; // "x-date-active";
17347 setCellClass(this, cells[i]);
17351 for(; i < 42; i++) {
17352 textEls[i].innerHTML = (++extraDays);
17353 d.setDate(d.getDate()+1);
17355 cells[i].className = "fc-future fc-other-month";
17356 setCellClass(this, cells[i]);
17359 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17361 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17363 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17364 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17366 if(totalRows != 6){
17367 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17368 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17371 this.fireEvent('monthchange', this, date);
17375 if(!this.internalRender){
17376 var main = this.el.dom.firstChild;
17377 var w = main.offsetWidth;
17378 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17379 Roo.fly(main).setWidth(w);
17380 this.internalRender = true;
17381 // opera does not respect the auto grow header center column
17382 // then, after it gets a width opera refuses to recalculate
17383 // without a second pass
17384 if(Roo.isOpera && !this.secondPass){
17385 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17386 this.secondPass = true;
17387 this.update.defer(10, this, [date]);
17394 findCell : function(dt) {
17395 dt = dt.clearTime().getTime();
17397 this.cells.each(function(c){
17398 //Roo.log("check " +c.dateValue + '?=' + dt);
17399 if(c.dateValue == dt){
17409 findCells : function(ev) {
17410 var s = ev.start.clone().clearTime().getTime();
17412 var e= ev.end.clone().clearTime().getTime();
17415 this.cells.each(function(c){
17416 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17418 if(c.dateValue > e){
17421 if(c.dateValue < s){
17430 // findBestRow: function(cells)
17434 // for (var i =0 ; i < cells.length;i++) {
17435 // ret = Math.max(cells[i].rows || 0,ret);
17442 addItem : function(ev)
17444 // look for vertical location slot in
17445 var cells = this.findCells(ev);
17447 // ev.row = this.findBestRow(cells);
17449 // work out the location.
17453 for(var i =0; i < cells.length; i++) {
17455 cells[i].row = cells[0].row;
17458 cells[i].row = cells[i].row + 1;
17468 if (crow.start.getY() == cells[i].getY()) {
17470 crow.end = cells[i];
17487 cells[0].events.push(ev);
17489 this.calevents.push(ev);
17492 clearEvents: function() {
17494 if(!this.calevents){
17498 Roo.each(this.cells.elements, function(c){
17504 Roo.each(this.calevents, function(e) {
17505 Roo.each(e.els, function(el) {
17506 el.un('mouseenter' ,this.onEventEnter, this);
17507 el.un('mouseleave' ,this.onEventLeave, this);
17512 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17518 renderEvents: function()
17522 this.cells.each(function(c) {
17531 if(c.row != c.events.length){
17532 r = 4 - (4 - (c.row - c.events.length));
17535 c.events = ev.slice(0, r);
17536 c.more = ev.slice(r);
17538 if(c.more.length && c.more.length == 1){
17539 c.events.push(c.more.pop());
17542 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17546 this.cells.each(function(c) {
17548 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17551 for (var e = 0; e < c.events.length; e++){
17552 var ev = c.events[e];
17553 var rows = ev.rows;
17555 for(var i = 0; i < rows.length; i++) {
17557 // how many rows should it span..
17560 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17561 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17563 unselectable : "on",
17566 cls: 'fc-event-inner',
17570 // cls: 'fc-event-time',
17571 // html : cells.length > 1 ? '' : ev.time
17575 cls: 'fc-event-title',
17576 html : String.format('{0}', ev.title)
17583 cls: 'ui-resizable-handle ui-resizable-e',
17584 html : '  '
17591 cfg.cls += ' fc-event-start';
17593 if ((i+1) == rows.length) {
17594 cfg.cls += ' fc-event-end';
17597 var ctr = _this.el.select('.fc-event-container',true).first();
17598 var cg = ctr.createChild(cfg);
17600 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17601 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17603 var r = (c.more.length) ? 1 : 0;
17604 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17605 cg.setWidth(ebox.right - sbox.x -2);
17607 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17608 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17609 cg.on('click', _this.onEventClick, _this, ev);
17620 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17621 style : 'position: absolute',
17622 unselectable : "on",
17625 cls: 'fc-event-inner',
17629 cls: 'fc-event-title',
17637 cls: 'ui-resizable-handle ui-resizable-e',
17638 html : '  '
17644 var ctr = _this.el.select('.fc-event-container',true).first();
17645 var cg = ctr.createChild(cfg);
17647 var sbox = c.select('.fc-day-content',true).first().getBox();
17648 var ebox = c.select('.fc-day-content',true).first().getBox();
17650 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17651 cg.setWidth(ebox.right - sbox.x -2);
17653 cg.on('click', _this.onMoreEventClick, _this, c.more);
17663 onEventEnter: function (e, el,event,d) {
17664 this.fireEvent('evententer', this, el, event);
17667 onEventLeave: function (e, el,event,d) {
17668 this.fireEvent('eventleave', this, el, event);
17671 onEventClick: function (e, el,event,d) {
17672 this.fireEvent('eventclick', this, el, event);
17675 onMonthChange: function () {
17679 onMoreEventClick: function(e, el, more)
17683 this.calpopover.placement = 'right';
17684 this.calpopover.setTitle('More');
17686 this.calpopover.setContent('');
17688 var ctr = this.calpopover.el.select('.popover-content', true).first();
17690 Roo.each(more, function(m){
17692 cls : 'fc-event-hori fc-event-draggable',
17695 var cg = ctr.createChild(cfg);
17697 cg.on('click', _this.onEventClick, _this, m);
17700 this.calpopover.show(el);
17705 onLoad: function ()
17707 this.calevents = [];
17710 if(this.store.getCount() > 0){
17711 this.store.data.each(function(d){
17714 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17715 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17716 time : d.data.start_time,
17717 title : d.data.title,
17718 description : d.data.description,
17719 venue : d.data.venue
17724 this.renderEvents();
17726 if(this.calevents.length && this.loadMask){
17727 this.maskEl.hide();
17731 onBeforeLoad: function()
17733 this.clearEvents();
17735 this.maskEl.show();
17749 * @class Roo.bootstrap.Popover
17750 * @extends Roo.bootstrap.Component
17751 * Bootstrap Popover class
17752 * @cfg {String} html contents of the popover (or false to use children..)
17753 * @cfg {String} title of popover (or false to hide)
17754 * @cfg {String} placement how it is placed
17755 * @cfg {String} trigger click || hover (or false to trigger manually)
17756 * @cfg {String} over what (parent or false to trigger manually.)
17757 * @cfg {Number} delay - delay before showing
17760 * Create a new Popover
17761 * @param {Object} config The config object
17764 Roo.bootstrap.Popover = function(config){
17765 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17771 * After the popover show
17773 * @param {Roo.bootstrap.Popover} this
17778 * After the popover hide
17780 * @param {Roo.bootstrap.Popover} this
17786 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17788 title: 'Fill in a title',
17791 placement : 'right',
17792 trigger : 'hover', // hover
17798 can_build_overlaid : false,
17800 getChildContainer : function()
17802 return this.el.select('.popover-content',true).first();
17805 getAutoCreate : function(){
17808 cls : 'popover roo-dynamic',
17809 style: 'display:block',
17815 cls : 'popover-inner',
17819 cls: 'popover-title popover-header',
17823 cls : 'popover-content popover-body',
17834 setTitle: function(str)
17837 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17839 setContent: function(str)
17842 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17844 // as it get's added to the bottom of the page.
17845 onRender : function(ct, position)
17847 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17849 var cfg = Roo.apply({}, this.getAutoCreate());
17853 cfg.cls += ' ' + this.cls;
17856 cfg.style = this.style;
17858 //Roo.log("adding to ");
17859 this.el = Roo.get(document.body).createChild(cfg, position);
17860 // Roo.log(this.el);
17865 initEvents : function()
17867 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17868 this.el.enableDisplayMode('block');
17870 if (this.over === false) {
17873 if (this.triggers === false) {
17876 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17877 var triggers = this.trigger ? this.trigger.split(' ') : [];
17878 Roo.each(triggers, function(trigger) {
17880 if (trigger == 'click') {
17881 on_el.on('click', this.toggle, this);
17882 } else if (trigger != 'manual') {
17883 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17884 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17886 on_el.on(eventIn ,this.enter, this);
17887 on_el.on(eventOut, this.leave, this);
17898 toggle : function () {
17899 this.hoverState == 'in' ? this.leave() : this.enter();
17902 enter : function () {
17904 clearTimeout(this.timeout);
17906 this.hoverState = 'in';
17908 if (!this.delay || !this.delay.show) {
17913 this.timeout = setTimeout(function () {
17914 if (_t.hoverState == 'in') {
17917 }, this.delay.show)
17920 leave : function() {
17921 clearTimeout(this.timeout);
17923 this.hoverState = 'out';
17925 if (!this.delay || !this.delay.hide) {
17930 this.timeout = setTimeout(function () {
17931 if (_t.hoverState == 'out') {
17934 }, this.delay.hide)
17937 show : function (on_el)
17940 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17944 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17945 if (this.html !== false) {
17946 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17948 this.el.removeClass([
17949 'fade','top','bottom', 'left', 'right','in',
17950 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17952 if (!this.title.length) {
17953 this.el.select('.popover-title',true).hide();
17956 var placement = typeof this.placement == 'function' ?
17957 this.placement.call(this, this.el, on_el) :
17960 var autoToken = /\s?auto?\s?/i;
17961 var autoPlace = autoToken.test(placement);
17963 placement = placement.replace(autoToken, '') || 'top';
17967 //this.el.setXY([0,0]);
17969 this.el.dom.style.display='block';
17970 this.el.addClass(placement);
17972 //this.el.appendTo(on_el);
17974 var p = this.getPosition();
17975 var box = this.el.getBox();
17980 var align = Roo.bootstrap.Popover.alignment[placement];
17983 this.el.alignTo(on_el, align[0],align[1]);
17984 //var arrow = this.el.select('.arrow',true).first();
17985 //arrow.set(align[2],
17987 this.el.addClass('in');
17990 if (this.el.hasClass('fade')) {
17994 this.hoverState = 'in';
17996 this.fireEvent('show', this);
18001 this.el.setXY([0,0]);
18002 this.el.removeClass('in');
18004 this.hoverState = null;
18006 this.fireEvent('hide', this);
18011 Roo.bootstrap.Popover.alignment = {
18012 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18013 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18014 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18015 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18026 * @class Roo.bootstrap.Progress
18027 * @extends Roo.bootstrap.Component
18028 * Bootstrap Progress class
18029 * @cfg {Boolean} striped striped of the progress bar
18030 * @cfg {Boolean} active animated of the progress bar
18034 * Create a new Progress
18035 * @param {Object} config The config object
18038 Roo.bootstrap.Progress = function(config){
18039 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18042 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18047 getAutoCreate : function(){
18055 cfg.cls += ' progress-striped';
18059 cfg.cls += ' active';
18078 * @class Roo.bootstrap.ProgressBar
18079 * @extends Roo.bootstrap.Component
18080 * Bootstrap ProgressBar class
18081 * @cfg {Number} aria_valuenow aria-value now
18082 * @cfg {Number} aria_valuemin aria-value min
18083 * @cfg {Number} aria_valuemax aria-value max
18084 * @cfg {String} label label for the progress bar
18085 * @cfg {String} panel (success | info | warning | danger )
18086 * @cfg {String} role role of the progress bar
18087 * @cfg {String} sr_only text
18091 * Create a new ProgressBar
18092 * @param {Object} config The config object
18095 Roo.bootstrap.ProgressBar = function(config){
18096 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18099 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18103 aria_valuemax : 100,
18109 getAutoCreate : function()
18114 cls: 'progress-bar',
18115 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18127 cfg.role = this.role;
18130 if(this.aria_valuenow){
18131 cfg['aria-valuenow'] = this.aria_valuenow;
18134 if(this.aria_valuemin){
18135 cfg['aria-valuemin'] = this.aria_valuemin;
18138 if(this.aria_valuemax){
18139 cfg['aria-valuemax'] = this.aria_valuemax;
18142 if(this.label && !this.sr_only){
18143 cfg.html = this.label;
18147 cfg.cls += ' progress-bar-' + this.panel;
18153 update : function(aria_valuenow)
18155 this.aria_valuenow = aria_valuenow;
18157 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18172 * @class Roo.bootstrap.TabGroup
18173 * @extends Roo.bootstrap.Column
18174 * Bootstrap Column class
18175 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18176 * @cfg {Boolean} carousel true to make the group behave like a carousel
18177 * @cfg {Boolean} bullets show bullets for the panels
18178 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18179 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18180 * @cfg {Boolean} showarrow (true|false) show arrow default true
18183 * Create a new TabGroup
18184 * @param {Object} config The config object
18187 Roo.bootstrap.TabGroup = function(config){
18188 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18190 this.navId = Roo.id();
18193 Roo.bootstrap.TabGroup.register(this);
18197 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18200 transition : false,
18205 slideOnTouch : false,
18208 getAutoCreate : function()
18210 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18212 cfg.cls += ' tab-content';
18214 if (this.carousel) {
18215 cfg.cls += ' carousel slide';
18218 cls : 'carousel-inner',
18222 if(this.bullets && !Roo.isTouch){
18225 cls : 'carousel-bullets',
18229 if(this.bullets_cls){
18230 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18237 cfg.cn[0].cn.push(bullets);
18240 if(this.showarrow){
18241 cfg.cn[0].cn.push({
18243 class : 'carousel-arrow',
18247 class : 'carousel-prev',
18251 class : 'fa fa-chevron-left'
18257 class : 'carousel-next',
18261 class : 'fa fa-chevron-right'
18274 initEvents: function()
18276 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18277 // this.el.on("touchstart", this.onTouchStart, this);
18280 if(this.autoslide){
18283 this.slideFn = window.setInterval(function() {
18284 _this.showPanelNext();
18288 if(this.showarrow){
18289 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18290 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18296 // onTouchStart : function(e, el, o)
18298 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18302 // this.showPanelNext();
18306 getChildContainer : function()
18308 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18312 * register a Navigation item
18313 * @param {Roo.bootstrap.NavItem} the navitem to add
18315 register : function(item)
18317 this.tabs.push( item);
18318 item.navId = this.navId; // not really needed..
18323 getActivePanel : function()
18326 Roo.each(this.tabs, function(t) {
18336 getPanelByName : function(n)
18339 Roo.each(this.tabs, function(t) {
18340 if (t.tabId == n) {
18348 indexOfPanel : function(p)
18351 Roo.each(this.tabs, function(t,i) {
18352 if (t.tabId == p.tabId) {
18361 * show a specific panel
18362 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18363 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18365 showPanel : function (pan)
18367 if(this.transition || typeof(pan) == 'undefined'){
18368 Roo.log("waiting for the transitionend");
18372 if (typeof(pan) == 'number') {
18373 pan = this.tabs[pan];
18376 if (typeof(pan) == 'string') {
18377 pan = this.getPanelByName(pan);
18380 var cur = this.getActivePanel();
18383 Roo.log('pan or acitve pan is undefined');
18387 if (pan.tabId == this.getActivePanel().tabId) {
18391 if (false === cur.fireEvent('beforedeactivate')) {
18395 if(this.bullets > 0 && !Roo.isTouch){
18396 this.setActiveBullet(this.indexOfPanel(pan));
18399 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18401 //class="carousel-item carousel-item-next carousel-item-left"
18403 this.transition = true;
18404 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18405 var lr = dir == 'next' ? 'left' : 'right';
18406 pan.el.addClass(dir); // or prev
18407 pan.el.addClass('carousel-item-' + dir); // or prev
18408 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18409 cur.el.addClass(lr); // or right
18410 pan.el.addClass(lr);
18411 cur.el.addClass('carousel-item-' +lr); // or right
18412 pan.el.addClass('carousel-item-' +lr);
18416 cur.el.on('transitionend', function() {
18417 Roo.log("trans end?");
18419 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18420 pan.setActive(true);
18422 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18423 cur.setActive(false);
18425 _this.transition = false;
18427 }, this, { single: true } );
18432 cur.setActive(false);
18433 pan.setActive(true);
18438 showPanelNext : function()
18440 var i = this.indexOfPanel(this.getActivePanel());
18442 if (i >= this.tabs.length - 1 && !this.autoslide) {
18446 if (i >= this.tabs.length - 1 && this.autoslide) {
18450 this.showPanel(this.tabs[i+1]);
18453 showPanelPrev : function()
18455 var i = this.indexOfPanel(this.getActivePanel());
18457 if (i < 1 && !this.autoslide) {
18461 if (i < 1 && this.autoslide) {
18462 i = this.tabs.length;
18465 this.showPanel(this.tabs[i-1]);
18469 addBullet: function()
18471 if(!this.bullets || Roo.isTouch){
18474 var ctr = this.el.select('.carousel-bullets',true).first();
18475 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18476 var bullet = ctr.createChild({
18477 cls : 'bullet bullet-' + i
18478 },ctr.dom.lastChild);
18483 bullet.on('click', (function(e, el, o, ii, t){
18485 e.preventDefault();
18487 this.showPanel(ii);
18489 if(this.autoslide && this.slideFn){
18490 clearInterval(this.slideFn);
18491 this.slideFn = window.setInterval(function() {
18492 _this.showPanelNext();
18496 }).createDelegate(this, [i, bullet], true));
18501 setActiveBullet : function(i)
18507 Roo.each(this.el.select('.bullet', true).elements, function(el){
18508 el.removeClass('selected');
18511 var bullet = this.el.select('.bullet-' + i, true).first();
18517 bullet.addClass('selected');
18528 Roo.apply(Roo.bootstrap.TabGroup, {
18532 * register a Navigation Group
18533 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18535 register : function(navgrp)
18537 this.groups[navgrp.navId] = navgrp;
18541 * fetch a Navigation Group based on the navigation ID
18542 * if one does not exist , it will get created.
18543 * @param {string} the navgroup to add
18544 * @returns {Roo.bootstrap.NavGroup} the navgroup
18546 get: function(navId) {
18547 if (typeof(this.groups[navId]) == 'undefined') {
18548 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18550 return this.groups[navId] ;
18565 * @class Roo.bootstrap.TabPanel
18566 * @extends Roo.bootstrap.Component
18567 * Bootstrap TabPanel class
18568 * @cfg {Boolean} active panel active
18569 * @cfg {String} html panel content
18570 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18571 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18572 * @cfg {String} href click to link..
18576 * Create a new TabPanel
18577 * @param {Object} config The config object
18580 Roo.bootstrap.TabPanel = function(config){
18581 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18585 * Fires when the active status changes
18586 * @param {Roo.bootstrap.TabPanel} this
18587 * @param {Boolean} state the new state
18592 * @event beforedeactivate
18593 * Fires before a tab is de-activated - can be used to do validation on a form.
18594 * @param {Roo.bootstrap.TabPanel} this
18595 * @return {Boolean} false if there is an error
18598 'beforedeactivate': true
18601 this.tabId = this.tabId || Roo.id();
18605 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18613 getAutoCreate : function(){
18618 // item is needed for carousel - not sure if it has any effect otherwise
18619 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18620 html: this.html || ''
18624 cfg.cls += ' active';
18628 cfg.tabId = this.tabId;
18636 initEvents: function()
18638 var p = this.parent();
18640 this.navId = this.navId || p.navId;
18642 if (typeof(this.navId) != 'undefined') {
18643 // not really needed.. but just in case.. parent should be a NavGroup.
18644 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18648 var i = tg.tabs.length - 1;
18650 if(this.active && tg.bullets > 0 && i < tg.bullets){
18651 tg.setActiveBullet(i);
18655 this.el.on('click', this.onClick, this);
18658 this.el.on("touchstart", this.onTouchStart, this);
18659 this.el.on("touchmove", this.onTouchMove, this);
18660 this.el.on("touchend", this.onTouchEnd, this);
18665 onRender : function(ct, position)
18667 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18670 setActive : function(state)
18672 Roo.log("panel - set active " + this.tabId + "=" + state);
18674 this.active = state;
18676 this.el.removeClass('active');
18678 } else if (!this.el.hasClass('active')) {
18679 this.el.addClass('active');
18682 this.fireEvent('changed', this, state);
18685 onClick : function(e)
18687 e.preventDefault();
18689 if(!this.href.length){
18693 window.location.href = this.href;
18702 onTouchStart : function(e)
18704 this.swiping = false;
18706 this.startX = e.browserEvent.touches[0].clientX;
18707 this.startY = e.browserEvent.touches[0].clientY;
18710 onTouchMove : function(e)
18712 this.swiping = true;
18714 this.endX = e.browserEvent.touches[0].clientX;
18715 this.endY = e.browserEvent.touches[0].clientY;
18718 onTouchEnd : function(e)
18725 var tabGroup = this.parent();
18727 if(this.endX > this.startX){ // swiping right
18728 tabGroup.showPanelPrev();
18732 if(this.startX > this.endX){ // swiping left
18733 tabGroup.showPanelNext();
18752 * @class Roo.bootstrap.DateField
18753 * @extends Roo.bootstrap.Input
18754 * Bootstrap DateField class
18755 * @cfg {Number} weekStart default 0
18756 * @cfg {String} viewMode default empty, (months|years)
18757 * @cfg {String} minViewMode default empty, (months|years)
18758 * @cfg {Number} startDate default -Infinity
18759 * @cfg {Number} endDate default Infinity
18760 * @cfg {Boolean} todayHighlight default false
18761 * @cfg {Boolean} todayBtn default false
18762 * @cfg {Boolean} calendarWeeks default false
18763 * @cfg {Object} daysOfWeekDisabled default empty
18764 * @cfg {Boolean} singleMode default false (true | false)
18766 * @cfg {Boolean} keyboardNavigation default true
18767 * @cfg {String} language default en
18770 * Create a new DateField
18771 * @param {Object} config The config object
18774 Roo.bootstrap.DateField = function(config){
18775 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18779 * Fires when this field show.
18780 * @param {Roo.bootstrap.DateField} this
18781 * @param {Mixed} date The date value
18786 * Fires when this field hide.
18787 * @param {Roo.bootstrap.DateField} this
18788 * @param {Mixed} date The date value
18793 * Fires when select a date.
18794 * @param {Roo.bootstrap.DateField} this
18795 * @param {Mixed} date The date value
18799 * @event beforeselect
18800 * Fires when before select a date.
18801 * @param {Roo.bootstrap.DateField} this
18802 * @param {Mixed} date The date value
18804 beforeselect : true
18808 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18811 * @cfg {String} format
18812 * The default date format string which can be overriden for localization support. The format must be
18813 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18817 * @cfg {String} altFormats
18818 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18819 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18821 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18829 todayHighlight : false,
18835 keyboardNavigation: true,
18837 calendarWeeks: false,
18839 startDate: -Infinity,
18843 daysOfWeekDisabled: [],
18847 singleMode : false,
18849 UTCDate: function()
18851 return new Date(Date.UTC.apply(Date, arguments));
18854 UTCToday: function()
18856 var today = new Date();
18857 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18860 getDate: function() {
18861 var d = this.getUTCDate();
18862 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18865 getUTCDate: function() {
18869 setDate: function(d) {
18870 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18873 setUTCDate: function(d) {
18875 this.setValue(this.formatDate(this.date));
18878 onRender: function(ct, position)
18881 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18883 this.language = this.language || 'en';
18884 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18885 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18887 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18888 this.format = this.format || 'm/d/y';
18889 this.isInline = false;
18890 this.isInput = true;
18891 this.component = this.el.select('.add-on', true).first() || false;
18892 this.component = (this.component && this.component.length === 0) ? false : this.component;
18893 this.hasInput = this.component && this.inputEl().length;
18895 if (typeof(this.minViewMode === 'string')) {
18896 switch (this.minViewMode) {
18898 this.minViewMode = 1;
18901 this.minViewMode = 2;
18904 this.minViewMode = 0;
18909 if (typeof(this.viewMode === 'string')) {
18910 switch (this.viewMode) {
18923 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18925 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18927 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18929 this.picker().on('mousedown', this.onMousedown, this);
18930 this.picker().on('click', this.onClick, this);
18932 this.picker().addClass('datepicker-dropdown');
18934 this.startViewMode = this.viewMode;
18936 if(this.singleMode){
18937 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18938 v.setVisibilityMode(Roo.Element.DISPLAY);
18942 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18943 v.setStyle('width', '189px');
18947 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18948 if(!this.calendarWeeks){
18953 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18954 v.attr('colspan', function(i, val){
18955 return parseInt(val) + 1;
18960 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18962 this.setStartDate(this.startDate);
18963 this.setEndDate(this.endDate);
18965 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18972 if(this.isInline) {
18977 picker : function()
18979 return this.pickerEl;
18980 // return this.el.select('.datepicker', true).first();
18983 fillDow: function()
18985 var dowCnt = this.weekStart;
18994 if(this.calendarWeeks){
19002 while (dowCnt < this.weekStart + 7) {
19006 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19010 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19013 fillMonths: function()
19016 var months = this.picker().select('>.datepicker-months td', true).first();
19018 months.dom.innerHTML = '';
19024 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19027 months.createChild(month);
19034 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;
19036 if (this.date < this.startDate) {
19037 this.viewDate = new Date(this.startDate);
19038 } else if (this.date > this.endDate) {
19039 this.viewDate = new Date(this.endDate);
19041 this.viewDate = new Date(this.date);
19049 var d = new Date(this.viewDate),
19050 year = d.getUTCFullYear(),
19051 month = d.getUTCMonth(),
19052 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19053 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19054 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19055 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19056 currentDate = this.date && this.date.valueOf(),
19057 today = this.UTCToday();
19059 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19061 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19063 // this.picker.select('>tfoot th.today').
19064 // .text(dates[this.language].today)
19065 // .toggle(this.todayBtn !== false);
19067 this.updateNavArrows();
19070 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19072 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19074 prevMonth.setUTCDate(day);
19076 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19078 var nextMonth = new Date(prevMonth);
19080 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19082 nextMonth = nextMonth.valueOf();
19084 var fillMonths = false;
19086 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19088 while(prevMonth.valueOf() <= nextMonth) {
19091 if (prevMonth.getUTCDay() === this.weekStart) {
19093 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19101 if(this.calendarWeeks){
19102 // ISO 8601: First week contains first thursday.
19103 // ISO also states week starts on Monday, but we can be more abstract here.
19105 // Start of current week: based on weekstart/current date
19106 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19107 // Thursday of this week
19108 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19109 // First Thursday of year, year from thursday
19110 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19111 // Calendar week: ms between thursdays, div ms per day, div 7 days
19112 calWeek = (th - yth) / 864e5 / 7 + 1;
19114 fillMonths.cn.push({
19122 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19124 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19127 if (this.todayHighlight &&
19128 prevMonth.getUTCFullYear() == today.getFullYear() &&
19129 prevMonth.getUTCMonth() == today.getMonth() &&
19130 prevMonth.getUTCDate() == today.getDate()) {
19131 clsName += ' today';
19134 if (currentDate && prevMonth.valueOf() === currentDate) {
19135 clsName += ' active';
19138 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19139 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19140 clsName += ' disabled';
19143 fillMonths.cn.push({
19145 cls: 'day ' + clsName,
19146 html: prevMonth.getDate()
19149 prevMonth.setDate(prevMonth.getDate()+1);
19152 var currentYear = this.date && this.date.getUTCFullYear();
19153 var currentMonth = this.date && this.date.getUTCMonth();
19155 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19157 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19158 v.removeClass('active');
19160 if(currentYear === year && k === currentMonth){
19161 v.addClass('active');
19164 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19165 v.addClass('disabled');
19171 year = parseInt(year/10, 10) * 10;
19173 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19175 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19178 for (var i = -1; i < 11; i++) {
19179 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19181 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19189 showMode: function(dir)
19192 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19195 Roo.each(this.picker().select('>div',true).elements, function(v){
19196 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19199 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19204 if(this.isInline) {
19208 this.picker().removeClass(['bottom', 'top']);
19210 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19212 * place to the top of element!
19216 this.picker().addClass('top');
19217 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19222 this.picker().addClass('bottom');
19224 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19227 parseDate : function(value)
19229 if(!value || value instanceof Date){
19232 var v = Date.parseDate(value, this.format);
19233 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19234 v = Date.parseDate(value, 'Y-m-d');
19236 if(!v && this.altFormats){
19237 if(!this.altFormatsArray){
19238 this.altFormatsArray = this.altFormats.split("|");
19240 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19241 v = Date.parseDate(value, this.altFormatsArray[i]);
19247 formatDate : function(date, fmt)
19249 return (!date || !(date instanceof Date)) ?
19250 date : date.dateFormat(fmt || this.format);
19253 onFocus : function()
19255 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19259 onBlur : function()
19261 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19263 var d = this.inputEl().getValue();
19270 showPopup : function()
19272 this.picker().show();
19276 this.fireEvent('showpopup', this, this.date);
19279 hidePopup : function()
19281 if(this.isInline) {
19284 this.picker().hide();
19285 this.viewMode = this.startViewMode;
19288 this.fireEvent('hidepopup', this, this.date);
19292 onMousedown: function(e)
19294 e.stopPropagation();
19295 e.preventDefault();
19300 Roo.bootstrap.DateField.superclass.keyup.call(this);
19304 setValue: function(v)
19306 if(this.fireEvent('beforeselect', this, v) !== false){
19307 var d = new Date(this.parseDate(v) ).clearTime();
19309 if(isNaN(d.getTime())){
19310 this.date = this.viewDate = '';
19311 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19315 v = this.formatDate(d);
19317 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19319 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19323 this.fireEvent('select', this, this.date);
19327 getValue: function()
19329 return this.formatDate(this.date);
19332 fireKey: function(e)
19334 if (!this.picker().isVisible()){
19335 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19341 var dateChanged = false,
19343 newDate, newViewDate;
19348 e.preventDefault();
19352 if (!this.keyboardNavigation) {
19355 dir = e.keyCode == 37 ? -1 : 1;
19358 newDate = this.moveYear(this.date, dir);
19359 newViewDate = this.moveYear(this.viewDate, dir);
19360 } else if (e.shiftKey){
19361 newDate = this.moveMonth(this.date, dir);
19362 newViewDate = this.moveMonth(this.viewDate, dir);
19364 newDate = new Date(this.date);
19365 newDate.setUTCDate(this.date.getUTCDate() + dir);
19366 newViewDate = new Date(this.viewDate);
19367 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19369 if (this.dateWithinRange(newDate)){
19370 this.date = newDate;
19371 this.viewDate = newViewDate;
19372 this.setValue(this.formatDate(this.date));
19374 e.preventDefault();
19375 dateChanged = true;
19380 if (!this.keyboardNavigation) {
19383 dir = e.keyCode == 38 ? -1 : 1;
19385 newDate = this.moveYear(this.date, dir);
19386 newViewDate = this.moveYear(this.viewDate, dir);
19387 } else if (e.shiftKey){
19388 newDate = this.moveMonth(this.date, dir);
19389 newViewDate = this.moveMonth(this.viewDate, dir);
19391 newDate = new Date(this.date);
19392 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19393 newViewDate = new Date(this.viewDate);
19394 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19396 if (this.dateWithinRange(newDate)){
19397 this.date = newDate;
19398 this.viewDate = newViewDate;
19399 this.setValue(this.formatDate(this.date));
19401 e.preventDefault();
19402 dateChanged = true;
19406 this.setValue(this.formatDate(this.date));
19408 e.preventDefault();
19411 this.setValue(this.formatDate(this.date));
19425 onClick: function(e)
19427 e.stopPropagation();
19428 e.preventDefault();
19430 var target = e.getTarget();
19432 if(target.nodeName.toLowerCase() === 'i'){
19433 target = Roo.get(target).dom.parentNode;
19436 var nodeName = target.nodeName;
19437 var className = target.className;
19438 var html = target.innerHTML;
19439 //Roo.log(nodeName);
19441 switch(nodeName.toLowerCase()) {
19443 switch(className) {
19449 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19450 switch(this.viewMode){
19452 this.viewDate = this.moveMonth(this.viewDate, dir);
19456 this.viewDate = this.moveYear(this.viewDate, dir);
19462 var date = new Date();
19463 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19465 this.setValue(this.formatDate(this.date));
19472 if (className.indexOf('disabled') < 0) {
19473 this.viewDate.setUTCDate(1);
19474 if (className.indexOf('month') > -1) {
19475 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19477 var year = parseInt(html, 10) || 0;
19478 this.viewDate.setUTCFullYear(year);
19482 if(this.singleMode){
19483 this.setValue(this.formatDate(this.viewDate));
19494 //Roo.log(className);
19495 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19496 var day = parseInt(html, 10) || 1;
19497 var year = this.viewDate.getUTCFullYear(),
19498 month = this.viewDate.getUTCMonth();
19500 if (className.indexOf('old') > -1) {
19507 } else if (className.indexOf('new') > -1) {
19515 //Roo.log([year,month,day]);
19516 this.date = this.UTCDate(year, month, day,0,0,0,0);
19517 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19519 //Roo.log(this.formatDate(this.date));
19520 this.setValue(this.formatDate(this.date));
19527 setStartDate: function(startDate)
19529 this.startDate = startDate || -Infinity;
19530 if (this.startDate !== -Infinity) {
19531 this.startDate = this.parseDate(this.startDate);
19534 this.updateNavArrows();
19537 setEndDate: function(endDate)
19539 this.endDate = endDate || Infinity;
19540 if (this.endDate !== Infinity) {
19541 this.endDate = this.parseDate(this.endDate);
19544 this.updateNavArrows();
19547 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19549 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19550 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19551 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19553 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19554 return parseInt(d, 10);
19557 this.updateNavArrows();
19560 updateNavArrows: function()
19562 if(this.singleMode){
19566 var d = new Date(this.viewDate),
19567 year = d.getUTCFullYear(),
19568 month = d.getUTCMonth();
19570 Roo.each(this.picker().select('.prev', true).elements, function(v){
19572 switch (this.viewMode) {
19575 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19581 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19588 Roo.each(this.picker().select('.next', true).elements, function(v){
19590 switch (this.viewMode) {
19593 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19599 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19607 moveMonth: function(date, dir)
19612 var new_date = new Date(date.valueOf()),
19613 day = new_date.getUTCDate(),
19614 month = new_date.getUTCMonth(),
19615 mag = Math.abs(dir),
19617 dir = dir > 0 ? 1 : -1;
19620 // If going back one month, make sure month is not current month
19621 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19623 return new_date.getUTCMonth() == month;
19625 // If going forward one month, make sure month is as expected
19626 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19628 return new_date.getUTCMonth() != new_month;
19630 new_month = month + dir;
19631 new_date.setUTCMonth(new_month);
19632 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19633 if (new_month < 0 || new_month > 11) {
19634 new_month = (new_month + 12) % 12;
19637 // For magnitudes >1, move one month at a time...
19638 for (var i=0; i<mag; i++) {
19639 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19640 new_date = this.moveMonth(new_date, dir);
19642 // ...then reset the day, keeping it in the new month
19643 new_month = new_date.getUTCMonth();
19644 new_date.setUTCDate(day);
19646 return new_month != new_date.getUTCMonth();
19649 // Common date-resetting loop -- if date is beyond end of month, make it
19652 new_date.setUTCDate(--day);
19653 new_date.setUTCMonth(new_month);
19658 moveYear: function(date, dir)
19660 return this.moveMonth(date, dir*12);
19663 dateWithinRange: function(date)
19665 return date >= this.startDate && date <= this.endDate;
19671 this.picker().remove();
19674 validateValue : function(value)
19676 if(this.getVisibilityEl().hasClass('hidden')){
19680 if(value.length < 1) {
19681 if(this.allowBlank){
19687 if(value.length < this.minLength){
19690 if(value.length > this.maxLength){
19694 var vt = Roo.form.VTypes;
19695 if(!vt[this.vtype](value, this)){
19699 if(typeof this.validator == "function"){
19700 var msg = this.validator(value);
19706 if(this.regex && !this.regex.test(value)){
19710 if(typeof(this.parseDate(value)) == 'undefined'){
19714 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19718 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19728 this.date = this.viewDate = '';
19730 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19735 Roo.apply(Roo.bootstrap.DateField, {
19746 html: '<i class="fa fa-arrow-left"/>'
19756 html: '<i class="fa fa-arrow-right"/>'
19798 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19799 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19800 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19801 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19802 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19815 navFnc: 'FullYear',
19820 navFnc: 'FullYear',
19825 Roo.apply(Roo.bootstrap.DateField, {
19829 cls: 'datepicker dropdown-menu roo-dynamic',
19833 cls: 'datepicker-days',
19837 cls: 'table-condensed',
19839 Roo.bootstrap.DateField.head,
19843 Roo.bootstrap.DateField.footer
19850 cls: 'datepicker-months',
19854 cls: 'table-condensed',
19856 Roo.bootstrap.DateField.head,
19857 Roo.bootstrap.DateField.content,
19858 Roo.bootstrap.DateField.footer
19865 cls: 'datepicker-years',
19869 cls: 'table-condensed',
19871 Roo.bootstrap.DateField.head,
19872 Roo.bootstrap.DateField.content,
19873 Roo.bootstrap.DateField.footer
19892 * @class Roo.bootstrap.TimeField
19893 * @extends Roo.bootstrap.Input
19894 * Bootstrap DateField class
19898 * Create a new TimeField
19899 * @param {Object} config The config object
19902 Roo.bootstrap.TimeField = function(config){
19903 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19907 * Fires when this field show.
19908 * @param {Roo.bootstrap.DateField} thisthis
19909 * @param {Mixed} date The date value
19914 * Fires when this field hide.
19915 * @param {Roo.bootstrap.DateField} this
19916 * @param {Mixed} date The date value
19921 * Fires when select a date.
19922 * @param {Roo.bootstrap.DateField} this
19923 * @param {Mixed} date The date value
19929 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19932 * @cfg {String} format
19933 * The default time format string which can be overriden for localization support. The format must be
19934 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19938 onRender: function(ct, position)
19941 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19943 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19945 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19947 this.pop = this.picker().select('>.datepicker-time',true).first();
19948 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19950 this.picker().on('mousedown', this.onMousedown, this);
19951 this.picker().on('click', this.onClick, this);
19953 this.picker().addClass('datepicker-dropdown');
19958 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19959 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19960 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19961 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19962 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19963 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19967 fireKey: function(e){
19968 if (!this.picker().isVisible()){
19969 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19975 e.preventDefault();
19983 this.onTogglePeriod();
19986 this.onIncrementMinutes();
19989 this.onDecrementMinutes();
19998 onClick: function(e) {
19999 e.stopPropagation();
20000 e.preventDefault();
20003 picker : function()
20005 return this.el.select('.datepicker', true).first();
20008 fillTime: function()
20010 var time = this.pop.select('tbody', true).first();
20012 time.dom.innerHTML = '';
20027 cls: 'hours-up glyphicon glyphicon-chevron-up'
20047 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20068 cls: 'timepicker-hour',
20083 cls: 'timepicker-minute',
20098 cls: 'btn btn-primary period',
20120 cls: 'hours-down glyphicon glyphicon-chevron-down'
20140 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20158 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20165 var hours = this.time.getHours();
20166 var minutes = this.time.getMinutes();
20179 hours = hours - 12;
20183 hours = '0' + hours;
20187 minutes = '0' + minutes;
20190 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20191 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20192 this.pop.select('button', true).first().dom.innerHTML = period;
20198 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20200 var cls = ['bottom'];
20202 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20209 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20214 this.picker().addClass(cls.join('-'));
20218 Roo.each(cls, function(c){
20220 _this.picker().setTop(_this.inputEl().getHeight());
20224 _this.picker().setTop(0 - _this.picker().getHeight());
20229 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20233 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20240 onFocus : function()
20242 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20246 onBlur : function()
20248 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20254 this.picker().show();
20259 this.fireEvent('show', this, this.date);
20264 this.picker().hide();
20267 this.fireEvent('hide', this, this.date);
20270 setTime : function()
20273 this.setValue(this.time.format(this.format));
20275 this.fireEvent('select', this, this.date);
20280 onMousedown: function(e){
20281 e.stopPropagation();
20282 e.preventDefault();
20285 onIncrementHours: function()
20287 Roo.log('onIncrementHours');
20288 this.time = this.time.add(Date.HOUR, 1);
20293 onDecrementHours: function()
20295 Roo.log('onDecrementHours');
20296 this.time = this.time.add(Date.HOUR, -1);
20300 onIncrementMinutes: function()
20302 Roo.log('onIncrementMinutes');
20303 this.time = this.time.add(Date.MINUTE, 1);
20307 onDecrementMinutes: function()
20309 Roo.log('onDecrementMinutes');
20310 this.time = this.time.add(Date.MINUTE, -1);
20314 onTogglePeriod: function()
20316 Roo.log('onTogglePeriod');
20317 this.time = this.time.add(Date.HOUR, 12);
20324 Roo.apply(Roo.bootstrap.TimeField, {
20354 cls: 'btn btn-info ok',
20366 Roo.apply(Roo.bootstrap.TimeField, {
20370 cls: 'datepicker dropdown-menu',
20374 cls: 'datepicker-time',
20378 cls: 'table-condensed',
20380 Roo.bootstrap.TimeField.content,
20381 Roo.bootstrap.TimeField.footer
20400 * @class Roo.bootstrap.MonthField
20401 * @extends Roo.bootstrap.Input
20402 * Bootstrap MonthField class
20404 * @cfg {String} language default en
20407 * Create a new MonthField
20408 * @param {Object} config The config object
20411 Roo.bootstrap.MonthField = function(config){
20412 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20417 * Fires when this field show.
20418 * @param {Roo.bootstrap.MonthField} this
20419 * @param {Mixed} date The date value
20424 * Fires when this field hide.
20425 * @param {Roo.bootstrap.MonthField} this
20426 * @param {Mixed} date The date value
20431 * Fires when select a date.
20432 * @param {Roo.bootstrap.MonthField} this
20433 * @param {String} oldvalue The old value
20434 * @param {String} newvalue The new value
20440 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20442 onRender: function(ct, position)
20445 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20447 this.language = this.language || 'en';
20448 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20449 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20451 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20452 this.isInline = false;
20453 this.isInput = true;
20454 this.component = this.el.select('.add-on', true).first() || false;
20455 this.component = (this.component && this.component.length === 0) ? false : this.component;
20456 this.hasInput = this.component && this.inputEL().length;
20458 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20460 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20462 this.picker().on('mousedown', this.onMousedown, this);
20463 this.picker().on('click', this.onClick, this);
20465 this.picker().addClass('datepicker-dropdown');
20467 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20468 v.setStyle('width', '189px');
20475 if(this.isInline) {
20481 setValue: function(v, suppressEvent)
20483 var o = this.getValue();
20485 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20489 if(suppressEvent !== true){
20490 this.fireEvent('select', this, o, v);
20495 getValue: function()
20500 onClick: function(e)
20502 e.stopPropagation();
20503 e.preventDefault();
20505 var target = e.getTarget();
20507 if(target.nodeName.toLowerCase() === 'i'){
20508 target = Roo.get(target).dom.parentNode;
20511 var nodeName = target.nodeName;
20512 var className = target.className;
20513 var html = target.innerHTML;
20515 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20519 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20521 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20527 picker : function()
20529 return this.pickerEl;
20532 fillMonths: function()
20535 var months = this.picker().select('>.datepicker-months td', true).first();
20537 months.dom.innerHTML = '';
20543 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20546 months.createChild(month);
20555 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20556 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20559 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20560 e.removeClass('active');
20562 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20563 e.addClass('active');
20570 if(this.isInline) {
20574 this.picker().removeClass(['bottom', 'top']);
20576 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20578 * place to the top of element!
20582 this.picker().addClass('top');
20583 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20588 this.picker().addClass('bottom');
20590 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20593 onFocus : function()
20595 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20599 onBlur : function()
20601 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20603 var d = this.inputEl().getValue();
20612 this.picker().show();
20613 this.picker().select('>.datepicker-months', true).first().show();
20617 this.fireEvent('show', this, this.date);
20622 if(this.isInline) {
20625 this.picker().hide();
20626 this.fireEvent('hide', this, this.date);
20630 onMousedown: function(e)
20632 e.stopPropagation();
20633 e.preventDefault();
20638 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20642 fireKey: function(e)
20644 if (!this.picker().isVisible()){
20645 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20656 e.preventDefault();
20660 dir = e.keyCode == 37 ? -1 : 1;
20662 this.vIndex = this.vIndex + dir;
20664 if(this.vIndex < 0){
20668 if(this.vIndex > 11){
20672 if(isNaN(this.vIndex)){
20676 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20682 dir = e.keyCode == 38 ? -1 : 1;
20684 this.vIndex = this.vIndex + dir * 4;
20686 if(this.vIndex < 0){
20690 if(this.vIndex > 11){
20694 if(isNaN(this.vIndex)){
20698 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20703 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20704 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20708 e.preventDefault();
20711 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20712 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20728 this.picker().remove();
20733 Roo.apply(Roo.bootstrap.MonthField, {
20752 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20753 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20758 Roo.apply(Roo.bootstrap.MonthField, {
20762 cls: 'datepicker dropdown-menu roo-dynamic',
20766 cls: 'datepicker-months',
20770 cls: 'table-condensed',
20772 Roo.bootstrap.DateField.content
20792 * @class Roo.bootstrap.CheckBox
20793 * @extends Roo.bootstrap.Input
20794 * Bootstrap CheckBox class
20796 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20797 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20798 * @cfg {String} boxLabel The text that appears beside the checkbox
20799 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20800 * @cfg {Boolean} checked initnal the element
20801 * @cfg {Boolean} inline inline the element (default false)
20802 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20803 * @cfg {String} tooltip label tooltip
20806 * Create a new CheckBox
20807 * @param {Object} config The config object
20810 Roo.bootstrap.CheckBox = function(config){
20811 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20816 * Fires when the element is checked or unchecked.
20817 * @param {Roo.bootstrap.CheckBox} this This input
20818 * @param {Boolean} checked The new checked value
20823 * Fires when the element is click.
20824 * @param {Roo.bootstrap.CheckBox} this This input
20831 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20833 inputType: 'checkbox',
20842 getAutoCreate : function()
20844 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20850 cfg.cls = 'form-group ' + this.inputType; //input-group
20853 cfg.cls += ' ' + this.inputType + '-inline';
20859 type : this.inputType,
20860 value : this.inputValue,
20861 cls : 'roo-' + this.inputType, //'form-box',
20862 placeholder : this.placeholder || ''
20866 if(this.inputType != 'radio'){
20870 cls : 'roo-hidden-value',
20871 value : this.checked ? this.inputValue : this.valueOff
20876 if (this.weight) { // Validity check?
20877 cfg.cls += " " + this.inputType + "-" + this.weight;
20880 if (this.disabled) {
20881 input.disabled=true;
20885 input.checked = this.checked;
20890 input.name = this.name;
20892 if(this.inputType != 'radio'){
20893 hidden.name = this.name;
20894 input.name = '_hidden_' + this.name;
20899 input.cls += ' input-' + this.size;
20904 ['xs','sm','md','lg'].map(function(size){
20905 if (settings[size]) {
20906 cfg.cls += ' col-' + size + '-' + settings[size];
20910 var inputblock = input;
20912 if (this.before || this.after) {
20915 cls : 'input-group',
20920 inputblock.cn.push({
20922 cls : 'input-group-addon',
20927 inputblock.cn.push(input);
20929 if(this.inputType != 'radio'){
20930 inputblock.cn.push(hidden);
20934 inputblock.cn.push({
20936 cls : 'input-group-addon',
20943 if (align ==='left' && this.fieldLabel.length) {
20944 // Roo.log("left and has label");
20949 cls : 'control-label',
20950 html : this.fieldLabel
20960 if(this.labelWidth > 12){
20961 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20964 if(this.labelWidth < 13 && this.labelmd == 0){
20965 this.labelmd = this.labelWidth;
20968 if(this.labellg > 0){
20969 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20970 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20973 if(this.labelmd > 0){
20974 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20975 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20978 if(this.labelsm > 0){
20979 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20980 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20983 if(this.labelxs > 0){
20984 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20985 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20988 } else if ( this.fieldLabel.length) {
20989 // Roo.log(" label");
20993 tag: this.boxLabel ? 'span' : 'label',
20995 cls: 'control-label box-input-label',
20996 //cls : 'input-group-addon',
20997 html : this.fieldLabel
21006 // Roo.log(" no label && no align");
21007 cfg.cn = [ inputblock ] ;
21013 var boxLabelCfg = {
21015 //'for': id, // box label is handled by onclick - so no for...
21017 html: this.boxLabel
21021 boxLabelCfg.tooltip = this.tooltip;
21024 cfg.cn.push(boxLabelCfg);
21027 if(this.inputType != 'radio'){
21028 cfg.cn.push(hidden);
21036 * return the real input element.
21038 inputEl: function ()
21040 return this.el.select('input.roo-' + this.inputType,true).first();
21042 hiddenEl: function ()
21044 return this.el.select('input.roo-hidden-value',true).first();
21047 labelEl: function()
21049 return this.el.select('label.control-label',true).first();
21051 /* depricated... */
21055 return this.labelEl();
21058 boxLabelEl: function()
21060 return this.el.select('label.box-label',true).first();
21063 initEvents : function()
21065 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21067 this.inputEl().on('click', this.onClick, this);
21069 if (this.boxLabel) {
21070 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21073 this.startValue = this.getValue();
21076 Roo.bootstrap.CheckBox.register(this);
21080 onClick : function(e)
21082 if(this.fireEvent('click', this, e) !== false){
21083 this.setChecked(!this.checked);
21088 setChecked : function(state,suppressEvent)
21090 this.startValue = this.getValue();
21092 if(this.inputType == 'radio'){
21094 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21095 e.dom.checked = false;
21098 this.inputEl().dom.checked = true;
21100 this.inputEl().dom.value = this.inputValue;
21102 if(suppressEvent !== true){
21103 this.fireEvent('check', this, true);
21111 this.checked = state;
21113 this.inputEl().dom.checked = state;
21116 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21118 if(suppressEvent !== true){
21119 this.fireEvent('check', this, state);
21125 getValue : function()
21127 if(this.inputType == 'radio'){
21128 return this.getGroupValue();
21131 return this.hiddenEl().dom.value;
21135 getGroupValue : function()
21137 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21141 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21144 setValue : function(v,suppressEvent)
21146 if(this.inputType == 'radio'){
21147 this.setGroupValue(v, suppressEvent);
21151 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21156 setGroupValue : function(v, suppressEvent)
21158 this.startValue = this.getValue();
21160 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21161 e.dom.checked = false;
21163 if(e.dom.value == v){
21164 e.dom.checked = true;
21168 if(suppressEvent !== true){
21169 this.fireEvent('check', this, true);
21177 validate : function()
21179 if(this.getVisibilityEl().hasClass('hidden')){
21185 (this.inputType == 'radio' && this.validateRadio()) ||
21186 (this.inputType == 'checkbox' && this.validateCheckbox())
21192 this.markInvalid();
21196 validateRadio : function()
21198 if(this.getVisibilityEl().hasClass('hidden')){
21202 if(this.allowBlank){
21208 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21209 if(!e.dom.checked){
21221 validateCheckbox : function()
21224 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21225 //return (this.getValue() == this.inputValue) ? true : false;
21228 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21236 for(var i in group){
21237 if(group[i].el.isVisible(true)){
21245 for(var i in group){
21250 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21257 * Mark this field as valid
21259 markValid : function()
21263 this.fireEvent('valid', this);
21265 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21268 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21275 if(this.inputType == 'radio'){
21276 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21277 var fg = e.findParent('.form-group', false, true);
21278 if (Roo.bootstrap.version == 3) {
21279 fg.removeClass([_this.invalidClass, _this.validClass]);
21280 fg.addClass(_this.validClass);
21282 fg.removeClass(['is-valid', 'is-invalid']);
21283 fg.addClass('is-valid');
21291 var fg = this.el.findParent('.form-group', false, true);
21292 if (Roo.bootstrap.version == 3) {
21293 fg.removeClass([this.invalidClass, this.validClass]);
21294 fg.addClass(this.validClass);
21296 fg.removeClass(['is-valid', 'is-invalid']);
21297 fg.addClass('is-valid');
21302 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21308 for(var i in group){
21309 var fg = group[i].el.findParent('.form-group', false, true);
21310 if (Roo.bootstrap.version == 3) {
21311 fg.removeClass([this.invalidClass, this.validClass]);
21312 fg.addClass(this.validClass);
21314 fg.removeClass(['is-valid', 'is-invalid']);
21315 fg.addClass('is-valid');
21321 * Mark this field as invalid
21322 * @param {String} msg The validation message
21324 markInvalid : function(msg)
21326 if(this.allowBlank){
21332 this.fireEvent('invalid', this, msg);
21334 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21337 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21341 label.markInvalid();
21344 if(this.inputType == 'radio'){
21346 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21347 var fg = e.findParent('.form-group', false, true);
21348 if (Roo.bootstrap.version == 3) {
21349 fg.removeClass([_this.invalidClass, _this.validClass]);
21350 fg.addClass(_this.invalidClass);
21352 fg.removeClass(['is-invalid', 'is-valid']);
21353 fg.addClass('is-invalid');
21361 var fg = this.el.findParent('.form-group', false, true);
21362 if (Roo.bootstrap.version == 3) {
21363 fg.removeClass([_this.invalidClass, _this.validClass]);
21364 fg.addClass(_this.invalidClass);
21366 fg.removeClass(['is-invalid', 'is-valid']);
21367 fg.addClass('is-invalid');
21372 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21378 for(var i in group){
21379 var fg = group[i].el.findParent('.form-group', false, true);
21380 if (Roo.bootstrap.version == 3) {
21381 fg.removeClass([_this.invalidClass, _this.validClass]);
21382 fg.addClass(_this.invalidClass);
21384 fg.removeClass(['is-invalid', 'is-valid']);
21385 fg.addClass('is-invalid');
21391 clearInvalid : function()
21393 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21395 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21397 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21399 if (label && label.iconEl) {
21400 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21401 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21405 disable : function()
21407 if(this.inputType != 'radio'){
21408 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21415 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21416 _this.getActionEl().addClass(this.disabledClass);
21417 e.dom.disabled = true;
21421 this.disabled = true;
21422 this.fireEvent("disable", this);
21426 enable : function()
21428 if(this.inputType != 'radio'){
21429 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21436 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21437 _this.getActionEl().removeClass(this.disabledClass);
21438 e.dom.disabled = false;
21442 this.disabled = false;
21443 this.fireEvent("enable", this);
21447 setBoxLabel : function(v)
21452 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21458 Roo.apply(Roo.bootstrap.CheckBox, {
21463 * register a CheckBox Group
21464 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21466 register : function(checkbox)
21468 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21469 this.groups[checkbox.groupId] = {};
21472 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21476 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21480 * fetch a CheckBox Group based on the group ID
21481 * @param {string} the group ID
21482 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21484 get: function(groupId) {
21485 if (typeof(this.groups[groupId]) == 'undefined') {
21489 return this.groups[groupId] ;
21502 * @class Roo.bootstrap.Radio
21503 * @extends Roo.bootstrap.Component
21504 * Bootstrap Radio class
21505 * @cfg {String} boxLabel - the label associated
21506 * @cfg {String} value - the value of radio
21509 * Create a new Radio
21510 * @param {Object} config The config object
21512 Roo.bootstrap.Radio = function(config){
21513 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21517 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21523 getAutoCreate : function()
21527 cls : 'form-group radio',
21532 html : this.boxLabel
21540 initEvents : function()
21542 this.parent().register(this);
21544 this.el.on('click', this.onClick, this);
21548 onClick : function(e)
21550 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21551 this.setChecked(true);
21555 setChecked : function(state, suppressEvent)
21557 this.parent().setValue(this.value, suppressEvent);
21561 setBoxLabel : function(v)
21566 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21581 * @class Roo.bootstrap.SecurePass
21582 * @extends Roo.bootstrap.Input
21583 * Bootstrap SecurePass class
21587 * Create a new SecurePass
21588 * @param {Object} config The config object
21591 Roo.bootstrap.SecurePass = function (config) {
21592 // these go here, so the translation tool can replace them..
21594 PwdEmpty: "Please type a password, and then retype it to confirm.",
21595 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21596 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21597 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21598 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21599 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21600 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21601 TooWeak: "Your password is Too Weak."
21603 this.meterLabel = "Password strength:";
21604 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21605 this.meterClass = [
21606 "roo-password-meter-tooweak",
21607 "roo-password-meter-weak",
21608 "roo-password-meter-medium",
21609 "roo-password-meter-strong",
21610 "roo-password-meter-grey"
21615 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21618 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21620 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21622 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21623 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21624 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21625 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21626 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21627 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21628 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21638 * @cfg {String/Object} Label for the strength meter (defaults to
21639 * 'Password strength:')
21644 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21645 * ['Weak', 'Medium', 'Strong'])
21648 pwdStrengths: false,
21661 initEvents: function ()
21663 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21665 if (this.el.is('input[type=password]') && Roo.isSafari) {
21666 this.el.on('keydown', this.SafariOnKeyDown, this);
21669 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21672 onRender: function (ct, position)
21674 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21675 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21676 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21678 this.trigger.createChild({
21683 cls: 'roo-password-meter-grey col-xs-12',
21686 //width: this.meterWidth + 'px'
21690 cls: 'roo-password-meter-text'
21696 if (this.hideTrigger) {
21697 this.trigger.setDisplayed(false);
21699 this.setSize(this.width || '', this.height || '');
21702 onDestroy: function ()
21704 if (this.trigger) {
21705 this.trigger.removeAllListeners();
21706 this.trigger.remove();
21709 this.wrap.remove();
21711 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21714 checkStrength: function ()
21716 var pwd = this.inputEl().getValue();
21717 if (pwd == this._lastPwd) {
21722 if (this.ClientSideStrongPassword(pwd)) {
21724 } else if (this.ClientSideMediumPassword(pwd)) {
21726 } else if (this.ClientSideWeakPassword(pwd)) {
21732 Roo.log('strength1: ' + strength);
21734 //var pm = this.trigger.child('div/div/div').dom;
21735 var pm = this.trigger.child('div/div');
21736 pm.removeClass(this.meterClass);
21737 pm.addClass(this.meterClass[strength]);
21740 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21742 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21744 this._lastPwd = pwd;
21748 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21750 this._lastPwd = '';
21752 var pm = this.trigger.child('div/div');
21753 pm.removeClass(this.meterClass);
21754 pm.addClass('roo-password-meter-grey');
21757 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21760 this.inputEl().dom.type='password';
21763 validateValue: function (value)
21766 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21769 if (value.length == 0) {
21770 if (this.allowBlank) {
21771 this.clearInvalid();
21775 this.markInvalid(this.errors.PwdEmpty);
21776 this.errorMsg = this.errors.PwdEmpty;
21784 if ('[\x21-\x7e]*'.match(value)) {
21785 this.markInvalid(this.errors.PwdBadChar);
21786 this.errorMsg = this.errors.PwdBadChar;
21789 if (value.length < 6) {
21790 this.markInvalid(this.errors.PwdShort);
21791 this.errorMsg = this.errors.PwdShort;
21794 if (value.length > 16) {
21795 this.markInvalid(this.errors.PwdLong);
21796 this.errorMsg = this.errors.PwdLong;
21800 if (this.ClientSideStrongPassword(value)) {
21802 } else if (this.ClientSideMediumPassword(value)) {
21804 } else if (this.ClientSideWeakPassword(value)) {
21811 if (strength < 2) {
21812 //this.markInvalid(this.errors.TooWeak);
21813 this.errorMsg = this.errors.TooWeak;
21818 console.log('strength2: ' + strength);
21820 //var pm = this.trigger.child('div/div/div').dom;
21822 var pm = this.trigger.child('div/div');
21823 pm.removeClass(this.meterClass);
21824 pm.addClass(this.meterClass[strength]);
21826 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21828 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21830 this.errorMsg = '';
21834 CharacterSetChecks: function (type)
21837 this.fResult = false;
21840 isctype: function (character, type)
21843 case this.kCapitalLetter:
21844 if (character >= 'A' && character <= 'Z') {
21849 case this.kSmallLetter:
21850 if (character >= 'a' && character <= 'z') {
21856 if (character >= '0' && character <= '9') {
21861 case this.kPunctuation:
21862 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21873 IsLongEnough: function (pwd, size)
21875 return !(pwd == null || isNaN(size) || pwd.length < size);
21878 SpansEnoughCharacterSets: function (word, nb)
21880 if (!this.IsLongEnough(word, nb))
21885 var characterSetChecks = new Array(
21886 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21887 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21890 for (var index = 0; index < word.length; ++index) {
21891 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21892 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21893 characterSetChecks[nCharSet].fResult = true;
21900 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21901 if (characterSetChecks[nCharSet].fResult) {
21906 if (nCharSets < nb) {
21912 ClientSideStrongPassword: function (pwd)
21914 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21917 ClientSideMediumPassword: function (pwd)
21919 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21922 ClientSideWeakPassword: function (pwd)
21924 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21927 })//<script type="text/javascript">
21930 * Based Ext JS Library 1.1.1
21931 * Copyright(c) 2006-2007, Ext JS, LLC.
21937 * @class Roo.HtmlEditorCore
21938 * @extends Roo.Component
21939 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21941 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21944 Roo.HtmlEditorCore = function(config){
21947 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21952 * @event initialize
21953 * Fires when the editor is fully initialized (including the iframe)
21954 * @param {Roo.HtmlEditorCore} this
21959 * Fires when the editor is first receives the focus. Any insertion must wait
21960 * until after this event.
21961 * @param {Roo.HtmlEditorCore} this
21965 * @event beforesync
21966 * Fires before the textarea is updated with content from the editor iframe. Return false
21967 * to cancel the sync.
21968 * @param {Roo.HtmlEditorCore} this
21969 * @param {String} html
21973 * @event beforepush
21974 * Fires before the iframe editor is updated with content from the textarea. Return false
21975 * to cancel the push.
21976 * @param {Roo.HtmlEditorCore} this
21977 * @param {String} html
21982 * Fires when the textarea is updated with content from the editor iframe.
21983 * @param {Roo.HtmlEditorCore} this
21984 * @param {String} html
21989 * Fires when the iframe editor is updated with content from the textarea.
21990 * @param {Roo.HtmlEditorCore} this
21991 * @param {String} html
21996 * @event editorevent
21997 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21998 * @param {Roo.HtmlEditorCore} this
22004 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22006 // defaults : white / black...
22007 this.applyBlacklists();
22014 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22018 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22024 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22029 * @cfg {Number} height (in pixels)
22033 * @cfg {Number} width (in pixels)
22038 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22041 stylesheets: false,
22046 // private properties
22047 validationEvent : false,
22049 initialized : false,
22051 sourceEditMode : false,
22052 onFocus : Roo.emptyFn,
22054 hideMode:'offsets',
22058 // blacklist + whitelisted elements..
22065 * Protected method that will not generally be called directly. It
22066 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22067 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22069 getDocMarkup : function(){
22073 // inherit styels from page...??
22074 if (this.stylesheets === false) {
22076 Roo.get(document.head).select('style').each(function(node) {
22077 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22080 Roo.get(document.head).select('link').each(function(node) {
22081 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22084 } else if (!this.stylesheets.length) {
22086 st = '<style type="text/css">' +
22087 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22090 st = '<style type="text/css">' +
22095 st += '<style type="text/css">' +
22096 'IMG { cursor: pointer } ' +
22099 var cls = 'roo-htmleditor-body';
22101 if(this.bodyCls.length){
22102 cls += ' ' + this.bodyCls;
22105 return '<html><head>' + st +
22106 //<style type="text/css">' +
22107 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22109 ' </head><body class="' + cls + '"></body></html>';
22113 onRender : function(ct, position)
22116 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22117 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22120 this.el.dom.style.border = '0 none';
22121 this.el.dom.setAttribute('tabIndex', -1);
22122 this.el.addClass('x-hidden hide');
22126 if(Roo.isIE){ // fix IE 1px bogus margin
22127 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22131 this.frameId = Roo.id();
22135 var iframe = this.owner.wrap.createChild({
22137 cls: 'form-control', // bootstrap..
22139 name: this.frameId,
22140 frameBorder : 'no',
22141 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22146 this.iframe = iframe.dom;
22148 this.assignDocWin();
22150 this.doc.designMode = 'on';
22153 this.doc.write(this.getDocMarkup());
22157 var task = { // must defer to wait for browser to be ready
22159 //console.log("run task?" + this.doc.readyState);
22160 this.assignDocWin();
22161 if(this.doc.body || this.doc.readyState == 'complete'){
22163 this.doc.designMode="on";
22167 Roo.TaskMgr.stop(task);
22168 this.initEditor.defer(10, this);
22175 Roo.TaskMgr.start(task);
22180 onResize : function(w, h)
22182 Roo.log('resize: ' +w + ',' + h );
22183 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22187 if(typeof w == 'number'){
22189 this.iframe.style.width = w + 'px';
22191 if(typeof h == 'number'){
22193 this.iframe.style.height = h + 'px';
22195 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22202 * Toggles the editor between standard and source edit mode.
22203 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22205 toggleSourceEdit : function(sourceEditMode){
22207 this.sourceEditMode = sourceEditMode === true;
22209 if(this.sourceEditMode){
22211 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22214 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22215 //this.iframe.className = '';
22218 //this.setSize(this.owner.wrap.getSize());
22219 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22226 * Protected method that will not generally be called directly. If you need/want
22227 * custom HTML cleanup, this is the method you should override.
22228 * @param {String} html The HTML to be cleaned
22229 * return {String} The cleaned HTML
22231 cleanHtml : function(html){
22232 html = String(html);
22233 if(html.length > 5){
22234 if(Roo.isSafari){ // strip safari nonsense
22235 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22238 if(html == ' '){
22245 * HTML Editor -> Textarea
22246 * Protected method that will not generally be called directly. Syncs the contents
22247 * of the editor iframe with the textarea.
22249 syncValue : function(){
22250 if(this.initialized){
22251 var bd = (this.doc.body || this.doc.documentElement);
22252 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22253 var html = bd.innerHTML;
22255 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22256 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22258 html = '<div style="'+m[0]+'">' + html + '</div>';
22261 html = this.cleanHtml(html);
22262 // fix up the special chars.. normaly like back quotes in word...
22263 // however we do not want to do this with chinese..
22264 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22265 var cc = b.charCodeAt();
22267 (cc >= 0x4E00 && cc < 0xA000 ) ||
22268 (cc >= 0x3400 && cc < 0x4E00 ) ||
22269 (cc >= 0xf900 && cc < 0xfb00 )
22275 if(this.owner.fireEvent('beforesync', this, html) !== false){
22276 this.el.dom.value = html;
22277 this.owner.fireEvent('sync', this, html);
22283 * Protected method that will not generally be called directly. Pushes the value of the textarea
22284 * into the iframe editor.
22286 pushValue : function(){
22287 if(this.initialized){
22288 var v = this.el.dom.value.trim();
22290 // if(v.length < 1){
22294 if(this.owner.fireEvent('beforepush', this, v) !== false){
22295 var d = (this.doc.body || this.doc.documentElement);
22297 this.cleanUpPaste();
22298 this.el.dom.value = d.innerHTML;
22299 this.owner.fireEvent('push', this, v);
22305 deferFocus : function(){
22306 this.focus.defer(10, this);
22310 focus : function(){
22311 if(this.win && !this.sourceEditMode){
22318 assignDocWin: function()
22320 var iframe = this.iframe;
22323 this.doc = iframe.contentWindow.document;
22324 this.win = iframe.contentWindow;
22326 // if (!Roo.get(this.frameId)) {
22329 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22330 // this.win = Roo.get(this.frameId).dom.contentWindow;
22332 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22336 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22337 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22342 initEditor : function(){
22343 //console.log("INIT EDITOR");
22344 this.assignDocWin();
22348 this.doc.designMode="on";
22350 this.doc.write(this.getDocMarkup());
22353 var dbody = (this.doc.body || this.doc.documentElement);
22354 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22355 // this copies styles from the containing element into thsi one..
22356 // not sure why we need all of this..
22357 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22359 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22360 //ss['background-attachment'] = 'fixed'; // w3c
22361 dbody.bgProperties = 'fixed'; // ie
22362 //Roo.DomHelper.applyStyles(dbody, ss);
22363 Roo.EventManager.on(this.doc, {
22364 //'mousedown': this.onEditorEvent,
22365 'mouseup': this.onEditorEvent,
22366 'dblclick': this.onEditorEvent,
22367 'click': this.onEditorEvent,
22368 'keyup': this.onEditorEvent,
22373 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22375 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22376 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22378 this.initialized = true;
22380 this.owner.fireEvent('initialize', this);
22385 onDestroy : function(){
22391 //for (var i =0; i < this.toolbars.length;i++) {
22392 // // fixme - ask toolbars for heights?
22393 // this.toolbars[i].onDestroy();
22396 //this.wrap.dom.innerHTML = '';
22397 //this.wrap.remove();
22402 onFirstFocus : function(){
22404 this.assignDocWin();
22407 this.activated = true;
22410 if(Roo.isGecko){ // prevent silly gecko errors
22412 var s = this.win.getSelection();
22413 if(!s.focusNode || s.focusNode.nodeType != 3){
22414 var r = s.getRangeAt(0);
22415 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22420 this.execCmd('useCSS', true);
22421 this.execCmd('styleWithCSS', false);
22424 this.owner.fireEvent('activate', this);
22428 adjustFont: function(btn){
22429 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22430 //if(Roo.isSafari){ // safari
22433 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22434 if(Roo.isSafari){ // safari
22435 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22436 v = (v < 10) ? 10 : v;
22437 v = (v > 48) ? 48 : v;
22438 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22443 v = Math.max(1, v+adjust);
22445 this.execCmd('FontSize', v );
22448 onEditorEvent : function(e)
22450 this.owner.fireEvent('editorevent', this, e);
22451 // this.updateToolbar();
22452 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22455 insertTag : function(tg)
22457 // could be a bit smarter... -> wrap the current selected tRoo..
22458 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22460 range = this.createRange(this.getSelection());
22461 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22462 wrappingNode.appendChild(range.extractContents());
22463 range.insertNode(wrappingNode);
22470 this.execCmd("formatblock", tg);
22474 insertText : function(txt)
22478 var range = this.createRange();
22479 range.deleteContents();
22480 //alert(Sender.getAttribute('label'));
22482 range.insertNode(this.doc.createTextNode(txt));
22488 * Executes a Midas editor command on the editor document and performs necessary focus and
22489 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22490 * @param {String} cmd The Midas command
22491 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22493 relayCmd : function(cmd, value){
22495 this.execCmd(cmd, value);
22496 this.owner.fireEvent('editorevent', this);
22497 //this.updateToolbar();
22498 this.owner.deferFocus();
22502 * Executes a Midas editor command directly on the editor document.
22503 * For visual commands, you should use {@link #relayCmd} instead.
22504 * <b>This should only be called after the editor is initialized.</b>
22505 * @param {String} cmd The Midas command
22506 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22508 execCmd : function(cmd, value){
22509 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22516 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22518 * @param {String} text | dom node..
22520 insertAtCursor : function(text)
22523 if(!this.activated){
22529 var r = this.doc.selection.createRange();
22540 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22544 // from jquery ui (MIT licenced)
22546 var win = this.win;
22548 if (win.getSelection && win.getSelection().getRangeAt) {
22549 range = win.getSelection().getRangeAt(0);
22550 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22551 range.insertNode(node);
22552 } else if (win.document.selection && win.document.selection.createRange) {
22553 // no firefox support
22554 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22555 win.document.selection.createRange().pasteHTML(txt);
22557 // no firefox support
22558 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22559 this.execCmd('InsertHTML', txt);
22568 mozKeyPress : function(e){
22570 var c = e.getCharCode(), cmd;
22573 c = String.fromCharCode(c).toLowerCase();
22587 this.cleanUpPaste.defer(100, this);
22595 e.preventDefault();
22603 fixKeys : function(){ // load time branching for fastest keydown performance
22605 return function(e){
22606 var k = e.getKey(), r;
22609 r = this.doc.selection.createRange();
22612 r.pasteHTML('    ');
22619 r = this.doc.selection.createRange();
22621 var target = r.parentElement();
22622 if(!target || target.tagName.toLowerCase() != 'li'){
22624 r.pasteHTML('<br />');
22630 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22631 this.cleanUpPaste.defer(100, this);
22637 }else if(Roo.isOpera){
22638 return function(e){
22639 var k = e.getKey();
22643 this.execCmd('InsertHTML','    ');
22646 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22647 this.cleanUpPaste.defer(100, this);
22652 }else if(Roo.isSafari){
22653 return function(e){
22654 var k = e.getKey();
22658 this.execCmd('InsertText','\t');
22662 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22663 this.cleanUpPaste.defer(100, this);
22671 getAllAncestors: function()
22673 var p = this.getSelectedNode();
22676 a.push(p); // push blank onto stack..
22677 p = this.getParentElement();
22681 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22685 a.push(this.doc.body);
22689 lastSelNode : false,
22692 getSelection : function()
22694 this.assignDocWin();
22695 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22698 getSelectedNode: function()
22700 // this may only work on Gecko!!!
22702 // should we cache this!!!!
22707 var range = this.createRange(this.getSelection()).cloneRange();
22710 var parent = range.parentElement();
22712 var testRange = range.duplicate();
22713 testRange.moveToElementText(parent);
22714 if (testRange.inRange(range)) {
22717 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22720 parent = parent.parentElement;
22725 // is ancestor a text element.
22726 var ac = range.commonAncestorContainer;
22727 if (ac.nodeType == 3) {
22728 ac = ac.parentNode;
22731 var ar = ac.childNodes;
22734 var other_nodes = [];
22735 var has_other_nodes = false;
22736 for (var i=0;i<ar.length;i++) {
22737 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22740 // fullly contained node.
22742 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22747 // probably selected..
22748 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22749 other_nodes.push(ar[i]);
22753 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22758 has_other_nodes = true;
22760 if (!nodes.length && other_nodes.length) {
22761 nodes= other_nodes;
22763 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22769 createRange: function(sel)
22771 // this has strange effects when using with
22772 // top toolbar - not sure if it's a great idea.
22773 //this.editor.contentWindow.focus();
22774 if (typeof sel != "undefined") {
22776 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22778 return this.doc.createRange();
22781 return this.doc.createRange();
22784 getParentElement: function()
22787 this.assignDocWin();
22788 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22790 var range = this.createRange(sel);
22793 var p = range.commonAncestorContainer;
22794 while (p.nodeType == 3) { // text node
22805 * Range intersection.. the hard stuff...
22809 * [ -- selected range --- ]
22813 * if end is before start or hits it. fail.
22814 * if start is after end or hits it fail.
22816 * if either hits (but other is outside. - then it's not
22822 // @see http://www.thismuchiknow.co.uk/?p=64.
22823 rangeIntersectsNode : function(range, node)
22825 var nodeRange = node.ownerDocument.createRange();
22827 nodeRange.selectNode(node);
22829 nodeRange.selectNodeContents(node);
22832 var rangeStartRange = range.cloneRange();
22833 rangeStartRange.collapse(true);
22835 var rangeEndRange = range.cloneRange();
22836 rangeEndRange.collapse(false);
22838 var nodeStartRange = nodeRange.cloneRange();
22839 nodeStartRange.collapse(true);
22841 var nodeEndRange = nodeRange.cloneRange();
22842 nodeEndRange.collapse(false);
22844 return rangeStartRange.compareBoundaryPoints(
22845 Range.START_TO_START, nodeEndRange) == -1 &&
22846 rangeEndRange.compareBoundaryPoints(
22847 Range.START_TO_START, nodeStartRange) == 1;
22851 rangeCompareNode : function(range, node)
22853 var nodeRange = node.ownerDocument.createRange();
22855 nodeRange.selectNode(node);
22857 nodeRange.selectNodeContents(node);
22861 range.collapse(true);
22863 nodeRange.collapse(true);
22865 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22866 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22868 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22870 var nodeIsBefore = ss == 1;
22871 var nodeIsAfter = ee == -1;
22873 if (nodeIsBefore && nodeIsAfter) {
22876 if (!nodeIsBefore && nodeIsAfter) {
22877 return 1; //right trailed.
22880 if (nodeIsBefore && !nodeIsAfter) {
22881 return 2; // left trailed.
22887 // private? - in a new class?
22888 cleanUpPaste : function()
22890 // cleans up the whole document..
22891 Roo.log('cleanuppaste');
22893 this.cleanUpChildren(this.doc.body);
22894 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22895 if (clean != this.doc.body.innerHTML) {
22896 this.doc.body.innerHTML = clean;
22901 cleanWordChars : function(input) {// change the chars to hex code
22902 var he = Roo.HtmlEditorCore;
22904 var output = input;
22905 Roo.each(he.swapCodes, function(sw) {
22906 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22908 output = output.replace(swapper, sw[1]);
22915 cleanUpChildren : function (n)
22917 if (!n.childNodes.length) {
22920 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22921 this.cleanUpChild(n.childNodes[i]);
22928 cleanUpChild : function (node)
22931 //console.log(node);
22932 if (node.nodeName == "#text") {
22933 // clean up silly Windows -- stuff?
22936 if (node.nodeName == "#comment") {
22937 node.parentNode.removeChild(node);
22938 // clean up silly Windows -- stuff?
22941 var lcname = node.tagName.toLowerCase();
22942 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22943 // whitelist of tags..
22945 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22947 node.parentNode.removeChild(node);
22952 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22954 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22955 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22957 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22958 // remove_keep_children = true;
22961 if (remove_keep_children) {
22962 this.cleanUpChildren(node);
22963 // inserts everything just before this node...
22964 while (node.childNodes.length) {
22965 var cn = node.childNodes[0];
22966 node.removeChild(cn);
22967 node.parentNode.insertBefore(cn, node);
22969 node.parentNode.removeChild(node);
22973 if (!node.attributes || !node.attributes.length) {
22974 this.cleanUpChildren(node);
22978 function cleanAttr(n,v)
22981 if (v.match(/^\./) || v.match(/^\//)) {
22984 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22987 if (v.match(/^#/)) {
22990 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22991 node.removeAttribute(n);
22995 var cwhite = this.cwhite;
22996 var cblack = this.cblack;
22998 function cleanStyle(n,v)
23000 if (v.match(/expression/)) { //XSS?? should we even bother..
23001 node.removeAttribute(n);
23005 var parts = v.split(/;/);
23008 Roo.each(parts, function(p) {
23009 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23013 var l = p.split(':').shift().replace(/\s+/g,'');
23014 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23016 if ( cwhite.length && cblack.indexOf(l) > -1) {
23017 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23018 //node.removeAttribute(n);
23022 // only allow 'c whitelisted system attributes'
23023 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23024 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23025 //node.removeAttribute(n);
23035 if (clean.length) {
23036 node.setAttribute(n, clean.join(';'));
23038 node.removeAttribute(n);
23044 for (var i = node.attributes.length-1; i > -1 ; i--) {
23045 var a = node.attributes[i];
23048 if (a.name.toLowerCase().substr(0,2)=='on') {
23049 node.removeAttribute(a.name);
23052 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23053 node.removeAttribute(a.name);
23056 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23057 cleanAttr(a.name,a.value); // fixme..
23060 if (a.name == 'style') {
23061 cleanStyle(a.name,a.value);
23064 /// clean up MS crap..
23065 // tecnically this should be a list of valid class'es..
23068 if (a.name == 'class') {
23069 if (a.value.match(/^Mso/)) {
23070 node.className = '';
23073 if (a.value.match(/^body$/)) {
23074 node.className = '';
23085 this.cleanUpChildren(node);
23091 * Clean up MS wordisms...
23093 cleanWord : function(node)
23098 this.cleanWord(this.doc.body);
23101 if (node.nodeName == "#text") {
23102 // clean up silly Windows -- stuff?
23105 if (node.nodeName == "#comment") {
23106 node.parentNode.removeChild(node);
23107 // clean up silly Windows -- stuff?
23111 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23112 node.parentNode.removeChild(node);
23116 // remove - but keep children..
23117 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23118 while (node.childNodes.length) {
23119 var cn = node.childNodes[0];
23120 node.removeChild(cn);
23121 node.parentNode.insertBefore(cn, node);
23123 node.parentNode.removeChild(node);
23124 this.iterateChildren(node, this.cleanWord);
23128 if (node.className.length) {
23130 var cn = node.className.split(/\W+/);
23132 Roo.each(cn, function(cls) {
23133 if (cls.match(/Mso[a-zA-Z]+/)) {
23138 node.className = cna.length ? cna.join(' ') : '';
23140 node.removeAttribute("class");
23144 if (node.hasAttribute("lang")) {
23145 node.removeAttribute("lang");
23148 if (node.hasAttribute("style")) {
23150 var styles = node.getAttribute("style").split(";");
23152 Roo.each(styles, function(s) {
23153 if (!s.match(/:/)) {
23156 var kv = s.split(":");
23157 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23160 // what ever is left... we allow.
23163 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23164 if (!nstyle.length) {
23165 node.removeAttribute('style');
23168 this.iterateChildren(node, this.cleanWord);
23174 * iterateChildren of a Node, calling fn each time, using this as the scole..
23175 * @param {DomNode} node node to iterate children of.
23176 * @param {Function} fn method of this class to call on each item.
23178 iterateChildren : function(node, fn)
23180 if (!node.childNodes.length) {
23183 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23184 fn.call(this, node.childNodes[i])
23190 * cleanTableWidths.
23192 * Quite often pasting from word etc.. results in tables with column and widths.
23193 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23196 cleanTableWidths : function(node)
23201 this.cleanTableWidths(this.doc.body);
23206 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23209 Roo.log(node.tagName);
23210 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23211 this.iterateChildren(node, this.cleanTableWidths);
23214 if (node.hasAttribute('width')) {
23215 node.removeAttribute('width');
23219 if (node.hasAttribute("style")) {
23222 var styles = node.getAttribute("style").split(";");
23224 Roo.each(styles, function(s) {
23225 if (!s.match(/:/)) {
23228 var kv = s.split(":");
23229 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23232 // what ever is left... we allow.
23235 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23236 if (!nstyle.length) {
23237 node.removeAttribute('style');
23241 this.iterateChildren(node, this.cleanTableWidths);
23249 domToHTML : function(currentElement, depth, nopadtext) {
23251 depth = depth || 0;
23252 nopadtext = nopadtext || false;
23254 if (!currentElement) {
23255 return this.domToHTML(this.doc.body);
23258 //Roo.log(currentElement);
23260 var allText = false;
23261 var nodeName = currentElement.nodeName;
23262 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23264 if (nodeName == '#text') {
23266 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23271 if (nodeName != 'BODY') {
23274 // Prints the node tagName, such as <A>, <IMG>, etc
23277 for(i = 0; i < currentElement.attributes.length;i++) {
23279 var aname = currentElement.attributes.item(i).name;
23280 if (!currentElement.attributes.item(i).value.length) {
23283 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23286 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23295 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23298 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23303 // Traverse the tree
23305 var currentElementChild = currentElement.childNodes.item(i);
23306 var allText = true;
23307 var innerHTML = '';
23309 while (currentElementChild) {
23310 // Formatting code (indent the tree so it looks nice on the screen)
23311 var nopad = nopadtext;
23312 if (lastnode == 'SPAN') {
23316 if (currentElementChild.nodeName == '#text') {
23317 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23318 toadd = nopadtext ? toadd : toadd.trim();
23319 if (!nopad && toadd.length > 80) {
23320 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23322 innerHTML += toadd;
23325 currentElementChild = currentElement.childNodes.item(i);
23331 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23333 // Recursively traverse the tree structure of the child node
23334 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23335 lastnode = currentElementChild.nodeName;
23337 currentElementChild=currentElement.childNodes.item(i);
23343 // The remaining code is mostly for formatting the tree
23344 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23349 ret+= "</"+tagName+">";
23355 applyBlacklists : function()
23357 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23358 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23362 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23363 if (b.indexOf(tag) > -1) {
23366 this.white.push(tag);
23370 Roo.each(w, function(tag) {
23371 if (b.indexOf(tag) > -1) {
23374 if (this.white.indexOf(tag) > -1) {
23377 this.white.push(tag);
23382 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23383 if (w.indexOf(tag) > -1) {
23386 this.black.push(tag);
23390 Roo.each(b, function(tag) {
23391 if (w.indexOf(tag) > -1) {
23394 if (this.black.indexOf(tag) > -1) {
23397 this.black.push(tag);
23402 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23403 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23407 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23408 if (b.indexOf(tag) > -1) {
23411 this.cwhite.push(tag);
23415 Roo.each(w, function(tag) {
23416 if (b.indexOf(tag) > -1) {
23419 if (this.cwhite.indexOf(tag) > -1) {
23422 this.cwhite.push(tag);
23427 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23428 if (w.indexOf(tag) > -1) {
23431 this.cblack.push(tag);
23435 Roo.each(b, function(tag) {
23436 if (w.indexOf(tag) > -1) {
23439 if (this.cblack.indexOf(tag) > -1) {
23442 this.cblack.push(tag);
23447 setStylesheets : function(stylesheets)
23449 if(typeof(stylesheets) == 'string'){
23450 Roo.get(this.iframe.contentDocument.head).createChild({
23452 rel : 'stylesheet',
23461 Roo.each(stylesheets, function(s) {
23466 Roo.get(_this.iframe.contentDocument.head).createChild({
23468 rel : 'stylesheet',
23477 removeStylesheets : function()
23481 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23486 setStyle : function(style)
23488 Roo.get(this.iframe.contentDocument.head).createChild({
23497 // hide stuff that is not compatible
23511 * @event specialkey
23515 * @cfg {String} fieldClass @hide
23518 * @cfg {String} focusClass @hide
23521 * @cfg {String} autoCreate @hide
23524 * @cfg {String} inputType @hide
23527 * @cfg {String} invalidClass @hide
23530 * @cfg {String} invalidText @hide
23533 * @cfg {String} msgFx @hide
23536 * @cfg {String} validateOnBlur @hide
23540 Roo.HtmlEditorCore.white = [
23541 'area', 'br', 'img', 'input', 'hr', 'wbr',
23543 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23544 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23545 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23546 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23547 'table', 'ul', 'xmp',
23549 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23552 'dir', 'menu', 'ol', 'ul', 'dl',
23558 Roo.HtmlEditorCore.black = [
23559 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23561 'base', 'basefont', 'bgsound', 'blink', 'body',
23562 'frame', 'frameset', 'head', 'html', 'ilayer',
23563 'iframe', 'layer', 'link', 'meta', 'object',
23564 'script', 'style' ,'title', 'xml' // clean later..
23566 Roo.HtmlEditorCore.clean = [
23567 'script', 'style', 'title', 'xml'
23569 Roo.HtmlEditorCore.remove = [
23574 Roo.HtmlEditorCore.ablack = [
23578 Roo.HtmlEditorCore.aclean = [
23579 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23583 Roo.HtmlEditorCore.pwhite= [
23584 'http', 'https', 'mailto'
23587 // white listed style attributes.
23588 Roo.HtmlEditorCore.cwhite= [
23589 // 'text-align', /// default is to allow most things..
23595 // black listed style attributes.
23596 Roo.HtmlEditorCore.cblack= [
23597 // 'font-size' -- this can be set by the project
23601 Roo.HtmlEditorCore.swapCodes =[
23620 * @class Roo.bootstrap.HtmlEditor
23621 * @extends Roo.bootstrap.TextArea
23622 * Bootstrap HtmlEditor class
23625 * Create a new HtmlEditor
23626 * @param {Object} config The config object
23629 Roo.bootstrap.HtmlEditor = function(config){
23630 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23631 if (!this.toolbars) {
23632 this.toolbars = [];
23635 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23638 * @event initialize
23639 * Fires when the editor is fully initialized (including the iframe)
23640 * @param {HtmlEditor} this
23645 * Fires when the editor is first receives the focus. Any insertion must wait
23646 * until after this event.
23647 * @param {HtmlEditor} this
23651 * @event beforesync
23652 * Fires before the textarea is updated with content from the editor iframe. Return false
23653 * to cancel the sync.
23654 * @param {HtmlEditor} this
23655 * @param {String} html
23659 * @event beforepush
23660 * Fires before the iframe editor is updated with content from the textarea. Return false
23661 * to cancel the push.
23662 * @param {HtmlEditor} this
23663 * @param {String} html
23668 * Fires when the textarea is updated with content from the editor iframe.
23669 * @param {HtmlEditor} this
23670 * @param {String} html
23675 * Fires when the iframe editor is updated with content from the textarea.
23676 * @param {HtmlEditor} this
23677 * @param {String} html
23681 * @event editmodechange
23682 * Fires when the editor switches edit modes
23683 * @param {HtmlEditor} this
23684 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23686 editmodechange: true,
23688 * @event editorevent
23689 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23690 * @param {HtmlEditor} this
23694 * @event firstfocus
23695 * Fires when on first focus - needed by toolbars..
23696 * @param {HtmlEditor} this
23701 * Auto save the htmlEditor value as a file into Events
23702 * @param {HtmlEditor} this
23706 * @event savedpreview
23707 * preview the saved version of htmlEditor
23708 * @param {HtmlEditor} this
23715 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23719 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23724 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23729 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23734 * @cfg {Number} height (in pixels)
23738 * @cfg {Number} width (in pixels)
23743 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23746 stylesheets: false,
23751 // private properties
23752 validationEvent : false,
23754 initialized : false,
23757 onFocus : Roo.emptyFn,
23759 hideMode:'offsets',
23761 tbContainer : false,
23765 toolbarContainer :function() {
23766 return this.wrap.select('.x-html-editor-tb',true).first();
23770 * Protected method that will not generally be called directly. It
23771 * is called when the editor creates its toolbar. Override this method if you need to
23772 * add custom toolbar buttons.
23773 * @param {HtmlEditor} editor
23775 createToolbar : function(){
23776 Roo.log('renewing');
23777 Roo.log("create toolbars");
23779 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23780 this.toolbars[0].render(this.toolbarContainer());
23784 // if (!editor.toolbars || !editor.toolbars.length) {
23785 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23788 // for (var i =0 ; i < editor.toolbars.length;i++) {
23789 // editor.toolbars[i] = Roo.factory(
23790 // typeof(editor.toolbars[i]) == 'string' ?
23791 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23792 // Roo.bootstrap.HtmlEditor);
23793 // editor.toolbars[i].init(editor);
23799 onRender : function(ct, position)
23801 // Roo.log("Call onRender: " + this.xtype);
23803 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23805 this.wrap = this.inputEl().wrap({
23806 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23809 this.editorcore.onRender(ct, position);
23811 if (this.resizable) {
23812 this.resizeEl = new Roo.Resizable(this.wrap, {
23816 minHeight : this.height,
23817 height: this.height,
23818 handles : this.resizable,
23821 resize : function(r, w, h) {
23822 _t.onResize(w,h); // -something
23828 this.createToolbar(this);
23831 if(!this.width && this.resizable){
23832 this.setSize(this.wrap.getSize());
23834 if (this.resizeEl) {
23835 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23836 // should trigger onReize..
23842 onResize : function(w, h)
23844 Roo.log('resize: ' +w + ',' + h );
23845 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23849 if(this.inputEl() ){
23850 if(typeof w == 'number'){
23851 var aw = w - this.wrap.getFrameWidth('lr');
23852 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23855 if(typeof h == 'number'){
23856 var tbh = -11; // fixme it needs to tool bar size!
23857 for (var i =0; i < this.toolbars.length;i++) {
23858 // fixme - ask toolbars for heights?
23859 tbh += this.toolbars[i].el.getHeight();
23860 //if (this.toolbars[i].footer) {
23861 // tbh += this.toolbars[i].footer.el.getHeight();
23869 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23870 ah -= 5; // knock a few pixes off for look..
23871 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23875 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23876 this.editorcore.onResize(ew,eh);
23881 * Toggles the editor between standard and source edit mode.
23882 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23884 toggleSourceEdit : function(sourceEditMode)
23886 this.editorcore.toggleSourceEdit(sourceEditMode);
23888 if(this.editorcore.sourceEditMode){
23889 Roo.log('editor - showing textarea');
23892 // Roo.log(this.syncValue());
23894 this.inputEl().removeClass(['hide', 'x-hidden']);
23895 this.inputEl().dom.removeAttribute('tabIndex');
23896 this.inputEl().focus();
23898 Roo.log('editor - hiding textarea');
23900 // Roo.log(this.pushValue());
23903 this.inputEl().addClass(['hide', 'x-hidden']);
23904 this.inputEl().dom.setAttribute('tabIndex', -1);
23905 //this.deferFocus();
23908 if(this.resizable){
23909 this.setSize(this.wrap.getSize());
23912 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23915 // private (for BoxComponent)
23916 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23918 // private (for BoxComponent)
23919 getResizeEl : function(){
23923 // private (for BoxComponent)
23924 getPositionEl : function(){
23929 initEvents : function(){
23930 this.originalValue = this.getValue();
23934 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23937 // markInvalid : Roo.emptyFn,
23939 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23942 // clearInvalid : Roo.emptyFn,
23944 setValue : function(v){
23945 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23946 this.editorcore.pushValue();
23951 deferFocus : function(){
23952 this.focus.defer(10, this);
23956 focus : function(){
23957 this.editorcore.focus();
23963 onDestroy : function(){
23969 for (var i =0; i < this.toolbars.length;i++) {
23970 // fixme - ask toolbars for heights?
23971 this.toolbars[i].onDestroy();
23974 this.wrap.dom.innerHTML = '';
23975 this.wrap.remove();
23980 onFirstFocus : function(){
23981 //Roo.log("onFirstFocus");
23982 this.editorcore.onFirstFocus();
23983 for (var i =0; i < this.toolbars.length;i++) {
23984 this.toolbars[i].onFirstFocus();
23990 syncValue : function()
23992 this.editorcore.syncValue();
23995 pushValue : function()
23997 this.editorcore.pushValue();
24001 // hide stuff that is not compatible
24015 * @event specialkey
24019 * @cfg {String} fieldClass @hide
24022 * @cfg {String} focusClass @hide
24025 * @cfg {String} autoCreate @hide
24028 * @cfg {String} inputType @hide
24032 * @cfg {String} invalidText @hide
24035 * @cfg {String} msgFx @hide
24038 * @cfg {String} validateOnBlur @hide
24047 Roo.namespace('Roo.bootstrap.htmleditor');
24049 * @class Roo.bootstrap.HtmlEditorToolbar1
24054 new Roo.bootstrap.HtmlEditor({
24057 new Roo.bootstrap.HtmlEditorToolbar1({
24058 disable : { fonts: 1 , format: 1, ..., ... , ...],
24064 * @cfg {Object} disable List of elements to disable..
24065 * @cfg {Array} btns List of additional buttons.
24069 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24072 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24075 Roo.apply(this, config);
24077 // default disabled, based on 'good practice'..
24078 this.disable = this.disable || {};
24079 Roo.applyIf(this.disable, {
24082 specialElements : true
24084 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24086 this.editor = config.editor;
24087 this.editorcore = config.editor.editorcore;
24089 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24091 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24092 // dont call parent... till later.
24094 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24099 editorcore : false,
24104 "h1","h2","h3","h4","h5","h6",
24106 "abbr", "acronym", "address", "cite", "samp", "var",
24110 onRender : function(ct, position)
24112 // Roo.log("Call onRender: " + this.xtype);
24114 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24116 this.el.dom.style.marginBottom = '0';
24118 var editorcore = this.editorcore;
24119 var editor= this.editor;
24122 var btn = function(id,cmd , toggle, handler, html){
24124 var event = toggle ? 'toggle' : 'click';
24129 xns: Roo.bootstrap,
24133 enableToggle:toggle !== false,
24135 pressed : toggle ? false : null,
24138 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24139 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24145 // var cb_box = function...
24150 xns: Roo.bootstrap,
24155 xns: Roo.bootstrap,
24159 Roo.each(this.formats, function(f) {
24160 style.menu.items.push({
24162 xns: Roo.bootstrap,
24163 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24168 editorcore.insertTag(this.tagname);
24175 children.push(style);
24177 btn('bold',false,true);
24178 btn('italic',false,true);
24179 btn('align-left', 'justifyleft',true);
24180 btn('align-center', 'justifycenter',true);
24181 btn('align-right' , 'justifyright',true);
24182 btn('link', false, false, function(btn) {
24183 //Roo.log("create link?");
24184 var url = prompt(this.createLinkText, this.defaultLinkValue);
24185 if(url && url != 'http:/'+'/'){
24186 this.editorcore.relayCmd('createlink', url);
24189 btn('list','insertunorderedlist',true);
24190 btn('pencil', false,true, function(btn){
24192 this.toggleSourceEdit(btn.pressed);
24195 if (this.editor.btns.length > 0) {
24196 for (var i = 0; i<this.editor.btns.length; i++) {
24197 children.push(this.editor.btns[i]);
24205 xns: Roo.bootstrap,
24210 xns: Roo.bootstrap,
24215 cog.menu.items.push({
24217 xns: Roo.bootstrap,
24218 html : Clean styles,
24223 editorcore.insertTag(this.tagname);
24232 this.xtype = 'NavSimplebar';
24234 for(var i=0;i< children.length;i++) {
24236 this.buttons.add(this.addxtypeChild(children[i]));
24240 editor.on('editorevent', this.updateToolbar, this);
24242 onBtnClick : function(id)
24244 this.editorcore.relayCmd(id);
24245 this.editorcore.focus();
24249 * Protected method that will not generally be called directly. It triggers
24250 * a toolbar update by reading the markup state of the current selection in the editor.
24252 updateToolbar: function(){
24254 if(!this.editorcore.activated){
24255 this.editor.onFirstFocus(); // is this neeed?
24259 var btns = this.buttons;
24260 var doc = this.editorcore.doc;
24261 btns.get('bold').setActive(doc.queryCommandState('bold'));
24262 btns.get('italic').setActive(doc.queryCommandState('italic'));
24263 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24265 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24266 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24267 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24269 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24270 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24273 var ans = this.editorcore.getAllAncestors();
24274 if (this.formatCombo) {
24277 var store = this.formatCombo.store;
24278 this.formatCombo.setValue("");
24279 for (var i =0; i < ans.length;i++) {
24280 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24282 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24290 // hides menus... - so this cant be on a menu...
24291 Roo.bootstrap.MenuMgr.hideAll();
24293 Roo.bootstrap.MenuMgr.hideAll();
24294 //this.editorsyncValue();
24296 onFirstFocus: function() {
24297 this.buttons.each(function(item){
24301 toggleSourceEdit : function(sourceEditMode){
24304 if(sourceEditMode){
24305 Roo.log("disabling buttons");
24306 this.buttons.each( function(item){
24307 if(item.cmd != 'pencil'){
24313 Roo.log("enabling buttons");
24314 if(this.editorcore.initialized){
24315 this.buttons.each( function(item){
24321 Roo.log("calling toggole on editor");
24322 // tell the editor that it's been pressed..
24323 this.editor.toggleSourceEdit(sourceEditMode);
24333 * @class Roo.bootstrap.Table.AbstractSelectionModel
24334 * @extends Roo.util.Observable
24335 * Abstract base class for grid SelectionModels. It provides the interface that should be
24336 * implemented by descendant classes. This class should not be directly instantiated.
24339 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24340 this.locked = false;
24341 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24345 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24346 /** @ignore Called by the grid automatically. Do not call directly. */
24347 init : function(grid){
24353 * Locks the selections.
24356 this.locked = true;
24360 * Unlocks the selections.
24362 unlock : function(){
24363 this.locked = false;
24367 * Returns true if the selections are locked.
24368 * @return {Boolean}
24370 isLocked : function(){
24371 return this.locked;
24375 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24376 * @class Roo.bootstrap.Table.RowSelectionModel
24377 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24378 * It supports multiple selections and keyboard selection/navigation.
24380 * @param {Object} config
24383 Roo.bootstrap.Table.RowSelectionModel = function(config){
24384 Roo.apply(this, config);
24385 this.selections = new Roo.util.MixedCollection(false, function(o){
24390 this.lastActive = false;
24394 * @event selectionchange
24395 * Fires when the selection changes
24396 * @param {SelectionModel} this
24398 "selectionchange" : true,
24400 * @event afterselectionchange
24401 * Fires after the selection changes (eg. by key press or clicking)
24402 * @param {SelectionModel} this
24404 "afterselectionchange" : true,
24406 * @event beforerowselect
24407 * Fires when a row is selected being selected, return false to cancel.
24408 * @param {SelectionModel} this
24409 * @param {Number} rowIndex The selected index
24410 * @param {Boolean} keepExisting False if other selections will be cleared
24412 "beforerowselect" : true,
24415 * Fires when a row is selected.
24416 * @param {SelectionModel} this
24417 * @param {Number} rowIndex The selected index
24418 * @param {Roo.data.Record} r The record
24420 "rowselect" : true,
24422 * @event rowdeselect
24423 * Fires when a row is deselected.
24424 * @param {SelectionModel} this
24425 * @param {Number} rowIndex The selected index
24427 "rowdeselect" : true
24429 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24430 this.locked = false;
24433 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24435 * @cfg {Boolean} singleSelect
24436 * True to allow selection of only one row at a time (defaults to false)
24438 singleSelect : false,
24441 initEvents : function()
24444 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24445 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24446 //}else{ // allow click to work like normal
24447 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24449 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24450 this.grid.on("rowclick", this.handleMouseDown, this);
24452 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24453 "up" : function(e){
24455 this.selectPrevious(e.shiftKey);
24456 }else if(this.last !== false && this.lastActive !== false){
24457 var last = this.last;
24458 this.selectRange(this.last, this.lastActive-1);
24459 this.grid.getView().focusRow(this.lastActive);
24460 if(last !== false){
24464 this.selectFirstRow();
24466 this.fireEvent("afterselectionchange", this);
24468 "down" : function(e){
24470 this.selectNext(e.shiftKey);
24471 }else if(this.last !== false && this.lastActive !== false){
24472 var last = this.last;
24473 this.selectRange(this.last, this.lastActive+1);
24474 this.grid.getView().focusRow(this.lastActive);
24475 if(last !== false){
24479 this.selectFirstRow();
24481 this.fireEvent("afterselectionchange", this);
24485 this.grid.store.on('load', function(){
24486 this.selections.clear();
24489 var view = this.grid.view;
24490 view.on("refresh", this.onRefresh, this);
24491 view.on("rowupdated", this.onRowUpdated, this);
24492 view.on("rowremoved", this.onRemove, this);
24497 onRefresh : function()
24499 var ds = this.grid.store, i, v = this.grid.view;
24500 var s = this.selections;
24501 s.each(function(r){
24502 if((i = ds.indexOfId(r.id)) != -1){
24511 onRemove : function(v, index, r){
24512 this.selections.remove(r);
24516 onRowUpdated : function(v, index, r){
24517 if(this.isSelected(r)){
24518 v.onRowSelect(index);
24524 * @param {Array} records The records to select
24525 * @param {Boolean} keepExisting (optional) True to keep existing selections
24527 selectRecords : function(records, keepExisting)
24530 this.clearSelections();
24532 var ds = this.grid.store;
24533 for(var i = 0, len = records.length; i < len; i++){
24534 this.selectRow(ds.indexOf(records[i]), true);
24539 * Gets the number of selected rows.
24542 getCount : function(){
24543 return this.selections.length;
24547 * Selects the first row in the grid.
24549 selectFirstRow : function(){
24554 * Select the last row.
24555 * @param {Boolean} keepExisting (optional) True to keep existing selections
24557 selectLastRow : function(keepExisting){
24558 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24559 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24563 * Selects the row immediately following the last selected row.
24564 * @param {Boolean} keepExisting (optional) True to keep existing selections
24566 selectNext : function(keepExisting)
24568 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24569 this.selectRow(this.last+1, keepExisting);
24570 this.grid.getView().focusRow(this.last);
24575 * Selects the row that precedes the last selected row.
24576 * @param {Boolean} keepExisting (optional) True to keep existing selections
24578 selectPrevious : function(keepExisting){
24580 this.selectRow(this.last-1, keepExisting);
24581 this.grid.getView().focusRow(this.last);
24586 * Returns the selected records
24587 * @return {Array} Array of selected records
24589 getSelections : function(){
24590 return [].concat(this.selections.items);
24594 * Returns the first selected record.
24597 getSelected : function(){
24598 return this.selections.itemAt(0);
24603 * Clears all selections.
24605 clearSelections : function(fast)
24611 var ds = this.grid.store;
24612 var s = this.selections;
24613 s.each(function(r){
24614 this.deselectRow(ds.indexOfId(r.id));
24618 this.selections.clear();
24625 * Selects all rows.
24627 selectAll : function(){
24631 this.selections.clear();
24632 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24633 this.selectRow(i, true);
24638 * Returns True if there is a selection.
24639 * @return {Boolean}
24641 hasSelection : function(){
24642 return this.selections.length > 0;
24646 * Returns True if the specified row is selected.
24647 * @param {Number/Record} record The record or index of the record to check
24648 * @return {Boolean}
24650 isSelected : function(index){
24651 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24652 return (r && this.selections.key(r.id) ? true : false);
24656 * Returns True if the specified record id is selected.
24657 * @param {String} id The id of record to check
24658 * @return {Boolean}
24660 isIdSelected : function(id){
24661 return (this.selections.key(id) ? true : false);
24666 handleMouseDBClick : function(e, t){
24670 handleMouseDown : function(e, t)
24672 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24673 if(this.isLocked() || rowIndex < 0 ){
24676 if(e.shiftKey && this.last !== false){
24677 var last = this.last;
24678 this.selectRange(last, rowIndex, e.ctrlKey);
24679 this.last = last; // reset the last
24683 var isSelected = this.isSelected(rowIndex);
24684 //Roo.log("select row:" + rowIndex);
24686 this.deselectRow(rowIndex);
24688 this.selectRow(rowIndex, true);
24692 if(e.button !== 0 && isSelected){
24693 alert('rowIndex 2: ' + rowIndex);
24694 view.focusRow(rowIndex);
24695 }else if(e.ctrlKey && isSelected){
24696 this.deselectRow(rowIndex);
24697 }else if(!isSelected){
24698 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24699 view.focusRow(rowIndex);
24703 this.fireEvent("afterselectionchange", this);
24706 handleDragableRowClick : function(grid, rowIndex, e)
24708 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24709 this.selectRow(rowIndex, false);
24710 grid.view.focusRow(rowIndex);
24711 this.fireEvent("afterselectionchange", this);
24716 * Selects multiple rows.
24717 * @param {Array} rows Array of the indexes of the row to select
24718 * @param {Boolean} keepExisting (optional) True to keep existing selections
24720 selectRows : function(rows, keepExisting){
24722 this.clearSelections();
24724 for(var i = 0, len = rows.length; i < len; i++){
24725 this.selectRow(rows[i], true);
24730 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24731 * @param {Number} startRow The index of the first row in the range
24732 * @param {Number} endRow The index of the last row in the range
24733 * @param {Boolean} keepExisting (optional) True to retain existing selections
24735 selectRange : function(startRow, endRow, keepExisting){
24740 this.clearSelections();
24742 if(startRow <= endRow){
24743 for(var i = startRow; i <= endRow; i++){
24744 this.selectRow(i, true);
24747 for(var i = startRow; i >= endRow; i--){
24748 this.selectRow(i, true);
24754 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24755 * @param {Number} startRow The index of the first row in the range
24756 * @param {Number} endRow The index of the last row in the range
24758 deselectRange : function(startRow, endRow, preventViewNotify){
24762 for(var i = startRow; i <= endRow; i++){
24763 this.deselectRow(i, preventViewNotify);
24769 * @param {Number} row The index of the row to select
24770 * @param {Boolean} keepExisting (optional) True to keep existing selections
24772 selectRow : function(index, keepExisting, preventViewNotify)
24774 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24777 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24778 if(!keepExisting || this.singleSelect){
24779 this.clearSelections();
24782 var r = this.grid.store.getAt(index);
24783 //console.log('selectRow - record id :' + r.id);
24785 this.selections.add(r);
24786 this.last = this.lastActive = index;
24787 if(!preventViewNotify){
24788 var proxy = new Roo.Element(
24789 this.grid.getRowDom(index)
24791 proxy.addClass('bg-info info');
24793 this.fireEvent("rowselect", this, index, r);
24794 this.fireEvent("selectionchange", this);
24800 * @param {Number} row The index of the row to deselect
24802 deselectRow : function(index, preventViewNotify)
24807 if(this.last == index){
24810 if(this.lastActive == index){
24811 this.lastActive = false;
24814 var r = this.grid.store.getAt(index);
24819 this.selections.remove(r);
24820 //.console.log('deselectRow - record id :' + r.id);
24821 if(!preventViewNotify){
24823 var proxy = new Roo.Element(
24824 this.grid.getRowDom(index)
24826 proxy.removeClass('bg-info info');
24828 this.fireEvent("rowdeselect", this, index);
24829 this.fireEvent("selectionchange", this);
24833 restoreLast : function(){
24835 this.last = this._last;
24840 acceptsNav : function(row, col, cm){
24841 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24845 onEditorKey : function(field, e){
24846 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24851 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24853 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24855 }else if(k == e.ENTER && !e.ctrlKey){
24859 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24861 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24863 }else if(k == e.ESC){
24867 g.startEditing(newCell[0], newCell[1]);
24873 * Ext JS Library 1.1.1
24874 * Copyright(c) 2006-2007, Ext JS, LLC.
24876 * Originally Released Under LGPL - original licence link has changed is not relivant.
24879 * <script type="text/javascript">
24883 * @class Roo.bootstrap.PagingToolbar
24884 * @extends Roo.bootstrap.NavSimplebar
24885 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24887 * Create a new PagingToolbar
24888 * @param {Object} config The config object
24889 * @param {Roo.data.Store} store
24891 Roo.bootstrap.PagingToolbar = function(config)
24893 // old args format still supported... - xtype is prefered..
24894 // created from xtype...
24896 this.ds = config.dataSource;
24898 if (config.store && !this.ds) {
24899 this.store= Roo.factory(config.store, Roo.data);
24900 this.ds = this.store;
24901 this.ds.xmodule = this.xmodule || false;
24904 this.toolbarItems = [];
24905 if (config.items) {
24906 this.toolbarItems = config.items;
24909 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24914 this.bind(this.ds);
24917 if (Roo.bootstrap.version == 4) {
24918 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24920 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24925 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24927 * @cfg {Roo.data.Store} dataSource
24928 * The underlying data store providing the paged data
24931 * @cfg {String/HTMLElement/Element} container
24932 * container The id or element that will contain the toolbar
24935 * @cfg {Boolean} displayInfo
24936 * True to display the displayMsg (defaults to false)
24939 * @cfg {Number} pageSize
24940 * The number of records to display per page (defaults to 20)
24944 * @cfg {String} displayMsg
24945 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24947 displayMsg : 'Displaying {0} - {1} of {2}',
24949 * @cfg {String} emptyMsg
24950 * The message to display when no records are found (defaults to "No data to display")
24952 emptyMsg : 'No data to display',
24954 * Customizable piece of the default paging text (defaults to "Page")
24957 beforePageText : "Page",
24959 * Customizable piece of the default paging text (defaults to "of %0")
24962 afterPageText : "of {0}",
24964 * Customizable piece of the default paging text (defaults to "First Page")
24967 firstText : "First Page",
24969 * Customizable piece of the default paging text (defaults to "Previous Page")
24972 prevText : "Previous Page",
24974 * Customizable piece of the default paging text (defaults to "Next Page")
24977 nextText : "Next Page",
24979 * Customizable piece of the default paging text (defaults to "Last Page")
24982 lastText : "Last Page",
24984 * Customizable piece of the default paging text (defaults to "Refresh")
24987 refreshText : "Refresh",
24991 onRender : function(ct, position)
24993 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24994 this.navgroup.parentId = this.id;
24995 this.navgroup.onRender(this.el, null);
24996 // add the buttons to the navgroup
24998 if(this.displayInfo){
24999 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25000 this.displayEl = this.el.select('.x-paging-info', true).first();
25001 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25002 // this.displayEl = navel.el.select('span',true).first();
25008 Roo.each(_this.buttons, function(e){ // this might need to use render????
25009 Roo.factory(e).render(_this.el);
25013 Roo.each(_this.toolbarItems, function(e) {
25014 _this.navgroup.addItem(e);
25018 this.first = this.navgroup.addItem({
25019 tooltip: this.firstText,
25020 cls: "prev btn-outline-secondary",
25021 html : ' <i class="fa fa-step-backward"></i>',
25023 preventDefault: true,
25024 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25027 this.prev = this.navgroup.addItem({
25028 tooltip: this.prevText,
25029 cls: "prev btn-outline-secondary",
25030 html : ' <i class="fa fa-backward"></i>',
25032 preventDefault: true,
25033 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25035 //this.addSeparator();
25038 var field = this.navgroup.addItem( {
25040 cls : 'x-paging-position btn-outline-secondary',
25042 html : this.beforePageText +
25043 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25044 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25047 this.field = field.el.select('input', true).first();
25048 this.field.on("keydown", this.onPagingKeydown, this);
25049 this.field.on("focus", function(){this.dom.select();});
25052 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25053 //this.field.setHeight(18);
25054 //this.addSeparator();
25055 this.next = this.navgroup.addItem({
25056 tooltip: this.nextText,
25057 cls: "next btn-outline-secondary",
25058 html : ' <i class="fa fa-forward"></i>',
25060 preventDefault: true,
25061 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25063 this.last = this.navgroup.addItem({
25064 tooltip: this.lastText,
25065 html : ' <i class="fa fa-step-forward"></i>',
25066 cls: "next btn-outline-secondary",
25068 preventDefault: true,
25069 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25071 //this.addSeparator();
25072 this.loading = this.navgroup.addItem({
25073 tooltip: this.refreshText,
25074 cls: "btn-outline-secondary",
25075 html : ' <i class="fa fa-refresh"></i>',
25076 preventDefault: true,
25077 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25083 updateInfo : function(){
25084 if(this.displayEl){
25085 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25086 var msg = count == 0 ?
25090 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25092 this.displayEl.update(msg);
25097 onLoad : function(ds, r, o)
25099 this.cursor = o.params.start ? o.params.start : 0;
25101 var d = this.getPageData(),
25106 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25107 this.field.dom.value = ap;
25108 this.first.setDisabled(ap == 1);
25109 this.prev.setDisabled(ap == 1);
25110 this.next.setDisabled(ap == ps);
25111 this.last.setDisabled(ap == ps);
25112 this.loading.enable();
25117 getPageData : function(){
25118 var total = this.ds.getTotalCount();
25121 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25122 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25127 onLoadError : function(){
25128 this.loading.enable();
25132 onPagingKeydown : function(e){
25133 var k = e.getKey();
25134 var d = this.getPageData();
25136 var v = this.field.dom.value, pageNum;
25137 if(!v || isNaN(pageNum = parseInt(v, 10))){
25138 this.field.dom.value = d.activePage;
25141 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25142 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25145 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))
25147 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25148 this.field.dom.value = pageNum;
25149 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25152 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25154 var v = this.field.dom.value, pageNum;
25155 var increment = (e.shiftKey) ? 10 : 1;
25156 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25159 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25160 this.field.dom.value = d.activePage;
25163 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25165 this.field.dom.value = parseInt(v, 10) + increment;
25166 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25167 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25174 beforeLoad : function(){
25176 this.loading.disable();
25181 onClick : function(which){
25190 ds.load({params:{start: 0, limit: this.pageSize}});
25193 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25196 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25199 var total = ds.getTotalCount();
25200 var extra = total % this.pageSize;
25201 var lastStart = extra ? (total - extra) : total-this.pageSize;
25202 ds.load({params:{start: lastStart, limit: this.pageSize}});
25205 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25211 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25212 * @param {Roo.data.Store} store The data store to unbind
25214 unbind : function(ds){
25215 ds.un("beforeload", this.beforeLoad, this);
25216 ds.un("load", this.onLoad, this);
25217 ds.un("loadexception", this.onLoadError, this);
25218 ds.un("remove", this.updateInfo, this);
25219 ds.un("add", this.updateInfo, this);
25220 this.ds = undefined;
25224 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25225 * @param {Roo.data.Store} store The data store to bind
25227 bind : function(ds){
25228 ds.on("beforeload", this.beforeLoad, this);
25229 ds.on("load", this.onLoad, this);
25230 ds.on("loadexception", this.onLoadError, this);
25231 ds.on("remove", this.updateInfo, this);
25232 ds.on("add", this.updateInfo, this);
25243 * @class Roo.bootstrap.MessageBar
25244 * @extends Roo.bootstrap.Component
25245 * Bootstrap MessageBar class
25246 * @cfg {String} html contents of the MessageBar
25247 * @cfg {String} weight (info | success | warning | danger) default info
25248 * @cfg {String} beforeClass insert the bar before the given class
25249 * @cfg {Boolean} closable (true | false) default false
25250 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25253 * Create a new Element
25254 * @param {Object} config The config object
25257 Roo.bootstrap.MessageBar = function(config){
25258 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25261 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25267 beforeClass: 'bootstrap-sticky-wrap',
25269 getAutoCreate : function(){
25273 cls: 'alert alert-dismissable alert-' + this.weight,
25278 html: this.html || ''
25284 cfg.cls += ' alert-messages-fixed';
25298 onRender : function(ct, position)
25300 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25303 var cfg = Roo.apply({}, this.getAutoCreate());
25307 cfg.cls += ' ' + this.cls;
25310 cfg.style = this.style;
25312 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25314 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25317 this.el.select('>button.close').on('click', this.hide, this);
25323 if (!this.rendered) {
25329 this.fireEvent('show', this);
25335 if (!this.rendered) {
25341 this.fireEvent('hide', this);
25344 update : function()
25346 // var e = this.el.dom.firstChild;
25348 // if(this.closable){
25349 // e = e.nextSibling;
25352 // e.data = this.html || '';
25354 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25370 * @class Roo.bootstrap.Graph
25371 * @extends Roo.bootstrap.Component
25372 * Bootstrap Graph class
25376 @cfg {String} graphtype bar | vbar | pie
25377 @cfg {number} g_x coodinator | centre x (pie)
25378 @cfg {number} g_y coodinator | centre y (pie)
25379 @cfg {number} g_r radius (pie)
25380 @cfg {number} g_height height of the chart (respected by all elements in the set)
25381 @cfg {number} g_width width of the chart (respected by all elements in the set)
25382 @cfg {Object} title The title of the chart
25385 -opts (object) options for the chart
25387 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25388 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25390 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.
25391 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25393 o stretch (boolean)
25395 -opts (object) options for the pie
25398 o startAngle (number)
25399 o endAngle (number)
25403 * Create a new Input
25404 * @param {Object} config The config object
25407 Roo.bootstrap.Graph = function(config){
25408 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25414 * The img click event for the img.
25415 * @param {Roo.EventObject} e
25421 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25432 //g_colors: this.colors,
25439 getAutoCreate : function(){
25450 onRender : function(ct,position){
25453 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25455 if (typeof(Raphael) == 'undefined') {
25456 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25460 this.raphael = Raphael(this.el.dom);
25462 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25463 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25464 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25465 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25467 r.text(160, 10, "Single Series Chart").attr(txtattr);
25468 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25469 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25470 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25472 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25473 r.barchart(330, 10, 300, 220, data1);
25474 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25475 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25478 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25479 // r.barchart(30, 30, 560, 250, xdata, {
25480 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25481 // axis : "0 0 1 1",
25482 // axisxlabels : xdata
25483 // //yvalues : cols,
25486 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25488 // this.load(null,xdata,{
25489 // axis : "0 0 1 1",
25490 // axisxlabels : xdata
25495 load : function(graphtype,xdata,opts)
25497 this.raphael.clear();
25499 graphtype = this.graphtype;
25504 var r = this.raphael,
25505 fin = function () {
25506 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25508 fout = function () {
25509 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25511 pfin = function() {
25512 this.sector.stop();
25513 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25516 this.label[0].stop();
25517 this.label[0].attr({ r: 7.5 });
25518 this.label[1].attr({ "font-weight": 800 });
25521 pfout = function() {
25522 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25525 this.label[0].animate({ r: 5 }, 500, "bounce");
25526 this.label[1].attr({ "font-weight": 400 });
25532 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25535 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25538 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25539 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25541 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25548 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25553 setTitle: function(o)
25558 initEvents: function() {
25561 this.el.on('click', this.onClick, this);
25565 onClick : function(e)
25567 Roo.log('img onclick');
25568 this.fireEvent('click', this, e);
25580 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25583 * @class Roo.bootstrap.dash.NumberBox
25584 * @extends Roo.bootstrap.Component
25585 * Bootstrap NumberBox class
25586 * @cfg {String} headline Box headline
25587 * @cfg {String} content Box content
25588 * @cfg {String} icon Box icon
25589 * @cfg {String} footer Footer text
25590 * @cfg {String} fhref Footer href
25593 * Create a new NumberBox
25594 * @param {Object} config The config object
25598 Roo.bootstrap.dash.NumberBox = function(config){
25599 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25603 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25612 getAutoCreate : function(){
25616 cls : 'small-box ',
25624 cls : 'roo-headline',
25625 html : this.headline
25629 cls : 'roo-content',
25630 html : this.content
25644 cls : 'ion ' + this.icon
25653 cls : 'small-box-footer',
25654 href : this.fhref || '#',
25658 cfg.cn.push(footer);
25665 onRender : function(ct,position){
25666 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25673 setHeadline: function (value)
25675 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25678 setFooter: function (value, href)
25680 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25683 this.el.select('a.small-box-footer',true).first().attr('href', href);
25688 setContent: function (value)
25690 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25693 initEvents: function()
25707 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25710 * @class Roo.bootstrap.dash.TabBox
25711 * @extends Roo.bootstrap.Component
25712 * Bootstrap TabBox class
25713 * @cfg {String} title Title of the TabBox
25714 * @cfg {String} icon Icon of the TabBox
25715 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25716 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25719 * Create a new TabBox
25720 * @param {Object} config The config object
25724 Roo.bootstrap.dash.TabBox = function(config){
25725 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25730 * When a pane is added
25731 * @param {Roo.bootstrap.dash.TabPane} pane
25735 * @event activatepane
25736 * When a pane is activated
25737 * @param {Roo.bootstrap.dash.TabPane} pane
25739 "activatepane" : true
25747 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25752 tabScrollable : false,
25754 getChildContainer : function()
25756 return this.el.select('.tab-content', true).first();
25759 getAutoCreate : function(){
25763 cls: 'pull-left header',
25771 cls: 'fa ' + this.icon
25777 cls: 'nav nav-tabs pull-right',
25783 if(this.tabScrollable){
25790 cls: 'nav nav-tabs pull-right',
25801 cls: 'nav-tabs-custom',
25806 cls: 'tab-content no-padding',
25814 initEvents : function()
25816 //Roo.log('add add pane handler');
25817 this.on('addpane', this.onAddPane, this);
25820 * Updates the box title
25821 * @param {String} html to set the title to.
25823 setTitle : function(value)
25825 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25827 onAddPane : function(pane)
25829 this.panes.push(pane);
25830 //Roo.log('addpane');
25832 // tabs are rendere left to right..
25833 if(!this.showtabs){
25837 var ctr = this.el.select('.nav-tabs', true).first();
25840 var existing = ctr.select('.nav-tab',true);
25841 var qty = existing.getCount();;
25844 var tab = ctr.createChild({
25846 cls : 'nav-tab' + (qty ? '' : ' active'),
25854 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25857 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25859 pane.el.addClass('active');
25864 onTabClick : function(ev,un,ob,pane)
25866 //Roo.log('tab - prev default');
25867 ev.preventDefault();
25870 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25871 pane.tab.addClass('active');
25872 //Roo.log(pane.title);
25873 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25874 // technically we should have a deactivate event.. but maybe add later.
25875 // and it should not de-activate the selected tab...
25876 this.fireEvent('activatepane', pane);
25877 pane.el.addClass('active');
25878 pane.fireEvent('activate');
25883 getActivePane : function()
25886 Roo.each(this.panes, function(p) {
25887 if(p.el.hasClass('active')){
25908 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25910 * @class Roo.bootstrap.TabPane
25911 * @extends Roo.bootstrap.Component
25912 * Bootstrap TabPane class
25913 * @cfg {Boolean} active (false | true) Default false
25914 * @cfg {String} title title of panel
25918 * Create a new TabPane
25919 * @param {Object} config The config object
25922 Roo.bootstrap.dash.TabPane = function(config){
25923 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25929 * When a pane is activated
25930 * @param {Roo.bootstrap.dash.TabPane} pane
25937 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25942 // the tabBox that this is attached to.
25945 getAutoCreate : function()
25953 cfg.cls += ' active';
25958 initEvents : function()
25960 //Roo.log('trigger add pane handler');
25961 this.parent().fireEvent('addpane', this)
25965 * Updates the tab title
25966 * @param {String} html to set the title to.
25968 setTitle: function(str)
25974 this.tab.select('a', true).first().dom.innerHTML = str;
25991 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25994 * @class Roo.bootstrap.menu.Menu
25995 * @extends Roo.bootstrap.Component
25996 * Bootstrap Menu class - container for Menu
25997 * @cfg {String} html Text of the menu
25998 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25999 * @cfg {String} icon Font awesome icon
26000 * @cfg {String} pos Menu align to (top | bottom) default bottom
26004 * Create a new Menu
26005 * @param {Object} config The config object
26009 Roo.bootstrap.menu.Menu = function(config){
26010 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26014 * @event beforeshow
26015 * Fires before this menu is displayed
26016 * @param {Roo.bootstrap.menu.Menu} this
26020 * @event beforehide
26021 * Fires before this menu is hidden
26022 * @param {Roo.bootstrap.menu.Menu} this
26027 * Fires after this menu is displayed
26028 * @param {Roo.bootstrap.menu.Menu} this
26033 * Fires after this menu is hidden
26034 * @param {Roo.bootstrap.menu.Menu} this
26039 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26040 * @param {Roo.bootstrap.menu.Menu} this
26041 * @param {Roo.EventObject} e
26048 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26052 weight : 'default',
26057 getChildContainer : function() {
26058 if(this.isSubMenu){
26062 return this.el.select('ul.dropdown-menu', true).first();
26065 getAutoCreate : function()
26070 cls : 'roo-menu-text',
26078 cls : 'fa ' + this.icon
26089 cls : 'dropdown-button btn btn-' + this.weight,
26094 cls : 'dropdown-toggle btn btn-' + this.weight,
26104 cls : 'dropdown-menu'
26110 if(this.pos == 'top'){
26111 cfg.cls += ' dropup';
26114 if(this.isSubMenu){
26117 cls : 'dropdown-menu'
26124 onRender : function(ct, position)
26126 this.isSubMenu = ct.hasClass('dropdown-submenu');
26128 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26131 initEvents : function()
26133 if(this.isSubMenu){
26137 this.hidden = true;
26139 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26140 this.triggerEl.on('click', this.onTriggerPress, this);
26142 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26143 this.buttonEl.on('click', this.onClick, this);
26149 if(this.isSubMenu){
26153 return this.el.select('ul.dropdown-menu', true).first();
26156 onClick : function(e)
26158 this.fireEvent("click", this, e);
26161 onTriggerPress : function(e)
26163 if (this.isVisible()) {
26170 isVisible : function(){
26171 return !this.hidden;
26176 this.fireEvent("beforeshow", this);
26178 this.hidden = false;
26179 this.el.addClass('open');
26181 Roo.get(document).on("mouseup", this.onMouseUp, this);
26183 this.fireEvent("show", this);
26190 this.fireEvent("beforehide", this);
26192 this.hidden = true;
26193 this.el.removeClass('open');
26195 Roo.get(document).un("mouseup", this.onMouseUp);
26197 this.fireEvent("hide", this);
26200 onMouseUp : function()
26214 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26217 * @class Roo.bootstrap.menu.Item
26218 * @extends Roo.bootstrap.Component
26219 * Bootstrap MenuItem class
26220 * @cfg {Boolean} submenu (true | false) default false
26221 * @cfg {String} html text of the item
26222 * @cfg {String} href the link
26223 * @cfg {Boolean} disable (true | false) default false
26224 * @cfg {Boolean} preventDefault (true | false) default true
26225 * @cfg {String} icon Font awesome icon
26226 * @cfg {String} pos Submenu align to (left | right) default right
26230 * Create a new Item
26231 * @param {Object} config The config object
26235 Roo.bootstrap.menu.Item = function(config){
26236 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26240 * Fires when the mouse is hovering over this menu
26241 * @param {Roo.bootstrap.menu.Item} this
26242 * @param {Roo.EventObject} e
26247 * Fires when the mouse exits this menu
26248 * @param {Roo.bootstrap.menu.Item} this
26249 * @param {Roo.EventObject} e
26255 * The raw click event for the entire grid.
26256 * @param {Roo.EventObject} e
26262 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26267 preventDefault: true,
26272 getAutoCreate : function()
26277 cls : 'roo-menu-item-text',
26285 cls : 'fa ' + this.icon
26294 href : this.href || '#',
26301 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26305 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26307 if(this.pos == 'left'){
26308 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26315 initEvents : function()
26317 this.el.on('mouseover', this.onMouseOver, this);
26318 this.el.on('mouseout', this.onMouseOut, this);
26320 this.el.select('a', true).first().on('click', this.onClick, this);
26324 onClick : function(e)
26326 if(this.preventDefault){
26327 e.preventDefault();
26330 this.fireEvent("click", this, e);
26333 onMouseOver : function(e)
26335 if(this.submenu && this.pos == 'left'){
26336 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26339 this.fireEvent("mouseover", this, e);
26342 onMouseOut : function(e)
26344 this.fireEvent("mouseout", this, e);
26356 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26359 * @class Roo.bootstrap.menu.Separator
26360 * @extends Roo.bootstrap.Component
26361 * Bootstrap Separator class
26364 * Create a new Separator
26365 * @param {Object} config The config object
26369 Roo.bootstrap.menu.Separator = function(config){
26370 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26373 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26375 getAutoCreate : function(){
26396 * @class Roo.bootstrap.Tooltip
26397 * Bootstrap Tooltip class
26398 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26399 * to determine which dom element triggers the tooltip.
26401 * It needs to add support for additional attributes like tooltip-position
26404 * Create a new Toolti
26405 * @param {Object} config The config object
26408 Roo.bootstrap.Tooltip = function(config){
26409 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26411 this.alignment = Roo.bootstrap.Tooltip.alignment;
26413 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26414 this.alignment = config.alignment;
26419 Roo.apply(Roo.bootstrap.Tooltip, {
26421 * @function init initialize tooltip monitoring.
26425 currentTip : false,
26426 currentRegion : false,
26432 Roo.get(document).on('mouseover', this.enter ,this);
26433 Roo.get(document).on('mouseout', this.leave, this);
26436 this.currentTip = new Roo.bootstrap.Tooltip();
26439 enter : function(ev)
26441 var dom = ev.getTarget();
26443 //Roo.log(['enter',dom]);
26444 var el = Roo.fly(dom);
26445 if (this.currentEl) {
26447 //Roo.log(this.currentEl);
26448 //Roo.log(this.currentEl.contains(dom));
26449 if (this.currentEl == el) {
26452 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26458 if (this.currentTip.el) {
26459 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26463 if(!el || el.dom == document){
26469 // you can not look for children, as if el is the body.. then everythign is the child..
26470 if (!el.attr('tooltip')) { //
26471 if (!el.select("[tooltip]").elements.length) {
26474 // is the mouse over this child...?
26475 bindEl = el.select("[tooltip]").first();
26476 var xy = ev.getXY();
26477 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26478 //Roo.log("not in region.");
26481 //Roo.log("child element over..");
26484 this.currentEl = bindEl;
26485 this.currentTip.bind(bindEl);
26486 this.currentRegion = Roo.lib.Region.getRegion(dom);
26487 this.currentTip.enter();
26490 leave : function(ev)
26492 var dom = ev.getTarget();
26493 //Roo.log(['leave',dom]);
26494 if (!this.currentEl) {
26499 if (dom != this.currentEl.dom) {
26502 var xy = ev.getXY();
26503 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26506 // only activate leave if mouse cursor is outside... bounding box..
26511 if (this.currentTip) {
26512 this.currentTip.leave();
26514 //Roo.log('clear currentEl');
26515 this.currentEl = false;
26520 'left' : ['r-l', [-2,0], 'right'],
26521 'right' : ['l-r', [2,0], 'left'],
26522 'bottom' : ['t-b', [0,2], 'top'],
26523 'top' : [ 'b-t', [0,-2], 'bottom']
26529 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26534 delay : null, // can be { show : 300 , hide: 500}
26538 hoverState : null, //???
26540 placement : 'bottom',
26544 getAutoCreate : function(){
26551 cls : 'tooltip-arrow'
26554 cls : 'tooltip-inner'
26561 bind : function(el)
26567 enter : function () {
26569 if (this.timeout != null) {
26570 clearTimeout(this.timeout);
26573 this.hoverState = 'in';
26574 //Roo.log("enter - show");
26575 if (!this.delay || !this.delay.show) {
26580 this.timeout = setTimeout(function () {
26581 if (_t.hoverState == 'in') {
26584 }, this.delay.show);
26588 clearTimeout(this.timeout);
26590 this.hoverState = 'out';
26591 if (!this.delay || !this.delay.hide) {
26597 this.timeout = setTimeout(function () {
26598 //Roo.log("leave - timeout");
26600 if (_t.hoverState == 'out') {
26602 Roo.bootstrap.Tooltip.currentEl = false;
26607 show : function (msg)
26610 this.render(document.body);
26613 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26615 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26617 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26619 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26621 var placement = typeof this.placement == 'function' ?
26622 this.placement.call(this, this.el, on_el) :
26625 var autoToken = /\s?auto?\s?/i;
26626 var autoPlace = autoToken.test(placement);
26628 placement = placement.replace(autoToken, '') || 'top';
26632 //this.el.setXY([0,0]);
26634 //this.el.dom.style.display='block';
26636 //this.el.appendTo(on_el);
26638 var p = this.getPosition();
26639 var box = this.el.getBox();
26645 var align = this.alignment[placement];
26647 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26649 if(placement == 'top' || placement == 'bottom'){
26651 placement = 'right';
26654 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26655 placement = 'left';
26658 var scroll = Roo.select('body', true).first().getScroll();
26660 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26664 align = this.alignment[placement];
26667 this.el.alignTo(this.bindEl, align[0],align[1]);
26668 //var arrow = this.el.select('.arrow',true).first();
26669 //arrow.set(align[2],
26671 this.el.addClass(placement);
26673 this.el.addClass('in fade');
26675 this.hoverState = null;
26677 if (this.el.hasClass('fade')) {
26688 //this.el.setXY([0,0]);
26689 this.el.removeClass('in');
26705 * @class Roo.bootstrap.LocationPicker
26706 * @extends Roo.bootstrap.Component
26707 * Bootstrap LocationPicker class
26708 * @cfg {Number} latitude Position when init default 0
26709 * @cfg {Number} longitude Position when init default 0
26710 * @cfg {Number} zoom default 15
26711 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26712 * @cfg {Boolean} mapTypeControl default false
26713 * @cfg {Boolean} disableDoubleClickZoom default false
26714 * @cfg {Boolean} scrollwheel default true
26715 * @cfg {Boolean} streetViewControl default false
26716 * @cfg {Number} radius default 0
26717 * @cfg {String} locationName
26718 * @cfg {Boolean} draggable default true
26719 * @cfg {Boolean} enableAutocomplete default false
26720 * @cfg {Boolean} enableReverseGeocode default true
26721 * @cfg {String} markerTitle
26724 * Create a new LocationPicker
26725 * @param {Object} config The config object
26729 Roo.bootstrap.LocationPicker = function(config){
26731 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26736 * Fires when the picker initialized.
26737 * @param {Roo.bootstrap.LocationPicker} this
26738 * @param {Google Location} location
26742 * @event positionchanged
26743 * Fires when the picker position changed.
26744 * @param {Roo.bootstrap.LocationPicker} this
26745 * @param {Google Location} location
26747 positionchanged : true,
26750 * Fires when the map resize.
26751 * @param {Roo.bootstrap.LocationPicker} this
26756 * Fires when the map show.
26757 * @param {Roo.bootstrap.LocationPicker} this
26762 * Fires when the map hide.
26763 * @param {Roo.bootstrap.LocationPicker} this
26768 * Fires when click the map.
26769 * @param {Roo.bootstrap.LocationPicker} this
26770 * @param {Map event} e
26774 * @event mapRightClick
26775 * Fires when right click the map.
26776 * @param {Roo.bootstrap.LocationPicker} this
26777 * @param {Map event} e
26779 mapRightClick : true,
26781 * @event markerClick
26782 * Fires when click the marker.
26783 * @param {Roo.bootstrap.LocationPicker} this
26784 * @param {Map event} e
26786 markerClick : true,
26788 * @event markerRightClick
26789 * Fires when right click the marker.
26790 * @param {Roo.bootstrap.LocationPicker} this
26791 * @param {Map event} e
26793 markerRightClick : true,
26795 * @event OverlayViewDraw
26796 * Fires when OverlayView Draw
26797 * @param {Roo.bootstrap.LocationPicker} this
26799 OverlayViewDraw : true,
26801 * @event OverlayViewOnAdd
26802 * Fires when OverlayView Draw
26803 * @param {Roo.bootstrap.LocationPicker} this
26805 OverlayViewOnAdd : true,
26807 * @event OverlayViewOnRemove
26808 * Fires when OverlayView Draw
26809 * @param {Roo.bootstrap.LocationPicker} this
26811 OverlayViewOnRemove : true,
26813 * @event OverlayViewShow
26814 * Fires when OverlayView Draw
26815 * @param {Roo.bootstrap.LocationPicker} this
26816 * @param {Pixel} cpx
26818 OverlayViewShow : true,
26820 * @event OverlayViewHide
26821 * Fires when OverlayView Draw
26822 * @param {Roo.bootstrap.LocationPicker} this
26824 OverlayViewHide : true,
26826 * @event loadexception
26827 * Fires when load google lib failed.
26828 * @param {Roo.bootstrap.LocationPicker} this
26830 loadexception : true
26835 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26837 gMapContext: false,
26843 mapTypeControl: false,
26844 disableDoubleClickZoom: false,
26846 streetViewControl: false,
26850 enableAutocomplete: false,
26851 enableReverseGeocode: true,
26854 getAutoCreate: function()
26859 cls: 'roo-location-picker'
26865 initEvents: function(ct, position)
26867 if(!this.el.getWidth() || this.isApplied()){
26871 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26876 initial: function()
26878 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26879 this.fireEvent('loadexception', this);
26883 if(!this.mapTypeId){
26884 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26887 this.gMapContext = this.GMapContext();
26889 this.initOverlayView();
26891 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26895 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26896 _this.setPosition(_this.gMapContext.marker.position);
26899 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26900 _this.fireEvent('mapClick', this, event);
26904 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26905 _this.fireEvent('mapRightClick', this, event);
26909 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26910 _this.fireEvent('markerClick', this, event);
26914 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26915 _this.fireEvent('markerRightClick', this, event);
26919 this.setPosition(this.gMapContext.location);
26921 this.fireEvent('initial', this, this.gMapContext.location);
26924 initOverlayView: function()
26928 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26932 _this.fireEvent('OverlayViewDraw', _this);
26937 _this.fireEvent('OverlayViewOnAdd', _this);
26940 onRemove: function()
26942 _this.fireEvent('OverlayViewOnRemove', _this);
26945 show: function(cpx)
26947 _this.fireEvent('OverlayViewShow', _this, cpx);
26952 _this.fireEvent('OverlayViewHide', _this);
26958 fromLatLngToContainerPixel: function(event)
26960 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26963 isApplied: function()
26965 return this.getGmapContext() == false ? false : true;
26968 getGmapContext: function()
26970 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26973 GMapContext: function()
26975 var position = new google.maps.LatLng(this.latitude, this.longitude);
26977 var _map = new google.maps.Map(this.el.dom, {
26980 mapTypeId: this.mapTypeId,
26981 mapTypeControl: this.mapTypeControl,
26982 disableDoubleClickZoom: this.disableDoubleClickZoom,
26983 scrollwheel: this.scrollwheel,
26984 streetViewControl: this.streetViewControl,
26985 locationName: this.locationName,
26986 draggable: this.draggable,
26987 enableAutocomplete: this.enableAutocomplete,
26988 enableReverseGeocode: this.enableReverseGeocode
26991 var _marker = new google.maps.Marker({
26992 position: position,
26994 title: this.markerTitle,
26995 draggable: this.draggable
27002 location: position,
27003 radius: this.radius,
27004 locationName: this.locationName,
27005 addressComponents: {
27006 formatted_address: null,
27007 addressLine1: null,
27008 addressLine2: null,
27010 streetNumber: null,
27014 stateOrProvince: null
27017 domContainer: this.el.dom,
27018 geodecoder: new google.maps.Geocoder()
27022 drawCircle: function(center, radius, options)
27024 if (this.gMapContext.circle != null) {
27025 this.gMapContext.circle.setMap(null);
27029 options = Roo.apply({}, options, {
27030 strokeColor: "#0000FF",
27031 strokeOpacity: .35,
27033 fillColor: "#0000FF",
27037 options.map = this.gMapContext.map;
27038 options.radius = radius;
27039 options.center = center;
27040 this.gMapContext.circle = new google.maps.Circle(options);
27041 return this.gMapContext.circle;
27047 setPosition: function(location)
27049 this.gMapContext.location = location;
27050 this.gMapContext.marker.setPosition(location);
27051 this.gMapContext.map.panTo(location);
27052 this.drawCircle(location, this.gMapContext.radius, {});
27056 if (this.gMapContext.settings.enableReverseGeocode) {
27057 this.gMapContext.geodecoder.geocode({
27058 latLng: this.gMapContext.location
27059 }, function(results, status) {
27061 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27062 _this.gMapContext.locationName = results[0].formatted_address;
27063 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27065 _this.fireEvent('positionchanged', this, location);
27072 this.fireEvent('positionchanged', this, location);
27077 google.maps.event.trigger(this.gMapContext.map, "resize");
27079 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27081 this.fireEvent('resize', this);
27084 setPositionByLatLng: function(latitude, longitude)
27086 this.setPosition(new google.maps.LatLng(latitude, longitude));
27089 getCurrentPosition: function()
27092 latitude: this.gMapContext.location.lat(),
27093 longitude: this.gMapContext.location.lng()
27097 getAddressName: function()
27099 return this.gMapContext.locationName;
27102 getAddressComponents: function()
27104 return this.gMapContext.addressComponents;
27107 address_component_from_google_geocode: function(address_components)
27111 for (var i = 0; i < address_components.length; i++) {
27112 var component = address_components[i];
27113 if (component.types.indexOf("postal_code") >= 0) {
27114 result.postalCode = component.short_name;
27115 } else if (component.types.indexOf("street_number") >= 0) {
27116 result.streetNumber = component.short_name;
27117 } else if (component.types.indexOf("route") >= 0) {
27118 result.streetName = component.short_name;
27119 } else if (component.types.indexOf("neighborhood") >= 0) {
27120 result.city = component.short_name;
27121 } else if (component.types.indexOf("locality") >= 0) {
27122 result.city = component.short_name;
27123 } else if (component.types.indexOf("sublocality") >= 0) {
27124 result.district = component.short_name;
27125 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27126 result.stateOrProvince = component.short_name;
27127 } else if (component.types.indexOf("country") >= 0) {
27128 result.country = component.short_name;
27132 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27133 result.addressLine2 = "";
27137 setZoomLevel: function(zoom)
27139 this.gMapContext.map.setZoom(zoom);
27152 this.fireEvent('show', this);
27163 this.fireEvent('hide', this);
27168 Roo.apply(Roo.bootstrap.LocationPicker, {
27170 OverlayView : function(map, options)
27172 options = options || {};
27186 * @class Roo.bootstrap.Alert
27187 * @extends Roo.bootstrap.Component
27188 * Bootstrap Alert class
27189 * @cfg {String} title The title of alert
27190 * @cfg {String} html The content of alert
27191 * @cfg {String} weight ( success | info | warning | danger )
27192 * @cfg {String} faicon font-awesomeicon
27195 * Create a new alert
27196 * @param {Object} config The config object
27200 Roo.bootstrap.Alert = function(config){
27201 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27205 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27212 getAutoCreate : function()
27221 cls : 'roo-alert-icon'
27226 cls : 'roo-alert-title',
27231 cls : 'roo-alert-text',
27238 cfg.cn[0].cls += ' fa ' + this.faicon;
27242 cfg.cls += ' alert-' + this.weight;
27248 initEvents: function()
27250 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27253 setTitle : function(str)
27255 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27258 setText : function(str)
27260 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27263 setWeight : function(weight)
27266 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27269 this.weight = weight;
27271 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27274 setIcon : function(icon)
27277 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27280 this.faicon = icon;
27282 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27303 * @class Roo.bootstrap.UploadCropbox
27304 * @extends Roo.bootstrap.Component
27305 * Bootstrap UploadCropbox class
27306 * @cfg {String} emptyText show when image has been loaded
27307 * @cfg {String} rotateNotify show when image too small to rotate
27308 * @cfg {Number} errorTimeout default 3000
27309 * @cfg {Number} minWidth default 300
27310 * @cfg {Number} minHeight default 300
27311 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27312 * @cfg {Boolean} isDocument (true|false) default false
27313 * @cfg {String} url action url
27314 * @cfg {String} paramName default 'imageUpload'
27315 * @cfg {String} method default POST
27316 * @cfg {Boolean} loadMask (true|false) default true
27317 * @cfg {Boolean} loadingText default 'Loading...'
27320 * Create a new UploadCropbox
27321 * @param {Object} config The config object
27324 Roo.bootstrap.UploadCropbox = function(config){
27325 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27329 * @event beforeselectfile
27330 * Fire before select file
27331 * @param {Roo.bootstrap.UploadCropbox} this
27333 "beforeselectfile" : true,
27336 * Fire after initEvent
27337 * @param {Roo.bootstrap.UploadCropbox} this
27342 * Fire after initEvent
27343 * @param {Roo.bootstrap.UploadCropbox} this
27344 * @param {String} data
27349 * Fire when preparing the file data
27350 * @param {Roo.bootstrap.UploadCropbox} this
27351 * @param {Object} file
27356 * Fire when get exception
27357 * @param {Roo.bootstrap.UploadCropbox} this
27358 * @param {XMLHttpRequest} xhr
27360 "exception" : true,
27362 * @event beforeloadcanvas
27363 * Fire before load the canvas
27364 * @param {Roo.bootstrap.UploadCropbox} this
27365 * @param {String} src
27367 "beforeloadcanvas" : true,
27370 * Fire when trash image
27371 * @param {Roo.bootstrap.UploadCropbox} this
27376 * Fire when download the image
27377 * @param {Roo.bootstrap.UploadCropbox} this
27381 * @event footerbuttonclick
27382 * Fire when footerbuttonclick
27383 * @param {Roo.bootstrap.UploadCropbox} this
27384 * @param {String} type
27386 "footerbuttonclick" : true,
27390 * @param {Roo.bootstrap.UploadCropbox} this
27395 * Fire when rotate the image
27396 * @param {Roo.bootstrap.UploadCropbox} this
27397 * @param {String} pos
27402 * Fire when inspect the file
27403 * @param {Roo.bootstrap.UploadCropbox} this
27404 * @param {Object} file
27409 * Fire when xhr upload the file
27410 * @param {Roo.bootstrap.UploadCropbox} this
27411 * @param {Object} data
27416 * Fire when arrange the file data
27417 * @param {Roo.bootstrap.UploadCropbox} this
27418 * @param {Object} formData
27423 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27426 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27428 emptyText : 'Click to upload image',
27429 rotateNotify : 'Image is too small to rotate',
27430 errorTimeout : 3000,
27444 cropType : 'image/jpeg',
27446 canvasLoaded : false,
27447 isDocument : false,
27449 paramName : 'imageUpload',
27451 loadingText : 'Loading...',
27454 getAutoCreate : function()
27458 cls : 'roo-upload-cropbox',
27462 cls : 'roo-upload-cropbox-selector',
27467 cls : 'roo-upload-cropbox-body',
27468 style : 'cursor:pointer',
27472 cls : 'roo-upload-cropbox-preview'
27476 cls : 'roo-upload-cropbox-thumb'
27480 cls : 'roo-upload-cropbox-empty-notify',
27481 html : this.emptyText
27485 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27486 html : this.rotateNotify
27492 cls : 'roo-upload-cropbox-footer',
27495 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27505 onRender : function(ct, position)
27507 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27509 if (this.buttons.length) {
27511 Roo.each(this.buttons, function(bb) {
27513 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27515 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27521 this.maskEl = this.el;
27525 initEvents : function()
27527 this.urlAPI = (window.createObjectURL && window) ||
27528 (window.URL && URL.revokeObjectURL && URL) ||
27529 (window.webkitURL && webkitURL);
27531 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27532 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27534 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27535 this.selectorEl.hide();
27537 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27538 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27540 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27541 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27542 this.thumbEl.hide();
27544 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27545 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27547 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27548 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27549 this.errorEl.hide();
27551 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27552 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27553 this.footerEl.hide();
27555 this.setThumbBoxSize();
27561 this.fireEvent('initial', this);
27568 window.addEventListener("resize", function() { _this.resize(); } );
27570 this.bodyEl.on('click', this.beforeSelectFile, this);
27573 this.bodyEl.on('touchstart', this.onTouchStart, this);
27574 this.bodyEl.on('touchmove', this.onTouchMove, this);
27575 this.bodyEl.on('touchend', this.onTouchEnd, this);
27579 this.bodyEl.on('mousedown', this.onMouseDown, this);
27580 this.bodyEl.on('mousemove', this.onMouseMove, this);
27581 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27582 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27583 Roo.get(document).on('mouseup', this.onMouseUp, this);
27586 this.selectorEl.on('change', this.onFileSelected, this);
27592 this.baseScale = 1;
27594 this.baseRotate = 1;
27595 this.dragable = false;
27596 this.pinching = false;
27599 this.cropData = false;
27600 this.notifyEl.dom.innerHTML = this.emptyText;
27602 this.selectorEl.dom.value = '';
27606 resize : function()
27608 if(this.fireEvent('resize', this) != false){
27609 this.setThumbBoxPosition();
27610 this.setCanvasPosition();
27614 onFooterButtonClick : function(e, el, o, type)
27617 case 'rotate-left' :
27618 this.onRotateLeft(e);
27620 case 'rotate-right' :
27621 this.onRotateRight(e);
27624 this.beforeSelectFile(e);
27639 this.fireEvent('footerbuttonclick', this, type);
27642 beforeSelectFile : function(e)
27644 e.preventDefault();
27646 if(this.fireEvent('beforeselectfile', this) != false){
27647 this.selectorEl.dom.click();
27651 onFileSelected : function(e)
27653 e.preventDefault();
27655 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27659 var file = this.selectorEl.dom.files[0];
27661 if(this.fireEvent('inspect', this, file) != false){
27662 this.prepare(file);
27667 trash : function(e)
27669 this.fireEvent('trash', this);
27672 download : function(e)
27674 this.fireEvent('download', this);
27677 loadCanvas : function(src)
27679 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27683 this.imageEl = document.createElement('img');
27687 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27689 this.imageEl.src = src;
27693 onLoadCanvas : function()
27695 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27696 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27698 this.bodyEl.un('click', this.beforeSelectFile, this);
27700 this.notifyEl.hide();
27701 this.thumbEl.show();
27702 this.footerEl.show();
27704 this.baseRotateLevel();
27706 if(this.isDocument){
27707 this.setThumbBoxSize();
27710 this.setThumbBoxPosition();
27712 this.baseScaleLevel();
27718 this.canvasLoaded = true;
27721 this.maskEl.unmask();
27726 setCanvasPosition : function()
27728 if(!this.canvasEl){
27732 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27733 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27735 this.previewEl.setLeft(pw);
27736 this.previewEl.setTop(ph);
27740 onMouseDown : function(e)
27744 this.dragable = true;
27745 this.pinching = false;
27747 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27748 this.dragable = false;
27752 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27753 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27757 onMouseMove : function(e)
27761 if(!this.canvasLoaded){
27765 if (!this.dragable){
27769 var minX = Math.ceil(this.thumbEl.getLeft(true));
27770 var minY = Math.ceil(this.thumbEl.getTop(true));
27772 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27773 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27775 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27776 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27778 x = x - this.mouseX;
27779 y = y - this.mouseY;
27781 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27782 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27784 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27785 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27787 this.previewEl.setLeft(bgX);
27788 this.previewEl.setTop(bgY);
27790 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27791 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27794 onMouseUp : function(e)
27798 this.dragable = false;
27801 onMouseWheel : function(e)
27805 this.startScale = this.scale;
27807 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27809 if(!this.zoomable()){
27810 this.scale = this.startScale;
27819 zoomable : function()
27821 var minScale = this.thumbEl.getWidth() / this.minWidth;
27823 if(this.minWidth < this.minHeight){
27824 minScale = this.thumbEl.getHeight() / this.minHeight;
27827 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27828 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27832 (this.rotate == 0 || this.rotate == 180) &&
27834 width > this.imageEl.OriginWidth ||
27835 height > this.imageEl.OriginHeight ||
27836 (width < this.minWidth && height < this.minHeight)
27844 (this.rotate == 90 || this.rotate == 270) &&
27846 width > this.imageEl.OriginWidth ||
27847 height > this.imageEl.OriginHeight ||
27848 (width < this.minHeight && height < this.minWidth)
27855 !this.isDocument &&
27856 (this.rotate == 0 || this.rotate == 180) &&
27858 width < this.minWidth ||
27859 width > this.imageEl.OriginWidth ||
27860 height < this.minHeight ||
27861 height > this.imageEl.OriginHeight
27868 !this.isDocument &&
27869 (this.rotate == 90 || this.rotate == 270) &&
27871 width < this.minHeight ||
27872 width > this.imageEl.OriginWidth ||
27873 height < this.minWidth ||
27874 height > this.imageEl.OriginHeight
27884 onRotateLeft : function(e)
27886 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27888 var minScale = this.thumbEl.getWidth() / this.minWidth;
27890 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27891 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27893 this.startScale = this.scale;
27895 while (this.getScaleLevel() < minScale){
27897 this.scale = this.scale + 1;
27899 if(!this.zoomable()){
27904 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27905 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27910 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27917 this.scale = this.startScale;
27919 this.onRotateFail();
27924 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27926 if(this.isDocument){
27927 this.setThumbBoxSize();
27928 this.setThumbBoxPosition();
27929 this.setCanvasPosition();
27934 this.fireEvent('rotate', this, 'left');
27938 onRotateRight : function(e)
27940 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27942 var minScale = this.thumbEl.getWidth() / this.minWidth;
27944 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27945 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27947 this.startScale = this.scale;
27949 while (this.getScaleLevel() < minScale){
27951 this.scale = this.scale + 1;
27953 if(!this.zoomable()){
27958 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27959 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27964 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27971 this.scale = this.startScale;
27973 this.onRotateFail();
27978 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27980 if(this.isDocument){
27981 this.setThumbBoxSize();
27982 this.setThumbBoxPosition();
27983 this.setCanvasPosition();
27988 this.fireEvent('rotate', this, 'right');
27991 onRotateFail : function()
27993 this.errorEl.show(true);
27997 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28002 this.previewEl.dom.innerHTML = '';
28004 var canvasEl = document.createElement("canvas");
28006 var contextEl = canvasEl.getContext("2d");
28008 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28009 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28010 var center = this.imageEl.OriginWidth / 2;
28012 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28013 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28014 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28015 center = this.imageEl.OriginHeight / 2;
28018 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28020 contextEl.translate(center, center);
28021 contextEl.rotate(this.rotate * Math.PI / 180);
28023 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28025 this.canvasEl = document.createElement("canvas");
28027 this.contextEl = this.canvasEl.getContext("2d");
28029 switch (this.rotate) {
28032 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28033 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28035 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28040 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28041 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28043 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28044 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);
28048 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28053 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28054 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28056 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28057 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);
28061 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);
28066 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28067 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28069 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28070 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28074 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);
28081 this.previewEl.appendChild(this.canvasEl);
28083 this.setCanvasPosition();
28088 if(!this.canvasLoaded){
28092 var imageCanvas = document.createElement("canvas");
28094 var imageContext = imageCanvas.getContext("2d");
28096 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28097 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28099 var center = imageCanvas.width / 2;
28101 imageContext.translate(center, center);
28103 imageContext.rotate(this.rotate * Math.PI / 180);
28105 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28107 var canvas = document.createElement("canvas");
28109 var context = canvas.getContext("2d");
28111 canvas.width = this.minWidth;
28112 canvas.height = this.minHeight;
28114 switch (this.rotate) {
28117 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28118 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28120 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28121 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28123 var targetWidth = this.minWidth - 2 * x;
28124 var targetHeight = this.minHeight - 2 * y;
28128 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28129 scale = targetWidth / width;
28132 if(x > 0 && y == 0){
28133 scale = targetHeight / height;
28136 if(x > 0 && y > 0){
28137 scale = targetWidth / width;
28139 if(width < height){
28140 scale = targetHeight / height;
28144 context.scale(scale, scale);
28146 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28147 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28149 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28150 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28152 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28157 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28158 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28160 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28161 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28163 var targetWidth = this.minWidth - 2 * x;
28164 var targetHeight = this.minHeight - 2 * y;
28168 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28169 scale = targetWidth / width;
28172 if(x > 0 && y == 0){
28173 scale = targetHeight / height;
28176 if(x > 0 && y > 0){
28177 scale = targetWidth / width;
28179 if(width < height){
28180 scale = targetHeight / height;
28184 context.scale(scale, scale);
28186 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28187 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28189 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28190 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28192 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28194 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28199 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28200 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28202 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28203 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28205 var targetWidth = this.minWidth - 2 * x;
28206 var targetHeight = this.minHeight - 2 * y;
28210 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28211 scale = targetWidth / width;
28214 if(x > 0 && y == 0){
28215 scale = targetHeight / height;
28218 if(x > 0 && y > 0){
28219 scale = targetWidth / width;
28221 if(width < height){
28222 scale = targetHeight / height;
28226 context.scale(scale, scale);
28228 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28229 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28231 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28232 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28234 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28235 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28237 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28242 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28243 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28245 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28246 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28248 var targetWidth = this.minWidth - 2 * x;
28249 var targetHeight = this.minHeight - 2 * y;
28253 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28254 scale = targetWidth / width;
28257 if(x > 0 && y == 0){
28258 scale = targetHeight / height;
28261 if(x > 0 && y > 0){
28262 scale = targetWidth / width;
28264 if(width < height){
28265 scale = targetHeight / height;
28269 context.scale(scale, scale);
28271 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28272 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28274 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28275 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28277 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28279 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28286 this.cropData = canvas.toDataURL(this.cropType);
28288 if(this.fireEvent('crop', this, this.cropData) !== false){
28289 this.process(this.file, this.cropData);
28296 setThumbBoxSize : function()
28300 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28301 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28302 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28304 this.minWidth = width;
28305 this.minHeight = height;
28307 if(this.rotate == 90 || this.rotate == 270){
28308 this.minWidth = height;
28309 this.minHeight = width;
28314 width = Math.ceil(this.minWidth * height / this.minHeight);
28316 if(this.minWidth > this.minHeight){
28318 height = Math.ceil(this.minHeight * width / this.minWidth);
28321 this.thumbEl.setStyle({
28322 width : width + 'px',
28323 height : height + 'px'
28330 setThumbBoxPosition : function()
28332 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28333 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28335 this.thumbEl.setLeft(x);
28336 this.thumbEl.setTop(y);
28340 baseRotateLevel : function()
28342 this.baseRotate = 1;
28345 typeof(this.exif) != 'undefined' &&
28346 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28347 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28349 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28352 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28356 baseScaleLevel : function()
28360 if(this.isDocument){
28362 if(this.baseRotate == 6 || this.baseRotate == 8){
28364 height = this.thumbEl.getHeight();
28365 this.baseScale = height / this.imageEl.OriginWidth;
28367 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28368 width = this.thumbEl.getWidth();
28369 this.baseScale = width / this.imageEl.OriginHeight;
28375 height = this.thumbEl.getHeight();
28376 this.baseScale = height / this.imageEl.OriginHeight;
28378 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28379 width = this.thumbEl.getWidth();
28380 this.baseScale = width / this.imageEl.OriginWidth;
28386 if(this.baseRotate == 6 || this.baseRotate == 8){
28388 width = this.thumbEl.getHeight();
28389 this.baseScale = width / this.imageEl.OriginHeight;
28391 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28392 height = this.thumbEl.getWidth();
28393 this.baseScale = height / this.imageEl.OriginHeight;
28396 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28397 height = this.thumbEl.getWidth();
28398 this.baseScale = height / this.imageEl.OriginHeight;
28400 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28401 width = this.thumbEl.getHeight();
28402 this.baseScale = width / this.imageEl.OriginWidth;
28409 width = this.thumbEl.getWidth();
28410 this.baseScale = width / this.imageEl.OriginWidth;
28412 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28413 height = this.thumbEl.getHeight();
28414 this.baseScale = height / this.imageEl.OriginHeight;
28417 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28419 height = this.thumbEl.getHeight();
28420 this.baseScale = height / this.imageEl.OriginHeight;
28422 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28423 width = this.thumbEl.getWidth();
28424 this.baseScale = width / this.imageEl.OriginWidth;
28432 getScaleLevel : function()
28434 return this.baseScale * Math.pow(1.1, this.scale);
28437 onTouchStart : function(e)
28439 if(!this.canvasLoaded){
28440 this.beforeSelectFile(e);
28444 var touches = e.browserEvent.touches;
28450 if(touches.length == 1){
28451 this.onMouseDown(e);
28455 if(touches.length != 2){
28461 for(var i = 0, finger; finger = touches[i]; i++){
28462 coords.push(finger.pageX, finger.pageY);
28465 var x = Math.pow(coords[0] - coords[2], 2);
28466 var y = Math.pow(coords[1] - coords[3], 2);
28468 this.startDistance = Math.sqrt(x + y);
28470 this.startScale = this.scale;
28472 this.pinching = true;
28473 this.dragable = false;
28477 onTouchMove : function(e)
28479 if(!this.pinching && !this.dragable){
28483 var touches = e.browserEvent.touches;
28490 this.onMouseMove(e);
28496 for(var i = 0, finger; finger = touches[i]; i++){
28497 coords.push(finger.pageX, finger.pageY);
28500 var x = Math.pow(coords[0] - coords[2], 2);
28501 var y = Math.pow(coords[1] - coords[3], 2);
28503 this.endDistance = Math.sqrt(x + y);
28505 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28507 if(!this.zoomable()){
28508 this.scale = this.startScale;
28516 onTouchEnd : function(e)
28518 this.pinching = false;
28519 this.dragable = false;
28523 process : function(file, crop)
28526 this.maskEl.mask(this.loadingText);
28529 this.xhr = new XMLHttpRequest();
28531 file.xhr = this.xhr;
28533 this.xhr.open(this.method, this.url, true);
28536 "Accept": "application/json",
28537 "Cache-Control": "no-cache",
28538 "X-Requested-With": "XMLHttpRequest"
28541 for (var headerName in headers) {
28542 var headerValue = headers[headerName];
28544 this.xhr.setRequestHeader(headerName, headerValue);
28550 this.xhr.onload = function()
28552 _this.xhrOnLoad(_this.xhr);
28555 this.xhr.onerror = function()
28557 _this.xhrOnError(_this.xhr);
28560 var formData = new FormData();
28562 formData.append('returnHTML', 'NO');
28565 formData.append('crop', crop);
28568 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28569 formData.append(this.paramName, file, file.name);
28572 if(typeof(file.filename) != 'undefined'){
28573 formData.append('filename', file.filename);
28576 if(typeof(file.mimetype) != 'undefined'){
28577 formData.append('mimetype', file.mimetype);
28580 if(this.fireEvent('arrange', this, formData) != false){
28581 this.xhr.send(formData);
28585 xhrOnLoad : function(xhr)
28588 this.maskEl.unmask();
28591 if (xhr.readyState !== 4) {
28592 this.fireEvent('exception', this, xhr);
28596 var response = Roo.decode(xhr.responseText);
28598 if(!response.success){
28599 this.fireEvent('exception', this, xhr);
28603 var response = Roo.decode(xhr.responseText);
28605 this.fireEvent('upload', this, response);
28609 xhrOnError : function()
28612 this.maskEl.unmask();
28615 Roo.log('xhr on error');
28617 var response = Roo.decode(xhr.responseText);
28623 prepare : function(file)
28626 this.maskEl.mask(this.loadingText);
28632 if(typeof(file) === 'string'){
28633 this.loadCanvas(file);
28637 if(!file || !this.urlAPI){
28642 this.cropType = file.type;
28646 if(this.fireEvent('prepare', this, this.file) != false){
28648 var reader = new FileReader();
28650 reader.onload = function (e) {
28651 if (e.target.error) {
28652 Roo.log(e.target.error);
28656 var buffer = e.target.result,
28657 dataView = new DataView(buffer),
28659 maxOffset = dataView.byteLength - 4,
28663 if (dataView.getUint16(0) === 0xffd8) {
28664 while (offset < maxOffset) {
28665 markerBytes = dataView.getUint16(offset);
28667 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28668 markerLength = dataView.getUint16(offset + 2) + 2;
28669 if (offset + markerLength > dataView.byteLength) {
28670 Roo.log('Invalid meta data: Invalid segment size.');
28674 if(markerBytes == 0xffe1){
28675 _this.parseExifData(
28682 offset += markerLength;
28692 var url = _this.urlAPI.createObjectURL(_this.file);
28694 _this.loadCanvas(url);
28699 reader.readAsArrayBuffer(this.file);
28705 parseExifData : function(dataView, offset, length)
28707 var tiffOffset = offset + 10,
28711 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28712 // No Exif data, might be XMP data instead
28716 // Check for the ASCII code for "Exif" (0x45786966):
28717 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28718 // No Exif data, might be XMP data instead
28721 if (tiffOffset + 8 > dataView.byteLength) {
28722 Roo.log('Invalid Exif data: Invalid segment size.');
28725 // Check for the two null bytes:
28726 if (dataView.getUint16(offset + 8) !== 0x0000) {
28727 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28730 // Check the byte alignment:
28731 switch (dataView.getUint16(tiffOffset)) {
28733 littleEndian = true;
28736 littleEndian = false;
28739 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28742 // Check for the TIFF tag marker (0x002A):
28743 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28744 Roo.log('Invalid Exif data: Missing TIFF marker.');
28747 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28748 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28750 this.parseExifTags(
28753 tiffOffset + dirOffset,
28758 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28763 if (dirOffset + 6 > dataView.byteLength) {
28764 Roo.log('Invalid Exif data: Invalid directory offset.');
28767 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28768 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28769 if (dirEndOffset + 4 > dataView.byteLength) {
28770 Roo.log('Invalid Exif data: Invalid directory size.');
28773 for (i = 0; i < tagsNumber; i += 1) {
28777 dirOffset + 2 + 12 * i, // tag offset
28781 // Return the offset to the next directory:
28782 return dataView.getUint32(dirEndOffset, littleEndian);
28785 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28787 var tag = dataView.getUint16(offset, littleEndian);
28789 this.exif[tag] = this.getExifValue(
28793 dataView.getUint16(offset + 2, littleEndian), // tag type
28794 dataView.getUint32(offset + 4, littleEndian), // tag length
28799 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28801 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28810 Roo.log('Invalid Exif data: Invalid tag type.');
28814 tagSize = tagType.size * length;
28815 // Determine if the value is contained in the dataOffset bytes,
28816 // or if the value at the dataOffset is a pointer to the actual data:
28817 dataOffset = tagSize > 4 ?
28818 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28819 if (dataOffset + tagSize > dataView.byteLength) {
28820 Roo.log('Invalid Exif data: Invalid data offset.');
28823 if (length === 1) {
28824 return tagType.getValue(dataView, dataOffset, littleEndian);
28827 for (i = 0; i < length; i += 1) {
28828 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28831 if (tagType.ascii) {
28833 // Concatenate the chars:
28834 for (i = 0; i < values.length; i += 1) {
28836 // Ignore the terminating NULL byte(s):
28837 if (c === '\u0000') {
28849 Roo.apply(Roo.bootstrap.UploadCropbox, {
28851 'Orientation': 0x0112
28855 1: 0, //'top-left',
28857 3: 180, //'bottom-right',
28858 // 4: 'bottom-left',
28860 6: 90, //'right-top',
28861 // 7: 'right-bottom',
28862 8: 270 //'left-bottom'
28866 // byte, 8-bit unsigned int:
28868 getValue: function (dataView, dataOffset) {
28869 return dataView.getUint8(dataOffset);
28873 // ascii, 8-bit byte:
28875 getValue: function (dataView, dataOffset) {
28876 return String.fromCharCode(dataView.getUint8(dataOffset));
28881 // short, 16 bit int:
28883 getValue: function (dataView, dataOffset, littleEndian) {
28884 return dataView.getUint16(dataOffset, littleEndian);
28888 // long, 32 bit int:
28890 getValue: function (dataView, dataOffset, littleEndian) {
28891 return dataView.getUint32(dataOffset, littleEndian);
28895 // rational = two long values, first is numerator, second is denominator:
28897 getValue: function (dataView, dataOffset, littleEndian) {
28898 return dataView.getUint32(dataOffset, littleEndian) /
28899 dataView.getUint32(dataOffset + 4, littleEndian);
28903 // slong, 32 bit signed int:
28905 getValue: function (dataView, dataOffset, littleEndian) {
28906 return dataView.getInt32(dataOffset, littleEndian);
28910 // srational, two slongs, first is numerator, second is denominator:
28912 getValue: function (dataView, dataOffset, littleEndian) {
28913 return dataView.getInt32(dataOffset, littleEndian) /
28914 dataView.getInt32(dataOffset + 4, littleEndian);
28924 cls : 'btn-group roo-upload-cropbox-rotate-left',
28925 action : 'rotate-left',
28929 cls : 'btn btn-default',
28930 html : '<i class="fa fa-undo"></i>'
28936 cls : 'btn-group roo-upload-cropbox-picture',
28937 action : 'picture',
28941 cls : 'btn btn-default',
28942 html : '<i class="fa fa-picture-o"></i>'
28948 cls : 'btn-group roo-upload-cropbox-rotate-right',
28949 action : 'rotate-right',
28953 cls : 'btn btn-default',
28954 html : '<i class="fa fa-repeat"></i>'
28962 cls : 'btn-group roo-upload-cropbox-rotate-left',
28963 action : 'rotate-left',
28967 cls : 'btn btn-default',
28968 html : '<i class="fa fa-undo"></i>'
28974 cls : 'btn-group roo-upload-cropbox-download',
28975 action : 'download',
28979 cls : 'btn btn-default',
28980 html : '<i class="fa fa-download"></i>'
28986 cls : 'btn-group roo-upload-cropbox-crop',
28991 cls : 'btn btn-default',
28992 html : '<i class="fa fa-crop"></i>'
28998 cls : 'btn-group roo-upload-cropbox-trash',
29003 cls : 'btn btn-default',
29004 html : '<i class="fa fa-trash"></i>'
29010 cls : 'btn-group roo-upload-cropbox-rotate-right',
29011 action : 'rotate-right',
29015 cls : 'btn btn-default',
29016 html : '<i class="fa fa-repeat"></i>'
29024 cls : 'btn-group roo-upload-cropbox-rotate-left',
29025 action : 'rotate-left',
29029 cls : 'btn btn-default',
29030 html : '<i class="fa fa-undo"></i>'
29036 cls : 'btn-group roo-upload-cropbox-rotate-right',
29037 action : 'rotate-right',
29041 cls : 'btn btn-default',
29042 html : '<i class="fa fa-repeat"></i>'
29055 * @class Roo.bootstrap.DocumentManager
29056 * @extends Roo.bootstrap.Component
29057 * Bootstrap DocumentManager class
29058 * @cfg {String} paramName default 'imageUpload'
29059 * @cfg {String} toolTipName default 'filename'
29060 * @cfg {String} method default POST
29061 * @cfg {String} url action url
29062 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29063 * @cfg {Boolean} multiple multiple upload default true
29064 * @cfg {Number} thumbSize default 300
29065 * @cfg {String} fieldLabel
29066 * @cfg {Number} labelWidth default 4
29067 * @cfg {String} labelAlign (left|top) default left
29068 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29069 * @cfg {Number} labellg set the width of label (1-12)
29070 * @cfg {Number} labelmd set the width of label (1-12)
29071 * @cfg {Number} labelsm set the width of label (1-12)
29072 * @cfg {Number} labelxs set the width of label (1-12)
29075 * Create a new DocumentManager
29076 * @param {Object} config The config object
29079 Roo.bootstrap.DocumentManager = function(config){
29080 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29083 this.delegates = [];
29088 * Fire when initial the DocumentManager
29089 * @param {Roo.bootstrap.DocumentManager} this
29094 * inspect selected file
29095 * @param {Roo.bootstrap.DocumentManager} this
29096 * @param {File} file
29101 * Fire when xhr load exception
29102 * @param {Roo.bootstrap.DocumentManager} this
29103 * @param {XMLHttpRequest} xhr
29105 "exception" : true,
29107 * @event afterupload
29108 * Fire when xhr load exception
29109 * @param {Roo.bootstrap.DocumentManager} this
29110 * @param {XMLHttpRequest} xhr
29112 "afterupload" : true,
29115 * prepare the form data
29116 * @param {Roo.bootstrap.DocumentManager} this
29117 * @param {Object} formData
29122 * Fire when remove the file
29123 * @param {Roo.bootstrap.DocumentManager} this
29124 * @param {Object} file
29129 * Fire after refresh the file
29130 * @param {Roo.bootstrap.DocumentManager} this
29135 * Fire after click the image
29136 * @param {Roo.bootstrap.DocumentManager} this
29137 * @param {Object} file
29142 * Fire when upload a image and editable set to true
29143 * @param {Roo.bootstrap.DocumentManager} this
29144 * @param {Object} file
29148 * @event beforeselectfile
29149 * Fire before select file
29150 * @param {Roo.bootstrap.DocumentManager} this
29152 "beforeselectfile" : true,
29155 * Fire before process file
29156 * @param {Roo.bootstrap.DocumentManager} this
29157 * @param {Object} file
29161 * @event previewrendered
29162 * Fire when preview rendered
29163 * @param {Roo.bootstrap.DocumentManager} this
29164 * @param {Object} file
29166 "previewrendered" : true,
29169 "previewResize" : true
29174 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29183 paramName : 'imageUpload',
29184 toolTipName : 'filename',
29187 labelAlign : 'left',
29197 getAutoCreate : function()
29199 var managerWidget = {
29201 cls : 'roo-document-manager',
29205 cls : 'roo-document-manager-selector',
29210 cls : 'roo-document-manager-uploader',
29214 cls : 'roo-document-manager-upload-btn',
29215 html : '<i class="fa fa-plus"></i>'
29226 cls : 'column col-md-12',
29231 if(this.fieldLabel.length){
29236 cls : 'column col-md-12',
29237 html : this.fieldLabel
29241 cls : 'column col-md-12',
29246 if(this.labelAlign == 'left'){
29251 html : this.fieldLabel
29260 if(this.labelWidth > 12){
29261 content[0].style = "width: " + this.labelWidth + 'px';
29264 if(this.labelWidth < 13 && this.labelmd == 0){
29265 this.labelmd = this.labelWidth;
29268 if(this.labellg > 0){
29269 content[0].cls += ' col-lg-' + this.labellg;
29270 content[1].cls += ' col-lg-' + (12 - this.labellg);
29273 if(this.labelmd > 0){
29274 content[0].cls += ' col-md-' + this.labelmd;
29275 content[1].cls += ' col-md-' + (12 - this.labelmd);
29278 if(this.labelsm > 0){
29279 content[0].cls += ' col-sm-' + this.labelsm;
29280 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29283 if(this.labelxs > 0){
29284 content[0].cls += ' col-xs-' + this.labelxs;
29285 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29293 cls : 'row clearfix',
29301 initEvents : function()
29303 this.managerEl = this.el.select('.roo-document-manager', true).first();
29304 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29306 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29307 this.selectorEl.hide();
29310 this.selectorEl.attr('multiple', 'multiple');
29313 this.selectorEl.on('change', this.onFileSelected, this);
29315 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29316 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29318 this.uploader.on('click', this.onUploaderClick, this);
29320 this.renderProgressDialog();
29324 window.addEventListener("resize", function() { _this.refresh(); } );
29326 this.fireEvent('initial', this);
29329 renderProgressDialog : function()
29333 this.progressDialog = new Roo.bootstrap.Modal({
29334 cls : 'roo-document-manager-progress-dialog',
29335 allow_close : false,
29346 btnclick : function() {
29347 _this.uploadCancel();
29353 this.progressDialog.render(Roo.get(document.body));
29355 this.progress = new Roo.bootstrap.Progress({
29356 cls : 'roo-document-manager-progress',
29361 this.progress.render(this.progressDialog.getChildContainer());
29363 this.progressBar = new Roo.bootstrap.ProgressBar({
29364 cls : 'roo-document-manager-progress-bar',
29367 aria_valuemax : 12,
29371 this.progressBar.render(this.progress.getChildContainer());
29374 onUploaderClick : function(e)
29376 e.preventDefault();
29378 if(this.fireEvent('beforeselectfile', this) != false){
29379 this.selectorEl.dom.click();
29384 onFileSelected : function(e)
29386 e.preventDefault();
29388 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29392 Roo.each(this.selectorEl.dom.files, function(file){
29393 if(this.fireEvent('inspect', this, file) != false){
29394 this.files.push(file);
29404 this.selectorEl.dom.value = '';
29406 if(!this.files || !this.files.length){
29410 if(this.boxes > 0 && this.files.length > this.boxes){
29411 this.files = this.files.slice(0, this.boxes);
29414 this.uploader.show();
29416 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29417 this.uploader.hide();
29426 Roo.each(this.files, function(file){
29428 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29429 var f = this.renderPreview(file);
29434 if(file.type.indexOf('image') != -1){
29435 this.delegates.push(
29437 _this.process(file);
29438 }).createDelegate(this)
29446 _this.process(file);
29447 }).createDelegate(this)
29452 this.files = files;
29454 this.delegates = this.delegates.concat(docs);
29456 if(!this.delegates.length){
29461 this.progressBar.aria_valuemax = this.delegates.length;
29468 arrange : function()
29470 if(!this.delegates.length){
29471 this.progressDialog.hide();
29476 var delegate = this.delegates.shift();
29478 this.progressDialog.show();
29480 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29482 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29487 refresh : function()
29489 this.uploader.show();
29491 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29492 this.uploader.hide();
29495 Roo.isTouch ? this.closable(false) : this.closable(true);
29497 this.fireEvent('refresh', this);
29500 onRemove : function(e, el, o)
29502 e.preventDefault();
29504 this.fireEvent('remove', this, o);
29508 remove : function(o)
29512 Roo.each(this.files, function(file){
29513 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29522 this.files = files;
29529 Roo.each(this.files, function(file){
29534 file.target.remove();
29543 onClick : function(e, el, o)
29545 e.preventDefault();
29547 this.fireEvent('click', this, o);
29551 closable : function(closable)
29553 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29555 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29567 xhrOnLoad : function(xhr)
29569 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29573 if (xhr.readyState !== 4) {
29575 this.fireEvent('exception', this, xhr);
29579 var response = Roo.decode(xhr.responseText);
29581 if(!response.success){
29583 this.fireEvent('exception', this, xhr);
29587 var file = this.renderPreview(response.data);
29589 this.files.push(file);
29593 this.fireEvent('afterupload', this, xhr);
29597 xhrOnError : function(xhr)
29599 Roo.log('xhr on error');
29601 var response = Roo.decode(xhr.responseText);
29608 process : function(file)
29610 if(this.fireEvent('process', this, file) !== false){
29611 if(this.editable && file.type.indexOf('image') != -1){
29612 this.fireEvent('edit', this, file);
29616 this.uploadStart(file, false);
29623 uploadStart : function(file, crop)
29625 this.xhr = new XMLHttpRequest();
29627 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29632 file.xhr = this.xhr;
29634 this.managerEl.createChild({
29636 cls : 'roo-document-manager-loading',
29640 tooltip : file.name,
29641 cls : 'roo-document-manager-thumb',
29642 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29648 this.xhr.open(this.method, this.url, true);
29651 "Accept": "application/json",
29652 "Cache-Control": "no-cache",
29653 "X-Requested-With": "XMLHttpRequest"
29656 for (var headerName in headers) {
29657 var headerValue = headers[headerName];
29659 this.xhr.setRequestHeader(headerName, headerValue);
29665 this.xhr.onload = function()
29667 _this.xhrOnLoad(_this.xhr);
29670 this.xhr.onerror = function()
29672 _this.xhrOnError(_this.xhr);
29675 var formData = new FormData();
29677 formData.append('returnHTML', 'NO');
29680 formData.append('crop', crop);
29683 formData.append(this.paramName, file, file.name);
29690 if(this.fireEvent('prepare', this, formData, options) != false){
29692 if(options.manually){
29696 this.xhr.send(formData);
29700 this.uploadCancel();
29703 uploadCancel : function()
29709 this.delegates = [];
29711 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29718 renderPreview : function(file)
29720 if(typeof(file.target) != 'undefined' && file.target){
29724 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29726 var previewEl = this.managerEl.createChild({
29728 cls : 'roo-document-manager-preview',
29732 tooltip : file[this.toolTipName],
29733 cls : 'roo-document-manager-thumb',
29734 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29739 html : '<i class="fa fa-times-circle"></i>'
29744 var close = previewEl.select('button.close', true).first();
29746 close.on('click', this.onRemove, this, file);
29748 file.target = previewEl;
29750 var image = previewEl.select('img', true).first();
29754 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29756 image.on('click', this.onClick, this, file);
29758 this.fireEvent('previewrendered', this, file);
29764 onPreviewLoad : function(file, image)
29766 if(typeof(file.target) == 'undefined' || !file.target){
29770 var width = image.dom.naturalWidth || image.dom.width;
29771 var height = image.dom.naturalHeight || image.dom.height;
29773 if(!this.previewResize) {
29777 if(width > height){
29778 file.target.addClass('wide');
29782 file.target.addClass('tall');
29787 uploadFromSource : function(file, crop)
29789 this.xhr = new XMLHttpRequest();
29791 this.managerEl.createChild({
29793 cls : 'roo-document-manager-loading',
29797 tooltip : file.name,
29798 cls : 'roo-document-manager-thumb',
29799 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29805 this.xhr.open(this.method, this.url, true);
29808 "Accept": "application/json",
29809 "Cache-Control": "no-cache",
29810 "X-Requested-With": "XMLHttpRequest"
29813 for (var headerName in headers) {
29814 var headerValue = headers[headerName];
29816 this.xhr.setRequestHeader(headerName, headerValue);
29822 this.xhr.onload = function()
29824 _this.xhrOnLoad(_this.xhr);
29827 this.xhr.onerror = function()
29829 _this.xhrOnError(_this.xhr);
29832 var formData = new FormData();
29834 formData.append('returnHTML', 'NO');
29836 formData.append('crop', crop);
29838 if(typeof(file.filename) != 'undefined'){
29839 formData.append('filename', file.filename);
29842 if(typeof(file.mimetype) != 'undefined'){
29843 formData.append('mimetype', file.mimetype);
29848 if(this.fireEvent('prepare', this, formData) != false){
29849 this.xhr.send(formData);
29859 * @class Roo.bootstrap.DocumentViewer
29860 * @extends Roo.bootstrap.Component
29861 * Bootstrap DocumentViewer class
29862 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29863 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29866 * Create a new DocumentViewer
29867 * @param {Object} config The config object
29870 Roo.bootstrap.DocumentViewer = function(config){
29871 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29876 * Fire after initEvent
29877 * @param {Roo.bootstrap.DocumentViewer} this
29883 * @param {Roo.bootstrap.DocumentViewer} this
29888 * Fire after download button
29889 * @param {Roo.bootstrap.DocumentViewer} this
29894 * Fire after trash button
29895 * @param {Roo.bootstrap.DocumentViewer} this
29902 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29904 showDownload : true,
29908 getAutoCreate : function()
29912 cls : 'roo-document-viewer',
29916 cls : 'roo-document-viewer-body',
29920 cls : 'roo-document-viewer-thumb',
29924 cls : 'roo-document-viewer-image'
29932 cls : 'roo-document-viewer-footer',
29935 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29939 cls : 'btn-group roo-document-viewer-download',
29943 cls : 'btn btn-default',
29944 html : '<i class="fa fa-download"></i>'
29950 cls : 'btn-group roo-document-viewer-trash',
29954 cls : 'btn btn-default',
29955 html : '<i class="fa fa-trash"></i>'
29968 initEvents : function()
29970 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29971 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29973 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29974 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29976 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29977 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29979 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29980 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29982 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29983 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29985 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29986 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29988 this.bodyEl.on('click', this.onClick, this);
29989 this.downloadBtn.on('click', this.onDownload, this);
29990 this.trashBtn.on('click', this.onTrash, this);
29992 this.downloadBtn.hide();
29993 this.trashBtn.hide();
29995 if(this.showDownload){
29996 this.downloadBtn.show();
29999 if(this.showTrash){
30000 this.trashBtn.show();
30003 if(!this.showDownload && !this.showTrash) {
30004 this.footerEl.hide();
30009 initial : function()
30011 this.fireEvent('initial', this);
30015 onClick : function(e)
30017 e.preventDefault();
30019 this.fireEvent('click', this);
30022 onDownload : function(e)
30024 e.preventDefault();
30026 this.fireEvent('download', this);
30029 onTrash : function(e)
30031 e.preventDefault();
30033 this.fireEvent('trash', this);
30045 * @class Roo.bootstrap.NavProgressBar
30046 * @extends Roo.bootstrap.Component
30047 * Bootstrap NavProgressBar class
30050 * Create a new nav progress bar
30051 * @param {Object} config The config object
30054 Roo.bootstrap.NavProgressBar = function(config){
30055 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30057 this.bullets = this.bullets || [];
30059 // Roo.bootstrap.NavProgressBar.register(this);
30063 * Fires when the active item changes
30064 * @param {Roo.bootstrap.NavProgressBar} this
30065 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30066 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30073 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30078 getAutoCreate : function()
30080 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30084 cls : 'roo-navigation-bar-group',
30088 cls : 'roo-navigation-top-bar'
30092 cls : 'roo-navigation-bullets-bar',
30096 cls : 'roo-navigation-bar'
30103 cls : 'roo-navigation-bottom-bar'
30113 initEvents: function()
30118 onRender : function(ct, position)
30120 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30122 if(this.bullets.length){
30123 Roo.each(this.bullets, function(b){
30132 addItem : function(cfg)
30134 var item = new Roo.bootstrap.NavProgressItem(cfg);
30136 item.parentId = this.id;
30137 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30140 var top = new Roo.bootstrap.Element({
30142 cls : 'roo-navigation-bar-text'
30145 var bottom = new Roo.bootstrap.Element({
30147 cls : 'roo-navigation-bar-text'
30150 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30151 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30153 var topText = new Roo.bootstrap.Element({
30155 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30158 var bottomText = new Roo.bootstrap.Element({
30160 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30163 topText.onRender(top.el, null);
30164 bottomText.onRender(bottom.el, null);
30167 item.bottomEl = bottom;
30170 this.barItems.push(item);
30175 getActive : function()
30177 var active = false;
30179 Roo.each(this.barItems, function(v){
30181 if (!v.isActive()) {
30193 setActiveItem : function(item)
30197 Roo.each(this.barItems, function(v){
30198 if (v.rid == item.rid) {
30202 if (v.isActive()) {
30203 v.setActive(false);
30208 item.setActive(true);
30210 this.fireEvent('changed', this, item, prev);
30213 getBarItem: function(rid)
30217 Roo.each(this.barItems, function(e) {
30218 if (e.rid != rid) {
30229 indexOfItem : function(item)
30233 Roo.each(this.barItems, function(v, i){
30235 if (v.rid != item.rid) {
30246 setActiveNext : function()
30248 var i = this.indexOfItem(this.getActive());
30250 if (i > this.barItems.length) {
30254 this.setActiveItem(this.barItems[i+1]);
30257 setActivePrev : function()
30259 var i = this.indexOfItem(this.getActive());
30265 this.setActiveItem(this.barItems[i-1]);
30268 format : function()
30270 if(!this.barItems.length){
30274 var width = 100 / this.barItems.length;
30276 Roo.each(this.barItems, function(i){
30277 i.el.setStyle('width', width + '%');
30278 i.topEl.el.setStyle('width', width + '%');
30279 i.bottomEl.el.setStyle('width', width + '%');
30288 * Nav Progress Item
30293 * @class Roo.bootstrap.NavProgressItem
30294 * @extends Roo.bootstrap.Component
30295 * Bootstrap NavProgressItem class
30296 * @cfg {String} rid the reference id
30297 * @cfg {Boolean} active (true|false) Is item active default false
30298 * @cfg {Boolean} disabled (true|false) Is item active default false
30299 * @cfg {String} html
30300 * @cfg {String} position (top|bottom) text position default bottom
30301 * @cfg {String} icon show icon instead of number
30304 * Create a new NavProgressItem
30305 * @param {Object} config The config object
30307 Roo.bootstrap.NavProgressItem = function(config){
30308 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30313 * The raw click event for the entire grid.
30314 * @param {Roo.bootstrap.NavProgressItem} this
30315 * @param {Roo.EventObject} e
30322 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30328 position : 'bottom',
30331 getAutoCreate : function()
30333 var iconCls = 'roo-navigation-bar-item-icon';
30335 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30339 cls: 'roo-navigation-bar-item',
30349 cfg.cls += ' active';
30352 cfg.cls += ' disabled';
30358 disable : function()
30360 this.setDisabled(true);
30363 enable : function()
30365 this.setDisabled(false);
30368 initEvents: function()
30370 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30372 this.iconEl.on('click', this.onClick, this);
30375 onClick : function(e)
30377 e.preventDefault();
30383 if(this.fireEvent('click', this, e) === false){
30387 this.parent().setActiveItem(this);
30390 isActive: function ()
30392 return this.active;
30395 setActive : function(state)
30397 if(this.active == state){
30401 this.active = state;
30404 this.el.addClass('active');
30408 this.el.removeClass('active');
30413 setDisabled : function(state)
30415 if(this.disabled == state){
30419 this.disabled = state;
30422 this.el.addClass('disabled');
30426 this.el.removeClass('disabled');
30429 tooltipEl : function()
30431 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30444 * @class Roo.bootstrap.FieldLabel
30445 * @extends Roo.bootstrap.Component
30446 * Bootstrap FieldLabel class
30447 * @cfg {String} html contents of the element
30448 * @cfg {String} tag tag of the element default label
30449 * @cfg {String} cls class of the element
30450 * @cfg {String} target label target
30451 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30452 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30453 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30454 * @cfg {String} iconTooltip default "This field is required"
30455 * @cfg {String} indicatorpos (left|right) default left
30458 * Create a new FieldLabel
30459 * @param {Object} config The config object
30462 Roo.bootstrap.FieldLabel = function(config){
30463 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30468 * Fires after the field has been marked as invalid.
30469 * @param {Roo.form.FieldLabel} this
30470 * @param {String} msg The validation message
30475 * Fires after the field has been validated with no errors.
30476 * @param {Roo.form.FieldLabel} this
30482 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30489 invalidClass : 'has-warning',
30490 validClass : 'has-success',
30491 iconTooltip : 'This field is required',
30492 indicatorpos : 'left',
30494 getAutoCreate : function(){
30497 if (!this.allowBlank) {
30503 cls : 'roo-bootstrap-field-label ' + this.cls,
30508 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30509 tooltip : this.iconTooltip
30518 if(this.indicatorpos == 'right'){
30521 cls : 'roo-bootstrap-field-label ' + this.cls,
30530 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30531 tooltip : this.iconTooltip
30540 initEvents: function()
30542 Roo.bootstrap.Element.superclass.initEvents.call(this);
30544 this.indicator = this.indicatorEl();
30546 if(this.indicator){
30547 this.indicator.removeClass('visible');
30548 this.indicator.addClass('invisible');
30551 Roo.bootstrap.FieldLabel.register(this);
30554 indicatorEl : function()
30556 var indicator = this.el.select('i.roo-required-indicator',true).first();
30567 * Mark this field as valid
30569 markValid : function()
30571 if(this.indicator){
30572 this.indicator.removeClass('visible');
30573 this.indicator.addClass('invisible');
30575 if (Roo.bootstrap.version == 3) {
30576 this.el.removeClass(this.invalidClass);
30577 this.el.addClass(this.validClass);
30579 this.el.removeClass('is-invalid');
30580 this.el.addClass('is-valid');
30584 this.fireEvent('valid', this);
30588 * Mark this field as invalid
30589 * @param {String} msg The validation message
30591 markInvalid : function(msg)
30593 if(this.indicator){
30594 this.indicator.removeClass('invisible');
30595 this.indicator.addClass('visible');
30597 if (Roo.bootstrap.version == 3) {
30598 this.el.removeClass(this.validClass);
30599 this.el.addClass(this.invalidClass);
30601 this.el.removeClass('is-valid');
30602 this.el.addClass('is-invalid');
30606 this.fireEvent('invalid', this, msg);
30612 Roo.apply(Roo.bootstrap.FieldLabel, {
30617 * register a FieldLabel Group
30618 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30620 register : function(label)
30622 if(this.groups.hasOwnProperty(label.target)){
30626 this.groups[label.target] = label;
30630 * fetch a FieldLabel Group based on the target
30631 * @param {string} target
30632 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30634 get: function(target) {
30635 if (typeof(this.groups[target]) == 'undefined') {
30639 return this.groups[target] ;
30648 * page DateSplitField.
30654 * @class Roo.bootstrap.DateSplitField
30655 * @extends Roo.bootstrap.Component
30656 * Bootstrap DateSplitField class
30657 * @cfg {string} fieldLabel - the label associated
30658 * @cfg {Number} labelWidth set the width of label (0-12)
30659 * @cfg {String} labelAlign (top|left)
30660 * @cfg {Boolean} dayAllowBlank (true|false) default false
30661 * @cfg {Boolean} monthAllowBlank (true|false) default false
30662 * @cfg {Boolean} yearAllowBlank (true|false) default false
30663 * @cfg {string} dayPlaceholder
30664 * @cfg {string} monthPlaceholder
30665 * @cfg {string} yearPlaceholder
30666 * @cfg {string} dayFormat default 'd'
30667 * @cfg {string} monthFormat default 'm'
30668 * @cfg {string} yearFormat default 'Y'
30669 * @cfg {Number} labellg set the width of label (1-12)
30670 * @cfg {Number} labelmd set the width of label (1-12)
30671 * @cfg {Number} labelsm set the width of label (1-12)
30672 * @cfg {Number} labelxs set the width of label (1-12)
30676 * Create a new DateSplitField
30677 * @param {Object} config The config object
30680 Roo.bootstrap.DateSplitField = function(config){
30681 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30687 * getting the data of years
30688 * @param {Roo.bootstrap.DateSplitField} this
30689 * @param {Object} years
30694 * getting the data of days
30695 * @param {Roo.bootstrap.DateSplitField} this
30696 * @param {Object} days
30701 * Fires after the field has been marked as invalid.
30702 * @param {Roo.form.Field} this
30703 * @param {String} msg The validation message
30708 * Fires after the field has been validated with no errors.
30709 * @param {Roo.form.Field} this
30715 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30718 labelAlign : 'top',
30720 dayAllowBlank : false,
30721 monthAllowBlank : false,
30722 yearAllowBlank : false,
30723 dayPlaceholder : '',
30724 monthPlaceholder : '',
30725 yearPlaceholder : '',
30729 isFormField : true,
30735 getAutoCreate : function()
30739 cls : 'row roo-date-split-field-group',
30744 cls : 'form-hidden-field roo-date-split-field-group-value',
30750 var labelCls = 'col-md-12';
30751 var contentCls = 'col-md-4';
30753 if(this.fieldLabel){
30757 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30761 html : this.fieldLabel
30766 if(this.labelAlign == 'left'){
30768 if(this.labelWidth > 12){
30769 label.style = "width: " + this.labelWidth + 'px';
30772 if(this.labelWidth < 13 && this.labelmd == 0){
30773 this.labelmd = this.labelWidth;
30776 if(this.labellg > 0){
30777 labelCls = ' col-lg-' + this.labellg;
30778 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30781 if(this.labelmd > 0){
30782 labelCls = ' col-md-' + this.labelmd;
30783 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30786 if(this.labelsm > 0){
30787 labelCls = ' col-sm-' + this.labelsm;
30788 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30791 if(this.labelxs > 0){
30792 labelCls = ' col-xs-' + this.labelxs;
30793 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30797 label.cls += ' ' + labelCls;
30799 cfg.cn.push(label);
30802 Roo.each(['day', 'month', 'year'], function(t){
30805 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30812 inputEl: function ()
30814 return this.el.select('.roo-date-split-field-group-value', true).first();
30817 onRender : function(ct, position)
30821 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30823 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30825 this.dayField = new Roo.bootstrap.ComboBox({
30826 allowBlank : this.dayAllowBlank,
30827 alwaysQuery : true,
30828 displayField : 'value',
30831 forceSelection : true,
30833 placeholder : this.dayPlaceholder,
30834 selectOnFocus : true,
30835 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30836 triggerAction : 'all',
30838 valueField : 'value',
30839 store : new Roo.data.SimpleStore({
30840 data : (function() {
30842 _this.fireEvent('days', _this, days);
30845 fields : [ 'value' ]
30848 select : function (_self, record, index)
30850 _this.setValue(_this.getValue());
30855 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30857 this.monthField = new Roo.bootstrap.MonthField({
30858 after : '<i class=\"fa fa-calendar\"></i>',
30859 allowBlank : this.monthAllowBlank,
30860 placeholder : this.monthPlaceholder,
30863 render : function (_self)
30865 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30866 e.preventDefault();
30870 select : function (_self, oldvalue, newvalue)
30872 _this.setValue(_this.getValue());
30877 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30879 this.yearField = new Roo.bootstrap.ComboBox({
30880 allowBlank : this.yearAllowBlank,
30881 alwaysQuery : true,
30882 displayField : 'value',
30885 forceSelection : true,
30887 placeholder : this.yearPlaceholder,
30888 selectOnFocus : true,
30889 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30890 triggerAction : 'all',
30892 valueField : 'value',
30893 store : new Roo.data.SimpleStore({
30894 data : (function() {
30896 _this.fireEvent('years', _this, years);
30899 fields : [ 'value' ]
30902 select : function (_self, record, index)
30904 _this.setValue(_this.getValue());
30909 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30912 setValue : function(v, format)
30914 this.inputEl.dom.value = v;
30916 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30918 var d = Date.parseDate(v, f);
30925 this.setDay(d.format(this.dayFormat));
30926 this.setMonth(d.format(this.monthFormat));
30927 this.setYear(d.format(this.yearFormat));
30934 setDay : function(v)
30936 this.dayField.setValue(v);
30937 this.inputEl.dom.value = this.getValue();
30942 setMonth : function(v)
30944 this.monthField.setValue(v, true);
30945 this.inputEl.dom.value = this.getValue();
30950 setYear : function(v)
30952 this.yearField.setValue(v);
30953 this.inputEl.dom.value = this.getValue();
30958 getDay : function()
30960 return this.dayField.getValue();
30963 getMonth : function()
30965 return this.monthField.getValue();
30968 getYear : function()
30970 return this.yearField.getValue();
30973 getValue : function()
30975 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30977 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30987 this.inputEl.dom.value = '';
30992 validate : function()
30994 var d = this.dayField.validate();
30995 var m = this.monthField.validate();
30996 var y = this.yearField.validate();
31001 (!this.dayAllowBlank && !d) ||
31002 (!this.monthAllowBlank && !m) ||
31003 (!this.yearAllowBlank && !y)
31008 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31017 this.markInvalid();
31022 markValid : function()
31025 var label = this.el.select('label', true).first();
31026 var icon = this.el.select('i.fa-star', true).first();
31032 this.fireEvent('valid', this);
31036 * Mark this field as invalid
31037 * @param {String} msg The validation message
31039 markInvalid : function(msg)
31042 var label = this.el.select('label', true).first();
31043 var icon = this.el.select('i.fa-star', true).first();
31045 if(label && !icon){
31046 this.el.select('.roo-date-split-field-label', true).createChild({
31048 cls : 'text-danger fa fa-lg fa-star',
31049 tooltip : 'This field is required',
31050 style : 'margin-right:5px;'
31054 this.fireEvent('invalid', this, msg);
31057 clearInvalid : function()
31059 var label = this.el.select('label', true).first();
31060 var icon = this.el.select('i.fa-star', true).first();
31066 this.fireEvent('valid', this);
31069 getName: function()
31079 * http://masonry.desandro.com
31081 * The idea is to render all the bricks based on vertical width...
31083 * The original code extends 'outlayer' - we might need to use that....
31089 * @class Roo.bootstrap.LayoutMasonry
31090 * @extends Roo.bootstrap.Component
31091 * Bootstrap Layout Masonry class
31094 * Create a new Element
31095 * @param {Object} config The config object
31098 Roo.bootstrap.LayoutMasonry = function(config){
31100 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31104 Roo.bootstrap.LayoutMasonry.register(this);
31110 * Fire after layout the items
31111 * @param {Roo.bootstrap.LayoutMasonry} this
31112 * @param {Roo.EventObject} e
31119 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31122 * @cfg {Boolean} isLayoutInstant = no animation?
31124 isLayoutInstant : false, // needed?
31127 * @cfg {Number} boxWidth width of the columns
31132 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31137 * @cfg {Number} padWidth padding below box..
31142 * @cfg {Number} gutter gutter width..
31147 * @cfg {Number} maxCols maximum number of columns
31153 * @cfg {Boolean} isAutoInitial defalut true
31155 isAutoInitial : true,
31160 * @cfg {Boolean} isHorizontal defalut false
31162 isHorizontal : false,
31164 currentSize : null,
31170 bricks: null, //CompositeElement
31174 _isLayoutInited : false,
31176 // isAlternative : false, // only use for vertical layout...
31179 * @cfg {Number} alternativePadWidth padding below box..
31181 alternativePadWidth : 50,
31183 selectedBrick : [],
31185 getAutoCreate : function(){
31187 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31191 cls: 'blog-masonary-wrapper ' + this.cls,
31193 cls : 'mas-boxes masonary'
31200 getChildContainer: function( )
31202 if (this.boxesEl) {
31203 return this.boxesEl;
31206 this.boxesEl = this.el.select('.mas-boxes').first();
31208 return this.boxesEl;
31212 initEvents : function()
31216 if(this.isAutoInitial){
31217 Roo.log('hook children rendered');
31218 this.on('childrenrendered', function() {
31219 Roo.log('children rendered');
31225 initial : function()
31227 this.selectedBrick = [];
31229 this.currentSize = this.el.getBox(true);
31231 Roo.EventManager.onWindowResize(this.resize, this);
31233 if(!this.isAutoInitial){
31241 //this.layout.defer(500,this);
31245 resize : function()
31247 var cs = this.el.getBox(true);
31250 this.currentSize.width == cs.width &&
31251 this.currentSize.x == cs.x &&
31252 this.currentSize.height == cs.height &&
31253 this.currentSize.y == cs.y
31255 Roo.log("no change in with or X or Y");
31259 this.currentSize = cs;
31265 layout : function()
31267 this._resetLayout();
31269 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31271 this.layoutItems( isInstant );
31273 this._isLayoutInited = true;
31275 this.fireEvent('layout', this);
31279 _resetLayout : function()
31281 if(this.isHorizontal){
31282 this.horizontalMeasureColumns();
31286 this.verticalMeasureColumns();
31290 verticalMeasureColumns : function()
31292 this.getContainerWidth();
31294 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31295 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31299 var boxWidth = this.boxWidth + this.padWidth;
31301 if(this.containerWidth < this.boxWidth){
31302 boxWidth = this.containerWidth
31305 var containerWidth = this.containerWidth;
31307 var cols = Math.floor(containerWidth / boxWidth);
31309 this.cols = Math.max( cols, 1 );
31311 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31313 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31315 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31317 this.colWidth = boxWidth + avail - this.padWidth;
31319 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31320 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31323 horizontalMeasureColumns : function()
31325 this.getContainerWidth();
31327 var boxWidth = this.boxWidth;
31329 if(this.containerWidth < boxWidth){
31330 boxWidth = this.containerWidth;
31333 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31335 this.el.setHeight(boxWidth);
31339 getContainerWidth : function()
31341 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31344 layoutItems : function( isInstant )
31346 Roo.log(this.bricks);
31348 var items = Roo.apply([], this.bricks);
31350 if(this.isHorizontal){
31351 this._horizontalLayoutItems( items , isInstant );
31355 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31356 // this._verticalAlternativeLayoutItems( items , isInstant );
31360 this._verticalLayoutItems( items , isInstant );
31364 _verticalLayoutItems : function ( items , isInstant)
31366 if ( !items || !items.length ) {
31371 ['xs', 'xs', 'xs', 'tall'],
31372 ['xs', 'xs', 'tall'],
31373 ['xs', 'xs', 'sm'],
31374 ['xs', 'xs', 'xs'],
31380 ['sm', 'xs', 'xs'],
31384 ['tall', 'xs', 'xs', 'xs'],
31385 ['tall', 'xs', 'xs'],
31397 Roo.each(items, function(item, k){
31399 switch (item.size) {
31400 // these layouts take up a full box,
31411 boxes.push([item]);
31434 var filterPattern = function(box, length)
31442 var pattern = box.slice(0, length);
31446 Roo.each(pattern, function(i){
31447 format.push(i.size);
31450 Roo.each(standard, function(s){
31452 if(String(s) != String(format)){
31461 if(!match && length == 1){
31466 filterPattern(box, length - 1);
31470 queue.push(pattern);
31472 box = box.slice(length, box.length);
31474 filterPattern(box, 4);
31480 Roo.each(boxes, function(box, k){
31486 if(box.length == 1){
31491 filterPattern(box, 4);
31495 this._processVerticalLayoutQueue( queue, isInstant );
31499 // _verticalAlternativeLayoutItems : function( items , isInstant )
31501 // if ( !items || !items.length ) {
31505 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31509 _horizontalLayoutItems : function ( items , isInstant)
31511 if ( !items || !items.length || items.length < 3) {
31517 var eItems = items.slice(0, 3);
31519 items = items.slice(3, items.length);
31522 ['xs', 'xs', 'xs', 'wide'],
31523 ['xs', 'xs', 'wide'],
31524 ['xs', 'xs', 'sm'],
31525 ['xs', 'xs', 'xs'],
31531 ['sm', 'xs', 'xs'],
31535 ['wide', 'xs', 'xs', 'xs'],
31536 ['wide', 'xs', 'xs'],
31549 Roo.each(items, function(item, k){
31551 switch (item.size) {
31562 boxes.push([item]);
31586 var filterPattern = function(box, length)
31594 var pattern = box.slice(0, length);
31598 Roo.each(pattern, function(i){
31599 format.push(i.size);
31602 Roo.each(standard, function(s){
31604 if(String(s) != String(format)){
31613 if(!match && length == 1){
31618 filterPattern(box, length - 1);
31622 queue.push(pattern);
31624 box = box.slice(length, box.length);
31626 filterPattern(box, 4);
31632 Roo.each(boxes, function(box, k){
31638 if(box.length == 1){
31643 filterPattern(box, 4);
31650 var pos = this.el.getBox(true);
31654 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31656 var hit_end = false;
31658 Roo.each(queue, function(box){
31662 Roo.each(box, function(b){
31664 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31674 Roo.each(box, function(b){
31676 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31679 mx = Math.max(mx, b.x);
31683 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31687 Roo.each(box, function(b){
31689 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31703 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31706 /** Sets position of item in DOM
31707 * @param {Element} item
31708 * @param {Number} x - horizontal position
31709 * @param {Number} y - vertical position
31710 * @param {Boolean} isInstant - disables transitions
31712 _processVerticalLayoutQueue : function( queue, isInstant )
31714 var pos = this.el.getBox(true);
31719 for (var i = 0; i < this.cols; i++){
31723 Roo.each(queue, function(box, k){
31725 var col = k % this.cols;
31727 Roo.each(box, function(b,kk){
31729 b.el.position('absolute');
31731 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31732 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31734 if(b.size == 'md-left' || b.size == 'md-right'){
31735 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31736 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31739 b.el.setWidth(width);
31740 b.el.setHeight(height);
31742 b.el.select('iframe',true).setSize(width,height);
31746 for (var i = 0; i < this.cols; i++){
31748 if(maxY[i] < maxY[col]){
31753 col = Math.min(col, i);
31757 x = pos.x + col * (this.colWidth + this.padWidth);
31761 var positions = [];
31763 switch (box.length){
31765 positions = this.getVerticalOneBoxColPositions(x, y, box);
31768 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31771 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31774 positions = this.getVerticalFourBoxColPositions(x, y, box);
31780 Roo.each(box, function(b,kk){
31782 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31784 var sz = b.el.getSize();
31786 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31794 for (var i = 0; i < this.cols; i++){
31795 mY = Math.max(mY, maxY[i]);
31798 this.el.setHeight(mY - pos.y);
31802 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31804 // var pos = this.el.getBox(true);
31807 // var maxX = pos.right;
31809 // var maxHeight = 0;
31811 // Roo.each(items, function(item, k){
31815 // item.el.position('absolute');
31817 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31819 // item.el.setWidth(width);
31821 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31823 // item.el.setHeight(height);
31826 // item.el.setXY([x, y], isInstant ? false : true);
31828 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31831 // y = y + height + this.alternativePadWidth;
31833 // maxHeight = maxHeight + height + this.alternativePadWidth;
31837 // this.el.setHeight(maxHeight);
31841 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31843 var pos = this.el.getBox(true);
31848 var maxX = pos.right;
31850 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31852 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31854 Roo.each(queue, function(box, k){
31856 Roo.each(box, function(b, kk){
31858 b.el.position('absolute');
31860 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31861 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31863 if(b.size == 'md-left' || b.size == 'md-right'){
31864 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31865 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31868 b.el.setWidth(width);
31869 b.el.setHeight(height);
31877 var positions = [];
31879 switch (box.length){
31881 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31884 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31887 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31890 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31896 Roo.each(box, function(b,kk){
31898 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31900 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31908 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31910 Roo.each(eItems, function(b,k){
31912 b.size = (k == 0) ? 'sm' : 'xs';
31913 b.x = (k == 0) ? 2 : 1;
31914 b.y = (k == 0) ? 2 : 1;
31916 b.el.position('absolute');
31918 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31920 b.el.setWidth(width);
31922 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31924 b.el.setHeight(height);
31928 var positions = [];
31931 x : maxX - this.unitWidth * 2 - this.gutter,
31936 x : maxX - this.unitWidth,
31937 y : minY + (this.unitWidth + this.gutter) * 2
31941 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31945 Roo.each(eItems, function(b,k){
31947 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31953 getVerticalOneBoxColPositions : function(x, y, box)
31957 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31959 if(box[0].size == 'md-left'){
31963 if(box[0].size == 'md-right'){
31968 x : x + (this.unitWidth + this.gutter) * rand,
31975 getVerticalTwoBoxColPositions : function(x, y, box)
31979 if(box[0].size == 'xs'){
31983 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31987 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32001 x : x + (this.unitWidth + this.gutter) * 2,
32002 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32009 getVerticalThreeBoxColPositions : function(x, y, box)
32013 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32021 x : x + (this.unitWidth + this.gutter) * 1,
32026 x : x + (this.unitWidth + this.gutter) * 2,
32034 if(box[0].size == 'xs' && box[1].size == 'xs'){
32043 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32047 x : x + (this.unitWidth + this.gutter) * 1,
32061 x : x + (this.unitWidth + this.gutter) * 2,
32066 x : x + (this.unitWidth + this.gutter) * 2,
32067 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32074 getVerticalFourBoxColPositions : function(x, y, box)
32078 if(box[0].size == 'xs'){
32087 y : y + (this.unitHeight + this.gutter) * 1
32092 y : y + (this.unitHeight + this.gutter) * 2
32096 x : x + (this.unitWidth + this.gutter) * 1,
32110 x : x + (this.unitWidth + this.gutter) * 2,
32115 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32116 y : y + (this.unitHeight + this.gutter) * 1
32120 x : x + (this.unitWidth + this.gutter) * 2,
32121 y : y + (this.unitWidth + this.gutter) * 2
32128 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32132 if(box[0].size == 'md-left'){
32134 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32141 if(box[0].size == 'md-right'){
32143 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32144 y : minY + (this.unitWidth + this.gutter) * 1
32150 var rand = Math.floor(Math.random() * (4 - box[0].y));
32153 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32154 y : minY + (this.unitWidth + this.gutter) * rand
32161 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32165 if(box[0].size == 'xs'){
32168 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32173 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32174 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32182 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32187 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32188 y : minY + (this.unitWidth + this.gutter) * 2
32195 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32199 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32202 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32207 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32208 y : minY + (this.unitWidth + this.gutter) * 1
32212 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32213 y : minY + (this.unitWidth + this.gutter) * 2
32220 if(box[0].size == 'xs' && box[1].size == 'xs'){
32223 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32228 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32233 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32234 y : minY + (this.unitWidth + this.gutter) * 1
32242 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32247 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32248 y : minY + (this.unitWidth + this.gutter) * 2
32252 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32253 y : minY + (this.unitWidth + this.gutter) * 2
32260 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32264 if(box[0].size == 'xs'){
32267 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32272 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32277 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),
32282 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32283 y : minY + (this.unitWidth + this.gutter) * 1
32291 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32296 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32297 y : minY + (this.unitWidth + this.gutter) * 2
32301 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32302 y : minY + (this.unitWidth + this.gutter) * 2
32306 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),
32307 y : minY + (this.unitWidth + this.gutter) * 2
32315 * remove a Masonry Brick
32316 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32318 removeBrick : function(brick_id)
32324 for (var i = 0; i<this.bricks.length; i++) {
32325 if (this.bricks[i].id == brick_id) {
32326 this.bricks.splice(i,1);
32327 this.el.dom.removeChild(Roo.get(brick_id).dom);
32334 * adds a Masonry Brick
32335 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32337 addBrick : function(cfg)
32339 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32340 //this.register(cn);
32341 cn.parentId = this.id;
32342 cn.render(this.el);
32347 * register a Masonry Brick
32348 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32351 register : function(brick)
32353 this.bricks.push(brick);
32354 brick.masonryId = this.id;
32358 * clear all the Masonry Brick
32360 clearAll : function()
32363 //this.getChildContainer().dom.innerHTML = "";
32364 this.el.dom.innerHTML = '';
32367 getSelected : function()
32369 if (!this.selectedBrick) {
32373 return this.selectedBrick;
32377 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32381 * register a Masonry Layout
32382 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32385 register : function(layout)
32387 this.groups[layout.id] = layout;
32390 * fetch a Masonry Layout based on the masonry layout ID
32391 * @param {string} the masonry layout to add
32392 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32395 get: function(layout_id) {
32396 if (typeof(this.groups[layout_id]) == 'undefined') {
32399 return this.groups[layout_id] ;
32411 * http://masonry.desandro.com
32413 * The idea is to render all the bricks based on vertical width...
32415 * The original code extends 'outlayer' - we might need to use that....
32421 * @class Roo.bootstrap.LayoutMasonryAuto
32422 * @extends Roo.bootstrap.Component
32423 * Bootstrap Layout Masonry class
32426 * Create a new Element
32427 * @param {Object} config The config object
32430 Roo.bootstrap.LayoutMasonryAuto = function(config){
32431 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32434 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32437 * @cfg {Boolean} isFitWidth - resize the width..
32439 isFitWidth : false, // options..
32441 * @cfg {Boolean} isOriginLeft = left align?
32443 isOriginLeft : true,
32445 * @cfg {Boolean} isOriginTop = top align?
32447 isOriginTop : false,
32449 * @cfg {Boolean} isLayoutInstant = no animation?
32451 isLayoutInstant : false, // needed?
32453 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32455 isResizingContainer : true,
32457 * @cfg {Number} columnWidth width of the columns
32463 * @cfg {Number} maxCols maximum number of columns
32468 * @cfg {Number} padHeight padding below box..
32474 * @cfg {Boolean} isAutoInitial defalut true
32477 isAutoInitial : true,
32483 initialColumnWidth : 0,
32484 currentSize : null,
32486 colYs : null, // array.
32493 bricks: null, //CompositeElement
32494 cols : 0, // array?
32495 // element : null, // wrapped now this.el
32496 _isLayoutInited : null,
32499 getAutoCreate : function(){
32503 cls: 'blog-masonary-wrapper ' + this.cls,
32505 cls : 'mas-boxes masonary'
32512 getChildContainer: function( )
32514 if (this.boxesEl) {
32515 return this.boxesEl;
32518 this.boxesEl = this.el.select('.mas-boxes').first();
32520 return this.boxesEl;
32524 initEvents : function()
32528 if(this.isAutoInitial){
32529 Roo.log('hook children rendered');
32530 this.on('childrenrendered', function() {
32531 Roo.log('children rendered');
32538 initial : function()
32540 this.reloadItems();
32542 this.currentSize = this.el.getBox(true);
32544 /// was window resize... - let's see if this works..
32545 Roo.EventManager.onWindowResize(this.resize, this);
32547 if(!this.isAutoInitial){
32552 this.layout.defer(500,this);
32555 reloadItems: function()
32557 this.bricks = this.el.select('.masonry-brick', true);
32559 this.bricks.each(function(b) {
32560 //Roo.log(b.getSize());
32561 if (!b.attr('originalwidth')) {
32562 b.attr('originalwidth', b.getSize().width);
32567 Roo.log(this.bricks.elements.length);
32570 resize : function()
32573 var cs = this.el.getBox(true);
32575 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32576 Roo.log("no change in with or X");
32579 this.currentSize = cs;
32583 layout : function()
32586 this._resetLayout();
32587 //this._manageStamps();
32589 // don't animate first layout
32590 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32591 this.layoutItems( isInstant );
32593 // flag for initalized
32594 this._isLayoutInited = true;
32597 layoutItems : function( isInstant )
32599 //var items = this._getItemsForLayout( this.items );
32600 // original code supports filtering layout items.. we just ignore it..
32602 this._layoutItems( this.bricks , isInstant );
32604 this._postLayout();
32606 _layoutItems : function ( items , isInstant)
32608 //this.fireEvent( 'layout', this, items );
32611 if ( !items || !items.elements.length ) {
32612 // no items, emit event with empty array
32617 items.each(function(item) {
32618 Roo.log("layout item");
32620 // get x/y object from method
32621 var position = this._getItemLayoutPosition( item );
32623 position.item = item;
32624 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32625 queue.push( position );
32628 this._processLayoutQueue( queue );
32630 /** Sets position of item in DOM
32631 * @param {Element} item
32632 * @param {Number} x - horizontal position
32633 * @param {Number} y - vertical position
32634 * @param {Boolean} isInstant - disables transitions
32636 _processLayoutQueue : function( queue )
32638 for ( var i=0, len = queue.length; i < len; i++ ) {
32639 var obj = queue[i];
32640 obj.item.position('absolute');
32641 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32647 * Any logic you want to do after each layout,
32648 * i.e. size the container
32650 _postLayout : function()
32652 this.resizeContainer();
32655 resizeContainer : function()
32657 if ( !this.isResizingContainer ) {
32660 var size = this._getContainerSize();
32662 this.el.setSize(size.width,size.height);
32663 this.boxesEl.setSize(size.width,size.height);
32669 _resetLayout : function()
32671 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32672 this.colWidth = this.el.getWidth();
32673 //this.gutter = this.el.getWidth();
32675 this.measureColumns();
32681 this.colYs.push( 0 );
32687 measureColumns : function()
32689 this.getContainerWidth();
32690 // if columnWidth is 0, default to outerWidth of first item
32691 if ( !this.columnWidth ) {
32692 var firstItem = this.bricks.first();
32693 Roo.log(firstItem);
32694 this.columnWidth = this.containerWidth;
32695 if (firstItem && firstItem.attr('originalwidth') ) {
32696 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32698 // columnWidth fall back to item of first element
32699 Roo.log("set column width?");
32700 this.initialColumnWidth = this.columnWidth ;
32702 // if first elem has no width, default to size of container
32707 if (this.initialColumnWidth) {
32708 this.columnWidth = this.initialColumnWidth;
32713 // column width is fixed at the top - however if container width get's smaller we should
32716 // this bit calcs how man columns..
32718 var columnWidth = this.columnWidth += this.gutter;
32720 // calculate columns
32721 var containerWidth = this.containerWidth + this.gutter;
32723 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32724 // fix rounding errors, typically with gutters
32725 var excess = columnWidth - containerWidth % columnWidth;
32728 // if overshoot is less than a pixel, round up, otherwise floor it
32729 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32730 cols = Math[ mathMethod ]( cols );
32731 this.cols = Math.max( cols, 1 );
32732 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32734 // padding positioning..
32735 var totalColWidth = this.cols * this.columnWidth;
32736 var padavail = this.containerWidth - totalColWidth;
32737 // so for 2 columns - we need 3 'pads'
32739 var padNeeded = (1+this.cols) * this.padWidth;
32741 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32743 this.columnWidth += padExtra
32744 //this.padWidth = Math.floor(padavail / ( this.cols));
32746 // adjust colum width so that padding is fixed??
32748 // we have 3 columns ... total = width * 3
32749 // we have X left over... that should be used by
32751 //if (this.expandC) {
32759 getContainerWidth : function()
32761 /* // container is parent if fit width
32762 var container = this.isFitWidth ? this.element.parentNode : this.element;
32763 // check that this.size and size are there
32764 // IE8 triggers resize on body size change, so they might not be
32766 var size = getSize( container ); //FIXME
32767 this.containerWidth = size && size.innerWidth; //FIXME
32770 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32774 _getItemLayoutPosition : function( item ) // what is item?
32776 // we resize the item to our columnWidth..
32778 item.setWidth(this.columnWidth);
32779 item.autoBoxAdjust = false;
32781 var sz = item.getSize();
32783 // how many columns does this brick span
32784 var remainder = this.containerWidth % this.columnWidth;
32786 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32787 // round if off by 1 pixel, otherwise use ceil
32788 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32789 colSpan = Math.min( colSpan, this.cols );
32791 // normally this should be '1' as we dont' currently allow multi width columns..
32793 var colGroup = this._getColGroup( colSpan );
32794 // get the minimum Y value from the columns
32795 var minimumY = Math.min.apply( Math, colGroup );
32796 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32798 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32800 // position the brick
32802 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32803 y: this.currentSize.y + minimumY + this.padHeight
32807 // apply setHeight to necessary columns
32808 var setHeight = minimumY + sz.height + this.padHeight;
32809 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32811 var setSpan = this.cols + 1 - colGroup.length;
32812 for ( var i = 0; i < setSpan; i++ ) {
32813 this.colYs[ shortColIndex + i ] = setHeight ;
32820 * @param {Number} colSpan - number of columns the element spans
32821 * @returns {Array} colGroup
32823 _getColGroup : function( colSpan )
32825 if ( colSpan < 2 ) {
32826 // if brick spans only one column, use all the column Ys
32831 // how many different places could this brick fit horizontally
32832 var groupCount = this.cols + 1 - colSpan;
32833 // for each group potential horizontal position
32834 for ( var i = 0; i < groupCount; i++ ) {
32835 // make an array of colY values for that one group
32836 var groupColYs = this.colYs.slice( i, i + colSpan );
32837 // and get the max value of the array
32838 colGroup[i] = Math.max.apply( Math, groupColYs );
32843 _manageStamp : function( stamp )
32845 var stampSize = stamp.getSize();
32846 var offset = stamp.getBox();
32847 // get the columns that this stamp affects
32848 var firstX = this.isOriginLeft ? offset.x : offset.right;
32849 var lastX = firstX + stampSize.width;
32850 var firstCol = Math.floor( firstX / this.columnWidth );
32851 firstCol = Math.max( 0, firstCol );
32853 var lastCol = Math.floor( lastX / this.columnWidth );
32854 // lastCol should not go over if multiple of columnWidth #425
32855 lastCol -= lastX % this.columnWidth ? 0 : 1;
32856 lastCol = Math.min( this.cols - 1, lastCol );
32858 // set colYs to bottom of the stamp
32859 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32862 for ( var i = firstCol; i <= lastCol; i++ ) {
32863 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32868 _getContainerSize : function()
32870 this.maxY = Math.max.apply( Math, this.colYs );
32875 if ( this.isFitWidth ) {
32876 size.width = this._getContainerFitWidth();
32882 _getContainerFitWidth : function()
32884 var unusedCols = 0;
32885 // count unused columns
32888 if ( this.colYs[i] !== 0 ) {
32893 // fit container to columns that have been used
32894 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32897 needsResizeLayout : function()
32899 var previousWidth = this.containerWidth;
32900 this.getContainerWidth();
32901 return previousWidth !== this.containerWidth;
32916 * @class Roo.bootstrap.MasonryBrick
32917 * @extends Roo.bootstrap.Component
32918 * Bootstrap MasonryBrick class
32921 * Create a new MasonryBrick
32922 * @param {Object} config The config object
32925 Roo.bootstrap.MasonryBrick = function(config){
32927 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32929 Roo.bootstrap.MasonryBrick.register(this);
32935 * When a MasonryBrick is clcik
32936 * @param {Roo.bootstrap.MasonryBrick} this
32937 * @param {Roo.EventObject} e
32943 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32946 * @cfg {String} title
32950 * @cfg {String} html
32954 * @cfg {String} bgimage
32958 * @cfg {String} videourl
32962 * @cfg {String} cls
32966 * @cfg {String} href
32970 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32975 * @cfg {String} placetitle (center|bottom)
32980 * @cfg {Boolean} isFitContainer defalut true
32982 isFitContainer : true,
32985 * @cfg {Boolean} preventDefault defalut false
32987 preventDefault : false,
32990 * @cfg {Boolean} inverse defalut false
32992 maskInverse : false,
32994 getAutoCreate : function()
32996 if(!this.isFitContainer){
32997 return this.getSplitAutoCreate();
33000 var cls = 'masonry-brick masonry-brick-full';
33002 if(this.href.length){
33003 cls += ' masonry-brick-link';
33006 if(this.bgimage.length){
33007 cls += ' masonry-brick-image';
33010 if(this.maskInverse){
33011 cls += ' mask-inverse';
33014 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33015 cls += ' enable-mask';
33019 cls += ' masonry-' + this.size + '-brick';
33022 if(this.placetitle.length){
33024 switch (this.placetitle) {
33026 cls += ' masonry-center-title';
33029 cls += ' masonry-bottom-title';
33036 if(!this.html.length && !this.bgimage.length){
33037 cls += ' masonry-center-title';
33040 if(!this.html.length && this.bgimage.length){
33041 cls += ' masonry-bottom-title';
33046 cls += ' ' + this.cls;
33050 tag: (this.href.length) ? 'a' : 'div',
33055 cls: 'masonry-brick-mask'
33059 cls: 'masonry-brick-paragraph',
33065 if(this.href.length){
33066 cfg.href = this.href;
33069 var cn = cfg.cn[1].cn;
33071 if(this.title.length){
33074 cls: 'masonry-brick-title',
33079 if(this.html.length){
33082 cls: 'masonry-brick-text',
33087 if (!this.title.length && !this.html.length) {
33088 cfg.cn[1].cls += ' hide';
33091 if(this.bgimage.length){
33094 cls: 'masonry-brick-image-view',
33099 if(this.videourl.length){
33100 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33101 // youtube support only?
33104 cls: 'masonry-brick-image-view',
33107 allowfullscreen : true
33115 getSplitAutoCreate : function()
33117 var cls = 'masonry-brick masonry-brick-split';
33119 if(this.href.length){
33120 cls += ' masonry-brick-link';
33123 if(this.bgimage.length){
33124 cls += ' masonry-brick-image';
33128 cls += ' masonry-' + this.size + '-brick';
33131 switch (this.placetitle) {
33133 cls += ' masonry-center-title';
33136 cls += ' masonry-bottom-title';
33139 if(!this.bgimage.length){
33140 cls += ' masonry-center-title';
33143 if(this.bgimage.length){
33144 cls += ' masonry-bottom-title';
33150 cls += ' ' + this.cls;
33154 tag: (this.href.length) ? 'a' : 'div',
33159 cls: 'masonry-brick-split-head',
33163 cls: 'masonry-brick-paragraph',
33170 cls: 'masonry-brick-split-body',
33176 if(this.href.length){
33177 cfg.href = this.href;
33180 if(this.title.length){
33181 cfg.cn[0].cn[0].cn.push({
33183 cls: 'masonry-brick-title',
33188 if(this.html.length){
33189 cfg.cn[1].cn.push({
33191 cls: 'masonry-brick-text',
33196 if(this.bgimage.length){
33197 cfg.cn[0].cn.push({
33199 cls: 'masonry-brick-image-view',
33204 if(this.videourl.length){
33205 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33206 // youtube support only?
33207 cfg.cn[0].cn.cn.push({
33209 cls: 'masonry-brick-image-view',
33212 allowfullscreen : true
33219 initEvents: function()
33221 switch (this.size) {
33254 this.el.on('touchstart', this.onTouchStart, this);
33255 this.el.on('touchmove', this.onTouchMove, this);
33256 this.el.on('touchend', this.onTouchEnd, this);
33257 this.el.on('contextmenu', this.onContextMenu, this);
33259 this.el.on('mouseenter' ,this.enter, this);
33260 this.el.on('mouseleave', this.leave, this);
33261 this.el.on('click', this.onClick, this);
33264 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33265 this.parent().bricks.push(this);
33270 onClick: function(e, el)
33272 var time = this.endTimer - this.startTimer;
33273 // Roo.log(e.preventDefault());
33276 e.preventDefault();
33281 if(!this.preventDefault){
33285 e.preventDefault();
33287 if (this.activeClass != '') {
33288 this.selectBrick();
33291 this.fireEvent('click', this, e);
33294 enter: function(e, el)
33296 e.preventDefault();
33298 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33302 if(this.bgimage.length && this.html.length){
33303 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33307 leave: function(e, el)
33309 e.preventDefault();
33311 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33315 if(this.bgimage.length && this.html.length){
33316 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33320 onTouchStart: function(e, el)
33322 // e.preventDefault();
33324 this.touchmoved = false;
33326 if(!this.isFitContainer){
33330 if(!this.bgimage.length || !this.html.length){
33334 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33336 this.timer = new Date().getTime();
33340 onTouchMove: function(e, el)
33342 this.touchmoved = true;
33345 onContextMenu : function(e,el)
33347 e.preventDefault();
33348 e.stopPropagation();
33352 onTouchEnd: function(e, el)
33354 // e.preventDefault();
33356 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33363 if(!this.bgimage.length || !this.html.length){
33365 if(this.href.length){
33366 window.location.href = this.href;
33372 if(!this.isFitContainer){
33376 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33378 window.location.href = this.href;
33381 //selection on single brick only
33382 selectBrick : function() {
33384 if (!this.parentId) {
33388 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33389 var index = m.selectedBrick.indexOf(this.id);
33392 m.selectedBrick.splice(index,1);
33393 this.el.removeClass(this.activeClass);
33397 for(var i = 0; i < m.selectedBrick.length; i++) {
33398 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33399 b.el.removeClass(b.activeClass);
33402 m.selectedBrick = [];
33404 m.selectedBrick.push(this.id);
33405 this.el.addClass(this.activeClass);
33409 isSelected : function(){
33410 return this.el.hasClass(this.activeClass);
33415 Roo.apply(Roo.bootstrap.MasonryBrick, {
33418 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33420 * register a Masonry Brick
33421 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33424 register : function(brick)
33426 //this.groups[brick.id] = brick;
33427 this.groups.add(brick.id, brick);
33430 * fetch a masonry brick based on the masonry brick ID
33431 * @param {string} the masonry brick to add
33432 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33435 get: function(brick_id)
33437 // if (typeof(this.groups[brick_id]) == 'undefined') {
33440 // return this.groups[brick_id] ;
33442 if(this.groups.key(brick_id)) {
33443 return this.groups.key(brick_id);
33461 * @class Roo.bootstrap.Brick
33462 * @extends Roo.bootstrap.Component
33463 * Bootstrap Brick class
33466 * Create a new Brick
33467 * @param {Object} config The config object
33470 Roo.bootstrap.Brick = function(config){
33471 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33477 * When a Brick is click
33478 * @param {Roo.bootstrap.Brick} this
33479 * @param {Roo.EventObject} e
33485 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33488 * @cfg {String} title
33492 * @cfg {String} html
33496 * @cfg {String} bgimage
33500 * @cfg {String} cls
33504 * @cfg {String} href
33508 * @cfg {String} video
33512 * @cfg {Boolean} square
33516 getAutoCreate : function()
33518 var cls = 'roo-brick';
33520 if(this.href.length){
33521 cls += ' roo-brick-link';
33524 if(this.bgimage.length){
33525 cls += ' roo-brick-image';
33528 if(!this.html.length && !this.bgimage.length){
33529 cls += ' roo-brick-center-title';
33532 if(!this.html.length && this.bgimage.length){
33533 cls += ' roo-brick-bottom-title';
33537 cls += ' ' + this.cls;
33541 tag: (this.href.length) ? 'a' : 'div',
33546 cls: 'roo-brick-paragraph',
33552 if(this.href.length){
33553 cfg.href = this.href;
33556 var cn = cfg.cn[0].cn;
33558 if(this.title.length){
33561 cls: 'roo-brick-title',
33566 if(this.html.length){
33569 cls: 'roo-brick-text',
33576 if(this.bgimage.length){
33579 cls: 'roo-brick-image-view',
33587 initEvents: function()
33589 if(this.title.length || this.html.length){
33590 this.el.on('mouseenter' ,this.enter, this);
33591 this.el.on('mouseleave', this.leave, this);
33594 Roo.EventManager.onWindowResize(this.resize, this);
33596 if(this.bgimage.length){
33597 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33598 this.imageEl.on('load', this.onImageLoad, this);
33605 onImageLoad : function()
33610 resize : function()
33612 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33614 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33616 if(this.bgimage.length){
33617 var image = this.el.select('.roo-brick-image-view', true).first();
33619 image.setWidth(paragraph.getWidth());
33622 image.setHeight(paragraph.getWidth());
33625 this.el.setHeight(image.getHeight());
33626 paragraph.setHeight(image.getHeight());
33632 enter: function(e, el)
33634 e.preventDefault();
33636 if(this.bgimage.length){
33637 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33638 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33642 leave: function(e, el)
33644 e.preventDefault();
33646 if(this.bgimage.length){
33647 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33648 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33663 * @class Roo.bootstrap.NumberField
33664 * @extends Roo.bootstrap.Input
33665 * Bootstrap NumberField class
33671 * Create a new NumberField
33672 * @param {Object} config The config object
33675 Roo.bootstrap.NumberField = function(config){
33676 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33679 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33682 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33684 allowDecimals : true,
33686 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33688 decimalSeparator : ".",
33690 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33692 decimalPrecision : 2,
33694 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33696 allowNegative : true,
33699 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33703 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33705 minValue : Number.NEGATIVE_INFINITY,
33707 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33709 maxValue : Number.MAX_VALUE,
33711 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33713 minText : "The minimum value for this field is {0}",
33715 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33717 maxText : "The maximum value for this field is {0}",
33719 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33720 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33722 nanText : "{0} is not a valid number",
33724 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33726 thousandsDelimiter : false,
33728 * @cfg {String} valueAlign alignment of value
33730 valueAlign : "left",
33732 getAutoCreate : function()
33734 var hiddenInput = {
33738 cls: 'hidden-number-input'
33742 hiddenInput.name = this.name;
33747 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33749 this.name = hiddenInput.name;
33751 if(cfg.cn.length > 0) {
33752 cfg.cn.push(hiddenInput);
33759 initEvents : function()
33761 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33763 var allowed = "0123456789";
33765 if(this.allowDecimals){
33766 allowed += this.decimalSeparator;
33769 if(this.allowNegative){
33773 if(this.thousandsDelimiter) {
33777 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33779 var keyPress = function(e){
33781 var k = e.getKey();
33783 var c = e.getCharCode();
33786 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33787 allowed.indexOf(String.fromCharCode(c)) === -1
33793 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33797 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33802 this.el.on("keypress", keyPress, this);
33805 validateValue : function(value)
33808 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33812 var num = this.parseValue(value);
33815 this.markInvalid(String.format(this.nanText, value));
33819 if(num < this.minValue){
33820 this.markInvalid(String.format(this.minText, this.minValue));
33824 if(num > this.maxValue){
33825 this.markInvalid(String.format(this.maxText, this.maxValue));
33832 getValue : function()
33834 var v = this.hiddenEl().getValue();
33836 return this.fixPrecision(this.parseValue(v));
33839 parseValue : function(value)
33841 if(this.thousandsDelimiter) {
33843 r = new RegExp(",", "g");
33844 value = value.replace(r, "");
33847 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33848 return isNaN(value) ? '' : value;
33851 fixPrecision : function(value)
33853 if(this.thousandsDelimiter) {
33855 r = new RegExp(",", "g");
33856 value = value.replace(r, "");
33859 var nan = isNaN(value);
33861 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33862 return nan ? '' : value;
33864 return parseFloat(value).toFixed(this.decimalPrecision);
33867 setValue : function(v)
33869 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33875 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33877 this.inputEl().dom.value = (v == '') ? '' :
33878 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33880 if(!this.allowZero && v === '0') {
33881 this.hiddenEl().dom.value = '';
33882 this.inputEl().dom.value = '';
33889 decimalPrecisionFcn : function(v)
33891 return Math.floor(v);
33894 beforeBlur : function()
33896 var v = this.parseValue(this.getRawValue());
33898 if(v || v === 0 || v === ''){
33903 hiddenEl : function()
33905 return this.el.select('input.hidden-number-input',true).first();
33917 * @class Roo.bootstrap.DocumentSlider
33918 * @extends Roo.bootstrap.Component
33919 * Bootstrap DocumentSlider class
33922 * Create a new DocumentViewer
33923 * @param {Object} config The config object
33926 Roo.bootstrap.DocumentSlider = function(config){
33927 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33934 * Fire after initEvent
33935 * @param {Roo.bootstrap.DocumentSlider} this
33940 * Fire after update
33941 * @param {Roo.bootstrap.DocumentSlider} this
33947 * @param {Roo.bootstrap.DocumentSlider} this
33953 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33959 getAutoCreate : function()
33963 cls : 'roo-document-slider',
33967 cls : 'roo-document-slider-header',
33971 cls : 'roo-document-slider-header-title'
33977 cls : 'roo-document-slider-body',
33981 cls : 'roo-document-slider-prev',
33985 cls : 'fa fa-chevron-left'
33991 cls : 'roo-document-slider-thumb',
33995 cls : 'roo-document-slider-image'
34001 cls : 'roo-document-slider-next',
34005 cls : 'fa fa-chevron-right'
34017 initEvents : function()
34019 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34020 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34022 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34023 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34025 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34026 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34028 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34029 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34031 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34032 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34034 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34035 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34037 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34038 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34040 this.thumbEl.on('click', this.onClick, this);
34042 this.prevIndicator.on('click', this.prev, this);
34044 this.nextIndicator.on('click', this.next, this);
34048 initial : function()
34050 if(this.files.length){
34051 this.indicator = 1;
34055 this.fireEvent('initial', this);
34058 update : function()
34060 this.imageEl.attr('src', this.files[this.indicator - 1]);
34062 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34064 this.prevIndicator.show();
34066 if(this.indicator == 1){
34067 this.prevIndicator.hide();
34070 this.nextIndicator.show();
34072 if(this.indicator == this.files.length){
34073 this.nextIndicator.hide();
34076 this.thumbEl.scrollTo('top');
34078 this.fireEvent('update', this);
34081 onClick : function(e)
34083 e.preventDefault();
34085 this.fireEvent('click', this);
34090 e.preventDefault();
34092 this.indicator = Math.max(1, this.indicator - 1);
34099 e.preventDefault();
34101 this.indicator = Math.min(this.files.length, this.indicator + 1);
34115 * @class Roo.bootstrap.RadioSet
34116 * @extends Roo.bootstrap.Input
34117 * Bootstrap RadioSet class
34118 * @cfg {String} indicatorpos (left|right) default left
34119 * @cfg {Boolean} inline (true|false) inline the element (default true)
34120 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34122 * Create a new RadioSet
34123 * @param {Object} config The config object
34126 Roo.bootstrap.RadioSet = function(config){
34128 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34132 Roo.bootstrap.RadioSet.register(this);
34137 * Fires when the element is checked or unchecked.
34138 * @param {Roo.bootstrap.RadioSet} this This radio
34139 * @param {Roo.bootstrap.Radio} item The checked item
34144 * Fires when the element is click.
34145 * @param {Roo.bootstrap.RadioSet} this This radio set
34146 * @param {Roo.bootstrap.Radio} item The checked item
34147 * @param {Roo.EventObject} e The event object
34154 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34162 indicatorpos : 'left',
34164 getAutoCreate : function()
34168 cls : 'roo-radio-set-label',
34172 html : this.fieldLabel
34176 if (Roo.bootstrap.version == 3) {
34179 if(this.indicatorpos == 'left'){
34182 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34183 tooltip : 'This field is required'
34188 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34189 tooltip : 'This field is required'
34195 cls : 'roo-radio-set-items'
34198 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34200 if (align === 'left' && this.fieldLabel.length) {
34203 cls : "roo-radio-set-right",
34209 if(this.labelWidth > 12){
34210 label.style = "width: " + this.labelWidth + 'px';
34213 if(this.labelWidth < 13 && this.labelmd == 0){
34214 this.labelmd = this.labelWidth;
34217 if(this.labellg > 0){
34218 label.cls += ' col-lg-' + this.labellg;
34219 items.cls += ' col-lg-' + (12 - this.labellg);
34222 if(this.labelmd > 0){
34223 label.cls += ' col-md-' + this.labelmd;
34224 items.cls += ' col-md-' + (12 - this.labelmd);
34227 if(this.labelsm > 0){
34228 label.cls += ' col-sm-' + this.labelsm;
34229 items.cls += ' col-sm-' + (12 - this.labelsm);
34232 if(this.labelxs > 0){
34233 label.cls += ' col-xs-' + this.labelxs;
34234 items.cls += ' col-xs-' + (12 - this.labelxs);
34240 cls : 'roo-radio-set',
34244 cls : 'roo-radio-set-input',
34247 value : this.value ? this.value : ''
34254 if(this.weight.length){
34255 cfg.cls += ' roo-radio-' + this.weight;
34259 cfg.cls += ' roo-radio-set-inline';
34263 ['xs','sm','md','lg'].map(function(size){
34264 if (settings[size]) {
34265 cfg.cls += ' col-' + size + '-' + settings[size];
34273 initEvents : function()
34275 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34276 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34278 if(!this.fieldLabel.length){
34279 this.labelEl.hide();
34282 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34283 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34285 this.indicator = this.indicatorEl();
34287 if(this.indicator){
34288 this.indicator.addClass('invisible');
34291 this.originalValue = this.getValue();
34295 inputEl: function ()
34297 return this.el.select('.roo-radio-set-input', true).first();
34300 getChildContainer : function()
34302 return this.itemsEl;
34305 register : function(item)
34307 this.radioes.push(item);
34311 validate : function()
34313 if(this.getVisibilityEl().hasClass('hidden')){
34319 Roo.each(this.radioes, function(i){
34328 if(this.allowBlank) {
34332 if(this.disabled || valid){
34337 this.markInvalid();
34342 markValid : function()
34344 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34345 this.indicatorEl().removeClass('visible');
34346 this.indicatorEl().addClass('invisible');
34350 if (Roo.bootstrap.version == 3) {
34351 this.el.removeClass([this.invalidClass, this.validClass]);
34352 this.el.addClass(this.validClass);
34354 this.el.removeClass(['is-invalid','is-valid']);
34355 this.el.addClass(['is-valid']);
34357 this.fireEvent('valid', this);
34360 markInvalid : function(msg)
34362 if(this.allowBlank || this.disabled){
34366 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34367 this.indicatorEl().removeClass('invisible');
34368 this.indicatorEl().addClass('visible');
34370 if (Roo.bootstrap.version == 3) {
34371 this.el.removeClass([this.invalidClass, this.validClass]);
34372 this.el.addClass(this.invalidClass);
34374 this.el.removeClass(['is-invalid','is-valid']);
34375 this.el.addClass(['is-invalid']);
34378 this.fireEvent('invalid', this, msg);
34382 setValue : function(v, suppressEvent)
34384 if(this.value === v){
34391 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34394 Roo.each(this.radioes, function(i){
34396 i.el.removeClass('checked');
34399 Roo.each(this.radioes, function(i){
34401 if(i.value === v || i.value.toString() === v.toString()){
34403 i.el.addClass('checked');
34405 if(suppressEvent !== true){
34406 this.fireEvent('check', this, i);
34417 clearInvalid : function(){
34419 if(!this.el || this.preventMark){
34423 this.el.removeClass([this.invalidClass]);
34425 this.fireEvent('valid', this);
34430 Roo.apply(Roo.bootstrap.RadioSet, {
34434 register : function(set)
34436 this.groups[set.name] = set;
34439 get: function(name)
34441 if (typeof(this.groups[name]) == 'undefined') {
34445 return this.groups[name] ;
34451 * Ext JS Library 1.1.1
34452 * Copyright(c) 2006-2007, Ext JS, LLC.
34454 * Originally Released Under LGPL - original licence link has changed is not relivant.
34457 * <script type="text/javascript">
34462 * @class Roo.bootstrap.SplitBar
34463 * @extends Roo.util.Observable
34464 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34468 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34469 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34470 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34471 split.minSize = 100;
34472 split.maxSize = 600;
34473 split.animate = true;
34474 split.on('moved', splitterMoved);
34477 * Create a new SplitBar
34478 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34479 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34480 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34481 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34482 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34483 position of the SplitBar).
34485 Roo.bootstrap.SplitBar = function(cfg){
34490 // dragElement : elm
34491 // resizingElement: el,
34493 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34494 // placement : Roo.bootstrap.SplitBar.LEFT ,
34495 // existingProxy ???
34498 this.el = Roo.get(cfg.dragElement, true);
34499 this.el.dom.unselectable = "on";
34501 this.resizingEl = Roo.get(cfg.resizingElement, true);
34505 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34506 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34509 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34512 * The minimum size of the resizing element. (Defaults to 0)
34518 * The maximum size of the resizing element. (Defaults to 2000)
34521 this.maxSize = 2000;
34524 * Whether to animate the transition to the new size
34527 this.animate = false;
34530 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34533 this.useShim = false;
34538 if(!cfg.existingProxy){
34540 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34542 this.proxy = Roo.get(cfg.existingProxy).dom;
34545 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34548 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34551 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34554 this.dragSpecs = {};
34557 * @private The adapter to use to positon and resize elements
34559 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34560 this.adapter.init(this);
34562 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34564 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34565 this.el.addClass("roo-splitbar-h");
34568 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34569 this.el.addClass("roo-splitbar-v");
34575 * Fires when the splitter is moved (alias for {@link #event-moved})
34576 * @param {Roo.bootstrap.SplitBar} this
34577 * @param {Number} newSize the new width or height
34582 * Fires when the splitter is moved
34583 * @param {Roo.bootstrap.SplitBar} this
34584 * @param {Number} newSize the new width or height
34588 * @event beforeresize
34589 * Fires before the splitter is dragged
34590 * @param {Roo.bootstrap.SplitBar} this
34592 "beforeresize" : true,
34594 "beforeapply" : true
34597 Roo.util.Observable.call(this);
34600 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34601 onStartProxyDrag : function(x, y){
34602 this.fireEvent("beforeresize", this);
34604 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34606 o.enableDisplayMode("block");
34607 // all splitbars share the same overlay
34608 Roo.bootstrap.SplitBar.prototype.overlay = o;
34610 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34611 this.overlay.show();
34612 Roo.get(this.proxy).setDisplayed("block");
34613 var size = this.adapter.getElementSize(this);
34614 this.activeMinSize = this.getMinimumSize();;
34615 this.activeMaxSize = this.getMaximumSize();;
34616 var c1 = size - this.activeMinSize;
34617 var c2 = Math.max(this.activeMaxSize - size, 0);
34618 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34619 this.dd.resetConstraints();
34620 this.dd.setXConstraint(
34621 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34622 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34624 this.dd.setYConstraint(0, 0);
34626 this.dd.resetConstraints();
34627 this.dd.setXConstraint(0, 0);
34628 this.dd.setYConstraint(
34629 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34630 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34633 this.dragSpecs.startSize = size;
34634 this.dragSpecs.startPoint = [x, y];
34635 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34639 * @private Called after the drag operation by the DDProxy
34641 onEndProxyDrag : function(e){
34642 Roo.get(this.proxy).setDisplayed(false);
34643 var endPoint = Roo.lib.Event.getXY(e);
34645 this.overlay.hide();
34648 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34649 newSize = this.dragSpecs.startSize +
34650 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34651 endPoint[0] - this.dragSpecs.startPoint[0] :
34652 this.dragSpecs.startPoint[0] - endPoint[0]
34655 newSize = this.dragSpecs.startSize +
34656 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34657 endPoint[1] - this.dragSpecs.startPoint[1] :
34658 this.dragSpecs.startPoint[1] - endPoint[1]
34661 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34662 if(newSize != this.dragSpecs.startSize){
34663 if(this.fireEvent('beforeapply', this, newSize) !== false){
34664 this.adapter.setElementSize(this, newSize);
34665 this.fireEvent("moved", this, newSize);
34666 this.fireEvent("resize", this, newSize);
34672 * Get the adapter this SplitBar uses
34673 * @return The adapter object
34675 getAdapter : function(){
34676 return this.adapter;
34680 * Set the adapter this SplitBar uses
34681 * @param {Object} adapter A SplitBar adapter object
34683 setAdapter : function(adapter){
34684 this.adapter = adapter;
34685 this.adapter.init(this);
34689 * Gets the minimum size for the resizing element
34690 * @return {Number} The minimum size
34692 getMinimumSize : function(){
34693 return this.minSize;
34697 * Sets the minimum size for the resizing element
34698 * @param {Number} minSize The minimum size
34700 setMinimumSize : function(minSize){
34701 this.minSize = minSize;
34705 * Gets the maximum size for the resizing element
34706 * @return {Number} The maximum size
34708 getMaximumSize : function(){
34709 return this.maxSize;
34713 * Sets the maximum size for the resizing element
34714 * @param {Number} maxSize The maximum size
34716 setMaximumSize : function(maxSize){
34717 this.maxSize = maxSize;
34721 * Sets the initialize size for the resizing element
34722 * @param {Number} size The initial size
34724 setCurrentSize : function(size){
34725 var oldAnimate = this.animate;
34726 this.animate = false;
34727 this.adapter.setElementSize(this, size);
34728 this.animate = oldAnimate;
34732 * Destroy this splitbar.
34733 * @param {Boolean} removeEl True to remove the element
34735 destroy : function(removeEl){
34737 this.shim.remove();
34740 this.proxy.parentNode.removeChild(this.proxy);
34748 * @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.
34750 Roo.bootstrap.SplitBar.createProxy = function(dir){
34751 var proxy = new Roo.Element(document.createElement("div"));
34752 proxy.unselectable();
34753 var cls = 'roo-splitbar-proxy';
34754 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34755 document.body.appendChild(proxy.dom);
34760 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34761 * Default Adapter. It assumes the splitter and resizing element are not positioned
34762 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34764 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34767 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34768 // do nothing for now
34769 init : function(s){
34773 * Called before drag operations to get the current size of the resizing element.
34774 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34776 getElementSize : function(s){
34777 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34778 return s.resizingEl.getWidth();
34780 return s.resizingEl.getHeight();
34785 * Called after drag operations to set the size of the resizing element.
34786 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34787 * @param {Number} newSize The new size to set
34788 * @param {Function} onComplete A function to be invoked when resizing is complete
34790 setElementSize : function(s, newSize, onComplete){
34791 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34793 s.resizingEl.setWidth(newSize);
34795 onComplete(s, newSize);
34798 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34803 s.resizingEl.setHeight(newSize);
34805 onComplete(s, newSize);
34808 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34815 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34816 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34817 * Adapter that moves the splitter element to align with the resized sizing element.
34818 * Used with an absolute positioned SplitBar.
34819 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34820 * document.body, make sure you assign an id to the body element.
34822 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34823 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34824 this.container = Roo.get(container);
34827 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34828 init : function(s){
34829 this.basic.init(s);
34832 getElementSize : function(s){
34833 return this.basic.getElementSize(s);
34836 setElementSize : function(s, newSize, onComplete){
34837 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34840 moveSplitter : function(s){
34841 var yes = Roo.bootstrap.SplitBar;
34842 switch(s.placement){
34844 s.el.setX(s.resizingEl.getRight());
34847 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34850 s.el.setY(s.resizingEl.getBottom());
34853 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34860 * Orientation constant - Create a vertical SplitBar
34864 Roo.bootstrap.SplitBar.VERTICAL = 1;
34867 * Orientation constant - Create a horizontal SplitBar
34871 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34874 * Placement constant - The resizing element is to the left of the splitter element
34878 Roo.bootstrap.SplitBar.LEFT = 1;
34881 * Placement constant - The resizing element is to the right of the splitter element
34885 Roo.bootstrap.SplitBar.RIGHT = 2;
34888 * Placement constant - The resizing element is positioned above the splitter element
34892 Roo.bootstrap.SplitBar.TOP = 3;
34895 * Placement constant - The resizing element is positioned under splitter element
34899 Roo.bootstrap.SplitBar.BOTTOM = 4;
34900 Roo.namespace("Roo.bootstrap.layout");/*
34902 * Ext JS Library 1.1.1
34903 * Copyright(c) 2006-2007, Ext JS, LLC.
34905 * Originally Released Under LGPL - original licence link has changed is not relivant.
34908 * <script type="text/javascript">
34912 * @class Roo.bootstrap.layout.Manager
34913 * @extends Roo.bootstrap.Component
34914 * Base class for layout managers.
34916 Roo.bootstrap.layout.Manager = function(config)
34918 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34924 /** false to disable window resize monitoring @type Boolean */
34925 this.monitorWindowResize = true;
34930 * Fires when a layout is performed.
34931 * @param {Roo.LayoutManager} this
34935 * @event regionresized
34936 * Fires when the user resizes a region.
34937 * @param {Roo.LayoutRegion} region The resized region
34938 * @param {Number} newSize The new size (width for east/west, height for north/south)
34940 "regionresized" : true,
34942 * @event regioncollapsed
34943 * Fires when a region is collapsed.
34944 * @param {Roo.LayoutRegion} region The collapsed region
34946 "regioncollapsed" : true,
34948 * @event regionexpanded
34949 * Fires when a region is expanded.
34950 * @param {Roo.LayoutRegion} region The expanded region
34952 "regionexpanded" : true
34954 this.updating = false;
34957 this.el = Roo.get(config.el);
34963 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34968 monitorWindowResize : true,
34974 onRender : function(ct, position)
34977 this.el = Roo.get(ct);
34980 //this.fireEvent('render',this);
34984 initEvents: function()
34988 // ie scrollbar fix
34989 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34990 document.body.scroll = "no";
34991 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34992 this.el.position('relative');
34994 this.id = this.el.id;
34995 this.el.addClass("roo-layout-container");
34996 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34997 if(this.el.dom != document.body ) {
34998 this.el.on('resize', this.layout,this);
34999 this.el.on('show', this.layout,this);
35005 * Returns true if this layout is currently being updated
35006 * @return {Boolean}
35008 isUpdating : function(){
35009 return this.updating;
35013 * Suspend the LayoutManager from doing auto-layouts while
35014 * making multiple add or remove calls
35016 beginUpdate : function(){
35017 this.updating = true;
35021 * Restore auto-layouts and optionally disable the manager from performing a layout
35022 * @param {Boolean} noLayout true to disable a layout update
35024 endUpdate : function(noLayout){
35025 this.updating = false;
35031 layout: function(){
35035 onRegionResized : function(region, newSize){
35036 this.fireEvent("regionresized", region, newSize);
35040 onRegionCollapsed : function(region){
35041 this.fireEvent("regioncollapsed", region);
35044 onRegionExpanded : function(region){
35045 this.fireEvent("regionexpanded", region);
35049 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35050 * performs box-model adjustments.
35051 * @return {Object} The size as an object {width: (the width), height: (the height)}
35053 getViewSize : function()
35056 if(this.el.dom != document.body){
35057 size = this.el.getSize();
35059 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35061 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35062 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35067 * Returns the Element this layout is bound to.
35068 * @return {Roo.Element}
35070 getEl : function(){
35075 * Returns the specified region.
35076 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35077 * @return {Roo.LayoutRegion}
35079 getRegion : function(target){
35080 return this.regions[target.toLowerCase()];
35083 onWindowResize : function(){
35084 if(this.monitorWindowResize){
35091 * Ext JS Library 1.1.1
35092 * Copyright(c) 2006-2007, Ext JS, LLC.
35094 * Originally Released Under LGPL - original licence link has changed is not relivant.
35097 * <script type="text/javascript">
35100 * @class Roo.bootstrap.layout.Border
35101 * @extends Roo.bootstrap.layout.Manager
35102 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35103 * please see: examples/bootstrap/nested.html<br><br>
35105 <b>The container the layout is rendered into can be either the body element or any other element.
35106 If it is not the body element, the container needs to either be an absolute positioned element,
35107 or you will need to add "position:relative" to the css of the container. You will also need to specify
35108 the container size if it is not the body element.</b>
35111 * Create a new Border
35112 * @param {Object} config Configuration options
35114 Roo.bootstrap.layout.Border = function(config){
35115 config = config || {};
35116 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35120 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35121 if(config[region]){
35122 config[region].region = region;
35123 this.addRegion(config[region]);
35129 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35131 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35133 parent : false, // this might point to a 'nest' or a ???
35136 * Creates and adds a new region if it doesn't already exist.
35137 * @param {String} target The target region key (north, south, east, west or center).
35138 * @param {Object} config The regions config object
35139 * @return {BorderLayoutRegion} The new region
35141 addRegion : function(config)
35143 if(!this.regions[config.region]){
35144 var r = this.factory(config);
35145 this.bindRegion(r);
35147 return this.regions[config.region];
35151 bindRegion : function(r){
35152 this.regions[r.config.region] = r;
35154 r.on("visibilitychange", this.layout, this);
35155 r.on("paneladded", this.layout, this);
35156 r.on("panelremoved", this.layout, this);
35157 r.on("invalidated", this.layout, this);
35158 r.on("resized", this.onRegionResized, this);
35159 r.on("collapsed", this.onRegionCollapsed, this);
35160 r.on("expanded", this.onRegionExpanded, this);
35164 * Performs a layout update.
35166 layout : function()
35168 if(this.updating) {
35172 // render all the rebions if they have not been done alreayd?
35173 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35174 if(this.regions[region] && !this.regions[region].bodyEl){
35175 this.regions[region].onRender(this.el)
35179 var size = this.getViewSize();
35180 var w = size.width;
35181 var h = size.height;
35186 //var x = 0, y = 0;
35188 var rs = this.regions;
35189 var north = rs["north"];
35190 var south = rs["south"];
35191 var west = rs["west"];
35192 var east = rs["east"];
35193 var center = rs["center"];
35194 //if(this.hideOnLayout){ // not supported anymore
35195 //c.el.setStyle("display", "none");
35197 if(north && north.isVisible()){
35198 var b = north.getBox();
35199 var m = north.getMargins();
35200 b.width = w - (m.left+m.right);
35203 centerY = b.height + b.y + m.bottom;
35204 centerH -= centerY;
35205 north.updateBox(this.safeBox(b));
35207 if(south && south.isVisible()){
35208 var b = south.getBox();
35209 var m = south.getMargins();
35210 b.width = w - (m.left+m.right);
35212 var totalHeight = (b.height + m.top + m.bottom);
35213 b.y = h - totalHeight + m.top;
35214 centerH -= totalHeight;
35215 south.updateBox(this.safeBox(b));
35217 if(west && west.isVisible()){
35218 var b = west.getBox();
35219 var m = west.getMargins();
35220 b.height = centerH - (m.top+m.bottom);
35222 b.y = centerY + m.top;
35223 var totalWidth = (b.width + m.left + m.right);
35224 centerX += totalWidth;
35225 centerW -= totalWidth;
35226 west.updateBox(this.safeBox(b));
35228 if(east && east.isVisible()){
35229 var b = east.getBox();
35230 var m = east.getMargins();
35231 b.height = centerH - (m.top+m.bottom);
35232 var totalWidth = (b.width + m.left + m.right);
35233 b.x = w - totalWidth + m.left;
35234 b.y = centerY + m.top;
35235 centerW -= totalWidth;
35236 east.updateBox(this.safeBox(b));
35239 var m = center.getMargins();
35241 x: centerX + m.left,
35242 y: centerY + m.top,
35243 width: centerW - (m.left+m.right),
35244 height: centerH - (m.top+m.bottom)
35246 //if(this.hideOnLayout){
35247 //center.el.setStyle("display", "block");
35249 center.updateBox(this.safeBox(centerBox));
35252 this.fireEvent("layout", this);
35256 safeBox : function(box){
35257 box.width = Math.max(0, box.width);
35258 box.height = Math.max(0, box.height);
35263 * Adds a ContentPanel (or subclass) to this layout.
35264 * @param {String} target The target region key (north, south, east, west or center).
35265 * @param {Roo.ContentPanel} panel The panel to add
35266 * @return {Roo.ContentPanel} The added panel
35268 add : function(target, panel){
35270 target = target.toLowerCase();
35271 return this.regions[target].add(panel);
35275 * Remove a ContentPanel (or subclass) to this layout.
35276 * @param {String} target The target region key (north, south, east, west or center).
35277 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35278 * @return {Roo.ContentPanel} The removed panel
35280 remove : function(target, panel){
35281 target = target.toLowerCase();
35282 return this.regions[target].remove(panel);
35286 * Searches all regions for a panel with the specified id
35287 * @param {String} panelId
35288 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35290 findPanel : function(panelId){
35291 var rs = this.regions;
35292 for(var target in rs){
35293 if(typeof rs[target] != "function"){
35294 var p = rs[target].getPanel(panelId);
35304 * Searches all regions for a panel with the specified id and activates (shows) it.
35305 * @param {String/ContentPanel} panelId The panels id or the panel itself
35306 * @return {Roo.ContentPanel} The shown panel or null
35308 showPanel : function(panelId) {
35309 var rs = this.regions;
35310 for(var target in rs){
35311 var r = rs[target];
35312 if(typeof r != "function"){
35313 if(r.hasPanel(panelId)){
35314 return r.showPanel(panelId);
35322 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35323 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35326 restoreState : function(provider){
35328 provider = Roo.state.Manager;
35330 var sm = new Roo.LayoutStateManager();
35331 sm.init(this, provider);
35337 * Adds a xtype elements to the layout.
35341 xtype : 'ContentPanel',
35348 xtype : 'NestedLayoutPanel',
35354 items : [ ... list of content panels or nested layout panels.. ]
35358 * @param {Object} cfg Xtype definition of item to add.
35360 addxtype : function(cfg)
35362 // basically accepts a pannel...
35363 // can accept a layout region..!?!?
35364 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35367 // theory? children can only be panels??
35369 //if (!cfg.xtype.match(/Panel$/)) {
35374 if (typeof(cfg.region) == 'undefined') {
35375 Roo.log("Failed to add Panel, region was not set");
35379 var region = cfg.region;
35385 xitems = cfg.items;
35390 if ( region == 'center') {
35391 Roo.log("Center: " + cfg.title);
35397 case 'Content': // ContentPanel (el, cfg)
35398 case 'Scroll': // ContentPanel (el, cfg)
35400 cfg.autoCreate = cfg.autoCreate || true;
35401 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35403 // var el = this.el.createChild();
35404 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35407 this.add(region, ret);
35411 case 'TreePanel': // our new panel!
35412 cfg.el = this.el.createChild();
35413 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35414 this.add(region, ret);
35419 // create a new Layout (which is a Border Layout...
35421 var clayout = cfg.layout;
35422 clayout.el = this.el.createChild();
35423 clayout.items = clayout.items || [];
35427 // replace this exitems with the clayout ones..
35428 xitems = clayout.items;
35430 // force background off if it's in center...
35431 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35432 cfg.background = false;
35434 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35437 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35438 //console.log('adding nested layout panel ' + cfg.toSource());
35439 this.add(region, ret);
35440 nb = {}; /// find first...
35445 // needs grid and region
35447 //var el = this.getRegion(region).el.createChild();
35449 *var el = this.el.createChild();
35450 // create the grid first...
35451 cfg.grid.container = el;
35452 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35455 if (region == 'center' && this.active ) {
35456 cfg.background = false;
35459 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35461 this.add(region, ret);
35463 if (cfg.background) {
35464 // render grid on panel activation (if panel background)
35465 ret.on('activate', function(gp) {
35466 if (!gp.grid.rendered) {
35467 // gp.grid.render(el);
35471 // cfg.grid.render(el);
35477 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35478 // it was the old xcomponent building that caused this before.
35479 // espeically if border is the top element in the tree.
35489 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35491 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35492 this.add(region, ret);
35496 throw "Can not add '" + cfg.xtype + "' to Border";
35502 this.beginUpdate();
35506 Roo.each(xitems, function(i) {
35507 region = nb && i.region ? i.region : false;
35509 var add = ret.addxtype(i);
35512 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35513 if (!i.background) {
35514 abn[region] = nb[region] ;
35521 // make the last non-background panel active..
35522 //if (nb) { Roo.log(abn); }
35525 for(var r in abn) {
35526 region = this.getRegion(r);
35528 // tried using nb[r], but it does not work..
35530 region.showPanel(abn[r]);
35541 factory : function(cfg)
35544 var validRegions = Roo.bootstrap.layout.Border.regions;
35546 var target = cfg.region;
35549 var r = Roo.bootstrap.layout;
35553 return new r.North(cfg);
35555 return new r.South(cfg);
35557 return new r.East(cfg);
35559 return new r.West(cfg);
35561 return new r.Center(cfg);
35563 throw 'Layout region "'+target+'" not supported.';
35570 * Ext JS Library 1.1.1
35571 * Copyright(c) 2006-2007, Ext JS, LLC.
35573 * Originally Released Under LGPL - original licence link has changed is not relivant.
35576 * <script type="text/javascript">
35580 * @class Roo.bootstrap.layout.Basic
35581 * @extends Roo.util.Observable
35582 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35583 * and does not have a titlebar, tabs or any other features. All it does is size and position
35584 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35585 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35586 * @cfg {string} region the region that it inhabits..
35587 * @cfg {bool} skipConfig skip config?
35591 Roo.bootstrap.layout.Basic = function(config){
35593 this.mgr = config.mgr;
35595 this.position = config.region;
35597 var skipConfig = config.skipConfig;
35601 * @scope Roo.BasicLayoutRegion
35605 * @event beforeremove
35606 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35607 * @param {Roo.LayoutRegion} this
35608 * @param {Roo.ContentPanel} panel The panel
35609 * @param {Object} e The cancel event object
35611 "beforeremove" : true,
35613 * @event invalidated
35614 * Fires when the layout for this region is changed.
35615 * @param {Roo.LayoutRegion} this
35617 "invalidated" : true,
35619 * @event visibilitychange
35620 * Fires when this region is shown or hidden
35621 * @param {Roo.LayoutRegion} this
35622 * @param {Boolean} visibility true or false
35624 "visibilitychange" : true,
35626 * @event paneladded
35627 * Fires when a panel is added.
35628 * @param {Roo.LayoutRegion} this
35629 * @param {Roo.ContentPanel} panel The panel
35631 "paneladded" : true,
35633 * @event panelremoved
35634 * Fires when a panel is removed.
35635 * @param {Roo.LayoutRegion} this
35636 * @param {Roo.ContentPanel} panel The panel
35638 "panelremoved" : true,
35640 * @event beforecollapse
35641 * Fires when this region before collapse.
35642 * @param {Roo.LayoutRegion} this
35644 "beforecollapse" : true,
35647 * Fires when this region is collapsed.
35648 * @param {Roo.LayoutRegion} this
35650 "collapsed" : true,
35653 * Fires when this region is expanded.
35654 * @param {Roo.LayoutRegion} this
35659 * Fires when this region is slid into view.
35660 * @param {Roo.LayoutRegion} this
35662 "slideshow" : true,
35665 * Fires when this region slides out of view.
35666 * @param {Roo.LayoutRegion} this
35668 "slidehide" : true,
35670 * @event panelactivated
35671 * Fires when a panel is activated.
35672 * @param {Roo.LayoutRegion} this
35673 * @param {Roo.ContentPanel} panel The activated panel
35675 "panelactivated" : true,
35678 * Fires when the user resizes this region.
35679 * @param {Roo.LayoutRegion} this
35680 * @param {Number} newSize The new size (width for east/west, height for north/south)
35684 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35685 this.panels = new Roo.util.MixedCollection();
35686 this.panels.getKey = this.getPanelId.createDelegate(this);
35688 this.activePanel = null;
35689 // ensure listeners are added...
35691 if (config.listeners || config.events) {
35692 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35693 listeners : config.listeners || {},
35694 events : config.events || {}
35698 if(skipConfig !== true){
35699 this.applyConfig(config);
35703 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35705 getPanelId : function(p){
35709 applyConfig : function(config){
35710 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35711 this.config = config;
35716 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35717 * the width, for horizontal (north, south) the height.
35718 * @param {Number} newSize The new width or height
35720 resizeTo : function(newSize){
35721 var el = this.el ? this.el :
35722 (this.activePanel ? this.activePanel.getEl() : null);
35724 switch(this.position){
35727 el.setWidth(newSize);
35728 this.fireEvent("resized", this, newSize);
35732 el.setHeight(newSize);
35733 this.fireEvent("resized", this, newSize);
35739 getBox : function(){
35740 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35743 getMargins : function(){
35744 return this.margins;
35747 updateBox : function(box){
35749 var el = this.activePanel.getEl();
35750 el.dom.style.left = box.x + "px";
35751 el.dom.style.top = box.y + "px";
35752 this.activePanel.setSize(box.width, box.height);
35756 * Returns the container element for this region.
35757 * @return {Roo.Element}
35759 getEl : function(){
35760 return this.activePanel;
35764 * Returns true if this region is currently visible.
35765 * @return {Boolean}
35767 isVisible : function(){
35768 return this.activePanel ? true : false;
35771 setActivePanel : function(panel){
35772 panel = this.getPanel(panel);
35773 if(this.activePanel && this.activePanel != panel){
35774 this.activePanel.setActiveState(false);
35775 this.activePanel.getEl().setLeftTop(-10000,-10000);
35777 this.activePanel = panel;
35778 panel.setActiveState(true);
35780 panel.setSize(this.box.width, this.box.height);
35782 this.fireEvent("panelactivated", this, panel);
35783 this.fireEvent("invalidated");
35787 * Show the specified panel.
35788 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35789 * @return {Roo.ContentPanel} The shown panel or null
35791 showPanel : function(panel){
35792 panel = this.getPanel(panel);
35794 this.setActivePanel(panel);
35800 * Get the active panel for this region.
35801 * @return {Roo.ContentPanel} The active panel or null
35803 getActivePanel : function(){
35804 return this.activePanel;
35808 * Add the passed ContentPanel(s)
35809 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35810 * @return {Roo.ContentPanel} The panel added (if only one was added)
35812 add : function(panel){
35813 if(arguments.length > 1){
35814 for(var i = 0, len = arguments.length; i < len; i++) {
35815 this.add(arguments[i]);
35819 if(this.hasPanel(panel)){
35820 this.showPanel(panel);
35823 var el = panel.getEl();
35824 if(el.dom.parentNode != this.mgr.el.dom){
35825 this.mgr.el.dom.appendChild(el.dom);
35827 if(panel.setRegion){
35828 panel.setRegion(this);
35830 this.panels.add(panel);
35831 el.setStyle("position", "absolute");
35832 if(!panel.background){
35833 this.setActivePanel(panel);
35834 if(this.config.initialSize && this.panels.getCount()==1){
35835 this.resizeTo(this.config.initialSize);
35838 this.fireEvent("paneladded", this, panel);
35843 * Returns true if the panel is in this region.
35844 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35845 * @return {Boolean}
35847 hasPanel : function(panel){
35848 if(typeof panel == "object"){ // must be panel obj
35849 panel = panel.getId();
35851 return this.getPanel(panel) ? true : false;
35855 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35856 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35857 * @param {Boolean} preservePanel Overrides the config preservePanel option
35858 * @return {Roo.ContentPanel} The panel that was removed
35860 remove : function(panel, preservePanel){
35861 panel = this.getPanel(panel);
35866 this.fireEvent("beforeremove", this, panel, e);
35867 if(e.cancel === true){
35870 var panelId = panel.getId();
35871 this.panels.removeKey(panelId);
35876 * Returns the panel specified or null if it's not in this region.
35877 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35878 * @return {Roo.ContentPanel}
35880 getPanel : function(id){
35881 if(typeof id == "object"){ // must be panel obj
35884 return this.panels.get(id);
35888 * Returns this regions position (north/south/east/west/center).
35891 getPosition: function(){
35892 return this.position;
35896 * Ext JS Library 1.1.1
35897 * Copyright(c) 2006-2007, Ext JS, LLC.
35899 * Originally Released Under LGPL - original licence link has changed is not relivant.
35902 * <script type="text/javascript">
35906 * @class Roo.bootstrap.layout.Region
35907 * @extends Roo.bootstrap.layout.Basic
35908 * This class represents a region in a layout manager.
35910 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35911 * @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})
35912 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35913 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35914 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35915 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35916 * @cfg {String} title The title for the region (overrides panel titles)
35917 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35918 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35919 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35920 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35921 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35922 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35923 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35924 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35925 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35926 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35928 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35929 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35930 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35931 * @cfg {Number} width For East/West panels
35932 * @cfg {Number} height For North/South panels
35933 * @cfg {Boolean} split To show the splitter
35934 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35936 * @cfg {string} cls Extra CSS classes to add to region
35938 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35939 * @cfg {string} region the region that it inhabits..
35942 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35943 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35945 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35946 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35947 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35949 Roo.bootstrap.layout.Region = function(config)
35951 this.applyConfig(config);
35953 var mgr = config.mgr;
35954 var pos = config.region;
35955 config.skipConfig = true;
35956 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35959 this.onRender(mgr.el);
35962 this.visible = true;
35963 this.collapsed = false;
35964 this.unrendered_panels = [];
35967 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35969 position: '', // set by wrapper (eg. north/south etc..)
35970 unrendered_panels : null, // unrendered panels.
35972 tabPosition : false,
35974 mgr: false, // points to 'Border'
35977 createBody : function(){
35978 /** This region's body element
35979 * @type Roo.Element */
35980 this.bodyEl = this.el.createChild({
35982 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35986 onRender: function(ctr, pos)
35988 var dh = Roo.DomHelper;
35989 /** This region's container element
35990 * @type Roo.Element */
35991 this.el = dh.append(ctr.dom, {
35993 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35995 /** This region's title element
35996 * @type Roo.Element */
35998 this.titleEl = dh.append(this.el.dom, {
36000 unselectable: "on",
36001 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36003 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36004 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36008 this.titleEl.enableDisplayMode();
36009 /** This region's title text element
36010 * @type HTMLElement */
36011 this.titleTextEl = this.titleEl.dom.firstChild;
36012 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36014 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36015 this.closeBtn.enableDisplayMode();
36016 this.closeBtn.on("click", this.closeClicked, this);
36017 this.closeBtn.hide();
36019 this.createBody(this.config);
36020 if(this.config.hideWhenEmpty){
36022 this.on("paneladded", this.validateVisibility, this);
36023 this.on("panelremoved", this.validateVisibility, this);
36025 if(this.autoScroll){
36026 this.bodyEl.setStyle("overflow", "auto");
36028 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36030 //if(c.titlebar !== false){
36031 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36032 this.titleEl.hide();
36034 this.titleEl.show();
36035 if(this.config.title){
36036 this.titleTextEl.innerHTML = this.config.title;
36040 if(this.config.collapsed){
36041 this.collapse(true);
36043 if(this.config.hidden){
36047 if (this.unrendered_panels && this.unrendered_panels.length) {
36048 for (var i =0;i< this.unrendered_panels.length; i++) {
36049 this.add(this.unrendered_panels[i]);
36051 this.unrendered_panels = null;
36057 applyConfig : function(c)
36060 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36061 var dh = Roo.DomHelper;
36062 if(c.titlebar !== false){
36063 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36064 this.collapseBtn.on("click", this.collapse, this);
36065 this.collapseBtn.enableDisplayMode();
36067 if(c.showPin === true || this.showPin){
36068 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36069 this.stickBtn.enableDisplayMode();
36070 this.stickBtn.on("click", this.expand, this);
36071 this.stickBtn.hide();
36076 /** This region's collapsed element
36077 * @type Roo.Element */
36080 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36081 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36084 if(c.floatable !== false){
36085 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36086 this.collapsedEl.on("click", this.collapseClick, this);
36089 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36090 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36091 id: "message", unselectable: "on", style:{"float":"left"}});
36092 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36094 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36095 this.expandBtn.on("click", this.expand, this);
36099 if(this.collapseBtn){
36100 this.collapseBtn.setVisible(c.collapsible == true);
36103 this.cmargins = c.cmargins || this.cmargins ||
36104 (this.position == "west" || this.position == "east" ?
36105 {top: 0, left: 2, right:2, bottom: 0} :
36106 {top: 2, left: 0, right:0, bottom: 2});
36108 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36111 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36113 this.autoScroll = c.autoScroll || false;
36118 this.duration = c.duration || .30;
36119 this.slideDuration = c.slideDuration || .45;
36124 * Returns true if this region is currently visible.
36125 * @return {Boolean}
36127 isVisible : function(){
36128 return this.visible;
36132 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36133 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36135 //setCollapsedTitle : function(title){
36136 // title = title || " ";
36137 // if(this.collapsedTitleTextEl){
36138 // this.collapsedTitleTextEl.innerHTML = title;
36142 getBox : function(){
36144 // if(!this.collapsed){
36145 b = this.el.getBox(false, true);
36147 // b = this.collapsedEl.getBox(false, true);
36152 getMargins : function(){
36153 return this.margins;
36154 //return this.collapsed ? this.cmargins : this.margins;
36157 highlight : function(){
36158 this.el.addClass("x-layout-panel-dragover");
36161 unhighlight : function(){
36162 this.el.removeClass("x-layout-panel-dragover");
36165 updateBox : function(box)
36167 if (!this.bodyEl) {
36168 return; // not rendered yet..
36172 if(!this.collapsed){
36173 this.el.dom.style.left = box.x + "px";
36174 this.el.dom.style.top = box.y + "px";
36175 this.updateBody(box.width, box.height);
36177 this.collapsedEl.dom.style.left = box.x + "px";
36178 this.collapsedEl.dom.style.top = box.y + "px";
36179 this.collapsedEl.setSize(box.width, box.height);
36182 this.tabs.autoSizeTabs();
36186 updateBody : function(w, h)
36189 this.el.setWidth(w);
36190 w -= this.el.getBorderWidth("rl");
36191 if(this.config.adjustments){
36192 w += this.config.adjustments[0];
36195 if(h !== null && h > 0){
36196 this.el.setHeight(h);
36197 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36198 h -= this.el.getBorderWidth("tb");
36199 if(this.config.adjustments){
36200 h += this.config.adjustments[1];
36202 this.bodyEl.setHeight(h);
36204 h = this.tabs.syncHeight(h);
36207 if(this.panelSize){
36208 w = w !== null ? w : this.panelSize.width;
36209 h = h !== null ? h : this.panelSize.height;
36211 if(this.activePanel){
36212 var el = this.activePanel.getEl();
36213 w = w !== null ? w : el.getWidth();
36214 h = h !== null ? h : el.getHeight();
36215 this.panelSize = {width: w, height: h};
36216 this.activePanel.setSize(w, h);
36218 if(Roo.isIE && this.tabs){
36219 this.tabs.el.repaint();
36224 * Returns the container element for this region.
36225 * @return {Roo.Element}
36227 getEl : function(){
36232 * Hides this region.
36235 //if(!this.collapsed){
36236 this.el.dom.style.left = "-2000px";
36239 // this.collapsedEl.dom.style.left = "-2000px";
36240 // this.collapsedEl.hide();
36242 this.visible = false;
36243 this.fireEvent("visibilitychange", this, false);
36247 * Shows this region if it was previously hidden.
36250 //if(!this.collapsed){
36253 // this.collapsedEl.show();
36255 this.visible = true;
36256 this.fireEvent("visibilitychange", this, true);
36259 closeClicked : function(){
36260 if(this.activePanel){
36261 this.remove(this.activePanel);
36265 collapseClick : function(e){
36267 e.stopPropagation();
36270 e.stopPropagation();
36276 * Collapses this region.
36277 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36280 collapse : function(skipAnim, skipCheck = false){
36281 if(this.collapsed) {
36285 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36287 this.collapsed = true;
36289 this.split.el.hide();
36291 if(this.config.animate && skipAnim !== true){
36292 this.fireEvent("invalidated", this);
36293 this.animateCollapse();
36295 this.el.setLocation(-20000,-20000);
36297 this.collapsedEl.show();
36298 this.fireEvent("collapsed", this);
36299 this.fireEvent("invalidated", this);
36305 animateCollapse : function(){
36310 * Expands this region if it was previously collapsed.
36311 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36312 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36315 expand : function(e, skipAnim){
36317 e.stopPropagation();
36319 if(!this.collapsed || this.el.hasActiveFx()) {
36323 this.afterSlideIn();
36326 this.collapsed = false;
36327 if(this.config.animate && skipAnim !== true){
36328 this.animateExpand();
36332 this.split.el.show();
36334 this.collapsedEl.setLocation(-2000,-2000);
36335 this.collapsedEl.hide();
36336 this.fireEvent("invalidated", this);
36337 this.fireEvent("expanded", this);
36341 animateExpand : function(){
36345 initTabs : function()
36347 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36349 var ts = new Roo.bootstrap.panel.Tabs({
36350 el: this.bodyEl.dom,
36352 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36353 disableTooltips: this.config.disableTabTips,
36354 toolbar : this.config.toolbar
36357 if(this.config.hideTabs){
36358 ts.stripWrap.setDisplayed(false);
36361 ts.resizeTabs = this.config.resizeTabs === true;
36362 ts.minTabWidth = this.config.minTabWidth || 40;
36363 ts.maxTabWidth = this.config.maxTabWidth || 250;
36364 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36365 ts.monitorResize = false;
36366 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36367 ts.bodyEl.addClass('roo-layout-tabs-body');
36368 this.panels.each(this.initPanelAsTab, this);
36371 initPanelAsTab : function(panel){
36372 var ti = this.tabs.addTab(
36376 this.config.closeOnTab && panel.isClosable(),
36379 if(panel.tabTip !== undefined){
36380 ti.setTooltip(panel.tabTip);
36382 ti.on("activate", function(){
36383 this.setActivePanel(panel);
36386 if(this.config.closeOnTab){
36387 ti.on("beforeclose", function(t, e){
36389 this.remove(panel);
36393 panel.tabItem = ti;
36398 updatePanelTitle : function(panel, title)
36400 if(this.activePanel == panel){
36401 this.updateTitle(title);
36404 var ti = this.tabs.getTab(panel.getEl().id);
36406 if(panel.tabTip !== undefined){
36407 ti.setTooltip(panel.tabTip);
36412 updateTitle : function(title){
36413 if(this.titleTextEl && !this.config.title){
36414 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36418 setActivePanel : function(panel)
36420 panel = this.getPanel(panel);
36421 if(this.activePanel && this.activePanel != panel){
36422 if(this.activePanel.setActiveState(false) === false){
36426 this.activePanel = panel;
36427 panel.setActiveState(true);
36428 if(this.panelSize){
36429 panel.setSize(this.panelSize.width, this.panelSize.height);
36432 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36434 this.updateTitle(panel.getTitle());
36436 this.fireEvent("invalidated", this);
36438 this.fireEvent("panelactivated", this, panel);
36442 * Shows the specified panel.
36443 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36444 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36446 showPanel : function(panel)
36448 panel = this.getPanel(panel);
36451 var tab = this.tabs.getTab(panel.getEl().id);
36452 if(tab.isHidden()){
36453 this.tabs.unhideTab(tab.id);
36457 this.setActivePanel(panel);
36464 * Get the active panel for this region.
36465 * @return {Roo.ContentPanel} The active panel or null
36467 getActivePanel : function(){
36468 return this.activePanel;
36471 validateVisibility : function(){
36472 if(this.panels.getCount() < 1){
36473 this.updateTitle(" ");
36474 this.closeBtn.hide();
36477 if(!this.isVisible()){
36484 * Adds the passed ContentPanel(s) to this region.
36485 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36486 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36488 add : function(panel)
36490 if(arguments.length > 1){
36491 for(var i = 0, len = arguments.length; i < len; i++) {
36492 this.add(arguments[i]);
36497 // if we have not been rendered yet, then we can not really do much of this..
36498 if (!this.bodyEl) {
36499 this.unrendered_panels.push(panel);
36506 if(this.hasPanel(panel)){
36507 this.showPanel(panel);
36510 panel.setRegion(this);
36511 this.panels.add(panel);
36512 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36513 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36514 // and hide them... ???
36515 this.bodyEl.dom.appendChild(panel.getEl().dom);
36516 if(panel.background !== true){
36517 this.setActivePanel(panel);
36519 this.fireEvent("paneladded", this, panel);
36526 this.initPanelAsTab(panel);
36530 if(panel.background !== true){
36531 this.tabs.activate(panel.getEl().id);
36533 this.fireEvent("paneladded", this, panel);
36538 * Hides the tab for the specified panel.
36539 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36541 hidePanel : function(panel){
36542 if(this.tabs && (panel = this.getPanel(panel))){
36543 this.tabs.hideTab(panel.getEl().id);
36548 * Unhides the tab for a previously hidden panel.
36549 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36551 unhidePanel : function(panel){
36552 if(this.tabs && (panel = this.getPanel(panel))){
36553 this.tabs.unhideTab(panel.getEl().id);
36557 clearPanels : function(){
36558 while(this.panels.getCount() > 0){
36559 this.remove(this.panels.first());
36564 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36565 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36566 * @param {Boolean} preservePanel Overrides the config preservePanel option
36567 * @return {Roo.ContentPanel} The panel that was removed
36569 remove : function(panel, preservePanel)
36571 panel = this.getPanel(panel);
36576 this.fireEvent("beforeremove", this, panel, e);
36577 if(e.cancel === true){
36580 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36581 var panelId = panel.getId();
36582 this.panels.removeKey(panelId);
36584 document.body.appendChild(panel.getEl().dom);
36587 this.tabs.removeTab(panel.getEl().id);
36588 }else if (!preservePanel){
36589 this.bodyEl.dom.removeChild(panel.getEl().dom);
36591 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36592 var p = this.panels.first();
36593 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36594 tempEl.appendChild(p.getEl().dom);
36595 this.bodyEl.update("");
36596 this.bodyEl.dom.appendChild(p.getEl().dom);
36598 this.updateTitle(p.getTitle());
36600 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36601 this.setActivePanel(p);
36603 panel.setRegion(null);
36604 if(this.activePanel == panel){
36605 this.activePanel = null;
36607 if(this.config.autoDestroy !== false && preservePanel !== true){
36608 try{panel.destroy();}catch(e){}
36610 this.fireEvent("panelremoved", this, panel);
36615 * Returns the TabPanel component used by this region
36616 * @return {Roo.TabPanel}
36618 getTabs : function(){
36622 createTool : function(parentEl, className){
36623 var btn = Roo.DomHelper.append(parentEl, {
36625 cls: "x-layout-tools-button",
36628 cls: "roo-layout-tools-button-inner " + className,
36632 btn.addClassOnOver("roo-layout-tools-button-over");
36637 * Ext JS Library 1.1.1
36638 * Copyright(c) 2006-2007, Ext JS, LLC.
36640 * Originally Released Under LGPL - original licence link has changed is not relivant.
36643 * <script type="text/javascript">
36649 * @class Roo.SplitLayoutRegion
36650 * @extends Roo.LayoutRegion
36651 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36653 Roo.bootstrap.layout.Split = function(config){
36654 this.cursor = config.cursor;
36655 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36658 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36660 splitTip : "Drag to resize.",
36661 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36662 useSplitTips : false,
36664 applyConfig : function(config){
36665 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36668 onRender : function(ctr,pos) {
36670 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36671 if(!this.config.split){
36676 var splitEl = Roo.DomHelper.append(ctr.dom, {
36678 id: this.el.id + "-split",
36679 cls: "roo-layout-split roo-layout-split-"+this.position,
36682 /** The SplitBar for this region
36683 * @type Roo.SplitBar */
36684 // does not exist yet...
36685 Roo.log([this.position, this.orientation]);
36687 this.split = new Roo.bootstrap.SplitBar({
36688 dragElement : splitEl,
36689 resizingElement: this.el,
36690 orientation : this.orientation
36693 this.split.on("moved", this.onSplitMove, this);
36694 this.split.useShim = this.config.useShim === true;
36695 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36696 if(this.useSplitTips){
36697 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36699 //if(config.collapsible){
36700 // this.split.el.on("dblclick", this.collapse, this);
36703 if(typeof this.config.minSize != "undefined"){
36704 this.split.minSize = this.config.minSize;
36706 if(typeof this.config.maxSize != "undefined"){
36707 this.split.maxSize = this.config.maxSize;
36709 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36710 this.hideSplitter();
36715 getHMaxSize : function(){
36716 var cmax = this.config.maxSize || 10000;
36717 var center = this.mgr.getRegion("center");
36718 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36721 getVMaxSize : function(){
36722 var cmax = this.config.maxSize || 10000;
36723 var center = this.mgr.getRegion("center");
36724 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36727 onSplitMove : function(split, newSize){
36728 this.fireEvent("resized", this, newSize);
36732 * Returns the {@link Roo.SplitBar} for this region.
36733 * @return {Roo.SplitBar}
36735 getSplitBar : function(){
36740 this.hideSplitter();
36741 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36744 hideSplitter : function(){
36746 this.split.el.setLocation(-2000,-2000);
36747 this.split.el.hide();
36753 this.split.el.show();
36755 Roo.bootstrap.layout.Split.superclass.show.call(this);
36758 beforeSlide: function(){
36759 if(Roo.isGecko){// firefox overflow auto bug workaround
36760 this.bodyEl.clip();
36762 this.tabs.bodyEl.clip();
36764 if(this.activePanel){
36765 this.activePanel.getEl().clip();
36767 if(this.activePanel.beforeSlide){
36768 this.activePanel.beforeSlide();
36774 afterSlide : function(){
36775 if(Roo.isGecko){// firefox overflow auto bug workaround
36776 this.bodyEl.unclip();
36778 this.tabs.bodyEl.unclip();
36780 if(this.activePanel){
36781 this.activePanel.getEl().unclip();
36782 if(this.activePanel.afterSlide){
36783 this.activePanel.afterSlide();
36789 initAutoHide : function(){
36790 if(this.autoHide !== false){
36791 if(!this.autoHideHd){
36792 var st = new Roo.util.DelayedTask(this.slideIn, this);
36793 this.autoHideHd = {
36794 "mouseout": function(e){
36795 if(!e.within(this.el, true)){
36799 "mouseover" : function(e){
36805 this.el.on(this.autoHideHd);
36809 clearAutoHide : function(){
36810 if(this.autoHide !== false){
36811 this.el.un("mouseout", this.autoHideHd.mouseout);
36812 this.el.un("mouseover", this.autoHideHd.mouseover);
36816 clearMonitor : function(){
36817 Roo.get(document).un("click", this.slideInIf, this);
36820 // these names are backwards but not changed for compat
36821 slideOut : function(){
36822 if(this.isSlid || this.el.hasActiveFx()){
36825 this.isSlid = true;
36826 if(this.collapseBtn){
36827 this.collapseBtn.hide();
36829 this.closeBtnState = this.closeBtn.getStyle('display');
36830 this.closeBtn.hide();
36832 this.stickBtn.show();
36835 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36836 this.beforeSlide();
36837 this.el.setStyle("z-index", 10001);
36838 this.el.slideIn(this.getSlideAnchor(), {
36839 callback: function(){
36841 this.initAutoHide();
36842 Roo.get(document).on("click", this.slideInIf, this);
36843 this.fireEvent("slideshow", this);
36850 afterSlideIn : function(){
36851 this.clearAutoHide();
36852 this.isSlid = false;
36853 this.clearMonitor();
36854 this.el.setStyle("z-index", "");
36855 if(this.collapseBtn){
36856 this.collapseBtn.show();
36858 this.closeBtn.setStyle('display', this.closeBtnState);
36860 this.stickBtn.hide();
36862 this.fireEvent("slidehide", this);
36865 slideIn : function(cb){
36866 if(!this.isSlid || this.el.hasActiveFx()){
36870 this.isSlid = false;
36871 this.beforeSlide();
36872 this.el.slideOut(this.getSlideAnchor(), {
36873 callback: function(){
36874 this.el.setLeftTop(-10000, -10000);
36876 this.afterSlideIn();
36884 slideInIf : function(e){
36885 if(!e.within(this.el)){
36890 animateCollapse : function(){
36891 this.beforeSlide();
36892 this.el.setStyle("z-index", 20000);
36893 var anchor = this.getSlideAnchor();
36894 this.el.slideOut(anchor, {
36895 callback : function(){
36896 this.el.setStyle("z-index", "");
36897 this.collapsedEl.slideIn(anchor, {duration:.3});
36899 this.el.setLocation(-10000,-10000);
36901 this.fireEvent("collapsed", this);
36908 animateExpand : function(){
36909 this.beforeSlide();
36910 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36911 this.el.setStyle("z-index", 20000);
36912 this.collapsedEl.hide({
36915 this.el.slideIn(this.getSlideAnchor(), {
36916 callback : function(){
36917 this.el.setStyle("z-index", "");
36920 this.split.el.show();
36922 this.fireEvent("invalidated", this);
36923 this.fireEvent("expanded", this);
36951 getAnchor : function(){
36952 return this.anchors[this.position];
36955 getCollapseAnchor : function(){
36956 return this.canchors[this.position];
36959 getSlideAnchor : function(){
36960 return this.sanchors[this.position];
36963 getAlignAdj : function(){
36964 var cm = this.cmargins;
36965 switch(this.position){
36981 getExpandAdj : function(){
36982 var c = this.collapsedEl, cm = this.cmargins;
36983 switch(this.position){
36985 return [-(cm.right+c.getWidth()+cm.left), 0];
36988 return [cm.right+c.getWidth()+cm.left, 0];
36991 return [0, -(cm.top+cm.bottom+c.getHeight())];
36994 return [0, cm.top+cm.bottom+c.getHeight()];
37000 * Ext JS Library 1.1.1
37001 * Copyright(c) 2006-2007, Ext JS, LLC.
37003 * Originally Released Under LGPL - original licence link has changed is not relivant.
37006 * <script type="text/javascript">
37009 * These classes are private internal classes
37011 Roo.bootstrap.layout.Center = function(config){
37012 config.region = "center";
37013 Roo.bootstrap.layout.Region.call(this, config);
37014 this.visible = true;
37015 this.minWidth = config.minWidth || 20;
37016 this.minHeight = config.minHeight || 20;
37019 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37021 // center panel can't be hidden
37025 // center panel can't be hidden
37028 getMinWidth: function(){
37029 return this.minWidth;
37032 getMinHeight: function(){
37033 return this.minHeight;
37047 Roo.bootstrap.layout.North = function(config)
37049 config.region = 'north';
37050 config.cursor = 'n-resize';
37052 Roo.bootstrap.layout.Split.call(this, config);
37056 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37057 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37058 this.split.el.addClass("roo-layout-split-v");
37060 var size = config.initialSize || config.height;
37061 if(typeof size != "undefined"){
37062 this.el.setHeight(size);
37065 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37067 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37071 getBox : function(){
37072 if(this.collapsed){
37073 return this.collapsedEl.getBox();
37075 var box = this.el.getBox();
37077 box.height += this.split.el.getHeight();
37082 updateBox : function(box){
37083 if(this.split && !this.collapsed){
37084 box.height -= this.split.el.getHeight();
37085 this.split.el.setLeft(box.x);
37086 this.split.el.setTop(box.y+box.height);
37087 this.split.el.setWidth(box.width);
37089 if(this.collapsed){
37090 this.updateBody(box.width, null);
37092 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37100 Roo.bootstrap.layout.South = function(config){
37101 config.region = 'south';
37102 config.cursor = 's-resize';
37103 Roo.bootstrap.layout.Split.call(this, config);
37105 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37106 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37107 this.split.el.addClass("roo-layout-split-v");
37109 var size = config.initialSize || config.height;
37110 if(typeof size != "undefined"){
37111 this.el.setHeight(size);
37115 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37116 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37117 getBox : function(){
37118 if(this.collapsed){
37119 return this.collapsedEl.getBox();
37121 var box = this.el.getBox();
37123 var sh = this.split.el.getHeight();
37130 updateBox : function(box){
37131 if(this.split && !this.collapsed){
37132 var sh = this.split.el.getHeight();
37135 this.split.el.setLeft(box.x);
37136 this.split.el.setTop(box.y-sh);
37137 this.split.el.setWidth(box.width);
37139 if(this.collapsed){
37140 this.updateBody(box.width, null);
37142 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37146 Roo.bootstrap.layout.East = function(config){
37147 config.region = "east";
37148 config.cursor = "e-resize";
37149 Roo.bootstrap.layout.Split.call(this, config);
37151 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37152 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37153 this.split.el.addClass("roo-layout-split-h");
37155 var size = config.initialSize || config.width;
37156 if(typeof size != "undefined"){
37157 this.el.setWidth(size);
37160 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37161 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37162 getBox : function(){
37163 if(this.collapsed){
37164 return this.collapsedEl.getBox();
37166 var box = this.el.getBox();
37168 var sw = this.split.el.getWidth();
37175 updateBox : function(box){
37176 if(this.split && !this.collapsed){
37177 var sw = this.split.el.getWidth();
37179 this.split.el.setLeft(box.x);
37180 this.split.el.setTop(box.y);
37181 this.split.el.setHeight(box.height);
37184 if(this.collapsed){
37185 this.updateBody(null, box.height);
37187 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37191 Roo.bootstrap.layout.West = function(config){
37192 config.region = "west";
37193 config.cursor = "w-resize";
37195 Roo.bootstrap.layout.Split.call(this, config);
37197 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37198 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37199 this.split.el.addClass("roo-layout-split-h");
37203 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37204 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37206 onRender: function(ctr, pos)
37208 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37209 var size = this.config.initialSize || this.config.width;
37210 if(typeof size != "undefined"){
37211 this.el.setWidth(size);
37215 getBox : function(){
37216 if(this.collapsed){
37217 return this.collapsedEl.getBox();
37219 var box = this.el.getBox();
37221 box.width += this.split.el.getWidth();
37226 updateBox : function(box){
37227 if(this.split && !this.collapsed){
37228 var sw = this.split.el.getWidth();
37230 this.split.el.setLeft(box.x+box.width);
37231 this.split.el.setTop(box.y);
37232 this.split.el.setHeight(box.height);
37234 if(this.collapsed){
37235 this.updateBody(null, box.height);
37237 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37239 });Roo.namespace("Roo.bootstrap.panel");/*
37241 * Ext JS Library 1.1.1
37242 * Copyright(c) 2006-2007, Ext JS, LLC.
37244 * Originally Released Under LGPL - original licence link has changed is not relivant.
37247 * <script type="text/javascript">
37250 * @class Roo.ContentPanel
37251 * @extends Roo.util.Observable
37252 * A basic ContentPanel element.
37253 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37254 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37255 * @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
37256 * @cfg {Boolean} closable True if the panel can be closed/removed
37257 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37258 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37259 * @cfg {Toolbar} toolbar A toolbar for this panel
37260 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37261 * @cfg {String} title The title for this panel
37262 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37263 * @cfg {String} url Calls {@link #setUrl} with this value
37264 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37265 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37266 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37267 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37268 * @cfg {Boolean} badges render the badges
37271 * Create a new ContentPanel.
37272 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37273 * @param {String/Object} config A string to set only the title or a config object
37274 * @param {String} content (optional) Set the HTML content for this panel
37275 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37277 Roo.bootstrap.panel.Content = function( config){
37279 this.tpl = config.tpl || false;
37281 var el = config.el;
37282 var content = config.content;
37284 if(config.autoCreate){ // xtype is available if this is called from factory
37287 this.el = Roo.get(el);
37288 if(!this.el && config && config.autoCreate){
37289 if(typeof config.autoCreate == "object"){
37290 if(!config.autoCreate.id){
37291 config.autoCreate.id = config.id||el;
37293 this.el = Roo.DomHelper.append(document.body,
37294 config.autoCreate, true);
37296 var elcfg = { tag: "div",
37297 cls: "roo-layout-inactive-content",
37301 elcfg.html = config.html;
37305 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37308 this.closable = false;
37309 this.loaded = false;
37310 this.active = false;
37313 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37315 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37317 this.wrapEl = this.el; //this.el.wrap();
37319 if (config.toolbar.items) {
37320 ti = config.toolbar.items ;
37321 delete config.toolbar.items ;
37325 this.toolbar.render(this.wrapEl, 'before');
37326 for(var i =0;i < ti.length;i++) {
37327 // Roo.log(['add child', items[i]]);
37328 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37330 this.toolbar.items = nitems;
37331 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37332 delete config.toolbar;
37336 // xtype created footer. - not sure if will work as we normally have to render first..
37337 if (this.footer && !this.footer.el && this.footer.xtype) {
37338 if (!this.wrapEl) {
37339 this.wrapEl = this.el.wrap();
37342 this.footer.container = this.wrapEl.createChild();
37344 this.footer = Roo.factory(this.footer, Roo);
37349 if(typeof config == "string"){
37350 this.title = config;
37352 Roo.apply(this, config);
37356 this.resizeEl = Roo.get(this.resizeEl, true);
37358 this.resizeEl = this.el;
37360 // handle view.xtype
37368 * Fires when this panel is activated.
37369 * @param {Roo.ContentPanel} this
37373 * @event deactivate
37374 * Fires when this panel is activated.
37375 * @param {Roo.ContentPanel} this
37377 "deactivate" : true,
37381 * Fires when this panel is resized if fitToFrame is true.
37382 * @param {Roo.ContentPanel} this
37383 * @param {Number} width The width after any component adjustments
37384 * @param {Number} height The height after any component adjustments
37390 * Fires when this tab is created
37391 * @param {Roo.ContentPanel} this
37402 if(this.autoScroll){
37403 this.resizeEl.setStyle("overflow", "auto");
37405 // fix randome scrolling
37406 //this.el.on('scroll', function() {
37407 // Roo.log('fix random scolling');
37408 // this.scrollTo('top',0);
37411 content = content || this.content;
37413 this.setContent(content);
37415 if(config && config.url){
37416 this.setUrl(this.url, this.params, this.loadOnce);
37421 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37423 if (this.view && typeof(this.view.xtype) != 'undefined') {
37424 this.view.el = this.el.appendChild(document.createElement("div"));
37425 this.view = Roo.factory(this.view);
37426 this.view.render && this.view.render(false, '');
37430 this.fireEvent('render', this);
37433 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37437 setRegion : function(region){
37438 this.region = region;
37439 this.setActiveClass(region && !this.background);
37443 setActiveClass: function(state)
37446 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37447 this.el.setStyle('position','relative');
37449 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37450 this.el.setStyle('position', 'absolute');
37455 * Returns the toolbar for this Panel if one was configured.
37456 * @return {Roo.Toolbar}
37458 getToolbar : function(){
37459 return this.toolbar;
37462 setActiveState : function(active)
37464 this.active = active;
37465 this.setActiveClass(active);
37467 if(this.fireEvent("deactivate", this) === false){
37472 this.fireEvent("activate", this);
37476 * Updates this panel's element
37477 * @param {String} content The new content
37478 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37480 setContent : function(content, loadScripts){
37481 this.el.update(content, loadScripts);
37484 ignoreResize : function(w, h){
37485 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37488 this.lastSize = {width: w, height: h};
37493 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37494 * @return {Roo.UpdateManager} The UpdateManager
37496 getUpdateManager : function(){
37497 return this.el.getUpdateManager();
37500 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37501 * @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:
37504 url: "your-url.php",
37505 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37506 callback: yourFunction,
37507 scope: yourObject, //(optional scope)
37510 text: "Loading...",
37515 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37516 * 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.
37517 * @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}
37518 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37519 * @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.
37520 * @return {Roo.ContentPanel} this
37523 var um = this.el.getUpdateManager();
37524 um.update.apply(um, arguments);
37530 * 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.
37531 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37532 * @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)
37533 * @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)
37534 * @return {Roo.UpdateManager} The UpdateManager
37536 setUrl : function(url, params, loadOnce){
37537 if(this.refreshDelegate){
37538 this.removeListener("activate", this.refreshDelegate);
37540 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37541 this.on("activate", this.refreshDelegate);
37542 return this.el.getUpdateManager();
37545 _handleRefresh : function(url, params, loadOnce){
37546 if(!loadOnce || !this.loaded){
37547 var updater = this.el.getUpdateManager();
37548 updater.update(url, params, this._setLoaded.createDelegate(this));
37552 _setLoaded : function(){
37553 this.loaded = true;
37557 * Returns this panel's id
37560 getId : function(){
37565 * Returns this panel's element - used by regiosn to add.
37566 * @return {Roo.Element}
37568 getEl : function(){
37569 return this.wrapEl || this.el;
37574 adjustForComponents : function(width, height)
37576 //Roo.log('adjustForComponents ');
37577 if(this.resizeEl != this.el){
37578 width -= this.el.getFrameWidth('lr');
37579 height -= this.el.getFrameWidth('tb');
37582 var te = this.toolbar.getEl();
37583 te.setWidth(width);
37584 height -= te.getHeight();
37587 var te = this.footer.getEl();
37588 te.setWidth(width);
37589 height -= te.getHeight();
37593 if(this.adjustments){
37594 width += this.adjustments[0];
37595 height += this.adjustments[1];
37597 return {"width": width, "height": height};
37600 setSize : function(width, height){
37601 if(this.fitToFrame && !this.ignoreResize(width, height)){
37602 if(this.fitContainer && this.resizeEl != this.el){
37603 this.el.setSize(width, height);
37605 var size = this.adjustForComponents(width, height);
37606 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37607 this.fireEvent('resize', this, size.width, size.height);
37612 * Returns this panel's title
37615 getTitle : function(){
37617 if (typeof(this.title) != 'object') {
37622 for (var k in this.title) {
37623 if (!this.title.hasOwnProperty(k)) {
37627 if (k.indexOf('-') >= 0) {
37628 var s = k.split('-');
37629 for (var i = 0; i<s.length; i++) {
37630 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37633 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37640 * Set this panel's title
37641 * @param {String} title
37643 setTitle : function(title){
37644 this.title = title;
37646 this.region.updatePanelTitle(this, title);
37651 * Returns true is this panel was configured to be closable
37652 * @return {Boolean}
37654 isClosable : function(){
37655 return this.closable;
37658 beforeSlide : function(){
37660 this.resizeEl.clip();
37663 afterSlide : function(){
37665 this.resizeEl.unclip();
37669 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37670 * Will fail silently if the {@link #setUrl} method has not been called.
37671 * This does not activate the panel, just updates its content.
37673 refresh : function(){
37674 if(this.refreshDelegate){
37675 this.loaded = false;
37676 this.refreshDelegate();
37681 * Destroys this panel
37683 destroy : function(){
37684 this.el.removeAllListeners();
37685 var tempEl = document.createElement("span");
37686 tempEl.appendChild(this.el.dom);
37687 tempEl.innerHTML = "";
37693 * form - if the content panel contains a form - this is a reference to it.
37694 * @type {Roo.form.Form}
37698 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37699 * This contains a reference to it.
37705 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37715 * @param {Object} cfg Xtype definition of item to add.
37719 getChildContainer: function () {
37720 return this.getEl();
37725 var ret = new Roo.factory(cfg);
37730 if (cfg.xtype.match(/^Form$/)) {
37733 //if (this.footer) {
37734 // el = this.footer.container.insertSibling(false, 'before');
37736 el = this.el.createChild();
37739 this.form = new Roo.form.Form(cfg);
37742 if ( this.form.allItems.length) {
37743 this.form.render(el.dom);
37747 // should only have one of theses..
37748 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37749 // views.. should not be just added - used named prop 'view''
37751 cfg.el = this.el.appendChild(document.createElement("div"));
37754 var ret = new Roo.factory(cfg);
37756 ret.render && ret.render(false, ''); // render blank..
37766 * @class Roo.bootstrap.panel.Grid
37767 * @extends Roo.bootstrap.panel.Content
37769 * Create a new GridPanel.
37770 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37771 * @param {Object} config A the config object
37777 Roo.bootstrap.panel.Grid = function(config)
37781 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37782 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37784 config.el = this.wrapper;
37785 //this.el = this.wrapper;
37787 if (config.container) {
37788 // ctor'ed from a Border/panel.grid
37791 this.wrapper.setStyle("overflow", "hidden");
37792 this.wrapper.addClass('roo-grid-container');
37797 if(config.toolbar){
37798 var tool_el = this.wrapper.createChild();
37799 this.toolbar = Roo.factory(config.toolbar);
37801 if (config.toolbar.items) {
37802 ti = config.toolbar.items ;
37803 delete config.toolbar.items ;
37807 this.toolbar.render(tool_el);
37808 for(var i =0;i < ti.length;i++) {
37809 // Roo.log(['add child', items[i]]);
37810 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37812 this.toolbar.items = nitems;
37814 delete config.toolbar;
37817 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37818 config.grid.scrollBody = true;;
37819 config.grid.monitorWindowResize = false; // turn off autosizing
37820 config.grid.autoHeight = false;
37821 config.grid.autoWidth = false;
37823 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37825 if (config.background) {
37826 // render grid on panel activation (if panel background)
37827 this.on('activate', function(gp) {
37828 if (!gp.grid.rendered) {
37829 gp.grid.render(this.wrapper);
37830 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37835 this.grid.render(this.wrapper);
37836 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37839 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37840 // ??? needed ??? config.el = this.wrapper;
37845 // xtype created footer. - not sure if will work as we normally have to render first..
37846 if (this.footer && !this.footer.el && this.footer.xtype) {
37848 var ctr = this.grid.getView().getFooterPanel(true);
37849 this.footer.dataSource = this.grid.dataSource;
37850 this.footer = Roo.factory(this.footer, Roo);
37851 this.footer.render(ctr);
37861 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37862 getId : function(){
37863 return this.grid.id;
37867 * Returns the grid for this panel
37868 * @return {Roo.bootstrap.Table}
37870 getGrid : function(){
37874 setSize : function(width, height){
37875 if(!this.ignoreResize(width, height)){
37876 var grid = this.grid;
37877 var size = this.adjustForComponents(width, height);
37878 var gridel = grid.getGridEl();
37879 gridel.setSize(size.width, size.height);
37881 var thd = grid.getGridEl().select('thead',true).first();
37882 var tbd = grid.getGridEl().select('tbody', true).first();
37884 tbd.setSize(width, height - thd.getHeight());
37893 beforeSlide : function(){
37894 this.grid.getView().scroller.clip();
37897 afterSlide : function(){
37898 this.grid.getView().scroller.unclip();
37901 destroy : function(){
37902 this.grid.destroy();
37904 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37909 * @class Roo.bootstrap.panel.Nest
37910 * @extends Roo.bootstrap.panel.Content
37912 * Create a new Panel, that can contain a layout.Border.
37915 * @param {Roo.BorderLayout} layout The layout for this panel
37916 * @param {String/Object} config A string to set only the title or a config object
37918 Roo.bootstrap.panel.Nest = function(config)
37920 // construct with only one argument..
37921 /* FIXME - implement nicer consturctors
37922 if (layout.layout) {
37924 layout = config.layout;
37925 delete config.layout;
37927 if (layout.xtype && !layout.getEl) {
37928 // then layout needs constructing..
37929 layout = Roo.factory(layout, Roo);
37933 config.el = config.layout.getEl();
37935 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37937 config.layout.monitorWindowResize = false; // turn off autosizing
37938 this.layout = config.layout;
37939 this.layout.getEl().addClass("roo-layout-nested-layout");
37940 this.layout.parent = this;
37947 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37949 setSize : function(width, height){
37950 if(!this.ignoreResize(width, height)){
37951 var size = this.adjustForComponents(width, height);
37952 var el = this.layout.getEl();
37953 if (size.height < 1) {
37954 el.setWidth(size.width);
37956 el.setSize(size.width, size.height);
37958 var touch = el.dom.offsetWidth;
37959 this.layout.layout();
37960 // ie requires a double layout on the first pass
37961 if(Roo.isIE && !this.initialized){
37962 this.initialized = true;
37963 this.layout.layout();
37968 // activate all subpanels if not currently active..
37970 setActiveState : function(active){
37971 this.active = active;
37972 this.setActiveClass(active);
37975 this.fireEvent("deactivate", this);
37979 this.fireEvent("activate", this);
37980 // not sure if this should happen before or after..
37981 if (!this.layout) {
37982 return; // should not happen..
37985 for (var r in this.layout.regions) {
37986 reg = this.layout.getRegion(r);
37987 if (reg.getActivePanel()) {
37988 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37989 reg.setActivePanel(reg.getActivePanel());
37992 if (!reg.panels.length) {
37995 reg.showPanel(reg.getPanel(0));
38004 * Returns the nested BorderLayout for this panel
38005 * @return {Roo.BorderLayout}
38007 getLayout : function(){
38008 return this.layout;
38012 * Adds a xtype elements to the layout of the nested panel
38016 xtype : 'ContentPanel',
38023 xtype : 'NestedLayoutPanel',
38029 items : [ ... list of content panels or nested layout panels.. ]
38033 * @param {Object} cfg Xtype definition of item to add.
38035 addxtype : function(cfg) {
38036 return this.layout.addxtype(cfg);
38041 * Ext JS Library 1.1.1
38042 * Copyright(c) 2006-2007, Ext JS, LLC.
38044 * Originally Released Under LGPL - original licence link has changed is not relivant.
38047 * <script type="text/javascript">
38050 * @class Roo.TabPanel
38051 * @extends Roo.util.Observable
38052 * A lightweight tab container.
38056 // basic tabs 1, built from existing content
38057 var tabs = new Roo.TabPanel("tabs1");
38058 tabs.addTab("script", "View Script");
38059 tabs.addTab("markup", "View Markup");
38060 tabs.activate("script");
38062 // more advanced tabs, built from javascript
38063 var jtabs = new Roo.TabPanel("jtabs");
38064 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38066 // set up the UpdateManager
38067 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38068 var updater = tab2.getUpdateManager();
38069 updater.setDefaultUrl("ajax1.htm");
38070 tab2.on('activate', updater.refresh, updater, true);
38072 // Use setUrl for Ajax loading
38073 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38074 tab3.setUrl("ajax2.htm", null, true);
38077 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38080 jtabs.activate("jtabs-1");
38083 * Create a new TabPanel.
38084 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38085 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38087 Roo.bootstrap.panel.Tabs = function(config){
38089 * The container element for this TabPanel.
38090 * @type Roo.Element
38092 this.el = Roo.get(config.el);
38095 if(typeof config == "boolean"){
38096 this.tabPosition = config ? "bottom" : "top";
38098 Roo.apply(this, config);
38102 if(this.tabPosition == "bottom"){
38103 // if tabs are at the bottom = create the body first.
38104 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38105 this.el.addClass("roo-tabs-bottom");
38107 // next create the tabs holders
38109 if (this.tabPosition == "west"){
38111 var reg = this.region; // fake it..
38113 if (!reg.mgr.parent) {
38116 reg = reg.mgr.parent.region;
38118 Roo.log("got nest?");
38120 if (reg.mgr.getRegion('west')) {
38121 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38122 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38123 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38124 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38125 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38133 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38134 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38135 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38136 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38141 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38144 // finally - if tabs are at the top, then create the body last..
38145 if(this.tabPosition != "bottom"){
38146 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38147 * @type Roo.Element
38149 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38150 this.el.addClass("roo-tabs-top");
38154 this.bodyEl.setStyle("position", "relative");
38156 this.active = null;
38157 this.activateDelegate = this.activate.createDelegate(this);
38162 * Fires when the active tab changes
38163 * @param {Roo.TabPanel} this
38164 * @param {Roo.TabPanelItem} activePanel The new active tab
38168 * @event beforetabchange
38169 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38170 * @param {Roo.TabPanel} this
38171 * @param {Object} e Set cancel to true on this object to cancel the tab change
38172 * @param {Roo.TabPanelItem} tab The tab being changed to
38174 "beforetabchange" : true
38177 Roo.EventManager.onWindowResize(this.onResize, this);
38178 this.cpad = this.el.getPadding("lr");
38179 this.hiddenCount = 0;
38182 // toolbar on the tabbar support...
38183 if (this.toolbar) {
38184 alert("no toolbar support yet");
38185 this.toolbar = false;
38187 var tcfg = this.toolbar;
38188 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38189 this.toolbar = new Roo.Toolbar(tcfg);
38190 if (Roo.isSafari) {
38191 var tbl = tcfg.container.child('table', true);
38192 tbl.setAttribute('width', '100%');
38200 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38203 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38205 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38207 tabPosition : "top",
38209 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38211 currentTabWidth : 0,
38213 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38217 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38221 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38223 preferredTabWidth : 175,
38225 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38227 resizeTabs : false,
38229 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38231 monitorResize : true,
38233 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38235 toolbar : false, // set by caller..
38237 region : false, /// set by caller
38239 disableTooltips : true, // not used yet...
38242 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38243 * @param {String} id The id of the div to use <b>or create</b>
38244 * @param {String} text The text for the tab
38245 * @param {String} content (optional) Content to put in the TabPanelItem body
38246 * @param {Boolean} closable (optional) True to create a close icon on the tab
38247 * @return {Roo.TabPanelItem} The created TabPanelItem
38249 addTab : function(id, text, content, closable, tpl)
38251 var item = new Roo.bootstrap.panel.TabItem({
38255 closable : closable,
38258 this.addTabItem(item);
38260 item.setContent(content);
38266 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38267 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38268 * @return {Roo.TabPanelItem}
38270 getTab : function(id){
38271 return this.items[id];
38275 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38276 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38278 hideTab : function(id){
38279 var t = this.items[id];
38282 this.hiddenCount++;
38283 this.autoSizeTabs();
38288 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38289 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38291 unhideTab : function(id){
38292 var t = this.items[id];
38294 t.setHidden(false);
38295 this.hiddenCount--;
38296 this.autoSizeTabs();
38301 * Adds an existing {@link Roo.TabPanelItem}.
38302 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38304 addTabItem : function(item)
38306 this.items[item.id] = item;
38307 this.items.push(item);
38308 this.autoSizeTabs();
38309 // if(this.resizeTabs){
38310 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38311 // this.autoSizeTabs();
38313 // item.autoSize();
38318 * Removes a {@link Roo.TabPanelItem}.
38319 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38321 removeTab : function(id){
38322 var items = this.items;
38323 var tab = items[id];
38324 if(!tab) { return; }
38325 var index = items.indexOf(tab);
38326 if(this.active == tab && items.length > 1){
38327 var newTab = this.getNextAvailable(index);
38332 this.stripEl.dom.removeChild(tab.pnode.dom);
38333 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38334 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38336 items.splice(index, 1);
38337 delete this.items[tab.id];
38338 tab.fireEvent("close", tab);
38339 tab.purgeListeners();
38340 this.autoSizeTabs();
38343 getNextAvailable : function(start){
38344 var items = this.items;
38346 // look for a next tab that will slide over to
38347 // replace the one being removed
38348 while(index < items.length){
38349 var item = items[++index];
38350 if(item && !item.isHidden()){
38354 // if one isn't found select the previous tab (on the left)
38357 var item = items[--index];
38358 if(item && !item.isHidden()){
38366 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38367 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38369 disableTab : function(id){
38370 var tab = this.items[id];
38371 if(tab && this.active != tab){
38377 * Enables a {@link Roo.TabPanelItem} that is disabled.
38378 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38380 enableTab : function(id){
38381 var tab = this.items[id];
38386 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38387 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38388 * @return {Roo.TabPanelItem} The TabPanelItem.
38390 activate : function(id)
38392 //Roo.log('activite:' + id);
38394 var tab = this.items[id];
38398 if(tab == this.active || tab.disabled){
38402 this.fireEvent("beforetabchange", this, e, tab);
38403 if(e.cancel !== true && !tab.disabled){
38405 this.active.hide();
38407 this.active = this.items[id];
38408 this.active.show();
38409 this.fireEvent("tabchange", this, this.active);
38415 * Gets the active {@link Roo.TabPanelItem}.
38416 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38418 getActiveTab : function(){
38419 return this.active;
38423 * Updates the tab body element to fit the height of the container element
38424 * for overflow scrolling
38425 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38427 syncHeight : function(targetHeight){
38428 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38429 var bm = this.bodyEl.getMargins();
38430 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38431 this.bodyEl.setHeight(newHeight);
38435 onResize : function(){
38436 if(this.monitorResize){
38437 this.autoSizeTabs();
38442 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38444 beginUpdate : function(){
38445 this.updating = true;
38449 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38451 endUpdate : function(){
38452 this.updating = false;
38453 this.autoSizeTabs();
38457 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38459 autoSizeTabs : function()
38461 var count = this.items.length;
38462 var vcount = count - this.hiddenCount;
38465 this.stripEl.hide();
38467 this.stripEl.show();
38470 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38475 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38476 var availWidth = Math.floor(w / vcount);
38477 var b = this.stripBody;
38478 if(b.getWidth() > w){
38479 var tabs = this.items;
38480 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38481 if(availWidth < this.minTabWidth){
38482 /*if(!this.sleft){ // incomplete scrolling code
38483 this.createScrollButtons();
38486 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38489 if(this.currentTabWidth < this.preferredTabWidth){
38490 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38496 * Returns the number of tabs in this TabPanel.
38499 getCount : function(){
38500 return this.items.length;
38504 * Resizes all the tabs to the passed width
38505 * @param {Number} The new width
38507 setTabWidth : function(width){
38508 this.currentTabWidth = width;
38509 for(var i = 0, len = this.items.length; i < len; i++) {
38510 if(!this.items[i].isHidden()) {
38511 this.items[i].setWidth(width);
38517 * Destroys this TabPanel
38518 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38520 destroy : function(removeEl){
38521 Roo.EventManager.removeResizeListener(this.onResize, this);
38522 for(var i = 0, len = this.items.length; i < len; i++){
38523 this.items[i].purgeListeners();
38525 if(removeEl === true){
38526 this.el.update("");
38531 createStrip : function(container)
38533 var strip = document.createElement("nav");
38534 strip.className = Roo.bootstrap.version == 4 ?
38535 "navbar-light bg-light" :
38536 "navbar navbar-default"; //"x-tabs-wrap";
38537 container.appendChild(strip);
38541 createStripList : function(strip)
38543 // div wrapper for retard IE
38544 // returns the "tr" element.
38545 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38546 //'<div class="x-tabs-strip-wrap">'+
38547 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38548 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38549 return strip.firstChild; //.firstChild.firstChild.firstChild;
38551 createBody : function(container)
38553 var body = document.createElement("div");
38554 Roo.id(body, "tab-body");
38555 //Roo.fly(body).addClass("x-tabs-body");
38556 Roo.fly(body).addClass("tab-content");
38557 container.appendChild(body);
38560 createItemBody :function(bodyEl, id){
38561 var body = Roo.getDom(id);
38563 body = document.createElement("div");
38566 //Roo.fly(body).addClass("x-tabs-item-body");
38567 Roo.fly(body).addClass("tab-pane");
38568 bodyEl.insertBefore(body, bodyEl.firstChild);
38572 createStripElements : function(stripEl, text, closable, tpl)
38574 var td = document.createElement("li"); // was td..
38575 td.className = 'nav-item';
38577 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38580 stripEl.appendChild(td);
38582 td.className = "x-tabs-closable";
38583 if(!this.closeTpl){
38584 this.closeTpl = new Roo.Template(
38585 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38586 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38587 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38590 var el = this.closeTpl.overwrite(td, {"text": text});
38591 var close = el.getElementsByTagName("div")[0];
38592 var inner = el.getElementsByTagName("em")[0];
38593 return {"el": el, "close": close, "inner": inner};
38596 // not sure what this is..
38597 // if(!this.tabTpl){
38598 //this.tabTpl = new Roo.Template(
38599 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38600 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38602 // this.tabTpl = new Roo.Template(
38603 // '<a href="#">' +
38604 // '<span unselectable="on"' +
38605 // (this.disableTooltips ? '' : ' title="{text}"') +
38606 // ' >{text}</span></a>'
38612 var template = tpl || this.tabTpl || false;
38615 template = new Roo.Template(
38616 Roo.bootstrap.version == 4 ?
38618 '<a class="nav-link" href="#" unselectable="on"' +
38619 (this.disableTooltips ? '' : ' title="{text}"') +
38622 '<a class="nav-link" href="#">' +
38623 '<span unselectable="on"' +
38624 (this.disableTooltips ? '' : ' title="{text}"') +
38625 ' >{text}</span></a>'
38630 switch (typeof(template)) {
38634 template = new Roo.Template(template);
38640 var el = template.overwrite(td, {"text": text});
38642 var inner = el.getElementsByTagName("span")[0];
38644 return {"el": el, "inner": inner};
38652 * @class Roo.TabPanelItem
38653 * @extends Roo.util.Observable
38654 * Represents an individual item (tab plus body) in a TabPanel.
38655 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38656 * @param {String} id The id of this TabPanelItem
38657 * @param {String} text The text for the tab of this TabPanelItem
38658 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38660 Roo.bootstrap.panel.TabItem = function(config){
38662 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38663 * @type Roo.TabPanel
38665 this.tabPanel = config.panel;
38667 * The id for this TabPanelItem
38670 this.id = config.id;
38672 this.disabled = false;
38674 this.text = config.text;
38676 this.loaded = false;
38677 this.closable = config.closable;
38680 * The body element for this TabPanelItem.
38681 * @type Roo.Element
38683 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38684 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38685 this.bodyEl.setStyle("display", "block");
38686 this.bodyEl.setStyle("zoom", "1");
38687 //this.hideAction();
38689 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38691 this.el = Roo.get(els.el);
38692 this.inner = Roo.get(els.inner, true);
38693 this.textEl = Roo.bootstrap.version == 4 ?
38694 this.el : Roo.get(this.el.dom.firstChild, true);
38696 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38697 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38700 // this.el.on("mousedown", this.onTabMouseDown, this);
38701 this.el.on("click", this.onTabClick, this);
38703 if(config.closable){
38704 var c = Roo.get(els.close, true);
38705 c.dom.title = this.closeText;
38706 c.addClassOnOver("close-over");
38707 c.on("click", this.closeClick, this);
38713 * Fires when this tab becomes the active tab.
38714 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38715 * @param {Roo.TabPanelItem} this
38719 * @event beforeclose
38720 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38721 * @param {Roo.TabPanelItem} this
38722 * @param {Object} e Set cancel to true on this object to cancel the close.
38724 "beforeclose": true,
38727 * Fires when this tab is closed.
38728 * @param {Roo.TabPanelItem} this
38732 * @event deactivate
38733 * Fires when this tab is no longer the active tab.
38734 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38735 * @param {Roo.TabPanelItem} this
38737 "deactivate" : true
38739 this.hidden = false;
38741 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38744 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38746 purgeListeners : function(){
38747 Roo.util.Observable.prototype.purgeListeners.call(this);
38748 this.el.removeAllListeners();
38751 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38754 this.status_node.addClass("active");
38757 this.tabPanel.stripWrap.repaint();
38759 this.fireEvent("activate", this.tabPanel, this);
38763 * Returns true if this tab is the active tab.
38764 * @return {Boolean}
38766 isActive : function(){
38767 return this.tabPanel.getActiveTab() == this;
38771 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38774 this.status_node.removeClass("active");
38776 this.fireEvent("deactivate", this.tabPanel, this);
38779 hideAction : function(){
38780 this.bodyEl.hide();
38781 this.bodyEl.setStyle("position", "absolute");
38782 this.bodyEl.setLeft("-20000px");
38783 this.bodyEl.setTop("-20000px");
38786 showAction : function(){
38787 this.bodyEl.setStyle("position", "relative");
38788 this.bodyEl.setTop("");
38789 this.bodyEl.setLeft("");
38790 this.bodyEl.show();
38794 * Set the tooltip for the tab.
38795 * @param {String} tooltip The tab's tooltip
38797 setTooltip : function(text){
38798 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38799 this.textEl.dom.qtip = text;
38800 this.textEl.dom.removeAttribute('title');
38802 this.textEl.dom.title = text;
38806 onTabClick : function(e){
38807 e.preventDefault();
38808 this.tabPanel.activate(this.id);
38811 onTabMouseDown : function(e){
38812 e.preventDefault();
38813 this.tabPanel.activate(this.id);
38816 getWidth : function(){
38817 return this.inner.getWidth();
38820 setWidth : function(width){
38821 var iwidth = width - this.linode.getPadding("lr");
38822 this.inner.setWidth(iwidth);
38823 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38824 this.linode.setWidth(width);
38828 * Show or hide the tab
38829 * @param {Boolean} hidden True to hide or false to show.
38831 setHidden : function(hidden){
38832 this.hidden = hidden;
38833 this.linode.setStyle("display", hidden ? "none" : "");
38837 * Returns true if this tab is "hidden"
38838 * @return {Boolean}
38840 isHidden : function(){
38841 return this.hidden;
38845 * Returns the text for this tab
38848 getText : function(){
38852 autoSize : function(){
38853 //this.el.beginMeasure();
38854 this.textEl.setWidth(1);
38856 * #2804 [new] Tabs in Roojs
38857 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38859 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38860 //this.el.endMeasure();
38864 * Sets the text for the tab (Note: this also sets the tooltip text)
38865 * @param {String} text The tab's text and tooltip
38867 setText : function(text){
38869 this.textEl.update(text);
38870 this.setTooltip(text);
38871 //if(!this.tabPanel.resizeTabs){
38872 // this.autoSize();
38876 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38878 activate : function(){
38879 this.tabPanel.activate(this.id);
38883 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38885 disable : function(){
38886 if(this.tabPanel.active != this){
38887 this.disabled = true;
38888 this.status_node.addClass("disabled");
38893 * Enables this TabPanelItem if it was previously disabled.
38895 enable : function(){
38896 this.disabled = false;
38897 this.status_node.removeClass("disabled");
38901 * Sets the content for this TabPanelItem.
38902 * @param {String} content The content
38903 * @param {Boolean} loadScripts true to look for and load scripts
38905 setContent : function(content, loadScripts){
38906 this.bodyEl.update(content, loadScripts);
38910 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38911 * @return {Roo.UpdateManager} The UpdateManager
38913 getUpdateManager : function(){
38914 return this.bodyEl.getUpdateManager();
38918 * Set a URL to be used to load the content for this TabPanelItem.
38919 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38920 * @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)
38921 * @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)
38922 * @return {Roo.UpdateManager} The UpdateManager
38924 setUrl : function(url, params, loadOnce){
38925 if(this.refreshDelegate){
38926 this.un('activate', this.refreshDelegate);
38928 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38929 this.on("activate", this.refreshDelegate);
38930 return this.bodyEl.getUpdateManager();
38934 _handleRefresh : function(url, params, loadOnce){
38935 if(!loadOnce || !this.loaded){
38936 var updater = this.bodyEl.getUpdateManager();
38937 updater.update(url, params, this._setLoaded.createDelegate(this));
38942 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38943 * Will fail silently if the setUrl method has not been called.
38944 * This does not activate the panel, just updates its content.
38946 refresh : function(){
38947 if(this.refreshDelegate){
38948 this.loaded = false;
38949 this.refreshDelegate();
38954 _setLoaded : function(){
38955 this.loaded = true;
38959 closeClick : function(e){
38962 this.fireEvent("beforeclose", this, o);
38963 if(o.cancel !== true){
38964 this.tabPanel.removeTab(this.id);
38968 * The text displayed in the tooltip for the close icon.
38971 closeText : "Close this tab"
38974 * This script refer to:
38975 * Title: International Telephone Input
38976 * Author: Jack O'Connor
38977 * Code version: v12.1.12
38978 * Availability: https://github.com/jackocnr/intl-tel-input.git
38981 Roo.bootstrap.PhoneInputData = function() {
38984 "Afghanistan (افغانستان)",
38989 "Albania (Shqipëri)",
38994 "Algeria (الجزائر)",
39019 "Antigua and Barbuda",
39029 "Armenia (Հայաստան)",
39045 "Austria (Österreich)",
39050 "Azerbaijan (Azərbaycan)",
39060 "Bahrain (البحرين)",
39065 "Bangladesh (বাংলাদেশ)",
39075 "Belarus (Беларусь)",
39080 "Belgium (België)",
39110 "Bosnia and Herzegovina (Босна и Херцеговина)",
39125 "British Indian Ocean Territory",
39130 "British Virgin Islands",
39140 "Bulgaria (България)",
39150 "Burundi (Uburundi)",
39155 "Cambodia (កម្ពុជា)",
39160 "Cameroon (Cameroun)",
39169 ["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"]
39172 "Cape Verde (Kabu Verdi)",
39177 "Caribbean Netherlands",
39188 "Central African Republic (République centrafricaine)",
39208 "Christmas Island",
39214 "Cocos (Keeling) Islands",
39225 "Comoros (جزر القمر)",
39230 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39235 "Congo (Republic) (Congo-Brazzaville)",
39255 "Croatia (Hrvatska)",
39276 "Czech Republic (Česká republika)",
39281 "Denmark (Danmark)",
39296 "Dominican Republic (República Dominicana)",
39300 ["809", "829", "849"]
39318 "Equatorial Guinea (Guinea Ecuatorial)",
39338 "Falkland Islands (Islas Malvinas)",
39343 "Faroe Islands (Føroyar)",
39364 "French Guiana (Guyane française)",
39369 "French Polynesia (Polynésie française)",
39384 "Georgia (საქართველო)",
39389 "Germany (Deutschland)",
39409 "Greenland (Kalaallit Nunaat)",
39446 "Guinea-Bissau (Guiné Bissau)",
39471 "Hungary (Magyarország)",
39476 "Iceland (Ísland)",
39496 "Iraq (العراق)",
39512 "Israel (ישראל)",
39539 "Jordan (الأردن)",
39544 "Kazakhstan (Казахстан)",
39565 "Kuwait (الكويت)",
39570 "Kyrgyzstan (Кыргызстан)",
39580 "Latvia (Latvija)",
39585 "Lebanon (لبنان)",
39600 "Libya (ليبيا)",
39610 "Lithuania (Lietuva)",
39625 "Macedonia (FYROM) (Македонија)",
39630 "Madagascar (Madagasikara)",
39660 "Marshall Islands",
39670 "Mauritania (موريتانيا)",
39675 "Mauritius (Moris)",
39696 "Moldova (Republica Moldova)",
39706 "Mongolia (Монгол)",
39711 "Montenegro (Crna Gora)",
39721 "Morocco (المغرب)",
39727 "Mozambique (Moçambique)",
39732 "Myanmar (Burma) (မြန်မာ)",
39737 "Namibia (Namibië)",
39752 "Netherlands (Nederland)",
39757 "New Caledonia (Nouvelle-Calédonie)",
39792 "North Korea (조선 민주주의 인민 공화국)",
39797 "Northern Mariana Islands",
39813 "Pakistan (پاکستان)",
39823 "Palestine (فلسطين)",
39833 "Papua New Guinea",
39875 "Réunion (La Réunion)",
39881 "Romania (România)",
39897 "Saint Barthélemy",
39908 "Saint Kitts and Nevis",
39918 "Saint Martin (Saint-Martin (partie française))",
39924 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39929 "Saint Vincent and the Grenadines",
39944 "São Tomé and Príncipe (São Tomé e Príncipe)",
39949 "Saudi Arabia (المملكة العربية السعودية)",
39954 "Senegal (Sénégal)",
39984 "Slovakia (Slovensko)",
39989 "Slovenia (Slovenija)",
39999 "Somalia (Soomaaliya)",
40009 "South Korea (대한민국)",
40014 "South Sudan (جنوب السودان)",
40024 "Sri Lanka (ශ්රී ලංකාව)",
40029 "Sudan (السودان)",
40039 "Svalbard and Jan Mayen",
40050 "Sweden (Sverige)",
40055 "Switzerland (Schweiz)",
40060 "Syria (سوريا)",
40105 "Trinidad and Tobago",
40110 "Tunisia (تونس)",
40115 "Turkey (Türkiye)",
40125 "Turks and Caicos Islands",
40135 "U.S. Virgin Islands",
40145 "Ukraine (Україна)",
40150 "United Arab Emirates (الإمارات العربية المتحدة)",
40172 "Uzbekistan (Oʻzbekiston)",
40182 "Vatican City (Città del Vaticano)",
40193 "Vietnam (Việt Nam)",
40198 "Wallis and Futuna (Wallis-et-Futuna)",
40203 "Western Sahara (الصحراء الغربية)",
40209 "Yemen (اليمن)",
40233 * This script refer to:
40234 * Title: International Telephone Input
40235 * Author: Jack O'Connor
40236 * Code version: v12.1.12
40237 * Availability: https://github.com/jackocnr/intl-tel-input.git
40241 * @class Roo.bootstrap.PhoneInput
40242 * @extends Roo.bootstrap.TriggerField
40243 * An input with International dial-code selection
40245 * @cfg {String} defaultDialCode default '+852'
40246 * @cfg {Array} preferedCountries default []
40249 * Create a new PhoneInput.
40250 * @param {Object} config Configuration options
40253 Roo.bootstrap.PhoneInput = function(config) {
40254 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40257 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40259 listWidth: undefined,
40261 selectedClass: 'active',
40263 invalidClass : "has-warning",
40265 validClass: 'has-success',
40267 allowed: '0123456789',
40272 * @cfg {String} defaultDialCode The default dial code when initializing the input
40274 defaultDialCode: '+852',
40277 * @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
40279 preferedCountries: false,
40281 getAutoCreate : function()
40283 var data = Roo.bootstrap.PhoneInputData();
40284 var align = this.labelAlign || this.parentLabelAlign();
40287 this.allCountries = [];
40288 this.dialCodeMapping = [];
40290 for (var i = 0; i < data.length; i++) {
40292 this.allCountries[i] = {
40296 priority: c[3] || 0,
40297 areaCodes: c[4] || null
40299 this.dialCodeMapping[c[2]] = {
40302 priority: c[3] || 0,
40303 areaCodes: c[4] || null
40315 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40316 maxlength: this.max_length,
40317 cls : 'form-control tel-input',
40318 autocomplete: 'new-password'
40321 var hiddenInput = {
40324 cls: 'hidden-tel-input'
40328 hiddenInput.name = this.name;
40331 if (this.disabled) {
40332 input.disabled = true;
40335 var flag_container = {
40352 cls: this.hasFeedback ? 'has-feedback' : '',
40358 cls: 'dial-code-holder',
40365 cls: 'roo-select2-container input-group',
40372 if (this.fieldLabel.length) {
40375 tooltip: 'This field is required'
40381 cls: 'control-label',
40387 html: this.fieldLabel
40390 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40396 if(this.indicatorpos == 'right') {
40397 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40404 if(align == 'left') {
40412 if(this.labelWidth > 12){
40413 label.style = "width: " + this.labelWidth + 'px';
40415 if(this.labelWidth < 13 && this.labelmd == 0){
40416 this.labelmd = this.labelWidth;
40418 if(this.labellg > 0){
40419 label.cls += ' col-lg-' + this.labellg;
40420 input.cls += ' col-lg-' + (12 - this.labellg);
40422 if(this.labelmd > 0){
40423 label.cls += ' col-md-' + this.labelmd;
40424 container.cls += ' col-md-' + (12 - this.labelmd);
40426 if(this.labelsm > 0){
40427 label.cls += ' col-sm-' + this.labelsm;
40428 container.cls += ' col-sm-' + (12 - this.labelsm);
40430 if(this.labelxs > 0){
40431 label.cls += ' col-xs-' + this.labelxs;
40432 container.cls += ' col-xs-' + (12 - this.labelxs);
40442 var settings = this;
40444 ['xs','sm','md','lg'].map(function(size){
40445 if (settings[size]) {
40446 cfg.cls += ' col-' + size + '-' + settings[size];
40450 this.store = new Roo.data.Store({
40451 proxy : new Roo.data.MemoryProxy({}),
40452 reader : new Roo.data.JsonReader({
40463 'name' : 'dialCode',
40467 'name' : 'priority',
40471 'name' : 'areaCodes',
40478 if(!this.preferedCountries) {
40479 this.preferedCountries = [
40486 var p = this.preferedCountries.reverse();
40489 for (var i = 0; i < p.length; i++) {
40490 for (var j = 0; j < this.allCountries.length; j++) {
40491 if(this.allCountries[j].iso2 == p[i]) {
40492 var t = this.allCountries[j];
40493 this.allCountries.splice(j,1);
40494 this.allCountries.unshift(t);
40500 this.store.proxy.data = {
40502 data: this.allCountries
40508 initEvents : function()
40511 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40513 this.indicator = this.indicatorEl();
40514 this.flag = this.flagEl();
40515 this.dialCodeHolder = this.dialCodeHolderEl();
40517 this.trigger = this.el.select('div.flag-box',true).first();
40518 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40523 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40524 _this.list.setWidth(lw);
40527 this.list.on('mouseover', this.onViewOver, this);
40528 this.list.on('mousemove', this.onViewMove, this);
40529 this.inputEl().on("keyup", this.onKeyUp, this);
40530 this.inputEl().on("keypress", this.onKeyPress, this);
40532 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40534 this.view = new Roo.View(this.list, this.tpl, {
40535 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40538 this.view.on('click', this.onViewClick, this);
40539 this.setValue(this.defaultDialCode);
40542 onTriggerClick : function(e)
40544 Roo.log('trigger click');
40549 if(this.isExpanded()){
40551 this.hasFocus = false;
40553 this.store.load({});
40554 this.hasFocus = true;
40559 isExpanded : function()
40561 return this.list.isVisible();
40564 collapse : function()
40566 if(!this.isExpanded()){
40570 Roo.get(document).un('mousedown', this.collapseIf, this);
40571 Roo.get(document).un('mousewheel', this.collapseIf, this);
40572 this.fireEvent('collapse', this);
40576 expand : function()
40580 if(this.isExpanded() || !this.hasFocus){
40584 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40585 this.list.setWidth(lw);
40588 this.restrictHeight();
40590 Roo.get(document).on('mousedown', this.collapseIf, this);
40591 Roo.get(document).on('mousewheel', this.collapseIf, this);
40593 this.fireEvent('expand', this);
40596 restrictHeight : function()
40598 this.list.alignTo(this.inputEl(), this.listAlign);
40599 this.list.alignTo(this.inputEl(), this.listAlign);
40602 onViewOver : function(e, t)
40604 if(this.inKeyMode){
40607 var item = this.view.findItemFromChild(t);
40610 var index = this.view.indexOf(item);
40611 this.select(index, false);
40616 onViewClick : function(view, doFocus, el, e)
40618 var index = this.view.getSelectedIndexes()[0];
40620 var r = this.store.getAt(index);
40623 this.onSelect(r, index);
40625 if(doFocus !== false && !this.blockFocus){
40626 this.inputEl().focus();
40630 onViewMove : function(e, t)
40632 this.inKeyMode = false;
40635 select : function(index, scrollIntoView)
40637 this.selectedIndex = index;
40638 this.view.select(index);
40639 if(scrollIntoView !== false){
40640 var el = this.view.getNode(index);
40642 this.list.scrollChildIntoView(el, false);
40647 createList : function()
40649 this.list = Roo.get(document.body).createChild({
40651 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40652 style: 'display:none'
40655 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40658 collapseIf : function(e)
40660 var in_combo = e.within(this.el);
40661 var in_list = e.within(this.list);
40662 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40664 if (in_combo || in_list || is_list) {
40670 onSelect : function(record, index)
40672 if(this.fireEvent('beforeselect', this, record, index) !== false){
40674 this.setFlagClass(record.data.iso2);
40675 this.setDialCode(record.data.dialCode);
40676 this.hasFocus = false;
40678 this.fireEvent('select', this, record, index);
40682 flagEl : function()
40684 var flag = this.el.select('div.flag',true).first();
40691 dialCodeHolderEl : function()
40693 var d = this.el.select('input.dial-code-holder',true).first();
40700 setDialCode : function(v)
40702 this.dialCodeHolder.dom.value = '+'+v;
40705 setFlagClass : function(n)
40707 this.flag.dom.className = 'flag '+n;
40710 getValue : function()
40712 var v = this.inputEl().getValue();
40713 if(this.dialCodeHolder) {
40714 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40719 setValue : function(v)
40721 var d = this.getDialCode(v);
40723 //invalid dial code
40724 if(v.length == 0 || !d || d.length == 0) {
40726 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40727 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40733 this.setFlagClass(this.dialCodeMapping[d].iso2);
40734 this.setDialCode(d);
40735 this.inputEl().dom.value = v.replace('+'+d,'');
40736 this.hiddenEl().dom.value = this.getValue();
40741 getDialCode : function(v)
40745 if (v.length == 0) {
40746 return this.dialCodeHolder.dom.value;
40750 if (v.charAt(0) != "+") {
40753 var numericChars = "";
40754 for (var i = 1; i < v.length; i++) {
40755 var c = v.charAt(i);
40758 if (this.dialCodeMapping[numericChars]) {
40759 dialCode = v.substr(1, i);
40761 if (numericChars.length == 4) {
40771 this.setValue(this.defaultDialCode);
40775 hiddenEl : function()
40777 return this.el.select('input.hidden-tel-input',true).first();
40780 // after setting val
40781 onKeyUp : function(e){
40782 this.setValue(this.getValue());
40785 onKeyPress : function(e){
40786 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40793 * @class Roo.bootstrap.MoneyField
40794 * @extends Roo.bootstrap.ComboBox
40795 * Bootstrap MoneyField class
40798 * Create a new MoneyField.
40799 * @param {Object} config Configuration options
40802 Roo.bootstrap.MoneyField = function(config) {
40804 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40808 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40811 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40813 allowDecimals : true,
40815 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40817 decimalSeparator : ".",
40819 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40821 decimalPrecision : 0,
40823 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40825 allowNegative : true,
40827 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40831 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40833 minValue : Number.NEGATIVE_INFINITY,
40835 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40837 maxValue : Number.MAX_VALUE,
40839 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40841 minText : "The minimum value for this field is {0}",
40843 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40845 maxText : "The maximum value for this field is {0}",
40847 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40848 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40850 nanText : "{0} is not a valid number",
40852 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40856 * @cfg {String} defaults currency of the MoneyField
40857 * value should be in lkey
40859 defaultCurrency : false,
40861 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40863 thousandsDelimiter : false,
40865 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40876 getAutoCreate : function()
40878 var align = this.labelAlign || this.parentLabelAlign();
40890 cls : 'form-control roo-money-amount-input',
40891 autocomplete: 'new-password'
40894 var hiddenInput = {
40898 cls: 'hidden-number-input'
40901 if(this.max_length) {
40902 input.maxlength = this.max_length;
40906 hiddenInput.name = this.name;
40909 if (this.disabled) {
40910 input.disabled = true;
40913 var clg = 12 - this.inputlg;
40914 var cmd = 12 - this.inputmd;
40915 var csm = 12 - this.inputsm;
40916 var cxs = 12 - this.inputxs;
40920 cls : 'row roo-money-field',
40924 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40928 cls: 'roo-select2-container input-group',
40932 cls : 'form-control roo-money-currency-input',
40933 autocomplete: 'new-password',
40935 name : this.currencyName
40939 cls : 'input-group-addon',
40953 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40957 cls: this.hasFeedback ? 'has-feedback' : '',
40968 if (this.fieldLabel.length) {
40971 tooltip: 'This field is required'
40977 cls: 'control-label',
40983 html: this.fieldLabel
40986 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40992 if(this.indicatorpos == 'right') {
40993 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41000 if(align == 'left') {
41008 if(this.labelWidth > 12){
41009 label.style = "width: " + this.labelWidth + 'px';
41011 if(this.labelWidth < 13 && this.labelmd == 0){
41012 this.labelmd = this.labelWidth;
41014 if(this.labellg > 0){
41015 label.cls += ' col-lg-' + this.labellg;
41016 input.cls += ' col-lg-' + (12 - this.labellg);
41018 if(this.labelmd > 0){
41019 label.cls += ' col-md-' + this.labelmd;
41020 container.cls += ' col-md-' + (12 - this.labelmd);
41022 if(this.labelsm > 0){
41023 label.cls += ' col-sm-' + this.labelsm;
41024 container.cls += ' col-sm-' + (12 - this.labelsm);
41026 if(this.labelxs > 0){
41027 label.cls += ' col-xs-' + this.labelxs;
41028 container.cls += ' col-xs-' + (12 - this.labelxs);
41039 var settings = this;
41041 ['xs','sm','md','lg'].map(function(size){
41042 if (settings[size]) {
41043 cfg.cls += ' col-' + size + '-' + settings[size];
41050 initEvents : function()
41052 this.indicator = this.indicatorEl();
41054 this.initCurrencyEvent();
41056 this.initNumberEvent();
41059 initCurrencyEvent : function()
41062 throw "can not find store for combo";
41065 this.store = Roo.factory(this.store, Roo.data);
41066 this.store.parent = this;
41070 this.triggerEl = this.el.select('.input-group-addon', true).first();
41072 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41077 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41078 _this.list.setWidth(lw);
41081 this.list.on('mouseover', this.onViewOver, this);
41082 this.list.on('mousemove', this.onViewMove, this);
41083 this.list.on('scroll', this.onViewScroll, this);
41086 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41089 this.view = new Roo.View(this.list, this.tpl, {
41090 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41093 this.view.on('click', this.onViewClick, this);
41095 this.store.on('beforeload', this.onBeforeLoad, this);
41096 this.store.on('load', this.onLoad, this);
41097 this.store.on('loadexception', this.onLoadException, this);
41099 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41100 "up" : function(e){
41101 this.inKeyMode = true;
41105 "down" : function(e){
41106 if(!this.isExpanded()){
41107 this.onTriggerClick();
41109 this.inKeyMode = true;
41114 "enter" : function(e){
41117 if(this.fireEvent("specialkey", this, e)){
41118 this.onViewClick(false);
41124 "esc" : function(e){
41128 "tab" : function(e){
41131 if(this.fireEvent("specialkey", this, e)){
41132 this.onViewClick(false);
41140 doRelay : function(foo, bar, hname){
41141 if(hname == 'down' || this.scope.isExpanded()){
41142 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41150 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41154 initNumberEvent : function(e)
41156 this.inputEl().on("keydown" , this.fireKey, this);
41157 this.inputEl().on("focus", this.onFocus, this);
41158 this.inputEl().on("blur", this.onBlur, this);
41160 this.inputEl().relayEvent('keyup', this);
41162 if(this.indicator){
41163 this.indicator.addClass('invisible');
41166 this.originalValue = this.getValue();
41168 if(this.validationEvent == 'keyup'){
41169 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41170 this.inputEl().on('keyup', this.filterValidation, this);
41172 else if(this.validationEvent !== false){
41173 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41176 if(this.selectOnFocus){
41177 this.on("focus", this.preFocus, this);
41180 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41181 this.inputEl().on("keypress", this.filterKeys, this);
41183 this.inputEl().relayEvent('keypress', this);
41186 var allowed = "0123456789";
41188 if(this.allowDecimals){
41189 allowed += this.decimalSeparator;
41192 if(this.allowNegative){
41196 if(this.thousandsDelimiter) {
41200 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41202 var keyPress = function(e){
41204 var k = e.getKey();
41206 var c = e.getCharCode();
41209 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41210 allowed.indexOf(String.fromCharCode(c)) === -1
41216 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41220 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41225 this.inputEl().on("keypress", keyPress, this);
41229 onTriggerClick : function(e)
41236 this.loadNext = false;
41238 if(this.isExpanded()){
41243 this.hasFocus = true;
41245 if(this.triggerAction == 'all') {
41246 this.doQuery(this.allQuery, true);
41250 this.doQuery(this.getRawValue());
41253 getCurrency : function()
41255 var v = this.currencyEl().getValue();
41260 restrictHeight : function()
41262 this.list.alignTo(this.currencyEl(), this.listAlign);
41263 this.list.alignTo(this.currencyEl(), this.listAlign);
41266 onViewClick : function(view, doFocus, el, e)
41268 var index = this.view.getSelectedIndexes()[0];
41270 var r = this.store.getAt(index);
41273 this.onSelect(r, index);
41277 onSelect : function(record, index){
41279 if(this.fireEvent('beforeselect', this, record, index) !== false){
41281 this.setFromCurrencyData(index > -1 ? record.data : false);
41285 this.fireEvent('select', this, record, index);
41289 setFromCurrencyData : function(o)
41293 this.lastCurrency = o;
41295 if (this.currencyField) {
41296 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41298 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41301 this.lastSelectionText = currency;
41303 //setting default currency
41304 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41305 this.setCurrency(this.defaultCurrency);
41309 this.setCurrency(currency);
41312 setFromData : function(o)
41316 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41318 this.setFromCurrencyData(c);
41323 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41325 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41328 this.setValue(value);
41332 setCurrency : function(v)
41334 this.currencyValue = v;
41337 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41342 setValue : function(v)
41344 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41350 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41352 this.inputEl().dom.value = (v == '') ? '' :
41353 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41355 if(!this.allowZero && v === '0') {
41356 this.hiddenEl().dom.value = '';
41357 this.inputEl().dom.value = '';
41364 getRawValue : function()
41366 var v = this.inputEl().getValue();
41371 getValue : function()
41373 return this.fixPrecision(this.parseValue(this.getRawValue()));
41376 parseValue : function(value)
41378 if(this.thousandsDelimiter) {
41380 r = new RegExp(",", "g");
41381 value = value.replace(r, "");
41384 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41385 return isNaN(value) ? '' : value;
41389 fixPrecision : function(value)
41391 if(this.thousandsDelimiter) {
41393 r = new RegExp(",", "g");
41394 value = value.replace(r, "");
41397 var nan = isNaN(value);
41399 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41400 return nan ? '' : value;
41402 return parseFloat(value).toFixed(this.decimalPrecision);
41405 decimalPrecisionFcn : function(v)
41407 return Math.floor(v);
41410 validateValue : function(value)
41412 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41416 var num = this.parseValue(value);
41419 this.markInvalid(String.format(this.nanText, value));
41423 if(num < this.minValue){
41424 this.markInvalid(String.format(this.minText, this.minValue));
41428 if(num > this.maxValue){
41429 this.markInvalid(String.format(this.maxText, this.maxValue));
41436 validate : function()
41438 if(this.disabled || this.allowBlank){
41443 var currency = this.getCurrency();
41445 if(this.validateValue(this.getRawValue()) && currency.length){
41450 this.markInvalid();
41454 getName: function()
41459 beforeBlur : function()
41465 var v = this.parseValue(this.getRawValue());
41472 onBlur : function()
41476 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41477 //this.el.removeClass(this.focusClass);
41480 this.hasFocus = false;
41482 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41486 var v = this.getValue();
41488 if(String(v) !== String(this.startValue)){
41489 this.fireEvent('change', this, v, this.startValue);
41492 this.fireEvent("blur", this);
41495 inputEl : function()
41497 return this.el.select('.roo-money-amount-input', true).first();
41500 currencyEl : function()
41502 return this.el.select('.roo-money-currency-input', true).first();
41505 hiddenEl : function()
41507 return this.el.select('input.hidden-number-input',true).first();
41511 * This script refer to:
41512 * Title: Signature Pad
41514 * Availability: https://github.com/szimek/signature_pad
41518 * @class Roo.bootstrap.BezierSignature
41519 * @extends Roo.bootstrap.Component
41520 * Bootstrap BezierSignature class
41523 * Create a new BezierSignature
41524 * @param {Object} config The config object
41527 Roo.bootstrap.BezierSignature = function(config){
41528 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41534 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, {
41540 mouse_btn_down: true,
41543 * @cfg(int) canvas height
41545 canvas_height: '200px',
41548 * @cfg(float or function) Radius of a single dot.
41553 * @cfg(float) Minimum width of a line. Defaults to 0.5.
41558 * @cfg(float) Maximum width of a line. Defaults to 2.5.
41563 * @cfg(integer) Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41568 * @cfg(integer) Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41573 * @cfg(string) Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images.
41575 bg_color: 'rgba(0, 0, 0, 0)',
41578 * @cfg(string) Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41580 dot_color: 'black',
41583 * @cfg(float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41585 velocity_filter_weight: 0.7,
41588 * @cfg(function) Callback when stroke begin.
41593 * @cfg(function) Callback when stroke end.
41597 getAutoCreate : function()
41599 var cls = 'roo-signature column';
41602 cls += ' ' + this.cls;
41612 for(var i = 0; i < col_sizes.length; i++) {
41613 if(this[col_sizes[i]]) {
41614 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41624 cls: 'roo-signature-body',
41628 cls: 'roo-signature-body-canvas',
41629 height: this.canvas_height,
41630 width: this.canvas_width
41637 style: 'display: none'
41645 initEvents: function()
41647 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41649 var canvas = this.canvasEl();
41651 // mouse && touch event swapping...
41652 canvas.dom.style.touchAction = 'none';
41653 canvas.dom.style.msTouchAction = 'none';
41655 this.mouse_btn_down = false;
41656 canvas.on('mousedown', this._handleMouseDown, this);
41657 canvas.on('mousemove', this._handleMouseMove, this);
41658 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41660 if (window.PointerEvent) {
41661 canvas.on('pointerdown', this._handleMouseDown, this);
41662 canvas.on('pointermove', this._handleMouseMove, this);
41663 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41666 if ('ontouchstart' in window) {
41667 canvas.on('touchstart', this._handleTouchStart, this);
41668 canvas.on('touchmove', this._handleTouchMove, this);
41669 canvas.on('touchend', this._handleTouchEnd, this);
41672 Roo.EventManager.onWindowResize(this.resize, this, true);
41674 // file input event
41675 this.fileEl().on('change', this.uploadImage, this);
41682 resize: function(){
41684 var canvas = this.canvasEl().dom;
41685 var ctx = this.canvasElCtx();
41686 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41688 // setting canvas width will clean img data
41691 var style = window.getComputedStyle ?
41692 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41694 var padding_left = parseInt(style.paddingLeft) || 0;
41695 var padding_right = parseInt(style.paddingRight) || 0;
41697 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41699 ctx.putImageData(img_data, 0, 0);
41702 _handleMouseDown: function(e)
41704 if (e.browserEvent.which === 1) {
41705 this.mouse_btn_down = true;
41706 this.strokeBegin(e);
41710 _handleMouseMove: function (e)
41712 if (this.mouse_btn_down) {
41713 this.strokeMoveUpdate(e);
41717 _handleMouseUp: function (e)
41719 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41720 this.mouse_btn_down = false;
41725 _handleTouchStart: function (e) {
41727 e.preventDefault();
41728 if (e.browserEvent.targetTouches.length === 1) {
41729 // var touch = e.browserEvent.changedTouches[0];
41730 // this.strokeBegin(touch);
41732 this.strokeBegin(e); // assume e catching the correct xy...
41736 _handleTouchMove: function (e) {
41737 e.preventDefault();
41738 // var touch = event.targetTouches[0];
41739 // _this._strokeMoveUpdate(touch);
41740 this.strokeMoveUpdate(e);
41743 _handleTouchEnd: function (e) {
41744 var wasCanvasTouched = e.target === this.canvasEl().dom;
41745 if (wasCanvasTouched) {
41746 e.preventDefault();
41747 // var touch = event.changedTouches[0];
41748 // _this._strokeEnd(touch);
41753 reset: function () {
41754 this._lastPoints = [];
41755 this._lastVelocity = 0;
41756 this._lastWidth = (this.min_width + this.max_width) / 2;
41757 this.canvasElCtx().fillStyle = this.dot_color;
41760 strokeMoveUpdate: function(e)
41762 this.strokeUpdate(e);
41764 if (this.throttle) {
41765 this.throttle(this.strokeUpdate, this.throttle);
41768 this.strokeUpdate(e);
41772 strokeBegin: function(e)
41774 var newPointGroup = {
41775 color: this.dot_color,
41779 if (typeof this.onBegin === 'function') {
41783 this.curve_data.push(newPointGroup);
41785 this.strokeUpdate(e);
41788 strokeUpdate: function(e)
41790 var rect = this.canvasEl().dom.getBoundingClientRect();
41791 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41792 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41793 var lastPoints = lastPointGroup.points;
41794 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41795 var isLastPointTooClose = lastPoint
41796 ? point.distanceTo(lastPoint) <= this.min_distance
41798 var color = lastPointGroup.color;
41799 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41800 var curve = this.addPoint(point);
41802 this.drawDot({color: color, point: point});
41805 this.drawCurve({color: color, curve: curve});
41815 strokeEnd: function(e)
41817 this.strokeUpdate(e);
41818 if (typeof this.onEnd === 'function') {
41823 addPoint: function (point) {
41824 var _lastPoints = this._lastPoints;
41825 _lastPoints.push(point);
41826 if (_lastPoints.length > 2) {
41827 if (_lastPoints.length === 3) {
41828 _lastPoints.unshift(_lastPoints[0]);
41830 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41831 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41832 _lastPoints.shift();
41838 calculateCurveWidths: function (startPoint, endPoint) {
41839 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41840 (1 - this.velocity_filter_weight) * this._lastVelocity;
41842 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41845 start: this._lastWidth
41848 this._lastVelocity = velocity;
41849 this._lastWidth = newWidth;
41853 drawDot: function (_a) {
41854 var color = _a.color, point = _a.point;
41855 var ctx = this.canvasElCtx();
41856 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41858 this.drawCurveSegment(point.x, point.y, width);
41860 ctx.fillStyle = color;
41864 drawCurve: function (_a) {
41865 var color = _a.color, curve = _a.curve;
41866 var ctx = this.canvasElCtx();
41867 var widthDelta = curve.endWidth - curve.startWidth;
41868 var drawSteps = Math.floor(curve.length()) * 2;
41870 ctx.fillStyle = color;
41871 for (var i = 0; i < drawSteps; i += 1) {
41872 var t = i / drawSteps;
41878 var x = uuu * curve.startPoint.x;
41879 x += 3 * uu * t * curve.control1.x;
41880 x += 3 * u * tt * curve.control2.x;
41881 x += ttt * curve.endPoint.x;
41882 var y = uuu * curve.startPoint.y;
41883 y += 3 * uu * t * curve.control1.y;
41884 y += 3 * u * tt * curve.control2.y;
41885 y += ttt * curve.endPoint.y;
41886 var width = curve.startWidth + ttt * widthDelta;
41887 this.drawCurveSegment(x, y, width);
41893 drawCurveSegment: function (x, y, width) {
41894 var ctx = this.canvasElCtx();
41896 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41897 this.is_empty = false;
41902 var ctx = this.canvasElCtx();
41903 var canvas = this.canvasEl().dom;
41904 ctx.fillStyle = this.bg_color;
41905 ctx.clearRect(0, 0, canvas.width, canvas.height);
41906 ctx.fillRect(0, 0, canvas.width, canvas.height);
41907 this.curve_data = [];
41909 this.is_empty = true;
41914 return this.el.select('input',true).first();
41917 canvasEl: function()
41919 return this.el.select('canvas',true).first();
41922 canvasElCtx: function()
41924 return this.el.select('canvas',true).first().dom.getContext('2d');
41927 getImage: function(type)
41929 if(this.is_empty) {
41934 return this.canvasEl().dom.toDataURL('image/'+type, 1);
41937 drawFromImage: function(img_src)
41939 var img = new Image();
41941 img.onload = function(){
41942 this.canvasElCtx().drawImage(img, 0, 0);
41947 this.is_empty = false;
41950 selectImage: function()
41952 this.fileEl().dom.click();
41955 uploadImage: function(e)
41957 var reader = new FileReader();
41959 reader.onload = function(e){
41960 var img = new Image();
41961 img.onload = function(){
41963 this.canvasElCtx().drawImage(img, 0, 0);
41965 img.src = e.target.result;
41968 reader.readAsDataURL(e.target.files[0]);
41971 // Bezier Point Constructor
41972 Point: (function () {
41973 function Point(x, y, time) {
41976 this.time = time || Date.now();
41978 Point.prototype.distanceTo = function (start) {
41979 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
41981 Point.prototype.equals = function (other) {
41982 return this.x === other.x && this.y === other.y && this.time === other.time;
41984 Point.prototype.velocityFrom = function (start) {
41985 return this.time !== start.time
41986 ? this.distanceTo(start) / (this.time - start.time)
41993 // Bezier Constructor
41994 Bezier: (function () {
41995 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
41996 this.startPoint = startPoint;
41997 this.control2 = control2;
41998 this.control1 = control1;
41999 this.endPoint = endPoint;
42000 this.startWidth = startWidth;
42001 this.endWidth = endWidth;
42003 Bezier.fromPoints = function (points, widths, scope) {
42004 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42005 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42006 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42008 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42009 var dx1 = s1.x - s2.x;
42010 var dy1 = s1.y - s2.y;
42011 var dx2 = s2.x - s3.x;
42012 var dy2 = s2.y - s3.y;
42013 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42014 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42015 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42016 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42017 var dxm = m1.x - m2.x;
42018 var dym = m1.y - m2.y;
42019 var k = l2 / (l1 + l2);
42020 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42021 var tx = s2.x - cm.x;
42022 var ty = s2.y - cm.y;
42024 c1: new scope.Point(m1.x + tx, m1.y + ty),
42025 c2: new scope.Point(m2.x + tx, m2.y + ty)
42028 Bezier.prototype.length = function () {
42033 for (var i = 0; i <= steps; i += 1) {
42035 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42036 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42038 var xdiff = cx - px;
42039 var ydiff = cy - py;
42040 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42047 Bezier.prototype.point = function (t, start, c1, c2, end) {
42048 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42049 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42050 + (3.0 * c2 * (1.0 - t) * t * t)
42051 + (end * t * t * t);
42056 throttle: function(fn, wait) {
42057 if (wait === void 0) { wait = 250; }
42059 var timeout = null;
42063 var later = function () {
42064 previous = Date.now();
42066 result = fn.apply(storedContext, storedArgs);
42068 storedContext = null;
42072 return function wrapper() {
42074 for (var _i = 0; _i < arguments.length; _i++) {
42075 args[_i] = arguments[_i];
42077 var now = Date.now();
42078 var remaining = wait - (now - previous);
42079 storedContext = this;
42081 if (remaining <= 0 || remaining > wait) {
42083 clearTimeout(timeout);
42087 result = fn.apply(storedContext, storedArgs);
42089 storedContext = null;
42093 else if (!timeout) {
42094 timeout = window.setTimeout(later, remaining);