2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets[0], function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
585 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
586 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
587 * @cfg {String} size ( lg | sm | xs)
588 * @cfg {String} tag ( a | input | submit)
589 * @cfg {String} href empty or href
590 * @cfg {Boolean} disabled default false;
591 * @cfg {Boolean} isClose default false;
592 * @cfg {String} glyphicon depricated - use fa
593 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
594 * @cfg {String} badge text for badge
595 * @cfg {String} theme (default|glow)
596 * @cfg {Boolean} inverse dark themed version
597 * @cfg {Boolean} toggle is it a slidy toggle button
598 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
599 * @cfg {String} ontext text for on slidy toggle state
600 * @cfg {String} offtext text for off slidy toggle state
601 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
602 * @cfg {Boolean} removeClass remove the standard class..
603 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
606 * Create a new button
607 * @param {Object} config The config object
611 Roo.bootstrap.Button = function(config){
612 Roo.bootstrap.Button.superclass.constructor.call(this, config);
613 this.weightClass = ["btn-default btn-outline-secondary",
625 * When a butotn is pressed
626 * @param {Roo.bootstrap.Button} btn
627 * @param {Roo.EventObject} e
632 * After the button has been toggles
633 * @param {Roo.bootstrap.Button} btn
634 * @param {Roo.EventObject} e
635 * @param {boolean} pressed (also available as button.pressed)
641 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
662 preventDefault: true,
670 getAutoCreate : function(){
678 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
679 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
684 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
686 if (this.toggle == true) {
689 cls: 'slider-frame roo-button',
694 'data-off-text':'OFF',
695 cls: 'slider-button',
701 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
702 cfg.cls += ' '+this.weight;
711 cfg["aria-hidden"] = true;
713 cfg.html = "×";
719 if (this.theme==='default') {
720 cfg.cls = 'btn roo-button';
722 //if (this.parentType != 'Navbar') {
723 this.weight = this.weight.length ? this.weight : 'default';
725 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
727 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
728 var weight = this.weight == 'default' ? 'secondary' : this.weight;
729 cfg.cls += ' btn-' + outline + weight;
730 if (this.weight == 'default') {
732 cfg.cls += ' btn-' + this.weight;
735 } else if (this.theme==='glow') {
738 cfg.cls = 'btn-glow roo-button';
740 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
742 cfg.cls += ' ' + this.weight;
748 this.cls += ' inverse';
752 if (this.active || this.pressed === true) {
753 cfg.cls += ' active';
757 cfg.disabled = 'disabled';
761 Roo.log('changing to ul' );
763 this.glyphicon = 'caret';
764 if (Roo.bootstrap.version == 4) {
765 this.fa = 'caret-down';
770 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
772 //gsRoo.log(this.parentType);
773 if (this.parentType === 'Navbar' && !this.parent().bar) {
774 Roo.log('changing to li?');
783 href : this.href || '#'
786 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
787 cfg.cls += ' dropdown';
794 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
796 if (this.glyphicon) {
797 cfg.html = ' ' + cfg.html;
802 cls: 'glyphicon glyphicon-' + this.glyphicon
807 cfg.html = ' ' + cfg.html;
812 cls: 'fa fas fa-' + this.fa
822 // cfg.cls='btn roo-button';
826 var value = cfg.html;
831 cls: 'glyphicon glyphicon-' + this.glyphicon,
838 cls: 'fa fas fa-' + this.fa,
843 var bw = this.badge_weight.length ? this.badge_weight :
844 (this.weight.length ? this.weight : 'secondary');
845 bw = bw == 'default' ? 'secondary' : bw;
851 cls: 'badge badge-' + bw,
860 cfg.cls += ' dropdown';
861 cfg.html = typeof(cfg.html) != 'undefined' ?
862 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
865 if (cfg.tag !== 'a' && this.href !== '') {
866 throw "Tag must be a to set href.";
867 } else if (this.href.length > 0) {
868 cfg.href = this.href;
871 if(this.removeClass){
876 cfg.target = this.target;
881 initEvents: function() {
882 // Roo.log('init events?');
883 // Roo.log(this.el.dom);
886 if (typeof (this.menu) != 'undefined') {
887 this.menu.parentType = this.xtype;
888 this.menu.triggerEl = this.el;
889 this.addxtype(Roo.apply({}, this.menu));
893 if (this.el.hasClass('roo-button')) {
894 this.el.on('click', this.onClick, this);
896 this.el.select('.roo-button').on('click', this.onClick, this);
899 if(this.removeClass){
900 this.el.on('click', this.onClick, this);
903 this.el.enableDisplayMode();
906 onClick : function(e)
912 Roo.log('button on click ');
913 if(this.preventDefault){
917 if (this.pressed === true || this.pressed === false) {
918 this.toggleActive(e);
922 this.fireEvent('click', this, e);
926 * Enables this button
930 this.disabled = false;
931 this.el.removeClass('disabled');
935 * Disable this button
939 this.disabled = true;
940 this.el.addClass('disabled');
943 * sets the active state on/off,
944 * @param {Boolean} state (optional) Force a particular state
946 setActive : function(v) {
948 this.el[v ? 'addClass' : 'removeClass']('active');
952 * toggles the current active state
954 toggleActive : function(e)
956 this.setActive(!this.pressed);
957 this.fireEvent('toggle', this, e, !this.pressed);
960 * get the current active state
961 * @return {boolean} true if it's active
963 isActive : function()
965 return this.el.hasClass('active');
968 * set the text of the first selected button
970 setText : function(str)
972 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
975 * get the text of the first selected button
979 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
982 setWeight : function(str)
984 this.el.removeClass(this.weightClass);
986 var outline = this.outline ? 'outline-' : '';
987 if (str == 'default') {
988 this.el.addClass('btn-default btn-outline-secondary');
991 this.el.addClass('btn-' + outline + str);
1005 * @class Roo.bootstrap.Column
1006 * @extends Roo.bootstrap.Component
1007 * Bootstrap Column class
1008 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1009 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1010 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1011 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1012 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1013 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1014 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1015 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1018 * @cfg {Boolean} hidden (true|false) hide the element
1019 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1020 * @cfg {String} fa (ban|check|...) font awesome icon
1021 * @cfg {Number} fasize (1|2|....) font awsome size
1023 * @cfg {String} icon (info-sign|check|...) glyphicon name
1025 * @cfg {String} html content of column.
1028 * Create a new Column
1029 * @param {Object} config The config object
1032 Roo.bootstrap.Column = function(config){
1033 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1036 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1054 getAutoCreate : function(){
1055 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1063 ['xs','sm','md','lg'].map(function(size){
1064 //Roo.log( size + ':' + settings[size]);
1066 if (settings[size+'off'] !== false) {
1067 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1070 if (settings[size] === false) {
1074 if (!settings[size]) { // 0 = hidden
1075 cfg.cls += ' hidden-' + size;
1078 cfg.cls += ' col-' + size + '-' + settings[size];
1083 cfg.cls += ' hidden';
1086 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1087 cfg.cls +=' alert alert-' + this.alert;
1091 if (this.html.length) {
1092 cfg.html = this.html;
1096 if (this.fasize > 1) {
1097 fasize = ' fa-' + this.fasize + 'x';
1099 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1104 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1123 * @class Roo.bootstrap.Container
1124 * @extends Roo.bootstrap.Component
1125 * Bootstrap Container class
1126 * @cfg {Boolean} jumbotron is it a jumbotron element
1127 * @cfg {String} html content of element
1128 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1129 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1130 * @cfg {String} header content of header (for panel)
1131 * @cfg {String} footer content of footer (for panel)
1132 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1133 * @cfg {String} tag (header|aside|section) type of HTML tag.
1134 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1135 * @cfg {String} fa font awesome icon
1136 * @cfg {String} icon (info-sign|check|...) glyphicon name
1137 * @cfg {Boolean} hidden (true|false) hide the element
1138 * @cfg {Boolean} expandable (true|false) default false
1139 * @cfg {Boolean} expanded (true|false) default true
1140 * @cfg {String} rheader contet on the right of header
1141 * @cfg {Boolean} clickable (true|false) default false
1145 * Create a new Container
1146 * @param {Object} config The config object
1149 Roo.bootstrap.Container = function(config){
1150 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1156 * After the panel has been expand
1158 * @param {Roo.bootstrap.Container} this
1163 * After the panel has been collapsed
1165 * @param {Roo.bootstrap.Container} this
1170 * When a element is chick
1171 * @param {Roo.bootstrap.Container} this
1172 * @param {Roo.EventObject} e
1178 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1196 getChildContainer : function() {
1202 if (this.panel.length) {
1203 return this.el.select('.panel-body',true).first();
1210 getAutoCreate : function(){
1213 tag : this.tag || 'div',
1217 if (this.jumbotron) {
1218 cfg.cls = 'jumbotron';
1223 // - this is applied by the parent..
1225 // cfg.cls = this.cls + '';
1228 if (this.sticky.length) {
1230 var bd = Roo.get(document.body);
1231 if (!bd.hasClass('bootstrap-sticky')) {
1232 bd.addClass('bootstrap-sticky');
1233 Roo.select('html',true).setStyle('height', '100%');
1236 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1240 if (this.well.length) {
1241 switch (this.well) {
1244 cfg.cls +=' well well-' +this.well;
1253 cfg.cls += ' hidden';
1257 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1258 cfg.cls +=' alert alert-' + this.alert;
1263 if (this.panel.length) {
1264 cfg.cls += ' panel panel-' + this.panel;
1266 if (this.header.length) {
1270 if(this.expandable){
1272 cfg.cls = cfg.cls + ' expandable';
1276 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1284 cls : 'panel-title',
1285 html : (this.expandable ? ' ' : '') + this.header
1289 cls: 'panel-header-right',
1295 cls : 'panel-heading',
1296 style : this.expandable ? 'cursor: pointer' : '',
1304 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1309 if (this.footer.length) {
1311 cls : 'panel-footer',
1320 body.html = this.html || cfg.html;
1321 // prefix with the icons..
1323 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1326 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1331 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1332 cfg.cls = 'container';
1338 initEvents: function()
1340 if(this.expandable){
1341 var headerEl = this.headerEl();
1344 headerEl.on('click', this.onToggleClick, this);
1349 this.el.on('click', this.onClick, this);
1354 onToggleClick : function()
1356 var headerEl = this.headerEl();
1372 if(this.fireEvent('expand', this)) {
1374 this.expanded = true;
1376 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1378 this.el.select('.panel-body',true).first().removeClass('hide');
1380 var toggleEl = this.toggleEl();
1386 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1391 collapse : function()
1393 if(this.fireEvent('collapse', this)) {
1395 this.expanded = false;
1397 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1398 this.el.select('.panel-body',true).first().addClass('hide');
1400 var toggleEl = this.toggleEl();
1406 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1410 toggleEl : function()
1412 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1416 return this.el.select('.panel-heading .fa',true).first();
1419 headerEl : function()
1421 if(!this.el || !this.panel.length || !this.header.length){
1425 return this.el.select('.panel-heading',true).first()
1430 if(!this.el || !this.panel.length){
1434 return this.el.select('.panel-body',true).first()
1437 titleEl : function()
1439 if(!this.el || !this.panel.length || !this.header.length){
1443 return this.el.select('.panel-title',true).first();
1446 setTitle : function(v)
1448 var titleEl = this.titleEl();
1454 titleEl.dom.innerHTML = v;
1457 getTitle : function()
1460 var titleEl = this.titleEl();
1466 return titleEl.dom.innerHTML;
1469 setRightTitle : function(v)
1471 var t = this.el.select('.panel-header-right',true).first();
1477 t.dom.innerHTML = v;
1480 onClick : function(e)
1484 this.fireEvent('click', this, e);
1497 * @class Roo.bootstrap.Img
1498 * @extends Roo.bootstrap.Component
1499 * Bootstrap Img class
1500 * @cfg {Boolean} imgResponsive false | true
1501 * @cfg {String} border rounded | circle | thumbnail
1502 * @cfg {String} src image source
1503 * @cfg {String} alt image alternative text
1504 * @cfg {String} href a tag href
1505 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1506 * @cfg {String} xsUrl xs image source
1507 * @cfg {String} smUrl sm image source
1508 * @cfg {String} mdUrl md image source
1509 * @cfg {String} lgUrl lg image source
1512 * Create a new Input
1513 * @param {Object} config The config object
1516 Roo.bootstrap.Img = function(config){
1517 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1523 * The img click event for the img.
1524 * @param {Roo.EventObject} e
1530 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1532 imgResponsive: true,
1542 getAutoCreate : function()
1544 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1545 return this.createSingleImg();
1550 cls: 'roo-image-responsive-group',
1555 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1557 if(!_this[size + 'Url']){
1563 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1564 html: _this.html || cfg.html,
1565 src: _this[size + 'Url']
1568 img.cls += ' roo-image-responsive-' + size;
1570 var s = ['xs', 'sm', 'md', 'lg'];
1572 s.splice(s.indexOf(size), 1);
1574 Roo.each(s, function(ss){
1575 img.cls += ' hidden-' + ss;
1578 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1579 cfg.cls += ' img-' + _this.border;
1583 cfg.alt = _this.alt;
1596 a.target = _this.target;
1600 cfg.cn.push((_this.href) ? a : img);
1607 createSingleImg : function()
1611 cls: (this.imgResponsive) ? 'img-responsive' : '',
1613 src : 'about:blank' // just incase src get's set to undefined?!?
1616 cfg.html = this.html || cfg.html;
1618 cfg.src = this.src || cfg.src;
1620 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1621 cfg.cls += ' img-' + this.border;
1638 a.target = this.target;
1643 return (this.href) ? a : cfg;
1646 initEvents: function()
1649 this.el.on('click', this.onClick, this);
1654 onClick : function(e)
1656 Roo.log('img onclick');
1657 this.fireEvent('click', this, e);
1660 * Sets the url of the image - used to update it
1661 * @param {String} url the url of the image
1664 setSrc : function(url)
1668 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1669 this.el.dom.src = url;
1673 this.el.select('img', true).first().dom.src = url;
1689 * @class Roo.bootstrap.Link
1690 * @extends Roo.bootstrap.Component
1691 * Bootstrap Link Class
1692 * @cfg {String} alt image alternative text
1693 * @cfg {String} href a tag href
1694 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1695 * @cfg {String} html the content of the link.
1696 * @cfg {String} anchor name for the anchor link
1697 * @cfg {String} fa - favicon
1699 * @cfg {Boolean} preventDefault (true | false) default false
1703 * Create a new Input
1704 * @param {Object} config The config object
1707 Roo.bootstrap.Link = function(config){
1708 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1714 * The img click event for the img.
1715 * @param {Roo.EventObject} e
1721 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1725 preventDefault: false,
1731 getAutoCreate : function()
1733 var html = this.html || '';
1735 if (this.fa !== false) {
1736 html = '<i class="fa fa-' + this.fa + '"></i>';
1741 // anchor's do not require html/href...
1742 if (this.anchor === false) {
1744 cfg.href = this.href || '#';
1746 cfg.name = this.anchor;
1747 if (this.html !== false || this.fa !== false) {
1750 if (this.href !== false) {
1751 cfg.href = this.href;
1755 if(this.alt !== false){
1760 if(this.target !== false) {
1761 cfg.target = this.target;
1767 initEvents: function() {
1769 if(!this.href || this.preventDefault){
1770 this.el.on('click', this.onClick, this);
1774 onClick : function(e)
1776 if(this.preventDefault){
1779 //Roo.log('img onclick');
1780 this.fireEvent('click', this, e);
1793 * @class Roo.bootstrap.Header
1794 * @extends Roo.bootstrap.Component
1795 * Bootstrap Header class
1796 * @cfg {String} html content of header
1797 * @cfg {Number} level (1|2|3|4|5|6) default 1
1800 * Create a new Header
1801 * @param {Object} config The config object
1805 Roo.bootstrap.Header = function(config){
1806 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1809 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1817 getAutoCreate : function(){
1822 tag: 'h' + (1 *this.level),
1823 html: this.html || ''
1835 * Ext JS Library 1.1.1
1836 * Copyright(c) 2006-2007, Ext JS, LLC.
1838 * Originally Released Under LGPL - original licence link has changed is not relivant.
1841 * <script type="text/javascript">
1845 * @class Roo.bootstrap.MenuMgr
1846 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1849 Roo.bootstrap.MenuMgr = function(){
1850 var menus, active, groups = {}, attached = false, lastShow = new Date();
1852 // private - called when first menu is created
1855 active = new Roo.util.MixedCollection();
1856 Roo.get(document).addKeyListener(27, function(){
1857 if(active.length > 0){
1865 if(active && active.length > 0){
1866 var c = active.clone();
1876 if(active.length < 1){
1877 Roo.get(document).un("mouseup", onMouseDown);
1885 var last = active.last();
1886 lastShow = new Date();
1889 Roo.get(document).on("mouseup", onMouseDown);
1894 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1895 m.parentMenu.activeChild = m;
1896 }else if(last && last.isVisible()){
1897 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1902 function onBeforeHide(m){
1904 m.activeChild.hide();
1906 if(m.autoHideTimer){
1907 clearTimeout(m.autoHideTimer);
1908 delete m.autoHideTimer;
1913 function onBeforeShow(m){
1914 var pm = m.parentMenu;
1915 if(!pm && !m.allowOtherMenus){
1917 }else if(pm && pm.activeChild && active != m){
1918 pm.activeChild.hide();
1922 // private this should really trigger on mouseup..
1923 function onMouseDown(e){
1924 Roo.log("on Mouse Up");
1926 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1927 Roo.log("MenuManager hideAll");
1936 function onBeforeCheck(mi, state){
1938 var g = groups[mi.group];
1939 for(var i = 0, l = g.length; i < l; i++){
1941 g[i].setChecked(false);
1950 * Hides all menus that are currently visible
1952 hideAll : function(){
1957 register : function(menu){
1961 menus[menu.id] = menu;
1962 menu.on("beforehide", onBeforeHide);
1963 menu.on("hide", onHide);
1964 menu.on("beforeshow", onBeforeShow);
1965 menu.on("show", onShow);
1967 if(g && menu.events["checkchange"]){
1971 groups[g].push(menu);
1972 menu.on("checkchange", onCheck);
1977 * Returns a {@link Roo.menu.Menu} object
1978 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1979 * be used to generate and return a new Menu instance.
1981 get : function(menu){
1982 if(typeof menu == "string"){ // menu id
1984 }else if(menu.events){ // menu instance
1987 /*else if(typeof menu.length == 'number'){ // array of menu items?
1988 return new Roo.bootstrap.Menu({items:menu});
1989 }else{ // otherwise, must be a config
1990 return new Roo.bootstrap.Menu(menu);
1997 unregister : function(menu){
1998 delete menus[menu.id];
1999 menu.un("beforehide", onBeforeHide);
2000 menu.un("hide", onHide);
2001 menu.un("beforeshow", onBeforeShow);
2002 menu.un("show", onShow);
2004 if(g && menu.events["checkchange"]){
2005 groups[g].remove(menu);
2006 menu.un("checkchange", onCheck);
2011 registerCheckable : function(menuItem){
2012 var g = menuItem.group;
2017 groups[g].push(menuItem);
2018 menuItem.on("beforecheckchange", onBeforeCheck);
2023 unregisterCheckable : function(menuItem){
2024 var g = menuItem.group;
2026 groups[g].remove(menuItem);
2027 menuItem.un("beforecheckchange", onBeforeCheck);
2039 * @class Roo.bootstrap.Menu
2040 * @extends Roo.bootstrap.Component
2041 * Bootstrap Menu class - container for MenuItems
2042 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2043 * @cfg {bool} hidden if the menu should be hidden when rendered.
2044 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2045 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2049 * @param {Object} config The config object
2053 Roo.bootstrap.Menu = function(config){
2054 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2055 if (this.registerMenu && this.type != 'treeview') {
2056 Roo.bootstrap.MenuMgr.register(this);
2063 * Fires before this menu is displayed
2064 * @param {Roo.menu.Menu} this
2069 * Fires before this menu is hidden
2070 * @param {Roo.menu.Menu} this
2075 * Fires after this menu is displayed
2076 * @param {Roo.menu.Menu} this
2081 * Fires after this menu is hidden
2082 * @param {Roo.menu.Menu} this
2087 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2088 * @param {Roo.menu.Menu} this
2089 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2090 * @param {Roo.EventObject} e
2095 * Fires when the mouse is hovering over this menu
2096 * @param {Roo.menu.Menu} this
2097 * @param {Roo.EventObject} e
2098 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2103 * Fires when the mouse exits this menu
2104 * @param {Roo.menu.Menu} this
2105 * @param {Roo.EventObject} e
2106 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2111 * Fires when a menu item contained in this menu is clicked
2112 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2113 * @param {Roo.EventObject} e
2117 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2120 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2124 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2127 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2129 registerMenu : true,
2131 menuItems :false, // stores the menu items..
2141 getChildContainer : function() {
2145 getAutoCreate : function(){
2147 //if (['right'].indexOf(this.align)!==-1) {
2148 // cfg.cn[1].cls += ' pull-right'
2154 cls : 'dropdown-menu' ,
2155 style : 'z-index:1000'
2159 if (this.type === 'submenu') {
2160 cfg.cls = 'submenu active';
2162 if (this.type === 'treeview') {
2163 cfg.cls = 'treeview-menu';
2168 initEvents : function() {
2170 // Roo.log("ADD event");
2171 // Roo.log(this.triggerEl.dom);
2173 this.triggerEl.on('click', this.onTriggerClick, this);
2175 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2178 if (this.triggerEl.hasClass('nav-item')) {
2179 // dropdown toggle on the 'a' in BS4?
2180 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2182 this.triggerEl.addClass('dropdown-toggle');
2185 this.el.on('touchstart' , this.onTouch, this);
2187 this.el.on('click' , this.onClick, this);
2189 this.el.on("mouseover", this.onMouseOver, this);
2190 this.el.on("mouseout", this.onMouseOut, this);
2194 findTargetItem : function(e)
2196 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2200 //Roo.log(t); Roo.log(t.id);
2202 //Roo.log(this.menuitems);
2203 return this.menuitems.get(t.id);
2205 //return this.items.get(t.menuItemId);
2211 onTouch : function(e)
2213 Roo.log("menu.onTouch");
2214 //e.stopEvent(); this make the user popdown broken
2218 onClick : function(e)
2220 Roo.log("menu.onClick");
2222 var t = this.findTargetItem(e);
2223 if(!t || t.isContainer){
2228 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2229 if(t == this.activeItem && t.shouldDeactivate(e)){
2230 this.activeItem.deactivate();
2231 delete this.activeItem;
2235 this.setActiveItem(t, true);
2243 Roo.log('pass click event');
2247 this.fireEvent("click", this, t, e);
2251 if(!t.href.length || t.href == '#'){
2252 (function() { _this.hide(); }).defer(100);
2257 onMouseOver : function(e){
2258 var t = this.findTargetItem(e);
2261 // if(t.canActivate && !t.disabled){
2262 // this.setActiveItem(t, true);
2266 this.fireEvent("mouseover", this, e, t);
2268 isVisible : function(){
2269 return !this.hidden;
2271 onMouseOut : function(e){
2272 var t = this.findTargetItem(e);
2275 // if(t == this.activeItem && t.shouldDeactivate(e)){
2276 // this.activeItem.deactivate();
2277 // delete this.activeItem;
2280 this.fireEvent("mouseout", this, e, t);
2285 * Displays this menu relative to another element
2286 * @param {String/HTMLElement/Roo.Element} element The element to align to
2287 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2288 * the element (defaults to this.defaultAlign)
2289 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2291 show : function(el, pos, parentMenu){
2292 this.parentMenu = parentMenu;
2296 this.fireEvent("beforeshow", this);
2297 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2300 * Displays this menu at a specific xy position
2301 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2302 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2304 showAt : function(xy, parentMenu, /* private: */_e){
2305 this.parentMenu = parentMenu;
2310 this.fireEvent("beforeshow", this);
2311 //xy = this.el.adjustForConstraints(xy);
2315 this.hideMenuItems();
2316 this.hidden = false;
2317 this.triggerEl.addClass('open');
2318 this.el.addClass('show');
2320 // reassign x when hitting right
2321 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2322 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2325 // reassign y when hitting bottom
2326 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2327 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2330 // but the list may align on trigger left or trigger top... should it be a properity?
2332 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2337 this.fireEvent("show", this);
2343 this.doFocus.defer(50, this);
2347 doFocus : function(){
2349 this.focusEl.focus();
2354 * Hides this menu and optionally all parent menus
2355 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2357 hide : function(deep)
2360 this.hideMenuItems();
2361 if(this.el && this.isVisible()){
2362 this.fireEvent("beforehide", this);
2363 if(this.activeItem){
2364 this.activeItem.deactivate();
2365 this.activeItem = null;
2367 this.triggerEl.removeClass('open');;
2368 this.el.removeClass('show');
2370 this.fireEvent("hide", this);
2372 if(deep === true && this.parentMenu){
2373 this.parentMenu.hide(true);
2377 onTriggerClick : function(e)
2379 Roo.log('trigger click');
2381 var target = e.getTarget();
2383 Roo.log(target.nodeName.toLowerCase());
2385 if(target.nodeName.toLowerCase() === 'i'){
2391 onTriggerPress : function(e)
2393 Roo.log('trigger press');
2394 //Roo.log(e.getTarget());
2395 // Roo.log(this.triggerEl.dom);
2397 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2398 var pel = Roo.get(e.getTarget());
2399 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2400 Roo.log('is treeview or dropdown?');
2404 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2408 if (this.isVisible()) {
2413 this.show(this.triggerEl, '?', false);
2416 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2423 hideMenuItems : function()
2425 Roo.log("hide Menu Items");
2429 //$(backdrop).remove()
2430 this.el.select('.open',true).each(function(aa) {
2432 aa.removeClass('open');
2433 //var parent = getParent($(this))
2434 //var relatedTarget = { relatedTarget: this }
2436 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2437 //if (e.isDefaultPrevented()) return
2438 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2441 addxtypeChild : function (tree, cntr) {
2442 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2444 this.menuitems.add(comp);
2456 this.getEl().dom.innerHTML = '';
2457 this.menuitems.clear();
2471 * @class Roo.bootstrap.MenuItem
2472 * @extends Roo.bootstrap.Component
2473 * Bootstrap MenuItem class
2474 * @cfg {String} html the menu label
2475 * @cfg {String} href the link
2476 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2477 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2478 * @cfg {Boolean} active used on sidebars to highlight active itesm
2479 * @cfg {String} fa favicon to show on left of menu item.
2480 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2484 * Create a new MenuItem
2485 * @param {Object} config The config object
2489 Roo.bootstrap.MenuItem = function(config){
2490 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2495 * The raw click event for the entire grid.
2496 * @param {Roo.bootstrap.MenuItem} this
2497 * @param {Roo.EventObject} e
2503 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2507 preventDefault: false,
2508 isContainer : false,
2512 getAutoCreate : function(){
2514 if(this.isContainer){
2517 cls: 'dropdown-menu-item '
2527 cls : 'dropdown-item',
2532 if (this.fa !== false) {
2535 cls : 'fa fa-' + this.fa
2544 cls: 'dropdown-menu-item',
2547 if (this.parent().type == 'treeview') {
2548 cfg.cls = 'treeview-menu';
2551 cfg.cls += ' active';
2556 anc.href = this.href || cfg.cn[0].href ;
2557 ctag.html = this.html || cfg.cn[0].html ;
2561 initEvents: function()
2563 if (this.parent().type == 'treeview') {
2564 this.el.select('a').on('click', this.onClick, this);
2568 this.menu.parentType = this.xtype;
2569 this.menu.triggerEl = this.el;
2570 this.menu = this.addxtype(Roo.apply({}, this.menu));
2574 onClick : function(e)
2576 Roo.log('item on click ');
2578 if(this.preventDefault){
2581 //this.parent().hideMenuItems();
2583 this.fireEvent('click', this, e);
2602 * @class Roo.bootstrap.MenuSeparator
2603 * @extends Roo.bootstrap.Component
2604 * Bootstrap MenuSeparator class
2607 * Create a new MenuItem
2608 * @param {Object} config The config object
2612 Roo.bootstrap.MenuSeparator = function(config){
2613 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2616 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2618 getAutoCreate : function(){
2637 * @class Roo.bootstrap.Modal
2638 * @extends Roo.bootstrap.Component
2639 * Bootstrap Modal class
2640 * @cfg {String} title Title of dialog
2641 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2642 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2643 * @cfg {Boolean} specificTitle default false
2644 * @cfg {Array} buttons Array of buttons or standard button set..
2645 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2646 * @cfg {Boolean} animate default true
2647 * @cfg {Boolean} allow_close default true
2648 * @cfg {Boolean} fitwindow default false
2649 * @cfg {String} size (sm|lg) default empty
2650 * @cfg {Number} max_width set the max width of modal
2654 * Create a new Modal Dialog
2655 * @param {Object} config The config object
2658 Roo.bootstrap.Modal = function(config){
2659 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2664 * The raw btnclick event for the button
2665 * @param {Roo.EventObject} e
2670 * Fire when dialog resize
2671 * @param {Roo.bootstrap.Modal} this
2672 * @param {Roo.EventObject} e
2676 this.buttons = this.buttons || [];
2679 this.tmpl = Roo.factory(this.tmpl);
2684 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2686 title : 'test dialog',
2696 specificTitle: false,
2698 buttonPosition: 'right',
2721 onRender : function(ct, position)
2723 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2726 var cfg = Roo.apply({}, this.getAutoCreate());
2729 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2731 //if (!cfg.name.length) {
2735 cfg.cls += ' ' + this.cls;
2738 cfg.style = this.style;
2740 this.el = Roo.get(document.body).createChild(cfg, position);
2742 //var type = this.el.dom.type;
2745 if(this.tabIndex !== undefined){
2746 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2749 this.dialogEl = this.el.select('.modal-dialog',true).first();
2750 this.bodyEl = this.el.select('.modal-body',true).first();
2751 this.closeEl = this.el.select('.modal-header .close', true).first();
2752 this.headerEl = this.el.select('.modal-header',true).first();
2753 this.titleEl = this.el.select('.modal-title',true).first();
2754 this.footerEl = this.el.select('.modal-footer',true).first();
2756 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2758 //this.el.addClass("x-dlg-modal");
2760 if (this.buttons.length) {
2761 Roo.each(this.buttons, function(bb) {
2762 var b = Roo.apply({}, bb);
2763 b.xns = b.xns || Roo.bootstrap;
2764 b.xtype = b.xtype || 'Button';
2765 if (typeof(b.listeners) == 'undefined') {
2766 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2769 var btn = Roo.factory(b);
2771 btn.render(this.getButtonContainer());
2775 // render the children.
2778 if(typeof(this.items) != 'undefined'){
2779 var items = this.items;
2782 for(var i =0;i < items.length;i++) {
2783 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2787 this.items = nitems;
2789 // where are these used - they used to be body/close/footer
2793 //this.el.addClass([this.fieldClass, this.cls]);
2797 getAutoCreate : function()
2801 html : this.html || ''
2806 cls : 'modal-title',
2810 if(this.specificTitle){
2816 if (this.allow_close && Roo.bootstrap.version == 3) {
2826 if (this.allow_close && Roo.bootstrap.version == 4) {
2836 if(this.size.length){
2837 size = 'modal-' + this.size;
2840 var footer = Roo.bootstrap.version == 3 ?
2842 cls : 'modal-footer',
2846 cls: 'btn-' + this.buttonPosition
2851 { // BS4 uses mr-auto on left buttons....
2852 cls : 'modal-footer'
2863 cls: "modal-dialog " + size,
2866 cls : "modal-content",
2869 cls : 'modal-header',
2884 modal.cls += ' fade';
2890 getChildContainer : function() {
2895 getButtonContainer : function() {
2897 return Roo.bootstrap.version == 4 ?
2898 this.el.select('.modal-footer',true).first()
2899 : this.el.select('.modal-footer div',true).first();
2902 initEvents : function()
2904 if (this.allow_close) {
2905 this.closeEl.on('click', this.hide, this);
2907 Roo.EventManager.onWindowResize(this.resize, this, true);
2914 this.maskEl.setSize(
2915 Roo.lib.Dom.getViewWidth(true),
2916 Roo.lib.Dom.getViewHeight(true)
2919 if (this.fitwindow) {
2921 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2922 this.height || Roo.lib.Dom.getViewportHeight(true) - 60
2927 if(this.max_width !== 0) {
2929 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2932 this.setSize(w, this.height);
2936 if(this.max_height) {
2937 this.setSize(w,Math.min(
2939 Roo.lib.Dom.getViewportHeight(true) - 60
2945 if(!this.fit_content) {
2946 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2950 this.setSize(w, Math.min(
2952 this.headerEl.getHeight() +
2953 this.footerEl.getHeight() +
2954 this.getChildHeight(this.bodyEl.dom.childNodes),
2955 Roo.lib.Dom.getViewportHeight(true) - 60)
2961 setSize : function(w,h)
2972 if (!this.rendered) {
2976 //this.el.setStyle('display', 'block');
2977 this.el.removeClass('hideing');
2978 this.el.dom.style.display='block';
2980 Roo.get(document.body).addClass('modal-open');
2982 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2985 this.el.addClass('show');
2986 this.el.addClass('in');
2989 this.el.addClass('show');
2990 this.el.addClass('in');
2993 // not sure how we can show data in here..
2995 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2998 Roo.get(document.body).addClass("x-body-masked");
3000 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3001 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3002 this.maskEl.dom.style.display = 'block';
3003 this.maskEl.addClass('show');
3008 this.fireEvent('show', this);
3010 // set zindex here - otherwise it appears to be ignored...
3011 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3014 this.items.forEach( function(e) {
3015 e.layout ? e.layout() : false;
3023 if(this.fireEvent("beforehide", this) !== false){
3025 this.maskEl.removeClass('show');
3027 this.maskEl.dom.style.display = '';
3028 Roo.get(document.body).removeClass("x-body-masked");
3029 this.el.removeClass('in');
3030 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3032 if(this.animate){ // why
3033 this.el.addClass('hideing');
3034 this.el.removeClass('show');
3036 if (!this.el.hasClass('hideing')) {
3037 return; // it's been shown again...
3040 this.el.dom.style.display='';
3042 Roo.get(document.body).removeClass('modal-open');
3043 this.el.removeClass('hideing');
3047 this.el.removeClass('show');
3048 this.el.dom.style.display='';
3049 Roo.get(document.body).removeClass('modal-open');
3052 this.fireEvent('hide', this);
3055 isVisible : function()
3058 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3062 addButton : function(str, cb)
3066 var b = Roo.apply({}, { html : str } );
3067 b.xns = b.xns || Roo.bootstrap;
3068 b.xtype = b.xtype || 'Button';
3069 if (typeof(b.listeners) == 'undefined') {
3070 b.listeners = { click : cb.createDelegate(this) };
3073 var btn = Roo.factory(b);
3075 btn.render(this.getButtonContainer());
3081 setDefaultButton : function(btn)
3083 //this.el.select('.modal-footer').()
3087 resizeTo: function(w,h)
3091 this.dialogEl.setWidth(w);
3092 if (this.diff === false) {
3093 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
3096 this.bodyEl.setHeight(h - this.diff);
3098 this.fireEvent('resize', this);
3101 setContentSize : function(w, h)
3105 onButtonClick: function(btn,e)
3108 this.fireEvent('btnclick', btn.name, e);
3111 * Set the title of the Dialog
3112 * @param {String} str new Title
3114 setTitle: function(str) {
3115 this.titleEl.dom.innerHTML = str;
3118 * Set the body of the Dialog
3119 * @param {String} str new Title
3121 setBody: function(str) {
3122 this.bodyEl.dom.innerHTML = str;
3125 * Set the body of the Dialog using the template
3126 * @param {Obj} data - apply this data to the template and replace the body contents.
3128 applyBody: function(obj)
3131 Roo.log("Error - using apply Body without a template");
3134 this.tmpl.overwrite(this.bodyEl, obj);
3137 getChildHeight : function(child_nodes)
3141 child_nodes.length == 0
3146 var child_height = 0;
3148 for(var i = 0; i < child_nodes.length; i++) {
3151 * for modal with tabs...
3152 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3154 var layout_childs = child_nodes[i].childNodes;
3156 for(var j = 0; j < layout_childs.length; j++) {
3158 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3160 var layout_body_childs = layout_childs[j].childNodes;
3162 for(var k = 0; k < layout_body_childs.length; k++) {
3164 if(layout_body_childs[k].classList.contains('navbar')) {
3165 child_height += layout_body_childs[k].offsetHeight;
3169 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3171 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3173 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3175 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3176 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3191 child_height += child_nodes[i].offsetHeight;
3192 // Roo.log(child_nodes[i].offsetHeight);
3195 return child_height;
3201 Roo.apply(Roo.bootstrap.Modal, {
3203 * Button config that displays a single OK button
3212 * Button config that displays Yes and No buttons
3228 * Button config that displays OK and Cancel buttons
3243 * Button config that displays Yes, No and Cancel buttons
3267 * messagebox - can be used as a replace
3271 * @class Roo.MessageBox
3272 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3276 Roo.Msg.alert('Status', 'Changes saved successfully.');
3278 // Prompt for user data:
3279 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3281 // process text value...
3285 // Show a dialog using config options:
3287 title:'Save Changes?',
3288 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3289 buttons: Roo.Msg.YESNOCANCEL,
3296 Roo.bootstrap.MessageBox = function(){
3297 var dlg, opt, mask, waitTimer;
3298 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3299 var buttons, activeTextEl, bwidth;
3303 var handleButton = function(button){
3305 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3309 var handleHide = function(){
3311 dlg.el.removeClass(opt.cls);
3314 // Roo.TaskMgr.stop(waitTimer);
3315 // waitTimer = null;
3320 var updateButtons = function(b){
3323 buttons["ok"].hide();
3324 buttons["cancel"].hide();
3325 buttons["yes"].hide();
3326 buttons["no"].hide();
3327 dlg.footerEl.hide();
3331 dlg.footerEl.show();
3332 for(var k in buttons){
3333 if(typeof buttons[k] != "function"){
3336 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3337 width += buttons[k].el.getWidth()+15;
3347 var handleEsc = function(d, k, e){
3348 if(opt && opt.closable !== false){
3358 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3359 * @return {Roo.BasicDialog} The BasicDialog element
3361 getDialog : function(){
3363 dlg = new Roo.bootstrap.Modal( {
3366 //constraintoviewport:false,
3368 //collapsible : false,
3373 //buttonAlign:"center",
3374 closeClick : function(){
3375 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3378 handleButton("cancel");
3383 dlg.on("hide", handleHide);
3385 //dlg.addKeyListener(27, handleEsc);
3387 this.buttons = buttons;
3388 var bt = this.buttonText;
3389 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3390 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3391 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3392 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3394 bodyEl = dlg.bodyEl.createChild({
3396 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3397 '<textarea class="roo-mb-textarea"></textarea>' +
3398 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3400 msgEl = bodyEl.dom.firstChild;
3401 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3402 textboxEl.enableDisplayMode();
3403 textboxEl.addKeyListener([10,13], function(){
3404 if(dlg.isVisible() && opt && opt.buttons){
3407 }else if(opt.buttons.yes){
3408 handleButton("yes");
3412 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3413 textareaEl.enableDisplayMode();
3414 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3415 progressEl.enableDisplayMode();
3417 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3418 var pf = progressEl.dom.firstChild;
3420 pp = Roo.get(pf.firstChild);
3421 pp.setHeight(pf.offsetHeight);
3429 * Updates the message box body text
3430 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3431 * the XHTML-compliant non-breaking space character '&#160;')
3432 * @return {Roo.MessageBox} This message box
3434 updateText : function(text)
3436 if(!dlg.isVisible() && !opt.width){
3437 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3438 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3440 msgEl.innerHTML = text || ' ';
3442 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3443 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3445 Math.min(opt.width || cw , this.maxWidth),
3446 Math.max(opt.minWidth || this.minWidth, bwidth)
3449 activeTextEl.setWidth(w);
3451 if(dlg.isVisible()){
3452 dlg.fixedcenter = false;
3454 // to big, make it scroll. = But as usual stupid IE does not support
3457 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3458 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3459 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3461 bodyEl.dom.style.height = '';
3462 bodyEl.dom.style.overflowY = '';
3465 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3467 bodyEl.dom.style.overflowX = '';
3470 dlg.setContentSize(w, bodyEl.getHeight());
3471 if(dlg.isVisible()){
3472 dlg.fixedcenter = true;
3478 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3479 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3480 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3481 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3482 * @return {Roo.MessageBox} This message box
3484 updateProgress : function(value, text){
3486 this.updateText(text);
3489 if (pp) { // weird bug on my firefox - for some reason this is not defined
3490 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3491 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3497 * Returns true if the message box is currently displayed
3498 * @return {Boolean} True if the message box is visible, else false
3500 isVisible : function(){
3501 return dlg && dlg.isVisible();
3505 * Hides the message box if it is displayed
3508 if(this.isVisible()){
3514 * Displays a new message box, or reinitializes an existing message box, based on the config options
3515 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3516 * The following config object properties are supported:
3518 Property Type Description
3519 ---------- --------------- ------------------------------------------------------------------------------------
3520 animEl String/Element An id or Element from which the message box should animate as it opens and
3521 closes (defaults to undefined)
3522 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3523 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3524 closable Boolean False to hide the top-right close button (defaults to true). Note that
3525 progress and wait dialogs will ignore this property and always hide the
3526 close button as they can only be closed programmatically.
3527 cls String A custom CSS class to apply to the message box element
3528 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3529 displayed (defaults to 75)
3530 fn Function A callback function to execute after closing the dialog. The arguments to the
3531 function will be btn (the name of the button that was clicked, if applicable,
3532 e.g. "ok"), and text (the value of the active text field, if applicable).
3533 Progress and wait dialogs will ignore this option since they do not respond to
3534 user actions and can only be closed programmatically, so any required function
3535 should be called by the same code after it closes the dialog.
3536 icon String A CSS class that provides a background image to be used as an icon for
3537 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3538 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3539 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3540 modal Boolean False to allow user interaction with the page while the message box is
3541 displayed (defaults to true)
3542 msg String A string that will replace the existing message box body text (defaults
3543 to the XHTML-compliant non-breaking space character ' ')
3544 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3545 progress Boolean True to display a progress bar (defaults to false)
3546 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3547 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3548 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3549 title String The title text
3550 value String The string value to set into the active textbox element if displayed
3551 wait Boolean True to display a progress bar (defaults to false)
3552 width Number The width of the dialog in pixels
3559 msg: 'Please enter your address:',
3561 buttons: Roo.MessageBox.OKCANCEL,
3564 animEl: 'addAddressBtn'
3567 * @param {Object} config Configuration options
3568 * @return {Roo.MessageBox} This message box
3570 show : function(options)
3573 // this causes nightmares if you show one dialog after another
3574 // especially on callbacks..
3576 if(this.isVisible()){
3579 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3580 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3581 Roo.log("New Dialog Message:" + options.msg )
3582 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3583 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3586 var d = this.getDialog();
3588 d.setTitle(opt.title || " ");
3589 d.closeEl.setDisplayed(opt.closable !== false);
3590 activeTextEl = textboxEl;
3591 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3596 textareaEl.setHeight(typeof opt.multiline == "number" ?
3597 opt.multiline : this.defaultTextHeight);
3598 activeTextEl = textareaEl;
3607 progressEl.setDisplayed(opt.progress === true);
3609 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3611 this.updateProgress(0);
3612 activeTextEl.dom.value = opt.value || "";
3614 dlg.setDefaultButton(activeTextEl);
3616 var bs = opt.buttons;
3620 }else if(bs && bs.yes){
3621 db = buttons["yes"];
3623 dlg.setDefaultButton(db);
3625 bwidth = updateButtons(opt.buttons);
3626 this.updateText(opt.msg);
3628 d.el.addClass(opt.cls);
3630 d.proxyDrag = opt.proxyDrag === true;
3631 d.modal = opt.modal !== false;
3632 d.mask = opt.modal !== false ? mask : false;
3634 // force it to the end of the z-index stack so it gets a cursor in FF
3635 document.body.appendChild(dlg.el.dom);
3636 d.animateTarget = null;
3637 d.show(options.animEl);
3643 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3644 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3645 * and closing the message box when the process is complete.
3646 * @param {String} title The title bar text
3647 * @param {String} msg The message box body text
3648 * @return {Roo.MessageBox} This message box
3650 progress : function(title, msg){
3657 minWidth: this.minProgressWidth,
3664 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3665 * If a callback function is passed it will be called after the user clicks the button, and the
3666 * id of the button that was clicked will be passed as the only parameter to the callback
3667 * (could also be the top-right close button).
3668 * @param {String} title The title bar text
3669 * @param {String} msg The message box body text
3670 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3671 * @param {Object} scope (optional) The scope of the callback function
3672 * @return {Roo.MessageBox} This message box
3674 alert : function(title, msg, fn, scope)
3689 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3690 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3691 * You are responsible for closing the message box when the process is complete.
3692 * @param {String} msg The message box body text
3693 * @param {String} title (optional) The title bar text
3694 * @return {Roo.MessageBox} This message box
3696 wait : function(msg, title){
3707 waitTimer = Roo.TaskMgr.start({
3709 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3717 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3718 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3719 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3720 * @param {String} title The title bar text
3721 * @param {String} msg The message box body text
3722 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3723 * @param {Object} scope (optional) The scope of the callback function
3724 * @return {Roo.MessageBox} This message box
3726 confirm : function(title, msg, fn, scope){
3730 buttons: this.YESNO,
3739 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3740 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3741 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3742 * (could also be the top-right close button) and the text that was entered will be passed as the two
3743 * parameters to the callback.
3744 * @param {String} title The title bar text
3745 * @param {String} msg The message box body text
3746 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3747 * @param {Object} scope (optional) The scope of the callback function
3748 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3749 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3750 * @return {Roo.MessageBox} This message box
3752 prompt : function(title, msg, fn, scope, multiline){
3756 buttons: this.OKCANCEL,
3761 multiline: multiline,
3768 * Button config that displays a single OK button
3773 * Button config that displays Yes and No buttons
3776 YESNO : {yes:true, no:true},
3778 * Button config that displays OK and Cancel buttons
3781 OKCANCEL : {ok:true, cancel:true},
3783 * Button config that displays Yes, No and Cancel buttons
3786 YESNOCANCEL : {yes:true, no:true, cancel:true},
3789 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3792 defaultTextHeight : 75,
3794 * The maximum width in pixels of the message box (defaults to 600)
3799 * The minimum width in pixels of the message box (defaults to 100)
3804 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3805 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3808 minProgressWidth : 250,
3810 * An object containing the default button text strings that can be overriden for localized language support.
3811 * Supported properties are: ok, cancel, yes and no.
3812 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3825 * Shorthand for {@link Roo.MessageBox}
3827 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3828 Roo.Msg = Roo.Msg || Roo.MessageBox;
3837 * @class Roo.bootstrap.Navbar
3838 * @extends Roo.bootstrap.Component
3839 * Bootstrap Navbar class
3842 * Create a new Navbar
3843 * @param {Object} config The config object
3847 Roo.bootstrap.Navbar = function(config){
3848 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3852 * @event beforetoggle
3853 * Fire before toggle the menu
3854 * @param {Roo.EventObject} e
3856 "beforetoggle" : true
3860 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3869 getAutoCreate : function(){
3872 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3876 initEvents :function ()
3878 //Roo.log(this.el.select('.navbar-toggle',true));
3879 this.el.select('.navbar-toggle',true).on('click', function() {
3880 if(this.fireEvent('beforetoggle', this) !== false){
3881 var ce = this.el.select('.navbar-collapse',true).first();
3882 ce.toggleClass('in'); // old...
3883 if (ce.hasClass('collapse')) {
3885 ce.removeClass('collapse');
3886 ce.addClass('show');
3887 var h = ce.getHeight();
3889 ce.removeClass('show');
3890 // at this point we should be able to see it..
3891 ce.addClass('collapsing');
3893 ce.setHeight(0); // resize it ...
3894 ce.on('transitionend', function() {
3895 Roo.log('done transition');
3896 ce.removeClass('collapsing');
3897 ce.addClass('show');
3898 ce.removeClass('collapse');
3900 ce.dom.style.height = '';
3901 }, this, { single: true} );
3905 ce.setHeight(ce.getHeight());
3906 ce.removeClass('show');
3907 ce.addClass('collapsing');
3909 ce.on('transitionend', function() {
3910 ce.dom.style.height = '';
3911 ce.removeClass('collapsing');
3912 ce.addClass('collapse');
3913 }, this, { single: true} );
3925 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3927 var size = this.el.getSize();
3928 this.maskEl.setSize(size.width, size.height);
3929 this.maskEl.enableDisplayMode("block");
3938 getChildContainer : function()
3940 if (this.el.select('.collapse').getCount()) {
3941 return this.el.select('.collapse',true).first();
3974 * @class Roo.bootstrap.NavSimplebar
3975 * @extends Roo.bootstrap.Navbar
3976 * Bootstrap Sidebar class
3978 * @cfg {Boolean} inverse is inverted color
3980 * @cfg {String} type (nav | pills | tabs)
3981 * @cfg {Boolean} arrangement stacked | justified
3982 * @cfg {String} align (left | right) alignment
3984 * @cfg {Boolean} main (true|false) main nav bar? default false
3985 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3987 * @cfg {String} tag (header|footer|nav|div) default is nav
3989 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
3993 * Create a new Sidebar
3994 * @param {Object} config The config object
3998 Roo.bootstrap.NavSimplebar = function(config){
3999 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4002 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4018 getAutoCreate : function(){
4022 tag : this.tag || 'div',
4023 cls : 'navbar navbar-expand-lg'
4025 if (['light','white'].indexOf(this.weight) > -1) {
4026 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4028 cfg.cls += ' bg-' + this.weight;
4031 cfg.cls += ' navbar-inverse';
4035 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4037 if (Roo.bootstrap.version == 4) {
4049 this.type = this.type || 'nav';
4050 if (['tabs','pills'].indexOf(this.type)!==-1) {
4051 cfg.cn[0].cls += ' nav-' + this.type
4055 if (this.type!=='nav') {
4056 Roo.log('nav type must be nav/tabs/pills')
4058 cfg.cn[0].cls += ' navbar-nav'
4064 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
4065 cfg.cn[0].cls += ' nav-' + this.arrangement;
4069 if (this.align === 'right') {
4070 cfg.cn[0].cls += ' navbar-right';
4095 * navbar-expand-md fixed-top
4099 * @class Roo.bootstrap.NavHeaderbar
4100 * @extends Roo.bootstrap.NavSimplebar
4101 * Bootstrap Sidebar class
4103 * @cfg {String} brand what is brand
4104 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4105 * @cfg {String} brand_href href of the brand
4106 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4107 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4108 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4109 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4112 * Create a new Sidebar
4113 * @param {Object} config The config object
4117 Roo.bootstrap.NavHeaderbar = function(config){
4118 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4122 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4129 desktopCenter : false,
4132 getAutoCreate : function(){
4135 tag: this.nav || 'nav',
4136 cls: 'navbar navbar-expand-md',
4142 if (this.desktopCenter) {
4143 cn.push({cls : 'container', cn : []});
4151 cls: 'navbar-toggle navbar-toggler',
4152 'data-toggle': 'collapse',
4157 html: 'Toggle navigation'
4161 cls: 'icon-bar navbar-toggler-icon'
4174 cn.push( Roo.bootstrap.version == 4 ? btn : {
4176 cls: 'navbar-header',
4185 cls: 'collapse navbar-collapse',
4189 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4191 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4192 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4194 // tag can override this..
4196 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4199 if (this.brand !== '') {
4200 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4201 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4203 href: this.brand_href ? this.brand_href : '#',
4204 cls: 'navbar-brand',
4212 cfg.cls += ' main-nav';
4220 getHeaderChildContainer : function()
4222 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4223 return this.el.select('.navbar-header',true).first();
4226 return this.getChildContainer();
4230 initEvents : function()
4232 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4234 if (this.autohide) {
4239 Roo.get(document).on('scroll',function(e) {
4240 var ns = Roo.get(document).getScroll().top;
4241 var os = prevScroll;
4245 ft.removeClass('slideDown');
4246 ft.addClass('slideUp');
4249 ft.removeClass('slideUp');
4250 ft.addClass('slideDown');
4271 * @class Roo.bootstrap.NavSidebar
4272 * @extends Roo.bootstrap.Navbar
4273 * Bootstrap Sidebar class
4276 * Create a new Sidebar
4277 * @param {Object} config The config object
4281 Roo.bootstrap.NavSidebar = function(config){
4282 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4285 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4287 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4289 getAutoCreate : function(){
4294 cls: 'sidebar sidebar-nav'
4316 * @class Roo.bootstrap.NavGroup
4317 * @extends Roo.bootstrap.Component
4318 * Bootstrap NavGroup class
4319 * @cfg {String} align (left|right)
4320 * @cfg {Boolean} inverse
4321 * @cfg {String} type (nav|pills|tab) default nav
4322 * @cfg {String} navId - reference Id for navbar.
4326 * Create a new nav group
4327 * @param {Object} config The config object
4330 Roo.bootstrap.NavGroup = function(config){
4331 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4334 Roo.bootstrap.NavGroup.register(this);
4338 * Fires when the active item changes
4339 * @param {Roo.bootstrap.NavGroup} this
4340 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4341 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4348 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4359 getAutoCreate : function()
4361 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4367 if (Roo.bootstrap.version == 4) {
4368 if (this.type == 'pills') {
4369 cfg.cls = ' nav-pills';
4372 if (['tabs','pills'].indexOf(this.type)!==-1) {
4373 cfg.cls += ' nav-' + this.type
4375 if (this.type !== 'nav') {
4376 Roo.log('nav type must be nav/tabs/pills')
4378 cfg.cls += ' navbar-nav'
4382 if (this.parent() && this.parent().sidebar) {
4385 cls: 'dashboard-menu sidebar-menu'
4391 if (this.form === true) {
4394 cls: 'navbar-form form-inline'
4397 if (this.align === 'right') {
4398 cfg.cls += ' navbar-right ml-md-auto';
4400 cfg.cls += ' navbar-left';
4404 if (this.align === 'right') {
4405 cfg.cls += ' navbar-right ml-md-auto';
4407 cfg.cls += ' mr-auto';
4411 cfg.cls += ' navbar-inverse';
4419 * sets the active Navigation item
4420 * @param {Roo.bootstrap.NavItem} the new current navitem
4422 setActiveItem : function(item)
4425 Roo.each(this.navItems, function(v){
4430 v.setActive(false, true);
4437 item.setActive(true, true);
4438 this.fireEvent('changed', this, item, prev);
4443 * gets the active Navigation item
4444 * @return {Roo.bootstrap.NavItem} the current navitem
4446 getActive : function()
4450 Roo.each(this.navItems, function(v){
4461 indexOfNav : function()
4465 Roo.each(this.navItems, function(v,i){
4476 * adds a Navigation item
4477 * @param {Roo.bootstrap.NavItem} the navitem to add
4479 addItem : function(cfg)
4481 if (this.form && Roo.bootstrap.version == 4) {
4484 var cn = new Roo.bootstrap.NavItem(cfg);
4486 cn.parentId = this.id;
4487 cn.onRender(this.el, null);
4491 * register a Navigation item
4492 * @param {Roo.bootstrap.NavItem} the navitem to add
4494 register : function(item)
4496 this.navItems.push( item);
4497 item.navId = this.navId;
4502 * clear all the Navigation item
4505 clearAll : function()
4508 this.el.dom.innerHTML = '';
4511 getNavItem: function(tabId)
4514 Roo.each(this.navItems, function(e) {
4515 if (e.tabId == tabId) {
4525 setActiveNext : function()
4527 var i = this.indexOfNav(this.getActive());
4528 if (i > this.navItems.length) {
4531 this.setActiveItem(this.navItems[i+1]);
4533 setActivePrev : function()
4535 var i = this.indexOfNav(this.getActive());
4539 this.setActiveItem(this.navItems[i-1]);
4541 clearWasActive : function(except) {
4542 Roo.each(this.navItems, function(e) {
4543 if (e.tabId != except.tabId && e.was_active) {
4544 e.was_active = false;
4551 getWasActive : function ()
4554 Roo.each(this.navItems, function(e) {
4569 Roo.apply(Roo.bootstrap.NavGroup, {
4573 * register a Navigation Group
4574 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4576 register : function(navgrp)
4578 this.groups[navgrp.navId] = navgrp;
4582 * fetch a Navigation Group based on the navigation ID
4583 * @param {string} the navgroup to add
4584 * @returns {Roo.bootstrap.NavGroup} the navgroup
4586 get: function(navId) {
4587 if (typeof(this.groups[navId]) == 'undefined') {
4589 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4591 return this.groups[navId] ;
4606 * @class Roo.bootstrap.NavItem
4607 * @extends Roo.bootstrap.Component
4608 * Bootstrap Navbar.NavItem class
4609 * @cfg {String} href link to
4610 * @cfg {String} html content of button
4611 * @cfg {String} badge text inside badge
4612 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4613 * @cfg {String} glyphicon DEPRICATED - use fa
4614 * @cfg {String} icon DEPRICATED - use fa
4615 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4616 * @cfg {Boolean} active Is item active
4617 * @cfg {Boolean} disabled Is item disabled
4619 * @cfg {Boolean} preventDefault (true | false) default false
4620 * @cfg {String} tabId the tab that this item activates.
4621 * @cfg {String} tagtype (a|span) render as a href or span?
4622 * @cfg {Boolean} animateRef (true|false) link to element default false
4625 * Create a new Navbar Item
4626 * @param {Object} config The config object
4628 Roo.bootstrap.NavItem = function(config){
4629 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4634 * The raw click event for the entire grid.
4635 * @param {Roo.EventObject} e
4640 * Fires when the active item active state changes
4641 * @param {Roo.bootstrap.NavItem} this
4642 * @param {boolean} state the new state
4648 * Fires when scroll to element
4649 * @param {Roo.bootstrap.NavItem} this
4650 * @param {Object} options
4651 * @param {Roo.EventObject} e
4659 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4668 preventDefault : false,
4676 getAutoCreate : function(){
4685 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4687 if (this.disabled) {
4688 cfg.cls += ' disabled';
4691 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4695 href : this.href || "#",
4696 html: this.html || ''
4699 if (this.tagtype == 'a') {
4700 cfg.cn[0].cls = 'nav-link';
4703 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4706 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>'
4708 if(this.glyphicon) {
4709 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4714 cfg.cn[0].html += " <span class='caret'></span>";
4718 if (this.badge !== '') {
4720 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4728 onRender : function(ct, position)
4730 // Roo.log("Call onRender: " + this.xtype);
4731 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4735 return Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4739 initEvents: function()
4741 if (typeof (this.menu) != 'undefined') {
4742 this.menu.parentType = this.xtype;
4743 this.menu.triggerEl = this.el;
4744 this.menu = this.addxtype(Roo.apply({}, this.menu));
4747 this.el.select('a',true).on('click', this.onClick, this);
4749 if(this.tagtype == 'span'){
4750 this.el.select('span',true).on('click', this.onClick, this);
4753 // at this point parent should be available..
4754 this.parent().register(this);
4757 onClick : function(e)
4759 if (e.getTarget('.dropdown-menu-item')) {
4760 // did you click on a menu itemm.... - then don't trigger onclick..
4765 this.preventDefault ||
4768 Roo.log("NavItem - prevent Default?");
4772 if (this.disabled) {
4776 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4777 if (tg && tg.transition) {
4778 Roo.log("waiting for the transitionend");
4784 //Roo.log("fire event clicked");
4785 if(this.fireEvent('click', this, e) === false){
4789 if(this.tagtype == 'span'){
4793 //Roo.log(this.href);
4794 var ael = this.el.select('a',true).first();
4797 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4798 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4799 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4800 return; // ignore... - it's a 'hash' to another page.
4802 Roo.log("NavItem - prevent Default?");
4804 this.scrollToElement(e);
4808 var p = this.parent();
4810 if (['tabs','pills'].indexOf(p.type)!==-1) {
4811 if (typeof(p.setActiveItem) !== 'undefined') {
4812 p.setActiveItem(this);
4816 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4817 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4818 // remove the collapsed menu expand...
4819 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4823 isActive: function () {
4826 setActive : function(state, fire, is_was_active)
4828 if (this.active && !state && this.navId) {
4829 this.was_active = true;
4830 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4832 nv.clearWasActive(this);
4836 this.active = state;
4839 this.el.removeClass('active');
4840 } else if (!this.el.hasClass('active')) {
4841 this.el.addClass('active');
4844 this.fireEvent('changed', this, state);
4847 // show a panel if it's registered and related..
4849 if (!this.navId || !this.tabId || !state || is_was_active) {
4853 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4857 var pan = tg.getPanelByName(this.tabId);
4861 // if we can not flip to new panel - go back to old nav highlight..
4862 if (false == tg.showPanel(pan)) {
4863 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4865 var onav = nv.getWasActive();
4867 onav.setActive(true, false, true);
4876 // this should not be here...
4877 setDisabled : function(state)
4879 this.disabled = state;
4881 this.el.removeClass('disabled');
4882 } else if (!this.el.hasClass('disabled')) {
4883 this.el.addClass('disabled');
4889 * Fetch the element to display the tooltip on.
4890 * @return {Roo.Element} defaults to this.el
4892 tooltipEl : function()
4894 return this.el.select('' + this.tagtype + '', true).first();
4897 scrollToElement : function(e)
4899 var c = document.body;
4902 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4904 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4905 c = document.documentElement;
4908 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4914 var o = target.calcOffsetsTo(c);
4921 this.fireEvent('scrollto', this, options, e);
4923 Roo.get(c).scrollTo('top', options.value, true);
4936 * <span> icon </span>
4937 * <span> text </span>
4938 * <span>badge </span>
4942 * @class Roo.bootstrap.NavSidebarItem
4943 * @extends Roo.bootstrap.NavItem
4944 * Bootstrap Navbar.NavSidebarItem class
4945 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4946 * {Boolean} open is the menu open
4947 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4948 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4949 * {String} buttonSize (sm|md|lg)the extra classes for the button
4950 * {Boolean} showArrow show arrow next to the text (default true)
4952 * Create a new Navbar Button
4953 * @param {Object} config The config object
4955 Roo.bootstrap.NavSidebarItem = function(config){
4956 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4961 * The raw click event for the entire grid.
4962 * @param {Roo.EventObject} e
4967 * Fires when the active item active state changes
4968 * @param {Roo.bootstrap.NavSidebarItem} this
4969 * @param {boolean} state the new state
4977 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4979 badgeWeight : 'default',
4985 buttonWeight : 'default',
4991 getAutoCreate : function(){
4996 href : this.href || '#',
5002 if(this.buttonView){
5005 href : this.href || '#',
5006 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5019 cfg.cls += ' active';
5022 if (this.disabled) {
5023 cfg.cls += ' disabled';
5026 cfg.cls += ' open x-open';
5029 if (this.glyphicon || this.icon) {
5030 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5031 a.cn.push({ tag : 'i', cls : c }) ;
5034 if(!this.buttonView){
5037 html : this.html || ''
5044 if (this.badge !== '') {
5045 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5051 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5054 a.cls += ' dropdown-toggle treeview' ;
5060 initEvents : function()
5062 if (typeof (this.menu) != 'undefined') {
5063 this.menu.parentType = this.xtype;
5064 this.menu.triggerEl = this.el;
5065 this.menu = this.addxtype(Roo.apply({}, this.menu));
5068 this.el.on('click', this.onClick, this);
5070 if(this.badge !== ''){
5071 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5076 onClick : function(e)
5083 if(this.preventDefault){
5087 this.fireEvent('click', this);
5090 disable : function()
5092 this.setDisabled(true);
5097 this.setDisabled(false);
5100 setDisabled : function(state)
5102 if(this.disabled == state){
5106 this.disabled = state;
5109 this.el.addClass('disabled');
5113 this.el.removeClass('disabled');
5118 setActive : function(state)
5120 if(this.active == state){
5124 this.active = state;
5127 this.el.addClass('active');
5131 this.el.removeClass('active');
5136 isActive: function ()
5141 setBadge : function(str)
5147 this.badgeEl.dom.innerHTML = str;
5164 * @class Roo.bootstrap.Row
5165 * @extends Roo.bootstrap.Component
5166 * Bootstrap Row class (contains columns...)
5170 * @param {Object} config The config object
5173 Roo.bootstrap.Row = function(config){
5174 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5177 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5179 getAutoCreate : function(){
5198 * @class Roo.bootstrap.Element
5199 * @extends Roo.bootstrap.Component
5200 * Bootstrap Element class
5201 * @cfg {String} html contents of the element
5202 * @cfg {String} tag tag of the element
5203 * @cfg {String} cls class of the element
5204 * @cfg {Boolean} preventDefault (true|false) default false
5205 * @cfg {Boolean} clickable (true|false) default false
5208 * Create a new Element
5209 * @param {Object} config The config object
5212 Roo.bootstrap.Element = function(config){
5213 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5219 * When a element is chick
5220 * @param {Roo.bootstrap.Element} this
5221 * @param {Roo.EventObject} e
5227 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5232 preventDefault: false,
5235 getAutoCreate : function(){
5239 // cls: this.cls, double assign in parent class Component.js :: onRender
5246 initEvents: function()
5248 Roo.bootstrap.Element.superclass.initEvents.call(this);
5251 this.el.on('click', this.onClick, this);
5256 onClick : function(e)
5258 if(this.preventDefault){
5262 this.fireEvent('click', this, e);
5265 getValue : function()
5267 return this.el.dom.innerHTML;
5270 setValue : function(value)
5272 this.el.dom.innerHTML = value;
5287 * @class Roo.bootstrap.Pagination
5288 * @extends Roo.bootstrap.Component
5289 * Bootstrap Pagination class
5290 * @cfg {String} size xs | sm | md | lg
5291 * @cfg {Boolean} inverse false | true
5294 * Create a new Pagination
5295 * @param {Object} config The config object
5298 Roo.bootstrap.Pagination = function(config){
5299 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5302 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5308 getAutoCreate : function(){
5314 cfg.cls += ' inverse';
5320 cfg.cls += " " + this.cls;
5338 * @class Roo.bootstrap.PaginationItem
5339 * @extends Roo.bootstrap.Component
5340 * Bootstrap PaginationItem class
5341 * @cfg {String} html text
5342 * @cfg {String} href the link
5343 * @cfg {Boolean} preventDefault (true | false) default true
5344 * @cfg {Boolean} active (true | false) default false
5345 * @cfg {Boolean} disabled default false
5349 * Create a new PaginationItem
5350 * @param {Object} config The config object
5354 Roo.bootstrap.PaginationItem = function(config){
5355 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5360 * The raw click event for the entire grid.
5361 * @param {Roo.EventObject} e
5367 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5371 preventDefault: true,
5376 getAutoCreate : function(){
5382 href : this.href ? this.href : '#',
5383 html : this.html ? this.html : ''
5393 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5397 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5403 initEvents: function() {
5405 this.el.on('click', this.onClick, this);
5408 onClick : function(e)
5410 Roo.log('PaginationItem on click ');
5411 if(this.preventDefault){
5419 this.fireEvent('click', this, e);
5435 * @class Roo.bootstrap.Slider
5436 * @extends Roo.bootstrap.Component
5437 * Bootstrap Slider class
5440 * Create a new Slider
5441 * @param {Object} config The config object
5444 Roo.bootstrap.Slider = function(config){
5445 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5448 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5450 getAutoCreate : function(){
5454 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5458 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5470 * Ext JS Library 1.1.1
5471 * Copyright(c) 2006-2007, Ext JS, LLC.
5473 * Originally Released Under LGPL - original licence link has changed is not relivant.
5476 * <script type="text/javascript">
5481 * @class Roo.grid.ColumnModel
5482 * @extends Roo.util.Observable
5483 * This is the default implementation of a ColumnModel used by the Grid. It defines
5484 * the columns in the grid.
5487 var colModel = new Roo.grid.ColumnModel([
5488 {header: "Ticker", width: 60, sortable: true, locked: true},
5489 {header: "Company Name", width: 150, sortable: true},
5490 {header: "Market Cap.", width: 100, sortable: true},
5491 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5492 {header: "Employees", width: 100, sortable: true, resizable: false}
5497 * The config options listed for this class are options which may appear in each
5498 * individual column definition.
5499 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5501 * @param {Object} config An Array of column config objects. See this class's
5502 * config objects for details.
5504 Roo.grid.ColumnModel = function(config){
5506 * The config passed into the constructor
5508 this.config = config;
5511 // if no id, create one
5512 // if the column does not have a dataIndex mapping,
5513 // map it to the order it is in the config
5514 for(var i = 0, len = config.length; i < len; i++){
5516 if(typeof c.dataIndex == "undefined"){
5519 if(typeof c.renderer == "string"){
5520 c.renderer = Roo.util.Format[c.renderer];
5522 if(typeof c.id == "undefined"){
5525 if(c.editor && c.editor.xtype){
5526 c.editor = Roo.factory(c.editor, Roo.grid);
5528 if(c.editor && c.editor.isFormField){
5529 c.editor = new Roo.grid.GridEditor(c.editor);
5531 this.lookup[c.id] = c;
5535 * The width of columns which have no width specified (defaults to 100)
5538 this.defaultWidth = 100;
5541 * Default sortable of columns which have no sortable specified (defaults to false)
5544 this.defaultSortable = false;
5548 * @event widthchange
5549 * Fires when the width of a column changes.
5550 * @param {ColumnModel} this
5551 * @param {Number} columnIndex The column index
5552 * @param {Number} newWidth The new width
5554 "widthchange": true,
5556 * @event headerchange
5557 * Fires when the text of a header changes.
5558 * @param {ColumnModel} this
5559 * @param {Number} columnIndex The column index
5560 * @param {Number} newText The new header text
5562 "headerchange": true,
5564 * @event hiddenchange
5565 * Fires when a column is hidden or "unhidden".
5566 * @param {ColumnModel} this
5567 * @param {Number} columnIndex The column index
5568 * @param {Boolean} hidden true if hidden, false otherwise
5570 "hiddenchange": true,
5572 * @event columnmoved
5573 * Fires when a column is moved.
5574 * @param {ColumnModel} this
5575 * @param {Number} oldIndex
5576 * @param {Number} newIndex
5578 "columnmoved" : true,
5580 * @event columlockchange
5581 * Fires when a column's locked state is changed
5582 * @param {ColumnModel} this
5583 * @param {Number} colIndex
5584 * @param {Boolean} locked true if locked
5586 "columnlockchange" : true
5588 Roo.grid.ColumnModel.superclass.constructor.call(this);
5590 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5592 * @cfg {String} header The header text to display in the Grid view.
5595 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5596 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5597 * specified, the column's index is used as an index into the Record's data Array.
5600 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5601 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5604 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5605 * Defaults to the value of the {@link #defaultSortable} property.
5606 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5609 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5612 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5615 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5618 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5621 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5622 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5623 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5624 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5627 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5630 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5633 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5636 * @cfg {String} cursor (Optional)
5639 * @cfg {String} tooltip (Optional)
5642 * @cfg {Number} xs (Optional)
5645 * @cfg {Number} sm (Optional)
5648 * @cfg {Number} md (Optional)
5651 * @cfg {Number} lg (Optional)
5654 * Returns the id of the column at the specified index.
5655 * @param {Number} index The column index
5656 * @return {String} the id
5658 getColumnId : function(index){
5659 return this.config[index].id;
5663 * Returns the column for a specified id.
5664 * @param {String} id The column id
5665 * @return {Object} the column
5667 getColumnById : function(id){
5668 return this.lookup[id];
5673 * Returns the column for a specified dataIndex.
5674 * @param {String} dataIndex The column dataIndex
5675 * @return {Object|Boolean} the column or false if not found
5677 getColumnByDataIndex: function(dataIndex){
5678 var index = this.findColumnIndex(dataIndex);
5679 return index > -1 ? this.config[index] : false;
5683 * Returns the index for a specified column id.
5684 * @param {String} id The column id
5685 * @return {Number} the index, or -1 if not found
5687 getIndexById : function(id){
5688 for(var i = 0, len = this.config.length; i < len; i++){
5689 if(this.config[i].id == id){
5697 * Returns the index for a specified column dataIndex.
5698 * @param {String} dataIndex The column dataIndex
5699 * @return {Number} the index, or -1 if not found
5702 findColumnIndex : function(dataIndex){
5703 for(var i = 0, len = this.config.length; i < len; i++){
5704 if(this.config[i].dataIndex == dataIndex){
5712 moveColumn : function(oldIndex, newIndex){
5713 var c = this.config[oldIndex];
5714 this.config.splice(oldIndex, 1);
5715 this.config.splice(newIndex, 0, c);
5716 this.dataMap = null;
5717 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5720 isLocked : function(colIndex){
5721 return this.config[colIndex].locked === true;
5724 setLocked : function(colIndex, value, suppressEvent){
5725 if(this.isLocked(colIndex) == value){
5728 this.config[colIndex].locked = value;
5730 this.fireEvent("columnlockchange", this, colIndex, value);
5734 getTotalLockedWidth : function(){
5736 for(var i = 0; i < this.config.length; i++){
5737 if(this.isLocked(i) && !this.isHidden(i)){
5738 this.totalWidth += this.getColumnWidth(i);
5744 getLockedCount : function(){
5745 for(var i = 0, len = this.config.length; i < len; i++){
5746 if(!this.isLocked(i)){
5751 return this.config.length;
5755 * Returns the number of columns.
5758 getColumnCount : function(visibleOnly){
5759 if(visibleOnly === true){
5761 for(var i = 0, len = this.config.length; i < len; i++){
5762 if(!this.isHidden(i)){
5768 return this.config.length;
5772 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5773 * @param {Function} fn
5774 * @param {Object} scope (optional)
5775 * @return {Array} result
5777 getColumnsBy : function(fn, scope){
5779 for(var i = 0, len = this.config.length; i < len; i++){
5780 var c = this.config[i];
5781 if(fn.call(scope||this, c, i) === true){
5789 * Returns true if the specified column is sortable.
5790 * @param {Number} col The column index
5793 isSortable : function(col){
5794 if(typeof this.config[col].sortable == "undefined"){
5795 return this.defaultSortable;
5797 return this.config[col].sortable;
5801 * Returns the rendering (formatting) function defined for the column.
5802 * @param {Number} col The column index.
5803 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5805 getRenderer : function(col){
5806 if(!this.config[col].renderer){
5807 return Roo.grid.ColumnModel.defaultRenderer;
5809 return this.config[col].renderer;
5813 * Sets the rendering (formatting) function for a column.
5814 * @param {Number} col The column index
5815 * @param {Function} fn The function to use to process the cell's raw data
5816 * to return HTML markup for the grid view. The render function is called with
5817 * the following parameters:<ul>
5818 * <li>Data value.</li>
5819 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5820 * <li>css A CSS style string to apply to the table cell.</li>
5821 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5822 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5823 * <li>Row index</li>
5824 * <li>Column index</li>
5825 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5827 setRenderer : function(col, fn){
5828 this.config[col].renderer = fn;
5832 * Returns the width for the specified column.
5833 * @param {Number} col The column index
5836 getColumnWidth : function(col){
5837 return this.config[col].width * 1 || this.defaultWidth;
5841 * Sets the width for a column.
5842 * @param {Number} col The column index
5843 * @param {Number} width The new width
5845 setColumnWidth : function(col, width, suppressEvent){
5846 this.config[col].width = width;
5847 this.totalWidth = null;
5849 this.fireEvent("widthchange", this, col, width);
5854 * Returns the total width of all columns.
5855 * @param {Boolean} includeHidden True to include hidden column widths
5858 getTotalWidth : function(includeHidden){
5859 if(!this.totalWidth){
5860 this.totalWidth = 0;
5861 for(var i = 0, len = this.config.length; i < len; i++){
5862 if(includeHidden || !this.isHidden(i)){
5863 this.totalWidth += this.getColumnWidth(i);
5867 return this.totalWidth;
5871 * Returns the header for the specified column.
5872 * @param {Number} col The column index
5875 getColumnHeader : function(col){
5876 return this.config[col].header;
5880 * Sets the header for a column.
5881 * @param {Number} col The column index
5882 * @param {String} header The new header
5884 setColumnHeader : function(col, header){
5885 this.config[col].header = header;
5886 this.fireEvent("headerchange", this, col, header);
5890 * Returns the tooltip for the specified column.
5891 * @param {Number} col The column index
5894 getColumnTooltip : function(col){
5895 return this.config[col].tooltip;
5898 * Sets the tooltip for a column.
5899 * @param {Number} col The column index
5900 * @param {String} tooltip The new tooltip
5902 setColumnTooltip : function(col, tooltip){
5903 this.config[col].tooltip = tooltip;
5907 * Returns the dataIndex for the specified column.
5908 * @param {Number} col The column index
5911 getDataIndex : function(col){
5912 return this.config[col].dataIndex;
5916 * Sets the dataIndex for a column.
5917 * @param {Number} col The column index
5918 * @param {Number} dataIndex The new dataIndex
5920 setDataIndex : function(col, dataIndex){
5921 this.config[col].dataIndex = dataIndex;
5927 * Returns true if the cell is editable.
5928 * @param {Number} colIndex The column index
5929 * @param {Number} rowIndex The row index - this is nto actually used..?
5932 isCellEditable : function(colIndex, rowIndex){
5933 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5937 * Returns the editor defined for the cell/column.
5938 * return false or null to disable editing.
5939 * @param {Number} colIndex The column index
5940 * @param {Number} rowIndex The row index
5943 getCellEditor : function(colIndex, rowIndex){
5944 return this.config[colIndex].editor;
5948 * Sets if a column is editable.
5949 * @param {Number} col The column index
5950 * @param {Boolean} editable True if the column is editable
5952 setEditable : function(col, editable){
5953 this.config[col].editable = editable;
5958 * Returns true if the column is hidden.
5959 * @param {Number} colIndex The column index
5962 isHidden : function(colIndex){
5963 return this.config[colIndex].hidden;
5968 * Returns true if the column width cannot be changed
5970 isFixed : function(colIndex){
5971 return this.config[colIndex].fixed;
5975 * Returns true if the column can be resized
5978 isResizable : function(colIndex){
5979 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5982 * Sets if a column is hidden.
5983 * @param {Number} colIndex The column index
5984 * @param {Boolean} hidden True if the column is hidden
5986 setHidden : function(colIndex, hidden){
5987 this.config[colIndex].hidden = hidden;
5988 this.totalWidth = null;
5989 this.fireEvent("hiddenchange", this, colIndex, hidden);
5993 * Sets the editor for a column.
5994 * @param {Number} col The column index
5995 * @param {Object} editor The editor object
5997 setEditor : function(col, editor){
5998 this.config[col].editor = editor;
6002 Roo.grid.ColumnModel.defaultRenderer = function(value)
6004 if(typeof value == "object") {
6007 if(typeof value == "string" && value.length < 1){
6011 return String.format("{0}", value);
6014 // Alias for backwards compatibility
6015 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6018 * Ext JS Library 1.1.1
6019 * Copyright(c) 2006-2007, Ext JS, LLC.
6021 * Originally Released Under LGPL - original licence link has changed is not relivant.
6024 * <script type="text/javascript">
6028 * @class Roo.LoadMask
6029 * A simple utility class for generically masking elements while loading data. If the element being masked has
6030 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6031 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6032 * element's UpdateManager load indicator and will be destroyed after the initial load.
6034 * Create a new LoadMask
6035 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6036 * @param {Object} config The config object
6038 Roo.LoadMask = function(el, config){
6039 this.el = Roo.get(el);
6040 Roo.apply(this, config);
6042 this.store.on('beforeload', this.onBeforeLoad, this);
6043 this.store.on('load', this.onLoad, this);
6044 this.store.on('loadexception', this.onLoadException, this);
6045 this.removeMask = false;
6047 var um = this.el.getUpdateManager();
6048 um.showLoadIndicator = false; // disable the default indicator
6049 um.on('beforeupdate', this.onBeforeLoad, this);
6050 um.on('update', this.onLoad, this);
6051 um.on('failure', this.onLoad, this);
6052 this.removeMask = true;
6056 Roo.LoadMask.prototype = {
6058 * @cfg {Boolean} removeMask
6059 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6060 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6064 * The text to display in a centered loading message box (defaults to 'Loading...')
6068 * @cfg {String} msgCls
6069 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6071 msgCls : 'x-mask-loading',
6074 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6080 * Disables the mask to prevent it from being displayed
6082 disable : function(){
6083 this.disabled = true;
6087 * Enables the mask so that it can be displayed
6089 enable : function(){
6090 this.disabled = false;
6093 onLoadException : function()
6097 if (typeof(arguments[3]) != 'undefined') {
6098 Roo.MessageBox.alert("Error loading",arguments[3]);
6102 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6103 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6110 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6115 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6119 onBeforeLoad : function(){
6121 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6126 destroy : function(){
6128 this.store.un('beforeload', this.onBeforeLoad, this);
6129 this.store.un('load', this.onLoad, this);
6130 this.store.un('loadexception', this.onLoadException, this);
6132 var um = this.el.getUpdateManager();
6133 um.un('beforeupdate', this.onBeforeLoad, this);
6134 um.un('update', this.onLoad, this);
6135 um.un('failure', this.onLoad, this);
6146 * @class Roo.bootstrap.Table
6147 * @extends Roo.bootstrap.Component
6148 * Bootstrap Table class
6149 * @cfg {String} cls table class
6150 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6151 * @cfg {String} bgcolor Specifies the background color for a table
6152 * @cfg {Number} border Specifies whether the table cells should have borders or not
6153 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6154 * @cfg {Number} cellspacing Specifies the space between cells
6155 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6156 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6157 * @cfg {String} sortable Specifies that the table should be sortable
6158 * @cfg {String} summary Specifies a summary of the content of a table
6159 * @cfg {Number} width Specifies the width of a table
6160 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6162 * @cfg {boolean} striped Should the rows be alternative striped
6163 * @cfg {boolean} bordered Add borders to the table
6164 * @cfg {boolean} hover Add hover highlighting
6165 * @cfg {boolean} condensed Format condensed
6166 * @cfg {boolean} responsive Format condensed
6167 * @cfg {Boolean} loadMask (true|false) default false
6168 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6169 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6170 * @cfg {Boolean} rowSelection (true|false) default false
6171 * @cfg {Boolean} cellSelection (true|false) default false
6172 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6173 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6174 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6175 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6179 * Create a new Table
6180 * @param {Object} config The config object
6183 Roo.bootstrap.Table = function(config){
6184 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6189 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6190 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6191 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6192 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6194 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6196 this.sm.grid = this;
6197 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6198 this.sm = this.selModel;
6199 this.sm.xmodule = this.xmodule || false;
6202 if (this.cm && typeof(this.cm.config) == 'undefined') {
6203 this.colModel = new Roo.grid.ColumnModel(this.cm);
6204 this.cm = this.colModel;
6205 this.cm.xmodule = this.xmodule || false;
6208 this.store= Roo.factory(this.store, Roo.data);
6209 this.ds = this.store;
6210 this.ds.xmodule = this.xmodule || false;
6213 if (this.footer && this.store) {
6214 this.footer.dataSource = this.ds;
6215 this.footer = Roo.factory(this.footer);
6222 * Fires when a cell is clicked
6223 * @param {Roo.bootstrap.Table} this
6224 * @param {Roo.Element} el
6225 * @param {Number} rowIndex
6226 * @param {Number} columnIndex
6227 * @param {Roo.EventObject} e
6231 * @event celldblclick
6232 * Fires when a cell is double clicked
6233 * @param {Roo.bootstrap.Table} this
6234 * @param {Roo.Element} el
6235 * @param {Number} rowIndex
6236 * @param {Number} columnIndex
6237 * @param {Roo.EventObject} e
6239 "celldblclick" : true,
6242 * Fires when a row is clicked
6243 * @param {Roo.bootstrap.Table} this
6244 * @param {Roo.Element} el
6245 * @param {Number} rowIndex
6246 * @param {Roo.EventObject} e
6250 * @event rowdblclick
6251 * Fires when a row is double clicked
6252 * @param {Roo.bootstrap.Table} this
6253 * @param {Roo.Element} el
6254 * @param {Number} rowIndex
6255 * @param {Roo.EventObject} e
6257 "rowdblclick" : true,
6260 * Fires when a mouseover occur
6261 * @param {Roo.bootstrap.Table} this
6262 * @param {Roo.Element} el
6263 * @param {Number} rowIndex
6264 * @param {Number} columnIndex
6265 * @param {Roo.EventObject} e
6270 * Fires when a mouseout occur
6271 * @param {Roo.bootstrap.Table} this
6272 * @param {Roo.Element} el
6273 * @param {Number} rowIndex
6274 * @param {Number} columnIndex
6275 * @param {Roo.EventObject} e
6280 * Fires when a row is rendered, so you can change add a style to it.
6281 * @param {Roo.bootstrap.Table} this
6282 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6286 * @event rowsrendered
6287 * Fires when all the rows have been rendered
6288 * @param {Roo.bootstrap.Table} this
6290 'rowsrendered' : true,
6292 * @event contextmenu
6293 * The raw contextmenu event for the entire grid.
6294 * @param {Roo.EventObject} e
6296 "contextmenu" : true,
6298 * @event rowcontextmenu
6299 * Fires when a row is right clicked
6300 * @param {Roo.bootstrap.Table} this
6301 * @param {Number} rowIndex
6302 * @param {Roo.EventObject} e
6304 "rowcontextmenu" : true,
6306 * @event cellcontextmenu
6307 * Fires when a cell is right clicked
6308 * @param {Roo.bootstrap.Table} this
6309 * @param {Number} rowIndex
6310 * @param {Number} cellIndex
6311 * @param {Roo.EventObject} e
6313 "cellcontextmenu" : true,
6315 * @event headercontextmenu
6316 * Fires when a header is right clicked
6317 * @param {Roo.bootstrap.Table} this
6318 * @param {Number} columnIndex
6319 * @param {Roo.EventObject} e
6321 "headercontextmenu" : true
6325 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6351 rowSelection : false,
6352 cellSelection : false,
6355 // Roo.Element - the tbody
6357 // Roo.Element - thead element
6360 container: false, // used by gridpanel...
6366 auto_hide_footer : false,
6368 getAutoCreate : function()
6370 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6377 if (this.scrollBody) {
6378 cfg.cls += ' table-body-fixed';
6381 cfg.cls += ' table-striped';
6385 cfg.cls += ' table-hover';
6387 if (this.bordered) {
6388 cfg.cls += ' table-bordered';
6390 if (this.condensed) {
6391 cfg.cls += ' table-condensed';
6393 if (this.responsive) {
6394 cfg.cls += ' table-responsive';
6398 cfg.cls+= ' ' +this.cls;
6401 // this lot should be simplifed...
6414 ].forEach(function(k) {
6422 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6425 if(this.store || this.cm){
6426 if(this.headerShow){
6427 cfg.cn.push(this.renderHeader());
6430 cfg.cn.push(this.renderBody());
6432 if(this.footerShow){
6433 cfg.cn.push(this.renderFooter());
6435 // where does this come from?
6436 //cfg.cls+= ' TableGrid';
6439 return { cn : [ cfg ] };
6442 initEvents : function()
6444 if(!this.store || !this.cm){
6447 if (this.selModel) {
6448 this.selModel.initEvents();
6452 //Roo.log('initEvents with ds!!!!');
6454 this.mainBody = this.el.select('tbody', true).first();
6455 this.mainHead = this.el.select('thead', true).first();
6456 this.mainFoot = this.el.select('tfoot', true).first();
6462 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6463 e.on('click', _this.sort, _this);
6466 this.mainBody.on("click", this.onClick, this);
6467 this.mainBody.on("dblclick", this.onDblClick, this);
6469 // why is this done????? = it breaks dialogs??
6470 //this.parent().el.setStyle('position', 'relative');
6474 this.footer.parentId = this.id;
6475 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6478 this.el.select('tfoot tr td').first().addClass('hide');
6483 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6486 this.store.on('load', this.onLoad, this);
6487 this.store.on('beforeload', this.onBeforeLoad, this);
6488 this.store.on('update', this.onUpdate, this);
6489 this.store.on('add', this.onAdd, this);
6490 this.store.on("clear", this.clear, this);
6492 this.el.on("contextmenu", this.onContextMenu, this);
6494 this.mainBody.on('scroll', this.onBodyScroll, this);
6496 this.cm.on("headerchange", this.onHeaderChange, this);
6498 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6502 onContextMenu : function(e, t)
6504 this.processEvent("contextmenu", e);
6507 processEvent : function(name, e)
6509 if (name != 'touchstart' ) {
6510 this.fireEvent(name, e);
6513 var t = e.getTarget();
6515 var cell = Roo.get(t);
6521 if(cell.findParent('tfoot', false, true)){
6525 if(cell.findParent('thead', false, true)){
6527 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6528 cell = Roo.get(t).findParent('th', false, true);
6530 Roo.log("failed to find th in thead?");
6531 Roo.log(e.getTarget());
6536 var cellIndex = cell.dom.cellIndex;
6538 var ename = name == 'touchstart' ? 'click' : name;
6539 this.fireEvent("header" + ename, this, cellIndex, e);
6544 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6545 cell = Roo.get(t).findParent('td', false, true);
6547 Roo.log("failed to find th in tbody?");
6548 Roo.log(e.getTarget());
6553 var row = cell.findParent('tr', false, true);
6554 var cellIndex = cell.dom.cellIndex;
6555 var rowIndex = row.dom.rowIndex - 1;
6559 this.fireEvent("row" + name, this, rowIndex, e);
6563 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6569 onMouseover : function(e, el)
6571 var cell = Roo.get(el);
6577 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6578 cell = cell.findParent('td', false, true);
6581 var row = cell.findParent('tr', false, true);
6582 var cellIndex = cell.dom.cellIndex;
6583 var rowIndex = row.dom.rowIndex - 1; // start from 0
6585 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6589 onMouseout : function(e, el)
6591 var cell = Roo.get(el);
6597 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6598 cell = cell.findParent('td', false, true);
6601 var row = cell.findParent('tr', false, true);
6602 var cellIndex = cell.dom.cellIndex;
6603 var rowIndex = row.dom.rowIndex - 1; // start from 0
6605 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6609 onClick : function(e, el)
6611 var cell = Roo.get(el);
6613 if(!cell || (!this.cellSelection && !this.rowSelection)){
6617 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6618 cell = cell.findParent('td', false, true);
6621 if(!cell || typeof(cell) == 'undefined'){
6625 var row = cell.findParent('tr', false, true);
6627 if(!row || typeof(row) == 'undefined'){
6631 var cellIndex = cell.dom.cellIndex;
6632 var rowIndex = this.getRowIndex(row);
6634 // why??? - should these not be based on SelectionModel?
6635 if(this.cellSelection){
6636 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6639 if(this.rowSelection){
6640 this.fireEvent('rowclick', this, row, rowIndex, e);
6646 onDblClick : function(e,el)
6648 var cell = Roo.get(el);
6650 if(!cell || (!this.cellSelection && !this.rowSelection)){
6654 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6655 cell = cell.findParent('td', false, true);
6658 if(!cell || typeof(cell) == 'undefined'){
6662 var row = cell.findParent('tr', false, true);
6664 if(!row || typeof(row) == 'undefined'){
6668 var cellIndex = cell.dom.cellIndex;
6669 var rowIndex = this.getRowIndex(row);
6671 if(this.cellSelection){
6672 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6675 if(this.rowSelection){
6676 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6680 sort : function(e,el)
6682 var col = Roo.get(el);
6684 if(!col.hasClass('sortable')){
6688 var sort = col.attr('sort');
6691 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6695 this.store.sortInfo = {field : sort, direction : dir};
6698 Roo.log("calling footer first");
6699 this.footer.onClick('first');
6702 this.store.load({ params : { start : 0 } });
6706 renderHeader : function()
6714 this.totalWidth = 0;
6716 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6718 var config = cm.config[i];
6722 cls : 'x-hcol-' + i,
6724 html: cm.getColumnHeader(i)
6729 if(typeof(config.sortable) != 'undefined' && config.sortable){
6731 c.html = '<i class="glyphicon"></i>' + c.html;
6734 if(typeof(config.lgHeader) != 'undefined'){
6735 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6738 if(typeof(config.mdHeader) != 'undefined'){
6739 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6742 if(typeof(config.smHeader) != 'undefined'){
6743 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6746 if(typeof(config.xsHeader) != 'undefined'){
6747 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6754 if(typeof(config.tooltip) != 'undefined'){
6755 c.tooltip = config.tooltip;
6758 if(typeof(config.colspan) != 'undefined'){
6759 c.colspan = config.colspan;
6762 if(typeof(config.hidden) != 'undefined' && config.hidden){
6763 c.style += ' display:none;';
6766 if(typeof(config.dataIndex) != 'undefined'){
6767 c.sort = config.dataIndex;
6772 if(typeof(config.align) != 'undefined' && config.align.length){
6773 c.style += ' text-align:' + config.align + ';';
6776 if(typeof(config.width) != 'undefined'){
6777 c.style += ' width:' + config.width + 'px;';
6778 this.totalWidth += config.width;
6780 this.totalWidth += 100; // assume minimum of 100 per column?
6783 if(typeof(config.cls) != 'undefined'){
6784 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6787 ['xs','sm','md','lg'].map(function(size){
6789 if(typeof(config[size]) == 'undefined'){
6793 if (!config[size]) { // 0 = hidden
6794 c.cls += ' hidden-' + size;
6798 c.cls += ' col-' + size + '-' + config[size];
6808 renderBody : function()
6818 colspan : this.cm.getColumnCount()
6828 renderFooter : function()
6838 colspan : this.cm.getColumnCount()
6852 // Roo.log('ds onload');
6857 var ds = this.store;
6859 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6860 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6861 if (_this.store.sortInfo) {
6863 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6864 e.select('i', true).addClass(['glyphicon-arrow-up']);
6867 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6868 e.select('i', true).addClass(['glyphicon-arrow-down']);
6873 var tbody = this.mainBody;
6875 if(ds.getCount() > 0){
6876 ds.data.each(function(d,rowIndex){
6877 var row = this.renderRow(cm, ds, rowIndex);
6879 tbody.createChild(row);
6883 if(row.cellObjects.length){
6884 Roo.each(row.cellObjects, function(r){
6885 _this.renderCellObject(r);
6892 var tfoot = this.el.select('tfoot', true).first();
6894 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6896 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6898 var total = this.ds.getTotalCount();
6900 if(this.footer.pageSize < total){
6901 this.mainFoot.show();
6905 Roo.each(this.el.select('tbody td', true).elements, function(e){
6906 e.on('mouseover', _this.onMouseover, _this);
6909 Roo.each(this.el.select('tbody td', true).elements, function(e){
6910 e.on('mouseout', _this.onMouseout, _this);
6912 this.fireEvent('rowsrendered', this);
6918 onUpdate : function(ds,record)
6920 this.refreshRow(record);
6924 onRemove : function(ds, record, index, isUpdate){
6925 if(isUpdate !== true){
6926 this.fireEvent("beforerowremoved", this, index, record);
6928 var bt = this.mainBody.dom;
6930 var rows = this.el.select('tbody > tr', true).elements;
6932 if(typeof(rows[index]) != 'undefined'){
6933 bt.removeChild(rows[index].dom);
6936 // if(bt.rows[index]){
6937 // bt.removeChild(bt.rows[index]);
6940 if(isUpdate !== true){
6941 //this.stripeRows(index);
6942 //this.syncRowHeights(index, index);
6944 this.fireEvent("rowremoved", this, index, record);
6948 onAdd : function(ds, records, rowIndex)
6950 //Roo.log('on Add called');
6951 // - note this does not handle multiple adding very well..
6952 var bt = this.mainBody.dom;
6953 for (var i =0 ; i < records.length;i++) {
6954 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6955 //Roo.log(records[i]);
6956 //Roo.log(this.store.getAt(rowIndex+i));
6957 this.insertRow(this.store, rowIndex + i, false);
6964 refreshRow : function(record){
6965 var ds = this.store, index;
6966 if(typeof record == 'number'){
6968 record = ds.getAt(index);
6970 index = ds.indexOf(record);
6972 this.insertRow(ds, index, true);
6974 this.onRemove(ds, record, index+1, true);
6976 //this.syncRowHeights(index, index);
6978 this.fireEvent("rowupdated", this, index, record);
6981 insertRow : function(dm, rowIndex, isUpdate){
6984 this.fireEvent("beforerowsinserted", this, rowIndex);
6986 //var s = this.getScrollState();
6987 var row = this.renderRow(this.cm, this.store, rowIndex);
6988 // insert before rowIndex..
6989 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6993 if(row.cellObjects.length){
6994 Roo.each(row.cellObjects, function(r){
6995 _this.renderCellObject(r);
7000 this.fireEvent("rowsinserted", this, rowIndex);
7001 //this.syncRowHeights(firstRow, lastRow);
7002 //this.stripeRows(firstRow);
7009 getRowDom : function(rowIndex)
7011 var rows = this.el.select('tbody > tr', true).elements;
7013 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7016 // returns the object tree for a tr..
7019 renderRow : function(cm, ds, rowIndex)
7021 var d = ds.getAt(rowIndex);
7025 cls : 'x-row-' + rowIndex,
7029 var cellObjects = [];
7031 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7032 var config = cm.config[i];
7034 var renderer = cm.getRenderer(i);
7038 if(typeof(renderer) !== 'undefined'){
7039 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7041 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7042 // and are rendered into the cells after the row is rendered - using the id for the element.
7044 if(typeof(value) === 'object'){
7054 rowIndex : rowIndex,
7059 this.fireEvent('rowclass', this, rowcfg);
7063 cls : rowcfg.rowClass + ' x-col-' + i,
7065 html: (typeof(value) === 'object') ? '' : value
7072 if(typeof(config.colspan) != 'undefined'){
7073 td.colspan = config.colspan;
7076 if(typeof(config.hidden) != 'undefined' && config.hidden){
7077 td.style += ' display:none;';
7080 if(typeof(config.align) != 'undefined' && config.align.length){
7081 td.style += ' text-align:' + config.align + ';';
7083 if(typeof(config.valign) != 'undefined' && config.valign.length){
7084 td.style += ' vertical-align:' + config.valign + ';';
7087 if(typeof(config.width) != 'undefined'){
7088 td.style += ' width:' + config.width + 'px;';
7091 if(typeof(config.cursor) != 'undefined'){
7092 td.style += ' cursor:' + config.cursor + ';';
7095 if(typeof(config.cls) != 'undefined'){
7096 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7099 ['xs','sm','md','lg'].map(function(size){
7101 if(typeof(config[size]) == 'undefined'){
7105 if (!config[size]) { // 0 = hidden
7106 td.cls += ' hidden-' + size;
7110 td.cls += ' col-' + size + '-' + config[size];
7118 row.cellObjects = cellObjects;
7126 onBeforeLoad : function()
7135 this.el.select('tbody', true).first().dom.innerHTML = '';
7138 * Show or hide a row.
7139 * @param {Number} rowIndex to show or hide
7140 * @param {Boolean} state hide
7142 setRowVisibility : function(rowIndex, state)
7144 var bt = this.mainBody.dom;
7146 var rows = this.el.select('tbody > tr', true).elements;
7148 if(typeof(rows[rowIndex]) == 'undefined'){
7151 rows[rowIndex].dom.style.display = state ? '' : 'none';
7155 getSelectionModel : function(){
7157 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7159 return this.selModel;
7162 * Render the Roo.bootstrap object from renderder
7164 renderCellObject : function(r)
7168 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7170 var t = r.cfg.render(r.container);
7173 Roo.each(r.cfg.cn, function(c){
7175 container: t.getChildContainer(),
7178 _this.renderCellObject(child);
7183 getRowIndex : function(row)
7187 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7198 * Returns the grid's underlying element = used by panel.Grid
7199 * @return {Element} The element
7201 getGridEl : function(){
7205 * Forces a resize - used by panel.Grid
7206 * @return {Element} The element
7208 autoSize : function()
7210 //var ctr = Roo.get(this.container.dom.parentElement);
7211 var ctr = Roo.get(this.el.dom);
7213 var thd = this.getGridEl().select('thead',true).first();
7214 var tbd = this.getGridEl().select('tbody', true).first();
7215 var tfd = this.getGridEl().select('tfoot', true).first();
7217 var cw = ctr.getWidth();
7221 tbd.setSize(ctr.getWidth(),
7222 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7224 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7227 cw = Math.max(cw, this.totalWidth);
7228 this.getGridEl().select('tr',true).setWidth(cw);
7229 // resize 'expandable coloumn?
7231 return; // we doe not have a view in this design..
7234 onBodyScroll: function()
7236 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7238 this.mainHead.setStyle({
7239 'position' : 'relative',
7240 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7246 var scrollHeight = this.mainBody.dom.scrollHeight;
7248 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7250 var height = this.mainBody.getHeight();
7252 if(scrollHeight - height == scrollTop) {
7254 var total = this.ds.getTotalCount();
7256 if(this.footer.cursor + this.footer.pageSize < total){
7258 this.footer.ds.load({
7260 start : this.footer.cursor + this.footer.pageSize,
7261 limit : this.footer.pageSize
7271 onHeaderChange : function()
7273 var header = this.renderHeader();
7274 var table = this.el.select('table', true).first();
7276 this.mainHead.remove();
7277 this.mainHead = table.createChild(header, this.mainBody, false);
7280 onHiddenChange : function(colModel, colIndex, hidden)
7282 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7283 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7285 this.CSS.updateRule(thSelector, "display", "");
7286 this.CSS.updateRule(tdSelector, "display", "");
7289 this.CSS.updateRule(thSelector, "display", "none");
7290 this.CSS.updateRule(tdSelector, "display", "none");
7293 this.onHeaderChange();
7297 setColumnWidth: function(col_index, width)
7299 // width = "md-2 xs-2..."
7300 if(!this.colModel.config[col_index]) {
7304 var w = width.split(" ");
7306 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7308 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7311 for(var j = 0; j < w.length; j++) {
7317 var size_cls = w[j].split("-");
7319 if(!Number.isInteger(size_cls[1] * 1)) {
7323 if(!this.colModel.config[col_index][size_cls[0]]) {
7327 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7331 h_row[0].classList.replace(
7332 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7333 "col-"+size_cls[0]+"-"+size_cls[1]
7336 for(var i = 0; i < rows.length; i++) {
7338 var size_cls = w[j].split("-");
7340 if(!Number.isInteger(size_cls[1] * 1)) {
7344 if(!this.colModel.config[col_index][size_cls[0]]) {
7348 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7352 rows[i].classList.replace(
7353 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7354 "col-"+size_cls[0]+"-"+size_cls[1]
7358 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7373 * @class Roo.bootstrap.TableCell
7374 * @extends Roo.bootstrap.Component
7375 * Bootstrap TableCell class
7376 * @cfg {String} html cell contain text
7377 * @cfg {String} cls cell class
7378 * @cfg {String} tag cell tag (td|th) default td
7379 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7380 * @cfg {String} align Aligns the content in a cell
7381 * @cfg {String} axis Categorizes cells
7382 * @cfg {String} bgcolor Specifies the background color of a cell
7383 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7384 * @cfg {Number} colspan Specifies the number of columns a cell should span
7385 * @cfg {String} headers Specifies one or more header cells a cell is related to
7386 * @cfg {Number} height Sets the height of a cell
7387 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7388 * @cfg {Number} rowspan Sets the number of rows a cell should span
7389 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7390 * @cfg {String} valign Vertical aligns the content in a cell
7391 * @cfg {Number} width Specifies the width of a cell
7394 * Create a new TableCell
7395 * @param {Object} config The config object
7398 Roo.bootstrap.TableCell = function(config){
7399 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7402 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7422 getAutoCreate : function(){
7423 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7443 cfg.align=this.align
7449 cfg.bgcolor=this.bgcolor
7452 cfg.charoff=this.charoff
7455 cfg.colspan=this.colspan
7458 cfg.headers=this.headers
7461 cfg.height=this.height
7464 cfg.nowrap=this.nowrap
7467 cfg.rowspan=this.rowspan
7470 cfg.scope=this.scope
7473 cfg.valign=this.valign
7476 cfg.width=this.width
7495 * @class Roo.bootstrap.TableRow
7496 * @extends Roo.bootstrap.Component
7497 * Bootstrap TableRow class
7498 * @cfg {String} cls row class
7499 * @cfg {String} align Aligns the content in a table row
7500 * @cfg {String} bgcolor Specifies a background color for a table row
7501 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7502 * @cfg {String} valign Vertical aligns the content in a table row
7505 * Create a new TableRow
7506 * @param {Object} config The config object
7509 Roo.bootstrap.TableRow = function(config){
7510 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7513 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7521 getAutoCreate : function(){
7522 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7532 cfg.align = this.align;
7535 cfg.bgcolor = this.bgcolor;
7538 cfg.charoff = this.charoff;
7541 cfg.valign = this.valign;
7559 * @class Roo.bootstrap.TableBody
7560 * @extends Roo.bootstrap.Component
7561 * Bootstrap TableBody class
7562 * @cfg {String} cls element class
7563 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7564 * @cfg {String} align Aligns the content inside the element
7565 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7566 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7569 * Create a new TableBody
7570 * @param {Object} config The config object
7573 Roo.bootstrap.TableBody = function(config){
7574 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7577 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7585 getAutoCreate : function(){
7586 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7600 cfg.align = this.align;
7603 cfg.charoff = this.charoff;
7606 cfg.valign = this.valign;
7613 // initEvents : function()
7620 // this.store = Roo.factory(this.store, Roo.data);
7621 // this.store.on('load', this.onLoad, this);
7623 // this.store.load();
7627 // onLoad: function ()
7629 // this.fireEvent('load', this);
7639 * Ext JS Library 1.1.1
7640 * Copyright(c) 2006-2007, Ext JS, LLC.
7642 * Originally Released Under LGPL - original licence link has changed is not relivant.
7645 * <script type="text/javascript">
7648 // as we use this in bootstrap.
7649 Roo.namespace('Roo.form');
7651 * @class Roo.form.Action
7652 * Internal Class used to handle form actions
7654 * @param {Roo.form.BasicForm} el The form element or its id
7655 * @param {Object} config Configuration options
7660 // define the action interface
7661 Roo.form.Action = function(form, options){
7663 this.options = options || {};
7666 * Client Validation Failed
7669 Roo.form.Action.CLIENT_INVALID = 'client';
7671 * Server Validation Failed
7674 Roo.form.Action.SERVER_INVALID = 'server';
7676 * Connect to Server Failed
7679 Roo.form.Action.CONNECT_FAILURE = 'connect';
7681 * Reading Data from Server Failed
7684 Roo.form.Action.LOAD_FAILURE = 'load';
7686 Roo.form.Action.prototype = {
7688 failureType : undefined,
7689 response : undefined,
7693 run : function(options){
7698 success : function(response){
7703 handleResponse : function(response){
7707 // default connection failure
7708 failure : function(response){
7710 this.response = response;
7711 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7712 this.form.afterAction(this, false);
7715 processResponse : function(response){
7716 this.response = response;
7717 if(!response.responseText){
7720 this.result = this.handleResponse(response);
7724 // utility functions used internally
7725 getUrl : function(appendParams){
7726 var url = this.options.url || this.form.url || this.form.el.dom.action;
7728 var p = this.getParams();
7730 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7736 getMethod : function(){
7737 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7740 getParams : function(){
7741 var bp = this.form.baseParams;
7742 var p = this.options.params;
7744 if(typeof p == "object"){
7745 p = Roo.urlEncode(Roo.applyIf(p, bp));
7746 }else if(typeof p == 'string' && bp){
7747 p += '&' + Roo.urlEncode(bp);
7750 p = Roo.urlEncode(bp);
7755 createCallback : function(){
7757 success: this.success,
7758 failure: this.failure,
7760 timeout: (this.form.timeout*1000),
7761 upload: this.form.fileUpload ? this.success : undefined
7766 Roo.form.Action.Submit = function(form, options){
7767 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7770 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7773 haveProgress : false,
7774 uploadComplete : false,
7776 // uploadProgress indicator.
7777 uploadProgress : function()
7779 if (!this.form.progressUrl) {
7783 if (!this.haveProgress) {
7784 Roo.MessageBox.progress("Uploading", "Uploading");
7786 if (this.uploadComplete) {
7787 Roo.MessageBox.hide();
7791 this.haveProgress = true;
7793 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7795 var c = new Roo.data.Connection();
7797 url : this.form.progressUrl,
7802 success : function(req){
7803 //console.log(data);
7807 rdata = Roo.decode(req.responseText)
7809 Roo.log("Invalid data from server..");
7813 if (!rdata || !rdata.success) {
7815 Roo.MessageBox.alert(Roo.encode(rdata));
7818 var data = rdata.data;
7820 if (this.uploadComplete) {
7821 Roo.MessageBox.hide();
7826 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7827 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7830 this.uploadProgress.defer(2000,this);
7833 failure: function(data) {
7834 Roo.log('progress url failed ');
7845 // run get Values on the form, so it syncs any secondary forms.
7846 this.form.getValues();
7848 var o = this.options;
7849 var method = this.getMethod();
7850 var isPost = method == 'POST';
7851 if(o.clientValidation === false || this.form.isValid()){
7853 if (this.form.progressUrl) {
7854 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7855 (new Date() * 1) + '' + Math.random());
7860 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7861 form:this.form.el.dom,
7862 url:this.getUrl(!isPost),
7864 params:isPost ? this.getParams() : null,
7865 isUpload: this.form.fileUpload
7868 this.uploadProgress();
7870 }else if (o.clientValidation !== false){ // client validation failed
7871 this.failureType = Roo.form.Action.CLIENT_INVALID;
7872 this.form.afterAction(this, false);
7876 success : function(response)
7878 this.uploadComplete= true;
7879 if (this.haveProgress) {
7880 Roo.MessageBox.hide();
7884 var result = this.processResponse(response);
7885 if(result === true || result.success){
7886 this.form.afterAction(this, true);
7890 this.form.markInvalid(result.errors);
7891 this.failureType = Roo.form.Action.SERVER_INVALID;
7893 this.form.afterAction(this, false);
7895 failure : function(response)
7897 this.uploadComplete= true;
7898 if (this.haveProgress) {
7899 Roo.MessageBox.hide();
7902 this.response = response;
7903 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7904 this.form.afterAction(this, false);
7907 handleResponse : function(response){
7908 if(this.form.errorReader){
7909 var rs = this.form.errorReader.read(response);
7912 for(var i = 0, len = rs.records.length; i < len; i++) {
7913 var r = rs.records[i];
7917 if(errors.length < 1){
7921 success : rs.success,
7927 ret = Roo.decode(response.responseText);
7931 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7941 Roo.form.Action.Load = function(form, options){
7942 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7943 this.reader = this.form.reader;
7946 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7951 Roo.Ajax.request(Roo.apply(
7952 this.createCallback(), {
7953 method:this.getMethod(),
7954 url:this.getUrl(false),
7955 params:this.getParams()
7959 success : function(response){
7961 var result = this.processResponse(response);
7962 if(result === true || !result.success || !result.data){
7963 this.failureType = Roo.form.Action.LOAD_FAILURE;
7964 this.form.afterAction(this, false);
7967 this.form.clearInvalid();
7968 this.form.setValues(result.data);
7969 this.form.afterAction(this, true);
7972 handleResponse : function(response){
7973 if(this.form.reader){
7974 var rs = this.form.reader.read(response);
7975 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7977 success : rs.success,
7981 return Roo.decode(response.responseText);
7985 Roo.form.Action.ACTION_TYPES = {
7986 'load' : Roo.form.Action.Load,
7987 'submit' : Roo.form.Action.Submit
7996 * @class Roo.bootstrap.Form
7997 * @extends Roo.bootstrap.Component
7998 * Bootstrap Form class
7999 * @cfg {String} method GET | POST (default POST)
8000 * @cfg {String} labelAlign top | left (default top)
8001 * @cfg {String} align left | right - for navbars
8002 * @cfg {Boolean} loadMask load mask when submit (default true)
8007 * @param {Object} config The config object
8011 Roo.bootstrap.Form = function(config){
8013 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8015 Roo.bootstrap.Form.popover.apply();
8019 * @event clientvalidation
8020 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8021 * @param {Form} this
8022 * @param {Boolean} valid true if the form has passed client-side validation
8024 clientvalidation: true,
8026 * @event beforeaction
8027 * Fires before any action is performed. Return false to cancel the action.
8028 * @param {Form} this
8029 * @param {Action} action The action to be performed
8033 * @event actionfailed
8034 * Fires when an action fails.
8035 * @param {Form} this
8036 * @param {Action} action The action that failed
8038 actionfailed : true,
8040 * @event actioncomplete
8041 * Fires when an action is completed.
8042 * @param {Form} this
8043 * @param {Action} action The action that completed
8045 actioncomplete : true
8049 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8052 * @cfg {String} method
8053 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8058 * The URL to use for form actions if one isn't supplied in the action options.
8061 * @cfg {Boolean} fileUpload
8062 * Set to true if this form is a file upload.
8066 * @cfg {Object} baseParams
8067 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8071 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8075 * @cfg {Sting} align (left|right) for navbar forms
8080 activeAction : null,
8083 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8084 * element by passing it or its id or mask the form itself by passing in true.
8087 waitMsgTarget : false,
8092 * @cfg {Boolean} errorMask (true|false) default false
8097 * @cfg {Number} maskOffset Default 100
8102 * @cfg {Boolean} maskBody
8106 getAutoCreate : function(){
8110 method : this.method || 'POST',
8111 id : this.id || Roo.id(),
8114 if (this.parent().xtype.match(/^Nav/)) {
8115 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8119 if (this.labelAlign == 'left' ) {
8120 cfg.cls += ' form-horizontal';
8126 initEvents : function()
8128 this.el.on('submit', this.onSubmit, this);
8129 // this was added as random key presses on the form where triggering form submit.
8130 this.el.on('keypress', function(e) {
8131 if (e.getCharCode() != 13) {
8134 // we might need to allow it for textareas.. and some other items.
8135 // check e.getTarget().
8137 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8141 Roo.log("keypress blocked");
8149 onSubmit : function(e){
8154 * Returns true if client-side validation on the form is successful.
8157 isValid : function(){
8158 var items = this.getItems();
8162 items.each(function(f){
8168 Roo.log('invalid field: ' + f.name);
8172 if(!target && f.el.isVisible(true)){
8178 if(this.errorMask && !valid){
8179 Roo.bootstrap.Form.popover.mask(this, target);
8186 * Returns true if any fields in this form have changed since their original load.
8189 isDirty : function(){
8191 var items = this.getItems();
8192 items.each(function(f){
8202 * Performs a predefined action (submit or load) or custom actions you define on this form.
8203 * @param {String} actionName The name of the action type
8204 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8205 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8206 * accept other config options):
8208 Property Type Description
8209 ---------------- --------------- ----------------------------------------------------------------------------------
8210 url String The url for the action (defaults to the form's url)
8211 method String The form method to use (defaults to the form's method, or POST if not defined)
8212 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8213 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8214 validate the form on the client (defaults to false)
8216 * @return {BasicForm} this
8218 doAction : function(action, options){
8219 if(typeof action == 'string'){
8220 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8222 if(this.fireEvent('beforeaction', this, action) !== false){
8223 this.beforeAction(action);
8224 action.run.defer(100, action);
8230 beforeAction : function(action){
8231 var o = action.options;
8236 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8238 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8241 // not really supported yet.. ??
8243 //if(this.waitMsgTarget === true){
8244 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8245 //}else if(this.waitMsgTarget){
8246 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8247 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8249 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8255 afterAction : function(action, success){
8256 this.activeAction = null;
8257 var o = action.options;
8262 Roo.get(document.body).unmask();
8268 //if(this.waitMsgTarget === true){
8269 // this.el.unmask();
8270 //}else if(this.waitMsgTarget){
8271 // this.waitMsgTarget.unmask();
8273 // Roo.MessageBox.updateProgress(1);
8274 // Roo.MessageBox.hide();
8281 Roo.callback(o.success, o.scope, [this, action]);
8282 this.fireEvent('actioncomplete', this, action);
8286 // failure condition..
8287 // we have a scenario where updates need confirming.
8288 // eg. if a locking scenario exists..
8289 // we look for { errors : { needs_confirm : true }} in the response.
8291 (typeof(action.result) != 'undefined') &&
8292 (typeof(action.result.errors) != 'undefined') &&
8293 (typeof(action.result.errors.needs_confirm) != 'undefined')
8296 Roo.log("not supported yet");
8299 Roo.MessageBox.confirm(
8300 "Change requires confirmation",
8301 action.result.errorMsg,
8306 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8316 Roo.callback(o.failure, o.scope, [this, action]);
8317 // show an error message if no failed handler is set..
8318 if (!this.hasListener('actionfailed')) {
8319 Roo.log("need to add dialog support");
8321 Roo.MessageBox.alert("Error",
8322 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8323 action.result.errorMsg :
8324 "Saving Failed, please check your entries or try again"
8329 this.fireEvent('actionfailed', this, action);
8334 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8335 * @param {String} id The value to search for
8338 findField : function(id){
8339 var items = this.getItems();
8340 var field = items.get(id);
8342 items.each(function(f){
8343 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8350 return field || null;
8353 * Mark fields in this form invalid in bulk.
8354 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8355 * @return {BasicForm} this
8357 markInvalid : function(errors){
8358 if(errors instanceof Array){
8359 for(var i = 0, len = errors.length; i < len; i++){
8360 var fieldError = errors[i];
8361 var f = this.findField(fieldError.id);
8363 f.markInvalid(fieldError.msg);
8369 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8370 field.markInvalid(errors[id]);
8374 //Roo.each(this.childForms || [], function (f) {
8375 // f.markInvalid(errors);
8382 * Set values for fields in this form in bulk.
8383 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8384 * @return {BasicForm} this
8386 setValues : function(values){
8387 if(values instanceof Array){ // array of objects
8388 for(var i = 0, len = values.length; i < len; i++){
8390 var f = this.findField(v.id);
8392 f.setValue(v.value);
8393 if(this.trackResetOnLoad){
8394 f.originalValue = f.getValue();
8398 }else{ // object hash
8401 if(typeof values[id] != 'function' && (field = this.findField(id))){
8403 if (field.setFromData &&
8405 field.displayField &&
8406 // combos' with local stores can
8407 // be queried via setValue()
8408 // to set their value..
8409 (field.store && !field.store.isLocal)
8413 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8414 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8415 field.setFromData(sd);
8417 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8419 field.setFromData(values);
8422 field.setValue(values[id]);
8426 if(this.trackResetOnLoad){
8427 field.originalValue = field.getValue();
8433 //Roo.each(this.childForms || [], function (f) {
8434 // f.setValues(values);
8441 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8442 * they are returned as an array.
8443 * @param {Boolean} asString
8446 getValues : function(asString){
8447 //if (this.childForms) {
8448 // copy values from the child forms
8449 // Roo.each(this.childForms, function (f) {
8450 // this.setValues(f.getValues());
8456 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8457 if(asString === true){
8460 return Roo.urlDecode(fs);
8464 * Returns the fields in this form as an object with key/value pairs.
8465 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8468 getFieldValues : function(with_hidden)
8470 var items = this.getItems();
8472 items.each(function(f){
8478 var v = f.getValue();
8480 if (f.inputType =='radio') {
8481 if (typeof(ret[f.getName()]) == 'undefined') {
8482 ret[f.getName()] = ''; // empty..
8485 if (!f.el.dom.checked) {
8493 if(f.xtype == 'MoneyField'){
8494 ret[f.currencyName] = f.getCurrency();
8497 // not sure if this supported any more..
8498 if ((typeof(v) == 'object') && f.getRawValue) {
8499 v = f.getRawValue() ; // dates..
8501 // combo boxes where name != hiddenName...
8502 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8503 ret[f.name] = f.getRawValue();
8505 ret[f.getName()] = v;
8512 * Clears all invalid messages in this form.
8513 * @return {BasicForm} this
8515 clearInvalid : function(){
8516 var items = this.getItems();
8518 items.each(function(f){
8527 * @return {BasicForm} this
8530 var items = this.getItems();
8531 items.each(function(f){
8535 Roo.each(this.childForms || [], function (f) {
8543 getItems : function()
8545 var r=new Roo.util.MixedCollection(false, function(o){
8546 return o.id || (o.id = Roo.id());
8548 var iter = function(el) {
8555 Roo.each(el.items,function(e) {
8564 hideFields : function(items)
8566 Roo.each(items, function(i){
8568 var f = this.findField(i);
8579 showFields : function(items)
8581 Roo.each(items, function(i){
8583 var f = this.findField(i);
8596 Roo.apply(Roo.bootstrap.Form, {
8623 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8624 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8625 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8626 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8629 this.maskEl.top.enableDisplayMode("block");
8630 this.maskEl.left.enableDisplayMode("block");
8631 this.maskEl.bottom.enableDisplayMode("block");
8632 this.maskEl.right.enableDisplayMode("block");
8634 this.toolTip = new Roo.bootstrap.Tooltip({
8635 cls : 'roo-form-error-popover',
8637 'left' : ['r-l', [-2,0], 'right'],
8638 'right' : ['l-r', [2,0], 'left'],
8639 'bottom' : ['tl-bl', [0,2], 'top'],
8640 'top' : [ 'bl-tl', [0,-2], 'bottom']
8644 this.toolTip.render(Roo.get(document.body));
8646 this.toolTip.el.enableDisplayMode("block");
8648 Roo.get(document.body).on('click', function(){
8652 Roo.get(document.body).on('touchstart', function(){
8656 this.isApplied = true
8659 mask : function(form, target)
8663 this.target = target;
8665 if(!this.form.errorMask || !target.el){
8669 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8671 Roo.log(scrollable);
8673 var ot = this.target.el.calcOffsetsTo(scrollable);
8675 var scrollTo = ot[1] - this.form.maskOffset;
8677 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8679 scrollable.scrollTo('top', scrollTo);
8681 var box = this.target.el.getBox();
8683 var zIndex = Roo.bootstrap.Modal.zIndex++;
8686 this.maskEl.top.setStyle('position', 'absolute');
8687 this.maskEl.top.setStyle('z-index', zIndex);
8688 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8689 this.maskEl.top.setLeft(0);
8690 this.maskEl.top.setTop(0);
8691 this.maskEl.top.show();
8693 this.maskEl.left.setStyle('position', 'absolute');
8694 this.maskEl.left.setStyle('z-index', zIndex);
8695 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8696 this.maskEl.left.setLeft(0);
8697 this.maskEl.left.setTop(box.y - this.padding);
8698 this.maskEl.left.show();
8700 this.maskEl.bottom.setStyle('position', 'absolute');
8701 this.maskEl.bottom.setStyle('z-index', zIndex);
8702 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8703 this.maskEl.bottom.setLeft(0);
8704 this.maskEl.bottom.setTop(box.bottom + this.padding);
8705 this.maskEl.bottom.show();
8707 this.maskEl.right.setStyle('position', 'absolute');
8708 this.maskEl.right.setStyle('z-index', zIndex);
8709 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8710 this.maskEl.right.setLeft(box.right + this.padding);
8711 this.maskEl.right.setTop(box.y - this.padding);
8712 this.maskEl.right.show();
8714 this.toolTip.bindEl = this.target.el;
8716 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8718 var tip = this.target.blankText;
8720 if(this.target.getValue() !== '' ) {
8722 if (this.target.invalidText.length) {
8723 tip = this.target.invalidText;
8724 } else if (this.target.regexText.length){
8725 tip = this.target.regexText;
8729 this.toolTip.show(tip);
8731 this.intervalID = window.setInterval(function() {
8732 Roo.bootstrap.Form.popover.unmask();
8735 window.onwheel = function(){ return false;};
8737 (function(){ this.isMasked = true; }).defer(500, this);
8743 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8747 this.maskEl.top.setStyle('position', 'absolute');
8748 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8749 this.maskEl.top.hide();
8751 this.maskEl.left.setStyle('position', 'absolute');
8752 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8753 this.maskEl.left.hide();
8755 this.maskEl.bottom.setStyle('position', 'absolute');
8756 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8757 this.maskEl.bottom.hide();
8759 this.maskEl.right.setStyle('position', 'absolute');
8760 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8761 this.maskEl.right.hide();
8763 this.toolTip.hide();
8765 this.toolTip.el.hide();
8767 window.onwheel = function(){ return true;};
8769 if(this.intervalID){
8770 window.clearInterval(this.intervalID);
8771 this.intervalID = false;
8774 this.isMasked = false;
8784 * Ext JS Library 1.1.1
8785 * Copyright(c) 2006-2007, Ext JS, LLC.
8787 * Originally Released Under LGPL - original licence link has changed is not relivant.
8790 * <script type="text/javascript">
8793 * @class Roo.form.VTypes
8794 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8797 Roo.form.VTypes = function(){
8798 // closure these in so they are only created once.
8799 var alpha = /^[a-zA-Z_]+$/;
8800 var alphanum = /^[a-zA-Z0-9_]+$/;
8801 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8802 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8804 // All these messages and functions are configurable
8807 * The function used to validate email addresses
8808 * @param {String} value The email address
8810 'email' : function(v){
8811 return email.test(v);
8814 * The error text to display when the email validation function returns false
8817 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8819 * The keystroke filter mask to be applied on email input
8822 'emailMask' : /[a-z0-9_\.\-@]/i,
8825 * The function used to validate URLs
8826 * @param {String} value The URL
8828 'url' : function(v){
8832 * The error text to display when the url validation function returns false
8835 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8838 * The function used to validate alpha values
8839 * @param {String} value The value
8841 'alpha' : function(v){
8842 return alpha.test(v);
8845 * The error text to display when the alpha validation function returns false
8848 'alphaText' : 'This field should only contain letters and _',
8850 * The keystroke filter mask to be applied on alpha input
8853 'alphaMask' : /[a-z_]/i,
8856 * The function used to validate alphanumeric values
8857 * @param {String} value The value
8859 'alphanum' : function(v){
8860 return alphanum.test(v);
8863 * The error text to display when the alphanumeric validation function returns false
8866 'alphanumText' : 'This field should only contain letters, numbers and _',
8868 * The keystroke filter mask to be applied on alphanumeric input
8871 'alphanumMask' : /[a-z0-9_]/i
8881 * @class Roo.bootstrap.Input
8882 * @extends Roo.bootstrap.Component
8883 * Bootstrap Input class
8884 * @cfg {Boolean} disabled is it disabled
8885 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8886 * @cfg {String} name name of the input
8887 * @cfg {string} fieldLabel - the label associated
8888 * @cfg {string} placeholder - placeholder to put in text.
8889 * @cfg {string} before - input group add on before
8890 * @cfg {string} after - input group add on after
8891 * @cfg {string} size - (lg|sm) or leave empty..
8892 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8893 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8894 * @cfg {Number} md colspan out of 12 for computer-sized screens
8895 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8896 * @cfg {string} value default value of the input
8897 * @cfg {Number} labelWidth set the width of label
8898 * @cfg {Number} labellg set the width of label (1-12)
8899 * @cfg {Number} labelmd set the width of label (1-12)
8900 * @cfg {Number} labelsm set the width of label (1-12)
8901 * @cfg {Number} labelxs set the width of label (1-12)
8902 * @cfg {String} labelAlign (top|left)
8903 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8904 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8905 * @cfg {String} indicatorpos (left|right) default left
8906 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8907 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8909 * @cfg {String} align (left|center|right) Default left
8910 * @cfg {Boolean} forceFeedback (true|false) Default false
8913 * Create a new Input
8914 * @param {Object} config The config object
8917 Roo.bootstrap.Input = function(config){
8919 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8924 * Fires when this field receives input focus.
8925 * @param {Roo.form.Field} this
8930 * Fires when this field loses input focus.
8931 * @param {Roo.form.Field} this
8936 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8937 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8938 * @param {Roo.form.Field} this
8939 * @param {Roo.EventObject} e The event object
8944 * Fires just before the field blurs if the field value has changed.
8945 * @param {Roo.form.Field} this
8946 * @param {Mixed} newValue The new value
8947 * @param {Mixed} oldValue The original value
8952 * Fires after the field has been marked as invalid.
8953 * @param {Roo.form.Field} this
8954 * @param {String} msg The validation message
8959 * Fires after the field has been validated with no errors.
8960 * @param {Roo.form.Field} this
8965 * Fires after the key up
8966 * @param {Roo.form.Field} this
8967 * @param {Roo.EventObject} e The event Object
8973 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8975 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8976 automatic validation (defaults to "keyup").
8978 validationEvent : "keyup",
8980 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8982 validateOnBlur : true,
8984 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8986 validationDelay : 250,
8988 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8990 focusClass : "x-form-focus", // not needed???
8994 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
8996 invalidClass : "has-warning",
8999 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9001 validClass : "has-success",
9004 * @cfg {Boolean} hasFeedback (true|false) default true
9009 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9011 invalidFeedbackClass : "glyphicon-warning-sign",
9014 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9016 validFeedbackClass : "glyphicon-ok",
9019 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9021 selectOnFocus : false,
9024 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9028 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9033 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9035 disableKeyFilter : false,
9038 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9042 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9046 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9048 blankText : "Please complete this mandatory field",
9051 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9055 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9057 maxLength : Number.MAX_VALUE,
9059 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9061 minLengthText : "The minimum length for this field is {0}",
9063 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9065 maxLengthText : "The maximum length for this field is {0}",
9069 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9070 * If available, this function will be called only after the basic validators all return true, and will be passed the
9071 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9075 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9076 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9077 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9081 * @cfg {String} regexText -- Depricated - use Invalid Text
9086 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9092 autocomplete: false,
9111 formatedValue : false,
9112 forceFeedback : false,
9114 indicatorpos : 'left',
9124 parentLabelAlign : function()
9127 while (parent.parent()) {
9128 parent = parent.parent();
9129 if (typeof(parent.labelAlign) !='undefined') {
9130 return parent.labelAlign;
9137 getAutoCreate : function()
9139 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9145 if(this.inputType != 'hidden'){
9146 cfg.cls = 'form-group' //input-group
9152 type : this.inputType,
9154 cls : 'form-control',
9155 placeholder : this.placeholder || '',
9156 autocomplete : this.autocomplete || 'new-password'
9159 if(this.capture.length){
9160 input.capture = this.capture;
9163 if(this.accept.length){
9164 input.accept = this.accept + "/*";
9168 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9171 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9172 input.maxLength = this.maxLength;
9175 if (this.disabled) {
9176 input.disabled=true;
9179 if (this.readOnly) {
9180 input.readonly=true;
9184 input.name = this.name;
9188 input.cls += ' input-' + this.size;
9192 ['xs','sm','md','lg'].map(function(size){
9193 if (settings[size]) {
9194 cfg.cls += ' col-' + size + '-' + settings[size];
9198 var inputblock = input;
9202 cls: 'glyphicon form-control-feedback'
9205 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9208 cls : 'has-feedback',
9216 if (this.before || this.after) {
9219 cls : 'input-group',
9223 if (this.before && typeof(this.before) == 'string') {
9225 inputblock.cn.push({
9227 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9231 if (this.before && typeof(this.before) == 'object') {
9232 this.before = Roo.factory(this.before);
9234 inputblock.cn.push({
9236 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9237 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9241 inputblock.cn.push(input);
9243 if (this.after && typeof(this.after) == 'string') {
9244 inputblock.cn.push({
9246 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9250 if (this.after && typeof(this.after) == 'object') {
9251 this.after = Roo.factory(this.after);
9253 inputblock.cn.push({
9255 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9256 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9260 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9261 inputblock.cls += ' has-feedback';
9262 inputblock.cn.push(feedback);
9267 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9268 tooltip : 'This field is required'
9270 if (Roo.bootstrap.version == 4) {
9273 style : 'display-none'
9276 if (align ==='left' && this.fieldLabel.length) {
9278 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9285 cls : 'control-label col-form-label',
9286 html : this.fieldLabel
9297 var labelCfg = cfg.cn[1];
9298 var contentCfg = cfg.cn[2];
9300 if(this.indicatorpos == 'right'){
9305 cls : 'control-label col-form-label',
9309 html : this.fieldLabel
9323 labelCfg = cfg.cn[0];
9324 contentCfg = cfg.cn[1];
9328 if(this.labelWidth > 12){
9329 labelCfg.style = "width: " + this.labelWidth + 'px';
9332 if(this.labelWidth < 13 && this.labelmd == 0){
9333 this.labelmd = this.labelWidth;
9336 if(this.labellg > 0){
9337 labelCfg.cls += ' col-lg-' + this.labellg;
9338 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9341 if(this.labelmd > 0){
9342 labelCfg.cls += ' col-md-' + this.labelmd;
9343 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9346 if(this.labelsm > 0){
9347 labelCfg.cls += ' col-sm-' + this.labelsm;
9348 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9351 if(this.labelxs > 0){
9352 labelCfg.cls += ' col-xs-' + this.labelxs;
9353 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9357 } else if ( this.fieldLabel.length) {
9362 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9363 tooltip : 'This field is required'
9367 //cls : 'input-group-addon',
9368 html : this.fieldLabel
9376 if(this.indicatorpos == 'right'){
9381 //cls : 'input-group-addon',
9382 html : this.fieldLabel
9387 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9388 tooltip : 'This field is required'
9408 if (this.parentType === 'Navbar' && this.parent().bar) {
9409 cfg.cls += ' navbar-form';
9412 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9413 // on BS4 we do this only if not form
9414 cfg.cls += ' navbar-form';
9422 * return the real input element.
9424 inputEl: function ()
9426 return this.el.select('input.form-control',true).first();
9429 tooltipEl : function()
9431 return this.inputEl();
9434 indicatorEl : function()
9436 if (Roo.bootstrap.version == 4) {
9437 return false; // not enabled in v4 yet.
9440 var indicator = this.el.select('i.roo-required-indicator',true).first();
9450 setDisabled : function(v)
9452 var i = this.inputEl().dom;
9454 i.removeAttribute('disabled');
9458 i.setAttribute('disabled','true');
9460 initEvents : function()
9463 this.inputEl().on("keydown" , this.fireKey, this);
9464 this.inputEl().on("focus", this.onFocus, this);
9465 this.inputEl().on("blur", this.onBlur, this);
9467 this.inputEl().relayEvent('keyup', this);
9469 this.indicator = this.indicatorEl();
9472 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9475 // reference to original value for reset
9476 this.originalValue = this.getValue();
9477 //Roo.form.TextField.superclass.initEvents.call(this);
9478 if(this.validationEvent == 'keyup'){
9479 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9480 this.inputEl().on('keyup', this.filterValidation, this);
9482 else if(this.validationEvent !== false){
9483 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9486 if(this.selectOnFocus){
9487 this.on("focus", this.preFocus, this);
9490 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9491 this.inputEl().on("keypress", this.filterKeys, this);
9493 this.inputEl().relayEvent('keypress', this);
9496 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9497 this.el.on("click", this.autoSize, this);
9500 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9501 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9504 if (typeof(this.before) == 'object') {
9505 this.before.render(this.el.select('.roo-input-before',true).first());
9507 if (typeof(this.after) == 'object') {
9508 this.after.render(this.el.select('.roo-input-after',true).first());
9511 this.inputEl().on('change', this.onChange, this);
9514 filterValidation : function(e){
9515 if(!e.isNavKeyPress()){
9516 this.validationTask.delay(this.validationDelay);
9520 * Validates the field value
9521 * @return {Boolean} True if the value is valid, else false
9523 validate : function(){
9524 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9525 if(this.disabled || this.validateValue(this.getRawValue())){
9536 * Validates a value according to the field's validation rules and marks the field as invalid
9537 * if the validation fails
9538 * @param {Mixed} value The value to validate
9539 * @return {Boolean} True if the value is valid, else false
9541 validateValue : function(value)
9543 if(this.getVisibilityEl().hasClass('hidden')){
9547 if(value.length < 1) { // if it's blank
9548 if(this.allowBlank){
9554 if(value.length < this.minLength){
9557 if(value.length > this.maxLength){
9561 var vt = Roo.form.VTypes;
9562 if(!vt[this.vtype](value, this)){
9566 if(typeof this.validator == "function"){
9567 var msg = this.validator(value);
9571 if (typeof(msg) == 'string') {
9572 this.invalidText = msg;
9576 if(this.regex && !this.regex.test(value)){
9584 fireKey : function(e){
9585 //Roo.log('field ' + e.getKey());
9586 if(e.isNavKeyPress()){
9587 this.fireEvent("specialkey", this, e);
9590 focus : function (selectText){
9592 this.inputEl().focus();
9593 if(selectText === true){
9594 this.inputEl().dom.select();
9600 onFocus : function(){
9601 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9602 // this.el.addClass(this.focusClass);
9605 this.hasFocus = true;
9606 this.startValue = this.getValue();
9607 this.fireEvent("focus", this);
9611 beforeBlur : Roo.emptyFn,
9615 onBlur : function(){
9617 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9618 //this.el.removeClass(this.focusClass);
9620 this.hasFocus = false;
9621 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9624 var v = this.getValue();
9625 if(String(v) !== String(this.startValue)){
9626 this.fireEvent('change', this, v, this.startValue);
9628 this.fireEvent("blur", this);
9631 onChange : function(e)
9633 var v = this.getValue();
9634 if(String(v) !== String(this.startValue)){
9635 this.fireEvent('change', this, v, this.startValue);
9641 * Resets the current field value to the originally loaded value and clears any validation messages
9644 this.setValue(this.originalValue);
9648 * Returns the name of the field
9649 * @return {Mixed} name The name field
9651 getName: function(){
9655 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9656 * @return {Mixed} value The field value
9658 getValue : function(){
9660 var v = this.inputEl().getValue();
9665 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9666 * @return {Mixed} value The field value
9668 getRawValue : function(){
9669 var v = this.inputEl().getValue();
9675 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9676 * @param {Mixed} value The value to set
9678 setRawValue : function(v){
9679 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9682 selectText : function(start, end){
9683 var v = this.getRawValue();
9685 start = start === undefined ? 0 : start;
9686 end = end === undefined ? v.length : end;
9687 var d = this.inputEl().dom;
9688 if(d.setSelectionRange){
9689 d.setSelectionRange(start, end);
9690 }else if(d.createTextRange){
9691 var range = d.createTextRange();
9692 range.moveStart("character", start);
9693 range.moveEnd("character", v.length-end);
9700 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9701 * @param {Mixed} value The value to set
9703 setValue : function(v){
9706 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9712 processValue : function(value){
9713 if(this.stripCharsRe){
9714 var newValue = value.replace(this.stripCharsRe, '');
9715 if(newValue !== value){
9716 this.setRawValue(newValue);
9723 preFocus : function(){
9725 if(this.selectOnFocus){
9726 this.inputEl().dom.select();
9729 filterKeys : function(e){
9731 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9734 var c = e.getCharCode(), cc = String.fromCharCode(c);
9735 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9738 if(!this.maskRe.test(cc)){
9743 * Clear any invalid styles/messages for this field
9745 clearInvalid : function(){
9747 if(!this.el || this.preventMark){ // not rendered
9752 this.el.removeClass([this.invalidClass, 'is-invalid']);
9754 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9756 var feedback = this.el.select('.form-control-feedback', true).first();
9759 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9765 this.indicator.removeClass('visible');
9766 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9769 this.fireEvent('valid', this);
9773 * Mark this field as valid
9775 markValid : function()
9777 if(!this.el || this.preventMark){ // not rendered...
9781 this.el.removeClass([this.invalidClass, this.validClass]);
9782 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9784 var feedback = this.el.select('.form-control-feedback', true).first();
9787 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9791 this.indicator.removeClass('visible');
9792 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9799 if(this.allowBlank && !this.getRawValue().length){
9802 if (Roo.bootstrap.version == 3) {
9803 this.el.addClass(this.validClass);
9805 this.inputEl().addClass('is-valid');
9808 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9810 var feedback = this.el.select('.form-control-feedback', true).first();
9813 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9814 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9819 this.fireEvent('valid', this);
9823 * Mark this field as invalid
9824 * @param {String} msg The validation message
9826 markInvalid : function(msg)
9828 if(!this.el || this.preventMark){ // not rendered
9832 this.el.removeClass([this.invalidClass, this.validClass]);
9833 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9835 var feedback = this.el.select('.form-control-feedback', true).first();
9838 this.el.select('.form-control-feedback', true).first().removeClass(
9839 [this.invalidFeedbackClass, this.validFeedbackClass]);
9846 if(this.allowBlank && !this.getRawValue().length){
9851 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9852 this.indicator.addClass('visible');
9854 if (Roo.bootstrap.version == 3) {
9855 this.el.addClass(this.invalidClass);
9857 this.inputEl().addClass('is-invalid');
9862 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9864 var feedback = this.el.select('.form-control-feedback', true).first();
9867 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9869 if(this.getValue().length || this.forceFeedback){
9870 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9877 this.fireEvent('invalid', this, msg);
9880 SafariOnKeyDown : function(event)
9882 // this is a workaround for a password hang bug on chrome/ webkit.
9883 if (this.inputEl().dom.type != 'password') {
9887 var isSelectAll = false;
9889 if(this.inputEl().dom.selectionEnd > 0){
9890 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9892 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9893 event.preventDefault();
9898 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9900 event.preventDefault();
9901 // this is very hacky as keydown always get's upper case.
9903 var cc = String.fromCharCode(event.getCharCode());
9904 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9908 adjustWidth : function(tag, w){
9909 tag = tag.toLowerCase();
9910 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9911 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9915 if(tag == 'textarea'){
9918 }else if(Roo.isOpera){
9922 if(tag == 'textarea'){
9930 setFieldLabel : function(v)
9936 if(this.indicatorEl()){
9937 var ar = this.el.select('label > span',true);
9939 if (ar.elements.length) {
9940 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9941 this.fieldLabel = v;
9945 var br = this.el.select('label',true);
9947 if(br.elements.length) {
9948 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9949 this.fieldLabel = v;
9953 Roo.log('Cannot Found any of label > span || label in input');
9957 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9958 this.fieldLabel = v;
9973 * @class Roo.bootstrap.TextArea
9974 * @extends Roo.bootstrap.Input
9975 * Bootstrap TextArea class
9976 * @cfg {Number} cols Specifies the visible width of a text area
9977 * @cfg {Number} rows Specifies the visible number of lines in a text area
9978 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9979 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9980 * @cfg {string} html text
9983 * Create a new TextArea
9984 * @param {Object} config The config object
9987 Roo.bootstrap.TextArea = function(config){
9988 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9992 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10002 getAutoCreate : function(){
10004 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10010 if(this.inputType != 'hidden'){
10011 cfg.cls = 'form-group' //input-group
10019 value : this.value || '',
10020 html: this.html || '',
10021 cls : 'form-control',
10022 placeholder : this.placeholder || ''
10026 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10027 input.maxLength = this.maxLength;
10031 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10035 input.cols = this.cols;
10038 if (this.readOnly) {
10039 input.readonly = true;
10043 input.name = this.name;
10047 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10051 ['xs','sm','md','lg'].map(function(size){
10052 if (settings[size]) {
10053 cfg.cls += ' col-' + size + '-' + settings[size];
10057 var inputblock = input;
10059 if(this.hasFeedback && !this.allowBlank){
10063 cls: 'glyphicon form-control-feedback'
10067 cls : 'has-feedback',
10076 if (this.before || this.after) {
10079 cls : 'input-group',
10083 inputblock.cn.push({
10085 cls : 'input-group-addon',
10090 inputblock.cn.push(input);
10092 if(this.hasFeedback && !this.allowBlank){
10093 inputblock.cls += ' has-feedback';
10094 inputblock.cn.push(feedback);
10098 inputblock.cn.push({
10100 cls : 'input-group-addon',
10107 if (align ==='left' && this.fieldLabel.length) {
10112 cls : 'control-label',
10113 html : this.fieldLabel
10124 if(this.labelWidth > 12){
10125 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10128 if(this.labelWidth < 13 && this.labelmd == 0){
10129 this.labelmd = this.labelWidth;
10132 if(this.labellg > 0){
10133 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10134 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10137 if(this.labelmd > 0){
10138 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10139 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10142 if(this.labelsm > 0){
10143 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10144 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10147 if(this.labelxs > 0){
10148 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10149 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10152 } else if ( this.fieldLabel.length) {
10157 //cls : 'input-group-addon',
10158 html : this.fieldLabel
10176 if (this.disabled) {
10177 input.disabled=true;
10184 * return the real textarea element.
10186 inputEl: function ()
10188 return this.el.select('textarea.form-control',true).first();
10192 * Clear any invalid styles/messages for this field
10194 clearInvalid : function()
10197 if(!this.el || this.preventMark){ // not rendered
10201 var label = this.el.select('label', true).first();
10202 var icon = this.el.select('i.fa-star', true).first();
10208 this.el.removeClass([ this.invalidClass, 'is-invalid']);
10210 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10212 var feedback = this.el.select('.form-control-feedback', true).first();
10215 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10220 this.fireEvent('valid', this);
10224 * Mark this field as valid
10226 markValid : function()
10228 if(!this.el || this.preventMark){ // not rendered
10232 this.el.removeClass([this.invalidClass, this.validClass, 'is-valid', 'is-invalid']);
10235 var feedback = this.el.select('.form-control-feedback', true).first();
10238 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10241 if(this.disabled || this.allowBlank){
10245 var label = this.el.select('label', true).first();
10246 var icon = this.el.select('i.fa-star', true).first();
10251 if (Roo.bootstrap.version == 3) {
10252 this.el.addClass(this.validClass);
10254 this.inputEl().addClass('is-valid');
10258 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10260 var feedback = this.el.select('.form-control-feedback', true).first();
10263 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10264 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10269 this.fireEvent('valid', this);
10273 * Mark this field as invalid
10274 * @param {String} msg The validation message
10276 markInvalid : function(msg)
10278 if(!this.el || this.preventMark){ // not rendered
10282 this.el.removeClass([this.invalidClass, this.validClass, 'is-valid', 'is-invalid']);
10284 var feedback = this.el.select('.form-control-feedback', true).first();
10287 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10290 if(this.disabled || this.allowBlank){
10294 var label = this.el.select('label', true).first();
10295 var icon = this.el.select('i.fa-star', true).first();
10297 if(!this.getValue().length && label && !icon){
10298 this.el.createChild({
10300 cls : 'text-danger fa fa-lg fa-star',
10301 tooltip : 'This field is required',
10302 style : 'margin-right:5px;'
10306 if (Roo.bootstrap.version == 3) {
10307 this.el.addClass(this.invalidClass);
10309 this.inputEl().addClass('is-invalid');
10312 // fixme ... this may be depricated need to test..
10313 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10315 var feedback = this.el.select('.form-control-feedback', true).first();
10318 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10320 if(this.getValue().length || this.forceFeedback){
10321 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10328 this.fireEvent('invalid', this, msg);
10336 * trigger field - base class for combo..
10341 * @class Roo.bootstrap.TriggerField
10342 * @extends Roo.bootstrap.Input
10343 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10344 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10345 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10346 * for which you can provide a custom implementation. For example:
10348 var trigger = new Roo.bootstrap.TriggerField();
10349 trigger.onTriggerClick = myTriggerFn;
10350 trigger.applyTo('my-field');
10353 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10354 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10355 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10356 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10357 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10360 * Create a new TriggerField.
10361 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10362 * to the base TextField)
10364 Roo.bootstrap.TriggerField = function(config){
10365 this.mimicing = false;
10366 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10369 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10371 * @cfg {String} triggerClass A CSS class to apply to the trigger
10374 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10379 * @cfg {Boolean} removable (true|false) special filter default false
10383 /** @cfg {Boolean} grow @hide */
10384 /** @cfg {Number} growMin @hide */
10385 /** @cfg {Number} growMax @hide */
10391 autoSize: Roo.emptyFn,
10395 deferHeight : true,
10398 actionMode : 'wrap',
10403 getAutoCreate : function(){
10405 var align = this.labelAlign || this.parentLabelAlign();
10410 cls: 'form-group' //input-group
10417 type : this.inputType,
10418 cls : 'form-control',
10419 autocomplete: 'new-password',
10420 placeholder : this.placeholder || ''
10424 input.name = this.name;
10427 input.cls += ' input-' + this.size;
10430 if (this.disabled) {
10431 input.disabled=true;
10434 var inputblock = input;
10436 if(this.hasFeedback && !this.allowBlank){
10440 cls: 'glyphicon form-control-feedback'
10443 if(this.removable && !this.editable && !this.tickable){
10445 cls : 'has-feedback',
10451 cls : 'roo-combo-removable-btn close'
10458 cls : 'has-feedback',
10467 if(this.removable && !this.editable && !this.tickable){
10469 cls : 'roo-removable',
10475 cls : 'roo-combo-removable-btn close'
10482 if (this.before || this.after) {
10485 cls : 'input-group',
10489 inputblock.cn.push({
10491 cls : 'input-group-addon input-group-prepend input-group-text',
10496 inputblock.cn.push(input);
10498 if(this.hasFeedback && !this.allowBlank){
10499 inputblock.cls += ' has-feedback';
10500 inputblock.cn.push(feedback);
10504 inputblock.cn.push({
10506 cls : 'input-group-addon input-group-append input-group-text',
10515 var ibwrap = inputblock;
10520 cls: 'roo-select2-choices',
10524 cls: 'roo-select2-search-field',
10536 cls: 'roo-select2-container input-group',
10541 cls: 'form-hidden-field'
10547 if(!this.multiple && this.showToggleBtn){
10553 if (this.caret != false) {
10556 cls: 'fa fa-' + this.caret
10563 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10568 cls: 'combobox-clear',
10582 combobox.cls += ' roo-select2-container-multi';
10586 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10587 tooltip : 'This field is required'
10589 if (Roo.bootstrap.version == 4) {
10592 style : 'display:none'
10597 if (align ==='left' && this.fieldLabel.length) {
10599 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10606 cls : 'control-label',
10607 html : this.fieldLabel
10619 var labelCfg = cfg.cn[1];
10620 var contentCfg = cfg.cn[2];
10622 if(this.indicatorpos == 'right'){
10627 cls : 'control-label',
10631 html : this.fieldLabel
10645 labelCfg = cfg.cn[0];
10646 contentCfg = cfg.cn[1];
10649 if(this.labelWidth > 12){
10650 labelCfg.style = "width: " + this.labelWidth + 'px';
10653 if(this.labelWidth < 13 && this.labelmd == 0){
10654 this.labelmd = this.labelWidth;
10657 if(this.labellg > 0){
10658 labelCfg.cls += ' col-lg-' + this.labellg;
10659 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10662 if(this.labelmd > 0){
10663 labelCfg.cls += ' col-md-' + this.labelmd;
10664 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10667 if(this.labelsm > 0){
10668 labelCfg.cls += ' col-sm-' + this.labelsm;
10669 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10672 if(this.labelxs > 0){
10673 labelCfg.cls += ' col-xs-' + this.labelxs;
10674 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10677 } else if ( this.fieldLabel.length) {
10678 // Roo.log(" label");
10683 //cls : 'input-group-addon',
10684 html : this.fieldLabel
10692 if(this.indicatorpos == 'right'){
10700 html : this.fieldLabel
10714 // Roo.log(" no label && no align");
10721 ['xs','sm','md','lg'].map(function(size){
10722 if (settings[size]) {
10723 cfg.cls += ' col-' + size + '-' + settings[size];
10734 onResize : function(w, h){
10735 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10736 // if(typeof w == 'number'){
10737 // var x = w - this.trigger.getWidth();
10738 // this.inputEl().setWidth(this.adjustWidth('input', x));
10739 // this.trigger.setStyle('left', x+'px');
10744 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10747 getResizeEl : function(){
10748 return this.inputEl();
10752 getPositionEl : function(){
10753 return this.inputEl();
10757 alignErrorIcon : function(){
10758 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10762 initEvents : function(){
10766 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10767 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10768 if(!this.multiple && this.showToggleBtn){
10769 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10770 if(this.hideTrigger){
10771 this.trigger.setDisplayed(false);
10773 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10777 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10780 if(this.removable && !this.editable && !this.tickable){
10781 var close = this.closeTriggerEl();
10784 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10785 close.on('click', this.removeBtnClick, this, close);
10789 //this.trigger.addClassOnOver('x-form-trigger-over');
10790 //this.trigger.addClassOnClick('x-form-trigger-click');
10793 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10797 closeTriggerEl : function()
10799 var close = this.el.select('.roo-combo-removable-btn', true).first();
10800 return close ? close : false;
10803 removeBtnClick : function(e, h, el)
10805 e.preventDefault();
10807 if(this.fireEvent("remove", this) !== false){
10809 this.fireEvent("afterremove", this)
10813 createList : function()
10815 this.list = Roo.get(document.body).createChild({
10816 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10817 cls: 'typeahead typeahead-long dropdown-menu',
10818 style: 'display:none'
10821 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10826 initTrigger : function(){
10831 onDestroy : function(){
10833 this.trigger.removeAllListeners();
10834 // this.trigger.remove();
10837 // this.wrap.remove();
10839 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10843 onFocus : function(){
10844 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10846 if(!this.mimicing){
10847 this.wrap.addClass('x-trigger-wrap-focus');
10848 this.mimicing = true;
10849 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10850 if(this.monitorTab){
10851 this.el.on("keydown", this.checkTab, this);
10858 checkTab : function(e){
10859 if(e.getKey() == e.TAB){
10860 this.triggerBlur();
10865 onBlur : function(){
10870 mimicBlur : function(e, t){
10872 if(!this.wrap.contains(t) && this.validateBlur()){
10873 this.triggerBlur();
10879 triggerBlur : function(){
10880 this.mimicing = false;
10881 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10882 if(this.monitorTab){
10883 this.el.un("keydown", this.checkTab, this);
10885 //this.wrap.removeClass('x-trigger-wrap-focus');
10886 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10890 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10891 validateBlur : function(e, t){
10896 onDisable : function(){
10897 this.inputEl().dom.disabled = true;
10898 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10900 // this.wrap.addClass('x-item-disabled');
10905 onEnable : function(){
10906 this.inputEl().dom.disabled = false;
10907 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10909 // this.el.removeClass('x-item-disabled');
10914 onShow : function(){
10915 var ae = this.getActionEl();
10918 ae.dom.style.display = '';
10919 ae.dom.style.visibility = 'visible';
10925 onHide : function(){
10926 var ae = this.getActionEl();
10927 ae.dom.style.display = 'none';
10931 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10932 * by an implementing function.
10934 * @param {EventObject} e
10936 onTriggerClick : Roo.emptyFn
10940 * Ext JS Library 1.1.1
10941 * Copyright(c) 2006-2007, Ext JS, LLC.
10943 * Originally Released Under LGPL - original licence link has changed is not relivant.
10946 * <script type="text/javascript">
10951 * @class Roo.data.SortTypes
10953 * Defines the default sorting (casting?) comparison functions used when sorting data.
10955 Roo.data.SortTypes = {
10957 * Default sort that does nothing
10958 * @param {Mixed} s The value being converted
10959 * @return {Mixed} The comparison value
10961 none : function(s){
10966 * The regular expression used to strip tags
10970 stripTagsRE : /<\/?[^>]+>/gi,
10973 * Strips all HTML tags to sort on text only
10974 * @param {Mixed} s The value being converted
10975 * @return {String} The comparison value
10977 asText : function(s){
10978 return String(s).replace(this.stripTagsRE, "");
10982 * Strips all HTML tags to sort on text only - Case insensitive
10983 * @param {Mixed} s The value being converted
10984 * @return {String} The comparison value
10986 asUCText : function(s){
10987 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10991 * Case insensitive string
10992 * @param {Mixed} s The value being converted
10993 * @return {String} The comparison value
10995 asUCString : function(s) {
10996 return String(s).toUpperCase();
11001 * @param {Mixed} s The value being converted
11002 * @return {Number} The comparison value
11004 asDate : function(s) {
11008 if(s instanceof Date){
11009 return s.getTime();
11011 return Date.parse(String(s));
11016 * @param {Mixed} s The value being converted
11017 * @return {Float} The comparison value
11019 asFloat : function(s) {
11020 var val = parseFloat(String(s).replace(/,/g, ""));
11029 * @param {Mixed} s The value being converted
11030 * @return {Number} The comparison value
11032 asInt : function(s) {
11033 var val = parseInt(String(s).replace(/,/g, ""));
11041 * Ext JS Library 1.1.1
11042 * Copyright(c) 2006-2007, Ext JS, LLC.
11044 * Originally Released Under LGPL - original licence link has changed is not relivant.
11047 * <script type="text/javascript">
11051 * @class Roo.data.Record
11052 * Instances of this class encapsulate both record <em>definition</em> information, and record
11053 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11054 * to access Records cached in an {@link Roo.data.Store} object.<br>
11056 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11057 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11060 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11062 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11063 * {@link #create}. The parameters are the same.
11064 * @param {Array} data An associative Array of data values keyed by the field name.
11065 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11066 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11067 * not specified an integer id is generated.
11069 Roo.data.Record = function(data, id){
11070 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11075 * Generate a constructor for a specific record layout.
11076 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11077 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11078 * Each field definition object may contain the following properties: <ul>
11079 * <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,
11080 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11081 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11082 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11083 * is being used, then this is a string containing the javascript expression to reference the data relative to
11084 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11085 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11086 * this may be omitted.</p></li>
11087 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11088 * <ul><li>auto (Default, implies no conversion)</li>
11093 * <li>date</li></ul></p></li>
11094 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11095 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11096 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11097 * by the Reader into an object that will be stored in the Record. It is passed the
11098 * following parameters:<ul>
11099 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11101 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11103 * <br>usage:<br><pre><code>
11104 var TopicRecord = Roo.data.Record.create(
11105 {name: 'title', mapping: 'topic_title'},
11106 {name: 'author', mapping: 'username'},
11107 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11108 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11109 {name: 'lastPoster', mapping: 'user2'},
11110 {name: 'excerpt', mapping: 'post_text'}
11113 var myNewRecord = new TopicRecord({
11114 title: 'Do my job please',
11117 lastPost: new Date(),
11118 lastPoster: 'Animal',
11119 excerpt: 'No way dude!'
11121 myStore.add(myNewRecord);
11126 Roo.data.Record.create = function(o){
11127 var f = function(){
11128 f.superclass.constructor.apply(this, arguments);
11130 Roo.extend(f, Roo.data.Record);
11131 var p = f.prototype;
11132 p.fields = new Roo.util.MixedCollection(false, function(field){
11135 for(var i = 0, len = o.length; i < len; i++){
11136 p.fields.add(new Roo.data.Field(o[i]));
11138 f.getField = function(name){
11139 return p.fields.get(name);
11144 Roo.data.Record.AUTO_ID = 1000;
11145 Roo.data.Record.EDIT = 'edit';
11146 Roo.data.Record.REJECT = 'reject';
11147 Roo.data.Record.COMMIT = 'commit';
11149 Roo.data.Record.prototype = {
11151 * Readonly flag - true if this record has been modified.
11160 join : function(store){
11161 this.store = store;
11165 * Set the named field to the specified value.
11166 * @param {String} name The name of the field to set.
11167 * @param {Object} value The value to set the field to.
11169 set : function(name, value){
11170 if(this.data[name] == value){
11174 if(!this.modified){
11175 this.modified = {};
11177 if(typeof this.modified[name] == 'undefined'){
11178 this.modified[name] = this.data[name];
11180 this.data[name] = value;
11181 if(!this.editing && this.store){
11182 this.store.afterEdit(this);
11187 * Get the value of the named field.
11188 * @param {String} name The name of the field to get the value of.
11189 * @return {Object} The value of the field.
11191 get : function(name){
11192 return this.data[name];
11196 beginEdit : function(){
11197 this.editing = true;
11198 this.modified = {};
11202 cancelEdit : function(){
11203 this.editing = false;
11204 delete this.modified;
11208 endEdit : function(){
11209 this.editing = false;
11210 if(this.dirty && this.store){
11211 this.store.afterEdit(this);
11216 * Usually called by the {@link Roo.data.Store} which owns the Record.
11217 * Rejects all changes made to the Record since either creation, or the last commit operation.
11218 * Modified fields are reverted to their original values.
11220 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11221 * of reject operations.
11223 reject : function(){
11224 var m = this.modified;
11226 if(typeof m[n] != "function"){
11227 this.data[n] = m[n];
11230 this.dirty = false;
11231 delete this.modified;
11232 this.editing = false;
11234 this.store.afterReject(this);
11239 * Usually called by the {@link Roo.data.Store} which owns the Record.
11240 * Commits all changes made to the Record since either creation, or the last commit operation.
11242 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11243 * of commit operations.
11245 commit : function(){
11246 this.dirty = false;
11247 delete this.modified;
11248 this.editing = false;
11250 this.store.afterCommit(this);
11255 hasError : function(){
11256 return this.error != null;
11260 clearError : function(){
11265 * Creates a copy of this record.
11266 * @param {String} id (optional) A new record id if you don't want to use this record's id
11269 copy : function(newId) {
11270 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11274 * Ext JS Library 1.1.1
11275 * Copyright(c) 2006-2007, Ext JS, LLC.
11277 * Originally Released Under LGPL - original licence link has changed is not relivant.
11280 * <script type="text/javascript">
11286 * @class Roo.data.Store
11287 * @extends Roo.util.Observable
11288 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11289 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11291 * 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
11292 * has no knowledge of the format of the data returned by the Proxy.<br>
11294 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11295 * instances from the data object. These records are cached and made available through accessor functions.
11297 * Creates a new Store.
11298 * @param {Object} config A config object containing the objects needed for the Store to access data,
11299 * and read the data into Records.
11301 Roo.data.Store = function(config){
11302 this.data = new Roo.util.MixedCollection(false);
11303 this.data.getKey = function(o){
11306 this.baseParams = {};
11308 this.paramNames = {
11313 "multisort" : "_multisort"
11316 if(config && config.data){
11317 this.inlineData = config.data;
11318 delete config.data;
11321 Roo.apply(this, config);
11323 if(this.reader){ // reader passed
11324 this.reader = Roo.factory(this.reader, Roo.data);
11325 this.reader.xmodule = this.xmodule || false;
11326 if(!this.recordType){
11327 this.recordType = this.reader.recordType;
11329 if(this.reader.onMetaChange){
11330 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11334 if(this.recordType){
11335 this.fields = this.recordType.prototype.fields;
11337 this.modified = [];
11341 * @event datachanged
11342 * Fires when the data cache has changed, and a widget which is using this Store
11343 * as a Record cache should refresh its view.
11344 * @param {Store} this
11346 datachanged : true,
11348 * @event metachange
11349 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11350 * @param {Store} this
11351 * @param {Object} meta The JSON metadata
11356 * Fires when Records have been added to the Store
11357 * @param {Store} this
11358 * @param {Roo.data.Record[]} records The array of Records added
11359 * @param {Number} index The index at which the record(s) were added
11364 * Fires when a Record has been removed from the Store
11365 * @param {Store} this
11366 * @param {Roo.data.Record} record The Record that was removed
11367 * @param {Number} index The index at which the record was removed
11372 * Fires when a Record has been updated
11373 * @param {Store} this
11374 * @param {Roo.data.Record} record The Record that was updated
11375 * @param {String} operation The update operation being performed. Value may be one of:
11377 Roo.data.Record.EDIT
11378 Roo.data.Record.REJECT
11379 Roo.data.Record.COMMIT
11385 * Fires when the data cache has been cleared.
11386 * @param {Store} this
11390 * @event beforeload
11391 * Fires before a request is made for a new data object. If the beforeload handler returns false
11392 * the load action will be canceled.
11393 * @param {Store} this
11394 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11398 * @event beforeloadadd
11399 * Fires after a new set of Records has been loaded.
11400 * @param {Store} this
11401 * @param {Roo.data.Record[]} records The Records that were loaded
11402 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11404 beforeloadadd : true,
11407 * Fires after a new set of Records has been loaded, before they are added to the store.
11408 * @param {Store} this
11409 * @param {Roo.data.Record[]} records The Records that were loaded
11410 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11411 * @params {Object} return from reader
11415 * @event loadexception
11416 * Fires if an exception occurs in the Proxy during loading.
11417 * Called with the signature of the Proxy's "loadexception" event.
11418 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11421 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11422 * @param {Object} load options
11423 * @param {Object} jsonData from your request (normally this contains the Exception)
11425 loadexception : true
11429 this.proxy = Roo.factory(this.proxy, Roo.data);
11430 this.proxy.xmodule = this.xmodule || false;
11431 this.relayEvents(this.proxy, ["loadexception"]);
11433 this.sortToggle = {};
11434 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11436 Roo.data.Store.superclass.constructor.call(this);
11438 if(this.inlineData){
11439 this.loadData(this.inlineData);
11440 delete this.inlineData;
11444 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11446 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11447 * without a remote query - used by combo/forms at present.
11451 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11454 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11457 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11458 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11461 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11462 * on any HTTP request
11465 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11468 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11472 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11473 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11475 remoteSort : false,
11478 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11479 * loaded or when a record is removed. (defaults to false).
11481 pruneModifiedRecords : false,
11484 lastOptions : null,
11487 * Add Records to the Store and fires the add event.
11488 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11490 add : function(records){
11491 records = [].concat(records);
11492 for(var i = 0, len = records.length; i < len; i++){
11493 records[i].join(this);
11495 var index = this.data.length;
11496 this.data.addAll(records);
11497 this.fireEvent("add", this, records, index);
11501 * Remove a Record from the Store and fires the remove event.
11502 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11504 remove : function(record){
11505 var index = this.data.indexOf(record);
11506 this.data.removeAt(index);
11508 if(this.pruneModifiedRecords){
11509 this.modified.remove(record);
11511 this.fireEvent("remove", this, record, index);
11515 * Remove all Records from the Store and fires the clear event.
11517 removeAll : function(){
11519 if(this.pruneModifiedRecords){
11520 this.modified = [];
11522 this.fireEvent("clear", this);
11526 * Inserts Records to the Store at the given index and fires the add event.
11527 * @param {Number} index The start index at which to insert the passed Records.
11528 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11530 insert : function(index, records){
11531 records = [].concat(records);
11532 for(var i = 0, len = records.length; i < len; i++){
11533 this.data.insert(index, records[i]);
11534 records[i].join(this);
11536 this.fireEvent("add", this, records, index);
11540 * Get the index within the cache of the passed Record.
11541 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11542 * @return {Number} The index of the passed Record. Returns -1 if not found.
11544 indexOf : function(record){
11545 return this.data.indexOf(record);
11549 * Get the index within the cache of the Record with the passed id.
11550 * @param {String} id The id of the Record to find.
11551 * @return {Number} The index of the Record. Returns -1 if not found.
11553 indexOfId : function(id){
11554 return this.data.indexOfKey(id);
11558 * Get the Record with the specified id.
11559 * @param {String} id The id of the Record to find.
11560 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11562 getById : function(id){
11563 return this.data.key(id);
11567 * Get the Record at the specified index.
11568 * @param {Number} index The index of the Record to find.
11569 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11571 getAt : function(index){
11572 return this.data.itemAt(index);
11576 * Returns a range of Records between specified indices.
11577 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11578 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11579 * @return {Roo.data.Record[]} An array of Records
11581 getRange : function(start, end){
11582 return this.data.getRange(start, end);
11586 storeOptions : function(o){
11587 o = Roo.apply({}, o);
11590 this.lastOptions = o;
11594 * Loads the Record cache from the configured Proxy using the configured Reader.
11596 * If using remote paging, then the first load call must specify the <em>start</em>
11597 * and <em>limit</em> properties in the options.params property to establish the initial
11598 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11600 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11601 * and this call will return before the new data has been loaded. Perform any post-processing
11602 * in a callback function, or in a "load" event handler.</strong>
11604 * @param {Object} options An object containing properties which control loading options:<ul>
11605 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11606 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11607 * passed the following arguments:<ul>
11608 * <li>r : Roo.data.Record[]</li>
11609 * <li>options: Options object from the load call</li>
11610 * <li>success: Boolean success indicator</li></ul></li>
11611 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11612 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11615 load : function(options){
11616 options = options || {};
11617 if(this.fireEvent("beforeload", this, options) !== false){
11618 this.storeOptions(options);
11619 var p = Roo.apply(options.params || {}, this.baseParams);
11620 // if meta was not loaded from remote source.. try requesting it.
11621 if (!this.reader.metaFromRemote) {
11622 p._requestMeta = 1;
11624 if(this.sortInfo && this.remoteSort){
11625 var pn = this.paramNames;
11626 p[pn["sort"]] = this.sortInfo.field;
11627 p[pn["dir"]] = this.sortInfo.direction;
11629 if (this.multiSort) {
11630 var pn = this.paramNames;
11631 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11634 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11639 * Reloads the Record cache from the configured Proxy using the configured Reader and
11640 * the options from the last load operation performed.
11641 * @param {Object} options (optional) An object containing properties which may override the options
11642 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11643 * the most recently used options are reused).
11645 reload : function(options){
11646 this.load(Roo.applyIf(options||{}, this.lastOptions));
11650 // Called as a callback by the Reader during a load operation.
11651 loadRecords : function(o, options, success){
11652 if(!o || success === false){
11653 if(success !== false){
11654 this.fireEvent("load", this, [], options, o);
11656 if(options.callback){
11657 options.callback.call(options.scope || this, [], options, false);
11661 // if data returned failure - throw an exception.
11662 if (o.success === false) {
11663 // show a message if no listener is registered.
11664 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11665 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11667 // loadmask wil be hooked into this..
11668 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11671 var r = o.records, t = o.totalRecords || r.length;
11673 this.fireEvent("beforeloadadd", this, r, options, o);
11675 if(!options || options.add !== true){
11676 if(this.pruneModifiedRecords){
11677 this.modified = [];
11679 for(var i = 0, len = r.length; i < len; i++){
11683 this.data = this.snapshot;
11684 delete this.snapshot;
11687 this.data.addAll(r);
11688 this.totalLength = t;
11690 this.fireEvent("datachanged", this);
11692 this.totalLength = Math.max(t, this.data.length+r.length);
11696 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11698 var e = new Roo.data.Record({});
11700 e.set(this.parent.displayField, this.parent.emptyTitle);
11701 e.set(this.parent.valueField, '');
11706 this.fireEvent("load", this, r, options, o);
11707 if(options.callback){
11708 options.callback.call(options.scope || this, r, options, true);
11714 * Loads data from a passed data block. A Reader which understands the format of the data
11715 * must have been configured in the constructor.
11716 * @param {Object} data The data block from which to read the Records. The format of the data expected
11717 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11718 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11720 loadData : function(o, append){
11721 var r = this.reader.readRecords(o);
11722 this.loadRecords(r, {add: append}, true);
11726 * Gets the number of cached records.
11728 * <em>If using paging, this may not be the total size of the dataset. If the data object
11729 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11730 * the data set size</em>
11732 getCount : function(){
11733 return this.data.length || 0;
11737 * Gets the total number of records in the dataset as returned by the server.
11739 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11740 * the dataset size</em>
11742 getTotalCount : function(){
11743 return this.totalLength || 0;
11747 * Returns the sort state of the Store as an object with two properties:
11749 field {String} The name of the field by which the Records are sorted
11750 direction {String} The sort order, "ASC" or "DESC"
11753 getSortState : function(){
11754 return this.sortInfo;
11758 applySort : function(){
11759 if(this.sortInfo && !this.remoteSort){
11760 var s = this.sortInfo, f = s.field;
11761 var st = this.fields.get(f).sortType;
11762 var fn = function(r1, r2){
11763 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11764 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11766 this.data.sort(s.direction, fn);
11767 if(this.snapshot && this.snapshot != this.data){
11768 this.snapshot.sort(s.direction, fn);
11774 * Sets the default sort column and order to be used by the next load operation.
11775 * @param {String} fieldName The name of the field to sort by.
11776 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11778 setDefaultSort : function(field, dir){
11779 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11783 * Sort the Records.
11784 * If remote sorting is used, the sort is performed on the server, and the cache is
11785 * reloaded. If local sorting is used, the cache is sorted internally.
11786 * @param {String} fieldName The name of the field to sort by.
11787 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11789 sort : function(fieldName, dir){
11790 var f = this.fields.get(fieldName);
11792 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11794 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11795 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11800 this.sortToggle[f.name] = dir;
11801 this.sortInfo = {field: f.name, direction: dir};
11802 if(!this.remoteSort){
11804 this.fireEvent("datachanged", this);
11806 this.load(this.lastOptions);
11811 * Calls the specified function for each of the Records in the cache.
11812 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11813 * Returning <em>false</em> aborts and exits the iteration.
11814 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11816 each : function(fn, scope){
11817 this.data.each(fn, scope);
11821 * Gets all records modified since the last commit. Modified records are persisted across load operations
11822 * (e.g., during paging).
11823 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11825 getModifiedRecords : function(){
11826 return this.modified;
11830 createFilterFn : function(property, value, anyMatch){
11831 if(!value.exec){ // not a regex
11832 value = String(value);
11833 if(value.length == 0){
11836 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11838 return function(r){
11839 return value.test(r.data[property]);
11844 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11845 * @param {String} property A field on your records
11846 * @param {Number} start The record index to start at (defaults to 0)
11847 * @param {Number} end The last record index to include (defaults to length - 1)
11848 * @return {Number} The sum
11850 sum : function(property, start, end){
11851 var rs = this.data.items, v = 0;
11852 start = start || 0;
11853 end = (end || end === 0) ? end : rs.length-1;
11855 for(var i = start; i <= end; i++){
11856 v += (rs[i].data[property] || 0);
11862 * Filter the records by a specified property.
11863 * @param {String} field A field on your records
11864 * @param {String/RegExp} value Either a string that the field
11865 * should start with or a RegExp to test against the field
11866 * @param {Boolean} anyMatch True to match any part not just the beginning
11868 filter : function(property, value, anyMatch){
11869 var fn = this.createFilterFn(property, value, anyMatch);
11870 return fn ? this.filterBy(fn) : this.clearFilter();
11874 * Filter by a function. The specified function will be called with each
11875 * record in this data source. If the function returns true the record is included,
11876 * otherwise it is filtered.
11877 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11878 * @param {Object} scope (optional) The scope of the function (defaults to this)
11880 filterBy : function(fn, scope){
11881 this.snapshot = this.snapshot || this.data;
11882 this.data = this.queryBy(fn, scope||this);
11883 this.fireEvent("datachanged", this);
11887 * Query the records by a specified property.
11888 * @param {String} field A field on your records
11889 * @param {String/RegExp} value Either a string that the field
11890 * should start with or a RegExp to test against the field
11891 * @param {Boolean} anyMatch True to match any part not just the beginning
11892 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11894 query : function(property, value, anyMatch){
11895 var fn = this.createFilterFn(property, value, anyMatch);
11896 return fn ? this.queryBy(fn) : this.data.clone();
11900 * Query by a function. The specified function will be called with each
11901 * record in this data source. If the function returns true the record is included
11903 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11904 * @param {Object} scope (optional) The scope of the function (defaults to this)
11905 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11907 queryBy : function(fn, scope){
11908 var data = this.snapshot || this.data;
11909 return data.filterBy(fn, scope||this);
11913 * Collects unique values for a particular dataIndex from this store.
11914 * @param {String} dataIndex The property to collect
11915 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11916 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11917 * @return {Array} An array of the unique values
11919 collect : function(dataIndex, allowNull, bypassFilter){
11920 var d = (bypassFilter === true && this.snapshot) ?
11921 this.snapshot.items : this.data.items;
11922 var v, sv, r = [], l = {};
11923 for(var i = 0, len = d.length; i < len; i++){
11924 v = d[i].data[dataIndex];
11926 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11935 * Revert to a view of the Record cache with no filtering applied.
11936 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11938 clearFilter : function(suppressEvent){
11939 if(this.snapshot && this.snapshot != this.data){
11940 this.data = this.snapshot;
11941 delete this.snapshot;
11942 if(suppressEvent !== true){
11943 this.fireEvent("datachanged", this);
11949 afterEdit : function(record){
11950 if(this.modified.indexOf(record) == -1){
11951 this.modified.push(record);
11953 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11957 afterReject : function(record){
11958 this.modified.remove(record);
11959 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11963 afterCommit : function(record){
11964 this.modified.remove(record);
11965 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11969 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11970 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11972 commitChanges : function(){
11973 var m = this.modified.slice(0);
11974 this.modified = [];
11975 for(var i = 0, len = m.length; i < len; i++){
11981 * Cancel outstanding changes on all changed records.
11983 rejectChanges : function(){
11984 var m = this.modified.slice(0);
11985 this.modified = [];
11986 for(var i = 0, len = m.length; i < len; i++){
11991 onMetaChange : function(meta, rtype, o){
11992 this.recordType = rtype;
11993 this.fields = rtype.prototype.fields;
11994 delete this.snapshot;
11995 this.sortInfo = meta.sortInfo || this.sortInfo;
11996 this.modified = [];
11997 this.fireEvent('metachange', this, this.reader.meta);
12000 moveIndex : function(data, type)
12002 var index = this.indexOf(data);
12004 var newIndex = index + type;
12008 this.insert(newIndex, data);
12013 * Ext JS Library 1.1.1
12014 * Copyright(c) 2006-2007, Ext JS, LLC.
12016 * Originally Released Under LGPL - original licence link has changed is not relivant.
12019 * <script type="text/javascript">
12023 * @class Roo.data.SimpleStore
12024 * @extends Roo.data.Store
12025 * Small helper class to make creating Stores from Array data easier.
12026 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12027 * @cfg {Array} fields An array of field definition objects, or field name strings.
12028 * @cfg {Array} data The multi-dimensional array of data
12030 * @param {Object} config
12032 Roo.data.SimpleStore = function(config){
12033 Roo.data.SimpleStore.superclass.constructor.call(this, {
12035 reader: new Roo.data.ArrayReader({
12038 Roo.data.Record.create(config.fields)
12040 proxy : new Roo.data.MemoryProxy(config.data)
12044 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12046 * Ext JS Library 1.1.1
12047 * Copyright(c) 2006-2007, Ext JS, LLC.
12049 * Originally Released Under LGPL - original licence link has changed is not relivant.
12052 * <script type="text/javascript">
12057 * @extends Roo.data.Store
12058 * @class Roo.data.JsonStore
12059 * Small helper class to make creating Stores for JSON data easier. <br/>
12061 var store = new Roo.data.JsonStore({
12062 url: 'get-images.php',
12064 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12067 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12068 * JsonReader and HttpProxy (unless inline data is provided).</b>
12069 * @cfg {Array} fields An array of field definition objects, or field name strings.
12071 * @param {Object} config
12073 Roo.data.JsonStore = function(c){
12074 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12075 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12076 reader: new Roo.data.JsonReader(c, c.fields)
12079 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12081 * Ext JS Library 1.1.1
12082 * Copyright(c) 2006-2007, Ext JS, LLC.
12084 * Originally Released Under LGPL - original licence link has changed is not relivant.
12087 * <script type="text/javascript">
12091 Roo.data.Field = function(config){
12092 if(typeof config == "string"){
12093 config = {name: config};
12095 Roo.apply(this, config);
12098 this.type = "auto";
12101 var st = Roo.data.SortTypes;
12102 // named sortTypes are supported, here we look them up
12103 if(typeof this.sortType == "string"){
12104 this.sortType = st[this.sortType];
12107 // set default sortType for strings and dates
12108 if(!this.sortType){
12111 this.sortType = st.asUCString;
12114 this.sortType = st.asDate;
12117 this.sortType = st.none;
12122 var stripRe = /[\$,%]/g;
12124 // prebuilt conversion function for this field, instead of
12125 // switching every time we're reading a value
12127 var cv, dateFormat = this.dateFormat;
12132 cv = function(v){ return v; };
12135 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12139 return v !== undefined && v !== null && v !== '' ?
12140 parseInt(String(v).replace(stripRe, ""), 10) : '';
12145 return v !== undefined && v !== null && v !== '' ?
12146 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12151 cv = function(v){ return v === true || v === "true" || v == 1; };
12158 if(v instanceof Date){
12162 if(dateFormat == "timestamp"){
12163 return new Date(v*1000);
12165 return Date.parseDate(v, dateFormat);
12167 var parsed = Date.parse(v);
12168 return parsed ? new Date(parsed) : null;
12177 Roo.data.Field.prototype = {
12185 * Ext JS Library 1.1.1
12186 * Copyright(c) 2006-2007, Ext JS, LLC.
12188 * Originally Released Under LGPL - original licence link has changed is not relivant.
12191 * <script type="text/javascript">
12194 // Base class for reading structured data from a data source. This class is intended to be
12195 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12198 * @class Roo.data.DataReader
12199 * Base class for reading structured data from a data source. This class is intended to be
12200 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12203 Roo.data.DataReader = function(meta, recordType){
12207 this.recordType = recordType instanceof Array ?
12208 Roo.data.Record.create(recordType) : recordType;
12211 Roo.data.DataReader.prototype = {
12213 * Create an empty record
12214 * @param {Object} data (optional) - overlay some values
12215 * @return {Roo.data.Record} record created.
12217 newRow : function(d) {
12219 this.recordType.prototype.fields.each(function(c) {
12221 case 'int' : da[c.name] = 0; break;
12222 case 'date' : da[c.name] = new Date(); break;
12223 case 'float' : da[c.name] = 0.0; break;
12224 case 'boolean' : da[c.name] = false; break;
12225 default : da[c.name] = ""; break;
12229 return new this.recordType(Roo.apply(da, d));
12234 * Ext JS Library 1.1.1
12235 * Copyright(c) 2006-2007, Ext JS, LLC.
12237 * Originally Released Under LGPL - original licence link has changed is not relivant.
12240 * <script type="text/javascript">
12244 * @class Roo.data.DataProxy
12245 * @extends Roo.data.Observable
12246 * This class is an abstract base class for implementations which provide retrieval of
12247 * unformatted data objects.<br>
12249 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12250 * (of the appropriate type which knows how to parse the data object) to provide a block of
12251 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12253 * Custom implementations must implement the load method as described in
12254 * {@link Roo.data.HttpProxy#load}.
12256 Roo.data.DataProxy = function(){
12259 * @event beforeload
12260 * Fires before a network request is made to retrieve a data object.
12261 * @param {Object} This DataProxy object.
12262 * @param {Object} params The params parameter to the load function.
12267 * Fires before the load method's callback is called.
12268 * @param {Object} This DataProxy object.
12269 * @param {Object} o The data object.
12270 * @param {Object} arg The callback argument object passed to the load function.
12274 * @event loadexception
12275 * Fires if an Exception occurs during data retrieval.
12276 * @param {Object} This DataProxy object.
12277 * @param {Object} o The data object.
12278 * @param {Object} arg The callback argument object passed to the load function.
12279 * @param {Object} e The Exception.
12281 loadexception : true
12283 Roo.data.DataProxy.superclass.constructor.call(this);
12286 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12289 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12293 * Ext JS Library 1.1.1
12294 * Copyright(c) 2006-2007, Ext JS, LLC.
12296 * Originally Released Under LGPL - original licence link has changed is not relivant.
12299 * <script type="text/javascript">
12302 * @class Roo.data.MemoryProxy
12303 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12304 * to the Reader when its load method is called.
12306 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12308 Roo.data.MemoryProxy = function(data){
12312 Roo.data.MemoryProxy.superclass.constructor.call(this);
12316 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12319 * Load data from the requested source (in this case an in-memory
12320 * data object passed to the constructor), read the data object into
12321 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12322 * process that block using the passed callback.
12323 * @param {Object} params This parameter is not used by the MemoryProxy class.
12324 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12325 * object into a block of Roo.data.Records.
12326 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12327 * The function must be passed <ul>
12328 * <li>The Record block object</li>
12329 * <li>The "arg" argument from the load function</li>
12330 * <li>A boolean success indicator</li>
12332 * @param {Object} scope The scope in which to call the callback
12333 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12335 load : function(params, reader, callback, scope, arg){
12336 params = params || {};
12339 result = reader.readRecords(this.data);
12341 this.fireEvent("loadexception", this, arg, null, e);
12342 callback.call(scope, null, arg, false);
12345 callback.call(scope, result, arg, true);
12349 update : function(params, records){
12354 * Ext JS Library 1.1.1
12355 * Copyright(c) 2006-2007, Ext JS, LLC.
12357 * Originally Released Under LGPL - original licence link has changed is not relivant.
12360 * <script type="text/javascript">
12363 * @class Roo.data.HttpProxy
12364 * @extends Roo.data.DataProxy
12365 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12366 * configured to reference a certain URL.<br><br>
12368 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12369 * from which the running page was served.<br><br>
12371 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12373 * Be aware that to enable the browser to parse an XML document, the server must set
12374 * the Content-Type header in the HTTP response to "text/xml".
12376 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12377 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12378 * will be used to make the request.
12380 Roo.data.HttpProxy = function(conn){
12381 Roo.data.HttpProxy.superclass.constructor.call(this);
12382 // is conn a conn config or a real conn?
12384 this.useAjax = !conn || !conn.events;
12388 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12389 // thse are take from connection...
12392 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12395 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12396 * extra parameters to each request made by this object. (defaults to undefined)
12399 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12400 * to each request made by this object. (defaults to undefined)
12403 * @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)
12406 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12409 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12415 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12419 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12420 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12421 * a finer-grained basis than the DataProxy events.
12423 getConnection : function(){
12424 return this.useAjax ? Roo.Ajax : this.conn;
12428 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12429 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12430 * process that block using the passed callback.
12431 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12432 * for the request to the remote server.
12433 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12434 * object into a block of Roo.data.Records.
12435 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12436 * The function must be passed <ul>
12437 * <li>The Record block object</li>
12438 * <li>The "arg" argument from the load function</li>
12439 * <li>A boolean success indicator</li>
12441 * @param {Object} scope The scope in which to call the callback
12442 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12444 load : function(params, reader, callback, scope, arg){
12445 if(this.fireEvent("beforeload", this, params) !== false){
12447 params : params || {},
12449 callback : callback,
12454 callback : this.loadResponse,
12458 Roo.applyIf(o, this.conn);
12459 if(this.activeRequest){
12460 Roo.Ajax.abort(this.activeRequest);
12462 this.activeRequest = Roo.Ajax.request(o);
12464 this.conn.request(o);
12467 callback.call(scope||this, null, arg, false);
12472 loadResponse : function(o, success, response){
12473 delete this.activeRequest;
12475 this.fireEvent("loadexception", this, o, response);
12476 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12481 result = o.reader.read(response);
12483 this.fireEvent("loadexception", this, o, response, e);
12484 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12488 this.fireEvent("load", this, o, o.request.arg);
12489 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12493 update : function(dataSet){
12498 updateResponse : function(dataSet){
12503 * Ext JS Library 1.1.1
12504 * Copyright(c) 2006-2007, Ext JS, LLC.
12506 * Originally Released Under LGPL - original licence link has changed is not relivant.
12509 * <script type="text/javascript">
12513 * @class Roo.data.ScriptTagProxy
12514 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12515 * other than the originating domain of the running page.<br><br>
12517 * <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
12518 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12520 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12521 * source code that is used as the source inside a <script> tag.<br><br>
12523 * In order for the browser to process the returned data, the server must wrap the data object
12524 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12525 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12526 * depending on whether the callback name was passed:
12529 boolean scriptTag = false;
12530 String cb = request.getParameter("callback");
12533 response.setContentType("text/javascript");
12535 response.setContentType("application/x-json");
12537 Writer out = response.getWriter();
12539 out.write(cb + "(");
12541 out.print(dataBlock.toJsonString());
12548 * @param {Object} config A configuration object.
12550 Roo.data.ScriptTagProxy = function(config){
12551 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12552 Roo.apply(this, config);
12553 this.head = document.getElementsByTagName("head")[0];
12556 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12558 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12560 * @cfg {String} url The URL from which to request the data object.
12563 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12567 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12568 * the server the name of the callback function set up by the load call to process the returned data object.
12569 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12570 * javascript output which calls this named function passing the data object as its only parameter.
12572 callbackParam : "callback",
12574 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12575 * name to the request.
12580 * Load data from the configured URL, read the data object into
12581 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12582 * process that block using the passed callback.
12583 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12584 * for the request to the remote server.
12585 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12586 * object into a block of Roo.data.Records.
12587 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12588 * The function must be passed <ul>
12589 * <li>The Record block object</li>
12590 * <li>The "arg" argument from the load function</li>
12591 * <li>A boolean success indicator</li>
12593 * @param {Object} scope The scope in which to call the callback
12594 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12596 load : function(params, reader, callback, scope, arg){
12597 if(this.fireEvent("beforeload", this, params) !== false){
12599 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12601 var url = this.url;
12602 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12604 url += "&_dc=" + (new Date().getTime());
12606 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12609 cb : "stcCallback"+transId,
12610 scriptId : "stcScript"+transId,
12614 callback : callback,
12620 window[trans.cb] = function(o){
12621 conn.handleResponse(o, trans);
12624 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12626 if(this.autoAbort !== false){
12630 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12632 var script = document.createElement("script");
12633 script.setAttribute("src", url);
12634 script.setAttribute("type", "text/javascript");
12635 script.setAttribute("id", trans.scriptId);
12636 this.head.appendChild(script);
12638 this.trans = trans;
12640 callback.call(scope||this, null, arg, false);
12645 isLoading : function(){
12646 return this.trans ? true : false;
12650 * Abort the current server request.
12652 abort : function(){
12653 if(this.isLoading()){
12654 this.destroyTrans(this.trans);
12659 destroyTrans : function(trans, isLoaded){
12660 this.head.removeChild(document.getElementById(trans.scriptId));
12661 clearTimeout(trans.timeoutId);
12663 window[trans.cb] = undefined;
12665 delete window[trans.cb];
12668 // if hasn't been loaded, wait for load to remove it to prevent script error
12669 window[trans.cb] = function(){
12670 window[trans.cb] = undefined;
12672 delete window[trans.cb];
12679 handleResponse : function(o, trans){
12680 this.trans = false;
12681 this.destroyTrans(trans, true);
12684 result = trans.reader.readRecords(o);
12686 this.fireEvent("loadexception", this, o, trans.arg, e);
12687 trans.callback.call(trans.scope||window, null, trans.arg, false);
12690 this.fireEvent("load", this, o, trans.arg);
12691 trans.callback.call(trans.scope||window, result, trans.arg, true);
12695 handleFailure : function(trans){
12696 this.trans = false;
12697 this.destroyTrans(trans, false);
12698 this.fireEvent("loadexception", this, null, trans.arg);
12699 trans.callback.call(trans.scope||window, null, trans.arg, false);
12703 * Ext JS Library 1.1.1
12704 * Copyright(c) 2006-2007, Ext JS, LLC.
12706 * Originally Released Under LGPL - original licence link has changed is not relivant.
12709 * <script type="text/javascript">
12713 * @class Roo.data.JsonReader
12714 * @extends Roo.data.DataReader
12715 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12716 * based on mappings in a provided Roo.data.Record constructor.
12718 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12719 * in the reply previously.
12724 var RecordDef = Roo.data.Record.create([
12725 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12726 {name: 'occupation'} // This field will use "occupation" as the mapping.
12728 var myReader = new Roo.data.JsonReader({
12729 totalProperty: "results", // The property which contains the total dataset size (optional)
12730 root: "rows", // The property which contains an Array of row objects
12731 id: "id" // The property within each row object that provides an ID for the record (optional)
12735 * This would consume a JSON file like this:
12737 { 'results': 2, 'rows': [
12738 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12739 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12742 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12743 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12744 * paged from the remote server.
12745 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12746 * @cfg {String} root name of the property which contains the Array of row objects.
12747 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12748 * @cfg {Array} fields Array of field definition objects
12750 * Create a new JsonReader
12751 * @param {Object} meta Metadata configuration options
12752 * @param {Object} recordType Either an Array of field definition objects,
12753 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12755 Roo.data.JsonReader = function(meta, recordType){
12758 // set some defaults:
12759 Roo.applyIf(meta, {
12760 totalProperty: 'total',
12761 successProperty : 'success',
12766 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12768 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12771 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12772 * Used by Store query builder to append _requestMeta to params.
12775 metaFromRemote : false,
12777 * This method is only used by a DataProxy which has retrieved data from a remote server.
12778 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12779 * @return {Object} data A data block which is used by an Roo.data.Store object as
12780 * a cache of Roo.data.Records.
12782 read : function(response){
12783 var json = response.responseText;
12785 var o = /* eval:var:o */ eval("("+json+")");
12787 throw {message: "JsonReader.read: Json object not found"};
12793 this.metaFromRemote = true;
12794 this.meta = o.metaData;
12795 this.recordType = Roo.data.Record.create(o.metaData.fields);
12796 this.onMetaChange(this.meta, this.recordType, o);
12798 return this.readRecords(o);
12801 // private function a store will implement
12802 onMetaChange : function(meta, recordType, o){
12809 simpleAccess: function(obj, subsc) {
12816 getJsonAccessor: function(){
12818 return function(expr) {
12820 return(re.test(expr))
12821 ? new Function("obj", "return obj." + expr)
12826 return Roo.emptyFn;
12831 * Create a data block containing Roo.data.Records from an XML document.
12832 * @param {Object} o An object which contains an Array of row objects in the property specified
12833 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12834 * which contains the total size of the dataset.
12835 * @return {Object} data A data block which is used by an Roo.data.Store object as
12836 * a cache of Roo.data.Records.
12838 readRecords : function(o){
12840 * After any data loads, the raw JSON data is available for further custom processing.
12844 var s = this.meta, Record = this.recordType,
12845 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12847 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12849 if(s.totalProperty) {
12850 this.getTotal = this.getJsonAccessor(s.totalProperty);
12852 if(s.successProperty) {
12853 this.getSuccess = this.getJsonAccessor(s.successProperty);
12855 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12857 var g = this.getJsonAccessor(s.id);
12858 this.getId = function(rec) {
12860 return (r === undefined || r === "") ? null : r;
12863 this.getId = function(){return null;};
12866 for(var jj = 0; jj < fl; jj++){
12868 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12869 this.ef[jj] = this.getJsonAccessor(map);
12873 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12874 if(s.totalProperty){
12875 var vt = parseInt(this.getTotal(o), 10);
12880 if(s.successProperty){
12881 var vs = this.getSuccess(o);
12882 if(vs === false || vs === 'false'){
12887 for(var i = 0; i < c; i++){
12890 var id = this.getId(n);
12891 for(var j = 0; j < fl; j++){
12893 var v = this.ef[j](n);
12895 Roo.log('missing convert for ' + f.name);
12899 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12901 var record = new Record(values, id);
12903 records[i] = record;
12909 totalRecords : totalRecords
12914 * Ext JS Library 1.1.1
12915 * Copyright(c) 2006-2007, Ext JS, LLC.
12917 * Originally Released Under LGPL - original licence link has changed is not relivant.
12920 * <script type="text/javascript">
12924 * @class Roo.data.ArrayReader
12925 * @extends Roo.data.DataReader
12926 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12927 * Each element of that Array represents a row of data fields. The
12928 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12929 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12933 var RecordDef = Roo.data.Record.create([
12934 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12935 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12937 var myReader = new Roo.data.ArrayReader({
12938 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12942 * This would consume an Array like this:
12944 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12946 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12948 * Create a new JsonReader
12949 * @param {Object} meta Metadata configuration options.
12950 * @param {Object} recordType Either an Array of field definition objects
12951 * as specified to {@link Roo.data.Record#create},
12952 * or an {@link Roo.data.Record} object
12953 * created using {@link Roo.data.Record#create}.
12955 Roo.data.ArrayReader = function(meta, recordType){
12956 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12959 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12961 * Create a data block containing Roo.data.Records from an XML document.
12962 * @param {Object} o An Array of row objects which represents the dataset.
12963 * @return {Object} data A data block which is used by an Roo.data.Store object as
12964 * a cache of Roo.data.Records.
12966 readRecords : function(o){
12967 var sid = this.meta ? this.meta.id : null;
12968 var recordType = this.recordType, fields = recordType.prototype.fields;
12971 for(var i = 0; i < root.length; i++){
12974 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12975 for(var j = 0, jlen = fields.length; j < jlen; j++){
12976 var f = fields.items[j];
12977 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12978 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12980 values[f.name] = v;
12982 var record = new recordType(values, id);
12984 records[records.length] = record;
12988 totalRecords : records.length
12997 * @class Roo.bootstrap.ComboBox
12998 * @extends Roo.bootstrap.TriggerField
12999 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13000 * @cfg {Boolean} append (true|false) default false
13001 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13002 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13003 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13004 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13005 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13006 * @cfg {Boolean} animate default true
13007 * @cfg {Boolean} emptyResultText only for touch device
13008 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13009 * @cfg {String} emptyTitle default ''
13011 * Create a new ComboBox.
13012 * @param {Object} config Configuration options
13014 Roo.bootstrap.ComboBox = function(config){
13015 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13019 * Fires when the dropdown list is expanded
13020 * @param {Roo.bootstrap.ComboBox} combo This combo box
13025 * Fires when the dropdown list is collapsed
13026 * @param {Roo.bootstrap.ComboBox} combo This combo box
13030 * @event beforeselect
13031 * Fires before a list item is selected. Return false to cancel the selection.
13032 * @param {Roo.bootstrap.ComboBox} combo This combo box
13033 * @param {Roo.data.Record} record The data record returned from the underlying store
13034 * @param {Number} index The index of the selected item in the dropdown list
13036 'beforeselect' : true,
13039 * Fires when a list item is selected
13040 * @param {Roo.bootstrap.ComboBox} combo This combo box
13041 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13042 * @param {Number} index The index of the selected item in the dropdown list
13046 * @event beforequery
13047 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13048 * The event object passed has these properties:
13049 * @param {Roo.bootstrap.ComboBox} combo This combo box
13050 * @param {String} query The query
13051 * @param {Boolean} forceAll true to force "all" query
13052 * @param {Boolean} cancel true to cancel the query
13053 * @param {Object} e The query event object
13055 'beforequery': true,
13058 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13059 * @param {Roo.bootstrap.ComboBox} combo This combo box
13064 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13065 * @param {Roo.bootstrap.ComboBox} combo This combo box
13066 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13071 * Fires when the remove value from the combobox array
13072 * @param {Roo.bootstrap.ComboBox} combo This combo box
13076 * @event afterremove
13077 * Fires when the remove value from the combobox array
13078 * @param {Roo.bootstrap.ComboBox} combo This combo box
13080 'afterremove' : true,
13082 * @event specialfilter
13083 * Fires when specialfilter
13084 * @param {Roo.bootstrap.ComboBox} combo This combo box
13086 'specialfilter' : true,
13089 * Fires when tick the element
13090 * @param {Roo.bootstrap.ComboBox} combo This combo box
13094 * @event touchviewdisplay
13095 * Fires when touch view require special display (default is using displayField)
13096 * @param {Roo.bootstrap.ComboBox} combo This combo box
13097 * @param {Object} cfg set html .
13099 'touchviewdisplay' : true
13104 this.tickItems = [];
13106 this.selectedIndex = -1;
13107 if(this.mode == 'local'){
13108 if(config.queryDelay === undefined){
13109 this.queryDelay = 10;
13111 if(config.minChars === undefined){
13117 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13120 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13121 * rendering into an Roo.Editor, defaults to false)
13124 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13125 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13128 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13131 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13132 * the dropdown list (defaults to undefined, with no header element)
13136 * @cfg {String/Roo.Template} tpl The template to use to render the output
13140 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13142 listWidth: undefined,
13144 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13145 * mode = 'remote' or 'text' if mode = 'local')
13147 displayField: undefined,
13150 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13151 * mode = 'remote' or 'value' if mode = 'local').
13152 * Note: use of a valueField requires the user make a selection
13153 * in order for a value to be mapped.
13155 valueField: undefined,
13157 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13162 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13163 * field's data value (defaults to the underlying DOM element's name)
13165 hiddenName: undefined,
13167 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13171 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13173 selectedClass: 'active',
13176 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13180 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13181 * anchor positions (defaults to 'tl-bl')
13183 listAlign: 'tl-bl?',
13185 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13189 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13190 * query specified by the allQuery config option (defaults to 'query')
13192 triggerAction: 'query',
13194 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13195 * (defaults to 4, does not apply if editable = false)
13199 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13200 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13204 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13205 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13209 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13210 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13214 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13215 * when editable = true (defaults to false)
13217 selectOnFocus:false,
13219 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13221 queryParam: 'query',
13223 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13224 * when mode = 'remote' (defaults to 'Loading...')
13226 loadingText: 'Loading...',
13228 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13232 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13236 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13237 * traditional select (defaults to true)
13241 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13245 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13249 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13250 * listWidth has a higher value)
13254 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13255 * allow the user to set arbitrary text into the field (defaults to false)
13257 forceSelection:false,
13259 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13260 * if typeAhead = true (defaults to 250)
13262 typeAheadDelay : 250,
13264 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13265 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13267 valueNotFoundText : undefined,
13269 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13271 blockFocus : false,
13274 * @cfg {Boolean} disableClear Disable showing of clear button.
13276 disableClear : false,
13278 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13280 alwaysQuery : false,
13283 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13288 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13290 invalidClass : "has-warning",
13293 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13295 validClass : "has-success",
13298 * @cfg {Boolean} specialFilter (true|false) special filter default false
13300 specialFilter : false,
13303 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13305 mobileTouchView : true,
13308 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13310 useNativeIOS : false,
13313 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13315 mobile_restrict_height : false,
13317 ios_options : false,
13329 btnPosition : 'right',
13330 triggerList : true,
13331 showToggleBtn : true,
13333 emptyResultText: 'Empty',
13334 triggerText : 'Select',
13337 // element that contains real text value.. (when hidden is used..)
13339 getAutoCreate : function()
13344 * Render classic select for iso
13347 if(Roo.isIOS && this.useNativeIOS){
13348 cfg = this.getAutoCreateNativeIOS();
13356 if(Roo.isTouch && this.mobileTouchView){
13357 cfg = this.getAutoCreateTouchView();
13364 if(!this.tickable){
13365 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13370 * ComboBox with tickable selections
13373 var align = this.labelAlign || this.parentLabelAlign();
13376 cls : 'form-group roo-combobox-tickable' //input-group
13379 var btn_text_select = '';
13380 var btn_text_done = '';
13381 var btn_text_cancel = '';
13383 if (this.btn_text_show) {
13384 btn_text_select = 'Select';
13385 btn_text_done = 'Done';
13386 btn_text_cancel = 'Cancel';
13391 cls : 'tickable-buttons',
13396 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13397 //html : this.triggerText
13398 html: btn_text_select
13404 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13406 html: btn_text_done
13412 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13414 html: btn_text_cancel
13420 buttons.cn.unshift({
13422 cls: 'roo-select2-search-field-input'
13428 Roo.each(buttons.cn, function(c){
13430 c.cls += ' btn-' + _this.size;
13433 if (_this.disabled) {
13440 style : 'display: contents',
13445 cls: 'form-hidden-field'
13449 cls: 'roo-select2-choices',
13453 cls: 'roo-select2-search-field',
13464 cls: 'roo-select2-container input-group roo-select2-container-multi',
13470 // cls: 'typeahead typeahead-long dropdown-menu',
13471 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13476 if(this.hasFeedback && !this.allowBlank){
13480 cls: 'glyphicon form-control-feedback'
13483 combobox.cn.push(feedback);
13488 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13489 tooltip : 'This field is required'
13491 if (Roo.bootstrap.version == 4) {
13494 style : 'display:none'
13497 if (align ==='left' && this.fieldLabel.length) {
13499 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13506 cls : 'control-label col-form-label',
13507 html : this.fieldLabel
13519 var labelCfg = cfg.cn[1];
13520 var contentCfg = cfg.cn[2];
13523 if(this.indicatorpos == 'right'){
13529 cls : 'control-label col-form-label',
13533 html : this.fieldLabel
13549 labelCfg = cfg.cn[0];
13550 contentCfg = cfg.cn[1];
13554 if(this.labelWidth > 12){
13555 labelCfg.style = "width: " + this.labelWidth + 'px';
13558 if(this.labelWidth < 13 && this.labelmd == 0){
13559 this.labelmd = this.labelWidth;
13562 if(this.labellg > 0){
13563 labelCfg.cls += ' col-lg-' + this.labellg;
13564 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13567 if(this.labelmd > 0){
13568 labelCfg.cls += ' col-md-' + this.labelmd;
13569 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13572 if(this.labelsm > 0){
13573 labelCfg.cls += ' col-sm-' + this.labelsm;
13574 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13577 if(this.labelxs > 0){
13578 labelCfg.cls += ' col-xs-' + this.labelxs;
13579 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13583 } else if ( this.fieldLabel.length) {
13584 // Roo.log(" label");
13589 //cls : 'input-group-addon',
13590 html : this.fieldLabel
13595 if(this.indicatorpos == 'right'){
13599 //cls : 'input-group-addon',
13600 html : this.fieldLabel
13610 // Roo.log(" no label && no align");
13617 ['xs','sm','md','lg'].map(function(size){
13618 if (settings[size]) {
13619 cfg.cls += ' col-' + size + '-' + settings[size];
13627 _initEventsCalled : false,
13630 initEvents: function()
13632 if (this._initEventsCalled) { // as we call render... prevent looping...
13635 this._initEventsCalled = true;
13638 throw "can not find store for combo";
13641 this.indicator = this.indicatorEl();
13643 this.store = Roo.factory(this.store, Roo.data);
13644 this.store.parent = this;
13646 // if we are building from html. then this element is so complex, that we can not really
13647 // use the rendered HTML.
13648 // so we have to trash and replace the previous code.
13649 if (Roo.XComponent.build_from_html) {
13650 // remove this element....
13651 var e = this.el.dom, k=0;
13652 while (e ) { e = e.previousSibling; ++k;}
13657 this.rendered = false;
13659 this.render(this.parent().getChildContainer(true), k);
13662 if(Roo.isIOS && this.useNativeIOS){
13663 this.initIOSView();
13671 if(Roo.isTouch && this.mobileTouchView){
13672 this.initTouchView();
13677 this.initTickableEvents();
13681 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13683 if(this.hiddenName){
13685 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13687 this.hiddenField.dom.value =
13688 this.hiddenValue !== undefined ? this.hiddenValue :
13689 this.value !== undefined ? this.value : '';
13691 // prevent input submission
13692 this.el.dom.removeAttribute('name');
13693 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13698 // this.el.dom.setAttribute('autocomplete', 'off');
13701 var cls = 'x-combo-list';
13703 //this.list = new Roo.Layer({
13704 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13710 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13711 _this.list.setWidth(lw);
13714 this.list.on('mouseover', this.onViewOver, this);
13715 this.list.on('mousemove', this.onViewMove, this);
13716 this.list.on('scroll', this.onViewScroll, this);
13719 this.list.swallowEvent('mousewheel');
13720 this.assetHeight = 0;
13723 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13724 this.assetHeight += this.header.getHeight();
13727 this.innerList = this.list.createChild({cls:cls+'-inner'});
13728 this.innerList.on('mouseover', this.onViewOver, this);
13729 this.innerList.on('mousemove', this.onViewMove, this);
13730 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13732 if(this.allowBlank && !this.pageSize && !this.disableClear){
13733 this.footer = this.list.createChild({cls:cls+'-ft'});
13734 this.pageTb = new Roo.Toolbar(this.footer);
13738 this.footer = this.list.createChild({cls:cls+'-ft'});
13739 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13740 {pageSize: this.pageSize});
13744 if (this.pageTb && this.allowBlank && !this.disableClear) {
13746 this.pageTb.add(new Roo.Toolbar.Fill(), {
13747 cls: 'x-btn-icon x-btn-clear',
13749 handler: function()
13752 _this.clearValue();
13753 _this.onSelect(false, -1);
13758 this.assetHeight += this.footer.getHeight();
13763 this.tpl = Roo.bootstrap.version == 4 ?
13764 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13765 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13768 this.view = new Roo.View(this.list, this.tpl, {
13769 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13771 //this.view.wrapEl.setDisplayed(false);
13772 this.view.on('click', this.onViewClick, this);
13775 this.store.on('beforeload', this.onBeforeLoad, this);
13776 this.store.on('load', this.onLoad, this);
13777 this.store.on('loadexception', this.onLoadException, this);
13779 if(this.resizable){
13780 this.resizer = new Roo.Resizable(this.list, {
13781 pinned:true, handles:'se'
13783 this.resizer.on('resize', function(r, w, h){
13784 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13785 this.listWidth = w;
13786 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13787 this.restrictHeight();
13789 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13792 if(!this.editable){
13793 this.editable = true;
13794 this.setEditable(false);
13799 if (typeof(this.events.add.listeners) != 'undefined') {
13801 this.addicon = this.wrap.createChild(
13802 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13804 this.addicon.on('click', function(e) {
13805 this.fireEvent('add', this);
13808 if (typeof(this.events.edit.listeners) != 'undefined') {
13810 this.editicon = this.wrap.createChild(
13811 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13812 if (this.addicon) {
13813 this.editicon.setStyle('margin-left', '40px');
13815 this.editicon.on('click', function(e) {
13817 // we fire even if inothing is selected..
13818 this.fireEvent('edit', this, this.lastData );
13824 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13825 "up" : function(e){
13826 this.inKeyMode = true;
13830 "down" : function(e){
13831 if(!this.isExpanded()){
13832 this.onTriggerClick();
13834 this.inKeyMode = true;
13839 "enter" : function(e){
13840 // this.onViewClick();
13844 if(this.fireEvent("specialkey", this, e)){
13845 this.onViewClick(false);
13851 "esc" : function(e){
13855 "tab" : function(e){
13858 if(this.fireEvent("specialkey", this, e)){
13859 this.onViewClick(false);
13867 doRelay : function(foo, bar, hname){
13868 if(hname == 'down' || this.scope.isExpanded()){
13869 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13878 this.queryDelay = Math.max(this.queryDelay || 10,
13879 this.mode == 'local' ? 10 : 250);
13882 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13884 if(this.typeAhead){
13885 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13887 if(this.editable !== false){
13888 this.inputEl().on("keyup", this.onKeyUp, this);
13890 if(this.forceSelection){
13891 this.inputEl().on('blur', this.doForce, this);
13895 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13896 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13900 initTickableEvents: function()
13904 if(this.hiddenName){
13906 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13908 this.hiddenField.dom.value =
13909 this.hiddenValue !== undefined ? this.hiddenValue :
13910 this.value !== undefined ? this.value : '';
13912 // prevent input submission
13913 this.el.dom.removeAttribute('name');
13914 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13919 // this.list = this.el.select('ul.dropdown-menu',true).first();
13921 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13922 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13923 if(this.triggerList){
13924 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13927 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13928 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13930 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13931 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13933 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13934 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13936 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13937 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13938 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13941 this.cancelBtn.hide();
13946 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13947 _this.list.setWidth(lw);
13950 this.list.on('mouseover', this.onViewOver, this);
13951 this.list.on('mousemove', this.onViewMove, this);
13953 this.list.on('scroll', this.onViewScroll, this);
13956 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
13957 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13960 this.view = new Roo.View(this.list, this.tpl, {
13965 selectedClass: this.selectedClass
13968 //this.view.wrapEl.setDisplayed(false);
13969 this.view.on('click', this.onViewClick, this);
13973 this.store.on('beforeload', this.onBeforeLoad, this);
13974 this.store.on('load', this.onLoad, this);
13975 this.store.on('loadexception', this.onLoadException, this);
13978 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13979 "up" : function(e){
13980 this.inKeyMode = true;
13984 "down" : function(e){
13985 this.inKeyMode = true;
13989 "enter" : function(e){
13990 if(this.fireEvent("specialkey", this, e)){
13991 this.onViewClick(false);
13997 "esc" : function(e){
13998 this.onTickableFooterButtonClick(e, false, false);
14001 "tab" : function(e){
14002 this.fireEvent("specialkey", this, e);
14004 this.onTickableFooterButtonClick(e, false, false);
14011 doRelay : function(e, fn, key){
14012 if(this.scope.isExpanded()){
14013 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14022 this.queryDelay = Math.max(this.queryDelay || 10,
14023 this.mode == 'local' ? 10 : 250);
14026 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14028 if(this.typeAhead){
14029 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14032 if(this.editable !== false){
14033 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14036 this.indicator = this.indicatorEl();
14038 if(this.indicator){
14039 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14040 this.indicator.hide();
14045 onDestroy : function(){
14047 this.view.setStore(null);
14048 this.view.el.removeAllListeners();
14049 this.view.el.remove();
14050 this.view.purgeListeners();
14053 this.list.dom.innerHTML = '';
14057 this.store.un('beforeload', this.onBeforeLoad, this);
14058 this.store.un('load', this.onLoad, this);
14059 this.store.un('loadexception', this.onLoadException, this);
14061 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14065 fireKey : function(e){
14066 if(e.isNavKeyPress() && !this.list.isVisible()){
14067 this.fireEvent("specialkey", this, e);
14072 onResize: function(w, h){
14073 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14075 // if(typeof w != 'number'){
14076 // // we do not handle it!?!?
14079 // var tw = this.trigger.getWidth();
14080 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14081 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14083 // this.inputEl().setWidth( this.adjustWidth('input', x));
14085 // //this.trigger.setStyle('left', x+'px');
14087 // if(this.list && this.listWidth === undefined){
14088 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14089 // this.list.setWidth(lw);
14090 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14098 * Allow or prevent the user from directly editing the field text. If false is passed,
14099 * the user will only be able to select from the items defined in the dropdown list. This method
14100 * is the runtime equivalent of setting the 'editable' config option at config time.
14101 * @param {Boolean} value True to allow the user to directly edit the field text
14103 setEditable : function(value){
14104 if(value == this.editable){
14107 this.editable = value;
14109 this.inputEl().dom.setAttribute('readOnly', true);
14110 this.inputEl().on('mousedown', this.onTriggerClick, this);
14111 this.inputEl().addClass('x-combo-noedit');
14113 this.inputEl().dom.setAttribute('readOnly', false);
14114 this.inputEl().un('mousedown', this.onTriggerClick, this);
14115 this.inputEl().removeClass('x-combo-noedit');
14121 onBeforeLoad : function(combo,opts){
14122 if(!this.hasFocus){
14126 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14128 this.restrictHeight();
14129 this.selectedIndex = -1;
14133 onLoad : function(){
14135 this.hasQuery = false;
14137 if(!this.hasFocus){
14141 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14142 this.loading.hide();
14145 if(this.store.getCount() > 0){
14148 this.restrictHeight();
14149 if(this.lastQuery == this.allQuery){
14150 if(this.editable && !this.tickable){
14151 this.inputEl().dom.select();
14155 !this.selectByValue(this.value, true) &&
14158 !this.store.lastOptions ||
14159 typeof(this.store.lastOptions.add) == 'undefined' ||
14160 this.store.lastOptions.add != true
14163 this.select(0, true);
14166 if(this.autoFocus){
14169 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14170 this.taTask.delay(this.typeAheadDelay);
14174 this.onEmptyResults();
14180 onLoadException : function()
14182 this.hasQuery = false;
14184 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14185 this.loading.hide();
14188 if(this.tickable && this.editable){
14193 // only causes errors at present
14194 //Roo.log(this.store.reader.jsonData);
14195 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14197 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14203 onTypeAhead : function(){
14204 if(this.store.getCount() > 0){
14205 var r = this.store.getAt(0);
14206 var newValue = r.data[this.displayField];
14207 var len = newValue.length;
14208 var selStart = this.getRawValue().length;
14210 if(selStart != len){
14211 this.setRawValue(newValue);
14212 this.selectText(selStart, newValue.length);
14218 onSelect : function(record, index){
14220 if(this.fireEvent('beforeselect', this, record, index) !== false){
14222 this.setFromData(index > -1 ? record.data : false);
14225 this.fireEvent('select', this, record, index);
14230 * Returns the currently selected field value or empty string if no value is set.
14231 * @return {String} value The selected value
14233 getValue : function()
14235 if(Roo.isIOS && this.useNativeIOS){
14236 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14240 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14243 if(this.valueField){
14244 return typeof this.value != 'undefined' ? this.value : '';
14246 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14250 getRawValue : function()
14252 if(Roo.isIOS && this.useNativeIOS){
14253 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14256 var v = this.inputEl().getValue();
14262 * Clears any text/value currently set in the field
14264 clearValue : function(){
14266 if(this.hiddenField){
14267 this.hiddenField.dom.value = '';
14270 this.setRawValue('');
14271 this.lastSelectionText = '';
14272 this.lastData = false;
14274 var close = this.closeTriggerEl();
14285 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14286 * will be displayed in the field. If the value does not match the data value of an existing item,
14287 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14288 * Otherwise the field will be blank (although the value will still be set).
14289 * @param {String} value The value to match
14291 setValue : function(v)
14293 if(Roo.isIOS && this.useNativeIOS){
14294 this.setIOSValue(v);
14304 if(this.valueField){
14305 var r = this.findRecord(this.valueField, v);
14307 text = r.data[this.displayField];
14308 }else if(this.valueNotFoundText !== undefined){
14309 text = this.valueNotFoundText;
14312 this.lastSelectionText = text;
14313 if(this.hiddenField){
14314 this.hiddenField.dom.value = v;
14316 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14319 var close = this.closeTriggerEl();
14322 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14328 * @property {Object} the last set data for the element
14333 * Sets the value of the field based on a object which is related to the record format for the store.
14334 * @param {Object} value the value to set as. or false on reset?
14336 setFromData : function(o){
14343 var dv = ''; // display value
14344 var vv = ''; // value value..
14346 if (this.displayField) {
14347 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14349 // this is an error condition!!!
14350 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14353 if(this.valueField){
14354 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14357 var close = this.closeTriggerEl();
14360 if(dv.length || vv * 1 > 0){
14362 this.blockFocus=true;
14368 if(this.hiddenField){
14369 this.hiddenField.dom.value = vv;
14371 this.lastSelectionText = dv;
14372 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14376 // no hidden field.. - we store the value in 'value', but still display
14377 // display field!!!!
14378 this.lastSelectionText = dv;
14379 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14386 reset : function(){
14387 // overridden so that last data is reset..
14394 this.setValue(this.originalValue);
14395 //this.clearInvalid();
14396 this.lastData = false;
14398 this.view.clearSelections();
14404 findRecord : function(prop, value){
14406 if(this.store.getCount() > 0){
14407 this.store.each(function(r){
14408 if(r.data[prop] == value){
14418 getName: function()
14420 // returns hidden if it's set..
14421 if (!this.rendered) {return ''};
14422 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14426 onViewMove : function(e, t){
14427 this.inKeyMode = false;
14431 onViewOver : function(e, t){
14432 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14435 var item = this.view.findItemFromChild(t);
14438 var index = this.view.indexOf(item);
14439 this.select(index, false);
14444 onViewClick : function(view, doFocus, el, e)
14446 var index = this.view.getSelectedIndexes()[0];
14448 var r = this.store.getAt(index);
14452 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14459 Roo.each(this.tickItems, function(v,k){
14461 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14463 _this.tickItems.splice(k, 1);
14465 if(typeof(e) == 'undefined' && view == false){
14466 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14478 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14479 this.tickItems.push(r.data);
14482 if(typeof(e) == 'undefined' && view == false){
14483 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14490 this.onSelect(r, index);
14492 if(doFocus !== false && !this.blockFocus){
14493 this.inputEl().focus();
14498 restrictHeight : function(){
14499 //this.innerList.dom.style.height = '';
14500 //var inner = this.innerList.dom;
14501 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14502 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14503 //this.list.beginUpdate();
14504 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14505 this.list.alignTo(this.inputEl(), this.listAlign);
14506 this.list.alignTo(this.inputEl(), this.listAlign);
14507 //this.list.endUpdate();
14511 onEmptyResults : function(){
14513 if(this.tickable && this.editable){
14514 this.hasFocus = false;
14515 this.restrictHeight();
14523 * Returns true if the dropdown list is expanded, else false.
14525 isExpanded : function(){
14526 return this.list.isVisible();
14530 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14531 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14532 * @param {String} value The data value of the item to select
14533 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14534 * selected item if it is not currently in view (defaults to true)
14535 * @return {Boolean} True if the value matched an item in the list, else false
14537 selectByValue : function(v, scrollIntoView){
14538 if(v !== undefined && v !== null){
14539 var r = this.findRecord(this.valueField || this.displayField, v);
14541 this.select(this.store.indexOf(r), scrollIntoView);
14549 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14550 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14551 * @param {Number} index The zero-based index of the list item to select
14552 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14553 * selected item if it is not currently in view (defaults to true)
14555 select : function(index, scrollIntoView){
14556 this.selectedIndex = index;
14557 this.view.select(index);
14558 if(scrollIntoView !== false){
14559 var el = this.view.getNode(index);
14561 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14564 this.list.scrollChildIntoView(el, false);
14570 selectNext : function(){
14571 var ct = this.store.getCount();
14573 if(this.selectedIndex == -1){
14575 }else if(this.selectedIndex < ct-1){
14576 this.select(this.selectedIndex+1);
14582 selectPrev : function(){
14583 var ct = this.store.getCount();
14585 if(this.selectedIndex == -1){
14587 }else if(this.selectedIndex != 0){
14588 this.select(this.selectedIndex-1);
14594 onKeyUp : function(e){
14595 if(this.editable !== false && !e.isSpecialKey()){
14596 this.lastKey = e.getKey();
14597 this.dqTask.delay(this.queryDelay);
14602 validateBlur : function(){
14603 return !this.list || !this.list.isVisible();
14607 initQuery : function(){
14609 var v = this.getRawValue();
14611 if(this.tickable && this.editable){
14612 v = this.tickableInputEl().getValue();
14619 doForce : function(){
14620 if(this.inputEl().dom.value.length > 0){
14621 this.inputEl().dom.value =
14622 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14628 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14629 * query allowing the query action to be canceled if needed.
14630 * @param {String} query The SQL query to execute
14631 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14632 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14633 * saved in the current store (defaults to false)
14635 doQuery : function(q, forceAll){
14637 if(q === undefined || q === null){
14642 forceAll: forceAll,
14646 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14651 forceAll = qe.forceAll;
14652 if(forceAll === true || (q.length >= this.minChars)){
14654 this.hasQuery = true;
14656 if(this.lastQuery != q || this.alwaysQuery){
14657 this.lastQuery = q;
14658 if(this.mode == 'local'){
14659 this.selectedIndex = -1;
14661 this.store.clearFilter();
14664 if(this.specialFilter){
14665 this.fireEvent('specialfilter', this);
14670 this.store.filter(this.displayField, q);
14673 this.store.fireEvent("datachanged", this.store);
14680 this.store.baseParams[this.queryParam] = q;
14682 var options = {params : this.getParams(q)};
14685 options.add = true;
14686 options.params.start = this.page * this.pageSize;
14689 this.store.load(options);
14692 * this code will make the page width larger, at the beginning, the list not align correctly,
14693 * we should expand the list on onLoad
14694 * so command out it
14699 this.selectedIndex = -1;
14704 this.loadNext = false;
14708 getParams : function(q){
14710 //p[this.queryParam] = q;
14714 p.limit = this.pageSize;
14720 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14722 collapse : function(){
14723 if(!this.isExpanded()){
14729 this.hasFocus = false;
14733 this.cancelBtn.hide();
14734 this.trigger.show();
14737 this.tickableInputEl().dom.value = '';
14738 this.tickableInputEl().blur();
14743 Roo.get(document).un('mousedown', this.collapseIf, this);
14744 Roo.get(document).un('mousewheel', this.collapseIf, this);
14745 if (!this.editable) {
14746 Roo.get(document).un('keydown', this.listKeyPress, this);
14748 this.fireEvent('collapse', this);
14754 collapseIf : function(e){
14755 var in_combo = e.within(this.el);
14756 var in_list = e.within(this.list);
14757 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14759 if (in_combo || in_list || is_list) {
14760 //e.stopPropagation();
14765 this.onTickableFooterButtonClick(e, false, false);
14773 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14775 expand : function(){
14777 if(this.isExpanded() || !this.hasFocus){
14781 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14782 this.list.setWidth(lw);
14788 this.restrictHeight();
14792 this.tickItems = Roo.apply([], this.item);
14795 this.cancelBtn.show();
14796 this.trigger.hide();
14799 this.tickableInputEl().focus();
14804 Roo.get(document).on('mousedown', this.collapseIf, this);
14805 Roo.get(document).on('mousewheel', this.collapseIf, this);
14806 if (!this.editable) {
14807 Roo.get(document).on('keydown', this.listKeyPress, this);
14810 this.fireEvent('expand', this);
14814 // Implements the default empty TriggerField.onTriggerClick function
14815 onTriggerClick : function(e)
14817 Roo.log('trigger click');
14819 if(this.disabled || !this.triggerList){
14824 this.loadNext = false;
14826 if(this.isExpanded()){
14828 if (!this.blockFocus) {
14829 this.inputEl().focus();
14833 this.hasFocus = true;
14834 if(this.triggerAction == 'all') {
14835 this.doQuery(this.allQuery, true);
14837 this.doQuery(this.getRawValue());
14839 if (!this.blockFocus) {
14840 this.inputEl().focus();
14845 onTickableTriggerClick : function(e)
14852 this.loadNext = false;
14853 this.hasFocus = true;
14855 if(this.triggerAction == 'all') {
14856 this.doQuery(this.allQuery, true);
14858 this.doQuery(this.getRawValue());
14862 onSearchFieldClick : function(e)
14864 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14865 this.onTickableFooterButtonClick(e, false, false);
14869 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14874 this.loadNext = false;
14875 this.hasFocus = true;
14877 if(this.triggerAction == 'all') {
14878 this.doQuery(this.allQuery, true);
14880 this.doQuery(this.getRawValue());
14884 listKeyPress : function(e)
14886 //Roo.log('listkeypress');
14887 // scroll to first matching element based on key pres..
14888 if (e.isSpecialKey()) {
14891 var k = String.fromCharCode(e.getKey()).toUpperCase();
14894 var csel = this.view.getSelectedNodes();
14895 var cselitem = false;
14897 var ix = this.view.indexOf(csel[0]);
14898 cselitem = this.store.getAt(ix);
14899 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14905 this.store.each(function(v) {
14907 // start at existing selection.
14908 if (cselitem.id == v.id) {
14914 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14915 match = this.store.indexOf(v);
14921 if (match === false) {
14922 return true; // no more action?
14925 this.view.select(match);
14926 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14927 sn.scrollIntoView(sn.dom.parentNode, false);
14930 onViewScroll : function(e, t){
14932 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){
14936 this.hasQuery = true;
14938 this.loading = this.list.select('.loading', true).first();
14940 if(this.loading === null){
14941 this.list.createChild({
14943 cls: 'loading roo-select2-more-results roo-select2-active',
14944 html: 'Loading more results...'
14947 this.loading = this.list.select('.loading', true).first();
14949 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14951 this.loading.hide();
14954 this.loading.show();
14959 this.loadNext = true;
14961 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14966 addItem : function(o)
14968 var dv = ''; // display value
14970 if (this.displayField) {
14971 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14973 // this is an error condition!!!
14974 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14981 var choice = this.choices.createChild({
14983 cls: 'roo-select2-search-choice',
14992 cls: 'roo-select2-search-choice-close fa fa-times',
14997 }, this.searchField);
14999 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15001 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15009 this.inputEl().dom.value = '';
15014 onRemoveItem : function(e, _self, o)
15016 e.preventDefault();
15018 this.lastItem = Roo.apply([], this.item);
15020 var index = this.item.indexOf(o.data) * 1;
15023 Roo.log('not this item?!');
15027 this.item.splice(index, 1);
15032 this.fireEvent('remove', this, e);
15038 syncValue : function()
15040 if(!this.item.length){
15047 Roo.each(this.item, function(i){
15048 if(_this.valueField){
15049 value.push(i[_this.valueField]);
15056 this.value = value.join(',');
15058 if(this.hiddenField){
15059 this.hiddenField.dom.value = this.value;
15062 this.store.fireEvent("datachanged", this.store);
15067 clearItem : function()
15069 if(!this.multiple){
15075 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15083 if(this.tickable && !Roo.isTouch){
15084 this.view.refresh();
15088 inputEl: function ()
15090 if(Roo.isIOS && this.useNativeIOS){
15091 return this.el.select('select.roo-ios-select', true).first();
15094 if(Roo.isTouch && this.mobileTouchView){
15095 return this.el.select('input.form-control',true).first();
15099 return this.searchField;
15102 return this.el.select('input.form-control',true).first();
15105 onTickableFooterButtonClick : function(e, btn, el)
15107 e.preventDefault();
15109 this.lastItem = Roo.apply([], this.item);
15111 if(btn && btn.name == 'cancel'){
15112 this.tickItems = Roo.apply([], this.item);
15121 Roo.each(this.tickItems, function(o){
15129 validate : function()
15131 if(this.getVisibilityEl().hasClass('hidden')){
15135 var v = this.getRawValue();
15138 v = this.getValue();
15141 if(this.disabled || this.allowBlank || v.length){
15146 this.markInvalid();
15150 tickableInputEl : function()
15152 if(!this.tickable || !this.editable){
15153 return this.inputEl();
15156 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15160 getAutoCreateTouchView : function()
15165 cls: 'form-group' //input-group
15171 type : this.inputType,
15172 cls : 'form-control x-combo-noedit',
15173 autocomplete: 'new-password',
15174 placeholder : this.placeholder || '',
15179 input.name = this.name;
15183 input.cls += ' input-' + this.size;
15186 if (this.disabled) {
15187 input.disabled = true;
15198 inputblock.cls += ' input-group';
15200 inputblock.cn.unshift({
15202 cls : 'input-group-addon input-group-prepend input-group-text',
15207 if(this.removable && !this.multiple){
15208 inputblock.cls += ' roo-removable';
15210 inputblock.cn.push({
15213 cls : 'roo-combo-removable-btn close'
15217 if(this.hasFeedback && !this.allowBlank){
15219 inputblock.cls += ' has-feedback';
15221 inputblock.cn.push({
15223 cls: 'glyphicon form-control-feedback'
15230 inputblock.cls += (this.before) ? '' : ' input-group';
15232 inputblock.cn.push({
15234 cls : 'input-group-addon input-group-append input-group-text',
15240 var ibwrap = inputblock;
15245 cls: 'roo-select2-choices',
15249 cls: 'roo-select2-search-field',
15262 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15267 cls: 'form-hidden-field'
15273 if(!this.multiple && this.showToggleBtn){
15280 if (this.caret != false) {
15283 cls: 'fa fa-' + this.caret
15290 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15295 cls: 'combobox-clear',
15309 combobox.cls += ' roo-select2-container-multi';
15312 var align = this.labelAlign || this.parentLabelAlign();
15314 if (align ==='left' && this.fieldLabel.length) {
15319 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15320 tooltip : 'This field is required'
15324 cls : 'control-label col-form-label',
15325 html : this.fieldLabel
15336 var labelCfg = cfg.cn[1];
15337 var contentCfg = cfg.cn[2];
15340 if(this.indicatorpos == 'right'){
15345 cls : 'control-label col-form-label',
15349 html : this.fieldLabel
15353 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15354 tooltip : 'This field is required'
15367 labelCfg = cfg.cn[0];
15368 contentCfg = cfg.cn[1];
15373 if(this.labelWidth > 12){
15374 labelCfg.style = "width: " + this.labelWidth + 'px';
15377 if(this.labelWidth < 13 && this.labelmd == 0){
15378 this.labelmd = this.labelWidth;
15381 if(this.labellg > 0){
15382 labelCfg.cls += ' col-lg-' + this.labellg;
15383 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15386 if(this.labelmd > 0){
15387 labelCfg.cls += ' col-md-' + this.labelmd;
15388 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15391 if(this.labelsm > 0){
15392 labelCfg.cls += ' col-sm-' + this.labelsm;
15393 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15396 if(this.labelxs > 0){
15397 labelCfg.cls += ' col-xs-' + this.labelxs;
15398 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15402 } else if ( this.fieldLabel.length) {
15406 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15407 tooltip : 'This field is required'
15411 cls : 'control-label',
15412 html : this.fieldLabel
15423 if(this.indicatorpos == 'right'){
15427 cls : 'control-label',
15428 html : this.fieldLabel,
15432 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15433 tooltip : 'This field is required'
15450 var settings = this;
15452 ['xs','sm','md','lg'].map(function(size){
15453 if (settings[size]) {
15454 cfg.cls += ' col-' + size + '-' + settings[size];
15461 initTouchView : function()
15463 this.renderTouchView();
15465 this.touchViewEl.on('scroll', function(){
15466 this.el.dom.scrollTop = 0;
15469 this.originalValue = this.getValue();
15471 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15473 this.inputEl().on("click", this.showTouchView, this);
15474 if (this.triggerEl) {
15475 this.triggerEl.on("click", this.showTouchView, this);
15479 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15480 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15482 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15484 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15485 this.store.on('load', this.onTouchViewLoad, this);
15486 this.store.on('loadexception', this.onTouchViewLoadException, this);
15488 if(this.hiddenName){
15490 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15492 this.hiddenField.dom.value =
15493 this.hiddenValue !== undefined ? this.hiddenValue :
15494 this.value !== undefined ? this.value : '';
15496 this.el.dom.removeAttribute('name');
15497 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15501 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15502 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15505 if(this.removable && !this.multiple){
15506 var close = this.closeTriggerEl();
15508 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15509 close.on('click', this.removeBtnClick, this, close);
15513 * fix the bug in Safari iOS8
15515 this.inputEl().on("focus", function(e){
15516 document.activeElement.blur();
15519 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15526 renderTouchView : function()
15528 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15529 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15531 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15532 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15534 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15535 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15536 this.touchViewBodyEl.setStyle('overflow', 'auto');
15538 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15539 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15541 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15542 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15546 showTouchView : function()
15552 this.touchViewHeaderEl.hide();
15554 if(this.modalTitle.length){
15555 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15556 this.touchViewHeaderEl.show();
15559 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15560 this.touchViewEl.show();
15562 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15564 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15565 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15567 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15569 if(this.modalTitle.length){
15570 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15573 this.touchViewBodyEl.setHeight(bodyHeight);
15577 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15579 this.touchViewEl.addClass('in');
15582 if(this._touchViewMask){
15583 Roo.get(document.body).addClass("x-body-masked");
15584 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15585 this._touchViewMask.setStyle('z-index', 10000);
15586 this._touchViewMask.addClass('show');
15589 this.doTouchViewQuery();
15593 hideTouchView : function()
15595 this.touchViewEl.removeClass('in');
15599 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15601 this.touchViewEl.setStyle('display', 'none');
15604 if(this._touchViewMask){
15605 this._touchViewMask.removeClass('show');
15606 Roo.get(document.body).removeClass("x-body-masked");
15610 setTouchViewValue : function()
15617 Roo.each(this.tickItems, function(o){
15622 this.hideTouchView();
15625 doTouchViewQuery : function()
15634 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15638 if(!this.alwaysQuery || this.mode == 'local'){
15639 this.onTouchViewLoad();
15646 onTouchViewBeforeLoad : function(combo,opts)
15652 onTouchViewLoad : function()
15654 if(this.store.getCount() < 1){
15655 this.onTouchViewEmptyResults();
15659 this.clearTouchView();
15661 var rawValue = this.getRawValue();
15663 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15665 this.tickItems = [];
15667 this.store.data.each(function(d, rowIndex){
15668 var row = this.touchViewListGroup.createChild(template);
15670 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15671 row.addClass(d.data.cls);
15674 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15677 html : d.data[this.displayField]
15680 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15681 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15684 row.removeClass('selected');
15685 if(!this.multiple && this.valueField &&
15686 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15689 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15690 row.addClass('selected');
15693 if(this.multiple && this.valueField &&
15694 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15698 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15699 this.tickItems.push(d.data);
15702 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15706 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15708 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15710 if(this.modalTitle.length){
15711 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15714 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15716 if(this.mobile_restrict_height && listHeight < bodyHeight){
15717 this.touchViewBodyEl.setHeight(listHeight);
15722 if(firstChecked && listHeight > bodyHeight){
15723 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15728 onTouchViewLoadException : function()
15730 this.hideTouchView();
15733 onTouchViewEmptyResults : function()
15735 this.clearTouchView();
15737 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15739 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15743 clearTouchView : function()
15745 this.touchViewListGroup.dom.innerHTML = '';
15748 onTouchViewClick : function(e, el, o)
15750 e.preventDefault();
15753 var rowIndex = o.rowIndex;
15755 var r = this.store.getAt(rowIndex);
15757 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15759 if(!this.multiple){
15760 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15761 c.dom.removeAttribute('checked');
15764 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15766 this.setFromData(r.data);
15768 var close = this.closeTriggerEl();
15774 this.hideTouchView();
15776 this.fireEvent('select', this, r, rowIndex);
15781 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15782 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15783 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15787 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15788 this.addItem(r.data);
15789 this.tickItems.push(r.data);
15793 getAutoCreateNativeIOS : function()
15796 cls: 'form-group' //input-group,
15801 cls : 'roo-ios-select'
15805 combobox.name = this.name;
15808 if (this.disabled) {
15809 combobox.disabled = true;
15812 var settings = this;
15814 ['xs','sm','md','lg'].map(function(size){
15815 if (settings[size]) {
15816 cfg.cls += ' col-' + size + '-' + settings[size];
15826 initIOSView : function()
15828 this.store.on('load', this.onIOSViewLoad, this);
15833 onIOSViewLoad : function()
15835 if(this.store.getCount() < 1){
15839 this.clearIOSView();
15841 if(this.allowBlank) {
15843 var default_text = '-- SELECT --';
15845 if(this.placeholder.length){
15846 default_text = this.placeholder;
15849 if(this.emptyTitle.length){
15850 default_text += ' - ' + this.emptyTitle + ' -';
15853 var opt = this.inputEl().createChild({
15856 html : default_text
15860 o[this.valueField] = 0;
15861 o[this.displayField] = default_text;
15863 this.ios_options.push({
15870 this.store.data.each(function(d, rowIndex){
15874 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15875 html = d.data[this.displayField];
15880 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15881 value = d.data[this.valueField];
15890 if(this.value == d.data[this.valueField]){
15891 option['selected'] = true;
15894 var opt = this.inputEl().createChild(option);
15896 this.ios_options.push({
15903 this.inputEl().on('change', function(){
15904 this.fireEvent('select', this);
15909 clearIOSView: function()
15911 this.inputEl().dom.innerHTML = '';
15913 this.ios_options = [];
15916 setIOSValue: function(v)
15920 if(!this.ios_options){
15924 Roo.each(this.ios_options, function(opts){
15926 opts.el.dom.removeAttribute('selected');
15928 if(opts.data[this.valueField] != v){
15932 opts.el.dom.setAttribute('selected', true);
15938 * @cfg {Boolean} grow
15942 * @cfg {Number} growMin
15946 * @cfg {Number} growMax
15955 Roo.apply(Roo.bootstrap.ComboBox, {
15959 cls: 'modal-header',
15981 cls: 'list-group-item',
15985 cls: 'roo-combobox-list-group-item-value'
15989 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16003 listItemCheckbox : {
16005 cls: 'list-group-item',
16009 cls: 'roo-combobox-list-group-item-value'
16013 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16029 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16034 cls: 'modal-footer',
16042 cls: 'col-xs-6 text-left',
16045 cls: 'btn btn-danger roo-touch-view-cancel',
16051 cls: 'col-xs-6 text-right',
16054 cls: 'btn btn-success roo-touch-view-ok',
16065 Roo.apply(Roo.bootstrap.ComboBox, {
16067 touchViewTemplate : {
16069 cls: 'modal fade roo-combobox-touch-view',
16073 cls: 'modal-dialog',
16074 style : 'position:fixed', // we have to fix position....
16078 cls: 'modal-content',
16080 Roo.bootstrap.ComboBox.header,
16081 Roo.bootstrap.ComboBox.body,
16082 Roo.bootstrap.ComboBox.footer
16091 * Ext JS Library 1.1.1
16092 * Copyright(c) 2006-2007, Ext JS, LLC.
16094 * Originally Released Under LGPL - original licence link has changed is not relivant.
16097 * <script type="text/javascript">
16102 * @extends Roo.util.Observable
16103 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16104 * This class also supports single and multi selection modes. <br>
16105 * Create a data model bound view:
16107 var store = new Roo.data.Store(...);
16109 var view = new Roo.View({
16111 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16113 singleSelect: true,
16114 selectedClass: "ydataview-selected",
16118 // listen for node click?
16119 view.on("click", function(vw, index, node, e){
16120 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16124 dataModel.load("foobar.xml");
16126 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16128 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16129 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16131 * Note: old style constructor is still suported (container, template, config)
16134 * Create a new View
16135 * @param {Object} config The config object
16138 Roo.View = function(config, depreciated_tpl, depreciated_config){
16140 this.parent = false;
16142 if (typeof(depreciated_tpl) == 'undefined') {
16143 // new way.. - universal constructor.
16144 Roo.apply(this, config);
16145 this.el = Roo.get(this.el);
16148 this.el = Roo.get(config);
16149 this.tpl = depreciated_tpl;
16150 Roo.apply(this, depreciated_config);
16152 this.wrapEl = this.el.wrap().wrap();
16153 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16156 if(typeof(this.tpl) == "string"){
16157 this.tpl = new Roo.Template(this.tpl);
16159 // support xtype ctors..
16160 this.tpl = new Roo.factory(this.tpl, Roo);
16164 this.tpl.compile();
16169 * @event beforeclick
16170 * Fires before a click is processed. Returns false to cancel the default action.
16171 * @param {Roo.View} this
16172 * @param {Number} index The index of the target node
16173 * @param {HTMLElement} node The target node
16174 * @param {Roo.EventObject} e The raw event object
16176 "beforeclick" : true,
16179 * Fires when a template node is clicked.
16180 * @param {Roo.View} this
16181 * @param {Number} index The index of the target node
16182 * @param {HTMLElement} node The target node
16183 * @param {Roo.EventObject} e The raw event object
16188 * Fires when a template node is double clicked.
16189 * @param {Roo.View} this
16190 * @param {Number} index The index of the target node
16191 * @param {HTMLElement} node The target node
16192 * @param {Roo.EventObject} e The raw event object
16196 * @event contextmenu
16197 * Fires when a template node is right clicked.
16198 * @param {Roo.View} this
16199 * @param {Number} index The index of the target node
16200 * @param {HTMLElement} node The target node
16201 * @param {Roo.EventObject} e The raw event object
16203 "contextmenu" : true,
16205 * @event selectionchange
16206 * Fires when the selected nodes change.
16207 * @param {Roo.View} this
16208 * @param {Array} selections Array of the selected nodes
16210 "selectionchange" : true,
16213 * @event beforeselect
16214 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16215 * @param {Roo.View} this
16216 * @param {HTMLElement} node The node to be selected
16217 * @param {Array} selections Array of currently selected nodes
16219 "beforeselect" : true,
16221 * @event preparedata
16222 * Fires on every row to render, to allow you to change the data.
16223 * @param {Roo.View} this
16224 * @param {Object} data to be rendered (change this)
16226 "preparedata" : true
16234 "click": this.onClick,
16235 "dblclick": this.onDblClick,
16236 "contextmenu": this.onContextMenu,
16240 this.selections = [];
16242 this.cmp = new Roo.CompositeElementLite([]);
16244 this.store = Roo.factory(this.store, Roo.data);
16245 this.setStore(this.store, true);
16248 if ( this.footer && this.footer.xtype) {
16250 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16252 this.footer.dataSource = this.store;
16253 this.footer.container = fctr;
16254 this.footer = Roo.factory(this.footer, Roo);
16255 fctr.insertFirst(this.el);
16257 // this is a bit insane - as the paging toolbar seems to detach the el..
16258 // dom.parentNode.parentNode.parentNode
16259 // they get detached?
16263 Roo.View.superclass.constructor.call(this);
16268 Roo.extend(Roo.View, Roo.util.Observable, {
16271 * @cfg {Roo.data.Store} store Data store to load data from.
16276 * @cfg {String|Roo.Element} el The container element.
16281 * @cfg {String|Roo.Template} tpl The template used by this View
16285 * @cfg {String} dataName the named area of the template to use as the data area
16286 * Works with domtemplates roo-name="name"
16290 * @cfg {String} selectedClass The css class to add to selected nodes
16292 selectedClass : "x-view-selected",
16294 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16299 * @cfg {String} text to display on mask (default Loading)
16303 * @cfg {Boolean} multiSelect Allow multiple selection
16305 multiSelect : false,
16307 * @cfg {Boolean} singleSelect Allow single selection
16309 singleSelect: false,
16312 * @cfg {Boolean} toggleSelect - selecting
16314 toggleSelect : false,
16317 * @cfg {Boolean} tickable - selecting
16322 * Returns the element this view is bound to.
16323 * @return {Roo.Element}
16325 getEl : function(){
16326 return this.wrapEl;
16332 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16334 refresh : function(){
16335 //Roo.log('refresh');
16338 // if we are using something like 'domtemplate', then
16339 // the what gets used is:
16340 // t.applySubtemplate(NAME, data, wrapping data..)
16341 // the outer template then get' applied with
16342 // the store 'extra data'
16343 // and the body get's added to the
16344 // roo-name="data" node?
16345 // <span class='roo-tpl-{name}'></span> ?????
16349 this.clearSelections();
16350 this.el.update("");
16352 var records = this.store.getRange();
16353 if(records.length < 1) {
16355 // is this valid?? = should it render a template??
16357 this.el.update(this.emptyText);
16361 if (this.dataName) {
16362 this.el.update(t.apply(this.store.meta)); //????
16363 el = this.el.child('.roo-tpl-' + this.dataName);
16366 for(var i = 0, len = records.length; i < len; i++){
16367 var data = this.prepareData(records[i].data, i, records[i]);
16368 this.fireEvent("preparedata", this, data, i, records[i]);
16370 var d = Roo.apply({}, data);
16373 Roo.apply(d, {'roo-id' : Roo.id()});
16377 Roo.each(this.parent.item, function(item){
16378 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16381 Roo.apply(d, {'roo-data-checked' : 'checked'});
16385 html[html.length] = Roo.util.Format.trim(
16387 t.applySubtemplate(this.dataName, d, this.store.meta) :
16394 el.update(html.join(""));
16395 this.nodes = el.dom.childNodes;
16396 this.updateIndexes(0);
16401 * Function to override to reformat the data that is sent to
16402 * the template for each node.
16403 * DEPRICATED - use the preparedata event handler.
16404 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16405 * a JSON object for an UpdateManager bound view).
16407 prepareData : function(data, index, record)
16409 this.fireEvent("preparedata", this, data, index, record);
16413 onUpdate : function(ds, record){
16414 // Roo.log('on update');
16415 this.clearSelections();
16416 var index = this.store.indexOf(record);
16417 var n = this.nodes[index];
16418 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16419 n.parentNode.removeChild(n);
16420 this.updateIndexes(index, index);
16426 onAdd : function(ds, records, index)
16428 //Roo.log(['on Add', ds, records, index] );
16429 this.clearSelections();
16430 if(this.nodes.length == 0){
16434 var n = this.nodes[index];
16435 for(var i = 0, len = records.length; i < len; i++){
16436 var d = this.prepareData(records[i].data, i, records[i]);
16438 this.tpl.insertBefore(n, d);
16441 this.tpl.append(this.el, d);
16444 this.updateIndexes(index);
16447 onRemove : function(ds, record, index){
16448 // Roo.log('onRemove');
16449 this.clearSelections();
16450 var el = this.dataName ?
16451 this.el.child('.roo-tpl-' + this.dataName) :
16454 el.dom.removeChild(this.nodes[index]);
16455 this.updateIndexes(index);
16459 * Refresh an individual node.
16460 * @param {Number} index
16462 refreshNode : function(index){
16463 this.onUpdate(this.store, this.store.getAt(index));
16466 updateIndexes : function(startIndex, endIndex){
16467 var ns = this.nodes;
16468 startIndex = startIndex || 0;
16469 endIndex = endIndex || ns.length - 1;
16470 for(var i = startIndex; i <= endIndex; i++){
16471 ns[i].nodeIndex = i;
16476 * Changes the data store this view uses and refresh the view.
16477 * @param {Store} store
16479 setStore : function(store, initial){
16480 if(!initial && this.store){
16481 this.store.un("datachanged", this.refresh);
16482 this.store.un("add", this.onAdd);
16483 this.store.un("remove", this.onRemove);
16484 this.store.un("update", this.onUpdate);
16485 this.store.un("clear", this.refresh);
16486 this.store.un("beforeload", this.onBeforeLoad);
16487 this.store.un("load", this.onLoad);
16488 this.store.un("loadexception", this.onLoad);
16492 store.on("datachanged", this.refresh, this);
16493 store.on("add", this.onAdd, this);
16494 store.on("remove", this.onRemove, this);
16495 store.on("update", this.onUpdate, this);
16496 store.on("clear", this.refresh, this);
16497 store.on("beforeload", this.onBeforeLoad, this);
16498 store.on("load", this.onLoad, this);
16499 store.on("loadexception", this.onLoad, this);
16507 * onbeforeLoad - masks the loading area.
16510 onBeforeLoad : function(store,opts)
16512 //Roo.log('onBeforeLoad');
16514 this.el.update("");
16516 this.el.mask(this.mask ? this.mask : "Loading" );
16518 onLoad : function ()
16525 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16526 * @param {HTMLElement} node
16527 * @return {HTMLElement} The template node
16529 findItemFromChild : function(node){
16530 var el = this.dataName ?
16531 this.el.child('.roo-tpl-' + this.dataName,true) :
16534 if(!node || node.parentNode == el){
16537 var p = node.parentNode;
16538 while(p && p != el){
16539 if(p.parentNode == el){
16548 onClick : function(e){
16549 var item = this.findItemFromChild(e.getTarget());
16551 var index = this.indexOf(item);
16552 if(this.onItemClick(item, index, e) !== false){
16553 this.fireEvent("click", this, index, item, e);
16556 this.clearSelections();
16561 onContextMenu : function(e){
16562 var item = this.findItemFromChild(e.getTarget());
16564 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16569 onDblClick : function(e){
16570 var item = this.findItemFromChild(e.getTarget());
16572 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16576 onItemClick : function(item, index, e)
16578 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16581 if (this.toggleSelect) {
16582 var m = this.isSelected(item) ? 'unselect' : 'select';
16585 _t[m](item, true, false);
16588 if(this.multiSelect || this.singleSelect){
16589 if(this.multiSelect && e.shiftKey && this.lastSelection){
16590 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16592 this.select(item, this.multiSelect && e.ctrlKey);
16593 this.lastSelection = item;
16596 if(!this.tickable){
16597 e.preventDefault();
16605 * Get the number of selected nodes.
16608 getSelectionCount : function(){
16609 return this.selections.length;
16613 * Get the currently selected nodes.
16614 * @return {Array} An array of HTMLElements
16616 getSelectedNodes : function(){
16617 return this.selections;
16621 * Get the indexes of the selected nodes.
16624 getSelectedIndexes : function(){
16625 var indexes = [], s = this.selections;
16626 for(var i = 0, len = s.length; i < len; i++){
16627 indexes.push(s[i].nodeIndex);
16633 * Clear all selections
16634 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16636 clearSelections : function(suppressEvent){
16637 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16638 this.cmp.elements = this.selections;
16639 this.cmp.removeClass(this.selectedClass);
16640 this.selections = [];
16641 if(!suppressEvent){
16642 this.fireEvent("selectionchange", this, this.selections);
16648 * Returns true if the passed node is selected
16649 * @param {HTMLElement/Number} node The node or node index
16650 * @return {Boolean}
16652 isSelected : function(node){
16653 var s = this.selections;
16657 node = this.getNode(node);
16658 return s.indexOf(node) !== -1;
16663 * @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
16664 * @param {Boolean} keepExisting (optional) true to keep existing selections
16665 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16667 select : function(nodeInfo, keepExisting, suppressEvent){
16668 if(nodeInfo instanceof Array){
16670 this.clearSelections(true);
16672 for(var i = 0, len = nodeInfo.length; i < len; i++){
16673 this.select(nodeInfo[i], true, true);
16677 var node = this.getNode(nodeInfo);
16678 if(!node || this.isSelected(node)){
16679 return; // already selected.
16682 this.clearSelections(true);
16685 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16686 Roo.fly(node).addClass(this.selectedClass);
16687 this.selections.push(node);
16688 if(!suppressEvent){
16689 this.fireEvent("selectionchange", this, this.selections);
16697 * @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
16698 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16699 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16701 unselect : function(nodeInfo, keepExisting, suppressEvent)
16703 if(nodeInfo instanceof Array){
16704 Roo.each(this.selections, function(s) {
16705 this.unselect(s, nodeInfo);
16709 var node = this.getNode(nodeInfo);
16710 if(!node || !this.isSelected(node)){
16711 //Roo.log("not selected");
16712 return; // not selected.
16716 Roo.each(this.selections, function(s) {
16718 Roo.fly(node).removeClass(this.selectedClass);
16725 this.selections= ns;
16726 this.fireEvent("selectionchange", this, this.selections);
16730 * Gets a template node.
16731 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16732 * @return {HTMLElement} The node or null if it wasn't found
16734 getNode : function(nodeInfo){
16735 if(typeof nodeInfo == "string"){
16736 return document.getElementById(nodeInfo);
16737 }else if(typeof nodeInfo == "number"){
16738 return this.nodes[nodeInfo];
16744 * Gets a range template nodes.
16745 * @param {Number} startIndex
16746 * @param {Number} endIndex
16747 * @return {Array} An array of nodes
16749 getNodes : function(start, end){
16750 var ns = this.nodes;
16751 start = start || 0;
16752 end = typeof end == "undefined" ? ns.length - 1 : end;
16755 for(var i = start; i <= end; i++){
16759 for(var i = start; i >= end; i--){
16767 * Finds the index of the passed node
16768 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16769 * @return {Number} The index of the node or -1
16771 indexOf : function(node){
16772 node = this.getNode(node);
16773 if(typeof node.nodeIndex == "number"){
16774 return node.nodeIndex;
16776 var ns = this.nodes;
16777 for(var i = 0, len = ns.length; i < len; i++){
16788 * based on jquery fullcalendar
16792 Roo.bootstrap = Roo.bootstrap || {};
16794 * @class Roo.bootstrap.Calendar
16795 * @extends Roo.bootstrap.Component
16796 * Bootstrap Calendar class
16797 * @cfg {Boolean} loadMask (true|false) default false
16798 * @cfg {Object} header generate the user specific header of the calendar, default false
16801 * Create a new Container
16802 * @param {Object} config The config object
16807 Roo.bootstrap.Calendar = function(config){
16808 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16812 * Fires when a date is selected
16813 * @param {DatePicker} this
16814 * @param {Date} date The selected date
16818 * @event monthchange
16819 * Fires when the displayed month changes
16820 * @param {DatePicker} this
16821 * @param {Date} date The selected month
16823 'monthchange': true,
16825 * @event evententer
16826 * Fires when mouse over an event
16827 * @param {Calendar} this
16828 * @param {event} Event
16830 'evententer': true,
16832 * @event eventleave
16833 * Fires when the mouse leaves an
16834 * @param {Calendar} this
16837 'eventleave': true,
16839 * @event eventclick
16840 * Fires when the mouse click an
16841 * @param {Calendar} this
16850 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16853 * @cfg {Number} startDay
16854 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16862 getAutoCreate : function(){
16865 var fc_button = function(name, corner, style, content ) {
16866 return Roo.apply({},{
16868 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16870 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16873 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16884 style : 'width:100%',
16891 cls : 'fc-header-left',
16893 fc_button('prev', 'left', 'arrow', '‹' ),
16894 fc_button('next', 'right', 'arrow', '›' ),
16895 { tag: 'span', cls: 'fc-header-space' },
16896 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16904 cls : 'fc-header-center',
16908 cls: 'fc-header-title',
16911 html : 'month / year'
16919 cls : 'fc-header-right',
16921 /* fc_button('month', 'left', '', 'month' ),
16922 fc_button('week', '', '', 'week' ),
16923 fc_button('day', 'right', '', 'day' )
16935 header = this.header;
16938 var cal_heads = function() {
16940 // fixme - handle this.
16942 for (var i =0; i < Date.dayNames.length; i++) {
16943 var d = Date.dayNames[i];
16946 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16947 html : d.substring(0,3)
16951 ret[0].cls += ' fc-first';
16952 ret[6].cls += ' fc-last';
16955 var cal_cell = function(n) {
16958 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16963 cls: 'fc-day-number',
16967 cls: 'fc-day-content',
16971 style: 'position: relative;' // height: 17px;
16983 var cal_rows = function() {
16986 for (var r = 0; r < 6; r++) {
16993 for (var i =0; i < Date.dayNames.length; i++) {
16994 var d = Date.dayNames[i];
16995 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16998 row.cn[0].cls+=' fc-first';
16999 row.cn[0].cn[0].style = 'min-height:90px';
17000 row.cn[6].cls+=' fc-last';
17004 ret[0].cls += ' fc-first';
17005 ret[4].cls += ' fc-prev-last';
17006 ret[5].cls += ' fc-last';
17013 cls: 'fc-border-separate',
17014 style : 'width:100%',
17022 cls : 'fc-first fc-last',
17040 cls : 'fc-content',
17041 style : "position: relative;",
17044 cls : 'fc-view fc-view-month fc-grid',
17045 style : 'position: relative',
17046 unselectable : 'on',
17049 cls : 'fc-event-container',
17050 style : 'position:absolute;z-index:8;top:0;left:0;'
17068 initEvents : function()
17071 throw "can not find store for calendar";
17077 style: "text-align:center",
17081 style: "background-color:white;width:50%;margin:250 auto",
17085 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17096 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17098 var size = this.el.select('.fc-content', true).first().getSize();
17099 this.maskEl.setSize(size.width, size.height);
17100 this.maskEl.enableDisplayMode("block");
17101 if(!this.loadMask){
17102 this.maskEl.hide();
17105 this.store = Roo.factory(this.store, Roo.data);
17106 this.store.on('load', this.onLoad, this);
17107 this.store.on('beforeload', this.onBeforeLoad, this);
17111 this.cells = this.el.select('.fc-day',true);
17112 //Roo.log(this.cells);
17113 this.textNodes = this.el.query('.fc-day-number');
17114 this.cells.addClassOnOver('fc-state-hover');
17116 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17117 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17118 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17119 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17121 this.on('monthchange', this.onMonthChange, this);
17123 this.update(new Date().clearTime());
17126 resize : function() {
17127 var sz = this.el.getSize();
17129 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17130 this.el.select('.fc-day-content div',true).setHeight(34);
17135 showPrevMonth : function(e){
17136 this.update(this.activeDate.add("mo", -1));
17138 showToday : function(e){
17139 this.update(new Date().clearTime());
17142 showNextMonth : function(e){
17143 this.update(this.activeDate.add("mo", 1));
17147 showPrevYear : function(){
17148 this.update(this.activeDate.add("y", -1));
17152 showNextYear : function(){
17153 this.update(this.activeDate.add("y", 1));
17158 update : function(date)
17160 var vd = this.activeDate;
17161 this.activeDate = date;
17162 // if(vd && this.el){
17163 // var t = date.getTime();
17164 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17165 // Roo.log('using add remove');
17167 // this.fireEvent('monthchange', this, date);
17169 // this.cells.removeClass("fc-state-highlight");
17170 // this.cells.each(function(c){
17171 // if(c.dateValue == t){
17172 // c.addClass("fc-state-highlight");
17173 // setTimeout(function(){
17174 // try{c.dom.firstChild.focus();}catch(e){}
17184 var days = date.getDaysInMonth();
17186 var firstOfMonth = date.getFirstDateOfMonth();
17187 var startingPos = firstOfMonth.getDay()-this.startDay;
17189 if(startingPos < this.startDay){
17193 var pm = date.add(Date.MONTH, -1);
17194 var prevStart = pm.getDaysInMonth()-startingPos;
17196 this.cells = this.el.select('.fc-day',true);
17197 this.textNodes = this.el.query('.fc-day-number');
17198 this.cells.addClassOnOver('fc-state-hover');
17200 var cells = this.cells.elements;
17201 var textEls = this.textNodes;
17203 Roo.each(cells, function(cell){
17204 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17207 days += startingPos;
17209 // convert everything to numbers so it's fast
17210 var day = 86400000;
17211 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17214 //Roo.log(prevStart);
17216 var today = new Date().clearTime().getTime();
17217 var sel = date.clearTime().getTime();
17218 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17219 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17220 var ddMatch = this.disabledDatesRE;
17221 var ddText = this.disabledDatesText;
17222 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17223 var ddaysText = this.disabledDaysText;
17224 var format = this.format;
17226 var setCellClass = function(cal, cell){
17230 //Roo.log('set Cell Class');
17232 var t = d.getTime();
17236 cell.dateValue = t;
17238 cell.className += " fc-today";
17239 cell.className += " fc-state-highlight";
17240 cell.title = cal.todayText;
17243 // disable highlight in other month..
17244 //cell.className += " fc-state-highlight";
17249 cell.className = " fc-state-disabled";
17250 cell.title = cal.minText;
17254 cell.className = " fc-state-disabled";
17255 cell.title = cal.maxText;
17259 if(ddays.indexOf(d.getDay()) != -1){
17260 cell.title = ddaysText;
17261 cell.className = " fc-state-disabled";
17264 if(ddMatch && format){
17265 var fvalue = d.dateFormat(format);
17266 if(ddMatch.test(fvalue)){
17267 cell.title = ddText.replace("%0", fvalue);
17268 cell.className = " fc-state-disabled";
17272 if (!cell.initialClassName) {
17273 cell.initialClassName = cell.dom.className;
17276 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17281 for(; i < startingPos; i++) {
17282 textEls[i].innerHTML = (++prevStart);
17283 d.setDate(d.getDate()+1);
17285 cells[i].className = "fc-past fc-other-month";
17286 setCellClass(this, cells[i]);
17291 for(; i < days; i++){
17292 intDay = i - startingPos + 1;
17293 textEls[i].innerHTML = (intDay);
17294 d.setDate(d.getDate()+1);
17296 cells[i].className = ''; // "x-date-active";
17297 setCellClass(this, cells[i]);
17301 for(; i < 42; i++) {
17302 textEls[i].innerHTML = (++extraDays);
17303 d.setDate(d.getDate()+1);
17305 cells[i].className = "fc-future fc-other-month";
17306 setCellClass(this, cells[i]);
17309 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17311 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17313 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17314 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17316 if(totalRows != 6){
17317 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17318 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17321 this.fireEvent('monthchange', this, date);
17325 if(!this.internalRender){
17326 var main = this.el.dom.firstChild;
17327 var w = main.offsetWidth;
17328 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17329 Roo.fly(main).setWidth(w);
17330 this.internalRender = true;
17331 // opera does not respect the auto grow header center column
17332 // then, after it gets a width opera refuses to recalculate
17333 // without a second pass
17334 if(Roo.isOpera && !this.secondPass){
17335 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17336 this.secondPass = true;
17337 this.update.defer(10, this, [date]);
17344 findCell : function(dt) {
17345 dt = dt.clearTime().getTime();
17347 this.cells.each(function(c){
17348 //Roo.log("check " +c.dateValue + '?=' + dt);
17349 if(c.dateValue == dt){
17359 findCells : function(ev) {
17360 var s = ev.start.clone().clearTime().getTime();
17362 var e= ev.end.clone().clearTime().getTime();
17365 this.cells.each(function(c){
17366 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17368 if(c.dateValue > e){
17371 if(c.dateValue < s){
17380 // findBestRow: function(cells)
17384 // for (var i =0 ; i < cells.length;i++) {
17385 // ret = Math.max(cells[i].rows || 0,ret);
17392 addItem : function(ev)
17394 // look for vertical location slot in
17395 var cells = this.findCells(ev);
17397 // ev.row = this.findBestRow(cells);
17399 // work out the location.
17403 for(var i =0; i < cells.length; i++) {
17405 cells[i].row = cells[0].row;
17408 cells[i].row = cells[i].row + 1;
17418 if (crow.start.getY() == cells[i].getY()) {
17420 crow.end = cells[i];
17437 cells[0].events.push(ev);
17439 this.calevents.push(ev);
17442 clearEvents: function() {
17444 if(!this.calevents){
17448 Roo.each(this.cells.elements, function(c){
17454 Roo.each(this.calevents, function(e) {
17455 Roo.each(e.els, function(el) {
17456 el.un('mouseenter' ,this.onEventEnter, this);
17457 el.un('mouseleave' ,this.onEventLeave, this);
17462 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17468 renderEvents: function()
17472 this.cells.each(function(c) {
17481 if(c.row != c.events.length){
17482 r = 4 - (4 - (c.row - c.events.length));
17485 c.events = ev.slice(0, r);
17486 c.more = ev.slice(r);
17488 if(c.more.length && c.more.length == 1){
17489 c.events.push(c.more.pop());
17492 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17496 this.cells.each(function(c) {
17498 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17501 for (var e = 0; e < c.events.length; e++){
17502 var ev = c.events[e];
17503 var rows = ev.rows;
17505 for(var i = 0; i < rows.length; i++) {
17507 // how many rows should it span..
17510 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17511 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17513 unselectable : "on",
17516 cls: 'fc-event-inner',
17520 // cls: 'fc-event-time',
17521 // html : cells.length > 1 ? '' : ev.time
17525 cls: 'fc-event-title',
17526 html : String.format('{0}', ev.title)
17533 cls: 'ui-resizable-handle ui-resizable-e',
17534 html : '  '
17541 cfg.cls += ' fc-event-start';
17543 if ((i+1) == rows.length) {
17544 cfg.cls += ' fc-event-end';
17547 var ctr = _this.el.select('.fc-event-container',true).first();
17548 var cg = ctr.createChild(cfg);
17550 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17551 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17553 var r = (c.more.length) ? 1 : 0;
17554 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17555 cg.setWidth(ebox.right - sbox.x -2);
17557 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17558 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17559 cg.on('click', _this.onEventClick, _this, ev);
17570 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17571 style : 'position: absolute',
17572 unselectable : "on",
17575 cls: 'fc-event-inner',
17579 cls: 'fc-event-title',
17587 cls: 'ui-resizable-handle ui-resizable-e',
17588 html : '  '
17594 var ctr = _this.el.select('.fc-event-container',true).first();
17595 var cg = ctr.createChild(cfg);
17597 var sbox = c.select('.fc-day-content',true).first().getBox();
17598 var ebox = c.select('.fc-day-content',true).first().getBox();
17600 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17601 cg.setWidth(ebox.right - sbox.x -2);
17603 cg.on('click', _this.onMoreEventClick, _this, c.more);
17613 onEventEnter: function (e, el,event,d) {
17614 this.fireEvent('evententer', this, el, event);
17617 onEventLeave: function (e, el,event,d) {
17618 this.fireEvent('eventleave', this, el, event);
17621 onEventClick: function (e, el,event,d) {
17622 this.fireEvent('eventclick', this, el, event);
17625 onMonthChange: function () {
17629 onMoreEventClick: function(e, el, more)
17633 this.calpopover.placement = 'right';
17634 this.calpopover.setTitle('More');
17636 this.calpopover.setContent('');
17638 var ctr = this.calpopover.el.select('.popover-content', true).first();
17640 Roo.each(more, function(m){
17642 cls : 'fc-event-hori fc-event-draggable',
17645 var cg = ctr.createChild(cfg);
17647 cg.on('click', _this.onEventClick, _this, m);
17650 this.calpopover.show(el);
17655 onLoad: function ()
17657 this.calevents = [];
17660 if(this.store.getCount() > 0){
17661 this.store.data.each(function(d){
17664 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17665 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17666 time : d.data.start_time,
17667 title : d.data.title,
17668 description : d.data.description,
17669 venue : d.data.venue
17674 this.renderEvents();
17676 if(this.calevents.length && this.loadMask){
17677 this.maskEl.hide();
17681 onBeforeLoad: function()
17683 this.clearEvents();
17685 this.maskEl.show();
17699 * @class Roo.bootstrap.Popover
17700 * @extends Roo.bootstrap.Component
17701 * Bootstrap Popover class
17702 * @cfg {String} html contents of the popover (or false to use children..)
17703 * @cfg {String} title of popover (or false to hide)
17704 * @cfg {String} placement how it is placed
17705 * @cfg {String} trigger click || hover (or false to trigger manually)
17706 * @cfg {String} over what (parent or false to trigger manually.)
17707 * @cfg {Number} delay - delay before showing
17710 * Create a new Popover
17711 * @param {Object} config The config object
17714 Roo.bootstrap.Popover = function(config){
17715 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17721 * After the popover show
17723 * @param {Roo.bootstrap.Popover} this
17728 * After the popover hide
17730 * @param {Roo.bootstrap.Popover} this
17736 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17738 title: 'Fill in a title',
17741 placement : 'right',
17742 trigger : 'hover', // hover
17748 can_build_overlaid : false,
17750 getChildContainer : function()
17752 return this.el.select('.popover-content',true).first();
17755 getAutoCreate : function(){
17758 cls : 'popover roo-dynamic',
17759 style: 'display:block',
17765 cls : 'popover-inner',
17769 cls: 'popover-title popover-header',
17773 cls : 'popover-content popover-body',
17784 setTitle: function(str)
17787 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17789 setContent: function(str)
17792 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17794 // as it get's added to the bottom of the page.
17795 onRender : function(ct, position)
17797 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17799 var cfg = Roo.apply({}, this.getAutoCreate());
17803 cfg.cls += ' ' + this.cls;
17806 cfg.style = this.style;
17808 //Roo.log("adding to ");
17809 this.el = Roo.get(document.body).createChild(cfg, position);
17810 // Roo.log(this.el);
17815 initEvents : function()
17817 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17818 this.el.enableDisplayMode('block');
17820 if (this.over === false) {
17823 if (this.triggers === false) {
17826 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17827 var triggers = this.trigger ? this.trigger.split(' ') : [];
17828 Roo.each(triggers, function(trigger) {
17830 if (trigger == 'click') {
17831 on_el.on('click', this.toggle, this);
17832 } else if (trigger != 'manual') {
17833 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17834 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17836 on_el.on(eventIn ,this.enter, this);
17837 on_el.on(eventOut, this.leave, this);
17848 toggle : function () {
17849 this.hoverState == 'in' ? this.leave() : this.enter();
17852 enter : function () {
17854 clearTimeout(this.timeout);
17856 this.hoverState = 'in';
17858 if (!this.delay || !this.delay.show) {
17863 this.timeout = setTimeout(function () {
17864 if (_t.hoverState == 'in') {
17867 }, this.delay.show)
17870 leave : function() {
17871 clearTimeout(this.timeout);
17873 this.hoverState = 'out';
17875 if (!this.delay || !this.delay.hide) {
17880 this.timeout = setTimeout(function () {
17881 if (_t.hoverState == 'out') {
17884 }, this.delay.hide)
17887 show : function (on_el)
17890 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17894 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17895 if (this.html !== false) {
17896 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17898 this.el.removeClass([
17899 'fade','top','bottom', 'left', 'right','in',
17900 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17902 if (!this.title.length) {
17903 this.el.select('.popover-title',true).hide();
17906 var placement = typeof this.placement == 'function' ?
17907 this.placement.call(this, this.el, on_el) :
17910 var autoToken = /\s?auto?\s?/i;
17911 var autoPlace = autoToken.test(placement);
17913 placement = placement.replace(autoToken, '') || 'top';
17917 //this.el.setXY([0,0]);
17919 this.el.dom.style.display='block';
17920 this.el.addClass(placement);
17922 //this.el.appendTo(on_el);
17924 var p = this.getPosition();
17925 var box = this.el.getBox();
17930 var align = Roo.bootstrap.Popover.alignment[placement];
17933 this.el.alignTo(on_el, align[0],align[1]);
17934 //var arrow = this.el.select('.arrow',true).first();
17935 //arrow.set(align[2],
17937 this.el.addClass('in');
17940 if (this.el.hasClass('fade')) {
17944 this.hoverState = 'in';
17946 this.fireEvent('show', this);
17951 this.el.setXY([0,0]);
17952 this.el.removeClass('in');
17954 this.hoverState = null;
17956 this.fireEvent('hide', this);
17961 Roo.bootstrap.Popover.alignment = {
17962 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
17963 'right' : ['l-r', [10,0], 'left bs-popover-left'],
17964 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
17965 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
17976 * @class Roo.bootstrap.Progress
17977 * @extends Roo.bootstrap.Component
17978 * Bootstrap Progress class
17979 * @cfg {Boolean} striped striped of the progress bar
17980 * @cfg {Boolean} active animated of the progress bar
17984 * Create a new Progress
17985 * @param {Object} config The config object
17988 Roo.bootstrap.Progress = function(config){
17989 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17992 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17997 getAutoCreate : function(){
18005 cfg.cls += ' progress-striped';
18009 cfg.cls += ' active';
18028 * @class Roo.bootstrap.ProgressBar
18029 * @extends Roo.bootstrap.Component
18030 * Bootstrap ProgressBar class
18031 * @cfg {Number} aria_valuenow aria-value now
18032 * @cfg {Number} aria_valuemin aria-value min
18033 * @cfg {Number} aria_valuemax aria-value max
18034 * @cfg {String} label label for the progress bar
18035 * @cfg {String} panel (success | info | warning | danger )
18036 * @cfg {String} role role of the progress bar
18037 * @cfg {String} sr_only text
18041 * Create a new ProgressBar
18042 * @param {Object} config The config object
18045 Roo.bootstrap.ProgressBar = function(config){
18046 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18049 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18053 aria_valuemax : 100,
18059 getAutoCreate : function()
18064 cls: 'progress-bar',
18065 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18077 cfg.role = this.role;
18080 if(this.aria_valuenow){
18081 cfg['aria-valuenow'] = this.aria_valuenow;
18084 if(this.aria_valuemin){
18085 cfg['aria-valuemin'] = this.aria_valuemin;
18088 if(this.aria_valuemax){
18089 cfg['aria-valuemax'] = this.aria_valuemax;
18092 if(this.label && !this.sr_only){
18093 cfg.html = this.label;
18097 cfg.cls += ' progress-bar-' + this.panel;
18103 update : function(aria_valuenow)
18105 this.aria_valuenow = aria_valuenow;
18107 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18122 * @class Roo.bootstrap.TabGroup
18123 * @extends Roo.bootstrap.Column
18124 * Bootstrap Column class
18125 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18126 * @cfg {Boolean} carousel true to make the group behave like a carousel
18127 * @cfg {Boolean} bullets show bullets for the panels
18128 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18129 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18130 * @cfg {Boolean} showarrow (true|false) show arrow default true
18133 * Create a new TabGroup
18134 * @param {Object} config The config object
18137 Roo.bootstrap.TabGroup = function(config){
18138 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18140 this.navId = Roo.id();
18143 Roo.bootstrap.TabGroup.register(this);
18147 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18150 transition : false,
18155 slideOnTouch : false,
18158 getAutoCreate : function()
18160 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18162 cfg.cls += ' tab-content';
18164 if (this.carousel) {
18165 cfg.cls += ' carousel slide';
18168 cls : 'carousel-inner',
18172 if(this.bullets && !Roo.isTouch){
18175 cls : 'carousel-bullets',
18179 if(this.bullets_cls){
18180 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18187 cfg.cn[0].cn.push(bullets);
18190 if(this.showarrow){
18191 cfg.cn[0].cn.push({
18193 class : 'carousel-arrow',
18197 class : 'carousel-prev',
18201 class : 'fa fa-chevron-left'
18207 class : 'carousel-next',
18211 class : 'fa fa-chevron-right'
18224 initEvents: function()
18226 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18227 // this.el.on("touchstart", this.onTouchStart, this);
18230 if(this.autoslide){
18233 this.slideFn = window.setInterval(function() {
18234 _this.showPanelNext();
18238 if(this.showarrow){
18239 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18240 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18246 // onTouchStart : function(e, el, o)
18248 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18252 // this.showPanelNext();
18256 getChildContainer : function()
18258 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18262 * register a Navigation item
18263 * @param {Roo.bootstrap.NavItem} the navitem to add
18265 register : function(item)
18267 this.tabs.push( item);
18268 item.navId = this.navId; // not really needed..
18273 getActivePanel : function()
18276 Roo.each(this.tabs, function(t) {
18286 getPanelByName : function(n)
18289 Roo.each(this.tabs, function(t) {
18290 if (t.tabId == n) {
18298 indexOfPanel : function(p)
18301 Roo.each(this.tabs, function(t,i) {
18302 if (t.tabId == p.tabId) {
18311 * show a specific panel
18312 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18313 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18315 showPanel : function (pan)
18317 if(this.transition || typeof(pan) == 'undefined'){
18318 Roo.log("waiting for the transitionend");
18322 if (typeof(pan) == 'number') {
18323 pan = this.tabs[pan];
18326 if (typeof(pan) == 'string') {
18327 pan = this.getPanelByName(pan);
18330 var cur = this.getActivePanel();
18333 Roo.log('pan or acitve pan is undefined');
18337 if (pan.tabId == this.getActivePanel().tabId) {
18341 if (false === cur.fireEvent('beforedeactivate')) {
18345 if(this.bullets > 0 && !Roo.isTouch){
18346 this.setActiveBullet(this.indexOfPanel(pan));
18349 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18351 this.transition = true;
18352 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18353 var lr = dir == 'next' ? 'left' : 'right';
18354 pan.el.addClass(dir); // or prev
18355 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18356 cur.el.addClass(lr); // or right
18357 pan.el.addClass(lr);
18360 cur.el.on('transitionend', function() {
18361 Roo.log("trans end?");
18363 pan.el.removeClass([lr,dir]);
18364 pan.setActive(true);
18366 cur.el.removeClass([lr]);
18367 cur.setActive(false);
18369 _this.transition = false;
18371 }, this, { single: true } );
18376 cur.setActive(false);
18377 pan.setActive(true);
18382 showPanelNext : function()
18384 var i = this.indexOfPanel(this.getActivePanel());
18386 if (i >= this.tabs.length - 1 && !this.autoslide) {
18390 if (i >= this.tabs.length - 1 && this.autoslide) {
18394 this.showPanel(this.tabs[i+1]);
18397 showPanelPrev : function()
18399 var i = this.indexOfPanel(this.getActivePanel());
18401 if (i < 1 && !this.autoslide) {
18405 if (i < 1 && this.autoslide) {
18406 i = this.tabs.length;
18409 this.showPanel(this.tabs[i-1]);
18413 addBullet: function()
18415 if(!this.bullets || Roo.isTouch){
18418 var ctr = this.el.select('.carousel-bullets',true).first();
18419 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18420 var bullet = ctr.createChild({
18421 cls : 'bullet bullet-' + i
18422 },ctr.dom.lastChild);
18427 bullet.on('click', (function(e, el, o, ii, t){
18429 e.preventDefault();
18431 this.showPanel(ii);
18433 if(this.autoslide && this.slideFn){
18434 clearInterval(this.slideFn);
18435 this.slideFn = window.setInterval(function() {
18436 _this.showPanelNext();
18440 }).createDelegate(this, [i, bullet], true));
18445 setActiveBullet : function(i)
18451 Roo.each(this.el.select('.bullet', true).elements, function(el){
18452 el.removeClass('selected');
18455 var bullet = this.el.select('.bullet-' + i, true).first();
18461 bullet.addClass('selected');
18472 Roo.apply(Roo.bootstrap.TabGroup, {
18476 * register a Navigation Group
18477 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18479 register : function(navgrp)
18481 this.groups[navgrp.navId] = navgrp;
18485 * fetch a Navigation Group based on the navigation ID
18486 * if one does not exist , it will get created.
18487 * @param {string} the navgroup to add
18488 * @returns {Roo.bootstrap.NavGroup} the navgroup
18490 get: function(navId) {
18491 if (typeof(this.groups[navId]) == 'undefined') {
18492 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18494 return this.groups[navId] ;
18509 * @class Roo.bootstrap.TabPanel
18510 * @extends Roo.bootstrap.Component
18511 * Bootstrap TabPanel class
18512 * @cfg {Boolean} active panel active
18513 * @cfg {String} html panel content
18514 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18515 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18516 * @cfg {String} href click to link..
18520 * Create a new TabPanel
18521 * @param {Object} config The config object
18524 Roo.bootstrap.TabPanel = function(config){
18525 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18529 * Fires when the active status changes
18530 * @param {Roo.bootstrap.TabPanel} this
18531 * @param {Boolean} state the new state
18536 * @event beforedeactivate
18537 * Fires before a tab is de-activated - can be used to do validation on a form.
18538 * @param {Roo.bootstrap.TabPanel} this
18539 * @return {Boolean} false if there is an error
18542 'beforedeactivate': true
18545 this.tabId = this.tabId || Roo.id();
18549 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18557 getAutoCreate : function(){
18560 // item is needed for carousel - not sure if it has any effect otherwise
18561 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18562 html: this.html || ''
18566 cfg.cls += ' active';
18570 cfg.tabId = this.tabId;
18577 initEvents: function()
18579 var p = this.parent();
18581 this.navId = this.navId || p.navId;
18583 if (typeof(this.navId) != 'undefined') {
18584 // not really needed.. but just in case.. parent should be a NavGroup.
18585 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18589 var i = tg.tabs.length - 1;
18591 if(this.active && tg.bullets > 0 && i < tg.bullets){
18592 tg.setActiveBullet(i);
18596 this.el.on('click', this.onClick, this);
18599 this.el.on("touchstart", this.onTouchStart, this);
18600 this.el.on("touchmove", this.onTouchMove, this);
18601 this.el.on("touchend", this.onTouchEnd, this);
18606 onRender : function(ct, position)
18608 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18611 setActive : function(state)
18613 Roo.log("panel - set active " + this.tabId + "=" + state);
18615 this.active = state;
18617 this.el.removeClass('active');
18619 } else if (!this.el.hasClass('active')) {
18620 this.el.addClass('active');
18623 this.fireEvent('changed', this, state);
18626 onClick : function(e)
18628 e.preventDefault();
18630 if(!this.href.length){
18634 window.location.href = this.href;
18643 onTouchStart : function(e)
18645 this.swiping = false;
18647 this.startX = e.browserEvent.touches[0].clientX;
18648 this.startY = e.browserEvent.touches[0].clientY;
18651 onTouchMove : function(e)
18653 this.swiping = true;
18655 this.endX = e.browserEvent.touches[0].clientX;
18656 this.endY = e.browserEvent.touches[0].clientY;
18659 onTouchEnd : function(e)
18666 var tabGroup = this.parent();
18668 if(this.endX > this.startX){ // swiping right
18669 tabGroup.showPanelPrev();
18673 if(this.startX > this.endX){ // swiping left
18674 tabGroup.showPanelNext();
18693 * @class Roo.bootstrap.DateField
18694 * @extends Roo.bootstrap.Input
18695 * Bootstrap DateField class
18696 * @cfg {Number} weekStart default 0
18697 * @cfg {String} viewMode default empty, (months|years)
18698 * @cfg {String} minViewMode default empty, (months|years)
18699 * @cfg {Number} startDate default -Infinity
18700 * @cfg {Number} endDate default Infinity
18701 * @cfg {Boolean} todayHighlight default false
18702 * @cfg {Boolean} todayBtn default false
18703 * @cfg {Boolean} calendarWeeks default false
18704 * @cfg {Object} daysOfWeekDisabled default empty
18705 * @cfg {Boolean} singleMode default false (true | false)
18707 * @cfg {Boolean} keyboardNavigation default true
18708 * @cfg {String} language default en
18711 * Create a new DateField
18712 * @param {Object} config The config object
18715 Roo.bootstrap.DateField = function(config){
18716 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18720 * Fires when this field show.
18721 * @param {Roo.bootstrap.DateField} this
18722 * @param {Mixed} date The date value
18727 * Fires when this field hide.
18728 * @param {Roo.bootstrap.DateField} this
18729 * @param {Mixed} date The date value
18734 * Fires when select a date.
18735 * @param {Roo.bootstrap.DateField} this
18736 * @param {Mixed} date The date value
18740 * @event beforeselect
18741 * Fires when before select a date.
18742 * @param {Roo.bootstrap.DateField} this
18743 * @param {Mixed} date The date value
18745 beforeselect : true
18749 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18752 * @cfg {String} format
18753 * The default date format string which can be overriden for localization support. The format must be
18754 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18758 * @cfg {String} altFormats
18759 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18760 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18762 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18770 todayHighlight : false,
18776 keyboardNavigation: true,
18778 calendarWeeks: false,
18780 startDate: -Infinity,
18784 daysOfWeekDisabled: [],
18788 singleMode : false,
18790 UTCDate: function()
18792 return new Date(Date.UTC.apply(Date, arguments));
18795 UTCToday: function()
18797 var today = new Date();
18798 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18801 getDate: function() {
18802 var d = this.getUTCDate();
18803 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18806 getUTCDate: function() {
18810 setDate: function(d) {
18811 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18814 setUTCDate: function(d) {
18816 this.setValue(this.formatDate(this.date));
18819 onRender: function(ct, position)
18822 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18824 this.language = this.language || 'en';
18825 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18826 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18828 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18829 this.format = this.format || 'm/d/y';
18830 this.isInline = false;
18831 this.isInput = true;
18832 this.component = this.el.select('.add-on', true).first() || false;
18833 this.component = (this.component && this.component.length === 0) ? false : this.component;
18834 this.hasInput = this.component && this.inputEl().length;
18836 if (typeof(this.minViewMode === 'string')) {
18837 switch (this.minViewMode) {
18839 this.minViewMode = 1;
18842 this.minViewMode = 2;
18845 this.minViewMode = 0;
18850 if (typeof(this.viewMode === 'string')) {
18851 switch (this.viewMode) {
18864 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18866 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18868 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18870 this.picker().on('mousedown', this.onMousedown, this);
18871 this.picker().on('click', this.onClick, this);
18873 this.picker().addClass('datepicker-dropdown');
18875 this.startViewMode = this.viewMode;
18877 if(this.singleMode){
18878 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18879 v.setVisibilityMode(Roo.Element.DISPLAY);
18883 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18884 v.setStyle('width', '189px');
18888 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18889 if(!this.calendarWeeks){
18894 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18895 v.attr('colspan', function(i, val){
18896 return parseInt(val) + 1;
18901 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18903 this.setStartDate(this.startDate);
18904 this.setEndDate(this.endDate);
18906 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18913 if(this.isInline) {
18918 picker : function()
18920 return this.pickerEl;
18921 // return this.el.select('.datepicker', true).first();
18924 fillDow: function()
18926 var dowCnt = this.weekStart;
18935 if(this.calendarWeeks){
18943 while (dowCnt < this.weekStart + 7) {
18947 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18951 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18954 fillMonths: function()
18957 var months = this.picker().select('>.datepicker-months td', true).first();
18959 months.dom.innerHTML = '';
18965 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18968 months.createChild(month);
18975 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;
18977 if (this.date < this.startDate) {
18978 this.viewDate = new Date(this.startDate);
18979 } else if (this.date > this.endDate) {
18980 this.viewDate = new Date(this.endDate);
18982 this.viewDate = new Date(this.date);
18990 var d = new Date(this.viewDate),
18991 year = d.getUTCFullYear(),
18992 month = d.getUTCMonth(),
18993 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18994 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18995 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18996 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18997 currentDate = this.date && this.date.valueOf(),
18998 today = this.UTCToday();
19000 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19002 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19004 // this.picker.select('>tfoot th.today').
19005 // .text(dates[this.language].today)
19006 // .toggle(this.todayBtn !== false);
19008 this.updateNavArrows();
19011 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19013 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19015 prevMonth.setUTCDate(day);
19017 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19019 var nextMonth = new Date(prevMonth);
19021 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19023 nextMonth = nextMonth.valueOf();
19025 var fillMonths = false;
19027 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19029 while(prevMonth.valueOf() <= nextMonth) {
19032 if (prevMonth.getUTCDay() === this.weekStart) {
19034 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19042 if(this.calendarWeeks){
19043 // ISO 8601: First week contains first thursday.
19044 // ISO also states week starts on Monday, but we can be more abstract here.
19046 // Start of current week: based on weekstart/current date
19047 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19048 // Thursday of this week
19049 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19050 // First Thursday of year, year from thursday
19051 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19052 // Calendar week: ms between thursdays, div ms per day, div 7 days
19053 calWeek = (th - yth) / 864e5 / 7 + 1;
19055 fillMonths.cn.push({
19063 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19065 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19068 if (this.todayHighlight &&
19069 prevMonth.getUTCFullYear() == today.getFullYear() &&
19070 prevMonth.getUTCMonth() == today.getMonth() &&
19071 prevMonth.getUTCDate() == today.getDate()) {
19072 clsName += ' today';
19075 if (currentDate && prevMonth.valueOf() === currentDate) {
19076 clsName += ' active';
19079 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19080 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19081 clsName += ' disabled';
19084 fillMonths.cn.push({
19086 cls: 'day ' + clsName,
19087 html: prevMonth.getDate()
19090 prevMonth.setDate(prevMonth.getDate()+1);
19093 var currentYear = this.date && this.date.getUTCFullYear();
19094 var currentMonth = this.date && this.date.getUTCMonth();
19096 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19098 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19099 v.removeClass('active');
19101 if(currentYear === year && k === currentMonth){
19102 v.addClass('active');
19105 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19106 v.addClass('disabled');
19112 year = parseInt(year/10, 10) * 10;
19114 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19116 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19119 for (var i = -1; i < 11; i++) {
19120 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19122 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19130 showMode: function(dir)
19133 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19136 Roo.each(this.picker().select('>div',true).elements, function(v){
19137 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19140 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19145 if(this.isInline) {
19149 this.picker().removeClass(['bottom', 'top']);
19151 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19153 * place to the top of element!
19157 this.picker().addClass('top');
19158 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19163 this.picker().addClass('bottom');
19165 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19168 parseDate : function(value)
19170 if(!value || value instanceof Date){
19173 var v = Date.parseDate(value, this.format);
19174 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19175 v = Date.parseDate(value, 'Y-m-d');
19177 if(!v && this.altFormats){
19178 if(!this.altFormatsArray){
19179 this.altFormatsArray = this.altFormats.split("|");
19181 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19182 v = Date.parseDate(value, this.altFormatsArray[i]);
19188 formatDate : function(date, fmt)
19190 return (!date || !(date instanceof Date)) ?
19191 date : date.dateFormat(fmt || this.format);
19194 onFocus : function()
19196 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19200 onBlur : function()
19202 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19204 var d = this.inputEl().getValue();
19211 showPopup : function()
19213 this.picker().show();
19217 this.fireEvent('showpopup', this, this.date);
19220 hidePopup : function()
19222 if(this.isInline) {
19225 this.picker().hide();
19226 this.viewMode = this.startViewMode;
19229 this.fireEvent('hidepopup', this, this.date);
19233 onMousedown: function(e)
19235 e.stopPropagation();
19236 e.preventDefault();
19241 Roo.bootstrap.DateField.superclass.keyup.call(this);
19245 setValue: function(v)
19247 if(this.fireEvent('beforeselect', this, v) !== false){
19248 var d = new Date(this.parseDate(v) ).clearTime();
19250 if(isNaN(d.getTime())){
19251 this.date = this.viewDate = '';
19252 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19256 v = this.formatDate(d);
19258 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19260 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19264 this.fireEvent('select', this, this.date);
19268 getValue: function()
19270 return this.formatDate(this.date);
19273 fireKey: function(e)
19275 if (!this.picker().isVisible()){
19276 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19282 var dateChanged = false,
19284 newDate, newViewDate;
19289 e.preventDefault();
19293 if (!this.keyboardNavigation) {
19296 dir = e.keyCode == 37 ? -1 : 1;
19299 newDate = this.moveYear(this.date, dir);
19300 newViewDate = this.moveYear(this.viewDate, dir);
19301 } else if (e.shiftKey){
19302 newDate = this.moveMonth(this.date, dir);
19303 newViewDate = this.moveMonth(this.viewDate, dir);
19305 newDate = new Date(this.date);
19306 newDate.setUTCDate(this.date.getUTCDate() + dir);
19307 newViewDate = new Date(this.viewDate);
19308 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19310 if (this.dateWithinRange(newDate)){
19311 this.date = newDate;
19312 this.viewDate = newViewDate;
19313 this.setValue(this.formatDate(this.date));
19315 e.preventDefault();
19316 dateChanged = true;
19321 if (!this.keyboardNavigation) {
19324 dir = e.keyCode == 38 ? -1 : 1;
19326 newDate = this.moveYear(this.date, dir);
19327 newViewDate = this.moveYear(this.viewDate, dir);
19328 } else if (e.shiftKey){
19329 newDate = this.moveMonth(this.date, dir);
19330 newViewDate = this.moveMonth(this.viewDate, dir);
19332 newDate = new Date(this.date);
19333 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19334 newViewDate = new Date(this.viewDate);
19335 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19337 if (this.dateWithinRange(newDate)){
19338 this.date = newDate;
19339 this.viewDate = newViewDate;
19340 this.setValue(this.formatDate(this.date));
19342 e.preventDefault();
19343 dateChanged = true;
19347 this.setValue(this.formatDate(this.date));
19349 e.preventDefault();
19352 this.setValue(this.formatDate(this.date));
19366 onClick: function(e)
19368 e.stopPropagation();
19369 e.preventDefault();
19371 var target = e.getTarget();
19373 if(target.nodeName.toLowerCase() === 'i'){
19374 target = Roo.get(target).dom.parentNode;
19377 var nodeName = target.nodeName;
19378 var className = target.className;
19379 var html = target.innerHTML;
19380 //Roo.log(nodeName);
19382 switch(nodeName.toLowerCase()) {
19384 switch(className) {
19390 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19391 switch(this.viewMode){
19393 this.viewDate = this.moveMonth(this.viewDate, dir);
19397 this.viewDate = this.moveYear(this.viewDate, dir);
19403 var date = new Date();
19404 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19406 this.setValue(this.formatDate(this.date));
19413 if (className.indexOf('disabled') < 0) {
19414 this.viewDate.setUTCDate(1);
19415 if (className.indexOf('month') > -1) {
19416 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19418 var year = parseInt(html, 10) || 0;
19419 this.viewDate.setUTCFullYear(year);
19423 if(this.singleMode){
19424 this.setValue(this.formatDate(this.viewDate));
19435 //Roo.log(className);
19436 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19437 var day = parseInt(html, 10) || 1;
19438 var year = this.viewDate.getUTCFullYear(),
19439 month = this.viewDate.getUTCMonth();
19441 if (className.indexOf('old') > -1) {
19448 } else if (className.indexOf('new') > -1) {
19456 //Roo.log([year,month,day]);
19457 this.date = this.UTCDate(year, month, day,0,0,0,0);
19458 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19460 //Roo.log(this.formatDate(this.date));
19461 this.setValue(this.formatDate(this.date));
19468 setStartDate: function(startDate)
19470 this.startDate = startDate || -Infinity;
19471 if (this.startDate !== -Infinity) {
19472 this.startDate = this.parseDate(this.startDate);
19475 this.updateNavArrows();
19478 setEndDate: function(endDate)
19480 this.endDate = endDate || Infinity;
19481 if (this.endDate !== Infinity) {
19482 this.endDate = this.parseDate(this.endDate);
19485 this.updateNavArrows();
19488 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19490 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19491 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19492 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19494 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19495 return parseInt(d, 10);
19498 this.updateNavArrows();
19501 updateNavArrows: function()
19503 if(this.singleMode){
19507 var d = new Date(this.viewDate),
19508 year = d.getUTCFullYear(),
19509 month = d.getUTCMonth();
19511 Roo.each(this.picker().select('.prev', true).elements, function(v){
19513 switch (this.viewMode) {
19516 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19522 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19529 Roo.each(this.picker().select('.next', true).elements, function(v){
19531 switch (this.viewMode) {
19534 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19540 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19548 moveMonth: function(date, dir)
19553 var new_date = new Date(date.valueOf()),
19554 day = new_date.getUTCDate(),
19555 month = new_date.getUTCMonth(),
19556 mag = Math.abs(dir),
19558 dir = dir > 0 ? 1 : -1;
19561 // If going back one month, make sure month is not current month
19562 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19564 return new_date.getUTCMonth() == month;
19566 // If going forward one month, make sure month is as expected
19567 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19569 return new_date.getUTCMonth() != new_month;
19571 new_month = month + dir;
19572 new_date.setUTCMonth(new_month);
19573 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19574 if (new_month < 0 || new_month > 11) {
19575 new_month = (new_month + 12) % 12;
19578 // For magnitudes >1, move one month at a time...
19579 for (var i=0; i<mag; i++) {
19580 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19581 new_date = this.moveMonth(new_date, dir);
19583 // ...then reset the day, keeping it in the new month
19584 new_month = new_date.getUTCMonth();
19585 new_date.setUTCDate(day);
19587 return new_month != new_date.getUTCMonth();
19590 // Common date-resetting loop -- if date is beyond end of month, make it
19593 new_date.setUTCDate(--day);
19594 new_date.setUTCMonth(new_month);
19599 moveYear: function(date, dir)
19601 return this.moveMonth(date, dir*12);
19604 dateWithinRange: function(date)
19606 return date >= this.startDate && date <= this.endDate;
19612 this.picker().remove();
19615 validateValue : function(value)
19617 if(this.getVisibilityEl().hasClass('hidden')){
19621 if(value.length < 1) {
19622 if(this.allowBlank){
19628 if(value.length < this.minLength){
19631 if(value.length > this.maxLength){
19635 var vt = Roo.form.VTypes;
19636 if(!vt[this.vtype](value, this)){
19640 if(typeof this.validator == "function"){
19641 var msg = this.validator(value);
19647 if(this.regex && !this.regex.test(value)){
19651 if(typeof(this.parseDate(value)) == 'undefined'){
19655 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19659 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19669 this.date = this.viewDate = '';
19671 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19676 Roo.apply(Roo.bootstrap.DateField, {
19687 html: '<i class="fa fa-arrow-left"/>'
19697 html: '<i class="fa fa-arrow-right"/>'
19739 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19740 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19741 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19742 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19743 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19756 navFnc: 'FullYear',
19761 navFnc: 'FullYear',
19766 Roo.apply(Roo.bootstrap.DateField, {
19770 cls: 'datepicker dropdown-menu roo-dynamic',
19774 cls: 'datepicker-days',
19778 cls: 'table-condensed',
19780 Roo.bootstrap.DateField.head,
19784 Roo.bootstrap.DateField.footer
19791 cls: 'datepicker-months',
19795 cls: 'table-condensed',
19797 Roo.bootstrap.DateField.head,
19798 Roo.bootstrap.DateField.content,
19799 Roo.bootstrap.DateField.footer
19806 cls: 'datepicker-years',
19810 cls: 'table-condensed',
19812 Roo.bootstrap.DateField.head,
19813 Roo.bootstrap.DateField.content,
19814 Roo.bootstrap.DateField.footer
19833 * @class Roo.bootstrap.TimeField
19834 * @extends Roo.bootstrap.Input
19835 * Bootstrap DateField class
19839 * Create a new TimeField
19840 * @param {Object} config The config object
19843 Roo.bootstrap.TimeField = function(config){
19844 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19848 * Fires when this field show.
19849 * @param {Roo.bootstrap.DateField} thisthis
19850 * @param {Mixed} date The date value
19855 * Fires when this field hide.
19856 * @param {Roo.bootstrap.DateField} this
19857 * @param {Mixed} date The date value
19862 * Fires when select a date.
19863 * @param {Roo.bootstrap.DateField} this
19864 * @param {Mixed} date The date value
19870 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19873 * @cfg {String} format
19874 * The default time format string which can be overriden for localization support. The format must be
19875 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19879 onRender: function(ct, position)
19882 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19884 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19886 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19888 this.pop = this.picker().select('>.datepicker-time',true).first();
19889 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19891 this.picker().on('mousedown', this.onMousedown, this);
19892 this.picker().on('click', this.onClick, this);
19894 this.picker().addClass('datepicker-dropdown');
19899 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19900 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19901 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19902 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19903 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19904 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19908 fireKey: function(e){
19909 if (!this.picker().isVisible()){
19910 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19916 e.preventDefault();
19924 this.onTogglePeriod();
19927 this.onIncrementMinutes();
19930 this.onDecrementMinutes();
19939 onClick: function(e) {
19940 e.stopPropagation();
19941 e.preventDefault();
19944 picker : function()
19946 return this.el.select('.datepicker', true).first();
19949 fillTime: function()
19951 var time = this.pop.select('tbody', true).first();
19953 time.dom.innerHTML = '';
19968 cls: 'hours-up glyphicon glyphicon-chevron-up'
19988 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20009 cls: 'timepicker-hour',
20024 cls: 'timepicker-minute',
20039 cls: 'btn btn-primary period',
20061 cls: 'hours-down glyphicon glyphicon-chevron-down'
20081 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20099 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20106 var hours = this.time.getHours();
20107 var minutes = this.time.getMinutes();
20120 hours = hours - 12;
20124 hours = '0' + hours;
20128 minutes = '0' + minutes;
20131 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20132 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20133 this.pop.select('button', true).first().dom.innerHTML = period;
20139 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20141 var cls = ['bottom'];
20143 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20150 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20155 this.picker().addClass(cls.join('-'));
20159 Roo.each(cls, function(c){
20161 _this.picker().setTop(_this.inputEl().getHeight());
20165 _this.picker().setTop(0 - _this.picker().getHeight());
20170 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20174 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20181 onFocus : function()
20183 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20187 onBlur : function()
20189 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20195 this.picker().show();
20200 this.fireEvent('show', this, this.date);
20205 this.picker().hide();
20208 this.fireEvent('hide', this, this.date);
20211 setTime : function()
20214 this.setValue(this.time.format(this.format));
20216 this.fireEvent('select', this, this.date);
20221 onMousedown: function(e){
20222 e.stopPropagation();
20223 e.preventDefault();
20226 onIncrementHours: function()
20228 Roo.log('onIncrementHours');
20229 this.time = this.time.add(Date.HOUR, 1);
20234 onDecrementHours: function()
20236 Roo.log('onDecrementHours');
20237 this.time = this.time.add(Date.HOUR, -1);
20241 onIncrementMinutes: function()
20243 Roo.log('onIncrementMinutes');
20244 this.time = this.time.add(Date.MINUTE, 1);
20248 onDecrementMinutes: function()
20250 Roo.log('onDecrementMinutes');
20251 this.time = this.time.add(Date.MINUTE, -1);
20255 onTogglePeriod: function()
20257 Roo.log('onTogglePeriod');
20258 this.time = this.time.add(Date.HOUR, 12);
20265 Roo.apply(Roo.bootstrap.TimeField, {
20295 cls: 'btn btn-info ok',
20307 Roo.apply(Roo.bootstrap.TimeField, {
20311 cls: 'datepicker dropdown-menu',
20315 cls: 'datepicker-time',
20319 cls: 'table-condensed',
20321 Roo.bootstrap.TimeField.content,
20322 Roo.bootstrap.TimeField.footer
20341 * @class Roo.bootstrap.MonthField
20342 * @extends Roo.bootstrap.Input
20343 * Bootstrap MonthField class
20345 * @cfg {String} language default en
20348 * Create a new MonthField
20349 * @param {Object} config The config object
20352 Roo.bootstrap.MonthField = function(config){
20353 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20358 * Fires when this field show.
20359 * @param {Roo.bootstrap.MonthField} this
20360 * @param {Mixed} date The date value
20365 * Fires when this field hide.
20366 * @param {Roo.bootstrap.MonthField} this
20367 * @param {Mixed} date The date value
20372 * Fires when select a date.
20373 * @param {Roo.bootstrap.MonthField} this
20374 * @param {String} oldvalue The old value
20375 * @param {String} newvalue The new value
20381 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20383 onRender: function(ct, position)
20386 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20388 this.language = this.language || 'en';
20389 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20390 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20392 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20393 this.isInline = false;
20394 this.isInput = true;
20395 this.component = this.el.select('.add-on', true).first() || false;
20396 this.component = (this.component && this.component.length === 0) ? false : this.component;
20397 this.hasInput = this.component && this.inputEL().length;
20399 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20401 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20403 this.picker().on('mousedown', this.onMousedown, this);
20404 this.picker().on('click', this.onClick, this);
20406 this.picker().addClass('datepicker-dropdown');
20408 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20409 v.setStyle('width', '189px');
20416 if(this.isInline) {
20422 setValue: function(v, suppressEvent)
20424 var o = this.getValue();
20426 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20430 if(suppressEvent !== true){
20431 this.fireEvent('select', this, o, v);
20436 getValue: function()
20441 onClick: function(e)
20443 e.stopPropagation();
20444 e.preventDefault();
20446 var target = e.getTarget();
20448 if(target.nodeName.toLowerCase() === 'i'){
20449 target = Roo.get(target).dom.parentNode;
20452 var nodeName = target.nodeName;
20453 var className = target.className;
20454 var html = target.innerHTML;
20456 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20460 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20462 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20468 picker : function()
20470 return this.pickerEl;
20473 fillMonths: function()
20476 var months = this.picker().select('>.datepicker-months td', true).first();
20478 months.dom.innerHTML = '';
20484 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20487 months.createChild(month);
20496 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20497 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20500 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20501 e.removeClass('active');
20503 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20504 e.addClass('active');
20511 if(this.isInline) {
20515 this.picker().removeClass(['bottom', 'top']);
20517 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20519 * place to the top of element!
20523 this.picker().addClass('top');
20524 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20529 this.picker().addClass('bottom');
20531 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20534 onFocus : function()
20536 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20540 onBlur : function()
20542 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20544 var d = this.inputEl().getValue();
20553 this.picker().show();
20554 this.picker().select('>.datepicker-months', true).first().show();
20558 this.fireEvent('show', this, this.date);
20563 if(this.isInline) {
20566 this.picker().hide();
20567 this.fireEvent('hide', this, this.date);
20571 onMousedown: function(e)
20573 e.stopPropagation();
20574 e.preventDefault();
20579 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20583 fireKey: function(e)
20585 if (!this.picker().isVisible()){
20586 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20597 e.preventDefault();
20601 dir = e.keyCode == 37 ? -1 : 1;
20603 this.vIndex = this.vIndex + dir;
20605 if(this.vIndex < 0){
20609 if(this.vIndex > 11){
20613 if(isNaN(this.vIndex)){
20617 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20623 dir = e.keyCode == 38 ? -1 : 1;
20625 this.vIndex = this.vIndex + dir * 4;
20627 if(this.vIndex < 0){
20631 if(this.vIndex > 11){
20635 if(isNaN(this.vIndex)){
20639 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20644 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20645 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20649 e.preventDefault();
20652 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20653 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20669 this.picker().remove();
20674 Roo.apply(Roo.bootstrap.MonthField, {
20693 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20694 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20699 Roo.apply(Roo.bootstrap.MonthField, {
20703 cls: 'datepicker dropdown-menu roo-dynamic',
20707 cls: 'datepicker-months',
20711 cls: 'table-condensed',
20713 Roo.bootstrap.DateField.content
20733 * @class Roo.bootstrap.CheckBox
20734 * @extends Roo.bootstrap.Input
20735 * Bootstrap CheckBox class
20737 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20738 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20739 * @cfg {String} boxLabel The text that appears beside the checkbox
20740 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20741 * @cfg {Boolean} checked initnal the element
20742 * @cfg {Boolean} inline inline the element (default false)
20743 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20744 * @cfg {String} tooltip label tooltip
20747 * Create a new CheckBox
20748 * @param {Object} config The config object
20751 Roo.bootstrap.CheckBox = function(config){
20752 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20757 * Fires when the element is checked or unchecked.
20758 * @param {Roo.bootstrap.CheckBox} this This input
20759 * @param {Boolean} checked The new checked value
20764 * Fires when the element is click.
20765 * @param {Roo.bootstrap.CheckBox} this This input
20772 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20774 inputType: 'checkbox',
20783 getAutoCreate : function()
20785 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20791 cfg.cls = 'form-group ' + this.inputType; //input-group
20794 cfg.cls += ' ' + this.inputType + '-inline';
20800 type : this.inputType,
20801 value : this.inputValue,
20802 cls : 'roo-' + this.inputType, //'form-box',
20803 placeholder : this.placeholder || ''
20807 if(this.inputType != 'radio'){
20811 cls : 'roo-hidden-value',
20812 value : this.checked ? this.inputValue : this.valueOff
20817 if (this.weight) { // Validity check?
20818 cfg.cls += " " + this.inputType + "-" + this.weight;
20821 if (this.disabled) {
20822 input.disabled=true;
20826 input.checked = this.checked;
20831 input.name = this.name;
20833 if(this.inputType != 'radio'){
20834 hidden.name = this.name;
20835 input.name = '_hidden_' + this.name;
20840 input.cls += ' input-' + this.size;
20845 ['xs','sm','md','lg'].map(function(size){
20846 if (settings[size]) {
20847 cfg.cls += ' col-' + size + '-' + settings[size];
20851 var inputblock = input;
20853 if (this.before || this.after) {
20856 cls : 'input-group',
20861 inputblock.cn.push({
20863 cls : 'input-group-addon',
20868 inputblock.cn.push(input);
20870 if(this.inputType != 'radio'){
20871 inputblock.cn.push(hidden);
20875 inputblock.cn.push({
20877 cls : 'input-group-addon',
20884 if (align ==='left' && this.fieldLabel.length) {
20885 // Roo.log("left and has label");
20890 cls : 'control-label',
20891 html : this.fieldLabel
20901 if(this.labelWidth > 12){
20902 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20905 if(this.labelWidth < 13 && this.labelmd == 0){
20906 this.labelmd = this.labelWidth;
20909 if(this.labellg > 0){
20910 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20911 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20914 if(this.labelmd > 0){
20915 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20916 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20919 if(this.labelsm > 0){
20920 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20921 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20924 if(this.labelxs > 0){
20925 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20926 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20929 } else if ( this.fieldLabel.length) {
20930 // Roo.log(" label");
20934 tag: this.boxLabel ? 'span' : 'label',
20936 cls: 'control-label box-input-label',
20937 //cls : 'input-group-addon',
20938 html : this.fieldLabel
20947 // Roo.log(" no label && no align");
20948 cfg.cn = [ inputblock ] ;
20954 var boxLabelCfg = {
20956 //'for': id, // box label is handled by onclick - so no for...
20958 html: this.boxLabel
20962 boxLabelCfg.tooltip = this.tooltip;
20965 cfg.cn.push(boxLabelCfg);
20968 if(this.inputType != 'radio'){
20969 cfg.cn.push(hidden);
20977 * return the real input element.
20979 inputEl: function ()
20981 return this.el.select('input.roo-' + this.inputType,true).first();
20983 hiddenEl: function ()
20985 return this.el.select('input.roo-hidden-value',true).first();
20988 labelEl: function()
20990 return this.el.select('label.control-label',true).first();
20992 /* depricated... */
20996 return this.labelEl();
20999 boxLabelEl: function()
21001 return this.el.select('label.box-label',true).first();
21004 initEvents : function()
21006 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21008 this.inputEl().on('click', this.onClick, this);
21010 if (this.boxLabel) {
21011 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21014 this.startValue = this.getValue();
21017 Roo.bootstrap.CheckBox.register(this);
21021 onClick : function(e)
21023 if(this.fireEvent('click', this, e) !== false){
21024 this.setChecked(!this.checked);
21029 setChecked : function(state,suppressEvent)
21031 this.startValue = this.getValue();
21033 if(this.inputType == 'radio'){
21035 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21036 e.dom.checked = false;
21039 this.inputEl().dom.checked = true;
21041 this.inputEl().dom.value = this.inputValue;
21043 if(suppressEvent !== true){
21044 this.fireEvent('check', this, true);
21052 this.checked = state;
21054 this.inputEl().dom.checked = state;
21057 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21059 if(suppressEvent !== true){
21060 this.fireEvent('check', this, state);
21066 getValue : function()
21068 if(this.inputType == 'radio'){
21069 return this.getGroupValue();
21072 return this.hiddenEl().dom.value;
21076 getGroupValue : function()
21078 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21082 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21085 setValue : function(v,suppressEvent)
21087 if(this.inputType == 'radio'){
21088 this.setGroupValue(v, suppressEvent);
21092 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21097 setGroupValue : function(v, suppressEvent)
21099 this.startValue = this.getValue();
21101 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21102 e.dom.checked = false;
21104 if(e.dom.value == v){
21105 e.dom.checked = true;
21109 if(suppressEvent !== true){
21110 this.fireEvent('check', this, true);
21118 validate : function()
21120 if(this.getVisibilityEl().hasClass('hidden')){
21126 (this.inputType == 'radio' && this.validateRadio()) ||
21127 (this.inputType == 'checkbox' && this.validateCheckbox())
21133 this.markInvalid();
21137 validateRadio : function()
21139 if(this.getVisibilityEl().hasClass('hidden')){
21143 if(this.allowBlank){
21149 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21150 if(!e.dom.checked){
21162 validateCheckbox : function()
21165 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21166 //return (this.getValue() == this.inputValue) ? true : false;
21169 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21177 for(var i in group){
21178 if(group[i].el.isVisible(true)){
21186 for(var i in group){
21191 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21198 * Mark this field as valid
21200 markValid : function()
21204 this.fireEvent('valid', this);
21206 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21209 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21216 if(this.inputType == 'radio'){
21217 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21218 var fg = e.findParent('.form-group', false, true);
21219 if (Roo.bootstrap.version == 3) {
21220 fg.removeClass([_this.invalidClass, _this.validClass]);
21221 fg.addClass(_this.validClass);
21223 fg.removeClass(['is-valid', 'is-invalid']);
21224 fg.addClass('is-valid');
21232 var fg = this.el.findParent('.form-group', false, true);
21233 if (Roo.bootstrap.version == 3) {
21234 fg.removeClass([this.invalidClass, this.validClass]);
21235 fg.addClass(this.validClass);
21237 fg.removeClass(['is-valid', 'is-invalid']);
21238 fg.addClass('is-valid');
21243 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21249 for(var i in group){
21250 var fg = group[i].el.findParent('.form-group', false, true);
21251 if (Roo.bootstrap.version == 3) {
21252 fg.removeClass([this.invalidClass, this.validClass]);
21253 fg.addClass(this.validClass);
21255 fg.removeClass(['is-valid', 'is-invalid']);
21256 fg.addClass('is-valid');
21262 * Mark this field as invalid
21263 * @param {String} msg The validation message
21265 markInvalid : function(msg)
21267 if(this.allowBlank){
21273 this.fireEvent('invalid', this, msg);
21275 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21278 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21282 label.markInvalid();
21285 if(this.inputType == 'radio'){
21287 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21288 var fg = e.findParent('.form-group', false, true);
21289 if (Roo.bootstrap.version == 3) {
21290 fg.removeClass([_this.invalidClass, _this.validClass]);
21291 fg.addClass(_this.invalidClass);
21293 fg.removeClass(['is-invalid', 'is-valid']);
21294 fg.addClass('is-invalid');
21302 var fg = this.el.findParent('.form-group', false, true);
21303 if (Roo.bootstrap.version == 3) {
21304 fg.removeClass([_this.invalidClass, _this.validClass]);
21305 fg.addClass(_this.invalidClass);
21307 fg.removeClass(['is-invalid', 'is-valid']);
21308 fg.addClass('is-invalid');
21313 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21319 for(var i in group){
21320 var fg = group[i].el.findParent('.form-group', false, true);
21321 if (Roo.bootstrap.version == 3) {
21322 fg.removeClass([_this.invalidClass, _this.validClass]);
21323 fg.addClass(_this.invalidClass);
21325 fg.removeClass(['is-invalid', 'is-valid']);
21326 fg.addClass('is-invalid');
21332 clearInvalid : function()
21334 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21336 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21338 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21340 if (label && label.iconEl) {
21341 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21342 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21346 disable : function()
21348 if(this.inputType != 'radio'){
21349 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21356 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21357 _this.getActionEl().addClass(this.disabledClass);
21358 e.dom.disabled = true;
21362 this.disabled = true;
21363 this.fireEvent("disable", this);
21367 enable : function()
21369 if(this.inputType != 'radio'){
21370 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21377 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21378 _this.getActionEl().removeClass(this.disabledClass);
21379 e.dom.disabled = false;
21383 this.disabled = false;
21384 this.fireEvent("enable", this);
21388 setBoxLabel : function(v)
21393 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21399 Roo.apply(Roo.bootstrap.CheckBox, {
21404 * register a CheckBox Group
21405 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21407 register : function(checkbox)
21409 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21410 this.groups[checkbox.groupId] = {};
21413 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21417 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21421 * fetch a CheckBox Group based on the group ID
21422 * @param {string} the group ID
21423 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21425 get: function(groupId) {
21426 if (typeof(this.groups[groupId]) == 'undefined') {
21430 return this.groups[groupId] ;
21443 * @class Roo.bootstrap.Radio
21444 * @extends Roo.bootstrap.Component
21445 * Bootstrap Radio class
21446 * @cfg {String} boxLabel - the label associated
21447 * @cfg {String} value - the value of radio
21450 * Create a new Radio
21451 * @param {Object} config The config object
21453 Roo.bootstrap.Radio = function(config){
21454 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21458 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21464 getAutoCreate : function()
21468 cls : 'form-group radio',
21473 html : this.boxLabel
21481 initEvents : function()
21483 this.parent().register(this);
21485 this.el.on('click', this.onClick, this);
21489 onClick : function(e)
21491 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21492 this.setChecked(true);
21496 setChecked : function(state, suppressEvent)
21498 this.parent().setValue(this.value, suppressEvent);
21502 setBoxLabel : function(v)
21507 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21522 * @class Roo.bootstrap.SecurePass
21523 * @extends Roo.bootstrap.Input
21524 * Bootstrap SecurePass class
21528 * Create a new SecurePass
21529 * @param {Object} config The config object
21532 Roo.bootstrap.SecurePass = function (config) {
21533 // these go here, so the translation tool can replace them..
21535 PwdEmpty: "Please type a password, and then retype it to confirm.",
21536 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21537 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21538 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21539 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21540 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21541 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21542 TooWeak: "Your password is Too Weak."
21544 this.meterLabel = "Password strength:";
21545 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21546 this.meterClass = [
21547 "roo-password-meter-tooweak",
21548 "roo-password-meter-weak",
21549 "roo-password-meter-medium",
21550 "roo-password-meter-strong",
21551 "roo-password-meter-grey"
21556 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21559 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21561 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21563 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21564 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21565 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21566 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21567 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21568 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21569 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21579 * @cfg {String/Object} Label for the strength meter (defaults to
21580 * 'Password strength:')
21585 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21586 * ['Weak', 'Medium', 'Strong'])
21589 pwdStrengths: false,
21602 initEvents: function ()
21604 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21606 if (this.el.is('input[type=password]') && Roo.isSafari) {
21607 this.el.on('keydown', this.SafariOnKeyDown, this);
21610 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21613 onRender: function (ct, position)
21615 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21616 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21617 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21619 this.trigger.createChild({
21624 cls: 'roo-password-meter-grey col-xs-12',
21627 //width: this.meterWidth + 'px'
21631 cls: 'roo-password-meter-text'
21637 if (this.hideTrigger) {
21638 this.trigger.setDisplayed(false);
21640 this.setSize(this.width || '', this.height || '');
21643 onDestroy: function ()
21645 if (this.trigger) {
21646 this.trigger.removeAllListeners();
21647 this.trigger.remove();
21650 this.wrap.remove();
21652 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21655 checkStrength: function ()
21657 var pwd = this.inputEl().getValue();
21658 if (pwd == this._lastPwd) {
21663 if (this.ClientSideStrongPassword(pwd)) {
21665 } else if (this.ClientSideMediumPassword(pwd)) {
21667 } else if (this.ClientSideWeakPassword(pwd)) {
21673 Roo.log('strength1: ' + strength);
21675 //var pm = this.trigger.child('div/div/div').dom;
21676 var pm = this.trigger.child('div/div');
21677 pm.removeClass(this.meterClass);
21678 pm.addClass(this.meterClass[strength]);
21681 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21683 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21685 this._lastPwd = pwd;
21689 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21691 this._lastPwd = '';
21693 var pm = this.trigger.child('div/div');
21694 pm.removeClass(this.meterClass);
21695 pm.addClass('roo-password-meter-grey');
21698 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21701 this.inputEl().dom.type='password';
21704 validateValue: function (value)
21707 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21710 if (value.length == 0) {
21711 if (this.allowBlank) {
21712 this.clearInvalid();
21716 this.markInvalid(this.errors.PwdEmpty);
21717 this.errorMsg = this.errors.PwdEmpty;
21725 if ('[\x21-\x7e]*'.match(value)) {
21726 this.markInvalid(this.errors.PwdBadChar);
21727 this.errorMsg = this.errors.PwdBadChar;
21730 if (value.length < 6) {
21731 this.markInvalid(this.errors.PwdShort);
21732 this.errorMsg = this.errors.PwdShort;
21735 if (value.length > 16) {
21736 this.markInvalid(this.errors.PwdLong);
21737 this.errorMsg = this.errors.PwdLong;
21741 if (this.ClientSideStrongPassword(value)) {
21743 } else if (this.ClientSideMediumPassword(value)) {
21745 } else if (this.ClientSideWeakPassword(value)) {
21752 if (strength < 2) {
21753 //this.markInvalid(this.errors.TooWeak);
21754 this.errorMsg = this.errors.TooWeak;
21759 console.log('strength2: ' + strength);
21761 //var pm = this.trigger.child('div/div/div').dom;
21763 var pm = this.trigger.child('div/div');
21764 pm.removeClass(this.meterClass);
21765 pm.addClass(this.meterClass[strength]);
21767 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21769 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21771 this.errorMsg = '';
21775 CharacterSetChecks: function (type)
21778 this.fResult = false;
21781 isctype: function (character, type)
21784 case this.kCapitalLetter:
21785 if (character >= 'A' && character <= 'Z') {
21790 case this.kSmallLetter:
21791 if (character >= 'a' && character <= 'z') {
21797 if (character >= '0' && character <= '9') {
21802 case this.kPunctuation:
21803 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21814 IsLongEnough: function (pwd, size)
21816 return !(pwd == null || isNaN(size) || pwd.length < size);
21819 SpansEnoughCharacterSets: function (word, nb)
21821 if (!this.IsLongEnough(word, nb))
21826 var characterSetChecks = new Array(
21827 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21828 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21831 for (var index = 0; index < word.length; ++index) {
21832 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21833 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21834 characterSetChecks[nCharSet].fResult = true;
21841 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21842 if (characterSetChecks[nCharSet].fResult) {
21847 if (nCharSets < nb) {
21853 ClientSideStrongPassword: function (pwd)
21855 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21858 ClientSideMediumPassword: function (pwd)
21860 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21863 ClientSideWeakPassword: function (pwd)
21865 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21868 })//<script type="text/javascript">
21871 * Based Ext JS Library 1.1.1
21872 * Copyright(c) 2006-2007, Ext JS, LLC.
21878 * @class Roo.HtmlEditorCore
21879 * @extends Roo.Component
21880 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21882 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21885 Roo.HtmlEditorCore = function(config){
21888 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21893 * @event initialize
21894 * Fires when the editor is fully initialized (including the iframe)
21895 * @param {Roo.HtmlEditorCore} this
21900 * Fires when the editor is first receives the focus. Any insertion must wait
21901 * until after this event.
21902 * @param {Roo.HtmlEditorCore} this
21906 * @event beforesync
21907 * Fires before the textarea is updated with content from the editor iframe. Return false
21908 * to cancel the sync.
21909 * @param {Roo.HtmlEditorCore} this
21910 * @param {String} html
21914 * @event beforepush
21915 * Fires before the iframe editor is updated with content from the textarea. Return false
21916 * to cancel the push.
21917 * @param {Roo.HtmlEditorCore} this
21918 * @param {String} html
21923 * Fires when the textarea is updated with content from the editor iframe.
21924 * @param {Roo.HtmlEditorCore} this
21925 * @param {String} html
21930 * Fires when the iframe editor is updated with content from the textarea.
21931 * @param {Roo.HtmlEditorCore} this
21932 * @param {String} html
21937 * @event editorevent
21938 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21939 * @param {Roo.HtmlEditorCore} this
21945 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21947 // defaults : white / black...
21948 this.applyBlacklists();
21955 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21959 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21965 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21970 * @cfg {Number} height (in pixels)
21974 * @cfg {Number} width (in pixels)
21979 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21982 stylesheets: false,
21987 // private properties
21988 validationEvent : false,
21990 initialized : false,
21992 sourceEditMode : false,
21993 onFocus : Roo.emptyFn,
21995 hideMode:'offsets',
21999 // blacklist + whitelisted elements..
22006 * Protected method that will not generally be called directly. It
22007 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22008 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22010 getDocMarkup : function(){
22014 // inherit styels from page...??
22015 if (this.stylesheets === false) {
22017 Roo.get(document.head).select('style').each(function(node) {
22018 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22021 Roo.get(document.head).select('link').each(function(node) {
22022 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22025 } else if (!this.stylesheets.length) {
22027 st = '<style type="text/css">' +
22028 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22031 st = '<style type="text/css">' +
22036 st += '<style type="text/css">' +
22037 'IMG { cursor: pointer } ' +
22040 var cls = 'roo-htmleditor-body';
22042 if(this.bodyCls.length){
22043 cls += ' ' + this.bodyCls;
22046 return '<html><head>' + st +
22047 //<style type="text/css">' +
22048 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22050 ' </head><body class="' + cls + '"></body></html>';
22054 onRender : function(ct, position)
22057 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22058 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22061 this.el.dom.style.border = '0 none';
22062 this.el.dom.setAttribute('tabIndex', -1);
22063 this.el.addClass('x-hidden hide');
22067 if(Roo.isIE){ // fix IE 1px bogus margin
22068 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22072 this.frameId = Roo.id();
22076 var iframe = this.owner.wrap.createChild({
22078 cls: 'form-control', // bootstrap..
22080 name: this.frameId,
22081 frameBorder : 'no',
22082 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22087 this.iframe = iframe.dom;
22089 this.assignDocWin();
22091 this.doc.designMode = 'on';
22094 this.doc.write(this.getDocMarkup());
22098 var task = { // must defer to wait for browser to be ready
22100 //console.log("run task?" + this.doc.readyState);
22101 this.assignDocWin();
22102 if(this.doc.body || this.doc.readyState == 'complete'){
22104 this.doc.designMode="on";
22108 Roo.TaskMgr.stop(task);
22109 this.initEditor.defer(10, this);
22116 Roo.TaskMgr.start(task);
22121 onResize : function(w, h)
22123 Roo.log('resize: ' +w + ',' + h );
22124 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22128 if(typeof w == 'number'){
22130 this.iframe.style.width = w + 'px';
22132 if(typeof h == 'number'){
22134 this.iframe.style.height = h + 'px';
22136 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22143 * Toggles the editor between standard and source edit mode.
22144 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22146 toggleSourceEdit : function(sourceEditMode){
22148 this.sourceEditMode = sourceEditMode === true;
22150 if(this.sourceEditMode){
22152 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22155 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22156 //this.iframe.className = '';
22159 //this.setSize(this.owner.wrap.getSize());
22160 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22167 * Protected method that will not generally be called directly. If you need/want
22168 * custom HTML cleanup, this is the method you should override.
22169 * @param {String} html The HTML to be cleaned
22170 * return {String} The cleaned HTML
22172 cleanHtml : function(html){
22173 html = String(html);
22174 if(html.length > 5){
22175 if(Roo.isSafari){ // strip safari nonsense
22176 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22179 if(html == ' '){
22186 * HTML Editor -> Textarea
22187 * Protected method that will not generally be called directly. Syncs the contents
22188 * of the editor iframe with the textarea.
22190 syncValue : function(){
22191 if(this.initialized){
22192 var bd = (this.doc.body || this.doc.documentElement);
22193 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22194 var html = bd.innerHTML;
22196 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22197 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22199 html = '<div style="'+m[0]+'">' + html + '</div>';
22202 html = this.cleanHtml(html);
22203 // fix up the special chars.. normaly like back quotes in word...
22204 // however we do not want to do this with chinese..
22205 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22206 var cc = b.charCodeAt();
22208 (cc >= 0x4E00 && cc < 0xA000 ) ||
22209 (cc >= 0x3400 && cc < 0x4E00 ) ||
22210 (cc >= 0xf900 && cc < 0xfb00 )
22216 if(this.owner.fireEvent('beforesync', this, html) !== false){
22217 this.el.dom.value = html;
22218 this.owner.fireEvent('sync', this, html);
22224 * Protected method that will not generally be called directly. Pushes the value of the textarea
22225 * into the iframe editor.
22227 pushValue : function(){
22228 if(this.initialized){
22229 var v = this.el.dom.value.trim();
22231 // if(v.length < 1){
22235 if(this.owner.fireEvent('beforepush', this, v) !== false){
22236 var d = (this.doc.body || this.doc.documentElement);
22238 this.cleanUpPaste();
22239 this.el.dom.value = d.innerHTML;
22240 this.owner.fireEvent('push', this, v);
22246 deferFocus : function(){
22247 this.focus.defer(10, this);
22251 focus : function(){
22252 if(this.win && !this.sourceEditMode){
22259 assignDocWin: function()
22261 var iframe = this.iframe;
22264 this.doc = iframe.contentWindow.document;
22265 this.win = iframe.contentWindow;
22267 // if (!Roo.get(this.frameId)) {
22270 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22271 // this.win = Roo.get(this.frameId).dom.contentWindow;
22273 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22277 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22278 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22283 initEditor : function(){
22284 //console.log("INIT EDITOR");
22285 this.assignDocWin();
22289 this.doc.designMode="on";
22291 this.doc.write(this.getDocMarkup());
22294 var dbody = (this.doc.body || this.doc.documentElement);
22295 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22296 // this copies styles from the containing element into thsi one..
22297 // not sure why we need all of this..
22298 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22300 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22301 //ss['background-attachment'] = 'fixed'; // w3c
22302 dbody.bgProperties = 'fixed'; // ie
22303 //Roo.DomHelper.applyStyles(dbody, ss);
22304 Roo.EventManager.on(this.doc, {
22305 //'mousedown': this.onEditorEvent,
22306 'mouseup': this.onEditorEvent,
22307 'dblclick': this.onEditorEvent,
22308 'click': this.onEditorEvent,
22309 'keyup': this.onEditorEvent,
22314 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22316 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22317 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22319 this.initialized = true;
22321 this.owner.fireEvent('initialize', this);
22326 onDestroy : function(){
22332 //for (var i =0; i < this.toolbars.length;i++) {
22333 // // fixme - ask toolbars for heights?
22334 // this.toolbars[i].onDestroy();
22337 //this.wrap.dom.innerHTML = '';
22338 //this.wrap.remove();
22343 onFirstFocus : function(){
22345 this.assignDocWin();
22348 this.activated = true;
22351 if(Roo.isGecko){ // prevent silly gecko errors
22353 var s = this.win.getSelection();
22354 if(!s.focusNode || s.focusNode.nodeType != 3){
22355 var r = s.getRangeAt(0);
22356 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22361 this.execCmd('useCSS', true);
22362 this.execCmd('styleWithCSS', false);
22365 this.owner.fireEvent('activate', this);
22369 adjustFont: function(btn){
22370 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22371 //if(Roo.isSafari){ // safari
22374 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22375 if(Roo.isSafari){ // safari
22376 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22377 v = (v < 10) ? 10 : v;
22378 v = (v > 48) ? 48 : v;
22379 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22384 v = Math.max(1, v+adjust);
22386 this.execCmd('FontSize', v );
22389 onEditorEvent : function(e)
22391 this.owner.fireEvent('editorevent', this, e);
22392 // this.updateToolbar();
22393 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22396 insertTag : function(tg)
22398 // could be a bit smarter... -> wrap the current selected tRoo..
22399 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22401 range = this.createRange(this.getSelection());
22402 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22403 wrappingNode.appendChild(range.extractContents());
22404 range.insertNode(wrappingNode);
22411 this.execCmd("formatblock", tg);
22415 insertText : function(txt)
22419 var range = this.createRange();
22420 range.deleteContents();
22421 //alert(Sender.getAttribute('label'));
22423 range.insertNode(this.doc.createTextNode(txt));
22429 * Executes a Midas editor command on the editor document and performs necessary focus and
22430 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22431 * @param {String} cmd The Midas command
22432 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22434 relayCmd : function(cmd, value){
22436 this.execCmd(cmd, value);
22437 this.owner.fireEvent('editorevent', this);
22438 //this.updateToolbar();
22439 this.owner.deferFocus();
22443 * Executes a Midas editor command directly on the editor document.
22444 * For visual commands, you should use {@link #relayCmd} instead.
22445 * <b>This should only be called after the editor is initialized.</b>
22446 * @param {String} cmd The Midas command
22447 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22449 execCmd : function(cmd, value){
22450 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22457 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22459 * @param {String} text | dom node..
22461 insertAtCursor : function(text)
22464 if(!this.activated){
22470 var r = this.doc.selection.createRange();
22481 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22485 // from jquery ui (MIT licenced)
22487 var win = this.win;
22489 if (win.getSelection && win.getSelection().getRangeAt) {
22490 range = win.getSelection().getRangeAt(0);
22491 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22492 range.insertNode(node);
22493 } else if (win.document.selection && win.document.selection.createRange) {
22494 // no firefox support
22495 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22496 win.document.selection.createRange().pasteHTML(txt);
22498 // no firefox support
22499 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22500 this.execCmd('InsertHTML', txt);
22509 mozKeyPress : function(e){
22511 var c = e.getCharCode(), cmd;
22514 c = String.fromCharCode(c).toLowerCase();
22528 this.cleanUpPaste.defer(100, this);
22536 e.preventDefault();
22544 fixKeys : function(){ // load time branching for fastest keydown performance
22546 return function(e){
22547 var k = e.getKey(), r;
22550 r = this.doc.selection.createRange();
22553 r.pasteHTML('    ');
22560 r = this.doc.selection.createRange();
22562 var target = r.parentElement();
22563 if(!target || target.tagName.toLowerCase() != 'li'){
22565 r.pasteHTML('<br />');
22571 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22572 this.cleanUpPaste.defer(100, this);
22578 }else if(Roo.isOpera){
22579 return function(e){
22580 var k = e.getKey();
22584 this.execCmd('InsertHTML','    ');
22587 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22588 this.cleanUpPaste.defer(100, this);
22593 }else if(Roo.isSafari){
22594 return function(e){
22595 var k = e.getKey();
22599 this.execCmd('InsertText','\t');
22603 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22604 this.cleanUpPaste.defer(100, this);
22612 getAllAncestors: function()
22614 var p = this.getSelectedNode();
22617 a.push(p); // push blank onto stack..
22618 p = this.getParentElement();
22622 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22626 a.push(this.doc.body);
22630 lastSelNode : false,
22633 getSelection : function()
22635 this.assignDocWin();
22636 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22639 getSelectedNode: function()
22641 // this may only work on Gecko!!!
22643 // should we cache this!!!!
22648 var range = this.createRange(this.getSelection()).cloneRange();
22651 var parent = range.parentElement();
22653 var testRange = range.duplicate();
22654 testRange.moveToElementText(parent);
22655 if (testRange.inRange(range)) {
22658 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22661 parent = parent.parentElement;
22666 // is ancestor a text element.
22667 var ac = range.commonAncestorContainer;
22668 if (ac.nodeType == 3) {
22669 ac = ac.parentNode;
22672 var ar = ac.childNodes;
22675 var other_nodes = [];
22676 var has_other_nodes = false;
22677 for (var i=0;i<ar.length;i++) {
22678 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22681 // fullly contained node.
22683 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22688 // probably selected..
22689 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22690 other_nodes.push(ar[i]);
22694 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22699 has_other_nodes = true;
22701 if (!nodes.length && other_nodes.length) {
22702 nodes= other_nodes;
22704 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22710 createRange: function(sel)
22712 // this has strange effects when using with
22713 // top toolbar - not sure if it's a great idea.
22714 //this.editor.contentWindow.focus();
22715 if (typeof sel != "undefined") {
22717 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22719 return this.doc.createRange();
22722 return this.doc.createRange();
22725 getParentElement: function()
22728 this.assignDocWin();
22729 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22731 var range = this.createRange(sel);
22734 var p = range.commonAncestorContainer;
22735 while (p.nodeType == 3) { // text node
22746 * Range intersection.. the hard stuff...
22750 * [ -- selected range --- ]
22754 * if end is before start or hits it. fail.
22755 * if start is after end or hits it fail.
22757 * if either hits (but other is outside. - then it's not
22763 // @see http://www.thismuchiknow.co.uk/?p=64.
22764 rangeIntersectsNode : function(range, node)
22766 var nodeRange = node.ownerDocument.createRange();
22768 nodeRange.selectNode(node);
22770 nodeRange.selectNodeContents(node);
22773 var rangeStartRange = range.cloneRange();
22774 rangeStartRange.collapse(true);
22776 var rangeEndRange = range.cloneRange();
22777 rangeEndRange.collapse(false);
22779 var nodeStartRange = nodeRange.cloneRange();
22780 nodeStartRange.collapse(true);
22782 var nodeEndRange = nodeRange.cloneRange();
22783 nodeEndRange.collapse(false);
22785 return rangeStartRange.compareBoundaryPoints(
22786 Range.START_TO_START, nodeEndRange) == -1 &&
22787 rangeEndRange.compareBoundaryPoints(
22788 Range.START_TO_START, nodeStartRange) == 1;
22792 rangeCompareNode : function(range, node)
22794 var nodeRange = node.ownerDocument.createRange();
22796 nodeRange.selectNode(node);
22798 nodeRange.selectNodeContents(node);
22802 range.collapse(true);
22804 nodeRange.collapse(true);
22806 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22807 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22809 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22811 var nodeIsBefore = ss == 1;
22812 var nodeIsAfter = ee == -1;
22814 if (nodeIsBefore && nodeIsAfter) {
22817 if (!nodeIsBefore && nodeIsAfter) {
22818 return 1; //right trailed.
22821 if (nodeIsBefore && !nodeIsAfter) {
22822 return 2; // left trailed.
22828 // private? - in a new class?
22829 cleanUpPaste : function()
22831 // cleans up the whole document..
22832 Roo.log('cleanuppaste');
22834 this.cleanUpChildren(this.doc.body);
22835 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22836 if (clean != this.doc.body.innerHTML) {
22837 this.doc.body.innerHTML = clean;
22842 cleanWordChars : function(input) {// change the chars to hex code
22843 var he = Roo.HtmlEditorCore;
22845 var output = input;
22846 Roo.each(he.swapCodes, function(sw) {
22847 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22849 output = output.replace(swapper, sw[1]);
22856 cleanUpChildren : function (n)
22858 if (!n.childNodes.length) {
22861 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22862 this.cleanUpChild(n.childNodes[i]);
22869 cleanUpChild : function (node)
22872 //console.log(node);
22873 if (node.nodeName == "#text") {
22874 // clean up silly Windows -- stuff?
22877 if (node.nodeName == "#comment") {
22878 node.parentNode.removeChild(node);
22879 // clean up silly Windows -- stuff?
22882 var lcname = node.tagName.toLowerCase();
22883 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22884 // whitelist of tags..
22886 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22888 node.parentNode.removeChild(node);
22893 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22895 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22896 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22898 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22899 // remove_keep_children = true;
22902 if (remove_keep_children) {
22903 this.cleanUpChildren(node);
22904 // inserts everything just before this node...
22905 while (node.childNodes.length) {
22906 var cn = node.childNodes[0];
22907 node.removeChild(cn);
22908 node.parentNode.insertBefore(cn, node);
22910 node.parentNode.removeChild(node);
22914 if (!node.attributes || !node.attributes.length) {
22915 this.cleanUpChildren(node);
22919 function cleanAttr(n,v)
22922 if (v.match(/^\./) || v.match(/^\//)) {
22925 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22928 if (v.match(/^#/)) {
22931 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22932 node.removeAttribute(n);
22936 var cwhite = this.cwhite;
22937 var cblack = this.cblack;
22939 function cleanStyle(n,v)
22941 if (v.match(/expression/)) { //XSS?? should we even bother..
22942 node.removeAttribute(n);
22946 var parts = v.split(/;/);
22949 Roo.each(parts, function(p) {
22950 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22954 var l = p.split(':').shift().replace(/\s+/g,'');
22955 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22957 if ( cwhite.length && cblack.indexOf(l) > -1) {
22958 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22959 //node.removeAttribute(n);
22963 // only allow 'c whitelisted system attributes'
22964 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22965 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22966 //node.removeAttribute(n);
22976 if (clean.length) {
22977 node.setAttribute(n, clean.join(';'));
22979 node.removeAttribute(n);
22985 for (var i = node.attributes.length-1; i > -1 ; i--) {
22986 var a = node.attributes[i];
22989 if (a.name.toLowerCase().substr(0,2)=='on') {
22990 node.removeAttribute(a.name);
22993 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22994 node.removeAttribute(a.name);
22997 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22998 cleanAttr(a.name,a.value); // fixme..
23001 if (a.name == 'style') {
23002 cleanStyle(a.name,a.value);
23005 /// clean up MS crap..
23006 // tecnically this should be a list of valid class'es..
23009 if (a.name == 'class') {
23010 if (a.value.match(/^Mso/)) {
23011 node.className = '';
23014 if (a.value.match(/^body$/)) {
23015 node.className = '';
23026 this.cleanUpChildren(node);
23032 * Clean up MS wordisms...
23034 cleanWord : function(node)
23039 this.cleanWord(this.doc.body);
23042 if (node.nodeName == "#text") {
23043 // clean up silly Windows -- stuff?
23046 if (node.nodeName == "#comment") {
23047 node.parentNode.removeChild(node);
23048 // clean up silly Windows -- stuff?
23052 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23053 node.parentNode.removeChild(node);
23057 // remove - but keep children..
23058 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23059 while (node.childNodes.length) {
23060 var cn = node.childNodes[0];
23061 node.removeChild(cn);
23062 node.parentNode.insertBefore(cn, node);
23064 node.parentNode.removeChild(node);
23065 this.iterateChildren(node, this.cleanWord);
23069 if (node.className.length) {
23071 var cn = node.className.split(/\W+/);
23073 Roo.each(cn, function(cls) {
23074 if (cls.match(/Mso[a-zA-Z]+/)) {
23079 node.className = cna.length ? cna.join(' ') : '';
23081 node.removeAttribute("class");
23085 if (node.hasAttribute("lang")) {
23086 node.removeAttribute("lang");
23089 if (node.hasAttribute("style")) {
23091 var styles = node.getAttribute("style").split(";");
23093 Roo.each(styles, function(s) {
23094 if (!s.match(/:/)) {
23097 var kv = s.split(":");
23098 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23101 // what ever is left... we allow.
23104 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23105 if (!nstyle.length) {
23106 node.removeAttribute('style');
23109 this.iterateChildren(node, this.cleanWord);
23115 * iterateChildren of a Node, calling fn each time, using this as the scole..
23116 * @param {DomNode} node node to iterate children of.
23117 * @param {Function} fn method of this class to call on each item.
23119 iterateChildren : function(node, fn)
23121 if (!node.childNodes.length) {
23124 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23125 fn.call(this, node.childNodes[i])
23131 * cleanTableWidths.
23133 * Quite often pasting from word etc.. results in tables with column and widths.
23134 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23137 cleanTableWidths : function(node)
23142 this.cleanTableWidths(this.doc.body);
23147 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23150 Roo.log(node.tagName);
23151 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23152 this.iterateChildren(node, this.cleanTableWidths);
23155 if (node.hasAttribute('width')) {
23156 node.removeAttribute('width');
23160 if (node.hasAttribute("style")) {
23163 var styles = node.getAttribute("style").split(";");
23165 Roo.each(styles, function(s) {
23166 if (!s.match(/:/)) {
23169 var kv = s.split(":");
23170 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23173 // what ever is left... we allow.
23176 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23177 if (!nstyle.length) {
23178 node.removeAttribute('style');
23182 this.iterateChildren(node, this.cleanTableWidths);
23190 domToHTML : function(currentElement, depth, nopadtext) {
23192 depth = depth || 0;
23193 nopadtext = nopadtext || false;
23195 if (!currentElement) {
23196 return this.domToHTML(this.doc.body);
23199 //Roo.log(currentElement);
23201 var allText = false;
23202 var nodeName = currentElement.nodeName;
23203 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23205 if (nodeName == '#text') {
23207 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23212 if (nodeName != 'BODY') {
23215 // Prints the node tagName, such as <A>, <IMG>, etc
23218 for(i = 0; i < currentElement.attributes.length;i++) {
23220 var aname = currentElement.attributes.item(i).name;
23221 if (!currentElement.attributes.item(i).value.length) {
23224 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23227 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23236 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23239 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23244 // Traverse the tree
23246 var currentElementChild = currentElement.childNodes.item(i);
23247 var allText = true;
23248 var innerHTML = '';
23250 while (currentElementChild) {
23251 // Formatting code (indent the tree so it looks nice on the screen)
23252 var nopad = nopadtext;
23253 if (lastnode == 'SPAN') {
23257 if (currentElementChild.nodeName == '#text') {
23258 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23259 toadd = nopadtext ? toadd : toadd.trim();
23260 if (!nopad && toadd.length > 80) {
23261 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23263 innerHTML += toadd;
23266 currentElementChild = currentElement.childNodes.item(i);
23272 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23274 // Recursively traverse the tree structure of the child node
23275 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23276 lastnode = currentElementChild.nodeName;
23278 currentElementChild=currentElement.childNodes.item(i);
23284 // The remaining code is mostly for formatting the tree
23285 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23290 ret+= "</"+tagName+">";
23296 applyBlacklists : function()
23298 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23299 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23303 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23304 if (b.indexOf(tag) > -1) {
23307 this.white.push(tag);
23311 Roo.each(w, function(tag) {
23312 if (b.indexOf(tag) > -1) {
23315 if (this.white.indexOf(tag) > -1) {
23318 this.white.push(tag);
23323 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23324 if (w.indexOf(tag) > -1) {
23327 this.black.push(tag);
23331 Roo.each(b, function(tag) {
23332 if (w.indexOf(tag) > -1) {
23335 if (this.black.indexOf(tag) > -1) {
23338 this.black.push(tag);
23343 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23344 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23348 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23349 if (b.indexOf(tag) > -1) {
23352 this.cwhite.push(tag);
23356 Roo.each(w, function(tag) {
23357 if (b.indexOf(tag) > -1) {
23360 if (this.cwhite.indexOf(tag) > -1) {
23363 this.cwhite.push(tag);
23368 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23369 if (w.indexOf(tag) > -1) {
23372 this.cblack.push(tag);
23376 Roo.each(b, function(tag) {
23377 if (w.indexOf(tag) > -1) {
23380 if (this.cblack.indexOf(tag) > -1) {
23383 this.cblack.push(tag);
23388 setStylesheets : function(stylesheets)
23390 if(typeof(stylesheets) == 'string'){
23391 Roo.get(this.iframe.contentDocument.head).createChild({
23393 rel : 'stylesheet',
23402 Roo.each(stylesheets, function(s) {
23407 Roo.get(_this.iframe.contentDocument.head).createChild({
23409 rel : 'stylesheet',
23418 removeStylesheets : function()
23422 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23427 setStyle : function(style)
23429 Roo.get(this.iframe.contentDocument.head).createChild({
23438 // hide stuff that is not compatible
23452 * @event specialkey
23456 * @cfg {String} fieldClass @hide
23459 * @cfg {String} focusClass @hide
23462 * @cfg {String} autoCreate @hide
23465 * @cfg {String} inputType @hide
23468 * @cfg {String} invalidClass @hide
23471 * @cfg {String} invalidText @hide
23474 * @cfg {String} msgFx @hide
23477 * @cfg {String} validateOnBlur @hide
23481 Roo.HtmlEditorCore.white = [
23482 'area', 'br', 'img', 'input', 'hr', 'wbr',
23484 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23485 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23486 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23487 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23488 'table', 'ul', 'xmp',
23490 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23493 'dir', 'menu', 'ol', 'ul', 'dl',
23499 Roo.HtmlEditorCore.black = [
23500 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23502 'base', 'basefont', 'bgsound', 'blink', 'body',
23503 'frame', 'frameset', 'head', 'html', 'ilayer',
23504 'iframe', 'layer', 'link', 'meta', 'object',
23505 'script', 'style' ,'title', 'xml' // clean later..
23507 Roo.HtmlEditorCore.clean = [
23508 'script', 'style', 'title', 'xml'
23510 Roo.HtmlEditorCore.remove = [
23515 Roo.HtmlEditorCore.ablack = [
23519 Roo.HtmlEditorCore.aclean = [
23520 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23524 Roo.HtmlEditorCore.pwhite= [
23525 'http', 'https', 'mailto'
23528 // white listed style attributes.
23529 Roo.HtmlEditorCore.cwhite= [
23530 // 'text-align', /// default is to allow most things..
23536 // black listed style attributes.
23537 Roo.HtmlEditorCore.cblack= [
23538 // 'font-size' -- this can be set by the project
23542 Roo.HtmlEditorCore.swapCodes =[
23561 * @class Roo.bootstrap.HtmlEditor
23562 * @extends Roo.bootstrap.TextArea
23563 * Bootstrap HtmlEditor class
23566 * Create a new HtmlEditor
23567 * @param {Object} config The config object
23570 Roo.bootstrap.HtmlEditor = function(config){
23571 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23572 if (!this.toolbars) {
23573 this.toolbars = [];
23576 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23579 * @event initialize
23580 * Fires when the editor is fully initialized (including the iframe)
23581 * @param {HtmlEditor} this
23586 * Fires when the editor is first receives the focus. Any insertion must wait
23587 * until after this event.
23588 * @param {HtmlEditor} this
23592 * @event beforesync
23593 * Fires before the textarea is updated with content from the editor iframe. Return false
23594 * to cancel the sync.
23595 * @param {HtmlEditor} this
23596 * @param {String} html
23600 * @event beforepush
23601 * Fires before the iframe editor is updated with content from the textarea. Return false
23602 * to cancel the push.
23603 * @param {HtmlEditor} this
23604 * @param {String} html
23609 * Fires when the textarea is updated with content from the editor iframe.
23610 * @param {HtmlEditor} this
23611 * @param {String} html
23616 * Fires when the iframe editor is updated with content from the textarea.
23617 * @param {HtmlEditor} this
23618 * @param {String} html
23622 * @event editmodechange
23623 * Fires when the editor switches edit modes
23624 * @param {HtmlEditor} this
23625 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23627 editmodechange: true,
23629 * @event editorevent
23630 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23631 * @param {HtmlEditor} this
23635 * @event firstfocus
23636 * Fires when on first focus - needed by toolbars..
23637 * @param {HtmlEditor} this
23642 * Auto save the htmlEditor value as a file into Events
23643 * @param {HtmlEditor} this
23647 * @event savedpreview
23648 * preview the saved version of htmlEditor
23649 * @param {HtmlEditor} this
23656 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23660 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23665 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23670 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23675 * @cfg {Number} height (in pixels)
23679 * @cfg {Number} width (in pixels)
23684 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23687 stylesheets: false,
23692 // private properties
23693 validationEvent : false,
23695 initialized : false,
23698 onFocus : Roo.emptyFn,
23700 hideMode:'offsets',
23702 tbContainer : false,
23706 toolbarContainer :function() {
23707 return this.wrap.select('.x-html-editor-tb',true).first();
23711 * Protected method that will not generally be called directly. It
23712 * is called when the editor creates its toolbar. Override this method if you need to
23713 * add custom toolbar buttons.
23714 * @param {HtmlEditor} editor
23716 createToolbar : function(){
23717 Roo.log('renewing');
23718 Roo.log("create toolbars");
23720 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23721 this.toolbars[0].render(this.toolbarContainer());
23725 // if (!editor.toolbars || !editor.toolbars.length) {
23726 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23729 // for (var i =0 ; i < editor.toolbars.length;i++) {
23730 // editor.toolbars[i] = Roo.factory(
23731 // typeof(editor.toolbars[i]) == 'string' ?
23732 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23733 // Roo.bootstrap.HtmlEditor);
23734 // editor.toolbars[i].init(editor);
23740 onRender : function(ct, position)
23742 // Roo.log("Call onRender: " + this.xtype);
23744 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23746 this.wrap = this.inputEl().wrap({
23747 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23750 this.editorcore.onRender(ct, position);
23752 if (this.resizable) {
23753 this.resizeEl = new Roo.Resizable(this.wrap, {
23757 minHeight : this.height,
23758 height: this.height,
23759 handles : this.resizable,
23762 resize : function(r, w, h) {
23763 _t.onResize(w,h); // -something
23769 this.createToolbar(this);
23772 if(!this.width && this.resizable){
23773 this.setSize(this.wrap.getSize());
23775 if (this.resizeEl) {
23776 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23777 // should trigger onReize..
23783 onResize : function(w, h)
23785 Roo.log('resize: ' +w + ',' + h );
23786 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23790 if(this.inputEl() ){
23791 if(typeof w == 'number'){
23792 var aw = w - this.wrap.getFrameWidth('lr');
23793 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23796 if(typeof h == 'number'){
23797 var tbh = -11; // fixme it needs to tool bar size!
23798 for (var i =0; i < this.toolbars.length;i++) {
23799 // fixme - ask toolbars for heights?
23800 tbh += this.toolbars[i].el.getHeight();
23801 //if (this.toolbars[i].footer) {
23802 // tbh += this.toolbars[i].footer.el.getHeight();
23810 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23811 ah -= 5; // knock a few pixes off for look..
23812 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23816 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23817 this.editorcore.onResize(ew,eh);
23822 * Toggles the editor between standard and source edit mode.
23823 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23825 toggleSourceEdit : function(sourceEditMode)
23827 this.editorcore.toggleSourceEdit(sourceEditMode);
23829 if(this.editorcore.sourceEditMode){
23830 Roo.log('editor - showing textarea');
23833 // Roo.log(this.syncValue());
23835 this.inputEl().removeClass(['hide', 'x-hidden']);
23836 this.inputEl().dom.removeAttribute('tabIndex');
23837 this.inputEl().focus();
23839 Roo.log('editor - hiding textarea');
23841 // Roo.log(this.pushValue());
23844 this.inputEl().addClass(['hide', 'x-hidden']);
23845 this.inputEl().dom.setAttribute('tabIndex', -1);
23846 //this.deferFocus();
23849 if(this.resizable){
23850 this.setSize(this.wrap.getSize());
23853 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23856 // private (for BoxComponent)
23857 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23859 // private (for BoxComponent)
23860 getResizeEl : function(){
23864 // private (for BoxComponent)
23865 getPositionEl : function(){
23870 initEvents : function(){
23871 this.originalValue = this.getValue();
23875 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23878 // markInvalid : Roo.emptyFn,
23880 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23883 // clearInvalid : Roo.emptyFn,
23885 setValue : function(v){
23886 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23887 this.editorcore.pushValue();
23892 deferFocus : function(){
23893 this.focus.defer(10, this);
23897 focus : function(){
23898 this.editorcore.focus();
23904 onDestroy : function(){
23910 for (var i =0; i < this.toolbars.length;i++) {
23911 // fixme - ask toolbars for heights?
23912 this.toolbars[i].onDestroy();
23915 this.wrap.dom.innerHTML = '';
23916 this.wrap.remove();
23921 onFirstFocus : function(){
23922 //Roo.log("onFirstFocus");
23923 this.editorcore.onFirstFocus();
23924 for (var i =0; i < this.toolbars.length;i++) {
23925 this.toolbars[i].onFirstFocus();
23931 syncValue : function()
23933 this.editorcore.syncValue();
23936 pushValue : function()
23938 this.editorcore.pushValue();
23942 // hide stuff that is not compatible
23956 * @event specialkey
23960 * @cfg {String} fieldClass @hide
23963 * @cfg {String} focusClass @hide
23966 * @cfg {String} autoCreate @hide
23969 * @cfg {String} inputType @hide
23973 * @cfg {String} invalidText @hide
23976 * @cfg {String} msgFx @hide
23979 * @cfg {String} validateOnBlur @hide
23988 Roo.namespace('Roo.bootstrap.htmleditor');
23990 * @class Roo.bootstrap.HtmlEditorToolbar1
23995 new Roo.bootstrap.HtmlEditor({
23998 new Roo.bootstrap.HtmlEditorToolbar1({
23999 disable : { fonts: 1 , format: 1, ..., ... , ...],
24005 * @cfg {Object} disable List of elements to disable..
24006 * @cfg {Array} btns List of additional buttons.
24010 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24013 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24016 Roo.apply(this, config);
24018 // default disabled, based on 'good practice'..
24019 this.disable = this.disable || {};
24020 Roo.applyIf(this.disable, {
24023 specialElements : true
24025 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24027 this.editor = config.editor;
24028 this.editorcore = config.editor.editorcore;
24030 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24032 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24033 // dont call parent... till later.
24035 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24040 editorcore : false,
24045 "h1","h2","h3","h4","h5","h6",
24047 "abbr", "acronym", "address", "cite", "samp", "var",
24051 onRender : function(ct, position)
24053 // Roo.log("Call onRender: " + this.xtype);
24055 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24057 this.el.dom.style.marginBottom = '0';
24059 var editorcore = this.editorcore;
24060 var editor= this.editor;
24063 var btn = function(id,cmd , toggle, handler, html){
24065 var event = toggle ? 'toggle' : 'click';
24070 xns: Roo.bootstrap,
24074 enableToggle:toggle !== false,
24076 pressed : toggle ? false : null,
24079 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24080 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24086 // var cb_box = function...
24091 xns: Roo.bootstrap,
24096 xns: Roo.bootstrap,
24100 Roo.each(this.formats, function(f) {
24101 style.menu.items.push({
24103 xns: Roo.bootstrap,
24104 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24109 editorcore.insertTag(this.tagname);
24116 children.push(style);
24118 btn('bold',false,true);
24119 btn('italic',false,true);
24120 btn('align-left', 'justifyleft',true);
24121 btn('align-center', 'justifycenter',true);
24122 btn('align-right' , 'justifyright',true);
24123 btn('link', false, false, function(btn) {
24124 //Roo.log("create link?");
24125 var url = prompt(this.createLinkText, this.defaultLinkValue);
24126 if(url && url != 'http:/'+'/'){
24127 this.editorcore.relayCmd('createlink', url);
24130 btn('list','insertunorderedlist',true);
24131 btn('pencil', false,true, function(btn){
24133 this.toggleSourceEdit(btn.pressed);
24136 if (this.editor.btns.length > 0) {
24137 for (var i = 0; i<this.editor.btns.length; i++) {
24138 children.push(this.editor.btns[i]);
24146 xns: Roo.bootstrap,
24151 xns: Roo.bootstrap,
24156 cog.menu.items.push({
24158 xns: Roo.bootstrap,
24159 html : Clean styles,
24164 editorcore.insertTag(this.tagname);
24173 this.xtype = 'NavSimplebar';
24175 for(var i=0;i< children.length;i++) {
24177 this.buttons.add(this.addxtypeChild(children[i]));
24181 editor.on('editorevent', this.updateToolbar, this);
24183 onBtnClick : function(id)
24185 this.editorcore.relayCmd(id);
24186 this.editorcore.focus();
24190 * Protected method that will not generally be called directly. It triggers
24191 * a toolbar update by reading the markup state of the current selection in the editor.
24193 updateToolbar: function(){
24195 if(!this.editorcore.activated){
24196 this.editor.onFirstFocus(); // is this neeed?
24200 var btns = this.buttons;
24201 var doc = this.editorcore.doc;
24202 btns.get('bold').setActive(doc.queryCommandState('bold'));
24203 btns.get('italic').setActive(doc.queryCommandState('italic'));
24204 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24206 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24207 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24208 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24210 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24211 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24214 var ans = this.editorcore.getAllAncestors();
24215 if (this.formatCombo) {
24218 var store = this.formatCombo.store;
24219 this.formatCombo.setValue("");
24220 for (var i =0; i < ans.length;i++) {
24221 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24223 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24231 // hides menus... - so this cant be on a menu...
24232 Roo.bootstrap.MenuMgr.hideAll();
24234 Roo.bootstrap.MenuMgr.hideAll();
24235 //this.editorsyncValue();
24237 onFirstFocus: function() {
24238 this.buttons.each(function(item){
24242 toggleSourceEdit : function(sourceEditMode){
24245 if(sourceEditMode){
24246 Roo.log("disabling buttons");
24247 this.buttons.each( function(item){
24248 if(item.cmd != 'pencil'){
24254 Roo.log("enabling buttons");
24255 if(this.editorcore.initialized){
24256 this.buttons.each( function(item){
24262 Roo.log("calling toggole on editor");
24263 // tell the editor that it's been pressed..
24264 this.editor.toggleSourceEdit(sourceEditMode);
24274 * @class Roo.bootstrap.Table.AbstractSelectionModel
24275 * @extends Roo.util.Observable
24276 * Abstract base class for grid SelectionModels. It provides the interface that should be
24277 * implemented by descendant classes. This class should not be directly instantiated.
24280 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24281 this.locked = false;
24282 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24286 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24287 /** @ignore Called by the grid automatically. Do not call directly. */
24288 init : function(grid){
24294 * Locks the selections.
24297 this.locked = true;
24301 * Unlocks the selections.
24303 unlock : function(){
24304 this.locked = false;
24308 * Returns true if the selections are locked.
24309 * @return {Boolean}
24311 isLocked : function(){
24312 return this.locked;
24316 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24317 * @class Roo.bootstrap.Table.RowSelectionModel
24318 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24319 * It supports multiple selections and keyboard selection/navigation.
24321 * @param {Object} config
24324 Roo.bootstrap.Table.RowSelectionModel = function(config){
24325 Roo.apply(this, config);
24326 this.selections = new Roo.util.MixedCollection(false, function(o){
24331 this.lastActive = false;
24335 * @event selectionchange
24336 * Fires when the selection changes
24337 * @param {SelectionModel} this
24339 "selectionchange" : true,
24341 * @event afterselectionchange
24342 * Fires after the selection changes (eg. by key press or clicking)
24343 * @param {SelectionModel} this
24345 "afterselectionchange" : true,
24347 * @event beforerowselect
24348 * Fires when a row is selected being selected, return false to cancel.
24349 * @param {SelectionModel} this
24350 * @param {Number} rowIndex The selected index
24351 * @param {Boolean} keepExisting False if other selections will be cleared
24353 "beforerowselect" : true,
24356 * Fires when a row is selected.
24357 * @param {SelectionModel} this
24358 * @param {Number} rowIndex The selected index
24359 * @param {Roo.data.Record} r The record
24361 "rowselect" : true,
24363 * @event rowdeselect
24364 * Fires when a row is deselected.
24365 * @param {SelectionModel} this
24366 * @param {Number} rowIndex The selected index
24368 "rowdeselect" : true
24370 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24371 this.locked = false;
24374 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24376 * @cfg {Boolean} singleSelect
24377 * True to allow selection of only one row at a time (defaults to false)
24379 singleSelect : false,
24382 initEvents : function()
24385 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24386 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24387 //}else{ // allow click to work like normal
24388 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24390 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24391 this.grid.on("rowclick", this.handleMouseDown, this);
24393 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24394 "up" : function(e){
24396 this.selectPrevious(e.shiftKey);
24397 }else if(this.last !== false && this.lastActive !== false){
24398 var last = this.last;
24399 this.selectRange(this.last, this.lastActive-1);
24400 this.grid.getView().focusRow(this.lastActive);
24401 if(last !== false){
24405 this.selectFirstRow();
24407 this.fireEvent("afterselectionchange", this);
24409 "down" : function(e){
24411 this.selectNext(e.shiftKey);
24412 }else if(this.last !== false && this.lastActive !== false){
24413 var last = this.last;
24414 this.selectRange(this.last, this.lastActive+1);
24415 this.grid.getView().focusRow(this.lastActive);
24416 if(last !== false){
24420 this.selectFirstRow();
24422 this.fireEvent("afterselectionchange", this);
24426 this.grid.store.on('load', function(){
24427 this.selections.clear();
24430 var view = this.grid.view;
24431 view.on("refresh", this.onRefresh, this);
24432 view.on("rowupdated", this.onRowUpdated, this);
24433 view.on("rowremoved", this.onRemove, this);
24438 onRefresh : function()
24440 var ds = this.grid.store, i, v = this.grid.view;
24441 var s = this.selections;
24442 s.each(function(r){
24443 if((i = ds.indexOfId(r.id)) != -1){
24452 onRemove : function(v, index, r){
24453 this.selections.remove(r);
24457 onRowUpdated : function(v, index, r){
24458 if(this.isSelected(r)){
24459 v.onRowSelect(index);
24465 * @param {Array} records The records to select
24466 * @param {Boolean} keepExisting (optional) True to keep existing selections
24468 selectRecords : function(records, keepExisting)
24471 this.clearSelections();
24473 var ds = this.grid.store;
24474 for(var i = 0, len = records.length; i < len; i++){
24475 this.selectRow(ds.indexOf(records[i]), true);
24480 * Gets the number of selected rows.
24483 getCount : function(){
24484 return this.selections.length;
24488 * Selects the first row in the grid.
24490 selectFirstRow : function(){
24495 * Select the last row.
24496 * @param {Boolean} keepExisting (optional) True to keep existing selections
24498 selectLastRow : function(keepExisting){
24499 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24500 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24504 * Selects the row immediately following the last selected row.
24505 * @param {Boolean} keepExisting (optional) True to keep existing selections
24507 selectNext : function(keepExisting)
24509 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24510 this.selectRow(this.last+1, keepExisting);
24511 this.grid.getView().focusRow(this.last);
24516 * Selects the row that precedes the last selected row.
24517 * @param {Boolean} keepExisting (optional) True to keep existing selections
24519 selectPrevious : function(keepExisting){
24521 this.selectRow(this.last-1, keepExisting);
24522 this.grid.getView().focusRow(this.last);
24527 * Returns the selected records
24528 * @return {Array} Array of selected records
24530 getSelections : function(){
24531 return [].concat(this.selections.items);
24535 * Returns the first selected record.
24538 getSelected : function(){
24539 return this.selections.itemAt(0);
24544 * Clears all selections.
24546 clearSelections : function(fast)
24552 var ds = this.grid.store;
24553 var s = this.selections;
24554 s.each(function(r){
24555 this.deselectRow(ds.indexOfId(r.id));
24559 this.selections.clear();
24566 * Selects all rows.
24568 selectAll : function(){
24572 this.selections.clear();
24573 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24574 this.selectRow(i, true);
24579 * Returns True if there is a selection.
24580 * @return {Boolean}
24582 hasSelection : function(){
24583 return this.selections.length > 0;
24587 * Returns True if the specified row is selected.
24588 * @param {Number/Record} record The record or index of the record to check
24589 * @return {Boolean}
24591 isSelected : function(index){
24592 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24593 return (r && this.selections.key(r.id) ? true : false);
24597 * Returns True if the specified record id is selected.
24598 * @param {String} id The id of record to check
24599 * @return {Boolean}
24601 isIdSelected : function(id){
24602 return (this.selections.key(id) ? true : false);
24607 handleMouseDBClick : function(e, t){
24611 handleMouseDown : function(e, t)
24613 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24614 if(this.isLocked() || rowIndex < 0 ){
24617 if(e.shiftKey && this.last !== false){
24618 var last = this.last;
24619 this.selectRange(last, rowIndex, e.ctrlKey);
24620 this.last = last; // reset the last
24624 var isSelected = this.isSelected(rowIndex);
24625 //Roo.log("select row:" + rowIndex);
24627 this.deselectRow(rowIndex);
24629 this.selectRow(rowIndex, true);
24633 if(e.button !== 0 && isSelected){
24634 alert('rowIndex 2: ' + rowIndex);
24635 view.focusRow(rowIndex);
24636 }else if(e.ctrlKey && isSelected){
24637 this.deselectRow(rowIndex);
24638 }else if(!isSelected){
24639 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24640 view.focusRow(rowIndex);
24644 this.fireEvent("afterselectionchange", this);
24647 handleDragableRowClick : function(grid, rowIndex, e)
24649 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24650 this.selectRow(rowIndex, false);
24651 grid.view.focusRow(rowIndex);
24652 this.fireEvent("afterselectionchange", this);
24657 * Selects multiple rows.
24658 * @param {Array} rows Array of the indexes of the row to select
24659 * @param {Boolean} keepExisting (optional) True to keep existing selections
24661 selectRows : function(rows, keepExisting){
24663 this.clearSelections();
24665 for(var i = 0, len = rows.length; i < len; i++){
24666 this.selectRow(rows[i], true);
24671 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24672 * @param {Number} startRow The index of the first row in the range
24673 * @param {Number} endRow The index of the last row in the range
24674 * @param {Boolean} keepExisting (optional) True to retain existing selections
24676 selectRange : function(startRow, endRow, keepExisting){
24681 this.clearSelections();
24683 if(startRow <= endRow){
24684 for(var i = startRow; i <= endRow; i++){
24685 this.selectRow(i, true);
24688 for(var i = startRow; i >= endRow; i--){
24689 this.selectRow(i, true);
24695 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24696 * @param {Number} startRow The index of the first row in the range
24697 * @param {Number} endRow The index of the last row in the range
24699 deselectRange : function(startRow, endRow, preventViewNotify){
24703 for(var i = startRow; i <= endRow; i++){
24704 this.deselectRow(i, preventViewNotify);
24710 * @param {Number} row The index of the row to select
24711 * @param {Boolean} keepExisting (optional) True to keep existing selections
24713 selectRow : function(index, keepExisting, preventViewNotify)
24715 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24718 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24719 if(!keepExisting || this.singleSelect){
24720 this.clearSelections();
24723 var r = this.grid.store.getAt(index);
24724 //console.log('selectRow - record id :' + r.id);
24726 this.selections.add(r);
24727 this.last = this.lastActive = index;
24728 if(!preventViewNotify){
24729 var proxy = new Roo.Element(
24730 this.grid.getRowDom(index)
24732 proxy.addClass('bg-info info');
24734 this.fireEvent("rowselect", this, index, r);
24735 this.fireEvent("selectionchange", this);
24741 * @param {Number} row The index of the row to deselect
24743 deselectRow : function(index, preventViewNotify)
24748 if(this.last == index){
24751 if(this.lastActive == index){
24752 this.lastActive = false;
24755 var r = this.grid.store.getAt(index);
24760 this.selections.remove(r);
24761 //.console.log('deselectRow - record id :' + r.id);
24762 if(!preventViewNotify){
24764 var proxy = new Roo.Element(
24765 this.grid.getRowDom(index)
24767 proxy.removeClass('bg-info info');
24769 this.fireEvent("rowdeselect", this, index);
24770 this.fireEvent("selectionchange", this);
24774 restoreLast : function(){
24776 this.last = this._last;
24781 acceptsNav : function(row, col, cm){
24782 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24786 onEditorKey : function(field, e){
24787 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24792 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24794 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24796 }else if(k == e.ENTER && !e.ctrlKey){
24800 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24802 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24804 }else if(k == e.ESC){
24808 g.startEditing(newCell[0], newCell[1]);
24814 * Ext JS Library 1.1.1
24815 * Copyright(c) 2006-2007, Ext JS, LLC.
24817 * Originally Released Under LGPL - original licence link has changed is not relivant.
24820 * <script type="text/javascript">
24824 * @class Roo.bootstrap.PagingToolbar
24825 * @extends Roo.bootstrap.NavSimplebar
24826 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24828 * Create a new PagingToolbar
24829 * @param {Object} config The config object
24830 * @param {Roo.data.Store} store
24832 Roo.bootstrap.PagingToolbar = function(config)
24834 // old args format still supported... - xtype is prefered..
24835 // created from xtype...
24837 this.ds = config.dataSource;
24839 if (config.store && !this.ds) {
24840 this.store= Roo.factory(config.store, Roo.data);
24841 this.ds = this.store;
24842 this.ds.xmodule = this.xmodule || false;
24845 this.toolbarItems = [];
24846 if (config.items) {
24847 this.toolbarItems = config.items;
24850 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24855 this.bind(this.ds);
24858 if (Roo.bootstrap.version == 4) {
24859 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24861 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24866 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24868 * @cfg {Roo.data.Store} dataSource
24869 * The underlying data store providing the paged data
24872 * @cfg {String/HTMLElement/Element} container
24873 * container The id or element that will contain the toolbar
24876 * @cfg {Boolean} displayInfo
24877 * True to display the displayMsg (defaults to false)
24880 * @cfg {Number} pageSize
24881 * The number of records to display per page (defaults to 20)
24885 * @cfg {String} displayMsg
24886 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24888 displayMsg : 'Displaying {0} - {1} of {2}',
24890 * @cfg {String} emptyMsg
24891 * The message to display when no records are found (defaults to "No data to display")
24893 emptyMsg : 'No data to display',
24895 * Customizable piece of the default paging text (defaults to "Page")
24898 beforePageText : "Page",
24900 * Customizable piece of the default paging text (defaults to "of %0")
24903 afterPageText : "of {0}",
24905 * Customizable piece of the default paging text (defaults to "First Page")
24908 firstText : "First Page",
24910 * Customizable piece of the default paging text (defaults to "Previous Page")
24913 prevText : "Previous Page",
24915 * Customizable piece of the default paging text (defaults to "Next Page")
24918 nextText : "Next Page",
24920 * Customizable piece of the default paging text (defaults to "Last Page")
24923 lastText : "Last Page",
24925 * Customizable piece of the default paging text (defaults to "Refresh")
24928 refreshText : "Refresh",
24932 onRender : function(ct, position)
24934 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24935 this.navgroup.parentId = this.id;
24936 this.navgroup.onRender(this.el, null);
24937 // add the buttons to the navgroup
24939 if(this.displayInfo){
24940 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24941 this.displayEl = this.el.select('.x-paging-info', true).first();
24942 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24943 // this.displayEl = navel.el.select('span',true).first();
24949 Roo.each(_this.buttons, function(e){ // this might need to use render????
24950 Roo.factory(e).render(_this.el);
24954 Roo.each(_this.toolbarItems, function(e) {
24955 _this.navgroup.addItem(e);
24959 this.first = this.navgroup.addItem({
24960 tooltip: this.firstText,
24961 cls: "prev btn-outline-secondary",
24962 html : ' <i class="fa fa-step-backward"></i>',
24964 preventDefault: true,
24965 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24968 this.prev = this.navgroup.addItem({
24969 tooltip: this.prevText,
24970 cls: "prev btn-outline-secondary",
24971 html : ' <i class="fa fa-backward"></i>',
24973 preventDefault: true,
24974 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24976 //this.addSeparator();
24979 var field = this.navgroup.addItem( {
24981 cls : 'x-paging-position btn-outline-secondary',
24983 html : this.beforePageText +
24984 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24985 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24988 this.field = field.el.select('input', true).first();
24989 this.field.on("keydown", this.onPagingKeydown, this);
24990 this.field.on("focus", function(){this.dom.select();});
24993 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24994 //this.field.setHeight(18);
24995 //this.addSeparator();
24996 this.next = this.navgroup.addItem({
24997 tooltip: this.nextText,
24998 cls: "next btn-outline-secondary",
24999 html : ' <i class="fa fa-forward"></i>',
25001 preventDefault: true,
25002 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25004 this.last = this.navgroup.addItem({
25005 tooltip: this.lastText,
25006 html : ' <i class="fa fa-step-forward"></i>',
25007 cls: "next btn-outline-secondary",
25009 preventDefault: true,
25010 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25012 //this.addSeparator();
25013 this.loading = this.navgroup.addItem({
25014 tooltip: this.refreshText,
25015 cls: "btn-outline-secondary",
25016 html : ' <i class="fa fa-refresh"></i>',
25017 preventDefault: true,
25018 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25024 updateInfo : function(){
25025 if(this.displayEl){
25026 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25027 var msg = count == 0 ?
25031 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25033 this.displayEl.update(msg);
25038 onLoad : function(ds, r, o)
25040 this.cursor = o.params.start ? o.params.start : 0;
25042 var d = this.getPageData(),
25047 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25048 this.field.dom.value = ap;
25049 this.first.setDisabled(ap == 1);
25050 this.prev.setDisabled(ap == 1);
25051 this.next.setDisabled(ap == ps);
25052 this.last.setDisabled(ap == ps);
25053 this.loading.enable();
25058 getPageData : function(){
25059 var total = this.ds.getTotalCount();
25062 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25063 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25068 onLoadError : function(){
25069 this.loading.enable();
25073 onPagingKeydown : function(e){
25074 var k = e.getKey();
25075 var d = this.getPageData();
25077 var v = this.field.dom.value, pageNum;
25078 if(!v || isNaN(pageNum = parseInt(v, 10))){
25079 this.field.dom.value = d.activePage;
25082 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25083 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25086 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))
25088 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25089 this.field.dom.value = pageNum;
25090 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25093 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25095 var v = this.field.dom.value, pageNum;
25096 var increment = (e.shiftKey) ? 10 : 1;
25097 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25100 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25101 this.field.dom.value = d.activePage;
25104 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25106 this.field.dom.value = parseInt(v, 10) + increment;
25107 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25108 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25115 beforeLoad : function(){
25117 this.loading.disable();
25122 onClick : function(which){
25131 ds.load({params:{start: 0, limit: this.pageSize}});
25134 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25137 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25140 var total = ds.getTotalCount();
25141 var extra = total % this.pageSize;
25142 var lastStart = extra ? (total - extra) : total-this.pageSize;
25143 ds.load({params:{start: lastStart, limit: this.pageSize}});
25146 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25152 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25153 * @param {Roo.data.Store} store The data store to unbind
25155 unbind : function(ds){
25156 ds.un("beforeload", this.beforeLoad, this);
25157 ds.un("load", this.onLoad, this);
25158 ds.un("loadexception", this.onLoadError, this);
25159 ds.un("remove", this.updateInfo, this);
25160 ds.un("add", this.updateInfo, this);
25161 this.ds = undefined;
25165 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25166 * @param {Roo.data.Store} store The data store to bind
25168 bind : function(ds){
25169 ds.on("beforeload", this.beforeLoad, this);
25170 ds.on("load", this.onLoad, this);
25171 ds.on("loadexception", this.onLoadError, this);
25172 ds.on("remove", this.updateInfo, this);
25173 ds.on("add", this.updateInfo, this);
25184 * @class Roo.bootstrap.MessageBar
25185 * @extends Roo.bootstrap.Component
25186 * Bootstrap MessageBar class
25187 * @cfg {String} html contents of the MessageBar
25188 * @cfg {String} weight (info | success | warning | danger) default info
25189 * @cfg {String} beforeClass insert the bar before the given class
25190 * @cfg {Boolean} closable (true | false) default false
25191 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25194 * Create a new Element
25195 * @param {Object} config The config object
25198 Roo.bootstrap.MessageBar = function(config){
25199 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25202 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25208 beforeClass: 'bootstrap-sticky-wrap',
25210 getAutoCreate : function(){
25214 cls: 'alert alert-dismissable alert-' + this.weight,
25219 html: this.html || ''
25225 cfg.cls += ' alert-messages-fixed';
25239 onRender : function(ct, position)
25241 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25244 var cfg = Roo.apply({}, this.getAutoCreate());
25248 cfg.cls += ' ' + this.cls;
25251 cfg.style = this.style;
25253 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25255 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25258 this.el.select('>button.close').on('click', this.hide, this);
25264 if (!this.rendered) {
25270 this.fireEvent('show', this);
25276 if (!this.rendered) {
25282 this.fireEvent('hide', this);
25285 update : function()
25287 // var e = this.el.dom.firstChild;
25289 // if(this.closable){
25290 // e = e.nextSibling;
25293 // e.data = this.html || '';
25295 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25311 * @class Roo.bootstrap.Graph
25312 * @extends Roo.bootstrap.Component
25313 * Bootstrap Graph class
25317 @cfg {String} graphtype bar | vbar | pie
25318 @cfg {number} g_x coodinator | centre x (pie)
25319 @cfg {number} g_y coodinator | centre y (pie)
25320 @cfg {number} g_r radius (pie)
25321 @cfg {number} g_height height of the chart (respected by all elements in the set)
25322 @cfg {number} g_width width of the chart (respected by all elements in the set)
25323 @cfg {Object} title The title of the chart
25326 -opts (object) options for the chart
25328 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25329 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25331 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.
25332 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25334 o stretch (boolean)
25336 -opts (object) options for the pie
25339 o startAngle (number)
25340 o endAngle (number)
25344 * Create a new Input
25345 * @param {Object} config The config object
25348 Roo.bootstrap.Graph = function(config){
25349 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25355 * The img click event for the img.
25356 * @param {Roo.EventObject} e
25362 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25373 //g_colors: this.colors,
25380 getAutoCreate : function(){
25391 onRender : function(ct,position){
25394 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25396 if (typeof(Raphael) == 'undefined') {
25397 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25401 this.raphael = Raphael(this.el.dom);
25403 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25404 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25405 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25406 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25408 r.text(160, 10, "Single Series Chart").attr(txtattr);
25409 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25410 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25411 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25413 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25414 r.barchart(330, 10, 300, 220, data1);
25415 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25416 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25419 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25420 // r.barchart(30, 30, 560, 250, xdata, {
25421 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25422 // axis : "0 0 1 1",
25423 // axisxlabels : xdata
25424 // //yvalues : cols,
25427 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25429 // this.load(null,xdata,{
25430 // axis : "0 0 1 1",
25431 // axisxlabels : xdata
25436 load : function(graphtype,xdata,opts)
25438 this.raphael.clear();
25440 graphtype = this.graphtype;
25445 var r = this.raphael,
25446 fin = function () {
25447 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25449 fout = function () {
25450 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25452 pfin = function() {
25453 this.sector.stop();
25454 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25457 this.label[0].stop();
25458 this.label[0].attr({ r: 7.5 });
25459 this.label[1].attr({ "font-weight": 800 });
25462 pfout = function() {
25463 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25466 this.label[0].animate({ r: 5 }, 500, "bounce");
25467 this.label[1].attr({ "font-weight": 400 });
25473 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25476 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25479 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25480 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25482 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25489 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25494 setTitle: function(o)
25499 initEvents: function() {
25502 this.el.on('click', this.onClick, this);
25506 onClick : function(e)
25508 Roo.log('img onclick');
25509 this.fireEvent('click', this, e);
25521 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25524 * @class Roo.bootstrap.dash.NumberBox
25525 * @extends Roo.bootstrap.Component
25526 * Bootstrap NumberBox class
25527 * @cfg {String} headline Box headline
25528 * @cfg {String} content Box content
25529 * @cfg {String} icon Box icon
25530 * @cfg {String} footer Footer text
25531 * @cfg {String} fhref Footer href
25534 * Create a new NumberBox
25535 * @param {Object} config The config object
25539 Roo.bootstrap.dash.NumberBox = function(config){
25540 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25544 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25553 getAutoCreate : function(){
25557 cls : 'small-box ',
25565 cls : 'roo-headline',
25566 html : this.headline
25570 cls : 'roo-content',
25571 html : this.content
25585 cls : 'ion ' + this.icon
25594 cls : 'small-box-footer',
25595 href : this.fhref || '#',
25599 cfg.cn.push(footer);
25606 onRender : function(ct,position){
25607 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25614 setHeadline: function (value)
25616 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25619 setFooter: function (value, href)
25621 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25624 this.el.select('a.small-box-footer',true).first().attr('href', href);
25629 setContent: function (value)
25631 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25634 initEvents: function()
25648 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25651 * @class Roo.bootstrap.dash.TabBox
25652 * @extends Roo.bootstrap.Component
25653 * Bootstrap TabBox class
25654 * @cfg {String} title Title of the TabBox
25655 * @cfg {String} icon Icon of the TabBox
25656 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25657 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25660 * Create a new TabBox
25661 * @param {Object} config The config object
25665 Roo.bootstrap.dash.TabBox = function(config){
25666 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25671 * When a pane is added
25672 * @param {Roo.bootstrap.dash.TabPane} pane
25676 * @event activatepane
25677 * When a pane is activated
25678 * @param {Roo.bootstrap.dash.TabPane} pane
25680 "activatepane" : true
25688 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25693 tabScrollable : false,
25695 getChildContainer : function()
25697 return this.el.select('.tab-content', true).first();
25700 getAutoCreate : function(){
25704 cls: 'pull-left header',
25712 cls: 'fa ' + this.icon
25718 cls: 'nav nav-tabs pull-right',
25724 if(this.tabScrollable){
25731 cls: 'nav nav-tabs pull-right',
25742 cls: 'nav-tabs-custom',
25747 cls: 'tab-content no-padding',
25755 initEvents : function()
25757 //Roo.log('add add pane handler');
25758 this.on('addpane', this.onAddPane, this);
25761 * Updates the box title
25762 * @param {String} html to set the title to.
25764 setTitle : function(value)
25766 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25768 onAddPane : function(pane)
25770 this.panes.push(pane);
25771 //Roo.log('addpane');
25773 // tabs are rendere left to right..
25774 if(!this.showtabs){
25778 var ctr = this.el.select('.nav-tabs', true).first();
25781 var existing = ctr.select('.nav-tab',true);
25782 var qty = existing.getCount();;
25785 var tab = ctr.createChild({
25787 cls : 'nav-tab' + (qty ? '' : ' active'),
25795 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25798 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25800 pane.el.addClass('active');
25805 onTabClick : function(ev,un,ob,pane)
25807 //Roo.log('tab - prev default');
25808 ev.preventDefault();
25811 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25812 pane.tab.addClass('active');
25813 //Roo.log(pane.title);
25814 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25815 // technically we should have a deactivate event.. but maybe add later.
25816 // and it should not de-activate the selected tab...
25817 this.fireEvent('activatepane', pane);
25818 pane.el.addClass('active');
25819 pane.fireEvent('activate');
25824 getActivePane : function()
25827 Roo.each(this.panes, function(p) {
25828 if(p.el.hasClass('active')){
25849 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25851 * @class Roo.bootstrap.TabPane
25852 * @extends Roo.bootstrap.Component
25853 * Bootstrap TabPane class
25854 * @cfg {Boolean} active (false | true) Default false
25855 * @cfg {String} title title of panel
25859 * Create a new TabPane
25860 * @param {Object} config The config object
25863 Roo.bootstrap.dash.TabPane = function(config){
25864 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25870 * When a pane is activated
25871 * @param {Roo.bootstrap.dash.TabPane} pane
25878 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25883 // the tabBox that this is attached to.
25886 getAutoCreate : function()
25894 cfg.cls += ' active';
25899 initEvents : function()
25901 //Roo.log('trigger add pane handler');
25902 this.parent().fireEvent('addpane', this)
25906 * Updates the tab title
25907 * @param {String} html to set the title to.
25909 setTitle: function(str)
25915 this.tab.select('a', true).first().dom.innerHTML = str;
25932 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25935 * @class Roo.bootstrap.menu.Menu
25936 * @extends Roo.bootstrap.Component
25937 * Bootstrap Menu class - container for Menu
25938 * @cfg {String} html Text of the menu
25939 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25940 * @cfg {String} icon Font awesome icon
25941 * @cfg {String} pos Menu align to (top | bottom) default bottom
25945 * Create a new Menu
25946 * @param {Object} config The config object
25950 Roo.bootstrap.menu.Menu = function(config){
25951 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25955 * @event beforeshow
25956 * Fires before this menu is displayed
25957 * @param {Roo.bootstrap.menu.Menu} this
25961 * @event beforehide
25962 * Fires before this menu is hidden
25963 * @param {Roo.bootstrap.menu.Menu} this
25968 * Fires after this menu is displayed
25969 * @param {Roo.bootstrap.menu.Menu} this
25974 * Fires after this menu is hidden
25975 * @param {Roo.bootstrap.menu.Menu} this
25980 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25981 * @param {Roo.bootstrap.menu.Menu} this
25982 * @param {Roo.EventObject} e
25989 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25993 weight : 'default',
25998 getChildContainer : function() {
25999 if(this.isSubMenu){
26003 return this.el.select('ul.dropdown-menu', true).first();
26006 getAutoCreate : function()
26011 cls : 'roo-menu-text',
26019 cls : 'fa ' + this.icon
26030 cls : 'dropdown-button btn btn-' + this.weight,
26035 cls : 'dropdown-toggle btn btn-' + this.weight,
26045 cls : 'dropdown-menu'
26051 if(this.pos == 'top'){
26052 cfg.cls += ' dropup';
26055 if(this.isSubMenu){
26058 cls : 'dropdown-menu'
26065 onRender : function(ct, position)
26067 this.isSubMenu = ct.hasClass('dropdown-submenu');
26069 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26072 initEvents : function()
26074 if(this.isSubMenu){
26078 this.hidden = true;
26080 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26081 this.triggerEl.on('click', this.onTriggerPress, this);
26083 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26084 this.buttonEl.on('click', this.onClick, this);
26090 if(this.isSubMenu){
26094 return this.el.select('ul.dropdown-menu', true).first();
26097 onClick : function(e)
26099 this.fireEvent("click", this, e);
26102 onTriggerPress : function(e)
26104 if (this.isVisible()) {
26111 isVisible : function(){
26112 return !this.hidden;
26117 this.fireEvent("beforeshow", this);
26119 this.hidden = false;
26120 this.el.addClass('open');
26122 Roo.get(document).on("mouseup", this.onMouseUp, this);
26124 this.fireEvent("show", this);
26131 this.fireEvent("beforehide", this);
26133 this.hidden = true;
26134 this.el.removeClass('open');
26136 Roo.get(document).un("mouseup", this.onMouseUp);
26138 this.fireEvent("hide", this);
26141 onMouseUp : function()
26155 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26158 * @class Roo.bootstrap.menu.Item
26159 * @extends Roo.bootstrap.Component
26160 * Bootstrap MenuItem class
26161 * @cfg {Boolean} submenu (true | false) default false
26162 * @cfg {String} html text of the item
26163 * @cfg {String} href the link
26164 * @cfg {Boolean} disable (true | false) default false
26165 * @cfg {Boolean} preventDefault (true | false) default true
26166 * @cfg {String} icon Font awesome icon
26167 * @cfg {String} pos Submenu align to (left | right) default right
26171 * Create a new Item
26172 * @param {Object} config The config object
26176 Roo.bootstrap.menu.Item = function(config){
26177 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26181 * Fires when the mouse is hovering over this menu
26182 * @param {Roo.bootstrap.menu.Item} this
26183 * @param {Roo.EventObject} e
26188 * Fires when the mouse exits this menu
26189 * @param {Roo.bootstrap.menu.Item} this
26190 * @param {Roo.EventObject} e
26196 * The raw click event for the entire grid.
26197 * @param {Roo.EventObject} e
26203 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26208 preventDefault: true,
26213 getAutoCreate : function()
26218 cls : 'roo-menu-item-text',
26226 cls : 'fa ' + this.icon
26235 href : this.href || '#',
26242 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26246 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26248 if(this.pos == 'left'){
26249 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26256 initEvents : function()
26258 this.el.on('mouseover', this.onMouseOver, this);
26259 this.el.on('mouseout', this.onMouseOut, this);
26261 this.el.select('a', true).first().on('click', this.onClick, this);
26265 onClick : function(e)
26267 if(this.preventDefault){
26268 e.preventDefault();
26271 this.fireEvent("click", this, e);
26274 onMouseOver : function(e)
26276 if(this.submenu && this.pos == 'left'){
26277 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26280 this.fireEvent("mouseover", this, e);
26283 onMouseOut : function(e)
26285 this.fireEvent("mouseout", this, e);
26297 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26300 * @class Roo.bootstrap.menu.Separator
26301 * @extends Roo.bootstrap.Component
26302 * Bootstrap Separator class
26305 * Create a new Separator
26306 * @param {Object} config The config object
26310 Roo.bootstrap.menu.Separator = function(config){
26311 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26314 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26316 getAutoCreate : function(){
26337 * @class Roo.bootstrap.Tooltip
26338 * Bootstrap Tooltip class
26339 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26340 * to determine which dom element triggers the tooltip.
26342 * It needs to add support for additional attributes like tooltip-position
26345 * Create a new Toolti
26346 * @param {Object} config The config object
26349 Roo.bootstrap.Tooltip = function(config){
26350 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26352 this.alignment = Roo.bootstrap.Tooltip.alignment;
26354 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26355 this.alignment = config.alignment;
26360 Roo.apply(Roo.bootstrap.Tooltip, {
26362 * @function init initialize tooltip monitoring.
26366 currentTip : false,
26367 currentRegion : false,
26373 Roo.get(document).on('mouseover', this.enter ,this);
26374 Roo.get(document).on('mouseout', this.leave, this);
26377 this.currentTip = new Roo.bootstrap.Tooltip();
26380 enter : function(ev)
26382 var dom = ev.getTarget();
26384 //Roo.log(['enter',dom]);
26385 var el = Roo.fly(dom);
26386 if (this.currentEl) {
26388 //Roo.log(this.currentEl);
26389 //Roo.log(this.currentEl.contains(dom));
26390 if (this.currentEl == el) {
26393 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26399 if (this.currentTip.el) {
26400 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26404 if(!el || el.dom == document){
26410 // you can not look for children, as if el is the body.. then everythign is the child..
26411 if (!el.attr('tooltip')) { //
26412 if (!el.select("[tooltip]").elements.length) {
26415 // is the mouse over this child...?
26416 bindEl = el.select("[tooltip]").first();
26417 var xy = ev.getXY();
26418 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26419 //Roo.log("not in region.");
26422 //Roo.log("child element over..");
26425 this.currentEl = bindEl;
26426 this.currentTip.bind(bindEl);
26427 this.currentRegion = Roo.lib.Region.getRegion(dom);
26428 this.currentTip.enter();
26431 leave : function(ev)
26433 var dom = ev.getTarget();
26434 //Roo.log(['leave',dom]);
26435 if (!this.currentEl) {
26440 if (dom != this.currentEl.dom) {
26443 var xy = ev.getXY();
26444 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26447 // only activate leave if mouse cursor is outside... bounding box..
26452 if (this.currentTip) {
26453 this.currentTip.leave();
26455 //Roo.log('clear currentEl');
26456 this.currentEl = false;
26461 'left' : ['r-l', [-2,0], 'right'],
26462 'right' : ['l-r', [2,0], 'left'],
26463 'bottom' : ['t-b', [0,2], 'top'],
26464 'top' : [ 'b-t', [0,-2], 'bottom']
26470 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26475 delay : null, // can be { show : 300 , hide: 500}
26479 hoverState : null, //???
26481 placement : 'bottom',
26485 getAutoCreate : function(){
26492 cls : 'tooltip-arrow'
26495 cls : 'tooltip-inner'
26502 bind : function(el)
26508 enter : function () {
26510 if (this.timeout != null) {
26511 clearTimeout(this.timeout);
26514 this.hoverState = 'in';
26515 //Roo.log("enter - show");
26516 if (!this.delay || !this.delay.show) {
26521 this.timeout = setTimeout(function () {
26522 if (_t.hoverState == 'in') {
26525 }, this.delay.show);
26529 clearTimeout(this.timeout);
26531 this.hoverState = 'out';
26532 if (!this.delay || !this.delay.hide) {
26538 this.timeout = setTimeout(function () {
26539 //Roo.log("leave - timeout");
26541 if (_t.hoverState == 'out') {
26543 Roo.bootstrap.Tooltip.currentEl = false;
26548 show : function (msg)
26551 this.render(document.body);
26554 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26556 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26558 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26560 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26562 var placement = typeof this.placement == 'function' ?
26563 this.placement.call(this, this.el, on_el) :
26566 var autoToken = /\s?auto?\s?/i;
26567 var autoPlace = autoToken.test(placement);
26569 placement = placement.replace(autoToken, '') || 'top';
26573 //this.el.setXY([0,0]);
26575 //this.el.dom.style.display='block';
26577 //this.el.appendTo(on_el);
26579 var p = this.getPosition();
26580 var box = this.el.getBox();
26586 var align = this.alignment[placement];
26588 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26590 if(placement == 'top' || placement == 'bottom'){
26592 placement = 'right';
26595 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26596 placement = 'left';
26599 var scroll = Roo.select('body', true).first().getScroll();
26601 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26605 align = this.alignment[placement];
26608 this.el.alignTo(this.bindEl, align[0],align[1]);
26609 //var arrow = this.el.select('.arrow',true).first();
26610 //arrow.set(align[2],
26612 this.el.addClass(placement);
26614 this.el.addClass('in fade');
26616 this.hoverState = null;
26618 if (this.el.hasClass('fade')) {
26629 //this.el.setXY([0,0]);
26630 this.el.removeClass('in');
26646 * @class Roo.bootstrap.LocationPicker
26647 * @extends Roo.bootstrap.Component
26648 * Bootstrap LocationPicker class
26649 * @cfg {Number} latitude Position when init default 0
26650 * @cfg {Number} longitude Position when init default 0
26651 * @cfg {Number} zoom default 15
26652 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26653 * @cfg {Boolean} mapTypeControl default false
26654 * @cfg {Boolean} disableDoubleClickZoom default false
26655 * @cfg {Boolean} scrollwheel default true
26656 * @cfg {Boolean} streetViewControl default false
26657 * @cfg {Number} radius default 0
26658 * @cfg {String} locationName
26659 * @cfg {Boolean} draggable default true
26660 * @cfg {Boolean} enableAutocomplete default false
26661 * @cfg {Boolean} enableReverseGeocode default true
26662 * @cfg {String} markerTitle
26665 * Create a new LocationPicker
26666 * @param {Object} config The config object
26670 Roo.bootstrap.LocationPicker = function(config){
26672 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26677 * Fires when the picker initialized.
26678 * @param {Roo.bootstrap.LocationPicker} this
26679 * @param {Google Location} location
26683 * @event positionchanged
26684 * Fires when the picker position changed.
26685 * @param {Roo.bootstrap.LocationPicker} this
26686 * @param {Google Location} location
26688 positionchanged : true,
26691 * Fires when the map resize.
26692 * @param {Roo.bootstrap.LocationPicker} this
26697 * Fires when the map show.
26698 * @param {Roo.bootstrap.LocationPicker} this
26703 * Fires when the map hide.
26704 * @param {Roo.bootstrap.LocationPicker} this
26709 * Fires when click the map.
26710 * @param {Roo.bootstrap.LocationPicker} this
26711 * @param {Map event} e
26715 * @event mapRightClick
26716 * Fires when right click the map.
26717 * @param {Roo.bootstrap.LocationPicker} this
26718 * @param {Map event} e
26720 mapRightClick : true,
26722 * @event markerClick
26723 * Fires when click the marker.
26724 * @param {Roo.bootstrap.LocationPicker} this
26725 * @param {Map event} e
26727 markerClick : true,
26729 * @event markerRightClick
26730 * Fires when right click the marker.
26731 * @param {Roo.bootstrap.LocationPicker} this
26732 * @param {Map event} e
26734 markerRightClick : true,
26736 * @event OverlayViewDraw
26737 * Fires when OverlayView Draw
26738 * @param {Roo.bootstrap.LocationPicker} this
26740 OverlayViewDraw : true,
26742 * @event OverlayViewOnAdd
26743 * Fires when OverlayView Draw
26744 * @param {Roo.bootstrap.LocationPicker} this
26746 OverlayViewOnAdd : true,
26748 * @event OverlayViewOnRemove
26749 * Fires when OverlayView Draw
26750 * @param {Roo.bootstrap.LocationPicker} this
26752 OverlayViewOnRemove : true,
26754 * @event OverlayViewShow
26755 * Fires when OverlayView Draw
26756 * @param {Roo.bootstrap.LocationPicker} this
26757 * @param {Pixel} cpx
26759 OverlayViewShow : true,
26761 * @event OverlayViewHide
26762 * Fires when OverlayView Draw
26763 * @param {Roo.bootstrap.LocationPicker} this
26765 OverlayViewHide : true,
26767 * @event loadexception
26768 * Fires when load google lib failed.
26769 * @param {Roo.bootstrap.LocationPicker} this
26771 loadexception : true
26776 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26778 gMapContext: false,
26784 mapTypeControl: false,
26785 disableDoubleClickZoom: false,
26787 streetViewControl: false,
26791 enableAutocomplete: false,
26792 enableReverseGeocode: true,
26795 getAutoCreate: function()
26800 cls: 'roo-location-picker'
26806 initEvents: function(ct, position)
26808 if(!this.el.getWidth() || this.isApplied()){
26812 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26817 initial: function()
26819 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26820 this.fireEvent('loadexception', this);
26824 if(!this.mapTypeId){
26825 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26828 this.gMapContext = this.GMapContext();
26830 this.initOverlayView();
26832 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26836 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26837 _this.setPosition(_this.gMapContext.marker.position);
26840 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26841 _this.fireEvent('mapClick', this, event);
26845 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26846 _this.fireEvent('mapRightClick', this, event);
26850 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26851 _this.fireEvent('markerClick', this, event);
26855 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26856 _this.fireEvent('markerRightClick', this, event);
26860 this.setPosition(this.gMapContext.location);
26862 this.fireEvent('initial', this, this.gMapContext.location);
26865 initOverlayView: function()
26869 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26873 _this.fireEvent('OverlayViewDraw', _this);
26878 _this.fireEvent('OverlayViewOnAdd', _this);
26881 onRemove: function()
26883 _this.fireEvent('OverlayViewOnRemove', _this);
26886 show: function(cpx)
26888 _this.fireEvent('OverlayViewShow', _this, cpx);
26893 _this.fireEvent('OverlayViewHide', _this);
26899 fromLatLngToContainerPixel: function(event)
26901 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26904 isApplied: function()
26906 return this.getGmapContext() == false ? false : true;
26909 getGmapContext: function()
26911 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26914 GMapContext: function()
26916 var position = new google.maps.LatLng(this.latitude, this.longitude);
26918 var _map = new google.maps.Map(this.el.dom, {
26921 mapTypeId: this.mapTypeId,
26922 mapTypeControl: this.mapTypeControl,
26923 disableDoubleClickZoom: this.disableDoubleClickZoom,
26924 scrollwheel: this.scrollwheel,
26925 streetViewControl: this.streetViewControl,
26926 locationName: this.locationName,
26927 draggable: this.draggable,
26928 enableAutocomplete: this.enableAutocomplete,
26929 enableReverseGeocode: this.enableReverseGeocode
26932 var _marker = new google.maps.Marker({
26933 position: position,
26935 title: this.markerTitle,
26936 draggable: this.draggable
26943 location: position,
26944 radius: this.radius,
26945 locationName: this.locationName,
26946 addressComponents: {
26947 formatted_address: null,
26948 addressLine1: null,
26949 addressLine2: null,
26951 streetNumber: null,
26955 stateOrProvince: null
26958 domContainer: this.el.dom,
26959 geodecoder: new google.maps.Geocoder()
26963 drawCircle: function(center, radius, options)
26965 if (this.gMapContext.circle != null) {
26966 this.gMapContext.circle.setMap(null);
26970 options = Roo.apply({}, options, {
26971 strokeColor: "#0000FF",
26972 strokeOpacity: .35,
26974 fillColor: "#0000FF",
26978 options.map = this.gMapContext.map;
26979 options.radius = radius;
26980 options.center = center;
26981 this.gMapContext.circle = new google.maps.Circle(options);
26982 return this.gMapContext.circle;
26988 setPosition: function(location)
26990 this.gMapContext.location = location;
26991 this.gMapContext.marker.setPosition(location);
26992 this.gMapContext.map.panTo(location);
26993 this.drawCircle(location, this.gMapContext.radius, {});
26997 if (this.gMapContext.settings.enableReverseGeocode) {
26998 this.gMapContext.geodecoder.geocode({
26999 latLng: this.gMapContext.location
27000 }, function(results, status) {
27002 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27003 _this.gMapContext.locationName = results[0].formatted_address;
27004 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27006 _this.fireEvent('positionchanged', this, location);
27013 this.fireEvent('positionchanged', this, location);
27018 google.maps.event.trigger(this.gMapContext.map, "resize");
27020 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27022 this.fireEvent('resize', this);
27025 setPositionByLatLng: function(latitude, longitude)
27027 this.setPosition(new google.maps.LatLng(latitude, longitude));
27030 getCurrentPosition: function()
27033 latitude: this.gMapContext.location.lat(),
27034 longitude: this.gMapContext.location.lng()
27038 getAddressName: function()
27040 return this.gMapContext.locationName;
27043 getAddressComponents: function()
27045 return this.gMapContext.addressComponents;
27048 address_component_from_google_geocode: function(address_components)
27052 for (var i = 0; i < address_components.length; i++) {
27053 var component = address_components[i];
27054 if (component.types.indexOf("postal_code") >= 0) {
27055 result.postalCode = component.short_name;
27056 } else if (component.types.indexOf("street_number") >= 0) {
27057 result.streetNumber = component.short_name;
27058 } else if (component.types.indexOf("route") >= 0) {
27059 result.streetName = component.short_name;
27060 } else if (component.types.indexOf("neighborhood") >= 0) {
27061 result.city = component.short_name;
27062 } else if (component.types.indexOf("locality") >= 0) {
27063 result.city = component.short_name;
27064 } else if (component.types.indexOf("sublocality") >= 0) {
27065 result.district = component.short_name;
27066 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27067 result.stateOrProvince = component.short_name;
27068 } else if (component.types.indexOf("country") >= 0) {
27069 result.country = component.short_name;
27073 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27074 result.addressLine2 = "";
27078 setZoomLevel: function(zoom)
27080 this.gMapContext.map.setZoom(zoom);
27093 this.fireEvent('show', this);
27104 this.fireEvent('hide', this);
27109 Roo.apply(Roo.bootstrap.LocationPicker, {
27111 OverlayView : function(map, options)
27113 options = options || {};
27127 * @class Roo.bootstrap.Alert
27128 * @extends Roo.bootstrap.Component
27129 * Bootstrap Alert class
27130 * @cfg {String} title The title of alert
27131 * @cfg {String} html The content of alert
27132 * @cfg {String} weight ( success | info | warning | danger )
27133 * @cfg {String} faicon font-awesomeicon
27136 * Create a new alert
27137 * @param {Object} config The config object
27141 Roo.bootstrap.Alert = function(config){
27142 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27146 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27153 getAutoCreate : function()
27162 cls : 'roo-alert-icon'
27167 cls : 'roo-alert-title',
27172 cls : 'roo-alert-text',
27179 cfg.cn[0].cls += ' fa ' + this.faicon;
27183 cfg.cls += ' alert-' + this.weight;
27189 initEvents: function()
27191 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27194 setTitle : function(str)
27196 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27199 setText : function(str)
27201 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27204 setWeight : function(weight)
27207 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27210 this.weight = weight;
27212 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27215 setIcon : function(icon)
27218 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27221 this.faicon = icon;
27223 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27244 * @class Roo.bootstrap.UploadCropbox
27245 * @extends Roo.bootstrap.Component
27246 * Bootstrap UploadCropbox class
27247 * @cfg {String} emptyText show when image has been loaded
27248 * @cfg {String} rotateNotify show when image too small to rotate
27249 * @cfg {Number} errorTimeout default 3000
27250 * @cfg {Number} minWidth default 300
27251 * @cfg {Number} minHeight default 300
27252 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27253 * @cfg {Boolean} isDocument (true|false) default false
27254 * @cfg {String} url action url
27255 * @cfg {String} paramName default 'imageUpload'
27256 * @cfg {String} method default POST
27257 * @cfg {Boolean} loadMask (true|false) default true
27258 * @cfg {Boolean} loadingText default 'Loading...'
27261 * Create a new UploadCropbox
27262 * @param {Object} config The config object
27265 Roo.bootstrap.UploadCropbox = function(config){
27266 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27270 * @event beforeselectfile
27271 * Fire before select file
27272 * @param {Roo.bootstrap.UploadCropbox} this
27274 "beforeselectfile" : true,
27277 * Fire after initEvent
27278 * @param {Roo.bootstrap.UploadCropbox} this
27283 * Fire after initEvent
27284 * @param {Roo.bootstrap.UploadCropbox} this
27285 * @param {String} data
27290 * Fire when preparing the file data
27291 * @param {Roo.bootstrap.UploadCropbox} this
27292 * @param {Object} file
27297 * Fire when get exception
27298 * @param {Roo.bootstrap.UploadCropbox} this
27299 * @param {XMLHttpRequest} xhr
27301 "exception" : true,
27303 * @event beforeloadcanvas
27304 * Fire before load the canvas
27305 * @param {Roo.bootstrap.UploadCropbox} this
27306 * @param {String} src
27308 "beforeloadcanvas" : true,
27311 * Fire when trash image
27312 * @param {Roo.bootstrap.UploadCropbox} this
27317 * Fire when download the image
27318 * @param {Roo.bootstrap.UploadCropbox} this
27322 * @event footerbuttonclick
27323 * Fire when footerbuttonclick
27324 * @param {Roo.bootstrap.UploadCropbox} this
27325 * @param {String} type
27327 "footerbuttonclick" : true,
27331 * @param {Roo.bootstrap.UploadCropbox} this
27336 * Fire when rotate the image
27337 * @param {Roo.bootstrap.UploadCropbox} this
27338 * @param {String} pos
27343 * Fire when inspect the file
27344 * @param {Roo.bootstrap.UploadCropbox} this
27345 * @param {Object} file
27350 * Fire when xhr upload the file
27351 * @param {Roo.bootstrap.UploadCropbox} this
27352 * @param {Object} data
27357 * Fire when arrange the file data
27358 * @param {Roo.bootstrap.UploadCropbox} this
27359 * @param {Object} formData
27364 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27367 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27369 emptyText : 'Click to upload image',
27370 rotateNotify : 'Image is too small to rotate',
27371 errorTimeout : 3000,
27385 cropType : 'image/jpeg',
27387 canvasLoaded : false,
27388 isDocument : false,
27390 paramName : 'imageUpload',
27392 loadingText : 'Loading...',
27395 getAutoCreate : function()
27399 cls : 'roo-upload-cropbox',
27403 cls : 'roo-upload-cropbox-selector',
27408 cls : 'roo-upload-cropbox-body',
27409 style : 'cursor:pointer',
27413 cls : 'roo-upload-cropbox-preview'
27417 cls : 'roo-upload-cropbox-thumb'
27421 cls : 'roo-upload-cropbox-empty-notify',
27422 html : this.emptyText
27426 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27427 html : this.rotateNotify
27433 cls : 'roo-upload-cropbox-footer',
27436 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27446 onRender : function(ct, position)
27448 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27450 if (this.buttons.length) {
27452 Roo.each(this.buttons, function(bb) {
27454 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27456 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27462 this.maskEl = this.el;
27466 initEvents : function()
27468 this.urlAPI = (window.createObjectURL && window) ||
27469 (window.URL && URL.revokeObjectURL && URL) ||
27470 (window.webkitURL && webkitURL);
27472 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27473 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27475 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27476 this.selectorEl.hide();
27478 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27479 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27481 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27482 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27483 this.thumbEl.hide();
27485 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27486 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27488 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27489 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27490 this.errorEl.hide();
27492 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27493 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27494 this.footerEl.hide();
27496 this.setThumbBoxSize();
27502 this.fireEvent('initial', this);
27509 window.addEventListener("resize", function() { _this.resize(); } );
27511 this.bodyEl.on('click', this.beforeSelectFile, this);
27514 this.bodyEl.on('touchstart', this.onTouchStart, this);
27515 this.bodyEl.on('touchmove', this.onTouchMove, this);
27516 this.bodyEl.on('touchend', this.onTouchEnd, this);
27520 this.bodyEl.on('mousedown', this.onMouseDown, this);
27521 this.bodyEl.on('mousemove', this.onMouseMove, this);
27522 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27523 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27524 Roo.get(document).on('mouseup', this.onMouseUp, this);
27527 this.selectorEl.on('change', this.onFileSelected, this);
27533 this.baseScale = 1;
27535 this.baseRotate = 1;
27536 this.dragable = false;
27537 this.pinching = false;
27540 this.cropData = false;
27541 this.notifyEl.dom.innerHTML = this.emptyText;
27543 this.selectorEl.dom.value = '';
27547 resize : function()
27549 if(this.fireEvent('resize', this) != false){
27550 this.setThumbBoxPosition();
27551 this.setCanvasPosition();
27555 onFooterButtonClick : function(e, el, o, type)
27558 case 'rotate-left' :
27559 this.onRotateLeft(e);
27561 case 'rotate-right' :
27562 this.onRotateRight(e);
27565 this.beforeSelectFile(e);
27580 this.fireEvent('footerbuttonclick', this, type);
27583 beforeSelectFile : function(e)
27585 e.preventDefault();
27587 if(this.fireEvent('beforeselectfile', this) != false){
27588 this.selectorEl.dom.click();
27592 onFileSelected : function(e)
27594 e.preventDefault();
27596 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27600 var file = this.selectorEl.dom.files[0];
27602 if(this.fireEvent('inspect', this, file) != false){
27603 this.prepare(file);
27608 trash : function(e)
27610 this.fireEvent('trash', this);
27613 download : function(e)
27615 this.fireEvent('download', this);
27618 loadCanvas : function(src)
27620 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27624 this.imageEl = document.createElement('img');
27628 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27630 this.imageEl.src = src;
27634 onLoadCanvas : function()
27636 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27637 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27639 this.bodyEl.un('click', this.beforeSelectFile, this);
27641 this.notifyEl.hide();
27642 this.thumbEl.show();
27643 this.footerEl.show();
27645 this.baseRotateLevel();
27647 if(this.isDocument){
27648 this.setThumbBoxSize();
27651 this.setThumbBoxPosition();
27653 this.baseScaleLevel();
27659 this.canvasLoaded = true;
27662 this.maskEl.unmask();
27667 setCanvasPosition : function()
27669 if(!this.canvasEl){
27673 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27674 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27676 this.previewEl.setLeft(pw);
27677 this.previewEl.setTop(ph);
27681 onMouseDown : function(e)
27685 this.dragable = true;
27686 this.pinching = false;
27688 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27689 this.dragable = false;
27693 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27694 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27698 onMouseMove : function(e)
27702 if(!this.canvasLoaded){
27706 if (!this.dragable){
27710 var minX = Math.ceil(this.thumbEl.getLeft(true));
27711 var minY = Math.ceil(this.thumbEl.getTop(true));
27713 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27714 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27716 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27717 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27719 x = x - this.mouseX;
27720 y = y - this.mouseY;
27722 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27723 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27725 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27726 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27728 this.previewEl.setLeft(bgX);
27729 this.previewEl.setTop(bgY);
27731 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27732 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27735 onMouseUp : function(e)
27739 this.dragable = false;
27742 onMouseWheel : function(e)
27746 this.startScale = this.scale;
27748 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27750 if(!this.zoomable()){
27751 this.scale = this.startScale;
27760 zoomable : function()
27762 var minScale = this.thumbEl.getWidth() / this.minWidth;
27764 if(this.minWidth < this.minHeight){
27765 minScale = this.thumbEl.getHeight() / this.minHeight;
27768 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27769 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27773 (this.rotate == 0 || this.rotate == 180) &&
27775 width > this.imageEl.OriginWidth ||
27776 height > this.imageEl.OriginHeight ||
27777 (width < this.minWidth && height < this.minHeight)
27785 (this.rotate == 90 || this.rotate == 270) &&
27787 width > this.imageEl.OriginWidth ||
27788 height > this.imageEl.OriginHeight ||
27789 (width < this.minHeight && height < this.minWidth)
27796 !this.isDocument &&
27797 (this.rotate == 0 || this.rotate == 180) &&
27799 width < this.minWidth ||
27800 width > this.imageEl.OriginWidth ||
27801 height < this.minHeight ||
27802 height > this.imageEl.OriginHeight
27809 !this.isDocument &&
27810 (this.rotate == 90 || this.rotate == 270) &&
27812 width < this.minHeight ||
27813 width > this.imageEl.OriginWidth ||
27814 height < this.minWidth ||
27815 height > this.imageEl.OriginHeight
27825 onRotateLeft : function(e)
27827 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27829 var minScale = this.thumbEl.getWidth() / this.minWidth;
27831 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27832 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27834 this.startScale = this.scale;
27836 while (this.getScaleLevel() < minScale){
27838 this.scale = this.scale + 1;
27840 if(!this.zoomable()){
27845 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27846 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27851 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27858 this.scale = this.startScale;
27860 this.onRotateFail();
27865 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27867 if(this.isDocument){
27868 this.setThumbBoxSize();
27869 this.setThumbBoxPosition();
27870 this.setCanvasPosition();
27875 this.fireEvent('rotate', this, 'left');
27879 onRotateRight : function(e)
27881 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27883 var minScale = this.thumbEl.getWidth() / this.minWidth;
27885 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27886 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27888 this.startScale = this.scale;
27890 while (this.getScaleLevel() < minScale){
27892 this.scale = this.scale + 1;
27894 if(!this.zoomable()){
27899 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27900 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27905 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27912 this.scale = this.startScale;
27914 this.onRotateFail();
27919 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27921 if(this.isDocument){
27922 this.setThumbBoxSize();
27923 this.setThumbBoxPosition();
27924 this.setCanvasPosition();
27929 this.fireEvent('rotate', this, 'right');
27932 onRotateFail : function()
27934 this.errorEl.show(true);
27938 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27943 this.previewEl.dom.innerHTML = '';
27945 var canvasEl = document.createElement("canvas");
27947 var contextEl = canvasEl.getContext("2d");
27949 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27950 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27951 var center = this.imageEl.OriginWidth / 2;
27953 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27954 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27955 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27956 center = this.imageEl.OriginHeight / 2;
27959 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27961 contextEl.translate(center, center);
27962 contextEl.rotate(this.rotate * Math.PI / 180);
27964 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27966 this.canvasEl = document.createElement("canvas");
27968 this.contextEl = this.canvasEl.getContext("2d");
27970 switch (this.rotate) {
27973 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27974 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27976 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27981 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27982 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27984 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27985 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);
27989 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27994 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27995 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27997 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27998 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);
28002 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);
28007 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28008 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28010 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28011 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28015 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);
28022 this.previewEl.appendChild(this.canvasEl);
28024 this.setCanvasPosition();
28029 if(!this.canvasLoaded){
28033 var imageCanvas = document.createElement("canvas");
28035 var imageContext = imageCanvas.getContext("2d");
28037 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28038 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28040 var center = imageCanvas.width / 2;
28042 imageContext.translate(center, center);
28044 imageContext.rotate(this.rotate * Math.PI / 180);
28046 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28048 var canvas = document.createElement("canvas");
28050 var context = canvas.getContext("2d");
28052 canvas.width = this.minWidth;
28053 canvas.height = this.minHeight;
28055 switch (this.rotate) {
28058 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28059 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28061 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28062 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28064 var targetWidth = this.minWidth - 2 * x;
28065 var targetHeight = this.minHeight - 2 * y;
28069 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28070 scale = targetWidth / width;
28073 if(x > 0 && y == 0){
28074 scale = targetHeight / height;
28077 if(x > 0 && y > 0){
28078 scale = targetWidth / width;
28080 if(width < height){
28081 scale = targetHeight / height;
28085 context.scale(scale, scale);
28087 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28088 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28090 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28091 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28093 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28098 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28099 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28101 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28102 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28104 var targetWidth = this.minWidth - 2 * x;
28105 var targetHeight = this.minHeight - 2 * y;
28109 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28110 scale = targetWidth / width;
28113 if(x > 0 && y == 0){
28114 scale = targetHeight / height;
28117 if(x > 0 && y > 0){
28118 scale = targetWidth / width;
28120 if(width < height){
28121 scale = targetHeight / height;
28125 context.scale(scale, scale);
28127 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28128 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28130 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28131 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28133 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28135 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28140 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28141 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28143 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28144 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28146 var targetWidth = this.minWidth - 2 * x;
28147 var targetHeight = this.minHeight - 2 * y;
28151 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28152 scale = targetWidth / width;
28155 if(x > 0 && y == 0){
28156 scale = targetHeight / height;
28159 if(x > 0 && y > 0){
28160 scale = targetWidth / width;
28162 if(width < height){
28163 scale = targetHeight / height;
28167 context.scale(scale, scale);
28169 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28170 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28172 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28173 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28175 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28176 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28178 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28183 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28184 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28186 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28187 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28189 var targetWidth = this.minWidth - 2 * x;
28190 var targetHeight = this.minHeight - 2 * y;
28194 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28195 scale = targetWidth / width;
28198 if(x > 0 && y == 0){
28199 scale = targetHeight / height;
28202 if(x > 0 && y > 0){
28203 scale = targetWidth / width;
28205 if(width < height){
28206 scale = targetHeight / height;
28210 context.scale(scale, scale);
28212 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28213 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28215 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28216 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28218 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28220 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28227 this.cropData = canvas.toDataURL(this.cropType);
28229 if(this.fireEvent('crop', this, this.cropData) !== false){
28230 this.process(this.file, this.cropData);
28237 setThumbBoxSize : function()
28241 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28242 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28243 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28245 this.minWidth = width;
28246 this.minHeight = height;
28248 if(this.rotate == 90 || this.rotate == 270){
28249 this.minWidth = height;
28250 this.minHeight = width;
28255 width = Math.ceil(this.minWidth * height / this.minHeight);
28257 if(this.minWidth > this.minHeight){
28259 height = Math.ceil(this.minHeight * width / this.minWidth);
28262 this.thumbEl.setStyle({
28263 width : width + 'px',
28264 height : height + 'px'
28271 setThumbBoxPosition : function()
28273 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28274 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28276 this.thumbEl.setLeft(x);
28277 this.thumbEl.setTop(y);
28281 baseRotateLevel : function()
28283 this.baseRotate = 1;
28286 typeof(this.exif) != 'undefined' &&
28287 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28288 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28290 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28293 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28297 baseScaleLevel : function()
28301 if(this.isDocument){
28303 if(this.baseRotate == 6 || this.baseRotate == 8){
28305 height = this.thumbEl.getHeight();
28306 this.baseScale = height / this.imageEl.OriginWidth;
28308 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28309 width = this.thumbEl.getWidth();
28310 this.baseScale = width / this.imageEl.OriginHeight;
28316 height = this.thumbEl.getHeight();
28317 this.baseScale = height / this.imageEl.OriginHeight;
28319 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28320 width = this.thumbEl.getWidth();
28321 this.baseScale = width / this.imageEl.OriginWidth;
28327 if(this.baseRotate == 6 || this.baseRotate == 8){
28329 width = this.thumbEl.getHeight();
28330 this.baseScale = width / this.imageEl.OriginHeight;
28332 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28333 height = this.thumbEl.getWidth();
28334 this.baseScale = height / this.imageEl.OriginHeight;
28337 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28338 height = this.thumbEl.getWidth();
28339 this.baseScale = height / this.imageEl.OriginHeight;
28341 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28342 width = this.thumbEl.getHeight();
28343 this.baseScale = width / this.imageEl.OriginWidth;
28350 width = this.thumbEl.getWidth();
28351 this.baseScale = width / this.imageEl.OriginWidth;
28353 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28354 height = this.thumbEl.getHeight();
28355 this.baseScale = height / this.imageEl.OriginHeight;
28358 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28360 height = this.thumbEl.getHeight();
28361 this.baseScale = height / this.imageEl.OriginHeight;
28363 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28364 width = this.thumbEl.getWidth();
28365 this.baseScale = width / this.imageEl.OriginWidth;
28373 getScaleLevel : function()
28375 return this.baseScale * Math.pow(1.1, this.scale);
28378 onTouchStart : function(e)
28380 if(!this.canvasLoaded){
28381 this.beforeSelectFile(e);
28385 var touches = e.browserEvent.touches;
28391 if(touches.length == 1){
28392 this.onMouseDown(e);
28396 if(touches.length != 2){
28402 for(var i = 0, finger; finger = touches[i]; i++){
28403 coords.push(finger.pageX, finger.pageY);
28406 var x = Math.pow(coords[0] - coords[2], 2);
28407 var y = Math.pow(coords[1] - coords[3], 2);
28409 this.startDistance = Math.sqrt(x + y);
28411 this.startScale = this.scale;
28413 this.pinching = true;
28414 this.dragable = false;
28418 onTouchMove : function(e)
28420 if(!this.pinching && !this.dragable){
28424 var touches = e.browserEvent.touches;
28431 this.onMouseMove(e);
28437 for(var i = 0, finger; finger = touches[i]; i++){
28438 coords.push(finger.pageX, finger.pageY);
28441 var x = Math.pow(coords[0] - coords[2], 2);
28442 var y = Math.pow(coords[1] - coords[3], 2);
28444 this.endDistance = Math.sqrt(x + y);
28446 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28448 if(!this.zoomable()){
28449 this.scale = this.startScale;
28457 onTouchEnd : function(e)
28459 this.pinching = false;
28460 this.dragable = false;
28464 process : function(file, crop)
28467 this.maskEl.mask(this.loadingText);
28470 this.xhr = new XMLHttpRequest();
28472 file.xhr = this.xhr;
28474 this.xhr.open(this.method, this.url, true);
28477 "Accept": "application/json",
28478 "Cache-Control": "no-cache",
28479 "X-Requested-With": "XMLHttpRequest"
28482 for (var headerName in headers) {
28483 var headerValue = headers[headerName];
28485 this.xhr.setRequestHeader(headerName, headerValue);
28491 this.xhr.onload = function()
28493 _this.xhrOnLoad(_this.xhr);
28496 this.xhr.onerror = function()
28498 _this.xhrOnError(_this.xhr);
28501 var formData = new FormData();
28503 formData.append('returnHTML', 'NO');
28506 formData.append('crop', crop);
28509 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28510 formData.append(this.paramName, file, file.name);
28513 if(typeof(file.filename) != 'undefined'){
28514 formData.append('filename', file.filename);
28517 if(typeof(file.mimetype) != 'undefined'){
28518 formData.append('mimetype', file.mimetype);
28521 if(this.fireEvent('arrange', this, formData) != false){
28522 this.xhr.send(formData);
28526 xhrOnLoad : function(xhr)
28529 this.maskEl.unmask();
28532 if (xhr.readyState !== 4) {
28533 this.fireEvent('exception', this, xhr);
28537 var response = Roo.decode(xhr.responseText);
28539 if(!response.success){
28540 this.fireEvent('exception', this, xhr);
28544 var response = Roo.decode(xhr.responseText);
28546 this.fireEvent('upload', this, response);
28550 xhrOnError : function()
28553 this.maskEl.unmask();
28556 Roo.log('xhr on error');
28558 var response = Roo.decode(xhr.responseText);
28564 prepare : function(file)
28567 this.maskEl.mask(this.loadingText);
28573 if(typeof(file) === 'string'){
28574 this.loadCanvas(file);
28578 if(!file || !this.urlAPI){
28583 this.cropType = file.type;
28587 if(this.fireEvent('prepare', this, this.file) != false){
28589 var reader = new FileReader();
28591 reader.onload = function (e) {
28592 if (e.target.error) {
28593 Roo.log(e.target.error);
28597 var buffer = e.target.result,
28598 dataView = new DataView(buffer),
28600 maxOffset = dataView.byteLength - 4,
28604 if (dataView.getUint16(0) === 0xffd8) {
28605 while (offset < maxOffset) {
28606 markerBytes = dataView.getUint16(offset);
28608 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28609 markerLength = dataView.getUint16(offset + 2) + 2;
28610 if (offset + markerLength > dataView.byteLength) {
28611 Roo.log('Invalid meta data: Invalid segment size.');
28615 if(markerBytes == 0xffe1){
28616 _this.parseExifData(
28623 offset += markerLength;
28633 var url = _this.urlAPI.createObjectURL(_this.file);
28635 _this.loadCanvas(url);
28640 reader.readAsArrayBuffer(this.file);
28646 parseExifData : function(dataView, offset, length)
28648 var tiffOffset = offset + 10,
28652 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28653 // No Exif data, might be XMP data instead
28657 // Check for the ASCII code for "Exif" (0x45786966):
28658 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28659 // No Exif data, might be XMP data instead
28662 if (tiffOffset + 8 > dataView.byteLength) {
28663 Roo.log('Invalid Exif data: Invalid segment size.');
28666 // Check for the two null bytes:
28667 if (dataView.getUint16(offset + 8) !== 0x0000) {
28668 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28671 // Check the byte alignment:
28672 switch (dataView.getUint16(tiffOffset)) {
28674 littleEndian = true;
28677 littleEndian = false;
28680 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28683 // Check for the TIFF tag marker (0x002A):
28684 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28685 Roo.log('Invalid Exif data: Missing TIFF marker.');
28688 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28689 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28691 this.parseExifTags(
28694 tiffOffset + dirOffset,
28699 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28704 if (dirOffset + 6 > dataView.byteLength) {
28705 Roo.log('Invalid Exif data: Invalid directory offset.');
28708 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28709 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28710 if (dirEndOffset + 4 > dataView.byteLength) {
28711 Roo.log('Invalid Exif data: Invalid directory size.');
28714 for (i = 0; i < tagsNumber; i += 1) {
28718 dirOffset + 2 + 12 * i, // tag offset
28722 // Return the offset to the next directory:
28723 return dataView.getUint32(dirEndOffset, littleEndian);
28726 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28728 var tag = dataView.getUint16(offset, littleEndian);
28730 this.exif[tag] = this.getExifValue(
28734 dataView.getUint16(offset + 2, littleEndian), // tag type
28735 dataView.getUint32(offset + 4, littleEndian), // tag length
28740 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28742 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28751 Roo.log('Invalid Exif data: Invalid tag type.');
28755 tagSize = tagType.size * length;
28756 // Determine if the value is contained in the dataOffset bytes,
28757 // or if the value at the dataOffset is a pointer to the actual data:
28758 dataOffset = tagSize > 4 ?
28759 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28760 if (dataOffset + tagSize > dataView.byteLength) {
28761 Roo.log('Invalid Exif data: Invalid data offset.');
28764 if (length === 1) {
28765 return tagType.getValue(dataView, dataOffset, littleEndian);
28768 for (i = 0; i < length; i += 1) {
28769 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28772 if (tagType.ascii) {
28774 // Concatenate the chars:
28775 for (i = 0; i < values.length; i += 1) {
28777 // Ignore the terminating NULL byte(s):
28778 if (c === '\u0000') {
28790 Roo.apply(Roo.bootstrap.UploadCropbox, {
28792 'Orientation': 0x0112
28796 1: 0, //'top-left',
28798 3: 180, //'bottom-right',
28799 // 4: 'bottom-left',
28801 6: 90, //'right-top',
28802 // 7: 'right-bottom',
28803 8: 270 //'left-bottom'
28807 // byte, 8-bit unsigned int:
28809 getValue: function (dataView, dataOffset) {
28810 return dataView.getUint8(dataOffset);
28814 // ascii, 8-bit byte:
28816 getValue: function (dataView, dataOffset) {
28817 return String.fromCharCode(dataView.getUint8(dataOffset));
28822 // short, 16 bit int:
28824 getValue: function (dataView, dataOffset, littleEndian) {
28825 return dataView.getUint16(dataOffset, littleEndian);
28829 // long, 32 bit int:
28831 getValue: function (dataView, dataOffset, littleEndian) {
28832 return dataView.getUint32(dataOffset, littleEndian);
28836 // rational = two long values, first is numerator, second is denominator:
28838 getValue: function (dataView, dataOffset, littleEndian) {
28839 return dataView.getUint32(dataOffset, littleEndian) /
28840 dataView.getUint32(dataOffset + 4, littleEndian);
28844 // slong, 32 bit signed int:
28846 getValue: function (dataView, dataOffset, littleEndian) {
28847 return dataView.getInt32(dataOffset, littleEndian);
28851 // srational, two slongs, first is numerator, second is denominator:
28853 getValue: function (dataView, dataOffset, littleEndian) {
28854 return dataView.getInt32(dataOffset, littleEndian) /
28855 dataView.getInt32(dataOffset + 4, littleEndian);
28865 cls : 'btn-group roo-upload-cropbox-rotate-left',
28866 action : 'rotate-left',
28870 cls : 'btn btn-default',
28871 html : '<i class="fa fa-undo"></i>'
28877 cls : 'btn-group roo-upload-cropbox-picture',
28878 action : 'picture',
28882 cls : 'btn btn-default',
28883 html : '<i class="fa fa-picture-o"></i>'
28889 cls : 'btn-group roo-upload-cropbox-rotate-right',
28890 action : 'rotate-right',
28894 cls : 'btn btn-default',
28895 html : '<i class="fa fa-repeat"></i>'
28903 cls : 'btn-group roo-upload-cropbox-rotate-left',
28904 action : 'rotate-left',
28908 cls : 'btn btn-default',
28909 html : '<i class="fa fa-undo"></i>'
28915 cls : 'btn-group roo-upload-cropbox-download',
28916 action : 'download',
28920 cls : 'btn btn-default',
28921 html : '<i class="fa fa-download"></i>'
28927 cls : 'btn-group roo-upload-cropbox-crop',
28932 cls : 'btn btn-default',
28933 html : '<i class="fa fa-crop"></i>'
28939 cls : 'btn-group roo-upload-cropbox-trash',
28944 cls : 'btn btn-default',
28945 html : '<i class="fa fa-trash"></i>'
28951 cls : 'btn-group roo-upload-cropbox-rotate-right',
28952 action : 'rotate-right',
28956 cls : 'btn btn-default',
28957 html : '<i class="fa fa-repeat"></i>'
28965 cls : 'btn-group roo-upload-cropbox-rotate-left',
28966 action : 'rotate-left',
28970 cls : 'btn btn-default',
28971 html : '<i class="fa fa-undo"></i>'
28977 cls : 'btn-group roo-upload-cropbox-rotate-right',
28978 action : 'rotate-right',
28982 cls : 'btn btn-default',
28983 html : '<i class="fa fa-repeat"></i>'
28996 * @class Roo.bootstrap.DocumentManager
28997 * @extends Roo.bootstrap.Component
28998 * Bootstrap DocumentManager class
28999 * @cfg {String} paramName default 'imageUpload'
29000 * @cfg {String} toolTipName default 'filename'
29001 * @cfg {String} method default POST
29002 * @cfg {String} url action url
29003 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29004 * @cfg {Boolean} multiple multiple upload default true
29005 * @cfg {Number} thumbSize default 300
29006 * @cfg {String} fieldLabel
29007 * @cfg {Number} labelWidth default 4
29008 * @cfg {String} labelAlign (left|top) default left
29009 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29010 * @cfg {Number} labellg set the width of label (1-12)
29011 * @cfg {Number} labelmd set the width of label (1-12)
29012 * @cfg {Number} labelsm set the width of label (1-12)
29013 * @cfg {Number} labelxs set the width of label (1-12)
29016 * Create a new DocumentManager
29017 * @param {Object} config The config object
29020 Roo.bootstrap.DocumentManager = function(config){
29021 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29024 this.delegates = [];
29029 * Fire when initial the DocumentManager
29030 * @param {Roo.bootstrap.DocumentManager} this
29035 * inspect selected file
29036 * @param {Roo.bootstrap.DocumentManager} this
29037 * @param {File} file
29042 * Fire when xhr load exception
29043 * @param {Roo.bootstrap.DocumentManager} this
29044 * @param {XMLHttpRequest} xhr
29046 "exception" : true,
29048 * @event afterupload
29049 * Fire when xhr load exception
29050 * @param {Roo.bootstrap.DocumentManager} this
29051 * @param {XMLHttpRequest} xhr
29053 "afterupload" : true,
29056 * prepare the form data
29057 * @param {Roo.bootstrap.DocumentManager} this
29058 * @param {Object} formData
29063 * Fire when remove the file
29064 * @param {Roo.bootstrap.DocumentManager} this
29065 * @param {Object} file
29070 * Fire after refresh the file
29071 * @param {Roo.bootstrap.DocumentManager} this
29076 * Fire after click the image
29077 * @param {Roo.bootstrap.DocumentManager} this
29078 * @param {Object} file
29083 * Fire when upload a image and editable set to true
29084 * @param {Roo.bootstrap.DocumentManager} this
29085 * @param {Object} file
29089 * @event beforeselectfile
29090 * Fire before select file
29091 * @param {Roo.bootstrap.DocumentManager} this
29093 "beforeselectfile" : true,
29096 * Fire before process file
29097 * @param {Roo.bootstrap.DocumentManager} this
29098 * @param {Object} file
29102 * @event previewrendered
29103 * Fire when preview rendered
29104 * @param {Roo.bootstrap.DocumentManager} this
29105 * @param {Object} file
29107 "previewrendered" : true,
29110 "previewResize" : true
29115 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29124 paramName : 'imageUpload',
29125 toolTipName : 'filename',
29128 labelAlign : 'left',
29138 getAutoCreate : function()
29140 var managerWidget = {
29142 cls : 'roo-document-manager',
29146 cls : 'roo-document-manager-selector',
29151 cls : 'roo-document-manager-uploader',
29155 cls : 'roo-document-manager-upload-btn',
29156 html : '<i class="fa fa-plus"></i>'
29167 cls : 'column col-md-12',
29172 if(this.fieldLabel.length){
29177 cls : 'column col-md-12',
29178 html : this.fieldLabel
29182 cls : 'column col-md-12',
29187 if(this.labelAlign == 'left'){
29192 html : this.fieldLabel
29201 if(this.labelWidth > 12){
29202 content[0].style = "width: " + this.labelWidth + 'px';
29205 if(this.labelWidth < 13 && this.labelmd == 0){
29206 this.labelmd = this.labelWidth;
29209 if(this.labellg > 0){
29210 content[0].cls += ' col-lg-' + this.labellg;
29211 content[1].cls += ' col-lg-' + (12 - this.labellg);
29214 if(this.labelmd > 0){
29215 content[0].cls += ' col-md-' + this.labelmd;
29216 content[1].cls += ' col-md-' + (12 - this.labelmd);
29219 if(this.labelsm > 0){
29220 content[0].cls += ' col-sm-' + this.labelsm;
29221 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29224 if(this.labelxs > 0){
29225 content[0].cls += ' col-xs-' + this.labelxs;
29226 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29234 cls : 'row clearfix',
29242 initEvents : function()
29244 this.managerEl = this.el.select('.roo-document-manager', true).first();
29245 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29247 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29248 this.selectorEl.hide();
29251 this.selectorEl.attr('multiple', 'multiple');
29254 this.selectorEl.on('change', this.onFileSelected, this);
29256 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29257 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29259 this.uploader.on('click', this.onUploaderClick, this);
29261 this.renderProgressDialog();
29265 window.addEventListener("resize", function() { _this.refresh(); } );
29267 this.fireEvent('initial', this);
29270 renderProgressDialog : function()
29274 this.progressDialog = new Roo.bootstrap.Modal({
29275 cls : 'roo-document-manager-progress-dialog',
29276 allow_close : false,
29287 btnclick : function() {
29288 _this.uploadCancel();
29294 this.progressDialog.render(Roo.get(document.body));
29296 this.progress = new Roo.bootstrap.Progress({
29297 cls : 'roo-document-manager-progress',
29302 this.progress.render(this.progressDialog.getChildContainer());
29304 this.progressBar = new Roo.bootstrap.ProgressBar({
29305 cls : 'roo-document-manager-progress-bar',
29308 aria_valuemax : 12,
29312 this.progressBar.render(this.progress.getChildContainer());
29315 onUploaderClick : function(e)
29317 e.preventDefault();
29319 if(this.fireEvent('beforeselectfile', this) != false){
29320 this.selectorEl.dom.click();
29325 onFileSelected : function(e)
29327 e.preventDefault();
29329 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29333 Roo.each(this.selectorEl.dom.files, function(file){
29334 if(this.fireEvent('inspect', this, file) != false){
29335 this.files.push(file);
29345 this.selectorEl.dom.value = '';
29347 if(!this.files || !this.files.length){
29351 if(this.boxes > 0 && this.files.length > this.boxes){
29352 this.files = this.files.slice(0, this.boxes);
29355 this.uploader.show();
29357 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29358 this.uploader.hide();
29367 Roo.each(this.files, function(file){
29369 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29370 var f = this.renderPreview(file);
29375 if(file.type.indexOf('image') != -1){
29376 this.delegates.push(
29378 _this.process(file);
29379 }).createDelegate(this)
29387 _this.process(file);
29388 }).createDelegate(this)
29393 this.files = files;
29395 this.delegates = this.delegates.concat(docs);
29397 if(!this.delegates.length){
29402 this.progressBar.aria_valuemax = this.delegates.length;
29409 arrange : function()
29411 if(!this.delegates.length){
29412 this.progressDialog.hide();
29417 var delegate = this.delegates.shift();
29419 this.progressDialog.show();
29421 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29423 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29428 refresh : function()
29430 this.uploader.show();
29432 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29433 this.uploader.hide();
29436 Roo.isTouch ? this.closable(false) : this.closable(true);
29438 this.fireEvent('refresh', this);
29441 onRemove : function(e, el, o)
29443 e.preventDefault();
29445 this.fireEvent('remove', this, o);
29449 remove : function(o)
29453 Roo.each(this.files, function(file){
29454 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29463 this.files = files;
29470 Roo.each(this.files, function(file){
29475 file.target.remove();
29484 onClick : function(e, el, o)
29486 e.preventDefault();
29488 this.fireEvent('click', this, o);
29492 closable : function(closable)
29494 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29496 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29508 xhrOnLoad : function(xhr)
29510 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29514 if (xhr.readyState !== 4) {
29516 this.fireEvent('exception', this, xhr);
29520 var response = Roo.decode(xhr.responseText);
29522 if(!response.success){
29524 this.fireEvent('exception', this, xhr);
29528 var file = this.renderPreview(response.data);
29530 this.files.push(file);
29534 this.fireEvent('afterupload', this, xhr);
29538 xhrOnError : function(xhr)
29540 Roo.log('xhr on error');
29542 var response = Roo.decode(xhr.responseText);
29549 process : function(file)
29551 if(this.fireEvent('process', this, file) !== false){
29552 if(this.editable && file.type.indexOf('image') != -1){
29553 this.fireEvent('edit', this, file);
29557 this.uploadStart(file, false);
29564 uploadStart : function(file, crop)
29566 this.xhr = new XMLHttpRequest();
29568 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29573 file.xhr = this.xhr;
29575 this.managerEl.createChild({
29577 cls : 'roo-document-manager-loading',
29581 tooltip : file.name,
29582 cls : 'roo-document-manager-thumb',
29583 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29589 this.xhr.open(this.method, this.url, true);
29592 "Accept": "application/json",
29593 "Cache-Control": "no-cache",
29594 "X-Requested-With": "XMLHttpRequest"
29597 for (var headerName in headers) {
29598 var headerValue = headers[headerName];
29600 this.xhr.setRequestHeader(headerName, headerValue);
29606 this.xhr.onload = function()
29608 _this.xhrOnLoad(_this.xhr);
29611 this.xhr.onerror = function()
29613 _this.xhrOnError(_this.xhr);
29616 var formData = new FormData();
29618 formData.append('returnHTML', 'NO');
29621 formData.append('crop', crop);
29624 formData.append(this.paramName, file, file.name);
29631 if(this.fireEvent('prepare', this, formData, options) != false){
29633 if(options.manually){
29637 this.xhr.send(formData);
29641 this.uploadCancel();
29644 uploadCancel : function()
29650 this.delegates = [];
29652 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29659 renderPreview : function(file)
29661 if(typeof(file.target) != 'undefined' && file.target){
29665 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29667 var previewEl = this.managerEl.createChild({
29669 cls : 'roo-document-manager-preview',
29673 tooltip : file[this.toolTipName],
29674 cls : 'roo-document-manager-thumb',
29675 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29680 html : '<i class="fa fa-times-circle"></i>'
29685 var close = previewEl.select('button.close', true).first();
29687 close.on('click', this.onRemove, this, file);
29689 file.target = previewEl;
29691 var image = previewEl.select('img', true).first();
29695 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29697 image.on('click', this.onClick, this, file);
29699 this.fireEvent('previewrendered', this, file);
29705 onPreviewLoad : function(file, image)
29707 if(typeof(file.target) == 'undefined' || !file.target){
29711 var width = image.dom.naturalWidth || image.dom.width;
29712 var height = image.dom.naturalHeight || image.dom.height;
29714 if(!this.previewResize) {
29718 if(width > height){
29719 file.target.addClass('wide');
29723 file.target.addClass('tall');
29728 uploadFromSource : function(file, crop)
29730 this.xhr = new XMLHttpRequest();
29732 this.managerEl.createChild({
29734 cls : 'roo-document-manager-loading',
29738 tooltip : file.name,
29739 cls : 'roo-document-manager-thumb',
29740 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29746 this.xhr.open(this.method, this.url, true);
29749 "Accept": "application/json",
29750 "Cache-Control": "no-cache",
29751 "X-Requested-With": "XMLHttpRequest"
29754 for (var headerName in headers) {
29755 var headerValue = headers[headerName];
29757 this.xhr.setRequestHeader(headerName, headerValue);
29763 this.xhr.onload = function()
29765 _this.xhrOnLoad(_this.xhr);
29768 this.xhr.onerror = function()
29770 _this.xhrOnError(_this.xhr);
29773 var formData = new FormData();
29775 formData.append('returnHTML', 'NO');
29777 formData.append('crop', crop);
29779 if(typeof(file.filename) != 'undefined'){
29780 formData.append('filename', file.filename);
29783 if(typeof(file.mimetype) != 'undefined'){
29784 formData.append('mimetype', file.mimetype);
29789 if(this.fireEvent('prepare', this, formData) != false){
29790 this.xhr.send(formData);
29800 * @class Roo.bootstrap.DocumentViewer
29801 * @extends Roo.bootstrap.Component
29802 * Bootstrap DocumentViewer class
29803 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29804 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29807 * Create a new DocumentViewer
29808 * @param {Object} config The config object
29811 Roo.bootstrap.DocumentViewer = function(config){
29812 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29817 * Fire after initEvent
29818 * @param {Roo.bootstrap.DocumentViewer} this
29824 * @param {Roo.bootstrap.DocumentViewer} this
29829 * Fire after download button
29830 * @param {Roo.bootstrap.DocumentViewer} this
29835 * Fire after trash button
29836 * @param {Roo.bootstrap.DocumentViewer} this
29843 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29845 showDownload : true,
29849 getAutoCreate : function()
29853 cls : 'roo-document-viewer',
29857 cls : 'roo-document-viewer-body',
29861 cls : 'roo-document-viewer-thumb',
29865 cls : 'roo-document-viewer-image'
29873 cls : 'roo-document-viewer-footer',
29876 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29880 cls : 'btn-group roo-document-viewer-download',
29884 cls : 'btn btn-default',
29885 html : '<i class="fa fa-download"></i>'
29891 cls : 'btn-group roo-document-viewer-trash',
29895 cls : 'btn btn-default',
29896 html : '<i class="fa fa-trash"></i>'
29909 initEvents : function()
29911 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29912 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29914 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29915 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29917 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29918 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29920 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29921 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29923 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29924 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29926 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29927 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29929 this.bodyEl.on('click', this.onClick, this);
29930 this.downloadBtn.on('click', this.onDownload, this);
29931 this.trashBtn.on('click', this.onTrash, this);
29933 this.downloadBtn.hide();
29934 this.trashBtn.hide();
29936 if(this.showDownload){
29937 this.downloadBtn.show();
29940 if(this.showTrash){
29941 this.trashBtn.show();
29944 if(!this.showDownload && !this.showTrash) {
29945 this.footerEl.hide();
29950 initial : function()
29952 this.fireEvent('initial', this);
29956 onClick : function(e)
29958 e.preventDefault();
29960 this.fireEvent('click', this);
29963 onDownload : function(e)
29965 e.preventDefault();
29967 this.fireEvent('download', this);
29970 onTrash : function(e)
29972 e.preventDefault();
29974 this.fireEvent('trash', this);
29986 * @class Roo.bootstrap.NavProgressBar
29987 * @extends Roo.bootstrap.Component
29988 * Bootstrap NavProgressBar class
29991 * Create a new nav progress bar
29992 * @param {Object} config The config object
29995 Roo.bootstrap.NavProgressBar = function(config){
29996 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29998 this.bullets = this.bullets || [];
30000 // Roo.bootstrap.NavProgressBar.register(this);
30004 * Fires when the active item changes
30005 * @param {Roo.bootstrap.NavProgressBar} this
30006 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30007 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30014 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30019 getAutoCreate : function()
30021 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30025 cls : 'roo-navigation-bar-group',
30029 cls : 'roo-navigation-top-bar'
30033 cls : 'roo-navigation-bullets-bar',
30037 cls : 'roo-navigation-bar'
30044 cls : 'roo-navigation-bottom-bar'
30054 initEvents: function()
30059 onRender : function(ct, position)
30061 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30063 if(this.bullets.length){
30064 Roo.each(this.bullets, function(b){
30073 addItem : function(cfg)
30075 var item = new Roo.bootstrap.NavProgressItem(cfg);
30077 item.parentId = this.id;
30078 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30081 var top = new Roo.bootstrap.Element({
30083 cls : 'roo-navigation-bar-text'
30086 var bottom = new Roo.bootstrap.Element({
30088 cls : 'roo-navigation-bar-text'
30091 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30092 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30094 var topText = new Roo.bootstrap.Element({
30096 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30099 var bottomText = new Roo.bootstrap.Element({
30101 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30104 topText.onRender(top.el, null);
30105 bottomText.onRender(bottom.el, null);
30108 item.bottomEl = bottom;
30111 this.barItems.push(item);
30116 getActive : function()
30118 var active = false;
30120 Roo.each(this.barItems, function(v){
30122 if (!v.isActive()) {
30134 setActiveItem : function(item)
30138 Roo.each(this.barItems, function(v){
30139 if (v.rid == item.rid) {
30143 if (v.isActive()) {
30144 v.setActive(false);
30149 item.setActive(true);
30151 this.fireEvent('changed', this, item, prev);
30154 getBarItem: function(rid)
30158 Roo.each(this.barItems, function(e) {
30159 if (e.rid != rid) {
30170 indexOfItem : function(item)
30174 Roo.each(this.barItems, function(v, i){
30176 if (v.rid != item.rid) {
30187 setActiveNext : function()
30189 var i = this.indexOfItem(this.getActive());
30191 if (i > this.barItems.length) {
30195 this.setActiveItem(this.barItems[i+1]);
30198 setActivePrev : function()
30200 var i = this.indexOfItem(this.getActive());
30206 this.setActiveItem(this.barItems[i-1]);
30209 format : function()
30211 if(!this.barItems.length){
30215 var width = 100 / this.barItems.length;
30217 Roo.each(this.barItems, function(i){
30218 i.el.setStyle('width', width + '%');
30219 i.topEl.el.setStyle('width', width + '%');
30220 i.bottomEl.el.setStyle('width', width + '%');
30229 * Nav Progress Item
30234 * @class Roo.bootstrap.NavProgressItem
30235 * @extends Roo.bootstrap.Component
30236 * Bootstrap NavProgressItem class
30237 * @cfg {String} rid the reference id
30238 * @cfg {Boolean} active (true|false) Is item active default false
30239 * @cfg {Boolean} disabled (true|false) Is item active default false
30240 * @cfg {String} html
30241 * @cfg {String} position (top|bottom) text position default bottom
30242 * @cfg {String} icon show icon instead of number
30245 * Create a new NavProgressItem
30246 * @param {Object} config The config object
30248 Roo.bootstrap.NavProgressItem = function(config){
30249 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30254 * The raw click event for the entire grid.
30255 * @param {Roo.bootstrap.NavProgressItem} this
30256 * @param {Roo.EventObject} e
30263 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30269 position : 'bottom',
30272 getAutoCreate : function()
30274 var iconCls = 'roo-navigation-bar-item-icon';
30276 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30280 cls: 'roo-navigation-bar-item',
30290 cfg.cls += ' active';
30293 cfg.cls += ' disabled';
30299 disable : function()
30301 this.setDisabled(true);
30304 enable : function()
30306 this.setDisabled(false);
30309 initEvents: function()
30311 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30313 this.iconEl.on('click', this.onClick, this);
30316 onClick : function(e)
30318 e.preventDefault();
30324 if(this.fireEvent('click', this, e) === false){
30328 this.parent().setActiveItem(this);
30331 isActive: function ()
30333 return this.active;
30336 setActive : function(state)
30338 if(this.active == state){
30342 this.active = state;
30345 this.el.addClass('active');
30349 this.el.removeClass('active');
30354 setDisabled : function(state)
30356 if(this.disabled == state){
30360 this.disabled = state;
30363 this.el.addClass('disabled');
30367 this.el.removeClass('disabled');
30370 tooltipEl : function()
30372 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30385 * @class Roo.bootstrap.FieldLabel
30386 * @extends Roo.bootstrap.Component
30387 * Bootstrap FieldLabel class
30388 * @cfg {String} html contents of the element
30389 * @cfg {String} tag tag of the element default label
30390 * @cfg {String} cls class of the element
30391 * @cfg {String} target label target
30392 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30393 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30394 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30395 * @cfg {String} iconTooltip default "This field is required"
30396 * @cfg {String} indicatorpos (left|right) default left
30399 * Create a new FieldLabel
30400 * @param {Object} config The config object
30403 Roo.bootstrap.FieldLabel = function(config){
30404 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30409 * Fires after the field has been marked as invalid.
30410 * @param {Roo.form.FieldLabel} this
30411 * @param {String} msg The validation message
30416 * Fires after the field has been validated with no errors.
30417 * @param {Roo.form.FieldLabel} this
30423 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30430 invalidClass : 'has-warning',
30431 validClass : 'has-success',
30432 iconTooltip : 'This field is required',
30433 indicatorpos : 'left',
30435 getAutoCreate : function(){
30438 if (!this.allowBlank) {
30444 cls : 'roo-bootstrap-field-label ' + this.cls,
30449 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30450 tooltip : this.iconTooltip
30459 if(this.indicatorpos == 'right'){
30462 cls : 'roo-bootstrap-field-label ' + this.cls,
30471 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30472 tooltip : this.iconTooltip
30481 initEvents: function()
30483 Roo.bootstrap.Element.superclass.initEvents.call(this);
30485 this.indicator = this.indicatorEl();
30487 if(this.indicator){
30488 this.indicator.removeClass('visible');
30489 this.indicator.addClass('invisible');
30492 Roo.bootstrap.FieldLabel.register(this);
30495 indicatorEl : function()
30497 var indicator = this.el.select('i.roo-required-indicator',true).first();
30508 * Mark this field as valid
30510 markValid : function()
30512 if(this.indicator){
30513 this.indicator.removeClass('visible');
30514 this.indicator.addClass('invisible');
30516 if (Roo.bootstrap.version == 3) {
30517 this.el.removeClass(this.invalidClass);
30518 this.el.addClass(this.validClass);
30520 this.el.removeClass('is-invalid');
30521 this.el.addClass('is-valid');
30525 this.fireEvent('valid', this);
30529 * Mark this field as invalid
30530 * @param {String} msg The validation message
30532 markInvalid : function(msg)
30534 if(this.indicator){
30535 this.indicator.removeClass('invisible');
30536 this.indicator.addClass('visible');
30538 if (Roo.bootstrap.version == 3) {
30539 this.el.removeClass(this.validClass);
30540 this.el.addClass(this.invalidClass);
30542 this.el.removeClass('is-valid');
30543 this.el.addClass('is-invalid');
30547 this.fireEvent('invalid', this, msg);
30553 Roo.apply(Roo.bootstrap.FieldLabel, {
30558 * register a FieldLabel Group
30559 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30561 register : function(label)
30563 if(this.groups.hasOwnProperty(label.target)){
30567 this.groups[label.target] = label;
30571 * fetch a FieldLabel Group based on the target
30572 * @param {string} target
30573 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30575 get: function(target) {
30576 if (typeof(this.groups[target]) == 'undefined') {
30580 return this.groups[target] ;
30589 * page DateSplitField.
30595 * @class Roo.bootstrap.DateSplitField
30596 * @extends Roo.bootstrap.Component
30597 * Bootstrap DateSplitField class
30598 * @cfg {string} fieldLabel - the label associated
30599 * @cfg {Number} labelWidth set the width of label (0-12)
30600 * @cfg {String} labelAlign (top|left)
30601 * @cfg {Boolean} dayAllowBlank (true|false) default false
30602 * @cfg {Boolean} monthAllowBlank (true|false) default false
30603 * @cfg {Boolean} yearAllowBlank (true|false) default false
30604 * @cfg {string} dayPlaceholder
30605 * @cfg {string} monthPlaceholder
30606 * @cfg {string} yearPlaceholder
30607 * @cfg {string} dayFormat default 'd'
30608 * @cfg {string} monthFormat default 'm'
30609 * @cfg {string} yearFormat default 'Y'
30610 * @cfg {Number} labellg set the width of label (1-12)
30611 * @cfg {Number} labelmd set the width of label (1-12)
30612 * @cfg {Number} labelsm set the width of label (1-12)
30613 * @cfg {Number} labelxs set the width of label (1-12)
30617 * Create a new DateSplitField
30618 * @param {Object} config The config object
30621 Roo.bootstrap.DateSplitField = function(config){
30622 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30628 * getting the data of years
30629 * @param {Roo.bootstrap.DateSplitField} this
30630 * @param {Object} years
30635 * getting the data of days
30636 * @param {Roo.bootstrap.DateSplitField} this
30637 * @param {Object} days
30642 * Fires after the field has been marked as invalid.
30643 * @param {Roo.form.Field} this
30644 * @param {String} msg The validation message
30649 * Fires after the field has been validated with no errors.
30650 * @param {Roo.form.Field} this
30656 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30659 labelAlign : 'top',
30661 dayAllowBlank : false,
30662 monthAllowBlank : false,
30663 yearAllowBlank : false,
30664 dayPlaceholder : '',
30665 monthPlaceholder : '',
30666 yearPlaceholder : '',
30670 isFormField : true,
30676 getAutoCreate : function()
30680 cls : 'row roo-date-split-field-group',
30685 cls : 'form-hidden-field roo-date-split-field-group-value',
30691 var labelCls = 'col-md-12';
30692 var contentCls = 'col-md-4';
30694 if(this.fieldLabel){
30698 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30702 html : this.fieldLabel
30707 if(this.labelAlign == 'left'){
30709 if(this.labelWidth > 12){
30710 label.style = "width: " + this.labelWidth + 'px';
30713 if(this.labelWidth < 13 && this.labelmd == 0){
30714 this.labelmd = this.labelWidth;
30717 if(this.labellg > 0){
30718 labelCls = ' col-lg-' + this.labellg;
30719 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30722 if(this.labelmd > 0){
30723 labelCls = ' col-md-' + this.labelmd;
30724 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30727 if(this.labelsm > 0){
30728 labelCls = ' col-sm-' + this.labelsm;
30729 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30732 if(this.labelxs > 0){
30733 labelCls = ' col-xs-' + this.labelxs;
30734 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30738 label.cls += ' ' + labelCls;
30740 cfg.cn.push(label);
30743 Roo.each(['day', 'month', 'year'], function(t){
30746 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30753 inputEl: function ()
30755 return this.el.select('.roo-date-split-field-group-value', true).first();
30758 onRender : function(ct, position)
30762 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30764 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30766 this.dayField = new Roo.bootstrap.ComboBox({
30767 allowBlank : this.dayAllowBlank,
30768 alwaysQuery : true,
30769 displayField : 'value',
30772 forceSelection : true,
30774 placeholder : this.dayPlaceholder,
30775 selectOnFocus : true,
30776 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30777 triggerAction : 'all',
30779 valueField : 'value',
30780 store : new Roo.data.SimpleStore({
30781 data : (function() {
30783 _this.fireEvent('days', _this, days);
30786 fields : [ 'value' ]
30789 select : function (_self, record, index)
30791 _this.setValue(_this.getValue());
30796 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30798 this.monthField = new Roo.bootstrap.MonthField({
30799 after : '<i class=\"fa fa-calendar\"></i>',
30800 allowBlank : this.monthAllowBlank,
30801 placeholder : this.monthPlaceholder,
30804 render : function (_self)
30806 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30807 e.preventDefault();
30811 select : function (_self, oldvalue, newvalue)
30813 _this.setValue(_this.getValue());
30818 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30820 this.yearField = new Roo.bootstrap.ComboBox({
30821 allowBlank : this.yearAllowBlank,
30822 alwaysQuery : true,
30823 displayField : 'value',
30826 forceSelection : true,
30828 placeholder : this.yearPlaceholder,
30829 selectOnFocus : true,
30830 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30831 triggerAction : 'all',
30833 valueField : 'value',
30834 store : new Roo.data.SimpleStore({
30835 data : (function() {
30837 _this.fireEvent('years', _this, years);
30840 fields : [ 'value' ]
30843 select : function (_self, record, index)
30845 _this.setValue(_this.getValue());
30850 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30853 setValue : function(v, format)
30855 this.inputEl.dom.value = v;
30857 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30859 var d = Date.parseDate(v, f);
30866 this.setDay(d.format(this.dayFormat));
30867 this.setMonth(d.format(this.monthFormat));
30868 this.setYear(d.format(this.yearFormat));
30875 setDay : function(v)
30877 this.dayField.setValue(v);
30878 this.inputEl.dom.value = this.getValue();
30883 setMonth : function(v)
30885 this.monthField.setValue(v, true);
30886 this.inputEl.dom.value = this.getValue();
30891 setYear : function(v)
30893 this.yearField.setValue(v);
30894 this.inputEl.dom.value = this.getValue();
30899 getDay : function()
30901 return this.dayField.getValue();
30904 getMonth : function()
30906 return this.monthField.getValue();
30909 getYear : function()
30911 return this.yearField.getValue();
30914 getValue : function()
30916 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30918 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30928 this.inputEl.dom.value = '';
30933 validate : function()
30935 var d = this.dayField.validate();
30936 var m = this.monthField.validate();
30937 var y = this.yearField.validate();
30942 (!this.dayAllowBlank && !d) ||
30943 (!this.monthAllowBlank && !m) ||
30944 (!this.yearAllowBlank && !y)
30949 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30958 this.markInvalid();
30963 markValid : function()
30966 var label = this.el.select('label', true).first();
30967 var icon = this.el.select('i.fa-star', true).first();
30973 this.fireEvent('valid', this);
30977 * Mark this field as invalid
30978 * @param {String} msg The validation message
30980 markInvalid : function(msg)
30983 var label = this.el.select('label', true).first();
30984 var icon = this.el.select('i.fa-star', true).first();
30986 if(label && !icon){
30987 this.el.select('.roo-date-split-field-label', true).createChild({
30989 cls : 'text-danger fa fa-lg fa-star',
30990 tooltip : 'This field is required',
30991 style : 'margin-right:5px;'
30995 this.fireEvent('invalid', this, msg);
30998 clearInvalid : function()
31000 var label = this.el.select('label', true).first();
31001 var icon = this.el.select('i.fa-star', true).first();
31007 this.fireEvent('valid', this);
31010 getName: function()
31020 * http://masonry.desandro.com
31022 * The idea is to render all the bricks based on vertical width...
31024 * The original code extends 'outlayer' - we might need to use that....
31030 * @class Roo.bootstrap.LayoutMasonry
31031 * @extends Roo.bootstrap.Component
31032 * Bootstrap Layout Masonry class
31035 * Create a new Element
31036 * @param {Object} config The config object
31039 Roo.bootstrap.LayoutMasonry = function(config){
31041 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31045 Roo.bootstrap.LayoutMasonry.register(this);
31051 * Fire after layout the items
31052 * @param {Roo.bootstrap.LayoutMasonry} this
31053 * @param {Roo.EventObject} e
31060 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31063 * @cfg {Boolean} isLayoutInstant = no animation?
31065 isLayoutInstant : false, // needed?
31068 * @cfg {Number} boxWidth width of the columns
31073 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31078 * @cfg {Number} padWidth padding below box..
31083 * @cfg {Number} gutter gutter width..
31088 * @cfg {Number} maxCols maximum number of columns
31094 * @cfg {Boolean} isAutoInitial defalut true
31096 isAutoInitial : true,
31101 * @cfg {Boolean} isHorizontal defalut false
31103 isHorizontal : false,
31105 currentSize : null,
31111 bricks: null, //CompositeElement
31115 _isLayoutInited : false,
31117 // isAlternative : false, // only use for vertical layout...
31120 * @cfg {Number} alternativePadWidth padding below box..
31122 alternativePadWidth : 50,
31124 selectedBrick : [],
31126 getAutoCreate : function(){
31128 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31132 cls: 'blog-masonary-wrapper ' + this.cls,
31134 cls : 'mas-boxes masonary'
31141 getChildContainer: function( )
31143 if (this.boxesEl) {
31144 return this.boxesEl;
31147 this.boxesEl = this.el.select('.mas-boxes').first();
31149 return this.boxesEl;
31153 initEvents : function()
31157 if(this.isAutoInitial){
31158 Roo.log('hook children rendered');
31159 this.on('childrenrendered', function() {
31160 Roo.log('children rendered');
31166 initial : function()
31168 this.selectedBrick = [];
31170 this.currentSize = this.el.getBox(true);
31172 Roo.EventManager.onWindowResize(this.resize, this);
31174 if(!this.isAutoInitial){
31182 //this.layout.defer(500,this);
31186 resize : function()
31188 var cs = this.el.getBox(true);
31191 this.currentSize.width == cs.width &&
31192 this.currentSize.x == cs.x &&
31193 this.currentSize.height == cs.height &&
31194 this.currentSize.y == cs.y
31196 Roo.log("no change in with or X or Y");
31200 this.currentSize = cs;
31206 layout : function()
31208 this._resetLayout();
31210 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31212 this.layoutItems( isInstant );
31214 this._isLayoutInited = true;
31216 this.fireEvent('layout', this);
31220 _resetLayout : function()
31222 if(this.isHorizontal){
31223 this.horizontalMeasureColumns();
31227 this.verticalMeasureColumns();
31231 verticalMeasureColumns : function()
31233 this.getContainerWidth();
31235 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31236 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31240 var boxWidth = this.boxWidth + this.padWidth;
31242 if(this.containerWidth < this.boxWidth){
31243 boxWidth = this.containerWidth
31246 var containerWidth = this.containerWidth;
31248 var cols = Math.floor(containerWidth / boxWidth);
31250 this.cols = Math.max( cols, 1 );
31252 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31254 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31256 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31258 this.colWidth = boxWidth + avail - this.padWidth;
31260 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31261 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31264 horizontalMeasureColumns : function()
31266 this.getContainerWidth();
31268 var boxWidth = this.boxWidth;
31270 if(this.containerWidth < boxWidth){
31271 boxWidth = this.containerWidth;
31274 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31276 this.el.setHeight(boxWidth);
31280 getContainerWidth : function()
31282 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31285 layoutItems : function( isInstant )
31287 Roo.log(this.bricks);
31289 var items = Roo.apply([], this.bricks);
31291 if(this.isHorizontal){
31292 this._horizontalLayoutItems( items , isInstant );
31296 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31297 // this._verticalAlternativeLayoutItems( items , isInstant );
31301 this._verticalLayoutItems( items , isInstant );
31305 _verticalLayoutItems : function ( items , isInstant)
31307 if ( !items || !items.length ) {
31312 ['xs', 'xs', 'xs', 'tall'],
31313 ['xs', 'xs', 'tall'],
31314 ['xs', 'xs', 'sm'],
31315 ['xs', 'xs', 'xs'],
31321 ['sm', 'xs', 'xs'],
31325 ['tall', 'xs', 'xs', 'xs'],
31326 ['tall', 'xs', 'xs'],
31338 Roo.each(items, function(item, k){
31340 switch (item.size) {
31341 // these layouts take up a full box,
31352 boxes.push([item]);
31375 var filterPattern = function(box, length)
31383 var pattern = box.slice(0, length);
31387 Roo.each(pattern, function(i){
31388 format.push(i.size);
31391 Roo.each(standard, function(s){
31393 if(String(s) != String(format)){
31402 if(!match && length == 1){
31407 filterPattern(box, length - 1);
31411 queue.push(pattern);
31413 box = box.slice(length, box.length);
31415 filterPattern(box, 4);
31421 Roo.each(boxes, function(box, k){
31427 if(box.length == 1){
31432 filterPattern(box, 4);
31436 this._processVerticalLayoutQueue( queue, isInstant );
31440 // _verticalAlternativeLayoutItems : function( items , isInstant )
31442 // if ( !items || !items.length ) {
31446 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31450 _horizontalLayoutItems : function ( items , isInstant)
31452 if ( !items || !items.length || items.length < 3) {
31458 var eItems = items.slice(0, 3);
31460 items = items.slice(3, items.length);
31463 ['xs', 'xs', 'xs', 'wide'],
31464 ['xs', 'xs', 'wide'],
31465 ['xs', 'xs', 'sm'],
31466 ['xs', 'xs', 'xs'],
31472 ['sm', 'xs', 'xs'],
31476 ['wide', 'xs', 'xs', 'xs'],
31477 ['wide', 'xs', 'xs'],
31490 Roo.each(items, function(item, k){
31492 switch (item.size) {
31503 boxes.push([item]);
31527 var filterPattern = function(box, length)
31535 var pattern = box.slice(0, length);
31539 Roo.each(pattern, function(i){
31540 format.push(i.size);
31543 Roo.each(standard, function(s){
31545 if(String(s) != String(format)){
31554 if(!match && length == 1){
31559 filterPattern(box, length - 1);
31563 queue.push(pattern);
31565 box = box.slice(length, box.length);
31567 filterPattern(box, 4);
31573 Roo.each(boxes, function(box, k){
31579 if(box.length == 1){
31584 filterPattern(box, 4);
31591 var pos = this.el.getBox(true);
31595 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31597 var hit_end = false;
31599 Roo.each(queue, function(box){
31603 Roo.each(box, function(b){
31605 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31615 Roo.each(box, function(b){
31617 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31620 mx = Math.max(mx, b.x);
31624 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31628 Roo.each(box, function(b){
31630 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31644 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31647 /** Sets position of item in DOM
31648 * @param {Element} item
31649 * @param {Number} x - horizontal position
31650 * @param {Number} y - vertical position
31651 * @param {Boolean} isInstant - disables transitions
31653 _processVerticalLayoutQueue : function( queue, isInstant )
31655 var pos = this.el.getBox(true);
31660 for (var i = 0; i < this.cols; i++){
31664 Roo.each(queue, function(box, k){
31666 var col = k % this.cols;
31668 Roo.each(box, function(b,kk){
31670 b.el.position('absolute');
31672 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31673 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31675 if(b.size == 'md-left' || b.size == 'md-right'){
31676 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31677 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31680 b.el.setWidth(width);
31681 b.el.setHeight(height);
31683 b.el.select('iframe',true).setSize(width,height);
31687 for (var i = 0; i < this.cols; i++){
31689 if(maxY[i] < maxY[col]){
31694 col = Math.min(col, i);
31698 x = pos.x + col * (this.colWidth + this.padWidth);
31702 var positions = [];
31704 switch (box.length){
31706 positions = this.getVerticalOneBoxColPositions(x, y, box);
31709 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31712 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31715 positions = this.getVerticalFourBoxColPositions(x, y, box);
31721 Roo.each(box, function(b,kk){
31723 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31725 var sz = b.el.getSize();
31727 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31735 for (var i = 0; i < this.cols; i++){
31736 mY = Math.max(mY, maxY[i]);
31739 this.el.setHeight(mY - pos.y);
31743 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31745 // var pos = this.el.getBox(true);
31748 // var maxX = pos.right;
31750 // var maxHeight = 0;
31752 // Roo.each(items, function(item, k){
31756 // item.el.position('absolute');
31758 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31760 // item.el.setWidth(width);
31762 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31764 // item.el.setHeight(height);
31767 // item.el.setXY([x, y], isInstant ? false : true);
31769 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31772 // y = y + height + this.alternativePadWidth;
31774 // maxHeight = maxHeight + height + this.alternativePadWidth;
31778 // this.el.setHeight(maxHeight);
31782 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31784 var pos = this.el.getBox(true);
31789 var maxX = pos.right;
31791 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31793 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31795 Roo.each(queue, function(box, k){
31797 Roo.each(box, function(b, kk){
31799 b.el.position('absolute');
31801 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31802 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31804 if(b.size == 'md-left' || b.size == 'md-right'){
31805 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31806 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31809 b.el.setWidth(width);
31810 b.el.setHeight(height);
31818 var positions = [];
31820 switch (box.length){
31822 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31825 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31828 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31831 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31837 Roo.each(box, function(b,kk){
31839 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31841 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31849 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31851 Roo.each(eItems, function(b,k){
31853 b.size = (k == 0) ? 'sm' : 'xs';
31854 b.x = (k == 0) ? 2 : 1;
31855 b.y = (k == 0) ? 2 : 1;
31857 b.el.position('absolute');
31859 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31861 b.el.setWidth(width);
31863 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31865 b.el.setHeight(height);
31869 var positions = [];
31872 x : maxX - this.unitWidth * 2 - this.gutter,
31877 x : maxX - this.unitWidth,
31878 y : minY + (this.unitWidth + this.gutter) * 2
31882 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31886 Roo.each(eItems, function(b,k){
31888 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31894 getVerticalOneBoxColPositions : function(x, y, box)
31898 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31900 if(box[0].size == 'md-left'){
31904 if(box[0].size == 'md-right'){
31909 x : x + (this.unitWidth + this.gutter) * rand,
31916 getVerticalTwoBoxColPositions : function(x, y, box)
31920 if(box[0].size == 'xs'){
31924 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31928 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31942 x : x + (this.unitWidth + this.gutter) * 2,
31943 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31950 getVerticalThreeBoxColPositions : function(x, y, box)
31954 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31962 x : x + (this.unitWidth + this.gutter) * 1,
31967 x : x + (this.unitWidth + this.gutter) * 2,
31975 if(box[0].size == 'xs' && box[1].size == 'xs'){
31984 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31988 x : x + (this.unitWidth + this.gutter) * 1,
32002 x : x + (this.unitWidth + this.gutter) * 2,
32007 x : x + (this.unitWidth + this.gutter) * 2,
32008 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32015 getVerticalFourBoxColPositions : function(x, y, box)
32019 if(box[0].size == 'xs'){
32028 y : y + (this.unitHeight + this.gutter) * 1
32033 y : y + (this.unitHeight + this.gutter) * 2
32037 x : x + (this.unitWidth + this.gutter) * 1,
32051 x : x + (this.unitWidth + this.gutter) * 2,
32056 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32057 y : y + (this.unitHeight + this.gutter) * 1
32061 x : x + (this.unitWidth + this.gutter) * 2,
32062 y : y + (this.unitWidth + this.gutter) * 2
32069 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32073 if(box[0].size == 'md-left'){
32075 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32082 if(box[0].size == 'md-right'){
32084 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32085 y : minY + (this.unitWidth + this.gutter) * 1
32091 var rand = Math.floor(Math.random() * (4 - box[0].y));
32094 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32095 y : minY + (this.unitWidth + this.gutter) * rand
32102 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32106 if(box[0].size == 'xs'){
32109 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32114 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32115 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32123 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32128 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32129 y : minY + (this.unitWidth + this.gutter) * 2
32136 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32140 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32143 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32148 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32149 y : minY + (this.unitWidth + this.gutter) * 1
32153 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32154 y : minY + (this.unitWidth + this.gutter) * 2
32161 if(box[0].size == 'xs' && box[1].size == 'xs'){
32164 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32169 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32174 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32175 y : minY + (this.unitWidth + this.gutter) * 1
32183 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32188 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32189 y : minY + (this.unitWidth + this.gutter) * 2
32193 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32194 y : minY + (this.unitWidth + this.gutter) * 2
32201 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32205 if(box[0].size == 'xs'){
32208 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32213 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32218 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),
32223 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32224 y : minY + (this.unitWidth + this.gutter) * 1
32232 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32237 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32238 y : minY + (this.unitWidth + this.gutter) * 2
32242 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32243 y : minY + (this.unitWidth + this.gutter) * 2
32247 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),
32248 y : minY + (this.unitWidth + this.gutter) * 2
32256 * remove a Masonry Brick
32257 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32259 removeBrick : function(brick_id)
32265 for (var i = 0; i<this.bricks.length; i++) {
32266 if (this.bricks[i].id == brick_id) {
32267 this.bricks.splice(i,1);
32268 this.el.dom.removeChild(Roo.get(brick_id).dom);
32275 * adds a Masonry Brick
32276 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32278 addBrick : function(cfg)
32280 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32281 //this.register(cn);
32282 cn.parentId = this.id;
32283 cn.render(this.el);
32288 * register a Masonry Brick
32289 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32292 register : function(brick)
32294 this.bricks.push(brick);
32295 brick.masonryId = this.id;
32299 * clear all the Masonry Brick
32301 clearAll : function()
32304 //this.getChildContainer().dom.innerHTML = "";
32305 this.el.dom.innerHTML = '';
32308 getSelected : function()
32310 if (!this.selectedBrick) {
32314 return this.selectedBrick;
32318 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32322 * register a Masonry Layout
32323 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32326 register : function(layout)
32328 this.groups[layout.id] = layout;
32331 * fetch a Masonry Layout based on the masonry layout ID
32332 * @param {string} the masonry layout to add
32333 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32336 get: function(layout_id) {
32337 if (typeof(this.groups[layout_id]) == 'undefined') {
32340 return this.groups[layout_id] ;
32352 * http://masonry.desandro.com
32354 * The idea is to render all the bricks based on vertical width...
32356 * The original code extends 'outlayer' - we might need to use that....
32362 * @class Roo.bootstrap.LayoutMasonryAuto
32363 * @extends Roo.bootstrap.Component
32364 * Bootstrap Layout Masonry class
32367 * Create a new Element
32368 * @param {Object} config The config object
32371 Roo.bootstrap.LayoutMasonryAuto = function(config){
32372 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32375 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32378 * @cfg {Boolean} isFitWidth - resize the width..
32380 isFitWidth : false, // options..
32382 * @cfg {Boolean} isOriginLeft = left align?
32384 isOriginLeft : true,
32386 * @cfg {Boolean} isOriginTop = top align?
32388 isOriginTop : false,
32390 * @cfg {Boolean} isLayoutInstant = no animation?
32392 isLayoutInstant : false, // needed?
32394 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32396 isResizingContainer : true,
32398 * @cfg {Number} columnWidth width of the columns
32404 * @cfg {Number} maxCols maximum number of columns
32409 * @cfg {Number} padHeight padding below box..
32415 * @cfg {Boolean} isAutoInitial defalut true
32418 isAutoInitial : true,
32424 initialColumnWidth : 0,
32425 currentSize : null,
32427 colYs : null, // array.
32434 bricks: null, //CompositeElement
32435 cols : 0, // array?
32436 // element : null, // wrapped now this.el
32437 _isLayoutInited : null,
32440 getAutoCreate : function(){
32444 cls: 'blog-masonary-wrapper ' + this.cls,
32446 cls : 'mas-boxes masonary'
32453 getChildContainer: function( )
32455 if (this.boxesEl) {
32456 return this.boxesEl;
32459 this.boxesEl = this.el.select('.mas-boxes').first();
32461 return this.boxesEl;
32465 initEvents : function()
32469 if(this.isAutoInitial){
32470 Roo.log('hook children rendered');
32471 this.on('childrenrendered', function() {
32472 Roo.log('children rendered');
32479 initial : function()
32481 this.reloadItems();
32483 this.currentSize = this.el.getBox(true);
32485 /// was window resize... - let's see if this works..
32486 Roo.EventManager.onWindowResize(this.resize, this);
32488 if(!this.isAutoInitial){
32493 this.layout.defer(500,this);
32496 reloadItems: function()
32498 this.bricks = this.el.select('.masonry-brick', true);
32500 this.bricks.each(function(b) {
32501 //Roo.log(b.getSize());
32502 if (!b.attr('originalwidth')) {
32503 b.attr('originalwidth', b.getSize().width);
32508 Roo.log(this.bricks.elements.length);
32511 resize : function()
32514 var cs = this.el.getBox(true);
32516 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32517 Roo.log("no change in with or X");
32520 this.currentSize = cs;
32524 layout : function()
32527 this._resetLayout();
32528 //this._manageStamps();
32530 // don't animate first layout
32531 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32532 this.layoutItems( isInstant );
32534 // flag for initalized
32535 this._isLayoutInited = true;
32538 layoutItems : function( isInstant )
32540 //var items = this._getItemsForLayout( this.items );
32541 // original code supports filtering layout items.. we just ignore it..
32543 this._layoutItems( this.bricks , isInstant );
32545 this._postLayout();
32547 _layoutItems : function ( items , isInstant)
32549 //this.fireEvent( 'layout', this, items );
32552 if ( !items || !items.elements.length ) {
32553 // no items, emit event with empty array
32558 items.each(function(item) {
32559 Roo.log("layout item");
32561 // get x/y object from method
32562 var position = this._getItemLayoutPosition( item );
32564 position.item = item;
32565 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32566 queue.push( position );
32569 this._processLayoutQueue( queue );
32571 /** Sets position of item in DOM
32572 * @param {Element} item
32573 * @param {Number} x - horizontal position
32574 * @param {Number} y - vertical position
32575 * @param {Boolean} isInstant - disables transitions
32577 _processLayoutQueue : function( queue )
32579 for ( var i=0, len = queue.length; i < len; i++ ) {
32580 var obj = queue[i];
32581 obj.item.position('absolute');
32582 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32588 * Any logic you want to do after each layout,
32589 * i.e. size the container
32591 _postLayout : function()
32593 this.resizeContainer();
32596 resizeContainer : function()
32598 if ( !this.isResizingContainer ) {
32601 var size = this._getContainerSize();
32603 this.el.setSize(size.width,size.height);
32604 this.boxesEl.setSize(size.width,size.height);
32610 _resetLayout : function()
32612 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32613 this.colWidth = this.el.getWidth();
32614 //this.gutter = this.el.getWidth();
32616 this.measureColumns();
32622 this.colYs.push( 0 );
32628 measureColumns : function()
32630 this.getContainerWidth();
32631 // if columnWidth is 0, default to outerWidth of first item
32632 if ( !this.columnWidth ) {
32633 var firstItem = this.bricks.first();
32634 Roo.log(firstItem);
32635 this.columnWidth = this.containerWidth;
32636 if (firstItem && firstItem.attr('originalwidth') ) {
32637 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32639 // columnWidth fall back to item of first element
32640 Roo.log("set column width?");
32641 this.initialColumnWidth = this.columnWidth ;
32643 // if first elem has no width, default to size of container
32648 if (this.initialColumnWidth) {
32649 this.columnWidth = this.initialColumnWidth;
32654 // column width is fixed at the top - however if container width get's smaller we should
32657 // this bit calcs how man columns..
32659 var columnWidth = this.columnWidth += this.gutter;
32661 // calculate columns
32662 var containerWidth = this.containerWidth + this.gutter;
32664 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32665 // fix rounding errors, typically with gutters
32666 var excess = columnWidth - containerWidth % columnWidth;
32669 // if overshoot is less than a pixel, round up, otherwise floor it
32670 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32671 cols = Math[ mathMethod ]( cols );
32672 this.cols = Math.max( cols, 1 );
32673 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32675 // padding positioning..
32676 var totalColWidth = this.cols * this.columnWidth;
32677 var padavail = this.containerWidth - totalColWidth;
32678 // so for 2 columns - we need 3 'pads'
32680 var padNeeded = (1+this.cols) * this.padWidth;
32682 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32684 this.columnWidth += padExtra
32685 //this.padWidth = Math.floor(padavail / ( this.cols));
32687 // adjust colum width so that padding is fixed??
32689 // we have 3 columns ... total = width * 3
32690 // we have X left over... that should be used by
32692 //if (this.expandC) {
32700 getContainerWidth : function()
32702 /* // container is parent if fit width
32703 var container = this.isFitWidth ? this.element.parentNode : this.element;
32704 // check that this.size and size are there
32705 // IE8 triggers resize on body size change, so they might not be
32707 var size = getSize( container ); //FIXME
32708 this.containerWidth = size && size.innerWidth; //FIXME
32711 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32715 _getItemLayoutPosition : function( item ) // what is item?
32717 // we resize the item to our columnWidth..
32719 item.setWidth(this.columnWidth);
32720 item.autoBoxAdjust = false;
32722 var sz = item.getSize();
32724 // how many columns does this brick span
32725 var remainder = this.containerWidth % this.columnWidth;
32727 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32728 // round if off by 1 pixel, otherwise use ceil
32729 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32730 colSpan = Math.min( colSpan, this.cols );
32732 // normally this should be '1' as we dont' currently allow multi width columns..
32734 var colGroup = this._getColGroup( colSpan );
32735 // get the minimum Y value from the columns
32736 var minimumY = Math.min.apply( Math, colGroup );
32737 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32739 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32741 // position the brick
32743 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32744 y: this.currentSize.y + minimumY + this.padHeight
32748 // apply setHeight to necessary columns
32749 var setHeight = minimumY + sz.height + this.padHeight;
32750 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32752 var setSpan = this.cols + 1 - colGroup.length;
32753 for ( var i = 0; i < setSpan; i++ ) {
32754 this.colYs[ shortColIndex + i ] = setHeight ;
32761 * @param {Number} colSpan - number of columns the element spans
32762 * @returns {Array} colGroup
32764 _getColGroup : function( colSpan )
32766 if ( colSpan < 2 ) {
32767 // if brick spans only one column, use all the column Ys
32772 // how many different places could this brick fit horizontally
32773 var groupCount = this.cols + 1 - colSpan;
32774 // for each group potential horizontal position
32775 for ( var i = 0; i < groupCount; i++ ) {
32776 // make an array of colY values for that one group
32777 var groupColYs = this.colYs.slice( i, i + colSpan );
32778 // and get the max value of the array
32779 colGroup[i] = Math.max.apply( Math, groupColYs );
32784 _manageStamp : function( stamp )
32786 var stampSize = stamp.getSize();
32787 var offset = stamp.getBox();
32788 // get the columns that this stamp affects
32789 var firstX = this.isOriginLeft ? offset.x : offset.right;
32790 var lastX = firstX + stampSize.width;
32791 var firstCol = Math.floor( firstX / this.columnWidth );
32792 firstCol = Math.max( 0, firstCol );
32794 var lastCol = Math.floor( lastX / this.columnWidth );
32795 // lastCol should not go over if multiple of columnWidth #425
32796 lastCol -= lastX % this.columnWidth ? 0 : 1;
32797 lastCol = Math.min( this.cols - 1, lastCol );
32799 // set colYs to bottom of the stamp
32800 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32803 for ( var i = firstCol; i <= lastCol; i++ ) {
32804 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32809 _getContainerSize : function()
32811 this.maxY = Math.max.apply( Math, this.colYs );
32816 if ( this.isFitWidth ) {
32817 size.width = this._getContainerFitWidth();
32823 _getContainerFitWidth : function()
32825 var unusedCols = 0;
32826 // count unused columns
32829 if ( this.colYs[i] !== 0 ) {
32834 // fit container to columns that have been used
32835 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32838 needsResizeLayout : function()
32840 var previousWidth = this.containerWidth;
32841 this.getContainerWidth();
32842 return previousWidth !== this.containerWidth;
32857 * @class Roo.bootstrap.MasonryBrick
32858 * @extends Roo.bootstrap.Component
32859 * Bootstrap MasonryBrick class
32862 * Create a new MasonryBrick
32863 * @param {Object} config The config object
32866 Roo.bootstrap.MasonryBrick = function(config){
32868 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32870 Roo.bootstrap.MasonryBrick.register(this);
32876 * When a MasonryBrick is clcik
32877 * @param {Roo.bootstrap.MasonryBrick} this
32878 * @param {Roo.EventObject} e
32884 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32887 * @cfg {String} title
32891 * @cfg {String} html
32895 * @cfg {String} bgimage
32899 * @cfg {String} videourl
32903 * @cfg {String} cls
32907 * @cfg {String} href
32911 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32916 * @cfg {String} placetitle (center|bottom)
32921 * @cfg {Boolean} isFitContainer defalut true
32923 isFitContainer : true,
32926 * @cfg {Boolean} preventDefault defalut false
32928 preventDefault : false,
32931 * @cfg {Boolean} inverse defalut false
32933 maskInverse : false,
32935 getAutoCreate : function()
32937 if(!this.isFitContainer){
32938 return this.getSplitAutoCreate();
32941 var cls = 'masonry-brick masonry-brick-full';
32943 if(this.href.length){
32944 cls += ' masonry-brick-link';
32947 if(this.bgimage.length){
32948 cls += ' masonry-brick-image';
32951 if(this.maskInverse){
32952 cls += ' mask-inverse';
32955 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32956 cls += ' enable-mask';
32960 cls += ' masonry-' + this.size + '-brick';
32963 if(this.placetitle.length){
32965 switch (this.placetitle) {
32967 cls += ' masonry-center-title';
32970 cls += ' masonry-bottom-title';
32977 if(!this.html.length && !this.bgimage.length){
32978 cls += ' masonry-center-title';
32981 if(!this.html.length && this.bgimage.length){
32982 cls += ' masonry-bottom-title';
32987 cls += ' ' + this.cls;
32991 tag: (this.href.length) ? 'a' : 'div',
32996 cls: 'masonry-brick-mask'
33000 cls: 'masonry-brick-paragraph',
33006 if(this.href.length){
33007 cfg.href = this.href;
33010 var cn = cfg.cn[1].cn;
33012 if(this.title.length){
33015 cls: 'masonry-brick-title',
33020 if(this.html.length){
33023 cls: 'masonry-brick-text',
33028 if (!this.title.length && !this.html.length) {
33029 cfg.cn[1].cls += ' hide';
33032 if(this.bgimage.length){
33035 cls: 'masonry-brick-image-view',
33040 if(this.videourl.length){
33041 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33042 // youtube support only?
33045 cls: 'masonry-brick-image-view',
33048 allowfullscreen : true
33056 getSplitAutoCreate : function()
33058 var cls = 'masonry-brick masonry-brick-split';
33060 if(this.href.length){
33061 cls += ' masonry-brick-link';
33064 if(this.bgimage.length){
33065 cls += ' masonry-brick-image';
33069 cls += ' masonry-' + this.size + '-brick';
33072 switch (this.placetitle) {
33074 cls += ' masonry-center-title';
33077 cls += ' masonry-bottom-title';
33080 if(!this.bgimage.length){
33081 cls += ' masonry-center-title';
33084 if(this.bgimage.length){
33085 cls += ' masonry-bottom-title';
33091 cls += ' ' + this.cls;
33095 tag: (this.href.length) ? 'a' : 'div',
33100 cls: 'masonry-brick-split-head',
33104 cls: 'masonry-brick-paragraph',
33111 cls: 'masonry-brick-split-body',
33117 if(this.href.length){
33118 cfg.href = this.href;
33121 if(this.title.length){
33122 cfg.cn[0].cn[0].cn.push({
33124 cls: 'masonry-brick-title',
33129 if(this.html.length){
33130 cfg.cn[1].cn.push({
33132 cls: 'masonry-brick-text',
33137 if(this.bgimage.length){
33138 cfg.cn[0].cn.push({
33140 cls: 'masonry-brick-image-view',
33145 if(this.videourl.length){
33146 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33147 // youtube support only?
33148 cfg.cn[0].cn.cn.push({
33150 cls: 'masonry-brick-image-view',
33153 allowfullscreen : true
33160 initEvents: function()
33162 switch (this.size) {
33195 this.el.on('touchstart', this.onTouchStart, this);
33196 this.el.on('touchmove', this.onTouchMove, this);
33197 this.el.on('touchend', this.onTouchEnd, this);
33198 this.el.on('contextmenu', this.onContextMenu, this);
33200 this.el.on('mouseenter' ,this.enter, this);
33201 this.el.on('mouseleave', this.leave, this);
33202 this.el.on('click', this.onClick, this);
33205 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33206 this.parent().bricks.push(this);
33211 onClick: function(e, el)
33213 var time = this.endTimer - this.startTimer;
33214 // Roo.log(e.preventDefault());
33217 e.preventDefault();
33222 if(!this.preventDefault){
33226 e.preventDefault();
33228 if (this.activeClass != '') {
33229 this.selectBrick();
33232 this.fireEvent('click', this, e);
33235 enter: function(e, el)
33237 e.preventDefault();
33239 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33243 if(this.bgimage.length && this.html.length){
33244 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33248 leave: function(e, el)
33250 e.preventDefault();
33252 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33256 if(this.bgimage.length && this.html.length){
33257 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33261 onTouchStart: function(e, el)
33263 // e.preventDefault();
33265 this.touchmoved = false;
33267 if(!this.isFitContainer){
33271 if(!this.bgimage.length || !this.html.length){
33275 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33277 this.timer = new Date().getTime();
33281 onTouchMove: function(e, el)
33283 this.touchmoved = true;
33286 onContextMenu : function(e,el)
33288 e.preventDefault();
33289 e.stopPropagation();
33293 onTouchEnd: function(e, el)
33295 // e.preventDefault();
33297 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33304 if(!this.bgimage.length || !this.html.length){
33306 if(this.href.length){
33307 window.location.href = this.href;
33313 if(!this.isFitContainer){
33317 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33319 window.location.href = this.href;
33322 //selection on single brick only
33323 selectBrick : function() {
33325 if (!this.parentId) {
33329 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33330 var index = m.selectedBrick.indexOf(this.id);
33333 m.selectedBrick.splice(index,1);
33334 this.el.removeClass(this.activeClass);
33338 for(var i = 0; i < m.selectedBrick.length; i++) {
33339 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33340 b.el.removeClass(b.activeClass);
33343 m.selectedBrick = [];
33345 m.selectedBrick.push(this.id);
33346 this.el.addClass(this.activeClass);
33350 isSelected : function(){
33351 return this.el.hasClass(this.activeClass);
33356 Roo.apply(Roo.bootstrap.MasonryBrick, {
33359 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33361 * register a Masonry Brick
33362 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33365 register : function(brick)
33367 //this.groups[brick.id] = brick;
33368 this.groups.add(brick.id, brick);
33371 * fetch a masonry brick based on the masonry brick ID
33372 * @param {string} the masonry brick to add
33373 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33376 get: function(brick_id)
33378 // if (typeof(this.groups[brick_id]) == 'undefined') {
33381 // return this.groups[brick_id] ;
33383 if(this.groups.key(brick_id)) {
33384 return this.groups.key(brick_id);
33402 * @class Roo.bootstrap.Brick
33403 * @extends Roo.bootstrap.Component
33404 * Bootstrap Brick class
33407 * Create a new Brick
33408 * @param {Object} config The config object
33411 Roo.bootstrap.Brick = function(config){
33412 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33418 * When a Brick is click
33419 * @param {Roo.bootstrap.Brick} this
33420 * @param {Roo.EventObject} e
33426 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33429 * @cfg {String} title
33433 * @cfg {String} html
33437 * @cfg {String} bgimage
33441 * @cfg {String} cls
33445 * @cfg {String} href
33449 * @cfg {String} video
33453 * @cfg {Boolean} square
33457 getAutoCreate : function()
33459 var cls = 'roo-brick';
33461 if(this.href.length){
33462 cls += ' roo-brick-link';
33465 if(this.bgimage.length){
33466 cls += ' roo-brick-image';
33469 if(!this.html.length && !this.bgimage.length){
33470 cls += ' roo-brick-center-title';
33473 if(!this.html.length && this.bgimage.length){
33474 cls += ' roo-brick-bottom-title';
33478 cls += ' ' + this.cls;
33482 tag: (this.href.length) ? 'a' : 'div',
33487 cls: 'roo-brick-paragraph',
33493 if(this.href.length){
33494 cfg.href = this.href;
33497 var cn = cfg.cn[0].cn;
33499 if(this.title.length){
33502 cls: 'roo-brick-title',
33507 if(this.html.length){
33510 cls: 'roo-brick-text',
33517 if(this.bgimage.length){
33520 cls: 'roo-brick-image-view',
33528 initEvents: function()
33530 if(this.title.length || this.html.length){
33531 this.el.on('mouseenter' ,this.enter, this);
33532 this.el.on('mouseleave', this.leave, this);
33535 Roo.EventManager.onWindowResize(this.resize, this);
33537 if(this.bgimage.length){
33538 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33539 this.imageEl.on('load', this.onImageLoad, this);
33546 onImageLoad : function()
33551 resize : function()
33553 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33555 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33557 if(this.bgimage.length){
33558 var image = this.el.select('.roo-brick-image-view', true).first();
33560 image.setWidth(paragraph.getWidth());
33563 image.setHeight(paragraph.getWidth());
33566 this.el.setHeight(image.getHeight());
33567 paragraph.setHeight(image.getHeight());
33573 enter: function(e, el)
33575 e.preventDefault();
33577 if(this.bgimage.length){
33578 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33579 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33583 leave: function(e, el)
33585 e.preventDefault();
33587 if(this.bgimage.length){
33588 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33589 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33604 * @class Roo.bootstrap.NumberField
33605 * @extends Roo.bootstrap.Input
33606 * Bootstrap NumberField class
33612 * Create a new NumberField
33613 * @param {Object} config The config object
33616 Roo.bootstrap.NumberField = function(config){
33617 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33620 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33623 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33625 allowDecimals : true,
33627 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33629 decimalSeparator : ".",
33631 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33633 decimalPrecision : 2,
33635 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33637 allowNegative : true,
33640 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33644 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33646 minValue : Number.NEGATIVE_INFINITY,
33648 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33650 maxValue : Number.MAX_VALUE,
33652 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33654 minText : "The minimum value for this field is {0}",
33656 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33658 maxText : "The maximum value for this field is {0}",
33660 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33661 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33663 nanText : "{0} is not a valid number",
33665 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33667 thousandsDelimiter : false,
33669 * @cfg {String} valueAlign alignment of value
33671 valueAlign : "left",
33673 getAutoCreate : function()
33675 var hiddenInput = {
33679 cls: 'hidden-number-input'
33683 hiddenInput.name = this.name;
33688 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33690 this.name = hiddenInput.name;
33692 if(cfg.cn.length > 0) {
33693 cfg.cn.push(hiddenInput);
33700 initEvents : function()
33702 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33704 var allowed = "0123456789";
33706 if(this.allowDecimals){
33707 allowed += this.decimalSeparator;
33710 if(this.allowNegative){
33714 if(this.thousandsDelimiter) {
33718 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33720 var keyPress = function(e){
33722 var k = e.getKey();
33724 var c = e.getCharCode();
33727 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33728 allowed.indexOf(String.fromCharCode(c)) === -1
33734 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33738 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33743 this.el.on("keypress", keyPress, this);
33746 validateValue : function(value)
33749 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33753 var num = this.parseValue(value);
33756 this.markInvalid(String.format(this.nanText, value));
33760 if(num < this.minValue){
33761 this.markInvalid(String.format(this.minText, this.minValue));
33765 if(num > this.maxValue){
33766 this.markInvalid(String.format(this.maxText, this.maxValue));
33773 getValue : function()
33775 var v = this.hiddenEl().getValue();
33777 return this.fixPrecision(this.parseValue(v));
33780 parseValue : function(value)
33782 if(this.thousandsDelimiter) {
33784 r = new RegExp(",", "g");
33785 value = value.replace(r, "");
33788 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33789 return isNaN(value) ? '' : value;
33792 fixPrecision : function(value)
33794 if(this.thousandsDelimiter) {
33796 r = new RegExp(",", "g");
33797 value = value.replace(r, "");
33800 var nan = isNaN(value);
33802 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33803 return nan ? '' : value;
33805 return parseFloat(value).toFixed(this.decimalPrecision);
33808 setValue : function(v)
33810 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33816 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33818 this.inputEl().dom.value = (v == '') ? '' :
33819 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33821 if(!this.allowZero && v === '0') {
33822 this.hiddenEl().dom.value = '';
33823 this.inputEl().dom.value = '';
33830 decimalPrecisionFcn : function(v)
33832 return Math.floor(v);
33835 beforeBlur : function()
33837 var v = this.parseValue(this.getRawValue());
33839 if(v || v === 0 || v === ''){
33844 hiddenEl : function()
33846 return this.el.select('input.hidden-number-input',true).first();
33858 * @class Roo.bootstrap.DocumentSlider
33859 * @extends Roo.bootstrap.Component
33860 * Bootstrap DocumentSlider class
33863 * Create a new DocumentViewer
33864 * @param {Object} config The config object
33867 Roo.bootstrap.DocumentSlider = function(config){
33868 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33875 * Fire after initEvent
33876 * @param {Roo.bootstrap.DocumentSlider} this
33881 * Fire after update
33882 * @param {Roo.bootstrap.DocumentSlider} this
33888 * @param {Roo.bootstrap.DocumentSlider} this
33894 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33900 getAutoCreate : function()
33904 cls : 'roo-document-slider',
33908 cls : 'roo-document-slider-header',
33912 cls : 'roo-document-slider-header-title'
33918 cls : 'roo-document-slider-body',
33922 cls : 'roo-document-slider-prev',
33926 cls : 'fa fa-chevron-left'
33932 cls : 'roo-document-slider-thumb',
33936 cls : 'roo-document-slider-image'
33942 cls : 'roo-document-slider-next',
33946 cls : 'fa fa-chevron-right'
33958 initEvents : function()
33960 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33961 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33963 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33964 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33966 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33967 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33969 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33970 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33972 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33973 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33975 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33976 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33978 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33979 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33981 this.thumbEl.on('click', this.onClick, this);
33983 this.prevIndicator.on('click', this.prev, this);
33985 this.nextIndicator.on('click', this.next, this);
33989 initial : function()
33991 if(this.files.length){
33992 this.indicator = 1;
33996 this.fireEvent('initial', this);
33999 update : function()
34001 this.imageEl.attr('src', this.files[this.indicator - 1]);
34003 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34005 this.prevIndicator.show();
34007 if(this.indicator == 1){
34008 this.prevIndicator.hide();
34011 this.nextIndicator.show();
34013 if(this.indicator == this.files.length){
34014 this.nextIndicator.hide();
34017 this.thumbEl.scrollTo('top');
34019 this.fireEvent('update', this);
34022 onClick : function(e)
34024 e.preventDefault();
34026 this.fireEvent('click', this);
34031 e.preventDefault();
34033 this.indicator = Math.max(1, this.indicator - 1);
34040 e.preventDefault();
34042 this.indicator = Math.min(this.files.length, this.indicator + 1);
34056 * @class Roo.bootstrap.RadioSet
34057 * @extends Roo.bootstrap.Input
34058 * Bootstrap RadioSet class
34059 * @cfg {String} indicatorpos (left|right) default left
34060 * @cfg {Boolean} inline (true|false) inline the element (default true)
34061 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34063 * Create a new RadioSet
34064 * @param {Object} config The config object
34067 Roo.bootstrap.RadioSet = function(config){
34069 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34073 Roo.bootstrap.RadioSet.register(this);
34078 * Fires when the element is checked or unchecked.
34079 * @param {Roo.bootstrap.RadioSet} this This radio
34080 * @param {Roo.bootstrap.Radio} item The checked item
34085 * Fires when the element is click.
34086 * @param {Roo.bootstrap.RadioSet} this This radio set
34087 * @param {Roo.bootstrap.Radio} item The checked item
34088 * @param {Roo.EventObject} e The event object
34095 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34103 indicatorpos : 'left',
34105 getAutoCreate : function()
34109 cls : 'roo-radio-set-label',
34113 html : this.fieldLabel
34117 if (Roo.bootstrap.version == 3) {
34120 if(this.indicatorpos == 'left'){
34123 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34124 tooltip : 'This field is required'
34129 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34130 tooltip : 'This field is required'
34136 cls : 'roo-radio-set-items'
34139 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34141 if (align === 'left' && this.fieldLabel.length) {
34144 cls : "roo-radio-set-right",
34150 if(this.labelWidth > 12){
34151 label.style = "width: " + this.labelWidth + 'px';
34154 if(this.labelWidth < 13 && this.labelmd == 0){
34155 this.labelmd = this.labelWidth;
34158 if(this.labellg > 0){
34159 label.cls += ' col-lg-' + this.labellg;
34160 items.cls += ' col-lg-' + (12 - this.labellg);
34163 if(this.labelmd > 0){
34164 label.cls += ' col-md-' + this.labelmd;
34165 items.cls += ' col-md-' + (12 - this.labelmd);
34168 if(this.labelsm > 0){
34169 label.cls += ' col-sm-' + this.labelsm;
34170 items.cls += ' col-sm-' + (12 - this.labelsm);
34173 if(this.labelxs > 0){
34174 label.cls += ' col-xs-' + this.labelxs;
34175 items.cls += ' col-xs-' + (12 - this.labelxs);
34181 cls : 'roo-radio-set',
34185 cls : 'roo-radio-set-input',
34188 value : this.value ? this.value : ''
34195 if(this.weight.length){
34196 cfg.cls += ' roo-radio-' + this.weight;
34200 cfg.cls += ' roo-radio-set-inline';
34204 ['xs','sm','md','lg'].map(function(size){
34205 if (settings[size]) {
34206 cfg.cls += ' col-' + size + '-' + settings[size];
34214 initEvents : function()
34216 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34217 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34219 if(!this.fieldLabel.length){
34220 this.labelEl.hide();
34223 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34224 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34226 this.indicator = this.indicatorEl();
34228 if(this.indicator){
34229 this.indicator.addClass('invisible');
34232 this.originalValue = this.getValue();
34236 inputEl: function ()
34238 return this.el.select('.roo-radio-set-input', true).first();
34241 getChildContainer : function()
34243 return this.itemsEl;
34246 register : function(item)
34248 this.radioes.push(item);
34252 validate : function()
34254 if(this.getVisibilityEl().hasClass('hidden')){
34260 Roo.each(this.radioes, function(i){
34269 if(this.allowBlank) {
34273 if(this.disabled || valid){
34278 this.markInvalid();
34283 markValid : function()
34285 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34286 this.indicatorEl().removeClass('visible');
34287 this.indicatorEl().addClass('invisible');
34291 if (Roo.bootstrap.version == 3) {
34292 this.el.removeClass([this.invalidClass, this.validClass]);
34293 this.el.addClass(this.validClass);
34295 this.el.removeClass(['is-invalid','is-valid']);
34296 this.el.addClass(['is-valid']);
34298 this.fireEvent('valid', this);
34301 markInvalid : function(msg)
34303 if(this.allowBlank || this.disabled){
34307 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34308 this.indicatorEl().removeClass('invisible');
34309 this.indicatorEl().addClass('visible');
34311 if (Roo.bootstrap.version == 3) {
34312 this.el.removeClass([this.invalidClass, this.validClass]);
34313 this.el.addClass(this.invalidClass);
34315 this.el.removeClass(['is-invalid','is-valid']);
34316 this.el.addClass(['is-invalid']);
34319 this.fireEvent('invalid', this, msg);
34323 setValue : function(v, suppressEvent)
34325 if(this.value === v){
34332 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34335 Roo.each(this.radioes, function(i){
34337 i.el.removeClass('checked');
34340 Roo.each(this.radioes, function(i){
34342 if(i.value === v || i.value.toString() === v.toString()){
34344 i.el.addClass('checked');
34346 if(suppressEvent !== true){
34347 this.fireEvent('check', this, i);
34358 clearInvalid : function(){
34360 if(!this.el || this.preventMark){
34364 this.el.removeClass([this.invalidClass]);
34366 this.fireEvent('valid', this);
34371 Roo.apply(Roo.bootstrap.RadioSet, {
34375 register : function(set)
34377 this.groups[set.name] = set;
34380 get: function(name)
34382 if (typeof(this.groups[name]) == 'undefined') {
34386 return this.groups[name] ;
34392 * Ext JS Library 1.1.1
34393 * Copyright(c) 2006-2007, Ext JS, LLC.
34395 * Originally Released Under LGPL - original licence link has changed is not relivant.
34398 * <script type="text/javascript">
34403 * @class Roo.bootstrap.SplitBar
34404 * @extends Roo.util.Observable
34405 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34409 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34410 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34411 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34412 split.minSize = 100;
34413 split.maxSize = 600;
34414 split.animate = true;
34415 split.on('moved', splitterMoved);
34418 * Create a new SplitBar
34419 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34420 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34421 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34422 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34423 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34424 position of the SplitBar).
34426 Roo.bootstrap.SplitBar = function(cfg){
34431 // dragElement : elm
34432 // resizingElement: el,
34434 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34435 // placement : Roo.bootstrap.SplitBar.LEFT ,
34436 // existingProxy ???
34439 this.el = Roo.get(cfg.dragElement, true);
34440 this.el.dom.unselectable = "on";
34442 this.resizingEl = Roo.get(cfg.resizingElement, true);
34446 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34447 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34450 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34453 * The minimum size of the resizing element. (Defaults to 0)
34459 * The maximum size of the resizing element. (Defaults to 2000)
34462 this.maxSize = 2000;
34465 * Whether to animate the transition to the new size
34468 this.animate = false;
34471 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34474 this.useShim = false;
34479 if(!cfg.existingProxy){
34481 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34483 this.proxy = Roo.get(cfg.existingProxy).dom;
34486 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34489 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34492 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34495 this.dragSpecs = {};
34498 * @private The adapter to use to positon and resize elements
34500 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34501 this.adapter.init(this);
34503 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34505 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34506 this.el.addClass("roo-splitbar-h");
34509 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34510 this.el.addClass("roo-splitbar-v");
34516 * Fires when the splitter is moved (alias for {@link #event-moved})
34517 * @param {Roo.bootstrap.SplitBar} this
34518 * @param {Number} newSize the new width or height
34523 * Fires when the splitter is moved
34524 * @param {Roo.bootstrap.SplitBar} this
34525 * @param {Number} newSize the new width or height
34529 * @event beforeresize
34530 * Fires before the splitter is dragged
34531 * @param {Roo.bootstrap.SplitBar} this
34533 "beforeresize" : true,
34535 "beforeapply" : true
34538 Roo.util.Observable.call(this);
34541 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34542 onStartProxyDrag : function(x, y){
34543 this.fireEvent("beforeresize", this);
34545 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34547 o.enableDisplayMode("block");
34548 // all splitbars share the same overlay
34549 Roo.bootstrap.SplitBar.prototype.overlay = o;
34551 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34552 this.overlay.show();
34553 Roo.get(this.proxy).setDisplayed("block");
34554 var size = this.adapter.getElementSize(this);
34555 this.activeMinSize = this.getMinimumSize();;
34556 this.activeMaxSize = this.getMaximumSize();;
34557 var c1 = size - this.activeMinSize;
34558 var c2 = Math.max(this.activeMaxSize - size, 0);
34559 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34560 this.dd.resetConstraints();
34561 this.dd.setXConstraint(
34562 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34563 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34565 this.dd.setYConstraint(0, 0);
34567 this.dd.resetConstraints();
34568 this.dd.setXConstraint(0, 0);
34569 this.dd.setYConstraint(
34570 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34571 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34574 this.dragSpecs.startSize = size;
34575 this.dragSpecs.startPoint = [x, y];
34576 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34580 * @private Called after the drag operation by the DDProxy
34582 onEndProxyDrag : function(e){
34583 Roo.get(this.proxy).setDisplayed(false);
34584 var endPoint = Roo.lib.Event.getXY(e);
34586 this.overlay.hide();
34589 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34590 newSize = this.dragSpecs.startSize +
34591 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34592 endPoint[0] - this.dragSpecs.startPoint[0] :
34593 this.dragSpecs.startPoint[0] - endPoint[0]
34596 newSize = this.dragSpecs.startSize +
34597 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34598 endPoint[1] - this.dragSpecs.startPoint[1] :
34599 this.dragSpecs.startPoint[1] - endPoint[1]
34602 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34603 if(newSize != this.dragSpecs.startSize){
34604 if(this.fireEvent('beforeapply', this, newSize) !== false){
34605 this.adapter.setElementSize(this, newSize);
34606 this.fireEvent("moved", this, newSize);
34607 this.fireEvent("resize", this, newSize);
34613 * Get the adapter this SplitBar uses
34614 * @return The adapter object
34616 getAdapter : function(){
34617 return this.adapter;
34621 * Set the adapter this SplitBar uses
34622 * @param {Object} adapter A SplitBar adapter object
34624 setAdapter : function(adapter){
34625 this.adapter = adapter;
34626 this.adapter.init(this);
34630 * Gets the minimum size for the resizing element
34631 * @return {Number} The minimum size
34633 getMinimumSize : function(){
34634 return this.minSize;
34638 * Sets the minimum size for the resizing element
34639 * @param {Number} minSize The minimum size
34641 setMinimumSize : function(minSize){
34642 this.minSize = minSize;
34646 * Gets the maximum size for the resizing element
34647 * @return {Number} The maximum size
34649 getMaximumSize : function(){
34650 return this.maxSize;
34654 * Sets the maximum size for the resizing element
34655 * @param {Number} maxSize The maximum size
34657 setMaximumSize : function(maxSize){
34658 this.maxSize = maxSize;
34662 * Sets the initialize size for the resizing element
34663 * @param {Number} size The initial size
34665 setCurrentSize : function(size){
34666 var oldAnimate = this.animate;
34667 this.animate = false;
34668 this.adapter.setElementSize(this, size);
34669 this.animate = oldAnimate;
34673 * Destroy this splitbar.
34674 * @param {Boolean} removeEl True to remove the element
34676 destroy : function(removeEl){
34678 this.shim.remove();
34681 this.proxy.parentNode.removeChild(this.proxy);
34689 * @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.
34691 Roo.bootstrap.SplitBar.createProxy = function(dir){
34692 var proxy = new Roo.Element(document.createElement("div"));
34693 proxy.unselectable();
34694 var cls = 'roo-splitbar-proxy';
34695 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34696 document.body.appendChild(proxy.dom);
34701 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34702 * Default Adapter. It assumes the splitter and resizing element are not positioned
34703 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34705 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34708 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34709 // do nothing for now
34710 init : function(s){
34714 * Called before drag operations to get the current size of the resizing element.
34715 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34717 getElementSize : function(s){
34718 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34719 return s.resizingEl.getWidth();
34721 return s.resizingEl.getHeight();
34726 * Called after drag operations to set the size of the resizing element.
34727 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34728 * @param {Number} newSize The new size to set
34729 * @param {Function} onComplete A function to be invoked when resizing is complete
34731 setElementSize : function(s, newSize, onComplete){
34732 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34734 s.resizingEl.setWidth(newSize);
34736 onComplete(s, newSize);
34739 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34744 s.resizingEl.setHeight(newSize);
34746 onComplete(s, newSize);
34749 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34756 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34757 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34758 * Adapter that moves the splitter element to align with the resized sizing element.
34759 * Used with an absolute positioned SplitBar.
34760 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34761 * document.body, make sure you assign an id to the body element.
34763 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34764 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34765 this.container = Roo.get(container);
34768 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34769 init : function(s){
34770 this.basic.init(s);
34773 getElementSize : function(s){
34774 return this.basic.getElementSize(s);
34777 setElementSize : function(s, newSize, onComplete){
34778 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34781 moveSplitter : function(s){
34782 var yes = Roo.bootstrap.SplitBar;
34783 switch(s.placement){
34785 s.el.setX(s.resizingEl.getRight());
34788 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34791 s.el.setY(s.resizingEl.getBottom());
34794 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34801 * Orientation constant - Create a vertical SplitBar
34805 Roo.bootstrap.SplitBar.VERTICAL = 1;
34808 * Orientation constant - Create a horizontal SplitBar
34812 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34815 * Placement constant - The resizing element is to the left of the splitter element
34819 Roo.bootstrap.SplitBar.LEFT = 1;
34822 * Placement constant - The resizing element is to the right of the splitter element
34826 Roo.bootstrap.SplitBar.RIGHT = 2;
34829 * Placement constant - The resizing element is positioned above the splitter element
34833 Roo.bootstrap.SplitBar.TOP = 3;
34836 * Placement constant - The resizing element is positioned under splitter element
34840 Roo.bootstrap.SplitBar.BOTTOM = 4;
34841 Roo.namespace("Roo.bootstrap.layout");/*
34843 * Ext JS Library 1.1.1
34844 * Copyright(c) 2006-2007, Ext JS, LLC.
34846 * Originally Released Under LGPL - original licence link has changed is not relivant.
34849 * <script type="text/javascript">
34853 * @class Roo.bootstrap.layout.Manager
34854 * @extends Roo.bootstrap.Component
34855 * Base class for layout managers.
34857 Roo.bootstrap.layout.Manager = function(config)
34859 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34865 /** false to disable window resize monitoring @type Boolean */
34866 this.monitorWindowResize = true;
34871 * Fires when a layout is performed.
34872 * @param {Roo.LayoutManager} this
34876 * @event regionresized
34877 * Fires when the user resizes a region.
34878 * @param {Roo.LayoutRegion} region The resized region
34879 * @param {Number} newSize The new size (width for east/west, height for north/south)
34881 "regionresized" : true,
34883 * @event regioncollapsed
34884 * Fires when a region is collapsed.
34885 * @param {Roo.LayoutRegion} region The collapsed region
34887 "regioncollapsed" : true,
34889 * @event regionexpanded
34890 * Fires when a region is expanded.
34891 * @param {Roo.LayoutRegion} region The expanded region
34893 "regionexpanded" : true
34895 this.updating = false;
34898 this.el = Roo.get(config.el);
34904 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34909 monitorWindowResize : true,
34915 onRender : function(ct, position)
34918 this.el = Roo.get(ct);
34921 //this.fireEvent('render',this);
34925 initEvents: function()
34929 // ie scrollbar fix
34930 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34931 document.body.scroll = "no";
34932 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34933 this.el.position('relative');
34935 this.id = this.el.id;
34936 this.el.addClass("roo-layout-container");
34937 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34938 if(this.el.dom != document.body ) {
34939 this.el.on('resize', this.layout,this);
34940 this.el.on('show', this.layout,this);
34946 * Returns true if this layout is currently being updated
34947 * @return {Boolean}
34949 isUpdating : function(){
34950 return this.updating;
34954 * Suspend the LayoutManager from doing auto-layouts while
34955 * making multiple add or remove calls
34957 beginUpdate : function(){
34958 this.updating = true;
34962 * Restore auto-layouts and optionally disable the manager from performing a layout
34963 * @param {Boolean} noLayout true to disable a layout update
34965 endUpdate : function(noLayout){
34966 this.updating = false;
34972 layout: function(){
34976 onRegionResized : function(region, newSize){
34977 this.fireEvent("regionresized", region, newSize);
34981 onRegionCollapsed : function(region){
34982 this.fireEvent("regioncollapsed", region);
34985 onRegionExpanded : function(region){
34986 this.fireEvent("regionexpanded", region);
34990 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34991 * performs box-model adjustments.
34992 * @return {Object} The size as an object {width: (the width), height: (the height)}
34994 getViewSize : function()
34997 if(this.el.dom != document.body){
34998 size = this.el.getSize();
35000 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35002 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35003 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35008 * Returns the Element this layout is bound to.
35009 * @return {Roo.Element}
35011 getEl : function(){
35016 * Returns the specified region.
35017 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35018 * @return {Roo.LayoutRegion}
35020 getRegion : function(target){
35021 return this.regions[target.toLowerCase()];
35024 onWindowResize : function(){
35025 if(this.monitorWindowResize){
35032 * Ext JS Library 1.1.1
35033 * Copyright(c) 2006-2007, Ext JS, LLC.
35035 * Originally Released Under LGPL - original licence link has changed is not relivant.
35038 * <script type="text/javascript">
35041 * @class Roo.bootstrap.layout.Border
35042 * @extends Roo.bootstrap.layout.Manager
35043 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35044 * please see: examples/bootstrap/nested.html<br><br>
35046 <b>The container the layout is rendered into can be either the body element or any other element.
35047 If it is not the body element, the container needs to either be an absolute positioned element,
35048 or you will need to add "position:relative" to the css of the container. You will also need to specify
35049 the container size if it is not the body element.</b>
35052 * Create a new Border
35053 * @param {Object} config Configuration options
35055 Roo.bootstrap.layout.Border = function(config){
35056 config = config || {};
35057 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35061 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35062 if(config[region]){
35063 config[region].region = region;
35064 this.addRegion(config[region]);
35070 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35072 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35074 * Creates and adds a new region if it doesn't already exist.
35075 * @param {String} target The target region key (north, south, east, west or center).
35076 * @param {Object} config The regions config object
35077 * @return {BorderLayoutRegion} The new region
35079 addRegion : function(config)
35081 if(!this.regions[config.region]){
35082 var r = this.factory(config);
35083 this.bindRegion(r);
35085 return this.regions[config.region];
35089 bindRegion : function(r){
35090 this.regions[r.config.region] = r;
35092 r.on("visibilitychange", this.layout, this);
35093 r.on("paneladded", this.layout, this);
35094 r.on("panelremoved", this.layout, this);
35095 r.on("invalidated", this.layout, this);
35096 r.on("resized", this.onRegionResized, this);
35097 r.on("collapsed", this.onRegionCollapsed, this);
35098 r.on("expanded", this.onRegionExpanded, this);
35102 * Performs a layout update.
35104 layout : function()
35106 if(this.updating) {
35110 // render all the rebions if they have not been done alreayd?
35111 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35112 if(this.regions[region] && !this.regions[region].bodyEl){
35113 this.regions[region].onRender(this.el)
35117 var size = this.getViewSize();
35118 var w = size.width;
35119 var h = size.height;
35124 //var x = 0, y = 0;
35126 var rs = this.regions;
35127 var north = rs["north"];
35128 var south = rs["south"];
35129 var west = rs["west"];
35130 var east = rs["east"];
35131 var center = rs["center"];
35132 //if(this.hideOnLayout){ // not supported anymore
35133 //c.el.setStyle("display", "none");
35135 if(north && north.isVisible()){
35136 var b = north.getBox();
35137 var m = north.getMargins();
35138 b.width = w - (m.left+m.right);
35141 centerY = b.height + b.y + m.bottom;
35142 centerH -= centerY;
35143 north.updateBox(this.safeBox(b));
35145 if(south && south.isVisible()){
35146 var b = south.getBox();
35147 var m = south.getMargins();
35148 b.width = w - (m.left+m.right);
35150 var totalHeight = (b.height + m.top + m.bottom);
35151 b.y = h - totalHeight + m.top;
35152 centerH -= totalHeight;
35153 south.updateBox(this.safeBox(b));
35155 if(west && west.isVisible()){
35156 var b = west.getBox();
35157 var m = west.getMargins();
35158 b.height = centerH - (m.top+m.bottom);
35160 b.y = centerY + m.top;
35161 var totalWidth = (b.width + m.left + m.right);
35162 centerX += totalWidth;
35163 centerW -= totalWidth;
35164 west.updateBox(this.safeBox(b));
35166 if(east && east.isVisible()){
35167 var b = east.getBox();
35168 var m = east.getMargins();
35169 b.height = centerH - (m.top+m.bottom);
35170 var totalWidth = (b.width + m.left + m.right);
35171 b.x = w - totalWidth + m.left;
35172 b.y = centerY + m.top;
35173 centerW -= totalWidth;
35174 east.updateBox(this.safeBox(b));
35177 var m = center.getMargins();
35179 x: centerX + m.left,
35180 y: centerY + m.top,
35181 width: centerW - (m.left+m.right),
35182 height: centerH - (m.top+m.bottom)
35184 //if(this.hideOnLayout){
35185 //center.el.setStyle("display", "block");
35187 center.updateBox(this.safeBox(centerBox));
35190 this.fireEvent("layout", this);
35194 safeBox : function(box){
35195 box.width = Math.max(0, box.width);
35196 box.height = Math.max(0, box.height);
35201 * Adds a ContentPanel (or subclass) to this layout.
35202 * @param {String} target The target region key (north, south, east, west or center).
35203 * @param {Roo.ContentPanel} panel The panel to add
35204 * @return {Roo.ContentPanel} The added panel
35206 add : function(target, panel){
35208 target = target.toLowerCase();
35209 return this.regions[target].add(panel);
35213 * Remove a ContentPanel (or subclass) to this layout.
35214 * @param {String} target The target region key (north, south, east, west or center).
35215 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35216 * @return {Roo.ContentPanel} The removed panel
35218 remove : function(target, panel){
35219 target = target.toLowerCase();
35220 return this.regions[target].remove(panel);
35224 * Searches all regions for a panel with the specified id
35225 * @param {String} panelId
35226 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35228 findPanel : function(panelId){
35229 var rs = this.regions;
35230 for(var target in rs){
35231 if(typeof rs[target] != "function"){
35232 var p = rs[target].getPanel(panelId);
35242 * Searches all regions for a panel with the specified id and activates (shows) it.
35243 * @param {String/ContentPanel} panelId The panels id or the panel itself
35244 * @return {Roo.ContentPanel} The shown panel or null
35246 showPanel : function(panelId) {
35247 var rs = this.regions;
35248 for(var target in rs){
35249 var r = rs[target];
35250 if(typeof r != "function"){
35251 if(r.hasPanel(panelId)){
35252 return r.showPanel(panelId);
35260 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35261 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35264 restoreState : function(provider){
35266 provider = Roo.state.Manager;
35268 var sm = new Roo.LayoutStateManager();
35269 sm.init(this, provider);
35275 * Adds a xtype elements to the layout.
35279 xtype : 'ContentPanel',
35286 xtype : 'NestedLayoutPanel',
35292 items : [ ... list of content panels or nested layout panels.. ]
35296 * @param {Object} cfg Xtype definition of item to add.
35298 addxtype : function(cfg)
35300 // basically accepts a pannel...
35301 // can accept a layout region..!?!?
35302 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35305 // theory? children can only be panels??
35307 //if (!cfg.xtype.match(/Panel$/)) {
35312 if (typeof(cfg.region) == 'undefined') {
35313 Roo.log("Failed to add Panel, region was not set");
35317 var region = cfg.region;
35323 xitems = cfg.items;
35330 case 'Content': // ContentPanel (el, cfg)
35331 case 'Scroll': // ContentPanel (el, cfg)
35333 cfg.autoCreate = true;
35334 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35336 // var el = this.el.createChild();
35337 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35340 this.add(region, ret);
35344 case 'TreePanel': // our new panel!
35345 cfg.el = this.el.createChild();
35346 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35347 this.add(region, ret);
35352 // create a new Layout (which is a Border Layout...
35354 var clayout = cfg.layout;
35355 clayout.el = this.el.createChild();
35356 clayout.items = clayout.items || [];
35360 // replace this exitems with the clayout ones..
35361 xitems = clayout.items;
35363 // force background off if it's in center...
35364 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35365 cfg.background = false;
35367 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35370 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35371 //console.log('adding nested layout panel ' + cfg.toSource());
35372 this.add(region, ret);
35373 nb = {}; /// find first...
35378 // needs grid and region
35380 //var el = this.getRegion(region).el.createChild();
35382 *var el = this.el.createChild();
35383 // create the grid first...
35384 cfg.grid.container = el;
35385 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35388 if (region == 'center' && this.active ) {
35389 cfg.background = false;
35392 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35394 this.add(region, ret);
35396 if (cfg.background) {
35397 // render grid on panel activation (if panel background)
35398 ret.on('activate', function(gp) {
35399 if (!gp.grid.rendered) {
35400 // gp.grid.render(el);
35404 // cfg.grid.render(el);
35410 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35411 // it was the old xcomponent building that caused this before.
35412 // espeically if border is the top element in the tree.
35422 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35424 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35425 this.add(region, ret);
35429 throw "Can not add '" + cfg.xtype + "' to Border";
35435 this.beginUpdate();
35439 Roo.each(xitems, function(i) {
35440 region = nb && i.region ? i.region : false;
35442 var add = ret.addxtype(i);
35445 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35446 if (!i.background) {
35447 abn[region] = nb[region] ;
35454 // make the last non-background panel active..
35455 //if (nb) { Roo.log(abn); }
35458 for(var r in abn) {
35459 region = this.getRegion(r);
35461 // tried using nb[r], but it does not work..
35463 region.showPanel(abn[r]);
35474 factory : function(cfg)
35477 var validRegions = Roo.bootstrap.layout.Border.regions;
35479 var target = cfg.region;
35482 var r = Roo.bootstrap.layout;
35486 return new r.North(cfg);
35488 return new r.South(cfg);
35490 return new r.East(cfg);
35492 return new r.West(cfg);
35494 return new r.Center(cfg);
35496 throw 'Layout region "'+target+'" not supported.';
35503 * Ext JS Library 1.1.1
35504 * Copyright(c) 2006-2007, Ext JS, LLC.
35506 * Originally Released Under LGPL - original licence link has changed is not relivant.
35509 * <script type="text/javascript">
35513 * @class Roo.bootstrap.layout.Basic
35514 * @extends Roo.util.Observable
35515 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35516 * and does not have a titlebar, tabs or any other features. All it does is size and position
35517 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35518 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35519 * @cfg {string} region the region that it inhabits..
35520 * @cfg {bool} skipConfig skip config?
35524 Roo.bootstrap.layout.Basic = function(config){
35526 this.mgr = config.mgr;
35528 this.position = config.region;
35530 var skipConfig = config.skipConfig;
35534 * @scope Roo.BasicLayoutRegion
35538 * @event beforeremove
35539 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35540 * @param {Roo.LayoutRegion} this
35541 * @param {Roo.ContentPanel} panel The panel
35542 * @param {Object} e The cancel event object
35544 "beforeremove" : true,
35546 * @event invalidated
35547 * Fires when the layout for this region is changed.
35548 * @param {Roo.LayoutRegion} this
35550 "invalidated" : true,
35552 * @event visibilitychange
35553 * Fires when this region is shown or hidden
35554 * @param {Roo.LayoutRegion} this
35555 * @param {Boolean} visibility true or false
35557 "visibilitychange" : true,
35559 * @event paneladded
35560 * Fires when a panel is added.
35561 * @param {Roo.LayoutRegion} this
35562 * @param {Roo.ContentPanel} panel The panel
35564 "paneladded" : true,
35566 * @event panelremoved
35567 * Fires when a panel is removed.
35568 * @param {Roo.LayoutRegion} this
35569 * @param {Roo.ContentPanel} panel The panel
35571 "panelremoved" : true,
35573 * @event beforecollapse
35574 * Fires when this region before collapse.
35575 * @param {Roo.LayoutRegion} this
35577 "beforecollapse" : true,
35580 * Fires when this region is collapsed.
35581 * @param {Roo.LayoutRegion} this
35583 "collapsed" : true,
35586 * Fires when this region is expanded.
35587 * @param {Roo.LayoutRegion} this
35592 * Fires when this region is slid into view.
35593 * @param {Roo.LayoutRegion} this
35595 "slideshow" : true,
35598 * Fires when this region slides out of view.
35599 * @param {Roo.LayoutRegion} this
35601 "slidehide" : true,
35603 * @event panelactivated
35604 * Fires when a panel is activated.
35605 * @param {Roo.LayoutRegion} this
35606 * @param {Roo.ContentPanel} panel The activated panel
35608 "panelactivated" : true,
35611 * Fires when the user resizes this region.
35612 * @param {Roo.LayoutRegion} this
35613 * @param {Number} newSize The new size (width for east/west, height for north/south)
35617 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35618 this.panels = new Roo.util.MixedCollection();
35619 this.panels.getKey = this.getPanelId.createDelegate(this);
35621 this.activePanel = null;
35622 // ensure listeners are added...
35624 if (config.listeners || config.events) {
35625 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35626 listeners : config.listeners || {},
35627 events : config.events || {}
35631 if(skipConfig !== true){
35632 this.applyConfig(config);
35636 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35638 getPanelId : function(p){
35642 applyConfig : function(config){
35643 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35644 this.config = config;
35649 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35650 * the width, for horizontal (north, south) the height.
35651 * @param {Number} newSize The new width or height
35653 resizeTo : function(newSize){
35654 var el = this.el ? this.el :
35655 (this.activePanel ? this.activePanel.getEl() : null);
35657 switch(this.position){
35660 el.setWidth(newSize);
35661 this.fireEvent("resized", this, newSize);
35665 el.setHeight(newSize);
35666 this.fireEvent("resized", this, newSize);
35672 getBox : function(){
35673 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35676 getMargins : function(){
35677 return this.margins;
35680 updateBox : function(box){
35682 var el = this.activePanel.getEl();
35683 el.dom.style.left = box.x + "px";
35684 el.dom.style.top = box.y + "px";
35685 this.activePanel.setSize(box.width, box.height);
35689 * Returns the container element for this region.
35690 * @return {Roo.Element}
35692 getEl : function(){
35693 return this.activePanel;
35697 * Returns true if this region is currently visible.
35698 * @return {Boolean}
35700 isVisible : function(){
35701 return this.activePanel ? true : false;
35704 setActivePanel : function(panel){
35705 panel = this.getPanel(panel);
35706 if(this.activePanel && this.activePanel != panel){
35707 this.activePanel.setActiveState(false);
35708 this.activePanel.getEl().setLeftTop(-10000,-10000);
35710 this.activePanel = panel;
35711 panel.setActiveState(true);
35713 panel.setSize(this.box.width, this.box.height);
35715 this.fireEvent("panelactivated", this, panel);
35716 this.fireEvent("invalidated");
35720 * Show the specified panel.
35721 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35722 * @return {Roo.ContentPanel} The shown panel or null
35724 showPanel : function(panel){
35725 panel = this.getPanel(panel);
35727 this.setActivePanel(panel);
35733 * Get the active panel for this region.
35734 * @return {Roo.ContentPanel} The active panel or null
35736 getActivePanel : function(){
35737 return this.activePanel;
35741 * Add the passed ContentPanel(s)
35742 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35743 * @return {Roo.ContentPanel} The panel added (if only one was added)
35745 add : function(panel){
35746 if(arguments.length > 1){
35747 for(var i = 0, len = arguments.length; i < len; i++) {
35748 this.add(arguments[i]);
35752 if(this.hasPanel(panel)){
35753 this.showPanel(panel);
35756 var el = panel.getEl();
35757 if(el.dom.parentNode != this.mgr.el.dom){
35758 this.mgr.el.dom.appendChild(el.dom);
35760 if(panel.setRegion){
35761 panel.setRegion(this);
35763 this.panels.add(panel);
35764 el.setStyle("position", "absolute");
35765 if(!panel.background){
35766 this.setActivePanel(panel);
35767 if(this.config.initialSize && this.panels.getCount()==1){
35768 this.resizeTo(this.config.initialSize);
35771 this.fireEvent("paneladded", this, panel);
35776 * Returns true if the panel is in this region.
35777 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35778 * @return {Boolean}
35780 hasPanel : function(panel){
35781 if(typeof panel == "object"){ // must be panel obj
35782 panel = panel.getId();
35784 return this.getPanel(panel) ? true : false;
35788 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35789 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35790 * @param {Boolean} preservePanel Overrides the config preservePanel option
35791 * @return {Roo.ContentPanel} The panel that was removed
35793 remove : function(panel, preservePanel){
35794 panel = this.getPanel(panel);
35799 this.fireEvent("beforeremove", this, panel, e);
35800 if(e.cancel === true){
35803 var panelId = panel.getId();
35804 this.panels.removeKey(panelId);
35809 * Returns the panel specified or null if it's not in this region.
35810 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35811 * @return {Roo.ContentPanel}
35813 getPanel : function(id){
35814 if(typeof id == "object"){ // must be panel obj
35817 return this.panels.get(id);
35821 * Returns this regions position (north/south/east/west/center).
35824 getPosition: function(){
35825 return this.position;
35829 * Ext JS Library 1.1.1
35830 * Copyright(c) 2006-2007, Ext JS, LLC.
35832 * Originally Released Under LGPL - original licence link has changed is not relivant.
35835 * <script type="text/javascript">
35839 * @class Roo.bootstrap.layout.Region
35840 * @extends Roo.bootstrap.layout.Basic
35841 * This class represents a region in a layout manager.
35843 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35844 * @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})
35845 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35846 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35847 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35848 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35849 * @cfg {String} title The title for the region (overrides panel titles)
35850 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35851 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35852 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35853 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35854 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35855 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35856 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35857 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35858 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35859 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35861 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35862 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35863 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35864 * @cfg {Number} width For East/West panels
35865 * @cfg {Number} height For North/South panels
35866 * @cfg {Boolean} split To show the splitter
35867 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35869 * @cfg {string} cls Extra CSS classes to add to region
35871 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35872 * @cfg {string} region the region that it inhabits..
35875 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35876 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35878 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35879 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35880 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35882 Roo.bootstrap.layout.Region = function(config)
35884 this.applyConfig(config);
35886 var mgr = config.mgr;
35887 var pos = config.region;
35888 config.skipConfig = true;
35889 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35892 this.onRender(mgr.el);
35895 this.visible = true;
35896 this.collapsed = false;
35897 this.unrendered_panels = [];
35900 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35902 position: '', // set by wrapper (eg. north/south etc..)
35903 unrendered_panels : null, // unrendered panels.
35904 createBody : function(){
35905 /** This region's body element
35906 * @type Roo.Element */
35907 this.bodyEl = this.el.createChild({
35909 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35913 onRender: function(ctr, pos)
35915 var dh = Roo.DomHelper;
35916 /** This region's container element
35917 * @type Roo.Element */
35918 this.el = dh.append(ctr.dom, {
35920 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35922 /** This region's title element
35923 * @type Roo.Element */
35925 this.titleEl = dh.append(this.el.dom,
35928 unselectable: "on",
35929 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35931 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35932 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35935 this.titleEl.enableDisplayMode();
35936 /** This region's title text element
35937 * @type HTMLElement */
35938 this.titleTextEl = this.titleEl.dom.firstChild;
35939 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35941 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35942 this.closeBtn.enableDisplayMode();
35943 this.closeBtn.on("click", this.closeClicked, this);
35944 this.closeBtn.hide();
35946 this.createBody(this.config);
35947 if(this.config.hideWhenEmpty){
35949 this.on("paneladded", this.validateVisibility, this);
35950 this.on("panelremoved", this.validateVisibility, this);
35952 if(this.autoScroll){
35953 this.bodyEl.setStyle("overflow", "auto");
35955 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35957 //if(c.titlebar !== false){
35958 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35959 this.titleEl.hide();
35961 this.titleEl.show();
35962 if(this.config.title){
35963 this.titleTextEl.innerHTML = this.config.title;
35967 if(this.config.collapsed){
35968 this.collapse(true);
35970 if(this.config.hidden){
35974 if (this.unrendered_panels && this.unrendered_panels.length) {
35975 for (var i =0;i< this.unrendered_panels.length; i++) {
35976 this.add(this.unrendered_panels[i]);
35978 this.unrendered_panels = null;
35984 applyConfig : function(c)
35987 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35988 var dh = Roo.DomHelper;
35989 if(c.titlebar !== false){
35990 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35991 this.collapseBtn.on("click", this.collapse, this);
35992 this.collapseBtn.enableDisplayMode();
35994 if(c.showPin === true || this.showPin){
35995 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35996 this.stickBtn.enableDisplayMode();
35997 this.stickBtn.on("click", this.expand, this);
35998 this.stickBtn.hide();
36003 /** This region's collapsed element
36004 * @type Roo.Element */
36007 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36008 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36011 if(c.floatable !== false){
36012 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36013 this.collapsedEl.on("click", this.collapseClick, this);
36016 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36017 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36018 id: "message", unselectable: "on", style:{"float":"left"}});
36019 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36021 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36022 this.expandBtn.on("click", this.expand, this);
36026 if(this.collapseBtn){
36027 this.collapseBtn.setVisible(c.collapsible == true);
36030 this.cmargins = c.cmargins || this.cmargins ||
36031 (this.position == "west" || this.position == "east" ?
36032 {top: 0, left: 2, right:2, bottom: 0} :
36033 {top: 2, left: 0, right:0, bottom: 2});
36035 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36038 this.bottomTabs = c.tabPosition != "top";
36040 this.autoScroll = c.autoScroll || false;
36045 this.duration = c.duration || .30;
36046 this.slideDuration = c.slideDuration || .45;
36051 * Returns true if this region is currently visible.
36052 * @return {Boolean}
36054 isVisible : function(){
36055 return this.visible;
36059 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36060 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36062 //setCollapsedTitle : function(title){
36063 // title = title || " ";
36064 // if(this.collapsedTitleTextEl){
36065 // this.collapsedTitleTextEl.innerHTML = title;
36069 getBox : function(){
36071 // if(!this.collapsed){
36072 b = this.el.getBox(false, true);
36074 // b = this.collapsedEl.getBox(false, true);
36079 getMargins : function(){
36080 return this.margins;
36081 //return this.collapsed ? this.cmargins : this.margins;
36084 highlight : function(){
36085 this.el.addClass("x-layout-panel-dragover");
36088 unhighlight : function(){
36089 this.el.removeClass("x-layout-panel-dragover");
36092 updateBox : function(box)
36094 if (!this.bodyEl) {
36095 return; // not rendered yet..
36099 if(!this.collapsed){
36100 this.el.dom.style.left = box.x + "px";
36101 this.el.dom.style.top = box.y + "px";
36102 this.updateBody(box.width, box.height);
36104 this.collapsedEl.dom.style.left = box.x + "px";
36105 this.collapsedEl.dom.style.top = box.y + "px";
36106 this.collapsedEl.setSize(box.width, box.height);
36109 this.tabs.autoSizeTabs();
36113 updateBody : function(w, h)
36116 this.el.setWidth(w);
36117 w -= this.el.getBorderWidth("rl");
36118 if(this.config.adjustments){
36119 w += this.config.adjustments[0];
36122 if(h !== null && h > 0){
36123 this.el.setHeight(h);
36124 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36125 h -= this.el.getBorderWidth("tb");
36126 if(this.config.adjustments){
36127 h += this.config.adjustments[1];
36129 this.bodyEl.setHeight(h);
36131 h = this.tabs.syncHeight(h);
36134 if(this.panelSize){
36135 w = w !== null ? w : this.panelSize.width;
36136 h = h !== null ? h : this.panelSize.height;
36138 if(this.activePanel){
36139 var el = this.activePanel.getEl();
36140 w = w !== null ? w : el.getWidth();
36141 h = h !== null ? h : el.getHeight();
36142 this.panelSize = {width: w, height: h};
36143 this.activePanel.setSize(w, h);
36145 if(Roo.isIE && this.tabs){
36146 this.tabs.el.repaint();
36151 * Returns the container element for this region.
36152 * @return {Roo.Element}
36154 getEl : function(){
36159 * Hides this region.
36162 //if(!this.collapsed){
36163 this.el.dom.style.left = "-2000px";
36166 // this.collapsedEl.dom.style.left = "-2000px";
36167 // this.collapsedEl.hide();
36169 this.visible = false;
36170 this.fireEvent("visibilitychange", this, false);
36174 * Shows this region if it was previously hidden.
36177 //if(!this.collapsed){
36180 // this.collapsedEl.show();
36182 this.visible = true;
36183 this.fireEvent("visibilitychange", this, true);
36186 closeClicked : function(){
36187 if(this.activePanel){
36188 this.remove(this.activePanel);
36192 collapseClick : function(e){
36194 e.stopPropagation();
36197 e.stopPropagation();
36203 * Collapses this region.
36204 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36207 collapse : function(skipAnim, skipCheck = false){
36208 if(this.collapsed) {
36212 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36214 this.collapsed = true;
36216 this.split.el.hide();
36218 if(this.config.animate && skipAnim !== true){
36219 this.fireEvent("invalidated", this);
36220 this.animateCollapse();
36222 this.el.setLocation(-20000,-20000);
36224 this.collapsedEl.show();
36225 this.fireEvent("collapsed", this);
36226 this.fireEvent("invalidated", this);
36232 animateCollapse : function(){
36237 * Expands this region if it was previously collapsed.
36238 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36239 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36242 expand : function(e, skipAnim){
36244 e.stopPropagation();
36246 if(!this.collapsed || this.el.hasActiveFx()) {
36250 this.afterSlideIn();
36253 this.collapsed = false;
36254 if(this.config.animate && skipAnim !== true){
36255 this.animateExpand();
36259 this.split.el.show();
36261 this.collapsedEl.setLocation(-2000,-2000);
36262 this.collapsedEl.hide();
36263 this.fireEvent("invalidated", this);
36264 this.fireEvent("expanded", this);
36268 animateExpand : function(){
36272 initTabs : function()
36274 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36276 var ts = new Roo.bootstrap.panel.Tabs({
36277 el: this.bodyEl.dom,
36278 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36279 disableTooltips: this.config.disableTabTips,
36280 toolbar : this.config.toolbar
36283 if(this.config.hideTabs){
36284 ts.stripWrap.setDisplayed(false);
36287 ts.resizeTabs = this.config.resizeTabs === true;
36288 ts.minTabWidth = this.config.minTabWidth || 40;
36289 ts.maxTabWidth = this.config.maxTabWidth || 250;
36290 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36291 ts.monitorResize = false;
36292 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36293 ts.bodyEl.addClass('roo-layout-tabs-body');
36294 this.panels.each(this.initPanelAsTab, this);
36297 initPanelAsTab : function(panel){
36298 var ti = this.tabs.addTab(
36302 this.config.closeOnTab && panel.isClosable(),
36305 if(panel.tabTip !== undefined){
36306 ti.setTooltip(panel.tabTip);
36308 ti.on("activate", function(){
36309 this.setActivePanel(panel);
36312 if(this.config.closeOnTab){
36313 ti.on("beforeclose", function(t, e){
36315 this.remove(panel);
36319 panel.tabItem = ti;
36324 updatePanelTitle : function(panel, title)
36326 if(this.activePanel == panel){
36327 this.updateTitle(title);
36330 var ti = this.tabs.getTab(panel.getEl().id);
36332 if(panel.tabTip !== undefined){
36333 ti.setTooltip(panel.tabTip);
36338 updateTitle : function(title){
36339 if(this.titleTextEl && !this.config.title){
36340 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36344 setActivePanel : function(panel)
36346 panel = this.getPanel(panel);
36347 if(this.activePanel && this.activePanel != panel){
36348 if(this.activePanel.setActiveState(false) === false){
36352 this.activePanel = panel;
36353 panel.setActiveState(true);
36354 if(this.panelSize){
36355 panel.setSize(this.panelSize.width, this.panelSize.height);
36358 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36360 this.updateTitle(panel.getTitle());
36362 this.fireEvent("invalidated", this);
36364 this.fireEvent("panelactivated", this, panel);
36368 * Shows the specified panel.
36369 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36370 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36372 showPanel : function(panel)
36374 panel = this.getPanel(panel);
36377 var tab = this.tabs.getTab(panel.getEl().id);
36378 if(tab.isHidden()){
36379 this.tabs.unhideTab(tab.id);
36383 this.setActivePanel(panel);
36390 * Get the active panel for this region.
36391 * @return {Roo.ContentPanel} The active panel or null
36393 getActivePanel : function(){
36394 return this.activePanel;
36397 validateVisibility : function(){
36398 if(this.panels.getCount() < 1){
36399 this.updateTitle(" ");
36400 this.closeBtn.hide();
36403 if(!this.isVisible()){
36410 * Adds the passed ContentPanel(s) to this region.
36411 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36412 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36414 add : function(panel)
36416 if(arguments.length > 1){
36417 for(var i = 0, len = arguments.length; i < len; i++) {
36418 this.add(arguments[i]);
36423 // if we have not been rendered yet, then we can not really do much of this..
36424 if (!this.bodyEl) {
36425 this.unrendered_panels.push(panel);
36432 if(this.hasPanel(panel)){
36433 this.showPanel(panel);
36436 panel.setRegion(this);
36437 this.panels.add(panel);
36438 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36439 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36440 // and hide them... ???
36441 this.bodyEl.dom.appendChild(panel.getEl().dom);
36442 if(panel.background !== true){
36443 this.setActivePanel(panel);
36445 this.fireEvent("paneladded", this, panel);
36452 this.initPanelAsTab(panel);
36456 if(panel.background !== true){
36457 this.tabs.activate(panel.getEl().id);
36459 this.fireEvent("paneladded", this, panel);
36464 * Hides the tab for the specified panel.
36465 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36467 hidePanel : function(panel){
36468 if(this.tabs && (panel = this.getPanel(panel))){
36469 this.tabs.hideTab(panel.getEl().id);
36474 * Unhides the tab for a previously hidden panel.
36475 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36477 unhidePanel : function(panel){
36478 if(this.tabs && (panel = this.getPanel(panel))){
36479 this.tabs.unhideTab(panel.getEl().id);
36483 clearPanels : function(){
36484 while(this.panels.getCount() > 0){
36485 this.remove(this.panels.first());
36490 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36491 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36492 * @param {Boolean} preservePanel Overrides the config preservePanel option
36493 * @return {Roo.ContentPanel} The panel that was removed
36495 remove : function(panel, preservePanel)
36497 panel = this.getPanel(panel);
36502 this.fireEvent("beforeremove", this, panel, e);
36503 if(e.cancel === true){
36506 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36507 var panelId = panel.getId();
36508 this.panels.removeKey(panelId);
36510 document.body.appendChild(panel.getEl().dom);
36513 this.tabs.removeTab(panel.getEl().id);
36514 }else if (!preservePanel){
36515 this.bodyEl.dom.removeChild(panel.getEl().dom);
36517 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36518 var p = this.panels.first();
36519 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36520 tempEl.appendChild(p.getEl().dom);
36521 this.bodyEl.update("");
36522 this.bodyEl.dom.appendChild(p.getEl().dom);
36524 this.updateTitle(p.getTitle());
36526 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36527 this.setActivePanel(p);
36529 panel.setRegion(null);
36530 if(this.activePanel == panel){
36531 this.activePanel = null;
36533 if(this.config.autoDestroy !== false && preservePanel !== true){
36534 try{panel.destroy();}catch(e){}
36536 this.fireEvent("panelremoved", this, panel);
36541 * Returns the TabPanel component used by this region
36542 * @return {Roo.TabPanel}
36544 getTabs : function(){
36548 createTool : function(parentEl, className){
36549 var btn = Roo.DomHelper.append(parentEl, {
36551 cls: "x-layout-tools-button",
36554 cls: "roo-layout-tools-button-inner " + className,
36558 btn.addClassOnOver("roo-layout-tools-button-over");
36563 * Ext JS Library 1.1.1
36564 * Copyright(c) 2006-2007, Ext JS, LLC.
36566 * Originally Released Under LGPL - original licence link has changed is not relivant.
36569 * <script type="text/javascript">
36575 * @class Roo.SplitLayoutRegion
36576 * @extends Roo.LayoutRegion
36577 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36579 Roo.bootstrap.layout.Split = function(config){
36580 this.cursor = config.cursor;
36581 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36584 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36586 splitTip : "Drag to resize.",
36587 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36588 useSplitTips : false,
36590 applyConfig : function(config){
36591 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36594 onRender : function(ctr,pos) {
36596 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36597 if(!this.config.split){
36602 var splitEl = Roo.DomHelper.append(ctr.dom, {
36604 id: this.el.id + "-split",
36605 cls: "roo-layout-split roo-layout-split-"+this.position,
36608 /** The SplitBar for this region
36609 * @type Roo.SplitBar */
36610 // does not exist yet...
36611 Roo.log([this.position, this.orientation]);
36613 this.split = new Roo.bootstrap.SplitBar({
36614 dragElement : splitEl,
36615 resizingElement: this.el,
36616 orientation : this.orientation
36619 this.split.on("moved", this.onSplitMove, this);
36620 this.split.useShim = this.config.useShim === true;
36621 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36622 if(this.useSplitTips){
36623 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36625 //if(config.collapsible){
36626 // this.split.el.on("dblclick", this.collapse, this);
36629 if(typeof this.config.minSize != "undefined"){
36630 this.split.minSize = this.config.minSize;
36632 if(typeof this.config.maxSize != "undefined"){
36633 this.split.maxSize = this.config.maxSize;
36635 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36636 this.hideSplitter();
36641 getHMaxSize : function(){
36642 var cmax = this.config.maxSize || 10000;
36643 var center = this.mgr.getRegion("center");
36644 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36647 getVMaxSize : function(){
36648 var cmax = this.config.maxSize || 10000;
36649 var center = this.mgr.getRegion("center");
36650 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36653 onSplitMove : function(split, newSize){
36654 this.fireEvent("resized", this, newSize);
36658 * Returns the {@link Roo.SplitBar} for this region.
36659 * @return {Roo.SplitBar}
36661 getSplitBar : function(){
36666 this.hideSplitter();
36667 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36670 hideSplitter : function(){
36672 this.split.el.setLocation(-2000,-2000);
36673 this.split.el.hide();
36679 this.split.el.show();
36681 Roo.bootstrap.layout.Split.superclass.show.call(this);
36684 beforeSlide: function(){
36685 if(Roo.isGecko){// firefox overflow auto bug workaround
36686 this.bodyEl.clip();
36688 this.tabs.bodyEl.clip();
36690 if(this.activePanel){
36691 this.activePanel.getEl().clip();
36693 if(this.activePanel.beforeSlide){
36694 this.activePanel.beforeSlide();
36700 afterSlide : function(){
36701 if(Roo.isGecko){// firefox overflow auto bug workaround
36702 this.bodyEl.unclip();
36704 this.tabs.bodyEl.unclip();
36706 if(this.activePanel){
36707 this.activePanel.getEl().unclip();
36708 if(this.activePanel.afterSlide){
36709 this.activePanel.afterSlide();
36715 initAutoHide : function(){
36716 if(this.autoHide !== false){
36717 if(!this.autoHideHd){
36718 var st = new Roo.util.DelayedTask(this.slideIn, this);
36719 this.autoHideHd = {
36720 "mouseout": function(e){
36721 if(!e.within(this.el, true)){
36725 "mouseover" : function(e){
36731 this.el.on(this.autoHideHd);
36735 clearAutoHide : function(){
36736 if(this.autoHide !== false){
36737 this.el.un("mouseout", this.autoHideHd.mouseout);
36738 this.el.un("mouseover", this.autoHideHd.mouseover);
36742 clearMonitor : function(){
36743 Roo.get(document).un("click", this.slideInIf, this);
36746 // these names are backwards but not changed for compat
36747 slideOut : function(){
36748 if(this.isSlid || this.el.hasActiveFx()){
36751 this.isSlid = true;
36752 if(this.collapseBtn){
36753 this.collapseBtn.hide();
36755 this.closeBtnState = this.closeBtn.getStyle('display');
36756 this.closeBtn.hide();
36758 this.stickBtn.show();
36761 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36762 this.beforeSlide();
36763 this.el.setStyle("z-index", 10001);
36764 this.el.slideIn(this.getSlideAnchor(), {
36765 callback: function(){
36767 this.initAutoHide();
36768 Roo.get(document).on("click", this.slideInIf, this);
36769 this.fireEvent("slideshow", this);
36776 afterSlideIn : function(){
36777 this.clearAutoHide();
36778 this.isSlid = false;
36779 this.clearMonitor();
36780 this.el.setStyle("z-index", "");
36781 if(this.collapseBtn){
36782 this.collapseBtn.show();
36784 this.closeBtn.setStyle('display', this.closeBtnState);
36786 this.stickBtn.hide();
36788 this.fireEvent("slidehide", this);
36791 slideIn : function(cb){
36792 if(!this.isSlid || this.el.hasActiveFx()){
36796 this.isSlid = false;
36797 this.beforeSlide();
36798 this.el.slideOut(this.getSlideAnchor(), {
36799 callback: function(){
36800 this.el.setLeftTop(-10000, -10000);
36802 this.afterSlideIn();
36810 slideInIf : function(e){
36811 if(!e.within(this.el)){
36816 animateCollapse : function(){
36817 this.beforeSlide();
36818 this.el.setStyle("z-index", 20000);
36819 var anchor = this.getSlideAnchor();
36820 this.el.slideOut(anchor, {
36821 callback : function(){
36822 this.el.setStyle("z-index", "");
36823 this.collapsedEl.slideIn(anchor, {duration:.3});
36825 this.el.setLocation(-10000,-10000);
36827 this.fireEvent("collapsed", this);
36834 animateExpand : function(){
36835 this.beforeSlide();
36836 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36837 this.el.setStyle("z-index", 20000);
36838 this.collapsedEl.hide({
36841 this.el.slideIn(this.getSlideAnchor(), {
36842 callback : function(){
36843 this.el.setStyle("z-index", "");
36846 this.split.el.show();
36848 this.fireEvent("invalidated", this);
36849 this.fireEvent("expanded", this);
36877 getAnchor : function(){
36878 return this.anchors[this.position];
36881 getCollapseAnchor : function(){
36882 return this.canchors[this.position];
36885 getSlideAnchor : function(){
36886 return this.sanchors[this.position];
36889 getAlignAdj : function(){
36890 var cm = this.cmargins;
36891 switch(this.position){
36907 getExpandAdj : function(){
36908 var c = this.collapsedEl, cm = this.cmargins;
36909 switch(this.position){
36911 return [-(cm.right+c.getWidth()+cm.left), 0];
36914 return [cm.right+c.getWidth()+cm.left, 0];
36917 return [0, -(cm.top+cm.bottom+c.getHeight())];
36920 return [0, cm.top+cm.bottom+c.getHeight()];
36926 * Ext JS Library 1.1.1
36927 * Copyright(c) 2006-2007, Ext JS, LLC.
36929 * Originally Released Under LGPL - original licence link has changed is not relivant.
36932 * <script type="text/javascript">
36935 * These classes are private internal classes
36937 Roo.bootstrap.layout.Center = function(config){
36938 config.region = "center";
36939 Roo.bootstrap.layout.Region.call(this, config);
36940 this.visible = true;
36941 this.minWidth = config.minWidth || 20;
36942 this.minHeight = config.minHeight || 20;
36945 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36947 // center panel can't be hidden
36951 // center panel can't be hidden
36954 getMinWidth: function(){
36955 return this.minWidth;
36958 getMinHeight: function(){
36959 return this.minHeight;
36972 Roo.bootstrap.layout.North = function(config)
36974 config.region = 'north';
36975 config.cursor = 'n-resize';
36977 Roo.bootstrap.layout.Split.call(this, config);
36981 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36982 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36983 this.split.el.addClass("roo-layout-split-v");
36985 var size = config.initialSize || config.height;
36986 if(typeof size != "undefined"){
36987 this.el.setHeight(size);
36990 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36992 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36996 getBox : function(){
36997 if(this.collapsed){
36998 return this.collapsedEl.getBox();
37000 var box = this.el.getBox();
37002 box.height += this.split.el.getHeight();
37007 updateBox : function(box){
37008 if(this.split && !this.collapsed){
37009 box.height -= this.split.el.getHeight();
37010 this.split.el.setLeft(box.x);
37011 this.split.el.setTop(box.y+box.height);
37012 this.split.el.setWidth(box.width);
37014 if(this.collapsed){
37015 this.updateBody(box.width, null);
37017 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37025 Roo.bootstrap.layout.South = function(config){
37026 config.region = 'south';
37027 config.cursor = 's-resize';
37028 Roo.bootstrap.layout.Split.call(this, config);
37030 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37031 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37032 this.split.el.addClass("roo-layout-split-v");
37034 var size = config.initialSize || config.height;
37035 if(typeof size != "undefined"){
37036 this.el.setHeight(size);
37040 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37041 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37042 getBox : function(){
37043 if(this.collapsed){
37044 return this.collapsedEl.getBox();
37046 var box = this.el.getBox();
37048 var sh = this.split.el.getHeight();
37055 updateBox : function(box){
37056 if(this.split && !this.collapsed){
37057 var sh = this.split.el.getHeight();
37060 this.split.el.setLeft(box.x);
37061 this.split.el.setTop(box.y-sh);
37062 this.split.el.setWidth(box.width);
37064 if(this.collapsed){
37065 this.updateBody(box.width, null);
37067 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37071 Roo.bootstrap.layout.East = function(config){
37072 config.region = "east";
37073 config.cursor = "e-resize";
37074 Roo.bootstrap.layout.Split.call(this, config);
37076 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37077 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37078 this.split.el.addClass("roo-layout-split-h");
37080 var size = config.initialSize || config.width;
37081 if(typeof size != "undefined"){
37082 this.el.setWidth(size);
37085 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37086 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37087 getBox : function(){
37088 if(this.collapsed){
37089 return this.collapsedEl.getBox();
37091 var box = this.el.getBox();
37093 var sw = this.split.el.getWidth();
37100 updateBox : function(box){
37101 if(this.split && !this.collapsed){
37102 var sw = this.split.el.getWidth();
37104 this.split.el.setLeft(box.x);
37105 this.split.el.setTop(box.y);
37106 this.split.el.setHeight(box.height);
37109 if(this.collapsed){
37110 this.updateBody(null, box.height);
37112 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37116 Roo.bootstrap.layout.West = function(config){
37117 config.region = "west";
37118 config.cursor = "w-resize";
37120 Roo.bootstrap.layout.Split.call(this, config);
37122 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37123 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37124 this.split.el.addClass("roo-layout-split-h");
37128 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37129 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37131 onRender: function(ctr, pos)
37133 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37134 var size = this.config.initialSize || this.config.width;
37135 if(typeof size != "undefined"){
37136 this.el.setWidth(size);
37140 getBox : function(){
37141 if(this.collapsed){
37142 return this.collapsedEl.getBox();
37144 var box = this.el.getBox();
37146 box.width += this.split.el.getWidth();
37151 updateBox : function(box){
37152 if(this.split && !this.collapsed){
37153 var sw = this.split.el.getWidth();
37155 this.split.el.setLeft(box.x+box.width);
37156 this.split.el.setTop(box.y);
37157 this.split.el.setHeight(box.height);
37159 if(this.collapsed){
37160 this.updateBody(null, box.height);
37162 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37165 Roo.namespace("Roo.bootstrap.panel");/*
37167 * Ext JS Library 1.1.1
37168 * Copyright(c) 2006-2007, Ext JS, LLC.
37170 * Originally Released Under LGPL - original licence link has changed is not relivant.
37173 * <script type="text/javascript">
37176 * @class Roo.ContentPanel
37177 * @extends Roo.util.Observable
37178 * A basic ContentPanel element.
37179 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37180 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37181 * @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
37182 * @cfg {Boolean} closable True if the panel can be closed/removed
37183 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37184 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37185 * @cfg {Toolbar} toolbar A toolbar for this panel
37186 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37187 * @cfg {String} title The title for this panel
37188 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37189 * @cfg {String} url Calls {@link #setUrl} with this value
37190 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37191 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37192 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37193 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37194 * @cfg {Boolean} badges render the badges
37197 * Create a new ContentPanel.
37198 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37199 * @param {String/Object} config A string to set only the title or a config object
37200 * @param {String} content (optional) Set the HTML content for this panel
37201 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37203 Roo.bootstrap.panel.Content = function( config){
37205 this.tpl = config.tpl || false;
37207 var el = config.el;
37208 var content = config.content;
37210 if(config.autoCreate){ // xtype is available if this is called from factory
37213 this.el = Roo.get(el);
37214 if(!this.el && config && config.autoCreate){
37215 if(typeof config.autoCreate == "object"){
37216 if(!config.autoCreate.id){
37217 config.autoCreate.id = config.id||el;
37219 this.el = Roo.DomHelper.append(document.body,
37220 config.autoCreate, true);
37222 var elcfg = { tag: "div",
37223 cls: "roo-layout-inactive-content",
37227 elcfg.html = config.html;
37231 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37234 this.closable = false;
37235 this.loaded = false;
37236 this.active = false;
37239 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37241 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37243 this.wrapEl = this.el; //this.el.wrap();
37245 if (config.toolbar.items) {
37246 ti = config.toolbar.items ;
37247 delete config.toolbar.items ;
37251 this.toolbar.render(this.wrapEl, 'before');
37252 for(var i =0;i < ti.length;i++) {
37253 // Roo.log(['add child', items[i]]);
37254 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37256 this.toolbar.items = nitems;
37257 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37258 delete config.toolbar;
37262 // xtype created footer. - not sure if will work as we normally have to render first..
37263 if (this.footer && !this.footer.el && this.footer.xtype) {
37264 if (!this.wrapEl) {
37265 this.wrapEl = this.el.wrap();
37268 this.footer.container = this.wrapEl.createChild();
37270 this.footer = Roo.factory(this.footer, Roo);
37275 if(typeof config == "string"){
37276 this.title = config;
37278 Roo.apply(this, config);
37282 this.resizeEl = Roo.get(this.resizeEl, true);
37284 this.resizeEl = this.el;
37286 // handle view.xtype
37294 * Fires when this panel is activated.
37295 * @param {Roo.ContentPanel} this
37299 * @event deactivate
37300 * Fires when this panel is activated.
37301 * @param {Roo.ContentPanel} this
37303 "deactivate" : true,
37307 * Fires when this panel is resized if fitToFrame is true.
37308 * @param {Roo.ContentPanel} this
37309 * @param {Number} width The width after any component adjustments
37310 * @param {Number} height The height after any component adjustments
37316 * Fires when this tab is created
37317 * @param {Roo.ContentPanel} this
37328 if(this.autoScroll){
37329 this.resizeEl.setStyle("overflow", "auto");
37331 // fix randome scrolling
37332 //this.el.on('scroll', function() {
37333 // Roo.log('fix random scolling');
37334 // this.scrollTo('top',0);
37337 content = content || this.content;
37339 this.setContent(content);
37341 if(config && config.url){
37342 this.setUrl(this.url, this.params, this.loadOnce);
37347 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37349 if (this.view && typeof(this.view.xtype) != 'undefined') {
37350 this.view.el = this.el.appendChild(document.createElement("div"));
37351 this.view = Roo.factory(this.view);
37352 this.view.render && this.view.render(false, '');
37356 this.fireEvent('render', this);
37359 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37363 setRegion : function(region){
37364 this.region = region;
37365 this.setActiveClass(region && !this.background);
37369 setActiveClass: function(state)
37372 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37373 this.el.setStyle('position','relative');
37375 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37376 this.el.setStyle('position', 'absolute');
37381 * Returns the toolbar for this Panel if one was configured.
37382 * @return {Roo.Toolbar}
37384 getToolbar : function(){
37385 return this.toolbar;
37388 setActiveState : function(active)
37390 this.active = active;
37391 this.setActiveClass(active);
37393 if(this.fireEvent("deactivate", this) === false){
37398 this.fireEvent("activate", this);
37402 * Updates this panel's element
37403 * @param {String} content The new content
37404 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37406 setContent : function(content, loadScripts){
37407 this.el.update(content, loadScripts);
37410 ignoreResize : function(w, h){
37411 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37414 this.lastSize = {width: w, height: h};
37419 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37420 * @return {Roo.UpdateManager} The UpdateManager
37422 getUpdateManager : function(){
37423 return this.el.getUpdateManager();
37426 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37427 * @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:
37430 url: "your-url.php",
37431 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37432 callback: yourFunction,
37433 scope: yourObject, //(optional scope)
37436 text: "Loading...",
37441 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37442 * 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.
37443 * @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}
37444 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37445 * @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.
37446 * @return {Roo.ContentPanel} this
37449 var um = this.el.getUpdateManager();
37450 um.update.apply(um, arguments);
37456 * 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.
37457 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37458 * @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)
37459 * @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)
37460 * @return {Roo.UpdateManager} The UpdateManager
37462 setUrl : function(url, params, loadOnce){
37463 if(this.refreshDelegate){
37464 this.removeListener("activate", this.refreshDelegate);
37466 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37467 this.on("activate", this.refreshDelegate);
37468 return this.el.getUpdateManager();
37471 _handleRefresh : function(url, params, loadOnce){
37472 if(!loadOnce || !this.loaded){
37473 var updater = this.el.getUpdateManager();
37474 updater.update(url, params, this._setLoaded.createDelegate(this));
37478 _setLoaded : function(){
37479 this.loaded = true;
37483 * Returns this panel's id
37486 getId : function(){
37491 * Returns this panel's element - used by regiosn to add.
37492 * @return {Roo.Element}
37494 getEl : function(){
37495 return this.wrapEl || this.el;
37500 adjustForComponents : function(width, height)
37502 //Roo.log('adjustForComponents ');
37503 if(this.resizeEl != this.el){
37504 width -= this.el.getFrameWidth('lr');
37505 height -= this.el.getFrameWidth('tb');
37508 var te = this.toolbar.getEl();
37509 te.setWidth(width);
37510 height -= te.getHeight();
37513 var te = this.footer.getEl();
37514 te.setWidth(width);
37515 height -= te.getHeight();
37519 if(this.adjustments){
37520 width += this.adjustments[0];
37521 height += this.adjustments[1];
37523 return {"width": width, "height": height};
37526 setSize : function(width, height){
37527 if(this.fitToFrame && !this.ignoreResize(width, height)){
37528 if(this.fitContainer && this.resizeEl != this.el){
37529 this.el.setSize(width, height);
37531 var size = this.adjustForComponents(width, height);
37532 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37533 this.fireEvent('resize', this, size.width, size.height);
37538 * Returns this panel's title
37541 getTitle : function(){
37543 if (typeof(this.title) != 'object') {
37548 for (var k in this.title) {
37549 if (!this.title.hasOwnProperty(k)) {
37553 if (k.indexOf('-') >= 0) {
37554 var s = k.split('-');
37555 for (var i = 0; i<s.length; i++) {
37556 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37559 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37566 * Set this panel's title
37567 * @param {String} title
37569 setTitle : function(title){
37570 this.title = title;
37572 this.region.updatePanelTitle(this, title);
37577 * Returns true is this panel was configured to be closable
37578 * @return {Boolean}
37580 isClosable : function(){
37581 return this.closable;
37584 beforeSlide : function(){
37586 this.resizeEl.clip();
37589 afterSlide : function(){
37591 this.resizeEl.unclip();
37595 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37596 * Will fail silently if the {@link #setUrl} method has not been called.
37597 * This does not activate the panel, just updates its content.
37599 refresh : function(){
37600 if(this.refreshDelegate){
37601 this.loaded = false;
37602 this.refreshDelegate();
37607 * Destroys this panel
37609 destroy : function(){
37610 this.el.removeAllListeners();
37611 var tempEl = document.createElement("span");
37612 tempEl.appendChild(this.el.dom);
37613 tempEl.innerHTML = "";
37619 * form - if the content panel contains a form - this is a reference to it.
37620 * @type {Roo.form.Form}
37624 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37625 * This contains a reference to it.
37631 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37641 * @param {Object} cfg Xtype definition of item to add.
37645 getChildContainer: function () {
37646 return this.getEl();
37651 var ret = new Roo.factory(cfg);
37656 if (cfg.xtype.match(/^Form$/)) {
37659 //if (this.footer) {
37660 // el = this.footer.container.insertSibling(false, 'before');
37662 el = this.el.createChild();
37665 this.form = new Roo.form.Form(cfg);
37668 if ( this.form.allItems.length) {
37669 this.form.render(el.dom);
37673 // should only have one of theses..
37674 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37675 // views.. should not be just added - used named prop 'view''
37677 cfg.el = this.el.appendChild(document.createElement("div"));
37680 var ret = new Roo.factory(cfg);
37682 ret.render && ret.render(false, ''); // render blank..
37692 * @class Roo.bootstrap.panel.Grid
37693 * @extends Roo.bootstrap.panel.Content
37695 * Create a new GridPanel.
37696 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37697 * @param {Object} config A the config object
37703 Roo.bootstrap.panel.Grid = function(config)
37707 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37708 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37710 config.el = this.wrapper;
37711 //this.el = this.wrapper;
37713 if (config.container) {
37714 // ctor'ed from a Border/panel.grid
37717 this.wrapper.setStyle("overflow", "hidden");
37718 this.wrapper.addClass('roo-grid-container');
37723 if(config.toolbar){
37724 var tool_el = this.wrapper.createChild();
37725 this.toolbar = Roo.factory(config.toolbar);
37727 if (config.toolbar.items) {
37728 ti = config.toolbar.items ;
37729 delete config.toolbar.items ;
37733 this.toolbar.render(tool_el);
37734 for(var i =0;i < ti.length;i++) {
37735 // Roo.log(['add child', items[i]]);
37736 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37738 this.toolbar.items = nitems;
37740 delete config.toolbar;
37743 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37744 config.grid.scrollBody = true;;
37745 config.grid.monitorWindowResize = false; // turn off autosizing
37746 config.grid.autoHeight = false;
37747 config.grid.autoWidth = false;
37749 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37751 if (config.background) {
37752 // render grid on panel activation (if panel background)
37753 this.on('activate', function(gp) {
37754 if (!gp.grid.rendered) {
37755 gp.grid.render(this.wrapper);
37756 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37761 this.grid.render(this.wrapper);
37762 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37765 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37766 // ??? needed ??? config.el = this.wrapper;
37771 // xtype created footer. - not sure if will work as we normally have to render first..
37772 if (this.footer && !this.footer.el && this.footer.xtype) {
37774 var ctr = this.grid.getView().getFooterPanel(true);
37775 this.footer.dataSource = this.grid.dataSource;
37776 this.footer = Roo.factory(this.footer, Roo);
37777 this.footer.render(ctr);
37787 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37788 getId : function(){
37789 return this.grid.id;
37793 * Returns the grid for this panel
37794 * @return {Roo.bootstrap.Table}
37796 getGrid : function(){
37800 setSize : function(width, height){
37801 if(!this.ignoreResize(width, height)){
37802 var grid = this.grid;
37803 var size = this.adjustForComponents(width, height);
37804 var gridel = grid.getGridEl();
37805 gridel.setSize(size.width, size.height);
37807 var thd = grid.getGridEl().select('thead',true).first();
37808 var tbd = grid.getGridEl().select('tbody', true).first();
37810 tbd.setSize(width, height - thd.getHeight());
37819 beforeSlide : function(){
37820 this.grid.getView().scroller.clip();
37823 afterSlide : function(){
37824 this.grid.getView().scroller.unclip();
37827 destroy : function(){
37828 this.grid.destroy();
37830 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37835 * @class Roo.bootstrap.panel.Nest
37836 * @extends Roo.bootstrap.panel.Content
37838 * Create a new Panel, that can contain a layout.Border.
37841 * @param {Roo.BorderLayout} layout The layout for this panel
37842 * @param {String/Object} config A string to set only the title or a config object
37844 Roo.bootstrap.panel.Nest = function(config)
37846 // construct with only one argument..
37847 /* FIXME - implement nicer consturctors
37848 if (layout.layout) {
37850 layout = config.layout;
37851 delete config.layout;
37853 if (layout.xtype && !layout.getEl) {
37854 // then layout needs constructing..
37855 layout = Roo.factory(layout, Roo);
37859 config.el = config.layout.getEl();
37861 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37863 config.layout.monitorWindowResize = false; // turn off autosizing
37864 this.layout = config.layout;
37865 this.layout.getEl().addClass("roo-layout-nested-layout");
37872 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37874 setSize : function(width, height){
37875 if(!this.ignoreResize(width, height)){
37876 var size = this.adjustForComponents(width, height);
37877 var el = this.layout.getEl();
37878 if (size.height < 1) {
37879 el.setWidth(size.width);
37881 el.setSize(size.width, size.height);
37883 var touch = el.dom.offsetWidth;
37884 this.layout.layout();
37885 // ie requires a double layout on the first pass
37886 if(Roo.isIE && !this.initialized){
37887 this.initialized = true;
37888 this.layout.layout();
37893 // activate all subpanels if not currently active..
37895 setActiveState : function(active){
37896 this.active = active;
37897 this.setActiveClass(active);
37900 this.fireEvent("deactivate", this);
37904 this.fireEvent("activate", this);
37905 // not sure if this should happen before or after..
37906 if (!this.layout) {
37907 return; // should not happen..
37910 for (var r in this.layout.regions) {
37911 reg = this.layout.getRegion(r);
37912 if (reg.getActivePanel()) {
37913 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37914 reg.setActivePanel(reg.getActivePanel());
37917 if (!reg.panels.length) {
37920 reg.showPanel(reg.getPanel(0));
37929 * Returns the nested BorderLayout for this panel
37930 * @return {Roo.BorderLayout}
37932 getLayout : function(){
37933 return this.layout;
37937 * Adds a xtype elements to the layout of the nested panel
37941 xtype : 'ContentPanel',
37948 xtype : 'NestedLayoutPanel',
37954 items : [ ... list of content panels or nested layout panels.. ]
37958 * @param {Object} cfg Xtype definition of item to add.
37960 addxtype : function(cfg) {
37961 return this.layout.addxtype(cfg);
37966 * Ext JS Library 1.1.1
37967 * Copyright(c) 2006-2007, Ext JS, LLC.
37969 * Originally Released Under LGPL - original licence link has changed is not relivant.
37972 * <script type="text/javascript">
37975 * @class Roo.TabPanel
37976 * @extends Roo.util.Observable
37977 * A lightweight tab container.
37981 // basic tabs 1, built from existing content
37982 var tabs = new Roo.TabPanel("tabs1");
37983 tabs.addTab("script", "View Script");
37984 tabs.addTab("markup", "View Markup");
37985 tabs.activate("script");
37987 // more advanced tabs, built from javascript
37988 var jtabs = new Roo.TabPanel("jtabs");
37989 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37991 // set up the UpdateManager
37992 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37993 var updater = tab2.getUpdateManager();
37994 updater.setDefaultUrl("ajax1.htm");
37995 tab2.on('activate', updater.refresh, updater, true);
37997 // Use setUrl for Ajax loading
37998 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37999 tab3.setUrl("ajax2.htm", null, true);
38002 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38005 jtabs.activate("jtabs-1");
38008 * Create a new TabPanel.
38009 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38010 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38012 Roo.bootstrap.panel.Tabs = function(config){
38014 * The container element for this TabPanel.
38015 * @type Roo.Element
38017 this.el = Roo.get(config.el);
38020 if(typeof config == "boolean"){
38021 this.tabPosition = config ? "bottom" : "top";
38023 Roo.apply(this, config);
38027 if(this.tabPosition == "bottom"){
38028 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38029 this.el.addClass("roo-tabs-bottom");
38031 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38032 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38033 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38034 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38036 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38038 if(this.tabPosition != "bottom"){
38039 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38040 * @type Roo.Element
38042 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38043 this.el.addClass("roo-tabs-top");
38047 this.bodyEl.setStyle("position", "relative");
38049 this.active = null;
38050 this.activateDelegate = this.activate.createDelegate(this);
38055 * Fires when the active tab changes
38056 * @param {Roo.TabPanel} this
38057 * @param {Roo.TabPanelItem} activePanel The new active tab
38061 * @event beforetabchange
38062 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38063 * @param {Roo.TabPanel} this
38064 * @param {Object} e Set cancel to true on this object to cancel the tab change
38065 * @param {Roo.TabPanelItem} tab The tab being changed to
38067 "beforetabchange" : true
38070 Roo.EventManager.onWindowResize(this.onResize, this);
38071 this.cpad = this.el.getPadding("lr");
38072 this.hiddenCount = 0;
38075 // toolbar on the tabbar support...
38076 if (this.toolbar) {
38077 alert("no toolbar support yet");
38078 this.toolbar = false;
38080 var tcfg = this.toolbar;
38081 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38082 this.toolbar = new Roo.Toolbar(tcfg);
38083 if (Roo.isSafari) {
38084 var tbl = tcfg.container.child('table', true);
38085 tbl.setAttribute('width', '100%');
38093 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38096 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38098 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38100 tabPosition : "top",
38102 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38104 currentTabWidth : 0,
38106 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38110 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38114 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38116 preferredTabWidth : 175,
38118 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38120 resizeTabs : false,
38122 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38124 monitorResize : true,
38126 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38131 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38132 * @param {String} id The id of the div to use <b>or create</b>
38133 * @param {String} text The text for the tab
38134 * @param {String} content (optional) Content to put in the TabPanelItem body
38135 * @param {Boolean} closable (optional) True to create a close icon on the tab
38136 * @return {Roo.TabPanelItem} The created TabPanelItem
38138 addTab : function(id, text, content, closable, tpl)
38140 var item = new Roo.bootstrap.panel.TabItem({
38144 closable : closable,
38147 this.addTabItem(item);
38149 item.setContent(content);
38155 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38156 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38157 * @return {Roo.TabPanelItem}
38159 getTab : function(id){
38160 return this.items[id];
38164 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38165 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38167 hideTab : function(id){
38168 var t = this.items[id];
38171 this.hiddenCount++;
38172 this.autoSizeTabs();
38177 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38178 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38180 unhideTab : function(id){
38181 var t = this.items[id];
38183 t.setHidden(false);
38184 this.hiddenCount--;
38185 this.autoSizeTabs();
38190 * Adds an existing {@link Roo.TabPanelItem}.
38191 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38193 addTabItem : function(item)
38195 this.items[item.id] = item;
38196 this.items.push(item);
38197 this.autoSizeTabs();
38198 // if(this.resizeTabs){
38199 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38200 // this.autoSizeTabs();
38202 // item.autoSize();
38207 * Removes a {@link Roo.TabPanelItem}.
38208 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38210 removeTab : function(id){
38211 var items = this.items;
38212 var tab = items[id];
38213 if(!tab) { return; }
38214 var index = items.indexOf(tab);
38215 if(this.active == tab && items.length > 1){
38216 var newTab = this.getNextAvailable(index);
38221 this.stripEl.dom.removeChild(tab.pnode.dom);
38222 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38223 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38225 items.splice(index, 1);
38226 delete this.items[tab.id];
38227 tab.fireEvent("close", tab);
38228 tab.purgeListeners();
38229 this.autoSizeTabs();
38232 getNextAvailable : function(start){
38233 var items = this.items;
38235 // look for a next tab that will slide over to
38236 // replace the one being removed
38237 while(index < items.length){
38238 var item = items[++index];
38239 if(item && !item.isHidden()){
38243 // if one isn't found select the previous tab (on the left)
38246 var item = items[--index];
38247 if(item && !item.isHidden()){
38255 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38256 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38258 disableTab : function(id){
38259 var tab = this.items[id];
38260 if(tab && this.active != tab){
38266 * Enables a {@link Roo.TabPanelItem} that is disabled.
38267 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38269 enableTab : function(id){
38270 var tab = this.items[id];
38275 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38276 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38277 * @return {Roo.TabPanelItem} The TabPanelItem.
38279 activate : function(id)
38281 var tab = this.items[id];
38285 if(tab == this.active || tab.disabled){
38289 this.fireEvent("beforetabchange", this, e, tab);
38290 if(e.cancel !== true && !tab.disabled){
38292 this.active.hide();
38294 this.active = this.items[id];
38295 this.active.show();
38296 this.fireEvent("tabchange", this, this.active);
38302 * Gets the active {@link Roo.TabPanelItem}.
38303 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38305 getActiveTab : function(){
38306 return this.active;
38310 * Updates the tab body element to fit the height of the container element
38311 * for overflow scrolling
38312 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38314 syncHeight : function(targetHeight){
38315 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38316 var bm = this.bodyEl.getMargins();
38317 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38318 this.bodyEl.setHeight(newHeight);
38322 onResize : function(){
38323 if(this.monitorResize){
38324 this.autoSizeTabs();
38329 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38331 beginUpdate : function(){
38332 this.updating = true;
38336 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38338 endUpdate : function(){
38339 this.updating = false;
38340 this.autoSizeTabs();
38344 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38346 autoSizeTabs : function()
38348 var count = this.items.length;
38349 var vcount = count - this.hiddenCount;
38352 this.stripEl.hide();
38354 this.stripEl.show();
38357 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38362 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38363 var availWidth = Math.floor(w / vcount);
38364 var b = this.stripBody;
38365 if(b.getWidth() > w){
38366 var tabs = this.items;
38367 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38368 if(availWidth < this.minTabWidth){
38369 /*if(!this.sleft){ // incomplete scrolling code
38370 this.createScrollButtons();
38373 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38376 if(this.currentTabWidth < this.preferredTabWidth){
38377 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38383 * Returns the number of tabs in this TabPanel.
38386 getCount : function(){
38387 return this.items.length;
38391 * Resizes all the tabs to the passed width
38392 * @param {Number} The new width
38394 setTabWidth : function(width){
38395 this.currentTabWidth = width;
38396 for(var i = 0, len = this.items.length; i < len; i++) {
38397 if(!this.items[i].isHidden()) {
38398 this.items[i].setWidth(width);
38404 * Destroys this TabPanel
38405 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38407 destroy : function(removeEl){
38408 Roo.EventManager.removeResizeListener(this.onResize, this);
38409 for(var i = 0, len = this.items.length; i < len; i++){
38410 this.items[i].purgeListeners();
38412 if(removeEl === true){
38413 this.el.update("");
38418 createStrip : function(container)
38420 var strip = document.createElement("nav");
38421 strip.className = Roo.bootstrap.version == 4 ?
38422 "navbar-light bg-light" :
38423 "navbar navbar-default"; //"x-tabs-wrap";
38424 container.appendChild(strip);
38428 createStripList : function(strip)
38430 // div wrapper for retard IE
38431 // returns the "tr" element.
38432 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38433 //'<div class="x-tabs-strip-wrap">'+
38434 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38435 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38436 return strip.firstChild; //.firstChild.firstChild.firstChild;
38438 createBody : function(container)
38440 var body = document.createElement("div");
38441 Roo.id(body, "tab-body");
38442 //Roo.fly(body).addClass("x-tabs-body");
38443 Roo.fly(body).addClass("tab-content");
38444 container.appendChild(body);
38447 createItemBody :function(bodyEl, id){
38448 var body = Roo.getDom(id);
38450 body = document.createElement("div");
38453 //Roo.fly(body).addClass("x-tabs-item-body");
38454 Roo.fly(body).addClass("tab-pane");
38455 bodyEl.insertBefore(body, bodyEl.firstChild);
38459 createStripElements : function(stripEl, text, closable, tpl)
38461 var td = document.createElement("li"); // was td..
38462 td.className = 'nav-item';
38464 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38467 stripEl.appendChild(td);
38469 td.className = "x-tabs-closable";
38470 if(!this.closeTpl){
38471 this.closeTpl = new Roo.Template(
38472 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38473 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38474 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38477 var el = this.closeTpl.overwrite(td, {"text": text});
38478 var close = el.getElementsByTagName("div")[0];
38479 var inner = el.getElementsByTagName("em")[0];
38480 return {"el": el, "close": close, "inner": inner};
38483 // not sure what this is..
38484 // if(!this.tabTpl){
38485 //this.tabTpl = new Roo.Template(
38486 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38487 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38489 // this.tabTpl = new Roo.Template(
38490 // '<a href="#">' +
38491 // '<span unselectable="on"' +
38492 // (this.disableTooltips ? '' : ' title="{text}"') +
38493 // ' >{text}</span></a>'
38499 var template = tpl || this.tabTpl || false;
38502 template = new Roo.Template(
38503 Roo.bootstrap.version == 4 ?
38505 '<a class="nav-link" href="#" unselectable="on"' +
38506 (this.disableTooltips ? '' : ' title="{text}"') +
38509 '<a class="nav-link" href="#">' +
38510 '<span unselectable="on"' +
38511 (this.disableTooltips ? '' : ' title="{text}"') +
38512 ' >{text}</span></a>'
38517 switch (typeof(template)) {
38521 template = new Roo.Template(template);
38527 var el = template.overwrite(td, {"text": text});
38529 var inner = el.getElementsByTagName("span")[0];
38531 return {"el": el, "inner": inner};
38539 * @class Roo.TabPanelItem
38540 * @extends Roo.util.Observable
38541 * Represents an individual item (tab plus body) in a TabPanel.
38542 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38543 * @param {String} id The id of this TabPanelItem
38544 * @param {String} text The text for the tab of this TabPanelItem
38545 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38547 Roo.bootstrap.panel.TabItem = function(config){
38549 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38550 * @type Roo.TabPanel
38552 this.tabPanel = config.panel;
38554 * The id for this TabPanelItem
38557 this.id = config.id;
38559 this.disabled = false;
38561 this.text = config.text;
38563 this.loaded = false;
38564 this.closable = config.closable;
38567 * The body element for this TabPanelItem.
38568 * @type Roo.Element
38570 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38571 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38572 this.bodyEl.setStyle("display", "block");
38573 this.bodyEl.setStyle("zoom", "1");
38574 //this.hideAction();
38576 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38578 this.el = Roo.get(els.el);
38579 this.inner = Roo.get(els.inner, true);
38580 this.textEl = Roo.bootstrap.version == 4 ?
38581 this.el : Roo.get(this.el.dom.firstChild, true);
38583 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38584 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38587 // this.el.on("mousedown", this.onTabMouseDown, this);
38588 this.el.on("click", this.onTabClick, this);
38590 if(config.closable){
38591 var c = Roo.get(els.close, true);
38592 c.dom.title = this.closeText;
38593 c.addClassOnOver("close-over");
38594 c.on("click", this.closeClick, this);
38600 * Fires when this tab becomes the active tab.
38601 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38602 * @param {Roo.TabPanelItem} this
38606 * @event beforeclose
38607 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38608 * @param {Roo.TabPanelItem} this
38609 * @param {Object} e Set cancel to true on this object to cancel the close.
38611 "beforeclose": true,
38614 * Fires when this tab is closed.
38615 * @param {Roo.TabPanelItem} this
38619 * @event deactivate
38620 * Fires when this tab is no longer the active tab.
38621 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38622 * @param {Roo.TabPanelItem} this
38624 "deactivate" : true
38626 this.hidden = false;
38628 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38631 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38633 purgeListeners : function(){
38634 Roo.util.Observable.prototype.purgeListeners.call(this);
38635 this.el.removeAllListeners();
38638 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38641 this.status_node.addClass("active");
38644 this.tabPanel.stripWrap.repaint();
38646 this.fireEvent("activate", this.tabPanel, this);
38650 * Returns true if this tab is the active tab.
38651 * @return {Boolean}
38653 isActive : function(){
38654 return this.tabPanel.getActiveTab() == this;
38658 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38661 this.status_node.removeClass("active");
38663 this.fireEvent("deactivate", this.tabPanel, this);
38666 hideAction : function(){
38667 this.bodyEl.hide();
38668 this.bodyEl.setStyle("position", "absolute");
38669 this.bodyEl.setLeft("-20000px");
38670 this.bodyEl.setTop("-20000px");
38673 showAction : function(){
38674 this.bodyEl.setStyle("position", "relative");
38675 this.bodyEl.setTop("");
38676 this.bodyEl.setLeft("");
38677 this.bodyEl.show();
38681 * Set the tooltip for the tab.
38682 * @param {String} tooltip The tab's tooltip
38684 setTooltip : function(text){
38685 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38686 this.textEl.dom.qtip = text;
38687 this.textEl.dom.removeAttribute('title');
38689 this.textEl.dom.title = text;
38693 onTabClick : function(e){
38694 e.preventDefault();
38695 this.tabPanel.activate(this.id);
38698 onTabMouseDown : function(e){
38699 e.preventDefault();
38700 this.tabPanel.activate(this.id);
38703 getWidth : function(){
38704 return this.inner.getWidth();
38707 setWidth : function(width){
38708 var iwidth = width - this.linode.getPadding("lr");
38709 this.inner.setWidth(iwidth);
38710 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38711 this.linode.setWidth(width);
38715 * Show or hide the tab
38716 * @param {Boolean} hidden True to hide or false to show.
38718 setHidden : function(hidden){
38719 this.hidden = hidden;
38720 this.linode.setStyle("display", hidden ? "none" : "");
38724 * Returns true if this tab is "hidden"
38725 * @return {Boolean}
38727 isHidden : function(){
38728 return this.hidden;
38732 * Returns the text for this tab
38735 getText : function(){
38739 autoSize : function(){
38740 //this.el.beginMeasure();
38741 this.textEl.setWidth(1);
38743 * #2804 [new] Tabs in Roojs
38744 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38746 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38747 //this.el.endMeasure();
38751 * Sets the text for the tab (Note: this also sets the tooltip text)
38752 * @param {String} text The tab's text and tooltip
38754 setText : function(text){
38756 this.textEl.update(text);
38757 this.setTooltip(text);
38758 //if(!this.tabPanel.resizeTabs){
38759 // this.autoSize();
38763 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38765 activate : function(){
38766 this.tabPanel.activate(this.id);
38770 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38772 disable : function(){
38773 if(this.tabPanel.active != this){
38774 this.disabled = true;
38775 this.status_node.addClass("disabled");
38780 * Enables this TabPanelItem if it was previously disabled.
38782 enable : function(){
38783 this.disabled = false;
38784 this.status_node.removeClass("disabled");
38788 * Sets the content for this TabPanelItem.
38789 * @param {String} content The content
38790 * @param {Boolean} loadScripts true to look for and load scripts
38792 setContent : function(content, loadScripts){
38793 this.bodyEl.update(content, loadScripts);
38797 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38798 * @return {Roo.UpdateManager} The UpdateManager
38800 getUpdateManager : function(){
38801 return this.bodyEl.getUpdateManager();
38805 * Set a URL to be used to load the content for this TabPanelItem.
38806 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38807 * @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)
38808 * @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)
38809 * @return {Roo.UpdateManager} The UpdateManager
38811 setUrl : function(url, params, loadOnce){
38812 if(this.refreshDelegate){
38813 this.un('activate', this.refreshDelegate);
38815 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38816 this.on("activate", this.refreshDelegate);
38817 return this.bodyEl.getUpdateManager();
38821 _handleRefresh : function(url, params, loadOnce){
38822 if(!loadOnce || !this.loaded){
38823 var updater = this.bodyEl.getUpdateManager();
38824 updater.update(url, params, this._setLoaded.createDelegate(this));
38829 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38830 * Will fail silently if the setUrl method has not been called.
38831 * This does not activate the panel, just updates its content.
38833 refresh : function(){
38834 if(this.refreshDelegate){
38835 this.loaded = false;
38836 this.refreshDelegate();
38841 _setLoaded : function(){
38842 this.loaded = true;
38846 closeClick : function(e){
38849 this.fireEvent("beforeclose", this, o);
38850 if(o.cancel !== true){
38851 this.tabPanel.removeTab(this.id);
38855 * The text displayed in the tooltip for the close icon.
38858 closeText : "Close this tab"
38861 * This script refer to:
38862 * Title: International Telephone Input
38863 * Author: Jack O'Connor
38864 * Code version: v12.1.12
38865 * Availability: https://github.com/jackocnr/intl-tel-input.git
38868 Roo.bootstrap.PhoneInputData = function() {
38871 "Afghanistan (افغانستان)",
38876 "Albania (Shqipëri)",
38881 "Algeria (الجزائر)",
38906 "Antigua and Barbuda",
38916 "Armenia (Հայաստան)",
38932 "Austria (Österreich)",
38937 "Azerbaijan (Azərbaycan)",
38947 "Bahrain (البحرين)",
38952 "Bangladesh (বাংলাদেশ)",
38962 "Belarus (Беларусь)",
38967 "Belgium (België)",
38997 "Bosnia and Herzegovina (Босна и Херцеговина)",
39012 "British Indian Ocean Territory",
39017 "British Virgin Islands",
39027 "Bulgaria (България)",
39037 "Burundi (Uburundi)",
39042 "Cambodia (កម្ពុជា)",
39047 "Cameroon (Cameroun)",
39056 ["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"]
39059 "Cape Verde (Kabu Verdi)",
39064 "Caribbean Netherlands",
39075 "Central African Republic (République centrafricaine)",
39095 "Christmas Island",
39101 "Cocos (Keeling) Islands",
39112 "Comoros (جزر القمر)",
39117 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39122 "Congo (Republic) (Congo-Brazzaville)",
39142 "Croatia (Hrvatska)",
39163 "Czech Republic (Česká republika)",
39168 "Denmark (Danmark)",
39183 "Dominican Republic (República Dominicana)",
39187 ["809", "829", "849"]
39205 "Equatorial Guinea (Guinea Ecuatorial)",
39225 "Falkland Islands (Islas Malvinas)",
39230 "Faroe Islands (Føroyar)",
39251 "French Guiana (Guyane française)",
39256 "French Polynesia (Polynésie française)",
39271 "Georgia (საქართველო)",
39276 "Germany (Deutschland)",
39296 "Greenland (Kalaallit Nunaat)",
39333 "Guinea-Bissau (Guiné Bissau)",
39358 "Hungary (Magyarország)",
39363 "Iceland (Ísland)",
39383 "Iraq (العراق)",
39399 "Israel (ישראל)",
39426 "Jordan (الأردن)",
39431 "Kazakhstan (Казахстан)",
39452 "Kuwait (الكويت)",
39457 "Kyrgyzstan (Кыргызстан)",
39467 "Latvia (Latvija)",
39472 "Lebanon (لبنان)",
39487 "Libya (ليبيا)",
39497 "Lithuania (Lietuva)",
39512 "Macedonia (FYROM) (Македонија)",
39517 "Madagascar (Madagasikara)",
39547 "Marshall Islands",
39557 "Mauritania (موريتانيا)",
39562 "Mauritius (Moris)",
39583 "Moldova (Republica Moldova)",
39593 "Mongolia (Монгол)",
39598 "Montenegro (Crna Gora)",
39608 "Morocco (المغرب)",
39614 "Mozambique (Moçambique)",
39619 "Myanmar (Burma) (မြန်မာ)",
39624 "Namibia (Namibië)",
39639 "Netherlands (Nederland)",
39644 "New Caledonia (Nouvelle-Calédonie)",
39679 "North Korea (조선 민주주의 인민 공화국)",
39684 "Northern Mariana Islands",
39700 "Pakistan (پاکستان)",
39710 "Palestine (فلسطين)",
39720 "Papua New Guinea",
39762 "Réunion (La Réunion)",
39768 "Romania (România)",
39784 "Saint Barthélemy",
39795 "Saint Kitts and Nevis",
39805 "Saint Martin (Saint-Martin (partie française))",
39811 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39816 "Saint Vincent and the Grenadines",
39831 "São Tomé and Príncipe (São Tomé e Príncipe)",
39836 "Saudi Arabia (المملكة العربية السعودية)",
39841 "Senegal (Sénégal)",
39871 "Slovakia (Slovensko)",
39876 "Slovenia (Slovenija)",
39886 "Somalia (Soomaaliya)",
39896 "South Korea (대한민국)",
39901 "South Sudan (جنوب السودان)",
39911 "Sri Lanka (ශ්රී ලංකාව)",
39916 "Sudan (السودان)",
39926 "Svalbard and Jan Mayen",
39937 "Sweden (Sverige)",
39942 "Switzerland (Schweiz)",
39947 "Syria (سوريا)",
39992 "Trinidad and Tobago",
39997 "Tunisia (تونس)",
40002 "Turkey (Türkiye)",
40012 "Turks and Caicos Islands",
40022 "U.S. Virgin Islands",
40032 "Ukraine (Україна)",
40037 "United Arab Emirates (الإمارات العربية المتحدة)",
40059 "Uzbekistan (Oʻzbekiston)",
40069 "Vatican City (Città del Vaticano)",
40080 "Vietnam (Việt Nam)",
40085 "Wallis and Futuna (Wallis-et-Futuna)",
40090 "Western Sahara (الصحراء الغربية)",
40096 "Yemen (اليمن)",
40120 * This script refer to:
40121 * Title: International Telephone Input
40122 * Author: Jack O'Connor
40123 * Code version: v12.1.12
40124 * Availability: https://github.com/jackocnr/intl-tel-input.git
40128 * @class Roo.bootstrap.PhoneInput
40129 * @extends Roo.bootstrap.TriggerField
40130 * An input with International dial-code selection
40132 * @cfg {String} defaultDialCode default '+852'
40133 * @cfg {Array} preferedCountries default []
40136 * Create a new PhoneInput.
40137 * @param {Object} config Configuration options
40140 Roo.bootstrap.PhoneInput = function(config) {
40141 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40144 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40146 listWidth: undefined,
40148 selectedClass: 'active',
40150 invalidClass : "has-warning",
40152 validClass: 'has-success',
40154 allowed: '0123456789',
40159 * @cfg {String} defaultDialCode The default dial code when initializing the input
40161 defaultDialCode: '+852',
40164 * @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
40166 preferedCountries: false,
40168 getAutoCreate : function()
40170 var data = Roo.bootstrap.PhoneInputData();
40171 var align = this.labelAlign || this.parentLabelAlign();
40174 this.allCountries = [];
40175 this.dialCodeMapping = [];
40177 for (var i = 0; i < data.length; i++) {
40179 this.allCountries[i] = {
40183 priority: c[3] || 0,
40184 areaCodes: c[4] || null
40186 this.dialCodeMapping[c[2]] = {
40189 priority: c[3] || 0,
40190 areaCodes: c[4] || null
40202 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40203 maxlength: this.max_length,
40204 cls : 'form-control tel-input',
40205 autocomplete: 'new-password'
40208 var hiddenInput = {
40211 cls: 'hidden-tel-input'
40215 hiddenInput.name = this.name;
40218 if (this.disabled) {
40219 input.disabled = true;
40222 var flag_container = {
40239 cls: this.hasFeedback ? 'has-feedback' : '',
40245 cls: 'dial-code-holder',
40252 cls: 'roo-select2-container input-group',
40259 if (this.fieldLabel.length) {
40262 tooltip: 'This field is required'
40268 cls: 'control-label',
40274 html: this.fieldLabel
40277 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40283 if(this.indicatorpos == 'right') {
40284 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40291 if(align == 'left') {
40299 if(this.labelWidth > 12){
40300 label.style = "width: " + this.labelWidth + 'px';
40302 if(this.labelWidth < 13 && this.labelmd == 0){
40303 this.labelmd = this.labelWidth;
40305 if(this.labellg > 0){
40306 label.cls += ' col-lg-' + this.labellg;
40307 input.cls += ' col-lg-' + (12 - this.labellg);
40309 if(this.labelmd > 0){
40310 label.cls += ' col-md-' + this.labelmd;
40311 container.cls += ' col-md-' + (12 - this.labelmd);
40313 if(this.labelsm > 0){
40314 label.cls += ' col-sm-' + this.labelsm;
40315 container.cls += ' col-sm-' + (12 - this.labelsm);
40317 if(this.labelxs > 0){
40318 label.cls += ' col-xs-' + this.labelxs;
40319 container.cls += ' col-xs-' + (12 - this.labelxs);
40329 var settings = this;
40331 ['xs','sm','md','lg'].map(function(size){
40332 if (settings[size]) {
40333 cfg.cls += ' col-' + size + '-' + settings[size];
40337 this.store = new Roo.data.Store({
40338 proxy : new Roo.data.MemoryProxy({}),
40339 reader : new Roo.data.JsonReader({
40350 'name' : 'dialCode',
40354 'name' : 'priority',
40358 'name' : 'areaCodes',
40365 if(!this.preferedCountries) {
40366 this.preferedCountries = [
40373 var p = this.preferedCountries.reverse();
40376 for (var i = 0; i < p.length; i++) {
40377 for (var j = 0; j < this.allCountries.length; j++) {
40378 if(this.allCountries[j].iso2 == p[i]) {
40379 var t = this.allCountries[j];
40380 this.allCountries.splice(j,1);
40381 this.allCountries.unshift(t);
40387 this.store.proxy.data = {
40389 data: this.allCountries
40395 initEvents : function()
40398 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40400 this.indicator = this.indicatorEl();
40401 this.flag = this.flagEl();
40402 this.dialCodeHolder = this.dialCodeHolderEl();
40404 this.trigger = this.el.select('div.flag-box',true).first();
40405 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40410 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40411 _this.list.setWidth(lw);
40414 this.list.on('mouseover', this.onViewOver, this);
40415 this.list.on('mousemove', this.onViewMove, this);
40416 this.inputEl().on("keyup", this.onKeyUp, this);
40417 this.inputEl().on("keypress", this.onKeyPress, this);
40419 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40421 this.view = new Roo.View(this.list, this.tpl, {
40422 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40425 this.view.on('click', this.onViewClick, this);
40426 this.setValue(this.defaultDialCode);
40429 onTriggerClick : function(e)
40431 Roo.log('trigger click');
40436 if(this.isExpanded()){
40438 this.hasFocus = false;
40440 this.store.load({});
40441 this.hasFocus = true;
40446 isExpanded : function()
40448 return this.list.isVisible();
40451 collapse : function()
40453 if(!this.isExpanded()){
40457 Roo.get(document).un('mousedown', this.collapseIf, this);
40458 Roo.get(document).un('mousewheel', this.collapseIf, this);
40459 this.fireEvent('collapse', this);
40463 expand : function()
40467 if(this.isExpanded() || !this.hasFocus){
40471 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40472 this.list.setWidth(lw);
40475 this.restrictHeight();
40477 Roo.get(document).on('mousedown', this.collapseIf, this);
40478 Roo.get(document).on('mousewheel', this.collapseIf, this);
40480 this.fireEvent('expand', this);
40483 restrictHeight : function()
40485 this.list.alignTo(this.inputEl(), this.listAlign);
40486 this.list.alignTo(this.inputEl(), this.listAlign);
40489 onViewOver : function(e, t)
40491 if(this.inKeyMode){
40494 var item = this.view.findItemFromChild(t);
40497 var index = this.view.indexOf(item);
40498 this.select(index, false);
40503 onViewClick : function(view, doFocus, el, e)
40505 var index = this.view.getSelectedIndexes()[0];
40507 var r = this.store.getAt(index);
40510 this.onSelect(r, index);
40512 if(doFocus !== false && !this.blockFocus){
40513 this.inputEl().focus();
40517 onViewMove : function(e, t)
40519 this.inKeyMode = false;
40522 select : function(index, scrollIntoView)
40524 this.selectedIndex = index;
40525 this.view.select(index);
40526 if(scrollIntoView !== false){
40527 var el = this.view.getNode(index);
40529 this.list.scrollChildIntoView(el, false);
40534 createList : function()
40536 this.list = Roo.get(document.body).createChild({
40538 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40539 style: 'display:none'
40542 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40545 collapseIf : function(e)
40547 var in_combo = e.within(this.el);
40548 var in_list = e.within(this.list);
40549 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40551 if (in_combo || in_list || is_list) {
40557 onSelect : function(record, index)
40559 if(this.fireEvent('beforeselect', this, record, index) !== false){
40561 this.setFlagClass(record.data.iso2);
40562 this.setDialCode(record.data.dialCode);
40563 this.hasFocus = false;
40565 this.fireEvent('select', this, record, index);
40569 flagEl : function()
40571 var flag = this.el.select('div.flag',true).first();
40578 dialCodeHolderEl : function()
40580 var d = this.el.select('input.dial-code-holder',true).first();
40587 setDialCode : function(v)
40589 this.dialCodeHolder.dom.value = '+'+v;
40592 setFlagClass : function(n)
40594 this.flag.dom.className = 'flag '+n;
40597 getValue : function()
40599 var v = this.inputEl().getValue();
40600 if(this.dialCodeHolder) {
40601 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40606 setValue : function(v)
40608 var d = this.getDialCode(v);
40610 //invalid dial code
40611 if(v.length == 0 || !d || d.length == 0) {
40613 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40614 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40620 this.setFlagClass(this.dialCodeMapping[d].iso2);
40621 this.setDialCode(d);
40622 this.inputEl().dom.value = v.replace('+'+d,'');
40623 this.hiddenEl().dom.value = this.getValue();
40628 getDialCode : function(v)
40632 if (v.length == 0) {
40633 return this.dialCodeHolder.dom.value;
40637 if (v.charAt(0) != "+") {
40640 var numericChars = "";
40641 for (var i = 1; i < v.length; i++) {
40642 var c = v.charAt(i);
40645 if (this.dialCodeMapping[numericChars]) {
40646 dialCode = v.substr(1, i);
40648 if (numericChars.length == 4) {
40658 this.setValue(this.defaultDialCode);
40662 hiddenEl : function()
40664 return this.el.select('input.hidden-tel-input',true).first();
40667 // after setting val
40668 onKeyUp : function(e){
40669 this.setValue(this.getValue());
40672 onKeyPress : function(e){
40673 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40680 * @class Roo.bootstrap.MoneyField
40681 * @extends Roo.bootstrap.ComboBox
40682 * Bootstrap MoneyField class
40685 * Create a new MoneyField.
40686 * @param {Object} config Configuration options
40689 Roo.bootstrap.MoneyField = function(config) {
40691 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40695 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40698 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40700 allowDecimals : true,
40702 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40704 decimalSeparator : ".",
40706 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40708 decimalPrecision : 0,
40710 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40712 allowNegative : true,
40714 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40718 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40720 minValue : Number.NEGATIVE_INFINITY,
40722 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40724 maxValue : Number.MAX_VALUE,
40726 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40728 minText : "The minimum value for this field is {0}",
40730 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40732 maxText : "The maximum value for this field is {0}",
40734 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40735 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40737 nanText : "{0} is not a valid number",
40739 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40743 * @cfg {String} defaults currency of the MoneyField
40744 * value should be in lkey
40746 defaultCurrency : false,
40748 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40750 thousandsDelimiter : false,
40752 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40763 getAutoCreate : function()
40765 var align = this.labelAlign || this.parentLabelAlign();
40777 cls : 'form-control roo-money-amount-input',
40778 autocomplete: 'new-password'
40781 var hiddenInput = {
40785 cls: 'hidden-number-input'
40788 if(this.max_length) {
40789 input.maxlength = this.max_length;
40793 hiddenInput.name = this.name;
40796 if (this.disabled) {
40797 input.disabled = true;
40800 var clg = 12 - this.inputlg;
40801 var cmd = 12 - this.inputmd;
40802 var csm = 12 - this.inputsm;
40803 var cxs = 12 - this.inputxs;
40807 cls : 'row roo-money-field',
40811 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40815 cls: 'roo-select2-container input-group',
40819 cls : 'form-control roo-money-currency-input',
40820 autocomplete: 'new-password',
40822 name : this.currencyName
40826 cls : 'input-group-addon',
40840 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40844 cls: this.hasFeedback ? 'has-feedback' : '',
40855 if (this.fieldLabel.length) {
40858 tooltip: 'This field is required'
40864 cls: 'control-label',
40870 html: this.fieldLabel
40873 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40879 if(this.indicatorpos == 'right') {
40880 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40887 if(align == 'left') {
40895 if(this.labelWidth > 12){
40896 label.style = "width: " + this.labelWidth + 'px';
40898 if(this.labelWidth < 13 && this.labelmd == 0){
40899 this.labelmd = this.labelWidth;
40901 if(this.labellg > 0){
40902 label.cls += ' col-lg-' + this.labellg;
40903 input.cls += ' col-lg-' + (12 - this.labellg);
40905 if(this.labelmd > 0){
40906 label.cls += ' col-md-' + this.labelmd;
40907 container.cls += ' col-md-' + (12 - this.labelmd);
40909 if(this.labelsm > 0){
40910 label.cls += ' col-sm-' + this.labelsm;
40911 container.cls += ' col-sm-' + (12 - this.labelsm);
40913 if(this.labelxs > 0){
40914 label.cls += ' col-xs-' + this.labelxs;
40915 container.cls += ' col-xs-' + (12 - this.labelxs);
40926 var settings = this;
40928 ['xs','sm','md','lg'].map(function(size){
40929 if (settings[size]) {
40930 cfg.cls += ' col-' + size + '-' + settings[size];
40937 initEvents : function()
40939 this.indicator = this.indicatorEl();
40941 this.initCurrencyEvent();
40943 this.initNumberEvent();
40946 initCurrencyEvent : function()
40949 throw "can not find store for combo";
40952 this.store = Roo.factory(this.store, Roo.data);
40953 this.store.parent = this;
40957 this.triggerEl = this.el.select('.input-group-addon', true).first();
40959 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40964 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40965 _this.list.setWidth(lw);
40968 this.list.on('mouseover', this.onViewOver, this);
40969 this.list.on('mousemove', this.onViewMove, this);
40970 this.list.on('scroll', this.onViewScroll, this);
40973 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40976 this.view = new Roo.View(this.list, this.tpl, {
40977 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40980 this.view.on('click', this.onViewClick, this);
40982 this.store.on('beforeload', this.onBeforeLoad, this);
40983 this.store.on('load', this.onLoad, this);
40984 this.store.on('loadexception', this.onLoadException, this);
40986 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40987 "up" : function(e){
40988 this.inKeyMode = true;
40992 "down" : function(e){
40993 if(!this.isExpanded()){
40994 this.onTriggerClick();
40996 this.inKeyMode = true;
41001 "enter" : function(e){
41004 if(this.fireEvent("specialkey", this, e)){
41005 this.onViewClick(false);
41011 "esc" : function(e){
41015 "tab" : function(e){
41018 if(this.fireEvent("specialkey", this, e)){
41019 this.onViewClick(false);
41027 doRelay : function(foo, bar, hname){
41028 if(hname == 'down' || this.scope.isExpanded()){
41029 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41037 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41041 initNumberEvent : function(e)
41043 this.inputEl().on("keydown" , this.fireKey, this);
41044 this.inputEl().on("focus", this.onFocus, this);
41045 this.inputEl().on("blur", this.onBlur, this);
41047 this.inputEl().relayEvent('keyup', this);
41049 if(this.indicator){
41050 this.indicator.addClass('invisible');
41053 this.originalValue = this.getValue();
41055 if(this.validationEvent == 'keyup'){
41056 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41057 this.inputEl().on('keyup', this.filterValidation, this);
41059 else if(this.validationEvent !== false){
41060 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41063 if(this.selectOnFocus){
41064 this.on("focus", this.preFocus, this);
41067 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41068 this.inputEl().on("keypress", this.filterKeys, this);
41070 this.inputEl().relayEvent('keypress', this);
41073 var allowed = "0123456789";
41075 if(this.allowDecimals){
41076 allowed += this.decimalSeparator;
41079 if(this.allowNegative){
41083 if(this.thousandsDelimiter) {
41087 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41089 var keyPress = function(e){
41091 var k = e.getKey();
41093 var c = e.getCharCode();
41096 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41097 allowed.indexOf(String.fromCharCode(c)) === -1
41103 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41107 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41112 this.inputEl().on("keypress", keyPress, this);
41116 onTriggerClick : function(e)
41123 this.loadNext = false;
41125 if(this.isExpanded()){
41130 this.hasFocus = true;
41132 if(this.triggerAction == 'all') {
41133 this.doQuery(this.allQuery, true);
41137 this.doQuery(this.getRawValue());
41140 getCurrency : function()
41142 var v = this.currencyEl().getValue();
41147 restrictHeight : function()
41149 this.list.alignTo(this.currencyEl(), this.listAlign);
41150 this.list.alignTo(this.currencyEl(), this.listAlign);
41153 onViewClick : function(view, doFocus, el, e)
41155 var index = this.view.getSelectedIndexes()[0];
41157 var r = this.store.getAt(index);
41160 this.onSelect(r, index);
41164 onSelect : function(record, index){
41166 if(this.fireEvent('beforeselect', this, record, index) !== false){
41168 this.setFromCurrencyData(index > -1 ? record.data : false);
41172 this.fireEvent('select', this, record, index);
41176 setFromCurrencyData : function(o)
41180 this.lastCurrency = o;
41182 if (this.currencyField) {
41183 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41185 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41188 this.lastSelectionText = currency;
41190 //setting default currency
41191 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41192 this.setCurrency(this.defaultCurrency);
41196 this.setCurrency(currency);
41199 setFromData : function(o)
41203 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41205 this.setFromCurrencyData(c);
41210 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41212 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41215 this.setValue(value);
41219 setCurrency : function(v)
41221 this.currencyValue = v;
41224 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41229 setValue : function(v)
41231 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41237 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41239 this.inputEl().dom.value = (v == '') ? '' :
41240 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41242 if(!this.allowZero && v === '0') {
41243 this.hiddenEl().dom.value = '';
41244 this.inputEl().dom.value = '';
41251 getRawValue : function()
41253 var v = this.inputEl().getValue();
41258 getValue : function()
41260 return this.fixPrecision(this.parseValue(this.getRawValue()));
41263 parseValue : function(value)
41265 if(this.thousandsDelimiter) {
41267 r = new RegExp(",", "g");
41268 value = value.replace(r, "");
41271 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41272 return isNaN(value) ? '' : value;
41276 fixPrecision : function(value)
41278 if(this.thousandsDelimiter) {
41280 r = new RegExp(",", "g");
41281 value = value.replace(r, "");
41284 var nan = isNaN(value);
41286 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41287 return nan ? '' : value;
41289 return parseFloat(value).toFixed(this.decimalPrecision);
41292 decimalPrecisionFcn : function(v)
41294 return Math.floor(v);
41297 validateValue : function(value)
41299 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41303 var num = this.parseValue(value);
41306 this.markInvalid(String.format(this.nanText, value));
41310 if(num < this.minValue){
41311 this.markInvalid(String.format(this.minText, this.minValue));
41315 if(num > this.maxValue){
41316 this.markInvalid(String.format(this.maxText, this.maxValue));
41323 validate : function()
41325 if(this.disabled || this.allowBlank){
41330 var currency = this.getCurrency();
41332 if(this.validateValue(this.getRawValue()) && currency.length){
41337 this.markInvalid();
41341 getName: function()
41346 beforeBlur : function()
41352 var v = this.parseValue(this.getRawValue());
41359 onBlur : function()
41363 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41364 //this.el.removeClass(this.focusClass);
41367 this.hasFocus = false;
41369 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41373 var v = this.getValue();
41375 if(String(v) !== String(this.startValue)){
41376 this.fireEvent('change', this, v, this.startValue);
41379 this.fireEvent("blur", this);
41382 inputEl : function()
41384 return this.el.select('.roo-money-amount-input', true).first();
41387 currencyEl : function()
41389 return this.el.select('.roo-money-currency-input', true).first();
41392 hiddenEl : function()
41394 return this.el.select('input.hidden-number-input',true).first();